Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer][CTU][NFC] Add an extra regression test
Before `bc713f6a004723d1325bc16e1efc32d0ac82f939` landed, the analyzer crashed on this reduced example. It seems important to have bot `ctu` and `-analyzer-opt-analyze-headers` enabled in the example. This test file ensures that no regression happens in the future in this regard. Reviewed By: martong, NoQ Differential Revision: https://reviews.llvm.org/D96586
- Loading branch information
Balazs Benics
committed
Mar 10, 2021
1 parent
0dc0e2a
commit 0e0ea9f
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
clang/test/Analysis/Inputs/ctu-inherited-default-ctor-other.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace llvm { | ||
template <int, typename...> | ||
class impl; | ||
// basecase | ||
template <int n> | ||
class impl<n> {}; | ||
// recursion | ||
template <int n, typename T, typename... TS> | ||
class impl<n, T, TS...> : impl<n + 1, TS...> { | ||
using child = impl<n + 1, TS...>; | ||
using child::child; // no-crash | ||
impl(T); | ||
}; | ||
template <typename... TS> | ||
class container : impl<0, TS...> {}; | ||
} // namespace llvm | ||
namespace clang { | ||
class fun { | ||
llvm::container<int, float> k; | ||
fun() {} | ||
}; | ||
class DeclContextLookupResult { | ||
static int *const SingleElementDummyList; | ||
}; | ||
} // namespace clang | ||
using namespace clang; | ||
int *const DeclContextLookupResult::SingleElementDummyList = nullptr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Should not crash with '-analyzer-opt-analyze-headers' option during CTU analysis. | ||
// | ||
// RUN: rm -r %t && mkdir -p %t/ctudir | ||
// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \ | ||
// RUN: -emit-pch -o %t/ctudir/ctu-inherited-default-ctor-other.cpp.ast \ | ||
// RUN: %S/Inputs/ctu-inherited-default-ctor-other.cpp | ||
// RUN: echo "c:@N@clang@S@DeclContextLookupResult@SingleElementDummyList ctu-inherited-default-ctor-other.cpp.ast" \ | ||
// RUN: > %t/ctudir/externalDefMap.txt | ||
// | ||
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \ | ||
// RUN: -analyzer-opt-analyze-headers \ | ||
// RUN: -analyzer-checker=core \ | ||
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \ | ||
// RUN: -analyzer-config ctu-dir=%t/ctudir \ | ||
// RUN: -analyzer-config display-ctu-progress=true \ | ||
// RUN: -verify %s 2>&1 | FileCheck %s | ||
// | ||
// expected-no-diagnostics | ||
// | ||
// CHECK: CTU loaded AST file: ctu-inherited-default-ctor-other.cpp.ast | ||
|
||
namespace clang {} | ||
namespace llvm {} | ||
namespace clang { | ||
class DeclContextLookupResult { | ||
static int *const SingleElementDummyList; | ||
}; | ||
} // namespace clang |