clang API Documentation
#include <IdentifierTable.h>
Public Member Functions | |
IdentifierInfo () | |
template<std::size_t StrLen> | |
bool | isStr (const char(&Str)[StrLen]) const |
Return true if this is the identifier for the specified string. | |
const char * | getNameStart () const |
Return the beginning of the actual null-terminated string for this identifier. | |
unsigned | getLength () const |
Efficiently return the length of this identifier info. | |
StringRef | getName () const |
Return the actual identifier string. | |
bool | hasMacroDefinition () const |
Return true if this identifier is #defined to some other value. | |
void | setHasMacroDefinition (bool Val) |
bool | hadMacroDefinition () const |
Returns true if this identifier was #defined to some value at any moment. In this case there should be an entry for the identifier in the macro history table in Preprocessor. | |
tok::TokenKind | getTokenID () const |
bool | hasRevertedTokenIDToIdentifier () const |
True if RevertTokenIDToIdentifier() was called. | |
void | RevertTokenIDToIdentifier () |
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility. | |
tok::PPKeywordKind | getPPKeywordID () const |
Return the preprocessor keyword ID for this identifier. | |
tok::ObjCKeywordKind | getObjCKeywordID () const |
Return the Objective-C keyword ID for the this identifier. | |
void | setObjCKeywordID (tok::ObjCKeywordKind ID) |
unsigned | getBuiltinID () const |
Return a value indicating whether this is a builtin function. | |
void | setBuiltinID (unsigned ID) |
unsigned | getObjCOrBuiltinID () const |
void | setObjCOrBuiltinID (unsigned ID) |
bool | isExtensionToken () const |
void | setIsExtensionToken (bool Val) |
bool | isCXX11CompatKeyword () const |
void | setIsCXX11CompatKeyword (bool Val) |
void | setIsPoisoned (bool Value=true) |
bool | isPoisoned () const |
Return true if this token has been poisoned. | |
void | setIsCPlusPlusOperatorKeyword (bool Val=true) |
bool | isCPlusPlusOperatorKeyword () const |
template<typename T > | |
T * | getFETokenInfo () const |
void | setFETokenInfo (void *T) |
bool | isHandleIdentifierCase () const |
Return true if the Preprocessor::HandleIdentifier must be called on a token of this identifier. | |
bool | isFromAST () const |
Return true if the identifier in its current state was loaded from an AST file. | |
void | setIsFromAST () |
bool | hasChangedSinceDeserialization () const |
Determine whether this identifier has changed since it was loaded from an AST file. | |
void | setChangedSinceDeserialization () |
Note that this identifier has changed since it was loaded from an AST file. | |
bool | isOutOfDate () const |
Determine whether the information for this identifier is out of date with respect to the external source. | |
void | setOutOfDate (bool OOD) |
Set whether the information for this identifier is out of date with respect to the external source. | |
bool | isModulesImport () const |
Determine whether this is the contextual keyword import . | |
void | setModulesImport (bool I) |
Set whether this identifier is the contextual keyword import . | |
Friends | |
class | IdentifierTable |
One of these records is kept for each identifier that is lexed. This contains information about whether the token was #define'd, is a language keyword, or if it is a front-end token of some sort (e.g. a variable or function name). The preprocessor keeps this information in a set, and all tok::identifier tokens have a pointer to one of these.
Definition at line 47 of file IdentifierTable.h.
IdentifierInfo::IdentifierInfo | ( | ) |
Definition at line 32 of file IdentifierTable.cpp.
unsigned clang::IdentifierInfo::getBuiltinID | ( | ) | const [inline] |
Return a value indicating whether this is a builtin function.
0 is not-built-in. 1 is builtin-for-some-nonprimary-target. 2+ are specific builtin functions.
Definition at line 188 of file IdentifierTable.h.
Referenced by clang::FunctionDecl::getBuiltinID(), LookupBuiltin(), and clang::Sema::LookupInObjCMethod().
T* clang::IdentifierInfo::getFETokenInfo | ( | ) | const [inline] |
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata with this token.
Definition at line 255 of file IdentifierTable.h.
Referenced by isInterestingIdentifier().
unsigned clang::IdentifierInfo::getLength | ( | ) | const [inline] |
Efficiently return the length of this identifier info.
Definition at line 109 of file IdentifierTable.h.
Referenced by AddObjCKeyValueCompletions(), CheckExtVectorComponent(), getName(), getPPKeywordID(), getStandardSelLoc(), clang::Sema::isCurrentClassNameTypo(), isReservedName(), isStr(), and clang::Sema::MergeTypedefNameDecl().
StringRef clang::IdentifierInfo::getName | ( | ) | const [inline] |
Return the actual identifier string.
Definition at line 122 of file IdentifierTable.h.
References getLength(), and getNameStart().
Referenced by clang::Sema::ActOnFinishKNRParamDeclarations(), clang::Sema::ActOnGCCAsmStmt(), clang::Sema::ActOnPragmaRedefineExtname(), clang::Sema::ActOnPragmaVisibility(), clang::comments::Sema::actOnTParamCommandParamNameArg(), clang::TypoCorrectionConsumer::addCorrection(), AddObjCKeyValueCompletions(), AddTemplateParameterChunks(), appendEnumType(), appendRecordType(), clang::ento::AnyFunctionCall::argumentsMayEscape(), attributeHasIdentifierArg(), attributeIsTypeArgAttr(), attributeParsedArgsUnevaluated(), checkAvailabilityAttr(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::CheckLiteralOperatorDeclaration(), clang::Sema::checkStringLiteralArgumentAttr(), clang::Sema::ClassifyName(), clang::Sema::CodeCompleteObjCMethodDeclSelector(), clang::Sema::CodeCompleteObjCPropertySynthesizeIvar(), clang::DeclarationName::compare(), clang::SelectorTable::constructSetterSelector(), clang::ExtVectorElementExpr::containsDuplicateElements(), clang::Sema::CorrectTypo(), clang::Sema::CorrectTypoDelayed(), clang::comments::Sema::correctTypoInTParamReference(), clang::Sema::DeclApplyPragmaWeak(), diagnoseBadTypeAttribute(), DiagnoseNamespaceInlineMismatch(), clang::Sema::DiagnoseUnknownTemplateName(), clang::Sema::DiagnoseUnknownTypeName(), clang::MacroInfo::dump(), EmitGlobalDeclMetadata(), EvaluateBuildingModule(), EvaluateHasIncludeCommon(), findKnownClass(), clang::ento::coreFoundation::followsCreateRule(), FormatFunctionParameter(), clang::TypoCorrectionConsumer::FoundDecl(), clang::index::generateUSRForMacro(), clang::Selector::getAsString(), GetAssumedMessageSendExprType(), clang::AttributeList::getAttributeSpellingListIndex(), getCalleeName(), clang::ento::CheckerContext::getCalleeName(), getCCTypeAttrKind(), clang::ObjCPropertyDecl::getDefaultSynthIvarName(), clang::ExtVectorElementExpr::getEncodedElementAccess(), GetFullTypeForDeclarator(), getFunctionName(), clang::ento::ExprEngine::getInitialState(), clang::Selector::getInstTypeMethodFamily(), clang::AttributeList::getKind(), clang::CodeGen::CodeGenModule::getMangledName(), clang::NamedDecl::getName(), clang::MacroExpansion::getName(), clang::ObjCCategoryImplDecl::getName(), clang::ObjCImplementationDecl::getName(), clang::Selector::getNameForSlot(), getOrderedName(), handleArgumentWithTypeTagAttr(), handleAvailabilityAttr(), handleBlocksAttr(), handleConsumableAttr(), handleFormatAttr(), handleLoopHintAttr(), handleModeAttr(), handleObjCMethodFamilyAttr(), handleObjCOwnershipTypeAttr(), handleOwnershipAttr(), handleParamTypestateAttr(), clang::PragmaNamespace::HandlePragma(), clang::Preprocessor::HandlePragmaPopMacro(), handleReturnTypestateAttr(), handleSetTypestateAttr(), handleTestTypestateAttr(), clang::hasAttribute(), HasExtension(), HasFeature(), clang::Sema::ImplicitlyDefineFunction(), clang::ASTImporter::Import(), clang::CallGraph::includeInGraph(), InheritsFromClassNamed(), InNamespace(), isAttributeLateParsed(), isCharSpecialization(), clang::ento::CheckerContext::isCLibraryFunction(), clang::ento::cocoa::isCocoaObjectRef(), clang::Sema::isCurrentClassNameTypo(), IsStructurallyEquivalent(), clang::MangleContext::mangleGlobalBlock(), clang::MangleContext::mangleName(), clang::Sema::mergeAvailabilityAttr(), clang::analyze_format_string::FormatSpecifier::namedTypeToLengthModifier(), clang::Sema::ParseTypedefDecl(), PragmaLoopHintString(), clang::NestedNameSpecifier::print(), PrintMacroDefinition(), clang::PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(), clang::comments::Sema::resolveParmVarReference(), clang::RewriteMacrosInInput(), rewriteToNSEnumDecl(), rewriteToNSMacroDecl(), TryNamespaceTypoCorrection(), and clang::ASTReader::updateOutOfDateIdentifier().
const char* clang::IdentifierInfo::getNameStart | ( | ) | const [inline] |
Return the beginning of the actual null-terminated string for this identifier.
Definition at line 96 of file IdentifierTable.h.
Referenced by CheckExtVectorComponent(), getName(), clang::LabelStmt::getName(), getPPKeywordID(), isReservedName(), and isStr().
tok::ObjCKeywordKind clang::IdentifierInfo::getObjCKeywordID | ( | ) | const [inline] |
Return the Objective-C keyword ID for the this identifier.
For example, 'class' will return tok::objc_class if ObjC is enabled.
Definition at line 176 of file IdentifierTable.h.
Referenced by clang::Token::getObjCKeywordID().
unsigned clang::IdentifierInfo::getObjCOrBuiltinID | ( | ) | const [inline] |
Definition at line 200 of file IdentifierTable.h.
Referenced by isInterestingIdentifier().
Return the preprocessor keyword ID for this identifier.
For example, "define" will return tok::pp_define.
Definition at line 212 of file IdentifierTable.cpp.
References CASE, getLength(), getNameStart(), and HASH.
Referenced by clang::format::ContinuationIndenter::addTokenToState(), clang::Preprocessor::CheckMacroName(), and clang::Preprocessor::HandleDirective().
tok::TokenKind clang::IdentifierInfo::getTokenID | ( | ) | const [inline] |
If this is a source-language token (e.g. 'for'), this API can be used to cause the lexer to map identifiers to source-language tokens.
Definition at line 151 of file IdentifierTable.h.
Referenced by IsValidIdentifier(), clang::PTHLexer::Lex(), and clang::TokenLexer::Lex().
bool clang::IdentifierInfo::hadMacroDefinition | ( | ) | const [inline] |
Returns true if this identifier was #defined to some value at any moment. In this case there should be an entry for the identifier in the macro history table in Preprocessor.
Definition at line 144 of file IdentifierTable.h.
Referenced by checkConfigMacro(), clang::Preprocessor::getMacroDirectiveHistory(), isInterestingIdentifier(), and isMacroDefined().
bool clang::IdentifierInfo::hasChangedSinceDeserialization | ( | ) | const [inline] |
Determine whether this identifier has changed since it was loaded from an AST file.
Definition at line 273 of file IdentifierTable.h.
bool clang::IdentifierInfo::hasMacroDefinition | ( | ) | const [inline] |
Return true if this identifier is #defined to some other value.
Definition at line 127 of file IdentifierTable.h.
Referenced by AddOrdinaryNameResults(), checkConfigMacro(), clang::Preprocessor::CheckMacroName(), clang::Sema::CodeCompleteObjCPassingType(), EvaluateDefined(), clang::Preprocessor::getMacroDirective(), clang::arcmt::trans::getNilString(), clang::Preprocessor::HandlePragmaPoison(), isTrivialSingleTokenExpansion(), MaybeAddSentinel(), and rewriteToObjCProperty().
bool clang::IdentifierInfo::hasRevertedTokenIDToIdentifier | ( | ) | const [inline] |
True if RevertTokenIDToIdentifier() was called.
Definition at line 154 of file IdentifierTable.h.
Referenced by isInterestingIdentifier().
bool clang::IdentifierInfo::isCPlusPlusOperatorKeyword | ( | ) | const [inline] |
Definition at line 250 of file IdentifierTable.h.
Referenced by clang::Preprocessor::CheckMacroName().
bool clang::IdentifierInfo::isCXX11CompatKeyword | ( | ) | const [inline] |
is/setIsCXX11CompatKeyword - Initialize information about whether or not this language token is a keyword in C++11. This controls compatibility warnings, and is only true when not parsing C++11. Once a compatibility problem has been diagnosed with this keyword, the flag will be cleared.
Definition at line 219 of file IdentifierTable.h.
bool clang::IdentifierInfo::isExtensionToken | ( | ) | const [inline] |
get/setExtension - Initialize information about whether or not this language token is an extension. This controls extension warnings, and is only valid if a custom token ID is set.
Definition at line 206 of file IdentifierTable.h.
Referenced by isInterestingIdentifier().
bool clang::IdentifierInfo::isFromAST | ( | ) | const [inline] |
Return true if the identifier in its current state was loaded from an AST file.
Definition at line 267 of file IdentifierTable.h.
Referenced by clang::Preprocessor::appendMacroDirective(), clang::Preprocessor::HandlePragmaPoison(), and clang::serialization::reader::ASTIdentifierLookupTrait::ReadData().
bool clang::IdentifierInfo::isHandleIdentifierCase | ( | ) | const [inline] |
Return true if the Preprocessor::HandleIdentifier must be called on a token of this identifier.
If this returns false, we know that HandleIdentifier will not affect the token.
Definition at line 263 of file IdentifierTable.h.
Referenced by clang::PTHLexer::Lex(), and clang::TokenLexer::Lex().
bool clang::IdentifierInfo::isModulesImport | ( | ) | const [inline] |
Determine whether this is the contextual keyword import
.
Definition at line 298 of file IdentifierTable.h.
bool clang::IdentifierInfo::isOutOfDate | ( | ) | const [inline] |
Determine whether the information for this identifier is out of date with respect to the external source.
Definition at line 285 of file IdentifierTable.h.
Referenced by clang::ASTReader::CompleteRedeclChain(), and isTrivialSingleTokenExpansion().
bool clang::IdentifierInfo::isPoisoned | ( | ) | const [inline] |
Return true if this token has been poisoned.
Definition at line 239 of file IdentifierTable.h.
Referenced by clang::Preprocessor::HandleIdentifier(), clang::Preprocessor::HandlePragmaPoison(), isInterestingIdentifier(), and clang::TokenLexer::Lex().
bool clang::IdentifierInfo::isStr | ( | const char(&) | Str[StrLen] | ) | const [inline] |
Return true if this is the identifier for the specified string.
This is intended to be used for string literals only: II->isStr("foo").
Definition at line 89 of file IdentifierTable.h.
References getLength(), and getNameStart().
Referenced by clang::Sema::ActOnClassPropertyRefExpr(), clang::Sema::ActOnStartNamespaceDef(), clang::Sema::ActOnTag(), clang::Sema::ActOnUsingDirective(), clang::Sema::AddKnownFunctionAttributes(), clang::ento::AnyFunctionCall::argumentsMayEscape(), clang::ObjCMethodCall::argumentsMayEscape(), clang::Sema::ConversionToObjCStringLiteralCheck(), diagnoseBadTypeAttribute(), DiagnoseDirectIsaAccess(), findCapturingExpr(), clang::FunctionDecl::getMemoryFunctionKind(), handleLoopHintAttr(), handleObjCGCTypeAttr(), handleObjCOwnershipTypeAttr(), clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), isEnableIf(), IsFunctionStdAbs(), clang::TypoCorrection::isKeyword(), clang::Sema::isLibstdcxxEagerExceptionSpecHack(), isNamed(), isStd(), clang::DeclContext::isStdNamespace(), isStreamCharSpecialization(), clang::Preprocessor::LexOnOffSwitch(), LookupMemberExpr(), LookupPredefedObjCSuperType(), clang::Sema::MergeTypedefNameDecl(), ParseAlignPragma(), processTypeAttrs(), and clang::CodeGen::CodeGenFunction::StartObjCMethod().
void clang::IdentifierInfo::RevertTokenIDToIdentifier | ( | ) | [inline] |
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
TokenID is normally read-only but there are 2 instances where we revert it to tok::identifier for libstdc++ 4.2. Keep track of when this happens using this method so we can inform serialization about it.
Definition at line 162 of file IdentifierTable.h.
void clang::IdentifierInfo::setBuiltinID | ( | unsigned | ID | ) | [inline] |
Definition at line 194 of file IdentifierTable.h.
Referenced by clang::Builtin::Context::ForgetBuiltin(), clang::Builtin::Context::InitializeBuiltins(), and clang::Sema::MergeFunctionDecl().
void clang::IdentifierInfo::setChangedSinceDeserialization | ( | ) | [inline] |
Note that this identifier has changed since it was loaded from an AST file.
Definition at line 279 of file IdentifierTable.h.
Referenced by clang::Preprocessor::appendMacroDirective(), clang::Preprocessor::HandlePragmaPoison(), and clang::serialization::reader::ASTIdentifierLookupTrait::ReadData().
void clang::IdentifierInfo::setFETokenInfo | ( | void * | T | ) | [inline] |
Definition at line 256 of file IdentifierTable.h.
Referenced by clang::DeclarationName::setFETokenInfo().
void clang::IdentifierInfo::setHasMacroDefinition | ( | bool | Val | ) | [inline] |
Definition at line 130 of file IdentifierTable.h.
Referenced by clang::Preprocessor::appendMacroDirective(), and clang::Preprocessor::setLoadedMacroDirective().
void clang::IdentifierInfo::setIsCPlusPlusOperatorKeyword | ( | bool | Val = true | ) | [inline] |
isCPlusPlusOperatorKeyword/setIsCPlusPlusOperatorKeyword controls whether this identifier is a C++ alternate representation of an operator.
Definition at line 243 of file IdentifierTable.h.
Referenced by AddCXXOperatorKeyword().
void clang::IdentifierInfo::setIsCXX11CompatKeyword | ( | bool | Val | ) | [inline] |
Definition at line 220 of file IdentifierTable.h.
Referenced by AddKeyword().
void clang::IdentifierInfo::setIsExtensionToken | ( | bool | Val | ) | [inline] |
Definition at line 207 of file IdentifierTable.h.
Referenced by AddKeyword().
void clang::IdentifierInfo::setIsFromAST | ( | ) | [inline] |
Definition at line 269 of file IdentifierTable.h.
Referenced by clang::serialization::reader::ASTIdentifierLookupTrait::ReadData().
void clang::IdentifierInfo::setIsPoisoned | ( | bool | Value = true | ) | [inline] |
setIsPoisoned - Mark this identifier as poisoned. After poisoning, the Preprocessor will emit an error every time this token is used.
Definition at line 230 of file IdentifierTable.h.
Referenced by clang::Preprocessor::HandlePragmaPoison(), clang::PoisonIdentifierRAIIObject::PoisonIdentifierRAIIObject(), clang::Preprocessor::PoisonSEHIdentifiers(), and clang::PoisonIdentifierRAIIObject::~PoisonIdentifierRAIIObject().
void clang::IdentifierInfo::setModulesImport | ( | bool | I | ) | [inline] |
Set whether this identifier is the contextual keyword import
.
Definition at line 301 of file IdentifierTable.h.
Referenced by clang::IdentifierTable::getOwn().
void clang::IdentifierInfo::setObjCKeywordID | ( | tok::ObjCKeywordKind | ID | ) | [inline] |
Definition at line 182 of file IdentifierTable.h.
Referenced by AddObjCKeyword().
void clang::IdentifierInfo::setObjCOrBuiltinID | ( | unsigned | ID | ) | [inline] |
Definition at line 201 of file IdentifierTable.h.
void clang::IdentifierInfo::setOutOfDate | ( | bool | OOD | ) | [inline] |
Set whether the information for this identifier is out of date with respect to the external source.
Definition at line 289 of file IdentifierTable.h.
Referenced by clang::ASTReader::markIdentifierUpToDate().
friend class IdentifierTable [friend] |
Definition at line 79 of file IdentifierTable.h.