[cfe-commits] r64936 - in /cfe/trunk/lib: Lex/Preprocessor.cpp Sema/SemaChecking.cpp

Chris Lattner sabre at nondot.org
Wed Feb 18 10:52:53 PST 2009


Author: lattner
Date: Wed Feb 18 12:52:52 2009
New Revision: 64936

URL: http://llvm.org/viewvc/llvm-project?rev=64936&view=rev
Log:
Fix some issues handling sub-token locations that come from macro expansions.
We now emit:

t.m:6:15: warning: field width should have type 'int', but argument has type 'unsigned int'
  printf(STR, (unsigned) 1, 1);
         ^    ~~~~~~~~~~~~
t.m:3:18: note: instantiated from:
#define STR "abc%*ddef"
                 ^

which has the correct location in the string literal in the note line.


Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp

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

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Feb 18 12:52:52 2009
@@ -296,7 +296,7 @@
   // the instantiation point (the name).  We could point to the source
   // character, but without also pointing to instantiation info, this is
   // confusing.
-  if (CharNo == 0 || TokStart.isMacroID()) return TokStart;
+  if (CharNo == 0) return TokStart;
   
   // Figure out how many physical characters away the specified instantiation
   // character is.  This needs to take into consideration newlines and

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=64936&r1=64935&r2=64936&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Feb 18 12:52:52 2009
@@ -77,17 +77,12 @@
     
     // The length of the string is the token length minus the two quotes.
     TokNumBytes -= 2;
-    
-    // If we found the token we're looking for, return the location.
+
     // FIXME: This should consider character escapes!
+
+    // If the byte is in this token, return the location of the byte.
     if (ByteNo < TokNumBytes ||
         (ByteNo == TokNumBytes && TokNo == SL->getNumConcatenated())) {
-      // If the original token came from a macro expansion, just return the
-      // start of the token.  We don't want to magically jump to the spelling
-      // for a diagnostic.  We do the above business in case some tokens come
-      // from a macro expansion but others don't.
-      if (!StrTokLoc.isFileID()) return StrTokLoc;
-      
       // We advance +1 to step over the '"'.
       return PP.AdvanceToTokenCharacter(StrTokLoc, ByteNo+1);
     }





More information about the cfe-commits mailing list