On Dec 18, 2012, at 3:07 PM, Ted Kremenek <[email protected]> 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
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to