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
[clang][Sema] Fix and reapply 'Declare builtins used in #pragma intrinsic #138205' (#142019)
I had to revert #138205 in
#141994 because it broke the
Chrome build.
The problem came down to the following:
```c++
unsigned __int64 _umul128(unsigned __int64, unsigned __int64,
unsigned __int64 *);
namespace {}
#pragma intrinsic(_umul128)
void foo() {
unsigned __int64 carry;
unsigned __int64 low = _umul128(0, 0, &carry);
}
```
When processing the `#pragma intrinsic` line, we do a name lookup to see
if the builtin was previously declared. In this case the lookup fails
because the current namespace of the parser and sema is the above
namespace scope. The processing of the pragma happens as part of the
namespace close parsing. This is usually fine because most pragmas don't
care about scopes. However, that's not true for this and other MS
pragmas.
To fix this, we change the `#pragma intrinsic` processing to be the same
as other MS pragmas such as "optimize". Those are processed like a
declaration, and because of that we have the correct current scope, so
the lookup succeeds.
I added a test case that locks down the Chrome fix, as well as manually
tested the Chrome build and confirmed it passed.
0 commit comments