[cfe-commits] r69023 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/PPDirectives.cpp lib/Lex/Pragma.cpp

Chris Lattner sabre at nondot.org
Mon Apr 13 22:07:56 PDT 2009


Author: lattner
Date: Tue Apr 14 00:07:49 2009
New Revision: 69023

URL: http://llvm.org/viewvc/llvm-project?rev=69023&view=rev
Log:
Fix the #import / #include_next "extra tokens at end of #foo directive" 
Warning to properly report that it is an import/include_next instead of
claiming it is a #include.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=69023&r1=69022&r2=69023&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Apr 14 00:07:49 2009
@@ -113,7 +113,7 @@
   "#include_next is a language extension">;
 def ext_pp_warning_directive : Extension<"#warning is a language extension">;
 def ext_pp_extra_tokens_at_eol : ExtWarn<
-  "extra tokens at end of %0 directive">;
+  "extra tokens at end of #%0 directive">;
 def ext_pp_comma_expr : Extension<"comma operator in operand of #if">;
 def ext_pp_bad_vaargs_use : Extension<
   "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro">;

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

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Apr 14 00:07:49 2009
@@ -243,7 +243,7 @@
       }
     } else if (FirstChar == 'e') {
       if (IdLen == 5 && !strcmp(Directive+1, "ndif")) {  // "endif"
-        CheckEndOfDirective("#endif");
+        CheckEndOfDirective("endif");
         PPConditionalInfo CondInfo;
         CondInfo.WasSkipping = true; // Silence bogus warning.
         bool InCond = CurPPLexer->popConditionalLevel(CondInfo);
@@ -257,7 +257,7 @@
         // #else directive in a skipping conditional.  If not in some other
         // skipping conditional, and if #else hasn't already been seen, enter it
         // as a non-skipping conditional.
-        CheckEndOfDirective("#else");
+        CheckEndOfDirective("else");
         PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel();
         
         // If this is a #else with a #else before it, report the error.
@@ -689,7 +689,7 @@
                                                   Literal.GetStringLength());
     
     // Verify that there is nothing after the string, other than EOM.
-    CheckEndOfDirective("#line");
+    CheckEndOfDirective("line");
   }
   
   SourceMgr.AddLineNote(DigitTok.getLocation(), LineNo, FilenameID);
@@ -889,7 +889,7 @@
   }
   
   // Verify that there is nothing after the string, other than EOM.
-  CheckEndOfDirective("#ident");
+  CheckEndOfDirective("ident");
 
   if (Callbacks)
     Callbacks->Ident(Tok.getLocation(), getSpelling(StrTok));
@@ -1050,7 +1050,7 @@
   }
   
   // Verify that there is nothing after the filename, other than EOM.
-  CheckEndOfDirective("#include");
+  CheckEndOfDirective(IncludeTok.getIdentifierInfo()->getName());
 
   // Check that we don't have infinite #include recursion.
   if (IncludeMacroStack.size() == MaxAllowedIncludeStackDepth-1) {
@@ -1420,7 +1420,7 @@
     return;
   
   // Check to see if this is the last token on the #undef line.
-  CheckEndOfDirective("#undef");
+  CheckEndOfDirective("undef");
   
   // Okay, we finally have a valid identifier to undef.
   MacroInfo *MI = getMacroInfo(MacroNameTok.getIdentifierInfo());
@@ -1464,7 +1464,7 @@
   }
   
   // Check to see if this is the last token on the #if[n]def line.
-  CheckEndOfDirective(isIfndef ? "#ifndef" : "#ifdef");
+  CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
 
   if (CurPPLexer->getConditionalStackDepth() == 0) {
     // If the start of a top-level #ifdef, inform MIOpt.
@@ -1533,7 +1533,7 @@
   ++NumEndif;
   
   // Check that this is the whole directive.
-  CheckEndOfDirective("#endif");
+  CheckEndOfDirective("endif");
   
   PPConditionalInfo CondInfo;
   if (CurPPLexer->popConditionalLevel(CondInfo)) {
@@ -1555,7 +1555,7 @@
   ++NumElse;
   
   // #else directive in a non-skipping conditional... start skipping.
-  CheckEndOfDirective("#else");
+  CheckEndOfDirective("else");
   
   PPConditionalInfo CI;
   if (CurPPLexer->popConditionalLevel(CI)) {

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

==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Tue Apr 14 00:07:49 2009
@@ -461,7 +461,7 @@
 struct PragmaOnceHandler : public PragmaHandler {
   PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {}
   virtual void HandlePragma(Preprocessor &PP, Token &OnceTok) {
-    PP.CheckEndOfDirective("#pragma once");
+    PP.CheckEndOfDirective("pragma once");
     PP.HandlePragmaOnce(OnceTok);
   }
 };
@@ -489,7 +489,7 @@
   PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
   virtual void HandlePragma(Preprocessor &PP, Token &SHToken) {
     PP.HandlePragmaSystemHeader(SHToken);
-    PP.CheckEndOfDirective("#pragma");
+    PP.CheckEndOfDirective("pragma");
   }
 };
 struct PragmaDependencyHandler : public PragmaHandler {





More information about the cfe-commits mailing list