minor cleanups, make code more defensive, less branchy in Selector ctor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42603 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index a96d57f..8c6eeec 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -737,7 +737,6 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
diff --git a/include/clang/Lex/IdentifierTable.h b/include/clang/Lex/IdentifierTable.h
index ddfd029..9f6234c 100644
--- a/include/clang/Lex/IdentifierTable.h
+++ b/include/clang/Lex/IdentifierTable.h
@@ -234,6 +234,7 @@
class Selector {
enum IdentifierInfoFlag {
+ // MultiKeywordSelector = 0.
ZeroArg = 0x1,
OneArg = 0x2,
ArgFlags = ZeroArg|OneArg
@@ -242,20 +243,18 @@
Selector(IdentifierInfo *II, unsigned nArgs) {
InfoPtr = reinterpret_cast<uintptr_t>(II);
- if (nArgs == 0)
- InfoPtr |= ZeroArg;
- else if (nArgs == 1)
- InfoPtr |= OneArg;
- else
- assert(0 && "nArgs not equal to 0/1");
+ assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
+ assert(nArgs < 2 && "nArgs not equal to 0/1");
+ InfoPtr |= nArgs+1;
}
Selector(MultiKeywordSelector *SI) {
InfoPtr = reinterpret_cast<uintptr_t>(SI);
+ assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
}
friend class Parser; // only the Parser can create these.
IdentifierInfo *getAsIdentifierInfo() const {
- if (InfoPtr & ArgFlags)
+ if (getIdentifierInfoFlag())
return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags);
return 0;
}