[cfe-commits] r60362 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/LangOptions.h lib/Lex/Preprocessor.cpp

Daniel Dunbar daniel at zuster.org
Mon Dec 1 10:55:26 PST 2008


Author: ddunbar
Date: Mon Dec  1 12:55:22 2008
New Revision: 60362

URL: http://llvm.org/viewvc/llvm-project?rev=60362&view=rev
Log:
Add LangOptions marker for assembler-with-cpp mode and use to define
__ASSEMBLER__ properly. Patch from Roman Divacky (with minor
formatting changes). Thanks!

Modified:
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/include/clang/Basic/LangOptions.h
    cfe/trunk/lib/Lex/Preprocessor.cpp

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

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Dec  1 12:55:22 2008
@@ -353,6 +353,7 @@
     PCH = true;
     break;
   case langkind_asm_cpp:
+    Options.AsmPreprocessor = 1;
     // FALLTHROUGH
   case langkind_c_cpp:
     NoPreprocess = true;

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

==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Mon Dec  1 12:55:22 2008
@@ -25,6 +25,7 @@
   unsigned Trigraphs         : 1;  // Trigraphs in source files.
   unsigned BCPLComment       : 1;  // BCPL-style '//' comments.
   unsigned DollarIdents      : 1;  // '$' allowed in identifiers.
+  unsigned AsmPreprocessor   : 1;  // Preprocessor in asm mode.
   unsigned ImplicitInt       : 1;  // C89 implicit 'int'.
   unsigned Digraphs          : 1;  // C94, C99 and C++
   unsigned HexFloats         : 1;  // C99 Hexadecimal float constants.
@@ -47,7 +48,7 @@
   unsigned NeXTRuntime       : 1; // Use NeXT runtime.
 
   unsigned ThreadsafeStatics : 1; // Whether static initializers are protected
-                                  // by lockis.
+                                  // by locks.
   unsigned Blocks            : 1; // block extension to C
 private:
   unsigned GC : 2; // Objective-C Garbage Collection modes.  We declare
@@ -58,7 +59,8 @@
   enum GCMode { NonGC, GCOnly, HybridGC };
   
   LangOptions() {
-    Trigraphs = BCPLComment = DollarIdents = ImplicitInt = Digraphs = 0;
+    Trigraphs = BCPLComment = DollarIdents = AsmPreprocessor = 0;
+    ImplicitInt = Digraphs = 0;
     HexFloats = 0;
     GC = ObjC1 = ObjC2 = 0;
     C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=60362&r1=60361&r2=60362&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Dec  1 12:55:22 2008
@@ -431,7 +431,8 @@
   // These should all be defined in the preprocessor according to the
   // current language configuration.
   DefineBuiltinMacro(Buf, "__STDC__=1");
-  //DefineBuiltinMacro(Buf, "__ASSEMBLER__=1");
+  if (PP.getLangOptions().AsmPreprocessor)
+    DefineBuiltinMacro(Buf, "__ASSEMBLER__=1");
   if (PP.getLangOptions().C99 && !PP.getLangOptions().CPlusPlus)
     DefineBuiltinMacro(Buf, "__STDC_VERSION__=199901L");
   else if (0) // STDC94 ?





More information about the cfe-commits mailing list