Parse pragma intrinsic, display warning if the function isn't a builtin function in clang and suggest including intrin.h.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
include/clang/Basic/DiagnosticParseKinds.td | ||
---|---|---|
916 ↗ | (On Diff #69430) | I'd use this wording: '%0' is not a recognized builtin |
919 ↗ | (On Diff #69430) | Generally notes are attached to other source locations, which we don't have in this case. I'd replace this note with a second diagnostic with an extra clause: def warn_pragma_intrinsic_builtin_suggest : Warning< "'%0' is not a recognized builtin; consider including <intrin.h> to access non-builtin intrinsics">; If you search for "suggest" in the diagnostic file, you can see other instances of this. |
include/clang/Basic/DiagnosticParseKinds.td | ||
---|---|---|
918 ↗ | (On Diff #69605) | I would combine this with the above and use %select to decide whether to include the "consider including" bit. aka, "%0 is not a recognized builtin%select{|; consider including <intrin.h> to access non-builtin intrinsics"}1". |
lib/Parse/ParsePragma.cpp | ||
2148 ↗ | (On Diff #69605) |
|
2150 ↗ | (On Diff #69605) | pragma -> #pragma |
2157 ↗ | (On Diff #69605) | Not for your patch, but I wish we could use the balanced delimiter tracker for parsing pragmas. |
2164 ↗ | (On Diff #69605) | Is this safe to rely on? I'm not familiar with how we do our intrinsics, but it's spelled __INTRIN_H_ in MSVC 2015, but perhaps we only care about intrin.h from Clang? |
2169–2174 ↗ | (On Diff #69605) | Should elide braces here. |
lib/Parse/ParsePragma.cpp | ||
---|---|---|
2164 ↗ | (On Diff #69605) | I guess we only care about intrin.h from Clang - as far as I can see, MSVC's intrin.h contains only declarations, so including it won't change anything most of the time if the intrinsic isn't implemented in Clang. |
One buglet, otherwise looks good.
lib/Parse/ParsePragma.cpp | ||
---|---|---|
2169 ↗ | (On Diff #69632) | This doesn't seem like the right test. I think '1' is a valid builtin. This should probably be != 0. __builtin_atan2 looks like it has builtin id 1, and you can use that to test. |