[cfe-commits] r42603 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/Lex/IdentifierTable.h

Chris Lattner sabre at nondot.org
Wed Oct 3 22:21:22 PDT 2007


Author: lattner
Date: Thu Oct  4 00:21:22 2007
New Revision: 42603

URL: http://llvm.org/viewvc/llvm-project?rev=42603&view=rev
Log:
minor cleanups, make code more defensive, less branchy in Selector ctor.

Modified:
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/include/clang/Lex/IdentifierTable.h

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=42603&r1=42602&r2=42603&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Thu Oct  4 00:21:22 2007
@@ -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 = "";

Modified: cfe/trunk/include/clang/Lex/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/IdentifierTable.h?rev=42603&r1=42602&r2=42603&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Lex/IdentifierTable.h Thu Oct  4 00:21:22 2007
@@ -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;
   }





More information about the cfe-commits mailing list