[cfe-commits] r69485 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Preprocessor/line-directive.c

Chris Lattner sabre at nondot.org
Sat Apr 18 15:29:33 PDT 2009


Author: lattner
Date: Sat Apr 18 17:29:33 2009
New Revision: 69485

URL: http://llvm.org/viewvc/llvm-project?rev=69485&view=rev
Log:
Fix PR3917: the location of a #line directive is the location of the first _.

Modified:
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/test/Preprocessor/line-directive.c

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

==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Sat Apr 18 17:29:33 2009
@@ -485,6 +485,10 @@
     // be affected by #line.
     SourceLocation Loc = Tok.getLocation();
     
+    // Advance to the location of the first _, this might not be the first byte
+    // of the token if it starts with an escaped newline.
+    Loc = AdvanceToTokenCharacter(Loc, 0);
+    
     // One wrinkle here is that GCC expands __LINE__ to location of the *end* of
     // a macro instantiation.  This doesn't matter for object-like macros, but
     // can matter for a function-like macro that expands to contain __LINE__.

Modified: cfe/trunk/test/Preprocessor/line-directive.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/line-directive.c?rev=69485&r1=69484&r2=69485&view=diff

==============================================================================
--- cfe/trunk/test/Preprocessor/line-directive.c (original)
+++ cfe/trunk/test/Preprocessor/line-directive.c Sat Apr 18 17:29:33 2009
@@ -79,3 +79,11 @@
 #line 010  // expected-warning {{#line directive interprets number as decimal, not octal}}
 extern int array[__LINE__ == 10 ? 1:-1];
 
+/* PR3917 */
+#line 41
+extern char array2[\
+_\
+_LINE__ == 42 ? 1: -1];  /* line marker is location of first _ */
+
+
+





More information about the cfe-commits mailing list