Skip to content

[Clang] restrict use of attribute names reserved by the C++ standard #106036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 23, 2025

Conversation

a-tarasyuk
Copy link
Member

Fixes #92196

https://eel.is/c++draft/macro.names#2

A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table 4, or to the attribute-tokens described in [dcl.attr], except that the names likely and unlikely may be defined as function-like macros ([cpp.replace]).

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 26, 2024

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

Changes

Fixes #92196

https://eel.is/c++draft/macro.names#2
> A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table 4, or to the attribute-tokens described in [dcl.attr], except that the names likely and unlikely may be defined as function-like macros ([cpp.replace])[.](https://eel.is/c++draft/macro.names#2.sentence-1)


Full diff: https://github.com/llvm/llvm-project/pull/106036.diff

3 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (+2)
  • (modified) clang/lib/Lex/PPDirectives.cpp (+22)
  • (added) clang/test/Preprocessor/macro-reserved-attrs.cpp (+33)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2c6c7e083b9c91..b8b76eb0ff380c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -254,6 +254,8 @@ Improvements to Clang's diagnostics
   compilation speed with modules. This warning is disabled by default and it needs
   to be explicitly enabled or by ``-Weverything``.
 
+- Clang now diagnoses the use of attribute names reserved by the C++ standard. (#GH92196).
+
 Improvements to Clang's time-trace
 ----------------------------------
 
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 4e77df9ec444c7..bbe1b4a640c4ac 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {
+  const LangOptions &Lang = PP.getLangOpts();
+  const StringRef Name = II->getName();
+
+  if (Lang.CPlusPlus26)
+    return Name == "indeterminate";
+  if (Lang.CPlusPlus23)
+    return Name == "assume";
+  if (Lang.CPlusPlus20)
+    return Name == "no_unique_address";
+  if (Lang.CPlusPlus17)
+    return Name == "fallthrough" || Name == "nodiscard" ||
+           Name == "maybe_unused";
+  if (Lang.CPlusPlus14)
+    return Name == "deprecated";
+  if (Lang.CPlusPlus11)
+    return Name == "noreturn" || Name == "carries_dependency";
+  return false;
+}
+
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
   StringRef Text = II->getName();
@@ -186,6 +206,8 @@ static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
     return MD_KeywordDef;
   if (Lang.CPlusPlus11 && (Text == "override" || Text == "final"))
     return MD_KeywordDef;
+  if (isReservedAttrName(PP, II))
+    return MD_KeywordDef;
   return MD_NoWarn;
 }
 
diff --git a/clang/test/Preprocessor/macro-reserved-attrs.cpp b/clang/test/Preprocessor/macro-reserved-attrs.cpp
new file mode 100644
index 00000000000000..b4336f801e438a
--- /dev/null
+++ b/clang/test/Preprocessor/macro-reserved-attrs.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx11 -pedantic -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx14 -pedantic -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 -pedantic -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -pedantic -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx23 -pedantic -std=c++23 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx26 -pedantic -std=c++26 %s
+
+#define noreturn 1           // cxx11-warning {{keyword is hidden by macro definition}}
+#undef noreturn
+
+#define carries_dependency 1 // cxx11-warning {{keyword is hidden by macro definition}}
+#undef carries_dependency
+
+#define deprecated 1         // cxx14-warning {{keyword is hidden by macro definition}}
+#undef deprecated
+
+#define fallthrough 1        // cxx17-warning {{keyword is hidden by macro definition}}
+#undef fallthrough
+
+#define maybe_unused 1       // cxx17-warning {{keyword is hidden by macro definition}}
+#undef maybe_unused
+
+#define nodiscard 1          // cxx17-warning {{keyword is hidden by macro definition}}
+#undef nodiscard
+
+#define no_unique_address 1  // cxx20-warning {{keyword is hidden by macro definition}}
+#undef no_unique_address
+
+#define assume 1             // cxx23-warning {{keyword is hidden by macro definition}}
+#undef assume
+
+#define indeterminate 1      // cxx26-warning {{keyword is hidden by macro definition}}
+#undef indeterminate

@cor3ntin cor3ntin requested a review from AaronBallman August 26, 2024 13:50
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect these to be controlled by -Wreserved-identifier rather than keyword hiding (these are not keywords), probably in a new group like -Wreserved-attribute-identifier, WDYT?

SourceGraph's backend is currently falling over, so I don't have links to share, but I did see examples of #define likely in projects like MongoDB and #define assume in a fair number of projects. I'm slightly worried about the amount of noise this will generate in practice -- have you tried running these changes over a large corpus of C++ code?

@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Sep 9, 2024
@AaronBallman
Copy link
Collaborator

FWIW, LWG is still discussing the issue while trying to prioritize it, and it's got a reasonable amount of discussion on it. I think we should hold off making any changes or landing this patch until we have a better sense of whether LWG is going to refine this restriction or not.

@a-tarasyuk
Copy link
Member Author

@AaronBallman oke, thanks for the update.

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the patch itself is ready, but I want to see what LWG decides to do here.

@a-tarasyuk a-tarasyuk marked this pull request as draft December 25, 2024 23:49
@a-tarasyuk a-tarasyuk removed the bazel "Peripheral" support tier build system: utils/bazel label Dec 26, 2024
@erichkeane
Copy link
Collaborator

I saw this got updates over break. Did LWG make its decision already? Are you expecting re-review? I didn't see anything go across my emails about LWG, but I could definitely have missed it.

@AaronBallman
Copy link
Collaborator

I saw this got updates over break. Did LWG make its decision already? Are you expecting re-review? I didn't see anything go across my emails about LWG, but I could definitely have missed it.

The LWG issue is still open: https://cplusplus.github.io/LWG/issue4149 but doesn't seem to be under active discussion any longer. My reading of the reflector thread is that my suggested approach is not quite correct. Consider a case like:

#define maybe_unused 12

#include <algorithm>

where the namespace isn't going to be declared (aka header not included) at the time the #define happens. We could aim for a perfect analysis here, but it gets pretty complicated, so I am leaning towards always issuing a -Wreserved-attribute-identifier warning when we see the #define of a standard attribute name. It does mean false positives are possible, but the amount of C++ code that does not include a standard library header anywhere in the TU and defines standard attribute identifiers as macro names is hopefully quite small.

WDYT @erichkeane?

@erichkeane
Copy link
Collaborator

I saw this got updates over break. Did LWG make its decision already? Are you expecting re-review? I didn't see anything go across my emails about LWG, but I could definitely have missed it.

The LWG issue is still open: https://cplusplus.github.io/LWG/issue4149 but doesn't seem to be under active discussion any longer. My reading of the reflector thread is that my suggested approach is not quite correct. Consider a case like:

#define maybe_unused 12

#include <algorithm>

where the namespace isn't going to be declared (aka header not included) at the time the #define happens. We could aim for a perfect analysis here, but it gets pretty complicated, so I am leaning towards always issuing a -Wreserved-attribute-identifier warning when we see the #define of a standard attribute name. It does mean false positives are possible, but the amount of C++ code that does not include a standard library header anywhere in the TU and defines standard attribute identifiers as macro names is hopefully quite small.

WDYT @erichkeane?

Right part of the point is that the rule is SUPPOSED to protect against that case, and frankly, doesn't give a rip about the alternative. The standard doesn't REALLY care if you put that define AFTER all STL header includes, only if it is before, so trying to determine it at declaration time isn't really possible.

We discussed it offline: And I think making this diagnostic, "IF you use the STL and have this define, UB", with an easy enough to disable warning flag is about as good as we can get here. Trying to intuit whether the person is EVER going to use the STL in the TU is a fools errand.

Copy link
Collaborator

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed it offline: And I think making this diagnostic, "IF you use the STL and have this define, UB", with an easy enough to disable warning flag is about as good as we can get here. Trying to intuit whether the person is EVER going to use the STL in the TU is a fools errand.

Could we collect a list on Sema of the directives that we would have diagnosed if std were already declared, and then produce the diagnostics at the point where we see the first declaration of the std namespace? That seems like it could be relatively straightforward.

@erichkeane
Copy link
Collaborator

We discussed it offline: And I think making this diagnostic, "IF you use the STL and have this define, UB", with an easy enough to disable warning flag is about as good as we can get here. Trying to intuit whether the person is EVER going to use the STL in the TU is a fools errand.

Could we collect a list on Sema of the directives that we would have diagnosed if std were already declared, and then produce the diagnostics at the point where we see the first declaration of the std namespace? That seems like it could be relatively straightforward.

I had considered this, but frankly, I think that ends up with a bit of a chicken/egg problem, and quite a bit of extra work for something that affects basically no one.

Part of the problem is figuring out WHEN a library causes the restrictions in macro.names. Paragraph 2 (via CWG issue, and, IMO, by the rights that the Library section of the wording have) states that a TU that includes a standard library header shall not #define/#undef/etc.

SO at that point, you'd have to decide WHAT makes a standard library header sufficiently enough to opt its users into the macro.names restriction sufficiently. OR more importantly, what sort of not quite an Standard Library header, but made to look enough like it to be usable by my project tests we could have to exclude this properly. So things like, "has namespace std" or "has a name that matches one of the StdLib Headers" I think doesn't really qualify as a proper heuristic to the point where it would be correct-enough to be worth the effort.

The only one who knows whether their library IS an Standard Library Header for this purpose, so the 'right' way to do this would be some sort of opt-in (via an attribute, config file, etc). AND if they're doing that, perhaps the StdLib should be the one enforcing this rule in the first place, via #ifdefs and #warning. However, this would be awful for various reasons.

We COULD assume that anything that declared a namespace std and came from system headers would be 'standard library enough' for our uses, but again, I find myself wondering "is the juice worth the squeeze" in figuring this out.

In the end, I came down on, "The one who best knows that they aren't using any headers from the standard library are the ones who wrote the code, so they should be the ones who assert one way or another via a flag". And the -Wno flag seems to be as good as any.

I Strongly suspect that any effort to recognize an StdLib header is going to be fairly wasted, and likely not as accurate as "always assume they are going to use the Standard Library with this file... somewhere".

@zygoloid
Copy link
Collaborator

Oh, I see, you're suggesting we remove the getStdNamespace check from this PR. Yeah, I think that's reasonable.

But I'd somewhat question whether this PR and warning really has anything to do with the attribute names being "reserved" at that point -- we're not checking whether they're reserved or not, and it really doesn't matter. Warning on a #define that clobbers the name of a standard attribute is just generally a good thing to do, regardless of whether you're using the standard library.

@erichkeane
Copy link
Collaborator

Oh, I see, you're suggesting we remove the getStdNamespace check from this PR. Yeah, I think that's reasonable.

Yep, that is my suggestion, sorry I was insufficiently clear.

But I'd somewhat question whether this PR and warning really has anything to do with the attribute names being "reserved" at that point -- we're not checking whether they're reserved or not, and it really doesn't matter. Warning on a #define that clobbers the name of a standard attribute is just generally a good thing to do, regardless of whether you're using the standard library.

I agree with this 100%. The link to the 'reserved by the standard' is I think a good additional justification.

I think the proposal, complaining about these as reserved, is a good idea/good patch. BUT I think getting caught up in the "well, when is it technically NOT UB" is a waste of time, given that the warning is a good idea even without that justification.

@AaronBallman
Copy link
Collaborator

Oh, I see, you're suggesting we remove the getStdNamespace check from this PR. Yeah, I think that's reasonable.

Yep, that is my suggestion, sorry I was insufficiently clear.

But I'd somewhat question whether this PR and warning really has anything to do with the attribute names being "reserved" at that point -- we're not checking whether they're reserved or not, and it really doesn't matter. Warning on a #define that clobbers the name of a standard attribute is just generally a good thing to do, regardless of whether you're using the standard library.

I agree with this 100%. The link to the 'reserved by the standard' is I think a good additional justification.

I think the proposal, complaining about these as reserved, is a good idea/good patch. BUT I think getting caught up in the "well, when is it technically NOT UB" is a waste of time, given that the warning is a good idea even without that justification.

I think the warning is justified even without a standard library header being included, but I also wonder if that means putting this under -Wreserved-identifier is the wrong home and maybe this is a -Wattributes warning group instead. We could reword the diagnostic to something along the lines of "macro name conflicts with the name of a %select{vendor attribute prefix|standard attribute|attribute name}0" and we warn on all three of these cases:

#define msvc 12 // conflicts with [[msvc::no_unique_address]]
#define annotate 12 // conflicts with [[clang::annotate]]
#define nodiscard 12 // conflicts with [[nodiscard]]

WDYT?

@erichkeane
Copy link
Collaborator

Oh, I see, you're suggesting we remove the getStdNamespace check from this PR. Yeah, I think that's reasonable.

Yep, that is my suggestion, sorry I was insufficiently clear.

But I'd somewhat question whether this PR and warning really has anything to do with the attribute names being "reserved" at that point -- we're not checking whether they're reserved or not, and it really doesn't matter. Warning on a #define that clobbers the name of a standard attribute is just generally a good thing to do, regardless of whether you're using the standard library.

I agree with this 100%. The link to the 'reserved by the standard' is I think a good additional justification.
I think the proposal, complaining about these as reserved, is a good idea/good patch. BUT I think getting caught up in the "well, when is it technically NOT UB" is a waste of time, given that the warning is a good idea even without that justification.

I think the warning is justified even without a standard library header being included, but I also wonder if that means putting this under -Wreserved-identifier is the wrong home and maybe this is a -Wattributes warning group instead. We could reword the diagnostic to something along the lines of "macro name conflicts with the name of a %select{vendor attribute prefix|standard attribute|attribute name}0" and we warn on all three of these cases:

#define msvc 12 // conflicts with [[msvc::no_unique_address]]
#define annotate 12 // conflicts with [[clang::annotate]]
#define nodiscard 12 // conflicts with [[nodiscard]]

WDYT?

First, I think this needs its OWN warning group, as I can see justification for disabling just this.

Second, I think that the 'standard' attribute interference is a level of severity HIGHER than the others thanks to being in the standard (and thus, perhaps, likely more to be used/interfered with).

Third: DOES annotate conflict with attribute annotate? Isn't that a function/would have to be a function macro?

Fourth: I think the 'reserved name' has a level of gravitas/concreteness that makes the diagnostic more meaningful/immediately obvious to folks. A diagnostic of, "This name you chose for your macro might make this attribute no workie" yields "Yeah, but i wont use that so I'm ok". A diagnostic of, "This name is UB because the standard reserves it!" yields a level of pause/consideration that we otherwise wouldn't get.

SO I think the diagnostic being associated with it being reserved is COMPLETELY valid/justifiable. I think "this is a bad idea, UB or not" is a reason to not try at all to suppress this if we think you're not ACTUALLY breaking the rule (by not including an StdLib header).

@AaronBallman
Copy link
Collaborator

Oh, I see, you're suggesting we remove the getStdNamespace check from this PR. Yeah, I think that's reasonable.

Yep, that is my suggestion, sorry I was insufficiently clear.

But I'd somewhat question whether this PR and warning really has anything to do with the attribute names being "reserved" at that point -- we're not checking whether they're reserved or not, and it really doesn't matter. Warning on a #define that clobbers the name of a standard attribute is just generally a good thing to do, regardless of whether you're using the standard library.

I agree with this 100%. The link to the 'reserved by the standard' is I think a good additional justification.
I think the proposal, complaining about these as reserved, is a good idea/good patch. BUT I think getting caught up in the "well, when is it technically NOT UB" is a waste of time, given that the warning is a good idea even without that justification.

I think the warning is justified even without a standard library header being included, but I also wonder if that means putting this under -Wreserved-identifier is the wrong home and maybe this is a -Wattributes warning group instead. We could reword the diagnostic to something along the lines of "macro name conflicts with the name of a %select{vendor attribute prefix|standard attribute|attribute name}0" and we warn on all three of these cases:

#define msvc 12 // conflicts with [[msvc::no_unique_address]]
#define annotate 12 // conflicts with [[clang::annotate]]
#define nodiscard 12 // conflicts with [[nodiscard]]

WDYT?

First, I think this needs its OWN warning group, as I can see justification for disabling just this.

Agreed, I didn't mean to imply otherwise, I was speaking about the top-level umbrella (sorry for the confusion).

Second, I think that the 'standard' attribute interference is a level of severity HIGHER than the others thanks to being in the standard (and thus, perhaps, likely more to be used/interfered with).

I think the problem is the same regardless of whether the attribute is a standard attribute or a vendor attribute -- either way, redefining the meaning of something known to the implementation seems worth of letting the user know about.

Third: DOES annotate conflict with attribute annotate? Isn't that a function/would have to be a function macro?

Ah, good point, but the basic premise still stands.

Fourth: I think the 'reserved name' has a level of gravitas/concreteness that makes the diagnostic more meaningful/immediately obvious to folks. A diagnostic of, "This name you chose for your macro might make this attribute no workie" yields "Yeah, but i wont use that so I'm ok". A diagnostic of, "This name is UB because the standard reserves it!" yields a level of pause/consideration that we otherwise wouldn't get.

Yes, but the point is: these names aren't reserved but the pain can still happen. e.g., cdecl is not a reserved identifier, but re-defining its meaning can still break code in ways that could have better diagnostics: https://godbolt.org/z/vTfWPsYj9. Though, I suppose to reduce the chattiness, we could elect to diagnose when we see an attribute that is ill-formed due to the macro. e.g.,

#define cdecl 12
#define stdcall 100 // No warning, doesn't cause problems (yet)

void func() [[gnu::cdecl]]; // Expands to `[[gnu::12]] which is an error, so warn on the #define above

SO I think the diagnostic being associated with it being reserved is COMPLETELY valid/justifiable. I think "this is a bad idea, UB or not" is a reason to not try at all to suppress this if we think you're not ACTUALLY breaking the rule (by not including an StdLib header).

If we're only going to diagnose conflicts with standard attribute names, then I can squint enough to agree. But I think that's an arbitrary limitation; we all just agreed that this isn't about using a reserved identifier so much as about writing a macro which will conflict with uses of attributes of the same name.

@a-tarasyuk a-tarasyuk marked this pull request as ready for review January 14, 2025 21:50
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Jan 14, 2025
@a-tarasyuk
Copy link
Member Author

@AaronBallman @erichkeane I’ve switched back to the version without the std check. should the diagnostic group be changed?

@a-tarasyuk a-tarasyuk requested a review from erichkeane January 15, 2025 14:03
@AaronBallman
Copy link
Collaborator

@AaronBallman @erichkeane I’ve switched back to the version without the std check. should the diagnostic group be changed?

I think we're fine to leave it as-is.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@a-tarasyuk a-tarasyuk merged commit 4018317 into llvm:main Jan 23, 2025
9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 23, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-dylib running on linaro-flang-aarch64-dylib while building clang,llvm,utils at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/50/builds/9302

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
1449.577 [1655/1/5165] Building CXX object tools/mlir/lib/Dialect/IRDL/CMakeFiles/obj.MLIRIRDL.dir/IRDLVerifiers.cpp.o
1449.671 [1654/1/5166] Linking CXX static library lib/libMLIRIRDL.a
1449.778 [1653/1/5167] Building CXX object tools/mlir/lib/Dialect/Linalg/TransformOps/CMakeFiles/obj.MLIRLinalgTransformOps.dir/GPUHeuristics.cpp.o
1449.971 [1652/1/5168] Building CXX object tools/mlir/lib/Dialect/Linalg/TransformOps/CMakeFiles/obj.MLIRLinalgTransformOps.dir/DialectExtension.cpp.o
1450.095 [1651/1/5169] Building CXX object tools/mlir/lib/CAPI/Dialect/CMakeFiles/obj.MLIRCAPIArith.dir/Arith.cpp.o
1450.359 [1650/1/5170] Building CXX object tools/mlir/lib/Dialect/Linalg/IR/CMakeFiles/obj.MLIRLinalgDialect.dir/LinalgInterfaces.cpp.o
1450.489 [1649/1/5171] Building CXX object tools/mlir/lib/Dialect/Linalg/IR/CMakeFiles/obj.MLIRLinalgDialect.dir/ValueBoundsOpInterfaceImpl.cpp.o
1450.636 [1648/1/5172] Building CXX object tools/mlir/lib/Dialect/Linalg/IR/CMakeFiles/obj.MLIRLinalgDialect.dir/LinalgDialect.cpp.o
1450.758 [1647/1/5173] Building CXX object tools/mlir/lib/Dialect/Linalg/IR/CMakeFiles/obj.MLIRLinalgDialect.dir/LinalgOps.cpp.o
1468.616 [1646/1/5174] Building CXX object tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestSymbolUses.cpp.o
FAILED: tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestSymbolUses.cpp.o 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DMLIR_INCLUDE_TESTS -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/mlir/test/lib/IR -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/mlir/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/llvm/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/../Dialect/Test -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/mlir/test/lib/IR/../Dialect/Test -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Werror=mismatched-tags -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestSymbolUses.cpp.o -MF tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestSymbolUses.cpp.o.d -o tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestSymbolUses.cpp.o -c /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/TestSymbolUses.cpp
In file included from /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/TestSymbolUses.cpp:9:
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/../Dialect/Test/TestOps.h:148:10: fatal error: 'TestOps.h.inc' file not found
  148 | #include "TestOps.h.inc"
      |          ^~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 24, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building clang,llvm,utils at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/20722

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: UBSan-Minimal-x86_64 :: TestCases/recover-dedup.cpp (93836 of 97887)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Float/cast-overflow.cpp (93837 of 97887)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp (93838 of 97887)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/ImplicitConversion/integer-sign-change-summary.cpp (93839 of 97887)
PASS: UBSan-MemorySanitizer-lld-x86_64 :: TestCases/TypeCheck/vptr.cpp (93840 of 97887)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-summary.cpp (93841 of 97887)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/Function/function.cpp (93842 of 97887)
PASS: UBSan-Minimal-x86_64 :: TestCases/nullptr-and-nonzero-offset.c (93843 of 97887)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/Posix/diag-stacktrace.cpp (93844 of 97887)
TIMEOUT: MLIR :: Examples/standalone/test.toy (93845 of 97887)
******************** TEST 'MLIR :: Examples/standalone/test.toy' FAILED ********************
Exit Code: -9
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" "/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone" -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++  -DCMAKE_C_COMPILER=/usr/bin/clang   -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  -DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake /build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout------------
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
# | -- Using MLIRConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No diagnostic is reported for illegal macro definitions such as "noreturn" and "carries_dependency"