r185895 - Generalize hack allowing 'const' in __has_attribute (etc) to allow any token

Richard Smith richard-llvm at metafoo.co.uk
Mon Jul 8 17:57:56 PDT 2013


Author: rsmith
Date: Mon Jul  8 19:57:56 2013
New Revision: 185895

URL: http://llvm.org/viewvc/llvm-project?rev=185895&view=rev
Log:
Generalize hack allowing 'const' in __has_attribute (etc) to allow any token
with identifier info. This covers most identifier-like entities (other than
the ISO646 keywords).

Modified:
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/test/Preprocessor/has_attribute.c

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=185895&r1=185894&r2=185895&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Jul  8 19:57:56 2013
@@ -1218,9 +1218,7 @@ void Preprocessor::ExpandBuiltinMacro(To
     if (Tok.is(tok::l_paren)) {
       // Read the identifier
       LexUnexpandedToken(Tok);
-      if (Tok.is(tok::identifier) || Tok.is(tok::kw_const)) {
-        FeatureII = Tok.getIdentifierInfo();
-
+      if ((FeatureII = Tok.getIdentifierInfo())) {
         // Read the ')'.
         LexUnexpandedToken(Tok);
         if (Tok.is(tok::r_paren))

Modified: cfe/trunk/test/Preprocessor/has_attribute.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_attribute.c?rev=185895&r1=185894&r2=185895&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/has_attribute.c (original)
+++ cfe/trunk/test/Preprocessor/has_attribute.c Mon Jul  8 19:57:56 2013
@@ -34,3 +34,7 @@ int has_something_we_dont_have();
  static int constFunction() __attribute__((const));
 #endif
 
+// CHECK: has_no_volatile_attribute
+#if !__has_attribute(volatile)
+int has_no_volatile_attribute();
+#endif





More information about the cfe-commits mailing list