clang API Documentation

Functions
LiteralSupport.cpp File Reference
#include "clang/Lex/LiteralSupport.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/ErrorHandling.h"
Include dependency graph for LiteralSupport.cpp:

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.
static unsigned ProcessCharEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, bool &HadError, FullSourceLoc Loc, unsigned CharWidth, DiagnosticsEngine *Diags, const LangOptions &Features)
static void appendCodePoint (unsigned Codepoint, llvm::SmallVectorImpl< char > &Str)
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)
static int MeasureUCNEscape (const char *ThisTokBegin, const char *&ThisTokBuf, const char *ThisTokEnd, unsigned CharByteWidth, const LangOptions &Features, bool &HadError)
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)
static bool alwaysFitsInto64Bits (unsigned Radix, unsigned NumDigits)
static const char * resyncUTF8 (const char *Err, const char *End)

Function Documentation

static bool alwaysFitsInto64Bits ( unsigned  Radix,
unsigned  NumDigits 
) [static]

Definition at line 892 of file LiteralSupport.cpp.

Referenced by clang::NumericLiteralParser::GetIntegerValue().

static void appendCodePoint ( unsigned  Codepoint,
llvm::SmallVectorImpl< char > &  Str 
) [static]

Definition at line 216 of file LiteralSupport.cpp.

Referenced by clang::expandUCNs().

static DiagnosticBuilder Diag ( DiagnosticsEngine Diags,
const LangOptions Features,
FullSourceLoc  TokLoc,
const char *  TokBegin,
const char *  TokRangeBegin,
const char *  TokRangeEnd,
unsigned  DiagID 
) [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 65 of file LiteralSupport.cpp.

References clang::Lexer::AdvanceToTokenCharacter(), clang::FullSourceLoc::getManager(), MakeCharSourceRange(), and clang::DiagnosticsEngine::Report().

Referenced by clang::Sema::ActOnAsTypeExpr(), clang::Sema::ActOnBlockArguments(), clang::Sema::ActOnBlockStmtExpr(), clang::Sema::ActOnBreakStmt(), clang::Sema::ActOnCallExpr(), clang::Sema::ActOnCapScopeReturnStmt(), clang::Sema::ActOnCaseStmt(), clang::Sema::ActOnCastExpr(), clang::Sema::ActOnCharacterConstant(), clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnCompoundStmt(), clang::Sema::ActOnContinueStmt(), clang::Sema::ActOnCXXForRangeDecl(), clang::Sema::ActOnCXXForRangeStmt(), clang::Sema::ActOnCXXTryBlock(), clang::Sema::ActOnCXXTypeid(), clang::Sema::ActOnCXXUuidof(), clang::Sema::ActOnDefaultStmt(), clang::Sema::ActOnDelayedDefaultTemplateArg(), clang::Sema::ActOnDependentMemberExpr(), clang::Sema::ActOnDependentTag(), clang::Sema::ActOnDependentTemplateName(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnFields(), clang::Sema::ActOnFinishFunctionBody(), clang::Sema::ActOnFinishKNRParamDeclarations(), clang::Sema::ActOnFinishSwitchStmt(), clang::Sema::ActOnForEachDeclStmt(), clang::Sema::ActOnForStmt(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnGCCAsmStmt(), clang::Sema::ActOnIvar(), clang::Sema::ActOnLabelStmt(), clang::Sema::ActOnMemberAccessExpr(), clang::Sema::ActOnNonTypeTemplateParameter(), clang::Sema::ActOnNumericConstant(), clang::Sema::ActOnObjCAtSynchronizedOperand(), clang::Sema::ActOnObjCAtThrowStmt(), clang::Sema::ActOnObjCAtTryStmt(), clang::Sema::ActOnObjCForCollectionStmt(), clang::Sema::ActOnParamDeclarator(), clang::Sema::ActOnSEHExceptBlock(), clang::Sema::ActOnSEHLeaveStmt(), clang::Sema::ActOnStartOfFunctionDef(), clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnStmtExpr(), clang::Sema::ActOnStringLiteral(), clang::Sema::ActOnTag(), clang::Sema::ActOnTagTemplateIdType(), clang::Sema::ActOnTemplateParameterList(), clang::Sema::ActOnTemplateTemplateParameter(), clang::Sema::ActOnTypedefDeclarator(), clang::Sema::ActOnTypenameType(), clang::Sema::ActOnTypeParameter(), clang::Sema::ActOnUninitializedDecl(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::ActOnVarTemplateSpecialization(), clang::Sema::AddInitializerToDecl(), applyEditsToTemp(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildAnonymousStructUnionMemberReference(), clang::Sema::BuildBuiltinOffsetOf(), clang::Sema::BuildCompoundLiteralExpr(), clang::Sema::BuildCXXDefaultArgExpr(), clang::Sema::BuildCXXForRangeStmt(), clang::Sema::BuildCXXThrow(), clang::Sema::BuildCXXUuidof(), clang::Sema::BuildDeclarationNameExpr(), clang::Sema::BuildDeclaratorGroup(), clang::Sema::BuildDeclRefExpr(), clang::Sema::BuildMemberReferenceExpr(), clang::Sema::BuildObjCArrayLiteral(), clang::Sema::BuildObjCAtThrowStmt(), clang::Sema::BuildObjCBoxedExpr(), clang::Sema::BuildObjCDictionaryLiteral(), clang::Sema::BuildObjCEncodeExpression(), clang::Sema::BuildObjCStringLiteral(), clang::Sema::BuildPossibleImplicitMemberExpr(), clang::Sema::BuildPredefinedExpr(), clang::Sema::BuildQualifiedDeclarationNameExpr(), clang::Sema::BuildQualifiedTemplateIdExpr(), clang::Sema::BuildResolvedCallExpr(), clang::Sema::BuildReturnStmt(), clang::Sema::BuildVAArgExpr(), clang::Sema::BuildVectorLiteral(), clang::Sema::CheckAddressOfOperand(), clang::Sema::CheckAssignmentOperands(), checkAttributeNumArgsImpl(), clang::Sema::CheckCastAlign(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckCompareOperands(), clang::Sema::CheckCompleteVariableDeclaration(), clang::Sema::CheckConditionalOperands(), CheckCXX98CompatAccessibleCopy(), clang::Sema::CheckEnumConstant(), clang::Sema::CheckEnumRedeclaration(), clang::Sema::CheckEnumUnderlyingType(), clang::Sema::CheckExtVectorCast(), clang::Sema::CheckFieldDecl(), clang::Sema::CheckForConstantInitializer(), clang::Sema::CheckForFunctionRedefinition(), CheckForModifiableLvalue(), clang::Sema::CheckFunctionDeclaration(), checkIntToPointerCast(), clang::Sema::checkLiteralOperatorId(), clang::Sema::CheckLogicalOperands(), clang::Sema::CheckLoopHintExpr(), clang::Sema::CheckMain(), clang::Sema::CheckMemberPointerConversion(), clang::Sema::CheckMemberSpecialization(), clang::Sema::CheckMSVCRTEntryPoint(), checkNewAttributesAfterDef(), clang::Sema::CheckNontrivialField(), clang::Sema::CheckNonTypeTemplateParameterType(), clang::Sema::CheckObjCForCollectionOperand(), checkObjCPointerIntrospection(), clang::Sema::CheckParameter(), clang::Sema::CheckParmsForFunctionDef(), clang::Sema::CheckPointerConversion(), clang::Sema::checkPseudoObjectIncDec(), clang::Sema::CheckShadow(), clang::Sema::CheckSingleAssignmentConstraints(), clang::Sema::CheckSpecializationInstantiationRedecl(), clang::Sema::CheckStaticArrayArgument(), clang::Sema::checkStringLiteralArgumentAttr(), clang::Sema::CheckSubscriptingKind(), clang::Sema::CheckSubtractionOperands(), clang::Sema::CheckTemplateArgument(), clang::Sema::CheckTemplateArgumentList(), clang::Sema::CheckTemplateDeclScope(), clang::Sema::CheckTemplateIdType(), clang::Sema::CheckTemplateParameterList(), CheckTemplateSpecializationScope(), clang::Sema::CheckTemplateTypeArgument(), clang::Sema::CheckTypedefForVariablyModifiedType(), clang::Sema::CheckTypenameType(), clang::Sema::CheckUnaryExprOrTypeTraitOperand(), clang::Sema::checkUnsafeExprAssigns(), clang::Sema::CheckVariableDeclarationType(), clang::Sema::checkVariadicArgument(), clang::Sema::CheckVarTemplateId(), clang::Sema::CheckVectorCast(), clang::Sema::CheckVectorOperands(), clang::Sema::ConvertArgumentsForCall(), clang::Sema::CreateBuiltinArraySubscriptExpr(), clang::Sema::CreateBuiltinBinOp(), clang::Sema::CreateBuiltinUnaryOp(), clang::Sema::CreateGenericSelectionExpr(), clang::Sema::CreateUnaryExprOrTypeTraitExpr(), clang::Sema::DeduceAutoType(), clang::Sema::deduceClosureReturnType(), clang::Sema::DeduceFunctionTypeFromReturnExpr(), clang::Sema::DeduceReturnType(), clang::Sema::DefaultFunctionArrayConversion(), clang::Sema::DefaultLvalueConversion(), clang::DeductionFailureInfo::Destroy(), clang::Sema::DiagnoseAlwaysNonNullPointer(), clang::Sema::DiagnoseAmbiguousLookup(), clang::Sema::DiagnoseAssignmentEnum(), clang::Sema::DiagnoseAutoDeductionFailure(), clang::Sema::DiagnoseClassNameShadow(), clang::Sema::DiagnoseConditionalForNull(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::DiagnoseEmptyLoopBody(), clang::Sema::DiagnoseEmptyStmtBody(), clang::Sema::DiagnoseFunctionSpecifiers(), clang::Sema::diagnoseQualifiedDeclaration(), clang::Sema::DiagnoseSentinelCalls(), clang::Sema::DiagnoseSizeOfParametersAndReturnValue(), clang::Sema::DiagnoseTemplateParameterShadow(), clang::Sema::DiagnoseUnknownTemplateName(), clang::Sema::DiagnoseUnknownTypeName(), clang::Sema::DiagnoseUnusedDecl(), clang::Sema::DiagnoseUnusedExprResult(), clang::Sema::DiagnoseUnusedParameters(), clang::Sema::DiagnoseUseOfDecl(), clang::threadSafety::ThreadSafetyReporter::emitDiagnostics(), clang::DiagnosticRenderer::emitStoredDiagnostic(), clang::Expr::EvaluateKnownConstInt(), clang::Sema::FinalizeDeclaration(), clang::Sema::FindCompositeObjCPointerType(), clang::arcmt::FileRemapper::flushToFile(), clang::Diagnostic::FormatDiagnostic(), clang::Sema::getDestructorName(), clang::Sema::getDestructorType(), clang::Sema::getMostSpecialized(), clang::Sema::HandleDeclarator(), clang::Sema::HandleField(), clang::Sema::ImplicitlyDefineFunction(), clang::Sema::inferObjCARCLifetime(), clang::Sema::InvalidOperands(), clang::Sema::isAcceptableTagRedeclaration(), clang::Sema::isIncompatibleTypedef(), clang::Sema::IsOverload(), clang::Sema::LazilyCreateBuiltin(), clang::Sema::LookupInlineAsmIdentifier(), clang::Sema::LookupInObjCMethod(), clang::Sema::LookupLiteralOperator(), clang::Sema::LookupTemplateName(), clang::MakeDeductionFailureInfo(), clang::ASTReader::makeModuleVisible(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), clang::Sema::MaybeSuggestAddingStaticToDecl(), clang::Sema::MergeFunctionDecl(), clang::Sema::MergeTypedefNameDecl(), clang::Sema::MergeVarDecl(), clang::Sema::MergeVarDeclTypes(), clang::Sema::NoteAllFoundTemplates(), clang::Sema::NoteDeletedFunction(), clang::arcmt::FileRemapper::overwriteOriginal(), clang::Sema::ParsedFreeStandingDeclSpec(), clang::Sema::ParseObjCStringLiteral(), clang::Sema::ParseTypedefDecl(), clang::Sema::performLambdaInitCaptureInitialization(), ProcessCharEscape(), ProcessUCNEscape(), clang::Sema::SemaBuiltinShuffleVector(), clang::Sema::SemaConvertVectorExpr(), clang::Sema::SetMemberAccessSpecifier(), clang::DiagnosticsEngine::setSeverityForGroup(), and clang::Sema::VerifyBitField().

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 
) [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 367 of file LiteralSupport.cpp.

References ProcessUCNEscape().

static unsigned getCharWidth ( tok::TokenKind  kind,
const TargetInfo Target 
) [static]
static CharSourceRange MakeCharSourceRange ( const LangOptions Features,
FullSourceLoc  TokLoc,
const char *  TokBegin,
const char *  TokRangeBegin,
const char *  TokRangeEnd 
) [static]
static int MeasureUCNEscape ( const char *  ThisTokBegin,
const char *&  ThisTokBuf,
const char *  ThisTokEnd,
unsigned  CharByteWidth,
const LangOptions Features,
bool HadError 
) [static]

MeasureUCNEscape - Determine the number of bytes within the resulting string which this UCN will occupy.

Definition at line 332 of file LiteralSupport.cpp.

References ProcessUCNEscape().

Referenced by clang::StringLiteralParser::getOffsetOfStringByte().

static unsigned ProcessCharEscape ( const char *  ThisTokBegin,
const char *&  ThisTokBuf,
const char *  ThisTokEnd,
bool HadError,
FullSourceLoc  Loc,
unsigned  CharWidth,
DiagnosticsEngine Diags,
const LangOptions Features 
) [static]

ProcessCharEscape - Parse a standard C escape sequence, which can occur in either a character or a string literal.

Definition at line 78 of file LiteralSupport.cpp.

References Diag(), clang::isHexDigit(), and clang::isPrintable().

Referenced by clang::CharLiteralParser::CharLiteralParser(), and clang::StringLiteralParser::getOffsetOfStringByte().

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 
) [static]

ProcessUCNEscape - Read the Universal Character Name, check constraints and return the UTF32.

Definition at line 260 of file LiteralSupport.cpp.

References Diag(), and clang::isHexDigit().

Referenced by clang::CharLiteralParser::CharLiteralParser(), EncodeUCNEscape(), and MeasureUCNEscape().

static const char* resyncUTF8 ( const char *  Err,
const char *  End 
) [static]

Definition at line 1542 of file LiteralSupport.cpp.