[cfe-commits] r170468 - in /cfe/trunk: test/Index/c-index-api-loadTU-test.m test/Index/fix-its.m test/Index/preamble_macro_template.cpp tools/libclang/CXSourceLocation.cpp

Argyrios Kyrtzidis kyrtzidis at apple.com
Tue Dec 18 15:59:20 PST 2012


On Dec 18, 2012, at 3:07 PM, Ted Kremenek <kremenek at apple.com> wrote:

> 
> Modified: cfe/trunk/tools/libclang/CXSourceLocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXSourceLocation.cpp?rev=170468&r1=170467&r2=170468&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CXSourceLocation.cpp (original)
> +++ cfe/trunk/tools/libclang/CXSourceLocation.cpp Tue Dec 18 17:07:30 2012
> @@ -295,15 +295,13 @@
>   const SourceManager &SM =
>   *static_cast<const SourceManager*>(location.ptr_data[0]);
>   SourceLocation SpellLoc = Loc;
> -  if (SpellLoc.isMacroID()) {
> -    SourceLocation SimpleSpellingLoc = SM.getImmediateSpellingLoc(SpellLoc);
> -    if (SimpleSpellingLoc.isFileID() &&
> -        SM.getFileEntryForID(SM.getDecomposedLoc(SimpleSpellingLoc).first))
> -      SpellLoc = SimpleSpellingLoc;
> -    else
> -      SpellLoc = SM.getExpansionLoc(SpellLoc);
> +
> +  // Unravel the macro instantiation stack.  This logic mirrors that
> +  // in DiagnosticRenderer.
> +  while (SpellLoc.isMacroID()) {
> +    SpellLoc = SM.getImmediateMacroCallerLoc(SpellLoc);
>   }
> -  
> +
>   std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(SpellLoc);
>   FileID FID = LocInfo.first;
>   unsigned FileOffset = LocInfo.second;

You can just use:

SourceLocation SpellLoc = SM.getFileLoc(Loc);

to get the same effect.

> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list