clang
17.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/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 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. More... | |
static unsigned | ProcessCharEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, bool &HadError, FullSourceLoc Loc, unsigned CharWidth, DiagnosticsEngine *Diags, const LangOptions &Features) |
ProcessCharEscape - Parse a standard C escape sequence, which can occur in either a character or a string literal. More... | |
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. More... | |
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. More... | |
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. More... | |
static bool | alwaysFitsInto64Bits (unsigned Radix, unsigned NumDigits) |
static bool | IsExponentPart (char c) |
static const char * | resyncUTF8 (const char *Err, const char *End) |
Definition at line 1341 of file LiteralSupport.cpp.
Referenced by clang::NumericLiteralParser::GetFixedPointValue(), and clang::NumericLiteralParser::GetIntegerValue().
|
static |
Definition at line 323 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 79 of file LiteralSupport.cpp.
References clang::Lexer::AdvanceToTokenCharacter(), Begin, clang::FullSourceLoc::getManager(), MakeCharSourceRange(), and clang::DiagnosticsEngine::Report().
Referenced by clang::Sema::ActOnCapScopeReturnStmt(), clang::Sema::ActOnCaseStmt(), clang::Sema::ActOnCompoundStmt(), clang::Sema::ActOnCXXForRangeDecl(), clang::Sema::ActOnCXXTryBlock(), clang::Sema::ActOnCXXTypeid(), clang::Sema::ActOnDefaultStmt(), clang::Sema::ActOnDependentMemberExpr(), clang::Sema::ActOnFinishFunctionBody(), clang::Sema::ActOnFinishSwitchStmt(), clang::Sema::ActOnForEachDeclStmt(), clang::Sema::ActOnForStmt(), clang::Sema::ActOnGCCAsmStmt(), clang::Sema::ActOnLabelStmt(), clang::Sema::ActOnModuleDecl(), clang::Sema::ActOnModuleImport(), clang::Sema::ActOnMSAsmStmt(), clang::Sema::ActOnMSVCUnknownTypeName(), clang::Sema::ActOnObjCAtSynchronizedOperand(), clang::Sema::ActOnObjCAtThrowStmt(), clang::Sema::ActOnObjCAtTryStmt(), clang::Sema::ActOnObjCForCollectionStmt(), clang::Sema::ActOnPrivateModuleFragmentDecl(), clang::Sema::ActOnSEHExceptBlock(), clang::Sema::ActOnSEHLeaveStmt(), clang::Sema::ActOnSEHTryBlock(), clang::Sema::ActOnStartOfFunctionDef(), clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnStartOfSwitchStmt(), clang::Sema::ActOnStringLiteral(), clang::Sema::ActOnTagTemplateIdType(), clang::Sema::ActOnTemplateParameterList(), clang::Sema::ActOnUninitializedDecl(), clang::Sema::AddAlignedAttr(), clang::Sema::AddAlignValueAttr(), clang::Sema::AddAllocAlignAttr(), clang::Sema::AddAssumeAlignedAttr(), addConstraintSatisfaction(), clang::Sema::AddInitializerToDecl(), clang::Sema::addLambdaParameters(), clang::interp::State::addNotes(), clang::Sema::AddParameterABIAttr(), applyEditsToTemp(), clang::Sema::AttachTypeConstraint(), clang::Sema::BuildAtomicExpr(), clang::Sema::BuildCXXThrow(), clang::Sema::BuildCXXTypeId(), clang::Sema::BuildCXXUuidof(), clang::Sema::BuildDeclaratorGroup(), clang::Sema::BuildLambdaExpr(), clang::Sema::buildLambdaInitCaptureInitialization(), clang::Sema::BuildObjCArrayLiteral(), clang::Sema::BuildObjCAtThrowStmt(), clang::Sema::BuildObjCBoxedExpr(), clang::Sema::BuildObjCDictionaryLiteral(), clang::Sema::BuildQualifiedTemplateIdExpr(), clang::Sema::BuildReturnStmt(), clang::Sema::BuildTypeConstraint(), clang::Sema::BuildUnresolvedCoawaitExpr(), clang::interp::State::CCEDiag(), clang::Sema::CheckAlignasUnderalignment(), clang::Sema::CheckAttrTarget(), clang::Sema::CheckCallingConvAttr(), clang::Sema::CheckCastAlign(), clang::Sema::CheckCompletedCoroutineBody(), clang::Sema::CheckCompleteVariableDeclaration(), clang::Sema::CheckConceptRedefinition(), clang::Sema::CheckConstraintExpression(), clang::Sema::CheckCXXThrowOperand(), clang::Sema::CheckDeductionGuideTemplate(), clang::Sema::CheckDependentFunctionTemplateSpecialization(), clang::Sema::CheckEnumConstant(), clang::Sema::CheckEnumRedeclaration(), clang::Sema::CheckEnumUnderlyingType(), clang::Sema::checkFinalSuspendNoThrow(), clang::Sema::CheckFloatComparison(), clang::Sema::CheckForFunctionRedefinition(), clang::Sema::CheckHLSLEntryPoint(), checkIntToPointerCast(), clang::Sema::CheckMain(), clang::Sema::CheckMemberSpecialization(), clang::Sema::checkMSInheritanceAttrOnDefinition(), clang::Sema::CheckNontrivialField(), clang::Sema::CheckNonTypeTemplateParameterType(), clang::Sema::checkNSReturnsRetainedReturnType(), clang::Sema::CheckObjCForCollectionOperand(), clang::Sema::CheckParmsForFunctionDef(), clang::Sema::CheckPointerConversion(), clang::Sema::checkPseudoObjectIncDec(), clang::Sema::CheckRedeclarationModuleOwnership(), clang::Sema::CheckRegparmAttr(), clang::Sema::checkSectionName(), clang::Sema::CheckShadowingDeclModification(), clang::Sema::CheckSpecializationInstantiationRedecl(), clang::Sema::checkStringLiteralArgumentAttr(), clang::Sema::CheckSubscriptingKind(), clang::Sema::checkTargetAttr(), clang::Sema::checkTargetClonesAttrString(), clang::Sema::checkTargetVersionAttr(), clang::Sema::CheckTemplateArgument(), clang::Sema::CheckTemplateArgumentList(), clang::Sema::CheckTemplateParameterList(), clang::Sema::CheckThreadLocalForLargeAlignment(), clang::Sema::checkUnsafeExprAssigns(), clang::Sema::checkVarDeclRedefinition(), clang::Sema::CheckVariableDeclarationType(), clang::Sema::checkVariadicArgument(), clang::Sema::CheckVarTemplateId(), clang::computeDependence(), createResult(), createThreadFlows(), clang::Sema::deduceClosureReturnType(), clang::Sema::DeduceFunctionTypeFromReturnExpr(), clang::Sema::DefaultLvalueConversion(), clang::DeductionFailureInfo::Destroy(), clang::Sema::DiagnoseAlwaysNonNullPointer(), clang::Sema::DiagnoseAssignmentEnum(), clang::Sema::DiagnoseDependentMemberLookup(), clang::Sema::DiagnoseEmptyStmtBody(), clang::Sema::DiagnoseFunctionSpecifiers(), clang::Sema::DiagnoseMisalignedMembers(), clang::ODRDiagsEmitter::diagnoseMismatch(), clang::Sema::DiagnoseSelfMove(), clang::Sema::DiagnoseSentinelCalls(), clang::Sema::DiagnoseShadowingLambdaDecls(), clang::Sema::DiagnoseTemplateParameterShadow(), clang::Sema::DiagnoseUninstantiableTemplate(), clang::Sema::DiagnoseUnusedDecl(), clang::Sema::DiagnoseUnusedLambdaCapture(), clang::Sema::DiagnoseUnusedNestedTypedefs(), clang::Sema::DiagnoseUnusedParameters(), clang::Sema::DiagnoseUseOfDecl(), clang::SARIFDiagnostic::emitDiagnosticMessage(), clang::DiagnosticRenderer::emitStoredDiagnostic(), clang::Sema::EnsureTemplateArgumentListConstraints(), EvaluateFeatureLikeBuiltinMacro(), clang::Expr::EvaluateKnownConstInt(), clang::Expr::EvaluateKnownConstIntCheckOverflow(), clang::interp::State::FFDiag(), clang::Sema::FinalizeDeclaration(), clang::TextDiagnosticBuffer::FlushDiagnostics(), clang::arcmt::FileRemapper::flushToDisk(), clang::arcmt::FileRemapper::flushToFile(), clang::Diagnostic::FormatDiagnostic(), clang::SrcMgr::ContentCache::getBufferOrNone(), clang::Sema::getDarwinSDKInfoForAvailabilityChecking(), clang::Sema::getDestructorTypeForDecltype(), clang::DiagnosticIDs::getDiagnosticFlags(), clang::SourceManager::getLineNumber(), clang::SourceManager::getPresumedLoc(), clang::Sema::inferObjCARCLifetime(), clang::arcmt::FileRemapper::initFromDisk(), clang::arcmt::FileRemapper::initFromFile(), clang::Sema::isIncompatibleTypedef(), clang::Sema::isMemberAccessibleForDeletion(), clang::Sema::IsOverload(), clang::MakeDeductionFailureInfo(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), clang::Sema::MaybeEmitAmbiguousAtomicConstraintsDiagnostic(), clang::Sema::MaybeSuggestAddingStaticToDecl(), clang::Sema::mergeAlwaysInlineAttr(), clang::Sema::mergeAvailabilityAttr(), clang::Sema::mergeDeclAttributes(), clang::Sema::mergeDLLExportAttr(), clang::Sema::mergeDLLImportAttr(), clang::Sema::mergeErrorAttr(), clang::Sema::mergeHLSLNumThreadsAttr(), clang::Sema::mergeHLSLShaderAttr(), clang::Sema::mergeImportModuleAttr(), clang::Sema::mergeImportNameAttr(), clang::Sema::mergeInternalLinkageAttr(), clang::Sema::mergeMinSizeAttr(), clang::Sema::mergeMSInheritanceAttr(), clang::Sema::mergeOptimizeNoneAttr(), clang::Sema::mergeUuidAttr(), clang::Sema::MergeVarDecl(), clang::Sema::NoteDeletedFunction(), clang::Sema::notePreviousDefinition(), clang::arcmt::FileRemapper::overwriteOriginal(), clang::Parser::parseMapperModifier(), clang::Parser::parseMapTypeModifiers(), clang::Parser::ParseOpenMPVarList(), clang::Sema::ProcessAccessDeclAttributeList(), ProcessCharEscape(), ProcessNamedUCNEscape(), ProcessNumericUCNEscape(), ProcessUCNEscape(), clang::ASTReader::ReadPragmaDiagnosticMappings(), rejectConstNotMutableType(), reportDiag(), clang::Sema::RequireStructuralType(), clang::runWithSufficientStackSpace(), clang::runWithSufficientStackSpaceSlow(), clang::Sema::SemaBuiltinShuffleVector(), clang::Sema::SemaConvertVectorExpr(), clang::DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(), clang::DiagnosticsEngine::setDiagnosticGroupWarningAsError(), clang::Sema::SetMemberAccessSpecifier(), clang::DiagnosticsEngine::setSeverity(), clang::DiagnosticsEngine::setSeverityForAll(), clang::DiagnosticsEngine::setSeverityForGroup(), clang::Sema::setTagNameForLinkagePurposes(), clang::Sema::TemplateParameterListsAreEqual(), clang::SourceManager::translateLineCol(), TryReinterpretCast(), clang::Sema::tryToFixVariablyModifiedVarType(), clang::Sema::VerifyBitField(), and clang::ento::PathDiagnosticConsumer::~PathDiagnosticConsumer().
|
static |
Definition at line 479 of file LiteralSupport.cpp.
|
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 687 of file LiteralSupport.cpp.
References ProcessUCNEscape().
|
static |
Definition at line 40 of file LiteralSupport.cpp.
References clang::Target.
Referenced by clang::CharLiteralParser::CharLiteralParser(), and clang::targets::X86TargetInfo::X86TargetInfo().
|
inlinestatic |
Definition at line 1438 of file LiteralSupport.cpp.
References c.
Referenced by clang::NumericLiteralParser::GetFixedPointValue().
|
static |
Definition at line 60 of file LiteralSupport.cpp.
References clang::Lexer::AdvanceToTokenCharacter(), Begin, End, clang::CharSourceRange::getCharRange(), and clang::FullSourceLoc::getManager().
Referenced by Diag().
|
static |
MeasureUCNEscape - Determine the number of bytes within the resulting string which this UCN will occupy.
Definition at line 652 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 92 of file LiteralSupport.cpp.
References Diag(), clang::isHexDigit(), clang::isPrintable(), and string().
Referenced by clang::CharLiteralParser::CharLiteralParser(), and clang::StringLiteralParser::getOffsetOfStringByte().
|
static |
Definition at line 534 of file LiteralSupport.cpp.
References AttributeLangSupport::C, Diag(), and clang::isVerticalWhitespace().
Referenced by ProcessUCNEscape().
|
static |
Definition at line 393 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 583 of file LiteralSupport.cpp.
References Diag(), ProcessNamedUCNEscape(), and ProcessNumericUCNEscape().
Referenced by clang::CharLiteralParser::CharLiteralParser(), EncodeUCNEscape(), and MeasureUCNEscape().
|
static |
Definition at line 2147 of file LiteralSupport.cpp.
References End.