clang 22.0.0git
|
#include "clang/Lex/LiteralSupport.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/Token.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Unicode.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
Go to the source code of this file.
Functions | |
static unsigned | getCharWidth (tok::TokenKind kind, const TargetInfo &Target) |
static unsigned | getEncodingPrefixLen (tok::TokenKind kind) |
static CharSourceRange | MakeCharSourceRange (const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd) |
static DiagnosticBuilder | Diag (DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID) |
Produce a diagnostic highlighting some portion of a literal. | |
static bool | IsEscapeValidInUnevaluatedStringLiteral (char Escape) |
static unsigned | ProcessCharEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, bool &HadError, FullSourceLoc Loc, unsigned CharWidth, DiagnosticsEngine *Diags, const LangOptions &Features, StringLiteralEvalMethod EvalMethod) |
ProcessCharEscape - Parse a standard C escape sequence, which can occur in either a character or a string literal. | |
static void | appendCodePoint (unsigned Codepoint, llvm::SmallVectorImpl< char > &Str) |
static bool | ProcessNumericUCNEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, uint32_t &UcnVal, unsigned short &UcnLen, bool &Delimited, FullSourceLoc Loc, DiagnosticsEngine *Diags, const LangOptions &Features, bool in_char_string_literal=false) |
static void | DiagnoseInvalidUnicodeCharacterName (DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc Loc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, llvm::StringRef Name) |
static bool | ProcessNamedUCNEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, uint32_t &UcnVal, unsigned short &UcnLen, FullSourceLoc Loc, DiagnosticsEngine *Diags, const LangOptions &Features) |
static bool | ProcessUCNEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, uint32_t &UcnVal, unsigned short &UcnLen, FullSourceLoc Loc, DiagnosticsEngine *Diags, const LangOptions &Features, bool in_char_string_literal=false) |
ProcessUCNEscape - Read the Universal Character Name, check constraints and return the UTF32. | |
static int | MeasureUCNEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, unsigned CharByteWidth, const LangOptions &Features, bool &HadError) |
MeasureUCNEscape - Determine the number of bytes within the resulting string which this UCN will occupy. | |
static void | EncodeUCNEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, char *&ResultBuf, bool &HadError, FullSourceLoc Loc, unsigned CharByteWidth, DiagnosticsEngine *Diags, const LangOptions &Features) |
EncodeUCNEscape - Read the Universal Character Name, check constraints and convert the UTF32 to UTF8 or UTF16. | |
static bool | alwaysFitsInto64Bits (unsigned Radix, unsigned NumDigits) |
static bool | IsExponentPart (char c, bool isHex) |
static const char * | resyncUTF8 (const char *Err, const char *End) |
Definition at line 1488 of file LiteralSupport.cpp.
Referenced by clang::NumericLiteralParser::GetFixedPointValue(), and clang::NumericLiteralParser::GetIntegerValue().
|
static |
Definition at line 373 of file LiteralSupport.cpp.
Referenced by clang::expandUCNs().
|
static |
Produce a diagnostic highlighting some portion of a literal.
Emits the diagnostic DiagID
, highlighting the range of characters from TokRangeBegin
(inclusive) to TokRangeEnd
(exclusive), which must be a substring of a spelling buffer for the token beginning at TokBegin
.
Definition at line 100 of file LiteralSupport.cpp.
References clang::Lexer::AdvanceToTokenCharacter(), clang::FullSourceLoc::getManager(), MakeCharSourceRange(), and clang::DiagnosticsEngine::Report().
Referenced by clang::Sema::ActOnAliasDeclaration(), clang::Sema::ActOnBaseSpecifier(), clang::Sema::ActOnConversionDeclarator(), clang::Sema::ActOnCXXConditionDeclaration(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnDecompositionDeclarator(), clang::Sema::ActOnDesignatedInitializer(), clang::Sema::ActOnExceptionDeclarator(), clang::Sema::ActOnFinishCXXMemberSpecification(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFriendTypeDecl(), clang::Sema::ActOnMemInitializers(), clang::Sema::ActOnNamespaceAliasDef(), clang::SemaOpenMP::ActOnOpenMPAllocateDirective(), clang::SemaOpenMP::ActOnOpenMPAssumesDirective(), clang::SemaOpenMP::ActOnOpenMPDeclareSimdDirective(), clang::SemaOpenMP::ActOnOpenMPExecutableDirective(), clang::SemaOpenMP::ActOnOpenMPGroupPrivateDirective(), clang::SemaOpenMP::ActOnOpenMPIdExpression(), clang::SemaOpenMP::ActOnOpenMPRegionEnd(), clang::SemaOpenMP::ActOnOpenMPRequiresDirective(), clang::Sema::ActOnParamDefaultArgument(), clang::Sema::ActOnPureSpecifier(), clang::Sema::ActOnStartLinkageSpecification(), clang::Sema::ActOnStartNamespaceDef(), clang::Sema::ActOnTemplatedFriendTag(), clang::Sema::ActOnUsingDeclaration(), clang::Sema::ActOnUsingDirective(), clang::Sema::ActOnUsingEnumDeclaration(), addConstraintSatisfaction(), AddInitializerToDiag(), clang::interp::State::addNotes(), clang::Sema::AttachBaseSpecifiers(), clang::sema::BlockScopeInfo::BlockScopeInfo(), clang::Sema::BuildBaseInitializer(), clang::Sema::BuildCallToMemberFunction(), clang::Sema::BuildCXXMemberCallExpr(), clang::Sema::BuildDelegatingInitializer(), clang::Sema::BuildExceptionDeclaration(), clang::Sema::BuildMemInitializer(), clang::Sema::BuildOverloadedArrowExpr(), clang::Sema::BuildStaticAssertDeclaration(), clang::Sema::BuildStdInitializerList(), clang::Sema::BuildUsingDeclaration(), clang::Sema::BuildUsingEnumDeclaration(), clang::sema::CapturedRegionScopeInfo::CapturedRegionScopeInfo(), clang::sema::CapturingScopeInfo::CapturingScopeInfo(), clang::interp::State::CCEDiag(), checkAttributeNumArgsImpl(), clang::checkAttrMutualExclusion(), checkAVXParam(), checkAVXParamFeature(), clang::Sema::CheckBaseSpecifier(), clang::SemaRISCV::CheckBuiltinFunctionCall(), clang::Sema::checkClassLevelDLLAttribute(), clang::SemaOpenACC::CheckCollapseLoopCount(), clang::Sema::CheckComparisonCategoryType(), clang::Sema::CheckCompletedCXXClass(), clang::Sema::CheckCompleteDecompositionDeclaration(), clang::Sema::CheckConstexprFunctionDefinition(), clang::Sema::CheckConstructor(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckConversionDeclarator(), CheckCXX98CompatAccessibleCopy(), clang::Sema::CheckCXXDefaultArguments(), clang::SemaOpenACC::CheckDeclareClause(), clang::Sema::CheckDeductionGuideDeclarator(), clang::Sema::CheckDerivedToBaseConversion(), clang::Sema::CheckDestructor(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::CheckExplicitlyDefaultedComparison(), clang::Sema::CheckExplicitlyDefaultedSpecialMember(), clang::Sema::CheckExplicitObjectMemberFunction(), clang::Sema::CheckExplicitObjectOverride(), clang::Sema::CheckExtraCXXDefaultArguments(), clang::SemaOpenACC::CheckGangClause(), clang::Sema::CheckIfOverriddenFunctionIsMarkedFinal(), clang::Sema::checkIllFormedTrivialABIStruct(), clang::Sema::CheckImmediateEscalatingFunctionDefinition(), clang::SemaPseudoObject::checkIncDec(), clang::Sema::checkIncorrectVTablePointerAuthenticationAttribute(), clang::Sema::CheckInheritingConstructorUsingDecl(), checkIntToPointerCast(), clang::SemaOpenACC::CheckLinkClauseVarList(), clang::Sema::CheckLiteralOperatorDeclaration(), clang::SemaRISCV::CheckLMUL(), clang::Sema::CheckMemberPointerConversion(), checkMoreSpecializedThanPrimary(), checkNewAttributesAfterDef(), checkNumExprsInClause(), checkObjCPointerIntrospection(), clang::SemaOpenMP::CheckOMPGroupPrivateDecl(), clang::SemaOpenMP::CheckOMPRequiresDecl(), clang::SemaOpenMP::CheckOMPThreadPrivateDecl(), clang::Sema::CheckOverloadedOperatorDeclaration(), clang::Sema::CheckOverrideControl(), clang::Sema::CheckOverridingFunctionAttributes(), clang::Sema::CheckOverridingFunctionReturnType(), clang::Sema::CheckPointerConversion(), clang::Sema::CheckPureMethod(), clang::SemaOpenACC::CheckReductionClause(), clang::SemaOpenACC::CheckReductionVar(), clang::SemaRISCV::checkRVVTypeSupport(), clang::SemaRISCV::checkTargetClonesAttr(), clang::SemaRISCV::checkTargetVersionAttr(), CheckTautologicalComparison(), CheckTemplateSpecializationScope(), clang::SemaOpenACC::CheckTileSizeExpr(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckUsingDeclRedeclaration(), clang::Sema::CheckUsingShadowDecl(), clang_getDiagnosticOption(), clang::ASTUnit::CodeComplete(), collectModuleHeaderIncludes(), clang::computeDependence(), ComputeSelectedDestructor(), clang::Sema::CreateOverloadedBinOp(), createResult(), createThreadFlows(), clang::Sema::DefineImplicitCopyAssignment(), clang::Sema::DefineImplicitLambdaToBlockPointerConversion(), clang::Sema::DefineImplicitMoveAssignment(), clang::Sema::DefineUsedVTables(), clang::DeductionFailureInfo::Destroy(), clang::Sema::DiagnoseAbsenceOfOverrideControl(), clang::Sema::DiagnoseAbstractType(), clang::Sema::diagnoseConflictingFunctionEffect(), clang::Sema::diagnoseEquivalentInternalLinkageDeclarations(), clang::Sema::diagnoseFunctionEffectMergeConflicts(), clang::Sema::DiagnoseHiddenVirtualMethods(), clang::Sema::DiagnoseImmediateEscalatingReason(), diagnoseInstanceReference(), DiagnoseInvalidUnicodeCharacterName(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::Sema::DiagnoseMultipleUserDefinedConversion(), DiagnoseSelfAssignment(), clang::Sema::DiagnoseStaticAssertDetails(), diagnoseUnsatisfiedConstraintExpr(), clang::Sema::DiagPlaceholderVariableDefinition(), clang::Sema::DiagRedefinedPlaceholderFieldDecl(), clang::installapi::DylibVerifier::DylibVerifier(), clang::SARIFDiagnostic::emitDiagnosticMessage(), emitNullabilityConsistencyWarning(), clang::DiagnosticRenderer::emitStoredDiagnostic(), clang::SemaOpenMP::EndOpenMPDSABlock(), clang::Sema::EvaluateConvertedConstantExpression(), EvaluateFeatureLikeBuiltinMacro(), clang::Expr::EvaluateKnownConstIntCheckOverflow(), clang::interp::State::FFDiag(), clang::interp::State::FFDiag(), clang::SemaOpenMP::finalizeOpenMPDelayedAnalysis(), clang::Sema::FinalizeVarWithDestructor(), fixItNullability(), clang::TextDiagnosticBuffer::FlushDiagnostics(), clang::Diagnostic::FormatDiagnostic(), clang::sema::FunctionScopeInfo::FunctionScopeInfo(), clang::SrcMgr::ContentCache::getBufferOrNone(), clang::DiagnosticIDs::getCustomDiagID(), GetFullTypeForDeclarator(), clang::SourceMgrAdapter::handleDiag(), clang::SemaRISCV::handleInterruptAttr(), clang::Sema::HandleMSProperty(), clang::DiagnosticIDs::initCustomDiagMapping(), clang::Sema::InstantiateInClassInitializer(), clang::interp::interp__builtin_is_within_lifetime(), clang::DiagnosticIDs::IsCustomDiag(), IsStructurallyEquivalent(), clang::sema::LambdaScopeInfo::LambdaScopeInfo(), clang::MakeDeductionFailureInfo(), clang::Sema::MergeCXXFunctionDecl(), clang::Sema::NoteHiddenVirtualMethods(), clang::Sema::NoteOverloadCandidate(), clang::SrcMgr::ContentCache::operator=(), clang::Rewriter::overwriteChangedFiles(), clang::Sema::PerformContextuallyConvertToBool(), clang::Sema::PerformImplicitObjectArgumentInitialization(), printDiagnostic(), ProcessCharEscape(), ProcessNamedUCNEscape(), ProcessNumericUCNEscape(), ProcessUCNEscape(), clang::Sema::propagateDLLAttrToBaseClassTemplate(), rejectConstNotMutableType(), clang::Sema::ResolveAndFixSingleFunctionTemplateSpecialization(), clang::Sema::ResolveSingleFunctionTemplateSpecialization(), clang::runWithSufficientStackSpace(), clang::runWithSufficientStackSpaceSlow(), clang::Scope::Scope(), SelectPropertyForSynthesisFromProtocols(), clang::Sema::SetCtorInitializers(), clang::Sema::SetDeclDefaulted(), clang::Sema::SetDeclDeleted(), clang::DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(), clang::DiagnosticsEngine::setDiagnosticGroupWarningAsError(), clang::DiagnosticsEngine::setSeverity(), clang::DiagnosticsEngine::setSeverityForAll(), clang::DiagnosticsEngine::setSeverityForGroup(), clang::Sema::ShouldDeleteSpecialMember(), clang::Sema::SpecialMemberIsTrivial(), clang::StreamingDiagnostic::StreamingDiagnostic(), clang::StreamingDiagnostic::StreamingDiagnostic(), TryReinterpretCast(), and clang::ento::PathDiagnosticConsumer::~PathDiagnosticConsumer().
|
static |
Definition at line 542 of file LiteralSupport.cpp.
References clang::FixItHint::CreateReplacement(), Diag(), MakeCharSourceRange(), clang::Match, and V.
Referenced by ProcessNamedUCNEscape().
|
static |
EncodeUCNEscape - Read the Universal Character Name, check constraints and convert the UTF32 to UTF8 or UTF16.
This is a subroutine of StringLiteralParser. When we decide to implement UCN's for identifiers, we will likely rework our support for UCN's.
Definition at line 753 of file LiteralSupport.cpp.
References ProcessUCNEscape(), clang::UTF32, and clang::UTF8.
|
static |
Definition at line 41 of file LiteralSupport.cpp.
Referenced by clang::CharLiteralParser::CharLiteralParser(), clang::CodeGen::CodeGenFunction::EmitCountedByBoundsChecking(), clang::TargetInfo::getBitIntAlign(), clang::TargetInfo::hasBuiltinAtomic(), and clang::targets::X86TargetInfo::X86TargetInfo().
|
static |
Definition at line 61 of file LiteralSupport.cpp.
|
static |
Definition at line 111 of file LiteralSupport.cpp.
Referenced by ProcessCharEscape().
Definition at line 1585 of file LiteralSupport.cpp.
References c.
Referenced by clang::NumericLiteralParser::GetFixedPointValue().
|
static |
Definition at line 81 of file LiteralSupport.cpp.
References clang::Lexer::AdvanceToTokenCharacter(), clang::CharSourceRange::getCharRange(), and clang::FullSourceLoc::getManager().
Referenced by Diag(), and DiagnoseInvalidUnicodeCharacterName().
|
static |
MeasureUCNEscape - Determine the number of bytes within the resulting string which this UCN will occupy.
Definition at line 718 of file LiteralSupport.cpp.
References ProcessUCNEscape().
Referenced by clang::StringLiteralParser::getOffsetOfStringByte().
|
static |
ProcessCharEscape - Parse a standard C escape sequence, which can occur in either a character or a string literal.
Definition at line 131 of file LiteralSupport.cpp.
References Diag(), clang::Lexer::DiagnoseDelimitedOrNamedEscapeSequence(), IsEscapeValidInUnevaluatedStringLiteral(), clang::isHexDigit(), clang::isPrintable(), and clang::Unevaluated.
Referenced by clang::CharLiteralParser::CharLiteralParser(), and clang::StringLiteralParser::getOffsetOfStringByte().
|
static |
Definition at line 597 of file LiteralSupport.cpp.
References clang::C, Diag(), DiagnoseInvalidUnicodeCharacterName(), clang::Empty, clang::Incomplete, and clang::isVerticalWhitespace().
Referenced by ProcessUCNEscape().
|
static |
Definition at line 456 of file LiteralSupport.cpp.
References Diag(), and clang::isHexDigit().
Referenced by ProcessUCNEscape().
|
static |
ProcessUCNEscape - Read the Universal Character Name, check constraints and return the UTF32.
Definition at line 646 of file LiteralSupport.cpp.
References Diag(), clang::Lexer::DiagnoseDelimitedOrNamedEscapeSequence(), ProcessNamedUCNEscape(), and ProcessNumericUCNEscape().
Referenced by clang::CharLiteralParser::CharLiteralParser(), EncodeUCNEscape(), and MeasureUCNEscape().
|
static |
Definition at line 2323 of file LiteralSupport.cpp.