[cfe-commits] r122946 - in /cfe/trunk: lib/Lex/PPDirectives.cpp test/Preprocessor/assembler-with-cpp.c

Chris Lattner sabre at nondot.org
Wed Jan 5 21:01:51 PST 2011


Author: lattner
Date: Wed Jan  5 23:01:51 2011
New Revision: 122946

URL: http://llvm.org/viewvc/llvm-project?rev=122946&view=rev
Log:
fix rdar://8823139, a crash on a comment in a preprocessed .s file
that contains the ## operator.

Modified:
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/test/Preprocessor/assembler-with-cpp.c

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=122946&r1=122945&r2=122946&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jan  5 23:01:51 2011
@@ -654,6 +654,12 @@
     // Return the # and the token after it.
     Toks[0] = SavedHash;
     Toks[1] = Result;
+    
+    // If the second token is a hashhash token, then we need to translate it to
+    // unknown so the token lexer doesn't try to perform token pasting.
+    if (Result.is(tok::hashhash))
+      Toks[1].setKind(tok::unknown);
+    
     // Enter this token stream so that we re-lex the tokens.  Make sure to
     // enable macro expansion, in case the token after the # is an identifier
     // that is expanded.

Modified: cfe/trunk/test/Preprocessor/assembler-with-cpp.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/assembler-with-cpp.c?rev=122946&r1=122945&r2=122946&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/assembler-with-cpp.c (original)
+++ cfe/trunk/test/Preprocessor/assembler-with-cpp.c Wed Jan  5 23:01:51 2011
@@ -72,3 +72,8 @@
 11: T11(b)
 // CHECK-Identifiers-True: 11: #0
 
+
+// This should not crash
+// rdar://8823139
+# ##
+// CHECK-Identifiers-False: # ##





More information about the cfe-commits mailing list