[clang] [clang][analyzer] Add support for detecting uninitialized dynamically-allocated objects (PR #193001)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 20 08:39:04 PDT 2026
https://github.com/guillem-bartrina-sonarsource updated https://github.com/llvm/llvm-project/pull/193001
>From 8a817ec3d3e5cf5fc687070a3b147265427706f8 Mon Sep 17 00:00:00 2001
From: guillem-bartrina-sonarsource <guillem.bartrina at sonarsource.com>
Date: Mon, 20 Apr 2026 16:06:33 +0200
Subject: [PATCH 1/2] [clang][analyzer] Add support for detecting uninitialized
dynamically-allocated objects
---
.../UninitializedObjectChecker.cpp | 35 +++-
.../cxx-uninitialized-object-inheritance.cpp | 128 +++++++-----
...xx-uninitialized-object-no-dereference.cpp | 6 +-
...uninitialized-object-notes-as-warnings.cpp | 5 +-
.../cxx-uninitialized-object-ptr-ref.cpp | 175 ++++++++++++-----
...-uninitialized-object-unguarded-access.cpp | 24 ++-
...nitialized-object-unionlike-constructs.cpp | 5 +
.../Analysis/cxx-uninitialized-object.cpp | 185 ++++++++++++------
.../Analysis/objcpp-uninitialized-object.mm | 11 +-
9 files changed, 401 insertions(+), 173 deletions(-)
diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 6d4389fda8753..2b46d1c913b2a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -451,26 +451,44 @@ static void printTail(llvm::raw_ostream &Out,
// Utility functions.
//===----------------------------------------------------------------------===//
+static const SubRegion *
+ getConstructedSubRegion(const CXXConstructorDecl *CtorDecl,
+ CheckerContext &Context) {
+ Loc ThisLoc =
+ Context.getSValBuilder().getCXXThis(CtorDecl, Context.getStackFrame());
+ SVal ObjectV = Context.getState()->getSVal(ThisLoc);
+ return ObjectV.getAsRegion()->getAs<SubRegion>();
+}
+
static const TypedValueRegion *
getConstructedRegion(const CXXConstructorDecl *CtorDecl,
CheckerContext &Context) {
- Loc ThisLoc =
- Context.getSValBuilder().getCXXThis(CtorDecl, Context.getStackFrame());
+ const SubRegion *SR = getConstructedSubRegion(CtorDecl, Context);
+ if (!SR)
+ return nullptr;
- SVal ObjectV = Context.getState()->getSVal(ThisLoc);
+ if (const auto *TVR = SR->getAs<TypedValueRegion>()) {
+ return TVR->getValueType()->getAsCXXRecordDecl() ? TVR : nullptr;
+ }
- auto *R = ObjectV.getAsRegion()->getAs<TypedValueRegion>();
- if (R && !R->getValueType()->getAsCXXRecordDecl())
+ QualType DynType = CtorDecl->getThisType()->getPointeeType();
+ if (!DynType->getAsCXXRecordDecl())
return nullptr;
- return R;
+ auto &MemMgr = Context.getState()->getStateManager().getRegionManager();
+ auto &SVB = Context.getSValBuilder();
+
+ const auto *ElemR = MemMgr.getElementRegion(
+ DynType, SVB.makeZeroArrayIndex(), SR, Context.getASTContext());
+
+ return ElemR;
}
static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
CheckerContext &Context) {
- const TypedValueRegion *CurrRegion = getConstructedRegion(Ctor, Context);
+ const SubRegion *CurrRegion = getConstructedSubRegion(Ctor, Context);
if (!CurrRegion)
return false;
@@ -482,8 +500,7 @@ static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
if (!OtherCtor)
continue;
- const TypedValueRegion *OtherRegion =
- getConstructedRegion(OtherCtor, Context);
+ const SubRegion *OtherRegion = getConstructedSubRegion(OtherCtor, Context);
if (!OtherRegion)
continue;
diff --git a/clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp b/clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
index e2d190daaaa94..e94ed94f1b728 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
@@ -32,10 +32,11 @@ class NonPolymorphicInheritanceTest1 : public NonPolymorphicLeft1 {
void fNonPolymorphicInheritanceTest1() {
NonPolymorphicInheritanceTest1();
+ new NonPolymorphicInheritanceTest1();
}
class NonPolymorphicBaseClass2 {
- int x; // expected-note{{uninitialized field 'this->NonPolymorphicBaseClass2::x'}}
+ int x; // expected-note{{uninitialized field 'this->NonPolymorphicBaseClass2::x'}} expected-note{{uninitialized field 'this->NonPolymorphicBaseClass2::x'}}
protected:
int y;
@@ -50,19 +51,20 @@ class NonPolymorphicInheritanceTest2 : public NonPolymorphicBaseClass2 {
public:
NonPolymorphicInheritanceTest2() {
y = 5;
- z = 6; // expected-warning{{1 uninitialized field}}
+ z = 6; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fNonPolymorphicInheritanceTest2() {
NonPolymorphicInheritanceTest2();
+ new NonPolymorphicInheritanceTest2();
}
class NonPolymorphicBaseClass3 {
int x;
protected:
- int y; // expected-note{{uninitialized field 'this->NonPolymorphicBaseClass3::y'}}
+ int y; // expected-note{{uninitialized field 'this->NonPolymorphicBaseClass3::y'}} expected-note{{uninitialized field 'this->NonPolymorphicBaseClass3::y'}}
public:
NonPolymorphicBaseClass3() = default;
NonPolymorphicBaseClass3(int) : x(7) {}
@@ -74,12 +76,13 @@ class NonPolymorphicInheritanceTest3 : public NonPolymorphicBaseClass3 {
public:
NonPolymorphicInheritanceTest3()
: NonPolymorphicBaseClass3(int{}) {
- z = 8; // expected-warning{{1 uninitialized field}}
+ z = 8; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fNonPolymorphicInheritanceTest3() {
NonPolymorphicInheritanceTest3();
+ new NonPolymorphicInheritanceTest3();
}
class NonPolymorphicBaseClass4 {
@@ -94,17 +97,18 @@ class NonPolymorphicBaseClass4 {
};
class NonPolymorphicInheritanceTest4 : public NonPolymorphicBaseClass4 {
- int z; // expected-note{{uninitialized field 'this->z'}}
+ int z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
public:
NonPolymorphicInheritanceTest4()
: NonPolymorphicBaseClass4(int{}) {
- y = 10; // expected-warning{{1 uninitialized field}}
+ y = 10; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fNonPolymorphicInheritanceTest4() {
NonPolymorphicInheritanceTest4();
+ new NonPolymorphicInheritanceTest4();
}
//===----------------------------------------------------------------------===//
@@ -137,10 +141,11 @@ class PolymorphicInheritanceTest1 : public PolymorphicLeft1 {
void fPolymorphicInheritanceTest1() {
PolymorphicInheritanceTest1();
+ new PolymorphicInheritanceTest1();
}
class PolymorphicRight1 {
- int x; // expected-note{{uninitialized field 'this->PolymorphicRight1::x'}}
+ int x; // expected-note{{uninitialized field 'this->PolymorphicRight1::x'}} expected-note{{uninitialized field 'this->PolymorphicRight1::x'}}
protected:
int y;
@@ -156,19 +161,20 @@ class PolymorphicInheritanceTest2 : public PolymorphicRight1 {
public:
PolymorphicInheritanceTest2() {
y = 15;
- z = 16; // expected-warning{{1 uninitialized field}}
+ z = 16; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fPolymorphicInheritanceTest2() {
PolymorphicInheritanceTest2();
+ new PolymorphicInheritanceTest2();
}
class PolymorphicBaseClass3 {
int x;
protected:
- int y; // expected-note{{uninitialized field 'this->PolymorphicBaseClass3::y'}}
+ int y; // expected-note{{uninitialized field 'this->PolymorphicBaseClass3::y'}} expected-note{{uninitialized field 'this->PolymorphicBaseClass3::y'}}
public:
virtual ~PolymorphicBaseClass3() = default;
PolymorphicBaseClass3() = default;
@@ -181,12 +187,13 @@ class PolymorphicInheritanceTest3 : public PolymorphicBaseClass3 {
public:
PolymorphicInheritanceTest3()
: PolymorphicBaseClass3(int{}) {
- z = 18; // expected-warning{{1 uninitialized field}}
+ z = 18; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fPolymorphicInheritanceTest3() {
PolymorphicInheritanceTest3();
+ new PolymorphicInheritanceTest3();
}
class PolymorphicBaseClass4 {
@@ -202,17 +209,18 @@ class PolymorphicBaseClass4 {
};
class PolymorphicInheritanceTest4 : public PolymorphicBaseClass4 {
- int z; // expected-note{{uninitialized field 'this->z'}}
+ int z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
public:
PolymorphicInheritanceTest4()
: PolymorphicBaseClass4(int{}) {
- y = 20; // expected-warning{{1 uninitialized field}}
+ y = 20; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fPolymorphicInheritanceTest4() {
PolymorphicInheritanceTest4();
+ new PolymorphicInheritanceTest4();
}
//===----------------------------------------------------------------------===//
@@ -245,10 +253,11 @@ class VirtualInheritanceTest1 : virtual public VirtualPolymorphicLeft1 {
void fVirtualInheritanceTest1() {
VirtualInheritanceTest1();
+ new VirtualInheritanceTest1();
}
class VirtualPolymorphicRight1 {
- int x; // expected-note{{uninitialized field 'this->VirtualPolymorphicRight1::x'}}
+ int x; // expected-note{{uninitialized field 'this->VirtualPolymorphicRight1::x'}} expected-note{{uninitialized field 'this->VirtualPolymorphicRight1::x'}}
protected:
int y;
@@ -264,19 +273,20 @@ class VirtualInheritanceTest2 : virtual public VirtualPolymorphicRight1 {
public:
VirtualInheritanceTest2() {
y = 25;
- z = 26; // expected-warning{{1 uninitialized field}}
+ z = 26; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fVirtualInheritanceTest2() {
VirtualInheritanceTest2();
+ new VirtualInheritanceTest2();
}
class VirtualPolymorphicBaseClass3 {
int x;
protected:
- int y; // expected-note{{uninitialized field 'this->VirtualPolymorphicBaseClass3::y'}}
+ int y; // expected-note{{uninitialized field 'this->VirtualPolymorphicBaseClass3::y'}} expected-note{{uninitialized field 'this->VirtualPolymorphicBaseClass3::y'}}
public:
virtual ~VirtualPolymorphicBaseClass3() = default;
VirtualPolymorphicBaseClass3() = default;
@@ -289,12 +299,13 @@ class VirtualInheritanceTest3 : virtual public VirtualPolymorphicBaseClass3 {
public:
VirtualInheritanceTest3()
: VirtualPolymorphicBaseClass3(int{}) {
- z = 28; // expected-warning{{1 uninitialized field}}
+ z = 28; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fVirtualInheritanceTest3() {
VirtualInheritanceTest3();
+ new VirtualInheritanceTest3();
}
//===----------------------------------------------------------------------===//
@@ -348,8 +359,11 @@ class MultipleInheritanceTest1 : public Left1, public Right1 {
void fMultipleInheritanceTest1() {
MultipleInheritanceTest1();
+ new MultipleInheritanceTest1();
MultipleInheritanceTest1(int());
+ new MultipleInheritanceTest1(int());
MultipleInheritanceTest1(int(), int());
+ new MultipleInheritanceTest1(int(), int());
}
struct Left2 {
@@ -358,7 +372,7 @@ struct Left2 {
Left2(int) : x(36) {}
};
struct Right2 {
- int y; // expected-note{{uninitialized field 'this->Right2::y'}}
+ int y; // expected-note{{uninitialized field 'this->Right2::y'}} expected-note{{uninitialized field 'this->Right2::y'}}
Right2() = default;
Right2(int) : y(37) {}
};
@@ -369,16 +383,17 @@ class MultipleInheritanceTest2 : public Left2, public Right2 {
public:
MultipleInheritanceTest2()
: Left2(int{}) {
- z = 38; // expected-warning{{1 uninitialized field}}
+ z = 38; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fMultipleInheritanceTest2() {
MultipleInheritanceTest2();
+ new MultipleInheritanceTest2();
}
struct Left3 {
- int x; // expected-note{{uninitialized field 'this->Left3::x'}}
+ int x; // expected-note{{uninitialized field 'this->Left3::x'}} expected-note{{uninitialized field 'this->Left3::x'}}
Left3() = default;
Left3(int) : x(39) {}
};
@@ -394,12 +409,13 @@ class MultipleInheritanceTest3 : public Left3, public Right3 {
public:
MultipleInheritanceTest3()
: Right3(char{}) {
- z = 41; // expected-warning{{1 uninitialized field}}
+ z = 41; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fMultipleInheritanceTest3() {
MultipleInheritanceTest3();
+ new MultipleInheritanceTest3();
}
struct Left4 {
@@ -414,17 +430,18 @@ struct Right4 {
};
class MultipleInheritanceTest4 : public Left4, public Right4 {
- int z; // expected-note{{uninitialized field 'this->z'}}
+ int z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
public:
MultipleInheritanceTest4()
: Left4(int{}),
- Right4(char{}) { // expected-warning{{1 uninitialized field}}
+ Right4(char{}) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fMultipleInheritanceTest4() {
MultipleInheritanceTest4();
+ new MultipleInheritanceTest4();
}
struct Left5 {
@@ -433,22 +450,23 @@ struct Left5 {
Left5(int) : x(44) {}
};
struct Right5 {
- int y; // expected-note{{uninitialized field 'this->Right5::y'}}
+ int y; // expected-note{{uninitialized field 'this->Right5::y'}} expected-note{{uninitialized field 'this->Right5::y'}}
Right5() = default;
Right5(int) : y(45) {}
};
class MultipleInheritanceTest5 : public Left5, public Right5 {
- int z; // expected-note{{uninitialized field 'this->z'}}
+ int z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
public:
- MultipleInheritanceTest5() // expected-warning{{2 uninitialized fields}}
+ MultipleInheritanceTest5() // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
: Left5(int{}) {
}
};
void fMultipleInheritanceTest5() {
MultipleInheritanceTest5();
+ new MultipleInheritanceTest5();
}
//===----------------------------------------------------------------------===//
@@ -509,12 +527,15 @@ class NonVirtualDiamondInheritanceTest1 : public First1, public Second1 {
void fNonVirtualDiamondInheritanceTest1() {
NonVirtualDiamondInheritanceTest1();
+ new NonVirtualDiamondInheritanceTest1();
NonVirtualDiamondInheritanceTest1(int());
+ new NonVirtualDiamondInheritanceTest1(int());
NonVirtualDiamondInheritanceTest1(int(), int());
+ new NonVirtualDiamondInheritanceTest1(int(), int());
}
struct NonVirtualBase2 {
- int x; // expected-note{{uninitialized field 'this->NonVirtualBase2::x'}}
+ int x; // expected-note{{uninitialized field 'this->NonVirtualBase2::x'}} expected-note{{uninitialized field 'this->NonVirtualBase2::x'}}
NonVirtualBase2() = default;
NonVirtualBase2(int) : x(52) {}
};
@@ -533,16 +554,17 @@ class NonVirtualDiamondInheritanceTest2 : public First2, public Second2 {
public:
NonVirtualDiamondInheritanceTest2()
: First2(int{}) {
- z = 53; // expected-warning{{1 uninitialized field}}
+ z = 53; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fNonVirtualDiamondInheritanceTest2() {
NonVirtualDiamondInheritanceTest2();
+ new NonVirtualDiamondInheritanceTest2();
}
struct NonVirtualBase3 {
- int x; // expected-note{{uninitialized field 'this->NonVirtualBase3::x'}}
+ int x; // expected-note{{uninitialized field 'this->NonVirtualBase3::x'}} expected-note{{uninitialized field 'this->NonVirtualBase3::x'}}
NonVirtualBase3() = default;
NonVirtualBase3(int) : x(54) {}
};
@@ -561,17 +583,18 @@ class NonVirtualDiamondInheritanceTest3 : public First3, public Second3 {
public:
NonVirtualDiamondInheritanceTest3()
: Second3(int{}) {
- z = 55; // expected-warning{{1 uninitialized field}}
+ z = 55; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fNonVirtualDiamondInheritanceTest3() {
NonVirtualDiamondInheritanceTest3();
+ new NonVirtualDiamondInheritanceTest3();
}
struct NonVirtualBase4 {
- int x; // expected-note{{uninitialized field 'this->NonVirtualBase4::x'}}
- // expected-note at -1{{uninitialized field 'this->NonVirtualBase4::x'}}
+ int x; // expected-note{{uninitialized field 'this->NonVirtualBase4::x'}} expected-note{{uninitialized field 'this->NonVirtualBase4::x'}}
+ // expected-note at -1{{uninitialized field 'this->NonVirtualBase4::x'}} expected-note at -1{{uninitialized field 'this->NonVirtualBase4::x'}}
NonVirtualBase4() = default;
NonVirtualBase4(int) : x(56) {}
};
@@ -589,12 +612,13 @@ class NonVirtualDiamondInheritanceTest4 : public First4, public Second4 {
public:
NonVirtualDiamondInheritanceTest4() {
- z = 57; // expected-warning{{2 uninitialized fields}}
+ z = 57; // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
void fNonVirtualDiamondInheritanceTest4() {
NonVirtualDiamondInheritanceTest4();
+ new NonVirtualDiamondInheritanceTest4();
}
struct NonVirtualBase5 {
@@ -612,21 +636,22 @@ struct Second5 : public NonVirtualBase5 {
};
class NonVirtualDiamondInheritanceTest5 : public First5, public Second5 {
- int z; // expected-note{{uninitialized field 'this->z'}}
+ int z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
public:
NonVirtualDiamondInheritanceTest5()
: First5(int{}),
- Second5(int{}) { // expected-warning{{1 uninitialized field}}
+ Second5(int{}) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fNonVirtualDiamondInheritanceTest5() {
NonVirtualDiamondInheritanceTest5();
+ new NonVirtualDiamondInheritanceTest5();
}
struct NonVirtualBase6 {
- int x; // expected-note{{uninitialized field 'this->NonVirtualBase6::x'}}
+ int x; // expected-note{{uninitialized field 'this->NonVirtualBase6::x'}} expected-note{{uninitialized field 'this->NonVirtualBase6::x'}}
NonVirtualBase6() = default;
NonVirtualBase6(int) : x(59) {}
};
@@ -640,10 +665,10 @@ struct Second6 : public NonVirtualBase6 {
};
class NonVirtualDiamondInheritanceTest6 : public First6, public Second6 {
- int z; // expected-note{{uninitialized field 'this->z'}}
+ int z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
public:
- NonVirtualDiamondInheritanceTest6() // expected-warning{{2 uninitialized fields}}
+ NonVirtualDiamondInheritanceTest6() // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
: First6(int{}) {
// 'z' and 'Second::x' uninitialized
}
@@ -651,6 +676,7 @@ class NonVirtualDiamondInheritanceTest6 : public First6, public Second6 {
void fNonVirtualDiamondInheritanceTest6() {
NonVirtualDiamondInheritanceTest6();
+ new NonVirtualDiamondInheritanceTest6();
}
//===----------------------------------------------------------------------===//
@@ -707,12 +733,15 @@ class VirtualDiamondInheritanceTest1 : public VirtualFirst1, public VirtualSecon
void fVirtualDiamondInheritanceTest1() {
VirtualDiamondInheritanceTest1();
+ new VirtualDiamondInheritanceTest1();
VirtualDiamondInheritanceTest1(int());
+ new VirtualDiamondInheritanceTest1(int());
VirtualDiamondInheritanceTest1(int(), int());
+ new VirtualDiamondInheritanceTest1(int(), int());
}
struct VirtualBase2 {
- int x; // expected-note{{uninitialized field 'this->VirtualBase2::x'}}
+ int x; // expected-note{{uninitialized field 'this->VirtualBase2::x'}} expected-note{{uninitialized field 'this->VirtualBase2::x'}}
VirtualBase2() = default;
VirtualBase2(int) : x(63) {}
};
@@ -730,7 +759,7 @@ struct VirtualSecond2 : virtual public VirtualBase2 {
class VirtualDiamondInheritanceTest2 : public VirtualFirst2, public VirtualSecond2 {
public:
- VirtualDiamondInheritanceTest2() // expected-warning{{1 uninitialized field}}
+ VirtualDiamondInheritanceTest2() // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
: VirtualFirst2(int{}) {
// From the N4659 C++ Standard Working Draft:
//
@@ -748,10 +777,11 @@ class VirtualDiamondInheritanceTest2 : public VirtualFirst2, public VirtualSecon
void fVirtualDiamondInheritanceTest2() {
VirtualDiamondInheritanceTest2();
+ new VirtualDiamondInheritanceTest2();
}
struct VirtualBase3 {
- int x; // expected-note{{uninitialized field 'this->VirtualBase3::x'}}
+ int x; // expected-note{{uninitialized field 'this->VirtualBase3::x'}} expected-note{{uninitialized field 'this->VirtualBase3::x'}}
VirtualBase3() = default;
VirtualBase3(int) : x(66) {}
};
@@ -769,12 +799,13 @@ struct VirtualSecond3 : virtual public VirtualBase3 {
class VirtualDiamondInheritanceTest3 : public VirtualFirst3, public VirtualSecond3 {
public:
- VirtualDiamondInheritanceTest3() // expected-warning{{1 uninitialized field}}
+ VirtualDiamondInheritanceTest3() // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
: VirtualFirst3(int{}) {}
};
void fVirtualDiamondInheritanceTest3() {
VirtualDiamondInheritanceTest3();
+ new VirtualDiamondInheritanceTest3();
}
//===----------------------------------------------------------------------===//
@@ -783,38 +814,42 @@ void fVirtualDiamondInheritanceTest3() {
struct DynTBase1 {};
struct DynTDerived1 : DynTBase1 {
- int y; // expected-note{{uninitialized field 'static_cast<DynTDerived1 *>(this->bptr)->y'}}
+ int y; // expected-note{{uninitialized field 'static_cast<DynTDerived1 *>(this->bptr)->y'}} expected-note{{uninitialized field 'static_cast<DynTDerived1 *>(this->bptr)->y'}}
};
struct DynamicTypeTest1 {
DynTBase1 *bptr;
int i = 0;
- DynamicTypeTest1(DynTBase1 *bptr) : bptr(bptr) {} // expected-warning{{1 uninitialized field}}
+ DynamicTypeTest1(DynTBase1 *bptr) : bptr(bptr) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fDynamicTypeTest1() {
DynTDerived1 d;
DynamicTypeTest1 t(&d);
+ DynTDerived1 dp;
+ new DynamicTypeTest1(&dp);
};
struct DynTBase2 {
- int x; // expected-note{{uninitialized field 'static_cast<DynTDerived2 *>(this->bptr)->DynTBase2::x'}}
+ int x; // expected-note{{uninitialized field 'static_cast<DynTDerived2 *>(this->bptr)->DynTBase2::x'}} expected-note{{uninitialized field 'static_cast<DynTDerived2 *>(this->bptr)->DynTBase2::x'}}
};
struct DynTDerived2 : DynTBase2 {
- int y; // expected-note{{uninitialized field 'static_cast<DynTDerived2 *>(this->bptr)->y'}}
+ int y; // expected-note{{uninitialized field 'static_cast<DynTDerived2 *>(this->bptr)->y'}} expected-note{{uninitialized field 'static_cast<DynTDerived2 *>(this->bptr)->y'}}
};
struct DynamicTypeTest2 {
DynTBase2 *bptr;
int i = 0;
- DynamicTypeTest2(DynTBase2 *bptr) : bptr(bptr) {} // expected-warning{{2 uninitialized fields}}
+ DynamicTypeTest2(DynTBase2 *bptr) : bptr(bptr) {} // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
};
void fDynamicTypeTest2() {
DynTDerived2 d;
DynamicTypeTest2 t(&d);
+ DynTDerived2 dp;
+ new DynamicTypeTest2(&dp);
}
struct SymbolicSuperRegionBase {
@@ -830,4 +865,5 @@ SymbolicSuperRegionDerived *getSymbolicRegion();
void fSymbolicSuperRegionTest() {
SymbolicSuperRegionDerived test(getSymbolicRegion());
+ new SymbolicSuperRegionDerived(getSymbolicRegion());
}
diff --git a/clang/test/Analysis/cxx-uninitialized-object-no-dereference.cpp b/clang/test/Analysis/cxx-uninitialized-object-no-dereference.cpp
index e0aafb98085f2..24adae4ba6bf5 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-no-dereference.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-no-dereference.cpp
@@ -2,15 +2,16 @@
// RUN: -std=c++11 -DPEDANTIC -verify %s
class UninitPointerTest {
- int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}}
+ int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}} expected-note{{uninitialized pointer 'this->ptr'}}
int dontGetFilteredByNonPedanticMode = 0;
public:
- UninitPointerTest() {} // expected-warning{{1 uninitialized field}}
+ UninitPointerTest() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fUninitPointerTest() {
UninitPointerTest();
+ new UninitPointerTest();
}
class UninitPointeeTest {
@@ -24,4 +25,5 @@ class UninitPointeeTest {
void fUninitPointeeTest() {
int a;
UninitPointeeTest t(&a);
+ new UninitPointeeTest(&a);
}
diff --git a/clang/test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp b/clang/test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
index 33f7b0dba07e2..7cc53e48f5f6c 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
@@ -9,10 +9,11 @@ class NotesAsWarningsTest {
int dontGetFilteredByNonPedanticMode = 0;
public:
- NotesAsWarningsTest() {} // expected-warning{{uninitialized field 'this->a'}}
- // expected-warning at -1{{uninitialized field 'this->b'}}
+ NotesAsWarningsTest() {} // expected-warning{{uninitialized field 'this->a'}} expected-warning{{uninitialized field 'this->a'}}
+ // expected-warning at -1{{uninitialized field 'this->b'}} expected-warning at -1{{uninitialized field 'this->b'}}
};
void fNotesAsWarningsTest() {
NotesAsWarningsTest();
+ new NotesAsWarningsTest();
}
diff --git a/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp b/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
index d0eb9e80d6395..e199fdf2aa93d 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -19,6 +19,7 @@ struct ConcreteIntLocTest {
void fConcreteIntLocTest() {
ConcreteIntLocTest();
+ new ConcreteIntLocTest();
}
//===----------------------------------------------------------------------===//
@@ -28,15 +29,17 @@ void fConcreteIntLocTest() {
using intptr_t = unsigned long long;
struct LocAsIntegerTest {
- intptr_t ptr; // expected-note{{uninitialized pointee 'reinterpret_cast<char *>(this->ptr)'}}
+ intptr_t ptr; // expected-note{{uninitialized pointee 'reinterpret_cast<char *>(this->ptr)'}} expected-note{{uninitialized pointee 'reinterpret_cast<char *>(this->ptr)'}}
int dontGetFilteredByNonPedanticMode = 0;
- LocAsIntegerTest(void *ptr) : ptr(reinterpret_cast<intptr_t>(ptr)) {} // expected-warning{{1 uninitialized field}}
+ LocAsIntegerTest(void *ptr) : ptr(reinterpret_cast<intptr_t>(ptr)) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fLocAsIntegerTest() {
char c;
LocAsIntegerTest t(&c);
+ char cp;
+ new LocAsIntegerTest(&cp);
}
//===----------------------------------------------------------------------===//
@@ -61,6 +64,7 @@ class NullPtrTest {
void fNullPtrTest() {
NullPtrTest();
+ new NullPtrTest();
}
//===----------------------------------------------------------------------===//
@@ -141,6 +145,7 @@ class HeapPointerTest1 {
void fHeapPointerTest1() {
HeapPointerTest1();
+ new HeapPointerTest1();
}
class HeapPointerTest2 {
@@ -161,6 +166,7 @@ class HeapPointerTest2 {
void fHeapPointerTest2() {
HeapPointerTest2();
+ new HeapPointerTest2();
}
//===----------------------------------------------------------------------===//
@@ -188,22 +194,23 @@ void fStackPointerTest1() {
int ok_a = 28;
StackPointerTest1::RecordType ok_rec{29, 30};
StackPointerTest1(&ok_a, &ok_rec); // 'a', 'rec.x', 'rec.y' uninitialized
+ new StackPointerTest1(&ok_a, &ok_rec);
}
#ifdef PEDANTIC
class StackPointerTest2 {
public:
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->recPtr->x'}}
- int y; // expected-note{{uninitialized field 'this->recPtr->y'}}
+ int x; // expected-note{{uninitialized field 'this->recPtr->x'}} expected-note{{uninitialized field 'this->recPtr->x'}}
+ int y; // expected-note{{uninitialized field 'this->recPtr->y'}} expected-note{{uninitialized field 'this->recPtr->y'}}
};
private:
- int *ptr; // expected-note{{uninitialized pointee 'this->ptr'}}
+ int *ptr; // expected-note{{uninitialized pointee 'this->ptr'}} expected-note{{uninitialized pointee 'this->ptr'}}
RecordType *recPtr;
public:
- StackPointerTest2(int *_ptr, RecordType *_recPtr) : ptr(_ptr), recPtr(_recPtr) { // expected-warning{{3 uninitialized fields}}
+ StackPointerTest2(int *_ptr, RecordType *_recPtr) : ptr(_ptr), recPtr(_recPtr) { // expected-warning{{3 uninitialized fields}} expected-warning{{3 uninitialized fields}}
}
};
@@ -211,6 +218,9 @@ void fStackPointerTest2() {
int a;
StackPointerTest2::RecordType rec;
StackPointerTest2(&a, &rec); // 'a', 'rec.x', 'rec.y' uninitialized
+ int ap;
+ StackPointerTest2::RecordType recp;
+ new StackPointerTest2(&ap, &recp);
}
#else
class StackPointerTest2 {
@@ -233,6 +243,7 @@ void fStackPointerTest2() {
int a;
StackPointerTest2::RecordType rec;
StackPointerTest2(&a, &rec); // 'a', 'rec.x', 'rec.y' uninitialized
+ new StackPointerTest2(&a, &rec);
}
#endif // PEDANTIC
@@ -242,16 +253,17 @@ class UninitPointerTest {
int y;
};
- int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}}
+ int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}} expected-note{{uninitialized pointer 'this->ptr'}}
RecordType *recPtr;
public:
- UninitPointerTest() : recPtr(new RecordType{13, 13}) { // expected-warning{{1 uninitialized field}}
+ UninitPointerTest() : recPtr(new RecordType{13, 13}) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fUninitPointerTest() {
UninitPointerTest();
+ new UninitPointerTest();
}
struct CharPointerTest {
@@ -263,16 +275,18 @@ struct CharPointerTest {
void fCharPointerTest() {
CharPointerTest();
+ new CharPointerTest();
}
struct VectorSizePointer {
- VectorSizePointer() {} // expected-warning{{1 uninitialized field}}
- __attribute__((__vector_size__(8))) int *x; // expected-note{{uninitialized pointer 'this->x'}}
+ VectorSizePointer() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
+ __attribute__((__vector_size__(8))) int *x; // expected-note{{uninitialized pointer 'this->x'}} expected-note{{uninitialized pointer 'this->x'}}
int dontGetFilteredByNonPedanticMode = 0;
};
void __vector_size__PointerTest() {
VectorSizePointer v;
+ new VectorSizePointer();
}
struct VectorSizePointee {
@@ -286,28 +300,31 @@ void __vector_size__PointeeTest() {
VectorSizePointee::MyVectorType i;
// TODO: Report v.x's pointee.
VectorSizePointee v(&i);
+ new VectorSizePointee(&i);
}
struct CyclicPointerTest1 {
- int *ptr; // expected-note{{object references itself 'this->ptr'}}
+ int *ptr; // expected-note{{object references itself 'this->ptr'}} expected-note{{object references itself 'this->ptr'}}
int dontGetFilteredByNonPedanticMode = 0;
- CyclicPointerTest1() : ptr(reinterpret_cast<int *>(&ptr)) {} // expected-warning{{1 uninitialized field}}
+ CyclicPointerTest1() : ptr(reinterpret_cast<int *>(&ptr)) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fCyclicPointerTest1() {
CyclicPointerTest1();
+ new CyclicPointerTest1();
}
struct CyclicPointerTest2 {
- int **pptr; // expected-note{{object references itself 'this->pptr'}}
+ int **pptr; // expected-note{{object references itself 'this->pptr'}} expected-note{{object references itself 'this->pptr'}}
int dontGetFilteredByNonPedanticMode = 0;
- CyclicPointerTest2() : pptr(reinterpret_cast<int **>(&pptr)) {} // expected-warning{{1 uninitialized field}}
+ CyclicPointerTest2() : pptr(reinterpret_cast<int **>(&pptr)) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fCyclicPointerTest2() {
CyclicPointerTest2();
+ new CyclicPointerTest2();
}
//===----------------------------------------------------------------------===//
@@ -333,6 +350,7 @@ class VoidPointerTest1 {
void fVoidPointerTest1() {
void *vptr = calloc(1, sizeof(int));
VoidPointerTest1(vptr, char());
+ new VoidPointerTest1(vptr, char());
free(vptr);
}
@@ -348,6 +366,7 @@ class VoidPointerTest2 {
void fVoidPointerTest2() {
void *vptr = calloc(1, sizeof(int));
VoidPointerTest2(&vptr, char());
+ new VoidPointerTest2(&vptr, char());
free(vptr);
}
@@ -406,57 +425,62 @@ void fVoidPointerLRefTest() {
}
struct CyclicVoidPointerTest {
- void *vptr; // expected-note{{object references itself 'this->vptr'}}
+ void *vptr; // expected-note{{object references itself 'this->vptr'}} expected-note{{object references itself 'this->vptr'}}
int dontGetFilteredByNonPedanticMode = 0;
- CyclicVoidPointerTest() : vptr(&vptr) {} // expected-warning{{1 uninitialized field}}
+ CyclicVoidPointerTest() : vptr(&vptr) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fCyclicVoidPointerTest() {
CyclicVoidPointerTest();
+ new CyclicVoidPointerTest();
}
struct IntDynTypedVoidPointerTest1 {
- void *vptr; // expected-note{{uninitialized pointee 'static_cast<int *>(this->vptr)'}}
+ void *vptr; // expected-note{{uninitialized pointee 'static_cast<int *>(this->vptr)'}} expected-note{{uninitialized pointee 'static_cast<int *>(this->vptr)'}}
int dontGetFilteredByNonPedanticMode = 0;
- IntDynTypedVoidPointerTest1(void *vptr) : vptr(vptr) {} // expected-warning{{1 uninitialized field}}
+ IntDynTypedVoidPointerTest1(void *vptr) : vptr(vptr) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fIntDynTypedVoidPointerTest1() {
int a;
IntDynTypedVoidPointerTest1 tmp(&a);
+ int ap;
+ new IntDynTypedVoidPointerTest1(&ap);
}
struct RecordDynTypedVoidPointerTest {
struct RecordType {
- int x; // expected-note{{uninitialized field 'static_cast<RecordDynTypedVoidPointerTest::RecordType *>(this->vptr)->x'}}
- int y; // expected-note{{uninitialized field 'static_cast<RecordDynTypedVoidPointerTest::RecordType *>(this->vptr)->y'}}
+ int x; // expected-note{{uninitialized field 'static_cast<RecordDynTypedVoidPointerTest::RecordType *>(this->vptr)->x'}} expected-note{{uninitialized field 'static_cast<RecordDynTypedVoidPointerTest::RecordType *>(this->vptr)->x'}}
+ int y; // expected-note{{uninitialized field 'static_cast<RecordDynTypedVoidPointerTest::RecordType *>(this->vptr)->y'}} expected-note{{uninitialized field 'static_cast<RecordDynTypedVoidPointerTest::RecordType *>(this->vptr)->y'}}
};
void *vptr;
int dontGetFilteredByNonPedanticMode = 0;
- RecordDynTypedVoidPointerTest(void *vptr) : vptr(vptr) {} // expected-warning{{2 uninitialized fields}}
+ RecordDynTypedVoidPointerTest(void *vptr) : vptr(vptr) {} // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
};
void fRecordDynTypedVoidPointerTest() {
RecordDynTypedVoidPointerTest::RecordType a;
RecordDynTypedVoidPointerTest tmp(&a);
+ RecordDynTypedVoidPointerTest::RecordType ap;
+ new RecordDynTypedVoidPointerTest(&ap);
}
struct NestedNonVoidDynTypedVoidPointerTest {
struct RecordType {
- int x; // expected-note{{uninitialized field 'static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->x'}}
- int y; // expected-note{{uninitialized field 'static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->y'}}
- void *vptr; // expected-note{{uninitialized pointee 'static_cast<char *>(static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->vptr)'}}
+ int x; // expected-note{{uninitialized field 'static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->x'}} expected-note{{uninitialized field 'static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->x'}}
+ int y; // expected-note{{uninitialized field 'static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->y'}} expected-note{{uninitialized field 'static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->y'}}
+ void *vptr; // expected-note{{uninitialized pointee 'static_cast<char *>(static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->vptr)'}} expected-note{{uninitialized pointee 'static_cast<char *>(static_cast<NestedNonVoidDynTypedVoidPointerTest::RecordType *>(this->vptr)->vptr)'}}
};
void *vptr;
int dontGetFilteredByNonPedanticMode = 0;
NestedNonVoidDynTypedVoidPointerTest(void *vptr, void *c) : vptr(vptr) {
- static_cast<RecordType *>(vptr)->vptr = c; // expected-warning{{3 uninitialized fields}}
+ static_cast<RecordType *>(vptr)->vptr = c; // expected-warning{{3 uninitialized fields}} expected-warning{{3 uninitialized fields}}
}
};
@@ -464,6 +488,9 @@ void fNestedNonVoidDynTypedVoidPointerTest() {
NestedNonVoidDynTypedVoidPointerTest::RecordType a;
char c;
NestedNonVoidDynTypedVoidPointerTest tmp(&a, &c);
+ NestedNonVoidDynTypedVoidPointerTest::RecordType ap;
+ char cp;
+ new NestedNonVoidDynTypedVoidPointerTest(&ap, &cp);
}
//===----------------------------------------------------------------------===//
@@ -479,10 +506,10 @@ class MultiPointerTest1 {
};
private:
- RecordType **mptr; // expected-note{{uninitialized pointee 'this->mptr'}}
+ RecordType **mptr; // expected-note{{uninitialized pointee 'this->mptr'}} expected-note{{uninitialized pointee 'this->mptr'}}
public:
- MultiPointerTest1(RecordType **p, int) : mptr(p) { // expected-warning{{1 uninitialized field}}
+ MultiPointerTest1(RecordType **p, int) : mptr(p) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
@@ -490,6 +517,9 @@ void fMultiPointerTest1() {
MultiPointerTest1::RecordType *p1;
MultiPointerTest1::RecordType **mptr = &p1;
MultiPointerTest1(mptr, int()); // '*mptr' uninitialized
+ MultiPointerTest1::RecordType *p1p;
+ MultiPointerTest1::RecordType **mptrp = &p1p;
+ new MultiPointerTest1(mptrp, int());
}
#else
class MultiPointerTest1 {
@@ -510,6 +540,7 @@ void fMultiPointerTest1() {
MultiPointerTest1::RecordType *p1;
MultiPointerTest1::RecordType **mptr = &p1;
MultiPointerTest1(mptr, int()); // '*mptr' uninitialized
+ new MultiPointerTest1(mptr, int());
}
#endif // PEDANTIC
@@ -517,15 +548,15 @@ void fMultiPointerTest1() {
class MultiPointerTest2 {
public:
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->mptr->x'}}
- int y; // expected-note{{uninitialized field 'this->mptr->y'}}
+ int x; // expected-note{{uninitialized field 'this->mptr->x'}} expected-note{{uninitialized field 'this->mptr->x'}}
+ int y; // expected-note{{uninitialized field 'this->mptr->y'}} expected-note{{uninitialized field 'this->mptr->y'}}
};
private:
RecordType **mptr;
public:
- MultiPointerTest2(RecordType **p, int) : mptr(p) { // expected-warning{{2 uninitialized fields}}
+ MultiPointerTest2(RecordType **p, int) : mptr(p) { // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
@@ -534,6 +565,10 @@ void fMultiPointerTest2() {
MultiPointerTest2::RecordType *p1 = &i;
MultiPointerTest2::RecordType **mptr = &p1;
MultiPointerTest2(mptr, int()); // '**mptr' uninitialized
+ MultiPointerTest2::RecordType ip;
+ MultiPointerTest2::RecordType *p1p = &ip;
+ MultiPointerTest2::RecordType **mptrp = &p1p;
+ new MultiPointerTest2(mptrp, int());
}
#else
class MultiPointerTest2 {
@@ -556,6 +591,7 @@ void fMultiPointerTest2() {
MultiPointerTest2::RecordType *p1 = &i;
MultiPointerTest2::RecordType **mptr = &p1;
MultiPointerTest2(mptr, int()); // '**mptr' uninitialized
+ new MultiPointerTest2(mptr, int());
}
#endif // PEDANTIC
@@ -580,6 +616,7 @@ void fMultiPointerTest3() {
MultiPointerTest3::RecordType *p1 = &i;
MultiPointerTest3::RecordType **mptr = &p1;
MultiPointerTest3(mptr, int()); // '**mptr' uninitialized
+ new MultiPointerTest3(mptr, int());
}
//===----------------------------------------------------------------------===//
@@ -597,6 +634,7 @@ struct IncompletePointeeTypeTest {
void fIncompletePointeeTypeTest(void *ptr) {
IncompletePointeeTypeTest(reinterpret_cast<IncompleteType *>(ptr));
+ new IncompletePointeeTypeTest(reinterpret_cast<IncompleteType *>(ptr));
}
//===----------------------------------------------------------------------===//
@@ -628,12 +666,13 @@ struct UsefulFunctions {
#ifdef PEDANTIC
struct PointerToMemberFunctionTest1 {
- void (UsefulFunctions::*f)(void); // expected-note{{uninitialized field 'this->f'}}
+ void (UsefulFunctions::*f)(void); // expected-note{{uninitialized field 'this->f'}} expected-note{{uninitialized field 'this->f'}}
PointerToMemberFunctionTest1() {}
};
void fPointerToMemberFunctionTest1() {
PointerToMemberFunctionTest1(); // expected-warning{{1 uninitialized field}}
+ new PointerToMemberFunctionTest1(); // expected-warning{{1 uninitialized field}}
}
struct PointerToMemberFunctionTest2 {
@@ -646,15 +685,17 @@ struct PointerToMemberFunctionTest2 {
void fPointerToMemberFunctionTest2() {
void (UsefulFunctions::*f)(void) = &UsefulFunctions::print;
PointerToMemberFunctionTest2 a(f);
+ new PointerToMemberFunctionTest2(f);
}
struct MultiPointerToMemberFunctionTest1 {
- void (UsefulFunctions::**f)(void); // expected-note{{uninitialized pointer 'this->f'}}
+ void (UsefulFunctions::**f)(void); // expected-note{{uninitialized pointer 'this->f'}} expected-note{{uninitialized pointer 'this->f'}}
MultiPointerToMemberFunctionTest1() {}
};
void fMultiPointerToMemberFunctionTest1() {
MultiPointerToMemberFunctionTest1(); // expected-warning{{1 uninitialized field}}
+ new MultiPointerToMemberFunctionTest1(); // expected-warning{{1 uninitialized field}}
}
struct MultiPointerToMemberFunctionTest2 {
@@ -667,15 +708,17 @@ struct MultiPointerToMemberFunctionTest2 {
void fMultiPointerToMemberFunctionTest2() {
void (UsefulFunctions::*f)(void) = &UsefulFunctions::print;
MultiPointerToMemberFunctionTest2 a(&f);
+ new MultiPointerToMemberFunctionTest2(&f);
}
struct PointerToMemberDataTest1 {
- int UsefulFunctions::*d; // expected-note{{uninitialized field 'this->d'}}
+ int UsefulFunctions::*d; // expected-note{{uninitialized field 'this->d'}} expected-note{{uninitialized field 'this->d'}}
PointerToMemberDataTest1() {}
};
void fPointerToMemberDataTest1() {
PointerToMemberDataTest1(); // expected-warning{{1 uninitialized field}}
+ new PointerToMemberDataTest1(); // expected-warning{{1 uninitialized field}}
}
struct PointerToMemberDataTest2 {
@@ -688,15 +731,17 @@ struct PointerToMemberDataTest2 {
void fPointerToMemberDataTest2() {
int UsefulFunctions::*d = &UsefulFunctions::a;
PointerToMemberDataTest2 a(d);
+ new PointerToMemberDataTest2(d);
}
struct MultiPointerToMemberDataTest1 {
- int UsefulFunctions::**d; // expected-note{{uninitialized pointer 'this->d'}}
+ int UsefulFunctions::**d; // expected-note{{uninitialized pointer 'this->d'}} expected-note{{uninitialized pointer 'this->d'}}
MultiPointerToMemberDataTest1() {}
};
void fMultiPointerToMemberDataTest1() {
MultiPointerToMemberDataTest1(); // expected-warning{{1 uninitialized field}}
+ new MultiPointerToMemberDataTest1(); // expected-warning{{1 uninitialized field}}
}
struct MultiPointerToMemberDataTest2 {
@@ -709,6 +754,7 @@ struct MultiPointerToMemberDataTest2 {
void fMultiPointerToMemberDataTest2() {
int UsefulFunctions::*d = &UsefulFunctions::a;
MultiPointerToMemberDataTest2 a(&d);
+ new MultiPointerToMemberDataTest2(&d);
}
#endif // PEDANTIC
@@ -734,40 +780,43 @@ class ListTest1 {
void fListTest1() {
ListTest1();
+ new ListTest1();
}
class ListTest2 {
public:
struct Node {
Node *next = nullptr;
- int i; // expected-note{{uninitialized field 'this->head->i'}}
+ int i; // expected-note{{uninitialized field 'this->head->i'}} expected-note{{uninitialized field 'this->head->i'}}
};
private:
Node *head = nullptr;
public:
- ListTest2(Node *node, int) : head(node) { // expected-warning{{1 uninitialized field}}
+ ListTest2(Node *node, int) : head(node) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fListTest2() {
ListTest2::Node n;
ListTest2(&n, int());
+ ListTest2::Node np;
+ new ListTest2(&np, int());
}
class CyclicList {
public:
struct Node {
Node *next = nullptr;
- int i; // expected-note{{uninitialized field 'this->head->i'}}
+ int i; // expected-note{{uninitialized field 'this->head->i'}} expected-note{{uninitialized field 'this->head->i'}}
};
private:
Node *head = nullptr;
public:
- CyclicList(Node *node, int) : head(node) { // expected-warning{{1 uninitialized field}}
+ CyclicList(Node *node, int) : head(node) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
@@ -788,6 +837,15 @@ void fCyclicList() {
n1.next = &n3;
// note that n1.i is uninitialized
CyclicList(&n1, int());
+ CyclicList::Node n1p;
+ CyclicList::Node n2p;
+ n2p.next = &n1p;
+ n2p.i = 50;
+ CyclicList::Node n3p;
+ n3p.next = &n2p;
+ n3p.i = 50;
+ n1p.next = &n3p;
+ new CyclicList(&n1p, int());
}
struct RingListTest {
@@ -797,6 +855,7 @@ struct RingListTest {
void fRingListTest() {
RingListTest();
+ new RingListTest();
}
//===----------------------------------------------------------------------===//
@@ -823,14 +882,15 @@ class ReferenceTest1 {
void fReferenceTest1() {
ReferenceTest1::RecordType d{33, 34};
ReferenceTest1(d, d);
+ new ReferenceTest1(d, d);
}
#ifdef PEDANTIC
class ReferenceTest2 {
public:
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->lref.x'}}
- int y; // expected-note{{uninitialized field 'this->lref.y'}}
+ int x; // expected-note{{uninitialized field 'this->lref.x'}} expected-note{{uninitialized field 'this->lref.x'}}
+ int y; // expected-note{{uninitialized field 'this->lref.y'}} expected-note{{uninitialized field 'this->lref.y'}}
};
private:
@@ -839,13 +899,15 @@ class ReferenceTest2 {
public:
ReferenceTest2(RecordType &lref, RecordType &rref)
- : lref(lref), rref(static_cast<RecordType &&>(rref)) { // expected-warning{{2 uninitialized fields}}
+ : lref(lref), rref(static_cast<RecordType &&>(rref)) { // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
void fReferenceTest2() {
ReferenceTest2::RecordType c;
ReferenceTest2(c, c);
+ ReferenceTest2::RecordType cp;
+ new ReferenceTest2(cp, cp);
}
#else
class ReferenceTest2 {
@@ -868,14 +930,15 @@ class ReferenceTest2 {
void fReferenceTest2() {
ReferenceTest2::RecordType c;
ReferenceTest2(c, c);
+ new ReferenceTest2(c, c);
}
#endif // PEDANTIC
class ReferenceTest3 {
public:
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->lref.x'}}
- int y; // expected-note{{uninitialized field 'this->lref.y'}}
+ int x; // expected-note{{uninitialized field 'this->lref.x'}} expected-note{{uninitialized field 'this->lref.x'}}
+ int y; // expected-note{{uninitialized field 'this->lref.y'}} expected-note{{uninitialized field 'this->lref.y'}}
};
private:
@@ -884,20 +947,22 @@ class ReferenceTest3 {
public:
ReferenceTest3(RecordType &lref, RecordType &rref)
- : lref(lref), rref(static_cast<RecordType &&>(rref)) { // expected-warning{{2 uninitialized fields}}
+ : lref(lref), rref(static_cast<RecordType &&>(rref)) { // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
void fReferenceTest3() {
ReferenceTest3::RecordType c, d{35, 36};
ReferenceTest3(c, d);
+ ReferenceTest3::RecordType cp, dp{35, 36};
+ new ReferenceTest3(cp, dp);
}
class ReferenceTest4 {
public:
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->rref.x'}}
- int y; // expected-note{{uninitialized field 'this->rref.y'}}
+ int x; // expected-note{{uninitialized field 'this->rref.x'}} expected-note{{uninitialized field 'this->rref.x'}}
+ int y; // expected-note{{uninitialized field 'this->rref.y'}} expected-note{{uninitialized field 'this->rref.y'}}
};
private:
@@ -906,13 +971,15 @@ class ReferenceTest4 {
public:
ReferenceTest4(RecordType &lref, RecordType &rref)
- : lref(lref), rref(static_cast<RecordType &&>(rref)) { // expected-warning{{2 uninitialized fields}}
+ : lref(lref), rref(static_cast<RecordType &&>(rref)) { // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
void fReferenceTest5() {
ReferenceTest4::RecordType c, d{37, 38};
ReferenceTest4(d, c);
+ ReferenceTest4::RecordType cp, dp{37, 38};
+ new ReferenceTest4(dp, cp);
}
//===----------------------------------------------------------------------===//
@@ -920,25 +987,27 @@ void fReferenceTest5() {
//===----------------------------------------------------------------------===//
struct IntMultipleReferenceToSameObjectTest {
- int *iptr; // expected-note{{uninitialized pointee 'this->iptr'}}
+ int *iptr; // expected-note{{uninitialized pointee 'this->iptr'}} expected-note{{uninitialized pointee 'this->iptr'}}
int &iref; // no-note, pointee of this->iref was already reported
int dontGetFilteredByNonPedanticMode = 0;
- IntMultipleReferenceToSameObjectTest(int *i) : iptr(i), iref(*i) {} // expected-warning{{1 uninitialized field}}
+ IntMultipleReferenceToSameObjectTest(int *i) : iptr(i), iref(*i) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fIntMultipleReferenceToSameObjectTest() {
int a;
IntMultipleReferenceToSameObjectTest Test(&a);
+ int ap;
+ new IntMultipleReferenceToSameObjectTest(&ap);
}
struct IntReferenceWrapper1 {
- int &a; // expected-note{{uninitialized pointee 'this->a'}}
+ int &a; // expected-note{{uninitialized pointee 'this->a'}} expected-note{{uninitialized pointee 'this->a'}}
int dontGetFilteredByNonPedanticMode = 0;
- IntReferenceWrapper1(int &a) : a(a) {} // expected-warning{{1 uninitialized field}}
+ IntReferenceWrapper1(int &a) : a(a) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
struct IntReferenceWrapper2 {
@@ -954,4 +1023,8 @@ void fMultipleObjectsReferencingTheSameObjectTest() {
IntReferenceWrapper1 T1(a);
IntReferenceWrapper2 T2(a);
+
+ int ap;
+ new IntReferenceWrapper1(ap);
+ new IntReferenceWrapper2(ap);
}
diff --git a/clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp b/clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
index 611e1d8255976..de4368b6ee507 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
@@ -56,7 +56,9 @@ class NoUnguardedFieldsTest {
void fNoUnguardedFieldsTest() {
NoUnguardedFieldsTest T1(NoUnguardedFieldsTest::Kind::A);
+ new NoUnguardedFieldsTest(NoUnguardedFieldsTest::Kind::A);
NoUnguardedFieldsTest T2(NoUnguardedFieldsTest::Kind::V);
+ new NoUnguardedFieldsTest(NoUnguardedFieldsTest::Kind::V);
}
class NoUngardedFieldsNoReturnFuncCalledTest {
@@ -96,8 +98,10 @@ class NoUngardedFieldsNoReturnFuncCalledTest {
void fNoUngardedFieldsNoReturnFuncCalledTest() {
NoUngardedFieldsNoReturnFuncCalledTest
T1(NoUngardedFieldsNoReturnFuncCalledTest::Kind::A);
+ new NoUngardedFieldsNoReturnFuncCalledTest(NoUngardedFieldsNoReturnFuncCalledTest::Kind::A);
NoUngardedFieldsNoReturnFuncCalledTest
T2(NoUngardedFieldsNoReturnFuncCalledTest::Kind::V);
+ new NoUngardedFieldsNoReturnFuncCalledTest(NoUngardedFieldsNoReturnFuncCalledTest::Kind::V);
}
class NoUnguardedFieldsWithUndefMethodTest {
@@ -141,8 +145,10 @@ class NoUnguardedFieldsWithUndefMethodTest {
void fNoUnguardedFieldsWithUndefMethodTest() {
NoUnguardedFieldsWithUndefMethodTest
T1(NoUnguardedFieldsWithUndefMethodTest::Kind::A);
+ new NoUnguardedFieldsWithUndefMethodTest(NoUnguardedFieldsWithUndefMethodTest::Kind::A);
NoUnguardedFieldsWithUndefMethodTest
T2(NoUnguardedFieldsWithUndefMethodTest::Kind::V);
+ new NoUnguardedFieldsWithUndefMethodTest(NoUnguardedFieldsWithUndefMethodTest::Kind::V);
}
class UnguardedFieldThroughMethodTest {
@@ -153,7 +159,7 @@ class UnguardedFieldThroughMethodTest {
};
private:
- int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}}
+ int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}} expected-note {{uninitialized field 'this->Volume'}}
Kind K;
public:
@@ -164,7 +170,7 @@ class UnguardedFieldThroughMethodTest {
break;
case A:
Area = 0;
- break; // expected-warning {{1 uninitialized field}}
+ break; // expected-warning {{1 uninitialized field}} expected-warning {{1 uninitialized field}}
}
}
@@ -180,6 +186,7 @@ class UnguardedFieldThroughMethodTest {
void fUnguardedFieldThroughMethodTest() {
UnguardedFieldThroughMethodTest T1(UnguardedFieldThroughMethodTest::Kind::A);
+ new UnguardedFieldThroughMethodTest(UnguardedFieldThroughMethodTest::Kind::A);
}
class UnguardedPublicFieldsTest {
@@ -191,7 +198,7 @@ class UnguardedPublicFieldsTest {
public:
// Note that fields are public.
- int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}}
+ int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}} expected-note {{uninitialized field 'this->Volume'}}
Kind K;
public:
@@ -202,7 +209,7 @@ class UnguardedPublicFieldsTest {
break;
case A:
Area = 0;
- break; // expected-warning {{1 uninitialized field}}
+ break; // expected-warning {{1 uninitialized field}} expected-warning {{1 uninitialized field}}
}
}
@@ -219,6 +226,7 @@ class UnguardedPublicFieldsTest {
void fUnguardedPublicFieldsTest() {
UnguardedPublicFieldsTest T1(UnguardedPublicFieldsTest::Kind::A);
+ new UnguardedPublicFieldsTest(UnguardedPublicFieldsTest::Kind::A);
}
//===----------------------------------------------------------------------===//
@@ -263,6 +271,7 @@ class UnguardedFalseNegativeTest1 {
void fUnguardedFalseNegativeTest1() {
UnguardedFalseNegativeTest1 T1(UnguardedFalseNegativeTest1::Kind::A);
+ new UnguardedFalseNegativeTest1(UnguardedFalseNegativeTest1::Kind::A);
}
class UnguardedFalseNegativeTest2 {
@@ -301,6 +310,7 @@ class UnguardedFalseNegativeTest2 {
void fUnguardedFalseNegativeTest2() {
UnguardedFalseNegativeTest2 T1(UnguardedFalseNegativeTest2::Kind::A);
+ new UnguardedFalseNegativeTest2(UnguardedFalseNegativeTest2::Kind::A);
}
//===----------------------------------------------------------------------===//
@@ -350,7 +360,9 @@ class IfGuardedFieldsTest {
void fIfGuardedFieldsTest() {
IfGuardedFieldsTest T1(IfGuardedFieldsTest::Kind::A);
+ new IfGuardedFieldsTest(IfGuardedFieldsTest::Kind::A);
IfGuardedFieldsTest T2(IfGuardedFieldsTest::Kind::V);
+ new IfGuardedFieldsTest(IfGuardedFieldsTest::Kind::V);
}
class SwitchGuardedFieldsTest {
@@ -397,7 +409,9 @@ class SwitchGuardedFieldsTest {
void fSwitchGuardedFieldsTest() {
SwitchGuardedFieldsTest T1(SwitchGuardedFieldsTest::Kind::A);
+ new SwitchGuardedFieldsTest(SwitchGuardedFieldsTest::Kind::A);
SwitchGuardedFieldsTest T2(SwitchGuardedFieldsTest::Kind::V);
+ new SwitchGuardedFieldsTest(SwitchGuardedFieldsTest::Kind::V);
}
class ConditionalOperatorGuardedFieldsTest {
@@ -435,6 +449,8 @@ class ConditionalOperatorGuardedFieldsTest {
void fConditionalOperatorGuardedFieldsTest() {
ConditionalOperatorGuardedFieldsTest
T1(ConditionalOperatorGuardedFieldsTest::Kind::A);
+ new ConditionalOperatorGuardedFieldsTest(ConditionalOperatorGuardedFieldsTest::Kind::A);
ConditionalOperatorGuardedFieldsTest
T2(ConditionalOperatorGuardedFieldsTest::Kind::V);
+ new ConditionalOperatorGuardedFieldsTest(ConditionalOperatorGuardedFieldsTest::Kind::V);
}
diff --git a/clang/test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp b/clang/test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp
index 92412f7cccb9d..59d75af1740a7 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp
@@ -43,6 +43,7 @@ struct UnionLikeStruct1 {
void fUnionLikeStruct1() {
UnionLikeStruct1 t(UnionLikeStruct1::volume, 10);
+ new UnionLikeStruct1(UnionLikeStruct1::volume, 10);
}
// Only name contains "kind".
@@ -69,6 +70,7 @@ struct UnionLikeStruct2 {
void fUnionLikeStruct2() {
UnionLikeStruct2 t(UnionLikeStruct2::volume, 10);
+ new UnionLikeStruct2(UnionLikeStruct2::volume, 10);
}
// Only type contains "kind".
@@ -95,6 +97,7 @@ struct UnionLikeStruct3 {
void fUnionLikeStruct3() {
UnionLikeStruct3 t(UnionLikeStruct3::volume, 10);
+ new UnionLikeStruct3(UnionLikeStruct3::volume, 10);
}
// Only type contains "tag".
@@ -121,6 +124,7 @@ struct UnionLikeStruct4 {
void fUnionLikeStruct4() {
UnionLikeStruct4 t(UnionLikeStruct4::volume, 10);
+ new UnionLikeStruct4(UnionLikeStruct4::volume, 10);
}
// Both name and type name contains but does not equal to tag/kind.
@@ -147,4 +151,5 @@ struct UnionLikeStruct5 {
void fUnionLikeStruct5() {
UnionLikeStruct5 t(UnionLikeStruct5::volume, 10);
+ new UnionLikeStruct5(UnionLikeStruct5::volume, 10);
}
diff --git a/clang/test/Analysis/cxx-uninitialized-object.cpp b/clang/test/Analysis/cxx-uninitialized-object.cpp
index daaf6f418c7d1..f653bb9535540 100644
--- a/clang/test/Analysis/cxx-uninitialized-object.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object.cpp
@@ -24,11 +24,12 @@ class CompilerGeneratedConstructorTest {
void fCompilerGeneratedConstructorTest() {
CompilerGeneratedConstructorTest();
+ new CompilerGeneratedConstructorTest();
}
#ifdef PEDANTIC
class DefaultConstructorTest {
- int a; // expected-note{{uninitialized field 'this->a'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
public:
DefaultConstructorTest();
@@ -38,6 +39,7 @@ DefaultConstructorTest::DefaultConstructorTest() = default;
void fDefaultConstructorTest() {
DefaultConstructorTest(); // expected-warning{{1 uninitialized field}}
+ new DefaultConstructorTest(); // expected-warning{{1 uninitialized field}}
}
#else
class DefaultConstructorTest {
@@ -51,6 +53,7 @@ DefaultConstructorTest::DefaultConstructorTest() = default;
void fDefaultConstructorTest() {
DefaultConstructorTest();
+ new DefaultConstructorTest();
}
#endif // PEDANTIC
@@ -72,32 +75,35 @@ class InitListTest1 {
void fInitListTest1() {
InitListTest1();
+ new InitListTest1();
}
class InitListTest2 {
int a;
- int b; // expected-note{{uninitialized field 'this->b'}}
+ int b; // expected-note{{uninitialized field 'this->b'}} expected-note{{uninitialized field 'this->b'}}
public:
InitListTest2()
- : a(3) {} // expected-warning{{1 uninitialized field}}
+ : a(3) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fInitListTest2() {
InitListTest2();
+ new InitListTest2();
}
class InitListTest3 {
- int a; // expected-note{{uninitialized field 'this->a'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int b;
public:
InitListTest3()
- : b(4) {} // expected-warning{{1 uninitialized field}}
+ : b(4) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fInitListTest3() {
InitListTest3();
+ new InitListTest3();
}
//===----------------------------------------------------------------------===//
@@ -117,40 +123,43 @@ class CtorBodyTest1 {
void fCtorBodyTest1() {
CtorBodyTest1();
+ new CtorBodyTest1();
}
class CtorBodyTest2 {
int a;
- int b; // expected-note{{uninitialized field 'this->b'}}
+ int b; // expected-note{{uninitialized field 'this->b'}} expected-note{{uninitialized field 'this->b'}}
public:
CtorBodyTest2() {
- a = 7; // expected-warning{{1 uninitialized field}}
+ a = 7; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fCtorBodyTest2() {
CtorBodyTest2();
+ new CtorBodyTest2();
}
class CtorBodyTest3 {
- int a; // expected-note{{uninitialized field 'this->a'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int b;
public:
CtorBodyTest3() {
- b = 8; // expected-warning{{1 uninitialized field}}
+ b = 8; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fCtorBodyTest3() {
CtorBodyTest3();
+ new CtorBodyTest3();
}
#ifdef PEDANTIC
class CtorBodyTest4 {
- int a; // expected-note{{uninitialized field 'this->a'}}
- int b; // expected-note{{uninitialized field 'this->b'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
+ int b; // expected-note{{uninitialized field 'this->b'}} expected-note{{uninitialized field 'this->b'}}
public:
CtorBodyTest4() {}
@@ -158,6 +167,7 @@ class CtorBodyTest4 {
void fCtorBodyTest4() {
CtorBodyTest4(); // expected-warning{{2 uninitialized fields}}
+ new CtorBodyTest4(); // expected-warning{{2 uninitialized fields}}
}
#else
class CtorBodyTest4 {
@@ -170,6 +180,7 @@ class CtorBodyTest4 {
void fCtorBodyTest4() {
CtorBodyTest4();
+ new CtorBodyTest4();
}
#endif
@@ -196,10 +207,11 @@ class CtorDelegationTest1 {
void fCtorDelegationTest1() {
CtorDelegationTest1();
+ new CtorDelegationTest1();
}
class CtorDelegationTest2 {
- int a; // expected-note{{uninitialized field 'this->a'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int b;
public:
@@ -209,12 +221,13 @@ class CtorDelegationTest2 {
}
CtorDelegationTest2()
- : CtorDelegationTest2(int{}) { // expected-warning{{1 uninitialized field}}
+ : CtorDelegationTest2(int{}) { // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fCtorDelegationTest2() {
CtorDelegationTest2();
+ new CtorDelegationTest2();
}
//===----------------------------------------------------------------------===//
@@ -239,12 +252,13 @@ class ContainsRecordTest1 {
void fContainsRecordTest1() {
ContainsRecordTest1();
+ new ContainsRecordTest1();
}
class ContainsRecordTest2 {
struct RecordType {
int x;
- int y; // expected-note{{uninitialized field 'this->rec.y'}}
+ int y; // expected-note{{uninitialized field 'this->rec.y'}} expected-note{{uninitialized field 'this->rec.y'}}
} rec;
int c, d;
@@ -252,47 +266,50 @@ class ContainsRecordTest2 {
ContainsRecordTest2()
: c(16),
d(17) {
- rec.x = 18; // expected-warning{{1 uninitialized field}}
+ rec.x = 18; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fContainsRecordTest2() {
ContainsRecordTest2();
+ new ContainsRecordTest2();
}
class ContainsRecordTest3 {
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->rec.x'}}
- int y; // expected-note{{uninitialized field 'this->rec.y'}}
+ int x; // expected-note{{uninitialized field 'this->rec.x'}} expected-note{{uninitialized field 'this->rec.x'}}
+ int y; // expected-note{{uninitialized field 'this->rec.y'}} expected-note{{uninitialized field 'this->rec.y'}}
} rec;
int c, d;
public:
ContainsRecordTest3()
: c(19),
- d(20) { // expected-warning{{2 uninitialized fields}}
+ d(20) { // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
void fContainsRecordTest3() {
ContainsRecordTest3();
+ new ContainsRecordTest3();
}
class ContainsRecordTest4 {
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->rec.x'}}
- int y; // expected-note{{uninitialized field 'this->rec.y'}}
+ int x; // expected-note{{uninitialized field 'this->rec.x'}} expected-note{{uninitialized field 'this->rec.x'}}
+ int y; // expected-note{{uninitialized field 'this->rec.y'}} expected-note{{uninitialized field 'this->rec.y'}}
} rec;
- int c, d; // expected-note{{uninitialized field 'this->d'}}
+ int c, d; // expected-note{{uninitialized field 'this->d'}} expected-note{{uninitialized field 'this->d'}}
public:
ContainsRecordTest4()
- : c(19) { // expected-warning{{3 uninitialized fields}}
+ : c(19) { // expected-warning{{3 uninitialized fields}} expected-warning{{3 uninitialized fields}}
}
};
void fContainsRecordTest4() {
ContainsRecordTest4();
+ new ContainsRecordTest4();
}
//===----------------------------------------------------------------------===//
@@ -314,26 +331,28 @@ class IntTemplateClassTest1 {
void fIntTemplateClassTest1() {
IntTemplateClassTest1<int>(22);
+ new IntTemplateClassTest1<int>(22);
}
template <class T>
class IntTemplateClassTest2 {
- T t; // expected-note{{uninitialized field 'this->t'}}
+ T t; // expected-note{{uninitialized field 'this->t'}} expected-note{{uninitialized field 'this->t'}}
int b;
public:
IntTemplateClassTest2() {
- b = 23; // expected-warning{{1 uninitialized field}}
+ b = 23; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fIntTemplateClassTest2() {
IntTemplateClassTest2<int>();
+ new IntTemplateClassTest2<int>();
}
struct Record {
- int x; // expected-note{{uninitialized field 'this->t.x'}}
- int y; // expected-note{{uninitialized field 'this->t.y'}}
+ int x; // expected-note{{uninitialized field 'this->t.x'}} expected-note{{uninitialized field 'this->t.x'}}
+ int y; // expected-note{{uninitialized field 'this->t.y'}} expected-note{{uninitialized field 'this->t.y'}}
};
template <class T>
@@ -343,12 +362,13 @@ class RecordTemplateClassTest {
public:
RecordTemplateClassTest() {
- b = 24; // expected-warning{{2 uninitialized fields}}
+ b = 24; // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
}
};
void fRecordTemplateClassTest() {
RecordTemplateClassTest<Record>();
+ new RecordTemplateClassTest<Record>();
}
//===----------------------------------------------------------------------===//
@@ -384,23 +404,27 @@ class PassingToUnknownFunctionTest1 {
void fPassingToUnknownFunctionTest1() {
PassingToUnknownFunctionTest1();
+ new PassingToUnknownFunctionTest1();
PassingToUnknownFunctionTest1(int());
+ new PassingToUnknownFunctionTest1(int());
PassingToUnknownFunctionTest1(int(), int());
+ new PassingToUnknownFunctionTest1(int(), int());
}
class PassingToUnknownFunctionTest2 {
- int a; // expected-note{{uninitialized field 'this->a'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int b;
public:
PassingToUnknownFunctionTest2() {
wontInitialize(a);
- b = 4; // expected-warning{{1 uninitialized field}}
+ b = 4; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
};
void fPassingToUnknownFunctionTest2() {
PassingToUnknownFunctionTest2();
+ new PassingToUnknownFunctionTest2();
}
//===----------------------------------------------------------------------===//
@@ -428,6 +452,7 @@ class ContainsSimpleUnionTest1 {
void fContainsSimpleUnionTest1() {
ContainsSimpleUnionTest1();
+ new ContainsSimpleUnionTest1();
}
class ContainsSimpleUnionTest2 {
@@ -445,6 +470,7 @@ class ContainsSimpleUnionTest2 {
void fContainsSimpleUnionTest2() {
// TODO: we'd expect the warning: {{1 uninitialized field}}
ContainsSimpleUnionTest2(); // no-warning
+ new ContainsSimpleUnionTest2(); // no-warning
}
class UnionPointerTest1 {
@@ -468,6 +494,7 @@ void fUnionPointerTest1() {
UnionPointerTest1::SimpleUnion u;
u.uf = 41;
UnionPointerTest1(&u, int());
+ new UnionPointerTest1(&u, int());
}
class UnionPointerTest2 {
@@ -490,6 +517,7 @@ void fUnionPointerTest2() {
UnionPointerTest2::SimpleUnion u;
// TODO: we'd expect the warning: {{1 uninitialized field}}
UnionPointerTest2(&u, int()); // no-warning
+ new UnionPointerTest2(&u, int()); // no-warning
}
class ContainsUnionWithRecordTest1 {
@@ -513,6 +541,7 @@ class ContainsUnionWithRecordTest1 {
void fContainsUnionWithRecordTest1() {
ContainsUnionWithRecordTest1();
+ new ContainsUnionWithRecordTest1();
}
class ContainsUnionWithRecordTest2 {
@@ -536,6 +565,7 @@ class ContainsUnionWithRecordTest2 {
void fContainsUnionWithRecordTest2() {
ContainsUnionWithRecordTest1();
+ new ContainsUnionWithRecordTest1();
}
class ContainsUnionWithRecordTest3 {
@@ -562,6 +592,7 @@ class ContainsUnionWithRecordTest3 {
void fContainsUnionWithRecordTest3() {
ContainsUnionWithRecordTest3();
+ new ContainsUnionWithRecordTest3();
}
class ContainsUnionWithSimpleUnionTest1 {
@@ -584,6 +615,7 @@ class ContainsUnionWithSimpleUnionTest1 {
void fContainsUnionWithSimpleUnionTest1() {
ContainsUnionWithSimpleUnionTest1();
+ new ContainsUnionWithSimpleUnionTest1();
}
class ContainsUnionWithSimpleUnionTest2 {
@@ -605,6 +637,7 @@ class ContainsUnionWithSimpleUnionTest2 {
void fContainsUnionWithSimpleUnionTest2() {
// TODO: we'd expect the warning: {{1 uninitialized field}}
ContainsUnionWithSimpleUnionTest2(); // no-warning
+ new ContainsUnionWithSimpleUnionTest2(); // no-warning
}
//===----------------------------------------------------------------------===//
@@ -628,7 +661,7 @@ void funcToSquelchCompilerWarnings(const T &t);
#ifdef PEDANTIC
struct CopyConstructorTest {
- int i; // expected-note{{uninitialized field 'this->i'}}
+ int i; // expected-note{{uninitialized field 'this->i'}} expected-note{{uninitialized field 'this->i'}}
CopyConstructorTest() : i(1337) {}
CopyConstructorTest(const CopyConstructorTest &other) {}
@@ -637,6 +670,7 @@ struct CopyConstructorTest {
void fCopyConstructorTest() {
CopyConstructorTest cct;
CopyConstructorTest copy = cct; // expected-warning{{1 uninitialized field}}
+ new CopyConstructorTest(cct); // expected-warning{{1 uninitialized field}}
funcToSquelchCompilerWarnings(copy);
}
#else
@@ -650,6 +684,7 @@ struct CopyConstructorTest {
void fCopyConstructorTest() {
CopyConstructorTest cct;
CopyConstructorTest copy = cct;
+ new CopyConstructorTest(cct);
funcToSquelchCompilerWarnings(copy);
}
#endif // PEDANTIC
@@ -667,6 +702,7 @@ void fMoveConstructorTest() {
MoveConstructorTest cct;
// TODO: we'd expect the warning: {{1 uninitialized field}}
MoveConstructorTest copy(static_cast<MoveConstructorTest &&>(cct)); // no-warning
+ new MoveConstructorTest(static_cast<MoveConstructorTest &&>(cct)); // no-warning
funcToSquelchCompilerWarnings(copy);
}
@@ -684,6 +720,7 @@ struct IntArrayTest {
void fIntArrayTest() {
IntArrayTest();
+ new IntArrayTest();
}
struct RecordTypeArrayTest {
@@ -698,6 +735,7 @@ struct RecordTypeArrayTest {
void fRecordTypeArrayTest() {
RecordTypeArrayTest();
+ new RecordTypeArrayTest();
}
template <class T>
@@ -727,6 +765,7 @@ struct MemsetTest1 {
void fMemsetTest1() {
MemsetTest1();
+ new MemsetTest1();
}
struct MemsetTest2 {
@@ -739,6 +778,7 @@ struct MemsetTest2 {
void fMemsetTest2() {
MemsetTest2();
+ new MemsetTest2();
}
//===----------------------------------------------------------------------===//
@@ -773,6 +813,7 @@ struct LambdaTest1 {
void fLambdaTest1() {
auto isEven = [](int a) { return a % 2 == 0; };
LambdaTest1<decltype(isEven)>(isEven, int());
+ new LambdaTest1<decltype(isEven)>(isEven, int());
}
#ifdef PEDANTIC
@@ -780,13 +821,16 @@ template <class Callable>
struct LambdaTest2 {
Callable functor;
- LambdaTest2(const Callable &functor, int) : functor(functor) {} // expected-warning{{1 uninitialized field}}
+ LambdaTest2(const Callable &functor, int) : functor(functor) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fLambdaTest2() {
int b;
auto equals = [&b](int a) { return a == b; }; // expected-note{{uninitialized pointee 'this->functor./*captured variable*/b'}}
LambdaTest2<decltype(equals)>(equals, int());
+ int bp;
+ auto equalsp = [&bp](int a) { return a == bp; }; // expected-note{{uninitialized pointee 'this->functor./*captured variable*/bp'}}
+ new LambdaTest2<decltype(equalsp)>(equalsp, int());
}
#else
template <class Callable>
@@ -800,6 +844,7 @@ void fLambdaTest2() {
int b;
auto equals = [&b](int a) { return a == b; };
LambdaTest2<decltype(equals)>(equals, int());
+ new LambdaTest2<decltype(equals)>(equals, int());
}
#endif //PEDANTIC
@@ -807,8 +852,8 @@ void fLambdaTest2() {
namespace LT3Detail {
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->functor./*captured variable*/rec1.x'}}
- int y; // expected-note{{uninitialized field 'this->functor./*captured variable*/rec1.y'}}
+ int x; // expected-note{{uninitialized field 'this->functor./*captured variable*/rec1.x'}} expected-note{{uninitialized field 'this->functor./*captured variable*/rec1p.x'}}
+ int y; // expected-note{{uninitialized field 'this->functor./*captured variable*/rec1.y'}} expected-note{{uninitialized field 'this->functor./*captured variable*/rec1p.y'}}
};
} // namespace LT3Detail
@@ -816,7 +861,7 @@ template <class Callable>
struct LambdaTest3 {
Callable functor;
- LambdaTest3(const Callable &functor, int) : functor(functor) {} // expected-warning{{2 uninitialized fields}}
+ LambdaTest3(const Callable &functor, int) : functor(functor) {} // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
};
void fLambdaTest3() {
@@ -825,6 +870,11 @@ void fLambdaTest3() {
return rec1.x == rec2.x;
};
LambdaTest3<decltype(equals)>(equals, int());
+ LT3Detail::RecordType rec1p;
+ auto equalsp = [&rec1p](LT3Detail::RecordType rec2) {
+ return rec1p.x == rec2.x;
+ };
+ new LambdaTest3<decltype(equalsp)>(equalsp, int());
}
#else
namespace LT3Detail {
@@ -848,6 +898,7 @@ void fLambdaTest3() {
return rec1.x == rec2.x;
};
LambdaTest3<decltype(equals)>(equals, int());
+ new LambdaTest3<decltype(equals)>(equals, int());
}
#endif //PEDANTIC
@@ -856,7 +907,7 @@ struct MultipleLambdaCapturesTest1 {
Callable functor;
int dontGetFilteredByNonPedanticMode = 0;
- MultipleLambdaCapturesTest1(const Callable &functor, int) : functor(functor) {} // expected-warning{{2 uninitialized field}}
+ MultipleLambdaCapturesTest1(const Callable &functor, int) : functor(functor) {} // expected-warning{{2 uninitialized field}} expected-warning{{2 uninitialized field}}
};
void fMultipleLambdaCapturesTest1() {
@@ -864,6 +915,10 @@ void fMultipleLambdaCapturesTest1() {
auto equals = [&b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; // expected-note{{uninitialized pointee 'this->functor./*captured variable*/b1'}}
// expected-note at -1{{uninitialized pointee 'this->functor./*captured variable*/b3'}}
MultipleLambdaCapturesTest1<decltype(equals)>(equals, int());
+ int b1p, b2p = 3, b3p;
+ auto equalsp = [&b1p, &b2p, &b3p](int a) { return a == b1p == b2p == b3p; }; // expected-note{{uninitialized pointee 'this->functor./*captured variable*/b1p'}}
+ // expected-note at -1{{uninitialized pointee 'this->functor./*captured variable*/b3p'}}
+ new MultipleLambdaCapturesTest1<decltype(equalsp)>(equalsp, int());
}
template <class Callable>
@@ -871,13 +926,16 @@ struct MultipleLambdaCapturesTest2 {
Callable functor;
int dontGetFilteredByNonPedanticMode = 0;
- MultipleLambdaCapturesTest2(const Callable &functor, int) : functor(functor) {} // expected-warning{{1 uninitialized field}}
+ MultipleLambdaCapturesTest2(const Callable &functor, int) : functor(functor) {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fMultipleLambdaCapturesTest2() {
int b1, b2 = 3, b3;
auto equals = [b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; // expected-note{{uninitialized pointee 'this->functor./*captured variable*/b3'}}
MultipleLambdaCapturesTest2<decltype(equals)>(equals, int());
+ int b1p, b2p = 3, b3p;
+ auto equalsp = [b1p, &b2p, &b3p](int a) { return a == b1p == b2p == b3p; }; // expected-note{{uninitialized pointee 'this->functor./*captured variable*/b3p'}}
+ new MultipleLambdaCapturesTest2<decltype(equalsp)>(equalsp, int());
}
struct LambdaWrapper {
@@ -921,22 +979,24 @@ struct SystemHeaderTest1 {
void fSystemHeaderTest1() {
SystemHeaderTest1();
+ new SystemHeaderTest1();
}
#ifdef PEDANTIC
struct SystemHeaderTest2 {
struct RecordType {
- int x; // expected-note{{uninitialized field 'this->container.t.x}}
- int y; // expected-note{{uninitialized field 'this->container.t.y}}
+ int x; // expected-note{{uninitialized field 'this->container.t.x}} expected-note{{uninitialized field 'this->container.t.x}}
+ int y; // expected-note{{uninitialized field 'this->container.t.y}} expected-note{{uninitialized field 'this->container.t.y}}
};
ContainerInSystemHeader<RecordType> container;
- SystemHeaderTest2(RecordType &rec, int) : container(rec) {} // expected-warning{{2 uninitialized fields}}
+ SystemHeaderTest2(RecordType &rec, int) : container(rec) {} // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
};
void fSystemHeaderTest2() {
- SystemHeaderTest2::RecordType rec;
+ SystemHeaderTest2::RecordType rec, recp;
SystemHeaderTest2(rec, int());
+ new SystemHeaderTest2(recp, int());
}
#else
struct SystemHeaderTest2 {
@@ -952,6 +1012,7 @@ struct SystemHeaderTest2 {
void fSystemHeaderTest2() {
SystemHeaderTest2::RecordType rec;
SystemHeaderTest2(rec, int());
+ new SystemHeaderTest2(rec, int());
}
#endif //PEDANTIC
@@ -962,14 +1023,15 @@ void fSystemHeaderTest2() {
struct IncompleteTypeTest1 {
struct RecordType;
// no-crash
- RecordType *recptr; // expected-note{{uninitialized pointer 'this->recptr}}
+ RecordType *recptr; // expected-note{{uninitialized pointer 'this->recptr}} expected-note{{uninitialized pointer 'this->recptr}}
int dontGetFilteredByNonPedanticMode = 0;
- IncompleteTypeTest1() {} // expected-warning{{1 uninitialized field}}
+ IncompleteTypeTest1() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fIncompleteTypeTest1() {
IncompleteTypeTest1();
+ new IncompleteTypeTest1();
}
struct IncompleteTypeTest2 {
@@ -984,6 +1046,7 @@ struct IncompleteTypeTest2 {
void fIncompleteTypeTest2() {
IncompleteTypeTest2();
+ new IncompleteTypeTest2();
}
struct IncompleteTypeTest3 {
@@ -998,6 +1061,7 @@ struct IncompleteTypeTest3 {
void fIncompleteTypeTest3() {
IncompleteTypeTest3();
+ new IncompleteTypeTest3();
}
//===----------------------------------------------------------------------===//
@@ -1005,54 +1069,58 @@ void fIncompleteTypeTest3() {
//===----------------------------------------------------------------------===//
struct IntegralTypeTest {
- int a; // expected-note{{uninitialized field 'this->a'}}
+ int a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int dontGetFilteredByNonPedanticMode = 0;
- IntegralTypeTest() {} // expected-warning{{1 uninitialized field}}
+ IntegralTypeTest() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fIntegralTypeTest() {
IntegralTypeTest();
+ new IntegralTypeTest();
}
struct FloatingTypeTest {
- float a; // expected-note{{uninitialized field 'this->a'}}
+ float a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int dontGetFilteredByNonPedanticMode = 0;
- FloatingTypeTest() {} // expected-warning{{1 uninitialized field}}
+ FloatingTypeTest() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fFloatingTypeTest() {
FloatingTypeTest();
+ new FloatingTypeTest();
}
struct NullptrTypeTypeTest {
- decltype(nullptr) a; // expected-note{{uninitialized field 'this->a'}}
+ decltype(nullptr) a; // expected-note{{uninitialized field 'this->a'}} expected-note{{uninitialized field 'this->a'}}
int dontGetFilteredByNonPedanticMode = 0;
- NullptrTypeTypeTest() {} // expected-warning{{1 uninitialized field}}
+ NullptrTypeTypeTest() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void fNullptrTypeTypeTest() {
NullptrTypeTypeTest();
+ new NullptrTypeTypeTest();
}
struct EnumTest {
enum Enum {
A,
B
- } enum1; // expected-note{{uninitialized field 'this->enum1'}}
+ } enum1; // expected-note{{uninitialized field 'this->enum1'}} expected-note{{uninitialized field 'this->enum1'}}
enum class Enum2 {
A,
B
- } enum2; // expected-note{{uninitialized field 'this->enum2'}}
+ } enum2; // expected-note{{uninitialized field 'this->enum2'}} expected-note{{uninitialized field 'this->enum2'}}
int dontGetFilteredByNonPedanticMode = 0;
- EnumTest() {} // expected-warning{{2 uninitialized fields}}
+ EnumTest() {} // expected-warning{{2 uninitialized fields}} expected-warning{{2 uninitialized fields}}
};
void fEnumTest() {
EnumTest();
+ new EnumTest();
}
//===----------------------------------------------------------------------===//
@@ -1069,12 +1137,12 @@ void assert(int b) {
// While a singleton would make more sense as a static variable, that would zero
// initialize all of its fields, hence the not too practical implementation.
struct Singleton {
- int i; // expected-note{{uninitialized field 'this->i'}}
+ int i; // expected-note{{uninitialized field 'this->i'}} expected-note{{uninitialized field 'this->i'}}
int dontGetFilteredByNonPedanticMode = 0;
Singleton() {
assert(!isInstantiated);
- isInstantiated = true; // expected-warning{{1 uninitialized field}}
+ isInstantiated = true; // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
}
~Singleton() {
@@ -1091,6 +1159,7 @@ struct SingletonTest {
SingletonTest() {
Singleton();
+ new Singleton();
}
};
@@ -1112,6 +1181,7 @@ struct CXX11MemberInitTest1 {
void fCXX11MemberInitTest1() {
CXX11MemberInitTest1();
+ new CXX11MemberInitTest1();
}
struct CXX11MemberInitTest2 {
@@ -1133,6 +1203,7 @@ struct CXX11MemberInitTest2 {
void fCXX11MemberInitTest2() {
// TODO: we'd expect the warning: {{2 uninitializeds field}}
CXX11MemberInitTest2(); // no-warning
+ new CXX11MemberInitTest2(); // no-warning
}
//===----------------------------------------------------------------------===//
@@ -1140,14 +1211,15 @@ void fCXX11MemberInitTest2() {
//===----------------------------------------------------------------------===//
struct MyAtomicInt {
- _Atomic(int) x; // expected-note{{uninitialized field 'this->x'}}
+ _Atomic(int) x; // expected-note{{uninitialized field 'this->x'}} expected-note{{uninitialized field 'this->x'}}
int dontGetFilteredByNonPedanticMode = 0;
- MyAtomicInt() {} // expected-warning{{1 uninitialized field}}
+ MyAtomicInt() {} // expected-warning{{1 uninitialized field}} expected-warning{{1 uninitialized field}}
};
void _AtomicTest() {
MyAtomicInt b;
+ new MyAtomicInt();
}
struct VectorSizeLong {
@@ -1158,6 +1230,7 @@ struct VectorSizeLong {
void __vector_size__LongTest() {
// TODO: Warn for v.x.
VectorSizeLong v;
+ new VectorSizeLong();
v.x[0] = 0;
}
@@ -1178,9 +1251,11 @@ struct ComplexInitTest {
void fComplexTest() {
ComplexInitTest x;
+ new ComplexInitTest();
// TODO: we should emit a warning for x2.x and x2.y.
ComplexUninitTest x2;
+ new ComplexUninitTest();
}
struct PaddingBitfieldTest {
diff --git a/clang/test/Analysis/objcpp-uninitialized-object.mm b/clang/test/Analysis/objcpp-uninitialized-object.mm
index f5a4d7ae8564b..5542adcbef34a 100644
--- a/clang/test/Analysis/objcpp-uninitialized-object.mm
+++ b/clang/test/Analysis/objcpp-uninitialized-object.mm
@@ -4,29 +4,32 @@
struct StructWithBlock {
int a;
- myBlock z; // expected-note{{uninitialized field 'this->z'}}
+ myBlock z; // expected-note{{uninitialized field 'this->z'}} expected-note{{uninitialized field 'this->z'}}
StructWithBlock() : a(0), z(^{}) {}
// Miss initialization of field `z`.
- StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
+ StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} expected-warning{{1 uninitialized field at the end of the constructor call}}
};
void warnOnUninitializedBlock() {
StructWithBlock a(10);
+ new StructWithBlock(10);
}
void noWarningWhenInitialized() {
StructWithBlock a;
+ new StructWithBlock();
}
struct StructWithId {
int a;
- id z; // expected-note{{uninitialized pointer 'this->z'}}
- StructWithId() : a(0) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
+ id z; // expected-note{{uninitialized pointer 'this->z'}} expected-note{{uninitialized pointer 'this->z'}}
+ StructWithId() : a(0) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} expected-warning{{1 uninitialized field at the end of the constructor call}}
};
void warnOnUninitializedId() {
StructWithId s;
+ new StructWithId();
}
>From c58a7851b6153e48938c7a1ad704ce6ced46e10c Mon Sep 17 00:00:00 2001
From: guillem-bartrina-sonarsource <guillem.bartrina at sonarsource.com>
Date: Mon, 20 Apr 2026 17:38:36 +0200
Subject: [PATCH 2/2] Format
---
.../UninitializedObject/UninitializedObjectChecker.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 2b46d1c913b2a..8605877798e5e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -452,8 +452,8 @@ static void printTail(llvm::raw_ostream &Out,
//===----------------------------------------------------------------------===//
static const SubRegion *
- getConstructedSubRegion(const CXXConstructorDecl *CtorDecl,
- CheckerContext &Context) {
+getConstructedSubRegion(const CXXConstructorDecl *CtorDecl,
+ CheckerContext &Context) {
Loc ThisLoc =
Context.getSValBuilder().getCXXThis(CtorDecl, Context.getStackFrame());
SVal ObjectV = Context.getState()->getSVal(ThisLoc);
@@ -479,8 +479,8 @@ getConstructedRegion(const CXXConstructorDecl *CtorDecl,
auto &MemMgr = Context.getState()->getStateManager().getRegionManager();
auto &SVB = Context.getSValBuilder();
- const auto *ElemR = MemMgr.getElementRegion(
- DynType, SVB.makeZeroArrayIndex(), SR, Context.getASTContext());
+ const auto *ElemR = MemMgr.getElementRegion(DynType, SVB.makeZeroArrayIndex(),
+ SR, Context.getASTContext());
return ElemR;
}
More information about the cfe-commits
mailing list