You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
inttest(unsigned __x) {
return__builtin_popcount(1); // line 2
}
inttest2(unsigned __x) {
return__builtin_popcount(1);
}
voidfoo() {
__builtin^_popcount(1ul); // calling go-to-definition in clangd will jump to line2.
}
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).
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
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).The text was updated successfully, but these errors were encountered: