[cfe-commits] r69024 - /cfe/trunk/lib/Lex/PPDirectives.cpp

Chris Lattner sabre at nondot.org
Mon Apr 13 22:15:21 PDT 2009


Author: lattner
Date: Tue Apr 14 00:15:20 2009
New Revision: 69024

URL: http://llvm.org/viewvc/llvm-project?rev=69024&view=rev
Log:
Offer a fixit hint for our warning about tokens at the end of a directive:

t.c:3:8: warning: extra tokens at end of #endif directive
#endif foo
       ^
       //

Don't do this in strict-C89 mode because bcpl comments aren't 
valid there, and it is too much trouble to analyze whether
C block comments are safe.

Modified:
    cfe/trunk/lib/Lex/PPDirectives.cpp

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

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Apr 14 00:15:20 2009
@@ -114,7 +114,13 @@
     LexUnexpandedToken(Tmp);
   
   if (Tmp.isNot(tok::eom)) {
-    Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType;
+    // Add a fixit in GNU/C99/C++ mode.  Don't offer a fixit for strict-C89,
+    // because it is more trouble than it is worth to insert /**/ and check that
+    // there is no /**/ in the range also.
+    CodeModificationHint FixItHint;
+    if (Features.GNUMode || Features.C99 || Features.CPlusPlus)
+      FixItHint = CodeModificationHint::CreateInsertion(Tmp.getLocation(),"//");
+    Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType << FixItHint;
     DiscardUntilEndOfDirective();
   }
 }





More information about the cfe-commits mailing list