[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
Wed Apr 25 01:50:49 PDT 2018


ilya-biryukov added a comment.

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

> They are declared in some file defined by the line markers; the file are
>  not registered in the SourceManager as actual files, so getting the
>  FileEntry will always fail, that's why I changed it to get the PresumedLoc.


That's the part I'm confused about.
Does any of the examples in the current patch have this case (files are not registered in the source manager, but defined by the file markers)?
I assume all examples in the current patch will produce USRs even without your changes, is this correct or am I missing something?

> More general question is: how do we want USRs for function parameters to
> 
>> work, specifically should USR of the same param of different declarations
>>  be the same or different?
> 
> That's a good point, this patch will generated different names for the same
>  function param if a function is first defined then declared somewhere else.
> 
> I guess it should follow the USR generation pattern for FunctionDecls, what
>  do you think?

I guess it depends on the use-case, but  USRs for function params do not seem to provide much value if they aren't equal across different decls of the same function.

But I'm not sure whether they were designed with this use-case in mind or not.
E.g. if they **are** equal, we can two `Decl`s with the same USR, but different names:

  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.


Repository:
  rC Clang

https://reviews.llvm.org/D42966





More information about the cfe-commits mailing list