Skip to content

Commit

Permalink
[analyzer][CTU][NFC] Add an extra regression test
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
27 changes: 27 additions & 0 deletions clang/test/Analysis/Inputs/ctu-inherited-default-ctor-other.cpp
@@ -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;
28 changes: 28 additions & 0 deletions clang/test/Analysis/ctu-inherited-default-ctor.cpp
@@ -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

0 comments on commit 0e0ea9f

Please sign in to comment.