[cfe-commits] r44164 - in /cfe/trunk: Basic/IdentifierTable.cpp Driver/clang.cpp include/clang/Basic/LangOptions.h include/clang/Basic/TokenKinds.def

Nate Begeman natebegeman at mac.com
Wed Nov 14 23:30:50 PST 2007


Author: sampo
Date: Thu Nov 15 01:30:50 2007
New Revision: 44164

URL: http://llvm.org/viewvc/llvm-project?rev=44164&view=rev
Log:
Break out bool/true/false support into a LangOption


Modified:
    cfe/trunk/Basic/IdentifierTable.cpp
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/include/clang/Basic/LangOptions.h
    cfe/trunk/include/clang/Basic/TokenKinds.def

Modified: cfe/trunk/Basic/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/IdentifierTable.cpp?rev=44164&r1=44163&r2=44164&view=diff

==============================================================================
--- cfe/trunk/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/Basic/IdentifierTable.cpp Thu Nov 15 01:30:50 2007
@@ -68,10 +68,18 @@
 /// specified language.
 static void AddKeyword(const char *Keyword, unsigned KWLen,
                        tok::TokenKind TokenCode,
-                       int C90, int C99, int CXX, int CXX0x,
+                       int C90, int C99, int CXX, int CXX0x, int BoolSupport,
                        const LangOptions &LangOpts, IdentifierTable &Table) {
-  int Flags = LangOpts.CPlusPlus ? (LangOpts.CPlusPlus0x? CXX0x : CXX)
-                                 : (LangOpts.C99 ? C99 : C90);
+  int Flags = 0;
+  if (BoolSupport != 0) {
+    Flags = LangOpts.Boolean ? BoolSupport : 2;
+  } else if (LangOpts.CPlusPlus) {
+    Flags = LangOpts.CPlusPlus0x ? CXX0x : CXX;
+  } else if (LangOpts.C99) {
+    Flags = C99;
+  } else {
+    Flags = C90;
+  }
   
   // Don't add this keyword if disabled in this language or if an extension
   // and extensions are disabled.
@@ -126,6 +134,8 @@
     CPP0xShift = 6,
     EXTCPP0x   = 1 << CPP0xShift,
     NOTCPP0x   = 2 << CPP0xShift,
+    BoolShift = 8,
+    BOOLSUPPORT = 1 << BoolShift,
     Mask     = 3
   };
   
@@ -135,7 +145,8 @@
              ((FLAGS) >> C90Shift) & Mask, \
              ((FLAGS) >> C99Shift) & Mask, \
              ((FLAGS) >> CPPShift) & Mask, \
-             ((FLAGS) >> CPP0xShift) & Mask, LangOpts, *this);
+             ((FLAGS) >> CPP0xShift) & Mask, \
+             ((FLAGS) >> BoolShift) & Mask, LangOpts, *this);
 #define ALIAS(NAME, TOK) \
   AddAlias(NAME, strlen(NAME), #TOK, strlen(#TOK), LangOpts, *this);
 #define CXX_KEYWORD_OPERATOR(NAME, ALIAS) \

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44164&r1=44163&r2=44164&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Nov 15 01:30:50 2007
@@ -316,6 +316,7 @@
   case lang_cxx98:
     Options.CPlusPlus = 1;
     Options.CXXOperatorNames = !NoOperatorNames;
+    Options.Boolean = 1;
     // FALL THROUGH.
   case lang_gnu99:
   case lang_c99:

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=44164&r1=44163&r2=44164&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Thu Nov 15 01:30:50 2007
@@ -35,11 +35,12 @@
   unsigned ObjC2             : 1;  // Objective C 2 support enabled.
   
   unsigned PascalStrings     : 1;  // Allow Pascal strings
+  unsigned Boolean           : 1;  // Allow bool/true/false
   
   LangOptions() {
     Trigraphs = BCPLComment = DollarIdents = Digraphs = ObjC1 = ObjC2 = 0;
     C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;
-    CXXOperatorNames = PascalStrings = 0;
+    CXXOperatorNames = PascalStrings = Boolean = 0;
   }
 };
 

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=44164&r1=44163&r2=44164&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Thu Nov 15 01:30:50 2007
@@ -232,7 +232,7 @@
 
 // C++ 2.11p1: Keywords.
 KEYWORD(asm                         , EXTC90|EXTC99) // Exts in C90/C99
-KEYWORD(bool                        , NOTC90|NOTC99)
+KEYWORD(bool                        , BOOLSUPPORT)
 KEYWORD(catch                       , NOTC90|NOTC99)
 KEYWORD(class                       , NOTC90|NOTC99)
 KEYWORD(const_cast                  , NOTC90|NOTC99)
@@ -240,7 +240,7 @@
 KEYWORD(dynamic_cast                , NOTC90|NOTC99)
 KEYWORD(explicit                    , NOTC90|NOTC99)
 KEYWORD(export                      , NOTC90|NOTC99)
-KEYWORD(false                       , NOTC90|NOTC99)
+KEYWORD(false                       , BOOLSUPPORT)
 KEYWORD(friend                      , NOTC90|NOTC99)
 KEYWORD(mutable                     , NOTC90|NOTC99)
 KEYWORD(namespace                   , NOTC90|NOTC99)
@@ -254,7 +254,7 @@
 KEYWORD(template                    , NOTC90|NOTC99)
 KEYWORD(this                        , NOTC90|NOTC99)
 KEYWORD(throw                       , NOTC90|NOTC99)
-KEYWORD(true                        , NOTC90|NOTC99)
+KEYWORD(true                        , BOOLSUPPORT)
 KEYWORD(try                         , NOTC90|NOTC99)
 KEYWORD(typename                    , NOTC90|NOTC99)
 KEYWORD(typeid                      , NOTC90|NOTC99)





More information about the cfe-commits mailing list