[cfe-commits] r170487 - in /cfe/trunk: lib/Frontend/DiagnosticRenderer.cpp tools/libclang/CXSourceLocation.cpp

Ted Kremenek kremenek at apple.com
Tue Dec 18 17:16:49 PST 2012


Author: kremenek
Date: Tue Dec 18 19:16:49 2012
New Revision: 170487

URL: http://llvm.org/viewvc/llvm-project?rev=170487&view=rev
Log:
Simplify logic to use SourceManager::getFileLoc(), per Argyrios's feedback.

Modified:
    cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
    cfe/trunk/tools/libclang/CXSourceLocation.cpp

Modified: cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp?rev=170487&r1=170486&r2=170487&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp (original)
+++ cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp Tue Dec 18 19:16:49 2012
@@ -153,10 +153,8 @@
 
     SourceLocation UnexpandedLoc = Loc;
 
-    // Perform the same walk as emitMacroExpansions, to find the ultimate
-    // expansion location for the diagnostic.
-    while (Loc.isMacroID())
-      Loc = SM->getImmediateMacroCallerLoc(Loc);
+    // Find the ultimate expansion location for the diagnostic.
+    Loc = SM->getFileLoc(Loc);
 
     PresumedLoc PLoc = SM->getPresumedLoc(Loc, DiagOpts->ShowPresumedLoc);
 

Modified: cfe/trunk/tools/libclang/CXSourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXSourceLocation.cpp?rev=170487&r1=170486&r2=170487&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXSourceLocation.cpp (original)
+++ cfe/trunk/tools/libclang/CXSourceLocation.cpp Tue Dec 18 19:16:49 2012
@@ -294,14 +294,7 @@
   
   const SourceManager &SM =
   *static_cast<const SourceManager*>(location.ptr_data[0]);
-  SourceLocation SpellLoc = Loc;
-
-  // Unravel the macro instantiation stack.  This logic mirrors that
-  // in DiagnosticRenderer.
-  while (SpellLoc.isMacroID()) {
-    SpellLoc = SM.getImmediateMacroCallerLoc(SpellLoc);
-  }
-
+  SourceLocation SpellLoc = SM.getFileLoc(Loc);
   std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(SpellLoc);
   FileID FID = LocInfo.first;
   unsigned FileOffset = LocInfo.second;





More information about the cfe-commits mailing list