Skip to content

[Clang] Correctly handle allocations in the condition of a if constexpr #146890

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 4 commits into from
Jul 4, 2025

Conversation

cor3ntin
Copy link
Contributor

@cor3ntin cor3ntin commented Jul 3, 2025

Deal with the following scenario

struct S {
    char* c = new char;
    constexpr ~S() {
        delete c;
    }
};
if constexpr((S{}, true)){};

There were two issues

  • We need to produce a full expression before evaluating the condition (otherwise, automatic variables are never destroyed)
  • We need to preserve the evaluation context of the condition while doing the semantics analysis for it (lest it is evaluated in a non-constant-evaluated context)

Fixes #120197
Fixes #134820

…xpr`

Deal with the following scenario

```cpp
struct S {
    char* c = new char;
    constexpr ~S() {
        delete c;
    }
};
if constexpr((S{}, true)){};
```

There were two issues
 - We need to produce a full expressions _before_ evaluating the condition
   (otherwise automatic variables are neber destroyed)
 - We need to preserve the evaluation context of the condition while doing
   the semantics analysis for it (lest it is evaluated in a non constant
   evaluated context)

Fixes llvm#120197
Fixes llvm#134820
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 3, 2025

@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)

Changes

Deal with the following scenario

struct S {
    char* c = new char;
    constexpr ~S() {
        delete c;
    }
};
if constexpr((S{}, true)){};

There were two issues

  • We need to produce a full expression before evaluating the condition (otherwise, automatic variables are never destroyed)
  • We need to preserve the evaluation context of the condition while doing the semantics analysis for it (lest it is evaluated in a non-constant-evaluated context)

Fixes #120197
Fixes #134820


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

6 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (+1)
  • (modified) clang/include/clang/Sema/Sema.h (+3-3)
  • (modified) clang/lib/Parse/ParseExprCXX.cpp (+7-9)
  • (modified) clang/lib/Sema/SemaExpr.cpp (+6-5)
  • (modified) clang/lib/Sema/SemaExprCXX.cpp (+8-1)
  • (modified) clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp (+33)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3d893e0aa8e2c..9f9fc84b53104 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -896,6 +896,7 @@ Bug Fixes to C++ Support
 - Fixed a crash when constant evaluating some explicit object member assignment operators. (#GH142835)
 - Fixed an access checking bug when substituting into concepts (#GH115838)
 - Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
+- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3fe26f950ad51..b281b1cfef96a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7723,12 +7723,12 @@ class Sema final : public SemaBase {
 
   class ConditionResult {
     Decl *ConditionVar;
-    FullExprArg Condition;
+    ExprResult Condition;
     bool Invalid;
     std::optional<bool> KnownValue;
 
     friend class Sema;
-    ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
+    ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
                     bool IsConstexpr)
         : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
       if (IsConstexpr && Condition.get()) {
@@ -7739,7 +7739,7 @@ class Sema final : public SemaBase {
       }
     }
     explicit ConditionResult(bool Invalid)
-        : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
+        : ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
           KnownValue(std::nullopt) {}
 
   public:
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 1ea0cf52933f6..9f36c3ade5e74 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -1931,15 +1931,13 @@ Parser::ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc,
       return ParseCXXCondition(nullptr, Loc, CK, MissingOK);
     }
 
-    ExprResult Expr = [&] {
-      EnterExpressionEvaluationContext Eval(
-          Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
-          /*LambdaContextDecl=*/nullptr,
-          /*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other,
-          /*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf);
-      // Parse the expression.
-      return ParseExpression(); // expression
-    }();
+    EnterExpressionEvaluationContext Eval(
+        Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
+        /*LambdaContextDecl=*/nullptr,
+        /*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other,
+        /*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf);
+
+    ExprResult Expr = ParseExpression();
 
     if (Expr.isInvalid())
       return Sema::ConditionError();
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 437df742d572b..7c65489cc6234 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20629,6 +20629,9 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,
 
   case ConditionKind::ConstexprIf:
     Cond = CheckBooleanCondition(Loc, SubExpr, true);
+    assert(isa<FullExpr>(Cond.get()) &&
+           "we should have converted this expression to a FullExpr before "
+           "evaluating it");
     break;
 
   case ConditionKind::Switch:
@@ -20641,12 +20644,10 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,
     if (!Cond.get())
       return ConditionError();
   }
-  // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead.
-  FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc);
-  if (!FullExpr.get())
-    return ConditionError();
+  if (!isa<FullExpr>(Cond.get()))
+    Cond = ActOnFinishFullExpr(Cond.get(), Loc, /*DiscardedValue*/ false);
 
-  return ConditionResult(*this, nullptr, FullExpr,
+  return ConditionResult(*this, nullptr, Cond,
                          CK == ConditionKind::ConstexprIf);
 }
 
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 4a86cbd0633b6..f17a338825423 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4357,7 +4357,8 @@ Sema::ConditionResult Sema::ActOnConditionVariable(Decl *ConditionVar,
       CheckConditionVariable(cast<VarDecl>(ConditionVar), StmtLoc, CK);
   if (E.isInvalid())
     return ConditionError();
-  return ConditionResult(*this, ConditionVar, MakeFullExpr(E.get(), StmtLoc),
+  E = ActOnFinishFullExpr(E.get(), /*DiscardedValue*/ false);
+  return ConditionResult(*this, ConditionVar, E,
                          CK == ConditionKind::ConstexprIf);
 }
 
@@ -4417,6 +4418,12 @@ ExprResult Sema::CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr) {
   if (!IsConstexpr || E.isInvalid() || E.get()->isValueDependent())
     return E;
 
+  E = ActOnFinishFullExpr(E.get(), E.get()->getExprLoc(),
+                          /*DiscardedValue*/ false,
+                          /*IsConstexpr*/ true);
+  if (E.isInvalid())
+    return E;
+
   // FIXME: Return this value to the caller so they don't need to recompute it.
   llvm::APSInt Cond;
   E = VerifyIntegerConstantExpression(
diff --git a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
index ed8cbbbfe7067..edffe177e08c7 100644
--- a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
+++ b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
@@ -242,3 +242,36 @@ void f() {
 }
 
 }
+
+namespace GH134820 {
+struct S {
+    char* c = new char;
+    constexpr ~S() {
+        delete c;
+    }
+};
+
+int f() {
+    if constexpr((S{}, true)) {
+        return 1;
+    }
+    return 0;
+}
+}
+
+namespace GH120197{
+struct NonTrivialDtor {
+  NonTrivialDtor() = default;
+  NonTrivialDtor(const NonTrivialDtor&) = default;
+  NonTrivialDtor(NonTrivialDtor&&) = default;
+  NonTrivialDtor& operator=(const NonTrivialDtor&)  = default;
+  NonTrivialDtor& operator=(NonTrivialDtor&&) = default;
+  constexpr ~NonTrivialDtor() noexcept {}
+};
+
+static_assert(((void)NonTrivialDtor{}, true)); // passes
+
+void f() {
+  if constexpr ((void)NonTrivialDtor{}, true) {}
+}
+}

@@ -20629,6 +20629,9 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,

case ConditionKind::ConstexprIf:
Cond = CheckBooleanCondition(Loc, SubExpr, true);
assert(isa<FullExpr>(Cond.get()) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cond could still be invalid here, right? so .get would be ill-formed? Should we be doing some sort of if (Cond.isUsable()) or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the assert was incorrect, I removed it

Cond = ActOnFinishFullExpr(Cond.get(), Loc, /*DiscardedValue*/ false);

if (Cond.isInvalid())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (Cond.isInvalid())
if (!Cond.isUsable())

Unless there is a reason that ConditionResult would be ok with a 'null' expr?

Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
/*LambdaContextDecl=*/nullptr,
/*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_Other,
/*ShouldEnter=*/CK == Sema::ConditionKind::ConstexprIf);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to make an equivalent change to TreeTransform?

I came up with the following testcase:

struct S {
    char* c = new char;
    consteval S(){}
    constexpr ~S() {
        delete c;
    }
};
template<typename T> 
int f() {
    if constexpr((T{}, true)) {
        return 1;
    }
    return 0;
}
auto ff = f<S>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, thanks for thinking about that

@cor3ntin cor3ntin merged commit af2bb8f into llvm:main Jul 4, 2025
10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 4, 2025

LLVM Buildbot has detected a new failure on builder hip-third-party-libs-test running on ext_buildbot_hw_05-hip-docker while building clang at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py --jobs=32' (failure)
...
[6310/7914] Linking CXX shared library lib/libMLIRSPIRVDialect.so.21.0git
[6311/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/UninitializedObject/UninitializedObjectChecker.cpp.o
[6312/7914] Creating library symlink lib/libMLIRTensorTestPasses.so
[6313/7914] Creating library symlink lib/libMLIRSPIRVDialect.so
[6314/7914] Linking CXX shared library lib/libMLIRNVVMTarget.so.21.0git
[6315/7914] Linking CXX shared library lib/libMLIRSCFTestPasses.so.21.0git
[6316/7914] Creating library symlink lib/libMLIRNVVMTarget.so
[6317/7914] Linking CXX shared library lib/libMLIRTestTransformDialect.so.21.0git
[6318/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelConsumer.cpp.o
[6319/7914] Linking CXX shared library lib/libMLIRXeVMDialect.so.21.0git
FAILED: lib/libMLIRXeVMDialect.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/hip-third-party-libs-test/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRXeVMDialect.so.21.0git -o lib/libMLIRXeVMDialect.so.21.0git tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/hip-third-party-libs-test/build/lib:"  lib/libMLIRLLVMDialect.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/hip-third-party-libs-test/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o: in function `llvm::LogicalResult (anonymous namespace)::verifyMatrixInput<mlir::xevm::BlockLoad2dOp>(mlir::xevm::BlockLoad2dOp)':
XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm13BlockLoad2dOpEEEN4llvm13LogicalResultET_+0x68): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm13BlockLoad2dOpEEEN4llvm13LogicalResultET_+0xb7): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o: in function `llvm::LogicalResult (anonymous namespace)::verifyMatrixInput<mlir::xevm::BlockPrefetch2dOp>(mlir::xevm::BlockPrefetch2dOp)':
XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm17BlockPrefetch2dOpEEEN4llvm13LogicalResultET_+0x68): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm17BlockPrefetch2dOpEEEN4llvm13LogicalResultET_+0xb7): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o: in function `llvm::LogicalResult (anonymous namespace)::verifyMatrixInput<mlir::xevm::BlockStore2dOp>(mlir::xevm::BlockStore2dOp)':
XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm14BlockStore2dOpEEEN4llvm13LogicalResultET_+0x68): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o:XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm14BlockStore2dOpEEEN4llvm13LogicalResultET_+0xb7): more undefined references to `mlir::getConstantIntValue(mlir::OpFoldResult)' follow
collect2: error: ld returned 1 exit status
[6320/7914] Linking CXX shared library lib/libMLIRAsyncToLLVM.so.21.0git
[6321/7914] Linking CXX shared library lib/libMLIROpenMPToLLVM.so.21.0git
[6322/7914] Linking CXX shared library lib/libMLIRSCFToControlFlow.so.21.0git
[6323/7914] Linking CXX shared library lib/libMLIRVectorToLLVMPass.so.21.0git
[6324/7914] Linking CXX shared library lib/libMLIRVectorTransformOps.so.21.0git
[6325/7914] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
[6326/7914] Linking CXX shared library lib/libMLIRXeGPUTransforms.so.21.0git
[6327/7914] Linking CXX shared library lib/libMLIRSPIRVModuleCombiner.so.21.0git
[6328/7914] Linking CXX shared library lib/libMLIRSPIRVUtils.so.21.0git
[6329/7914] Linking CXX shared library lib/libMLIRSPIRVConversion.so.21.0git
[6330/7914] Linking CXX shared library lib/libMLIRExecutionEngine.so.21.0git
[6331/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ValistChecker.cpp.o
[6332/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VLASizeChecker.cpp.o
[6333/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VforkChecker.cpp.o
[6334/7914] Linking CXX shared library lib/libMLIRSPIRVSerialization.so.21.0git
[6335/7914] Linking CXX shared library lib/libMLIRSPIRVDeserialization.so.21.0git
[6336/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefMemberChecker.cpp.o
[6337/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefLambdaCapturesChecker.cpp.o
[6338/7914] Linking CXX shared library lib/libMLIRLinalgTransforms.so.21.0git
[6339/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/AnalysisConsumer.cpp.o
[6340/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefCallArgsChecker.cpp.o
[6341/7914] Linking CXX shared library lib/libMLIRArmSMEToLLVM.so.21.0git
[6342/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/FrontendActions.cpp.o
[6343/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VirtualCallChecker.cpp.o
[6344/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
[6345/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RefCntblBaseVirtualDtorChecker.cpp.o
[6346/7914] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o
Step 7 (build cmake config) failure: build cmake config (failure)
...
[6310/7914] Linking CXX shared library lib/libMLIRSPIRVDialect.so.21.0git
[6311/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/UninitializedObject/UninitializedObjectChecker.cpp.o
[6312/7914] Creating library symlink lib/libMLIRTensorTestPasses.so
[6313/7914] Creating library symlink lib/libMLIRSPIRVDialect.so
[6314/7914] Linking CXX shared library lib/libMLIRNVVMTarget.so.21.0git
[6315/7914] Linking CXX shared library lib/libMLIRSCFTestPasses.so.21.0git
[6316/7914] Creating library symlink lib/libMLIRNVVMTarget.so
[6317/7914] Linking CXX shared library lib/libMLIRTestTransformDialect.so.21.0git
[6318/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelConsumer.cpp.o
[6319/7914] Linking CXX shared library lib/libMLIRXeVMDialect.so.21.0git
FAILED: lib/libMLIRXeVMDialect.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/hip-third-party-libs-test/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRXeVMDialect.so.21.0git -o lib/libMLIRXeVMDialect.so.21.0git tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/hip-third-party-libs-test/build/lib:"  lib/libMLIRLLVMDialect.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/hip-third-party-libs-test/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o: in function `llvm::LogicalResult (anonymous namespace)::verifyMatrixInput<mlir::xevm::BlockLoad2dOp>(mlir::xevm::BlockLoad2dOp)':
XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm13BlockLoad2dOpEEEN4llvm13LogicalResultET_+0x68): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm13BlockLoad2dOpEEEN4llvm13LogicalResultET_+0xb7): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o: in function `llvm::LogicalResult (anonymous namespace)::verifyMatrixInput<mlir::xevm::BlockPrefetch2dOp>(mlir::xevm::BlockPrefetch2dOp)':
XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm17BlockPrefetch2dOpEEEN4llvm13LogicalResultET_+0x68): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm17BlockPrefetch2dOpEEEN4llvm13LogicalResultET_+0xb7): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o: in function `llvm::LogicalResult (anonymous namespace)::verifyMatrixInput<mlir::xevm::BlockStore2dOp>(mlir::xevm::BlockStore2dOp)':
XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm14BlockStore2dOpEEEN4llvm13LogicalResultET_+0x68): undefined reference to `mlir::getConstantIntValue(mlir::OpFoldResult)'
/usr/bin/ld: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRXeVMDialect.dir/IR/XeVMDialect.cpp.o:XeVMDialect.cpp:(.text._ZN12_GLOBAL__N_117verifyMatrixInputIN4mlir4xevm14BlockStore2dOpEEEN4llvm13LogicalResultET_+0xb7): more undefined references to `mlir::getConstantIntValue(mlir::OpFoldResult)' follow
collect2: error: ld returned 1 exit status
[6320/7914] Linking CXX shared library lib/libMLIRAsyncToLLVM.so.21.0git
[6321/7914] Linking CXX shared library lib/libMLIROpenMPToLLVM.so.21.0git
[6322/7914] Linking CXX shared library lib/libMLIRSCFToControlFlow.so.21.0git
[6323/7914] Linking CXX shared library lib/libMLIRVectorToLLVMPass.so.21.0git
[6324/7914] Linking CXX shared library lib/libMLIRVectorTransformOps.so.21.0git
[6325/7914] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
[6326/7914] Linking CXX shared library lib/libMLIRXeGPUTransforms.so.21.0git
[6327/7914] Linking CXX shared library lib/libMLIRSPIRVModuleCombiner.so.21.0git
[6328/7914] Linking CXX shared library lib/libMLIRSPIRVUtils.so.21.0git
[6329/7914] Linking CXX shared library lib/libMLIRSPIRVConversion.so.21.0git
[6330/7914] Linking CXX shared library lib/libMLIRExecutionEngine.so.21.0git
[6331/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ValistChecker.cpp.o
[6332/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VLASizeChecker.cpp.o
[6333/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VforkChecker.cpp.o
[6334/7914] Linking CXX shared library lib/libMLIRSPIRVSerialization.so.21.0git
[6335/7914] Linking CXX shared library lib/libMLIRSPIRVDeserialization.so.21.0git
[6336/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefMemberChecker.cpp.o
[6337/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefLambdaCapturesChecker.cpp.o
[6338/7914] Linking CXX shared library lib/libMLIRLinalgTransforms.so.21.0git
[6339/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/AnalysisConsumer.cpp.o
[6340/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefCallArgsChecker.cpp.o
[6341/7914] Linking CXX shared library lib/libMLIRArmSMEToLLVM.so.21.0git
[6342/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/FrontendActions.cpp.o
[6343/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VirtualCallChecker.cpp.o
[6344/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
[6345/7914] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RefCntblBaseVirtualDtorChecker.cpp.o
[6346/7914] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Constexpr allocating temporaries in if constexpr are rejected. Cannot compare std::string's in if constexpr
5 participants