[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 07:52:30 PDT 2018


ilya-biryukov added subscribers: sammccall, ioeric, hokein, bkramer.
ilya-biryukov added a comment.

In https://reviews.llvm.org/D42966#1079438, @mikhail.ramalho wrote:

> The virtual file is actually registered in the SourceManager but the
>  FileEntry for it is NULL (USRGeneration.cpp:33), which forces printLoc to
>  return true (USRGeneration.cpp:38) and the USR is not generated.


I still don't get why the file is virtual. Looking at the code in `SourceManager`, presumed location uses `FileEntry` of passed location (actually, its expansion location, but that shouldn't matter) and then translates line numbers according to the `#line` directives in the file.
So the question is: why is `FileEntry` null for original location, but not null for `PresumedLoc`?

Sorry for confusion, if any, I just want to understand to make sure we're looking at the right place to solve your original problem.

>> int func(int param1);
>>  int func(int param2);
>>  // param1 and param2 could both have the same USR, but different names.
>>  That might (or might not) be surprising.
> 
> I agree here, they should have the same USR.

Let's get more opinions on this, I'm not 100% certain about it myself :-)

@arphaman, @bkramer, @hokein, @ioeric, @sammccall, should parameters of **different declarations** for the **same function overload** have the same or different USRs? WDYT?


Repository:
  rC Clang

https://reviews.llvm.org/D42966





More information about the cfe-commits mailing list