Open hokein opened 1 year ago
@llvm/issue-subscribers-clang-frontend
It looks like we do the same thing w/ other builtins, I am not sure if this is expected behavior or not though, CC @AaronBallman
As best I can tell, this has been the behavior since at least Clang 3.5, so it's a bit tough to say whether it is or isn't expected. Sema::CreateBuiltin()
takes a source location for where the implicit declaration lives, but https://github.com/llvm/llvm-project/blob/277b8989794f6a915edb519cdf8c937ffbdc83eb/clang/lib/Sema/SemaLookup.cpp#L952 is what picks the source location to pass, and it's passing the location of the name.
I'm not certain what will break if we change the logic, but I would not expect this to be an invalid source location, but instead be in the <built-in>
location (same as predefined macros).
Given the following case:
The
__builtin_popcount
FunctionDecl looks like, its source location points to the first call site (line 2, col 10). The source location is suspicious (I think it should be an invalid source loc).