[cfe-commits] r64743 - /cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp

Chris Lattner sabre at nondot.org
Mon Feb 16 21:19:11 PST 2009


Author: lattner
Date: Mon Feb 16 23:19:10 2009
New Revision: 64743

URL: http://llvm.org/viewvc/llvm-project?rev=64743&view=rev
Log:
If a source range comes through a function-like macro expansion,
highlight the arguments to the macro as well as the identifier.

Before:

t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
 return acos(x);
        ^~~~

after:

t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
 return acos(x);
        ^~~~~~~


Modified:
    cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp?rev=64743&r1=64742&r2=64743&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp Mon Feb 16 23:19:10 2009
@@ -45,6 +45,14 @@
   SourceLocation Begin = SM.getInstantiationLoc(R.getBegin());
   SourceLocation End = SM.getInstantiationLoc(R.getEnd());
   
+  // If the End location and the start location are the same and are a macro
+  // location, then the range was something that came from a macro expansion
+  // or _Pragma.  If this is an object-like macro, the best we can do is to
+  // highlight the range.  If this is a function-like macro, we'd also like to
+  // highlight the arguments.
+  if (Begin == End && R.getEnd().isMacroID())
+    End = SM.getInstantiationRange(R.getEnd()).second;
+  
   unsigned StartLineNo = SM.getInstantiationLineNumber(Begin);
   if (StartLineNo > LineNo || SM.getFileID(Begin) != FID)
     return;  // No intersection.





More information about the cfe-commits mailing list