Files
TheRock/compiler/amd-llvm/clang/test/Analysis/missing-bind-temporary.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

125 lines
3.2 KiB
C++

// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=debug.DumpCFG -std=c++14 -analyzer-config eagerly-assume=false %s > %t 2>&1
// RUN: FileCheck --input-file=%t %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=core,debug.ExprInspection -std=c++14 -verify -analyzer-config eagerly-assume=false %s
void clang_analyzer_eval(bool);
int global;
namespace variant_0 {
class A {
public:
~A() { ++global; }
};
class B {
A a;
};
// CHECK: void foo(int)
// CHECK: [B1]
// CHECK-NEXT: 1: (CXXConstructExpr, [B1.2], B)
// CHECK-NEXT: 2: B i;
// CHECK-NEXT: 3: operator=
// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, B &(*)(B &&) noexcept)
// CHECK-NEXT: 5: {} (CXXConstructExpr, [B1.6], [B1.7], B)
// CHECK-NEXT: 6: [B1.5] (BindTemporary)
// CHECK-NEXT: 7: [B1.6]
// CHECK-NEXT: 8: i
// CHECK-NEXT: 9: [B1.8] = [B1.7] (OperatorCall)
// CHECK-NEXT: 10: ~B() (Temporary object destructor)
// CHECK-NEXT: 11: [B1.2].~B() (Implicit destructor)
void foo(int) {
B i;
i = {};
}
void bar() {
global = 0;
foo(1);
clang_analyzer_eval(global == 2); // expected-warning{{TRUE}}
}
} // end namespace variant_0
namespace variant_1 {
class A {
public:
~A() { ++global; }
};
class B {
A a;
};
// CHECK: template<> void foo<int>(int)
// CHECK: [B1]
// CHECK-NEXT: 1: (CXXConstructExpr, [B1.2], B)
// CHECK-NEXT: 2: B i;
// CHECK-NEXT: 3: operator=
// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, B &(*)(B &&) noexcept)
// CHECK-NEXT: 5: {} (CXXConstructExpr, [B1.6], [B1.7], B)
// CHECK-NEXT: 6: [B1.5] (BindTemporary)
// CHECK-NEXT: 7: [B1.6]
// CHECK-NEXT: 8: i
// CHECK-NEXT: 9: [B1.8] = [B1.7] (OperatorCall)
// CHECK-NEXT: 10: ~B() (Temporary object destructor)
// CHECK-NEXT: 11: [B1.2].~B() (Implicit destructor)
template <typename T> void foo(T) {
B i;
i = {};
}
void bar() {
global = 0;
foo(1);
clang_analyzer_eval(global == 2); // expected-warning{{TRUE [debug.ExprInspection]}}
}
} // end namespace variant_1
namespace variant_2 {
// Making field 'a' in class 'B' public turns the class into an aggregate.
// In this case there is no constructor at {} - only an aggregate
// initialization. Aggregate initialization is unsupported for now.
class A {
public:
~A() { ++global; }
};
class B {
public:
A a;
};
// CHECK: template<> void foo<int>(int)
// CHECK: [B1]
// CHECK-NEXT: 1: (CXXConstructExpr, [B1.2], B)
// CHECK-NEXT: 2: B i;
// CHECK-NEXT: 3: operator=
// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, B &(*)(B &&) noexcept)
// CHECK-NEXT: 5: {}
// CHECK-NEXT: 6: {}
// CHECK-NEXT: 7: [B1.6] (BindTemporary)
// CHECK-NEXT: 8: [B1.7]
// CHECK-NEXT: 9: i
// CHECK-NEXT: 10: [B1.9] = [B1.8] (OperatorCall)
// CHECK-NEXT: 11: ~B() (Temporary object destructor)
// CHECK-NEXT: 12: [B1.2].~B() (Implicit destructor)
template <typename T> void foo(T) {
B i;
i = {};
}
void bar() {
global = 0;
foo(1);
// FIXME: Should be TRUE, i.e. we should call (and inline) two destructors.
clang_analyzer_eval(global == 2); // expected-warning{{UNKNOWN}}
}
} // end namespace variant_2