aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/IdentifierTable.h
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-30 00:29:29 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-30 00:29:29 +0000
commitffaab3e2bb13991bb3357e80f14bcae3745b2347 (patch)
treeaba453c66d76494ce04b5495d76ac38b68e2af5c /include/clang/Basic/IdentifierTable.h
parent3ce9e7d270e7df86c09c8126b4412d55be7c123b (diff)
Make macro weirdness in chained PCH work. This required changing the way PCHReader and PCHWriter are initialized to correctly pick up all initializer. On the upside, this means that there is far less repetition in the dependent PCH now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109823 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r--include/clang/Basic/IdentifierTable.h48
1 files changed, 28 insertions, 20 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h
index 6b8bcdc52f..c8642a1ac5 100644
--- a/include/clang/Basic/IdentifierTable.h
+++ b/include/clang/Basic/IdentifierTable.h
@@ -59,7 +59,9 @@ 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".
- // 9 bits left in 32-bit word.
+ bool IsFromPCH : 1; // True if identfier first appeared in a PCH
+ // and wasn't modified since.
+ // 8 bits left in 32-bit word.
void *FETokenInfo; // Managed by the language front-end.
llvm::StringMapEntry<IdentifierInfo*> *Entry;
@@ -125,6 +127,7 @@ public:
NeedsHandleIdentifier = 1;
else
RecomputeNeedsHandleIdentifier();
+ IsFromPCH = false;
}
/// get/setTokenID - If this is a source-language token (e.g. 'for'), this API
@@ -186,6 +189,7 @@ public:
NeedsHandleIdentifier = 1;
else
RecomputeNeedsHandleIdentifier();
+ IsFromPCH = false;
}
/// isPoisoned - Return true if this token has been poisoned.
@@ -213,6 +217,12 @@ public:
/// know that HandleIdentifier will not affect the token.
bool isHandleIdentifierCase() const { return NeedsHandleIdentifier; }
+ /// isFromPCH - Return true if the identifier in its current state was loaded
+ /// from a PCH file.
+ bool isFromPCH() const { return IsFromPCH; }
+
+ void setIsFromPCH(bool FromPCH = true) { IsFromPCH = FromPCH; }
+
private:
/// RecomputeNeedsHandleIdentifier - The Preprocessor::HandleIdentifier does
/// several special (but rare) things to identifiers of various sorts. For
@@ -321,35 +331,33 @@ public:
return get(llvm::StringRef(Name, NameLen));
}
- /// \brief Creates a new IdentifierInfo from the given string.
+ /// \brief Gets an IdentifierInfo for the given name without consulting
+ /// external sources.
///
- /// This is a lower-level version of get() that requires that this
- /// identifier not be known previously and that does not consult an
- /// external source for identifiers. In particular, external
- /// identifier sources can use this routine to build IdentifierInfo
- /// nodes and then introduce additional information about those
- /// identifiers.
- IdentifierInfo &CreateIdentifierInfo(const char *NameStart,
- const char *NameEnd) {
+ /// This is a version of get() meant for external sources that want to
+ /// introduce or modify an identifier. If they called get(), they would
+ /// likely end up in a recursion.
+ IdentifierInfo &getOwn(const char *NameStart, const char *NameEnd) {
llvm::StringMapEntry<IdentifierInfo*> &Entry =
HashTable.GetOrCreateValue(NameStart, NameEnd);
IdentifierInfo *II = Entry.getValue();
- assert(!II && "IdentifierInfo already exists");
+ if (!II) {
- // Lookups failed, make a new IdentifierInfo.
- void *Mem = getAllocator().Allocate<IdentifierInfo>();
- II = new (Mem) IdentifierInfo();
- Entry.setValue(II);
+ // Lookups failed, make a new IdentifierInfo.
+ void *Mem = getAllocator().Allocate<IdentifierInfo>();
+ II = new (Mem) IdentifierInfo();
+ Entry.setValue(II);
- // Make sure getName() knows how to find the IdentifierInfo
- // contents.
- II->Entry = &Entry;
+ // Make sure getName() knows how to find the IdentifierInfo
+ // contents.
+ II->Entry = &Entry;
+ }
return *II;
}
- IdentifierInfo &CreateIdentifierInfo(llvm::StringRef Name) {
- return CreateIdentifierInfo(Name.begin(), Name.end());
+ IdentifierInfo &getOwn(llvm::StringRef Name) {
+ return getOwn(Name.begin(), Name.end());
}
typedef HashTableTy::const_iterator iterator;