diff options
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 5e48a86..cc0080b 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -20,11 +20,9 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/SmallString.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include <cassert> -#include <cctype> #include <string> namespace llvm { @@ -49,8 +47,6 @@ namespace clang { /// variable or function name). The preprocessor keeps this information in a /// set, and all tok::identifier tokens have a pointer to one of these. class IdentifierInfo { - // Note: DON'T make TokenID a 'tok::TokenKind'; MSVC will treat it as a - // signed char and TokenKinds > 255 won't be handled correctly. unsigned TokenID : 9; // Front-end token ID or tok::identifier. // Objective-C keyword ('protocol' in '@protocol') or builtin (__builtin_inf). // First NUM_OBJC_KEYWORDS values are for Objective-C, the remaining values @@ -62,11 +58,19 @@ class IdentifierInfo { bool IsPoisoned : 1; // True if identifier is poisoned. bool IsCPPOperatorKeyword : 1; // True if ident is a C++ operator keyword. bool NeedsHandleIdentifier : 1; // See "RecomputeNeedsHandleIdentifier". - bool IsFromAST : 1; // True if identfier first appeared in an AST - // file and wasn't modified since. + bool IsFromAST : 1; // True if identifier was loaded (at least + // partially) from an AST file. + bool ChangedAfterLoad : 1; // True if identifier has changed from the + // definition loaded from an AST file. bool RevertedTokenID : 1; // True if RevertTokenIDToIdentifier was // called. - // 5 bits left in 32-bit word. + bool OutOfDate : 1; // True if there may be additional + // information about this identifier + // stored externally. + bool IsModulesImport : 1; // True if this is the 'import' contextual + // keyword. + // 1 bit left in 32-bit word. + void *FETokenInfo; // Managed by the language front-end. llvm::StringMapEntry<IdentifierInfo*> *Entry; @@ -132,7 +136,6 @@ public: NeedsHandleIdentifier = 1; else RecomputeNeedsHandleIdentifier(); - IsFromAST = false; } /// getTokenID - If this is a source-language token (e.g. 'for'), this API @@ -221,7 +224,6 @@ public: NeedsHandleIdentifier = 1; else RecomputeNeedsHandleIdentifier(); - IsFromAST = false; } /// isPoisoned - Return true if this token has been poisoned. @@ -253,8 +255,48 @@ public: /// from an AST file. bool isFromAST() const { return IsFromAST; } - void setIsFromAST(bool FromAST = true) { IsFromAST = FromAST; } + void setIsFromAST() { IsFromAST = true; } + /// \brief Determine whether this identifier has changed since it was loaded + /// from an AST file. + bool hasChangedSinceDeserialization() const { + return ChangedAfterLoad; + } + + /// \brief Note that this identifier has changed since it was loaded from + /// an AST file. + void setChangedSinceDeserialization() { + ChangedAfterLoad = true; + } + + /// \brief Determine whether the information for this identifier is out of + /// date with respect to the external source. + bool isOutOfDate() const { return OutOfDate; } + + /// \brief Set whether the information for this identifier is out of + /// date with respect to the external source. + void setOutOfDate(bool OOD) { + OutOfDate = OOD; + if (OOD) + NeedsHandleIdentifier = true; + else + RecomputeNeedsHandleIdentifier(); + } + + /// \brief Determine whether this is the contextual keyword + /// '__experimental_modules_import'. + bool isModulesImport() const { return IsModulesImport; } + + /// \brief Set whether this identifier is the contextual keyword + /// '__experimental_modules_import'. + void setModulesImport(bool I) { + IsModulesImport = I; + if (I) + NeedsHandleIdentifier = true; + else + RecomputeNeedsHandleIdentifier(); + } + private: /// RecomputeNeedsHandleIdentifier - The Preprocessor::HandleIdentifier does /// several special (but rare) things to identifiers of various sorts. For @@ -266,8 +308,8 @@ private: void RecomputeNeedsHandleIdentifier() { NeedsHandleIdentifier = (isPoisoned() | hasMacroDefinition() | isCPlusPlusOperatorKeyword() | - isExtensionToken() | isCXX11CompatKeyword() || - (getTokenID() == tok::kw___import_module__)); + isExtensionToken() | isCXX11CompatKeyword() || isOutOfDate() || + isModulesImport()); } }; @@ -449,6 +491,10 @@ public: // Make sure getName() knows how to find the IdentifierInfo // contents. II->Entry = &Entry; + + // If this is the 'import' contextual keyword, mark it as such. + if (Name.equals("import")) + II->setModulesImport(true); } return *II; @@ -662,14 +708,7 @@ public: /// has been capitalized. static Selector constructSetterName(IdentifierTable &Idents, SelectorTable &SelTable, - const IdentifierInfo *Name) { - llvm::SmallString<100> SelectorName; - SelectorName = "set"; - SelectorName += Name->getName(); - SelectorName[3] = toupper(SelectorName[3]); - IdentifierInfo *SetterName = &Idents.get(SelectorName); - return SelTable.getUnarySelector(SetterName); - } + const IdentifierInfo *Name); }; /// DeclarationNameExtra - Common base of the MultiKeywordSelector, |