aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-11 22:55:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-11 22:55:12 +0000
commit646395bbcaa849c94bc2a3246c71d809ca719f01 (patch)
tree2a4d80ab05b4680e243ffc9d6977439e4e5e27a3 /lib
parentb3a29f132794f67108bccc9c7cc3795365e8a965 (diff)
-Make TokenID of IdentifierInfo read-only, remove setTokenID().
-There are 2 instances that change the TokenID for GNU libstdc++ 4.2 compatibility. To handler those cases introduce a RevertedTokenID bitfield, RevertTokenIDToIdentifier() and hasRevertedTokenIDToIdentifier() methods. Store the bitfield in PCH. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/IdentifierTable.cpp7
-rw-r--r--lib/Frontend/PCHReader.cpp6
-rw-r--r--lib/Frontend/PCHWriter.cpp1
-rw-r--r--lib/Parse/ParseDeclCXX.cpp4
4 files changed, 11 insertions, 7 deletions
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp
index 1f0c52bdc1..c7b16c99c9 100644
--- a/lib/Basic/IdentifierTable.cpp
+++ b/lib/Basic/IdentifierTable.cpp
@@ -35,6 +35,7 @@ IdentifierInfo::IdentifierInfo() {
IsCPPOperatorKeyword = false;
NeedsHandleIdentifier = false;
IsFromPCH = false;
+ RevertedTokenID = false;
FETokenInfo = 0;
Entry = 0;
}
@@ -101,8 +102,7 @@ static void AddKeyword(llvm::StringRef Keyword,
// Don't add this keyword if disabled in this language.
if (AddResult == 0) return;
- IdentifierInfo &Info = Table.get(Keyword);
- Info.setTokenID(TokenCode);
+ IdentifierInfo &Info = Table.get(Keyword, TokenCode);
Info.setIsExtensionToken(AddResult == 1);
}
@@ -111,8 +111,7 @@ static void AddKeyword(llvm::StringRef Keyword,
static void AddCXXOperatorKeyword(llvm::StringRef Keyword,
tok::TokenKind TokenCode,
IdentifierTable &Table) {
- IdentifierInfo &Info = Table.get(Keyword);
- Info.setTokenID(TokenCode);
+ IdentifierInfo &Info = Table.get(Keyword, TokenCode);
Info.setIsCPlusPlusOperatorKeyword();
}
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 68acbb2faf..a09b89deea 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -657,6 +657,8 @@ public:
unsigned Bits = ReadUnalignedLE16(d);
bool CPlusPlusOperatorKeyword = Bits & 0x01;
Bits >>= 1;
+ bool HasRevertedTokenIDToIdentifier = Bits & 0x01;
+ Bits >>= 1;
bool Poisoned = Bits & 0x01;
Bits >>= 1;
bool ExtensionToken = Bits & 0x01;
@@ -677,7 +679,9 @@ public:
Reader.SetIdentifierInfo(ID, II);
// Set or check the various bits in the IdentifierInfo structure.
- // FIXME: Load token IDs lazily, too?
+ // Token IDs are read-only.
+ if (HasRevertedTokenIDToIdentifier)
+ II->RevertTokenIDToIdentifier();
II->setObjCOrBuiltinID(ObjCOrBuiltinID);
assert(II->isExtensionToken() == ExtensionToken &&
"Incorrect extension token flag");
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 0eed4ccd71..6712122682 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -1847,6 +1847,7 @@ public:
Bits = (Bits << 1) | unsigned(hasMacroDefinition);
Bits = (Bits << 1) | unsigned(II->isExtensionToken());
Bits = (Bits << 1) | unsigned(II->isPoisoned());
+ Bits = (Bits << 1) | unsigned(II->hasRevertedTokenIDToIdentifier());
Bits = (Bits << 1) | unsigned(II->isCPlusPlusOperatorKeyword());
clang::io::Emit16(Out, Bits);
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 55e677dbaa..5f404ac430 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -661,7 +661,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// token sequence "struct __is_pod", make __is_pod into a normal
// identifier rather than a keyword, to allow libstdc++ 4.2 to work
// properly.
- Tok.getIdentifierInfo()->setTokenID(tok::identifier);
+ Tok.getIdentifierInfo()->RevertTokenIDToIdentifier();
Tok.setKind(tok::identifier);
}
@@ -671,7 +671,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// token sequence "struct __is_empty", make __is_empty into a normal
// identifier rather than a keyword, to allow libstdc++ 4.2 to work
// properly.
- Tok.getIdentifierInfo()->setTokenID(tok::identifier);
+ Tok.getIdentifierInfo()->RevertTokenIDToIdentifier();
Tok.setKind(tok::identifier);
}