[PATCH] D96586: [analyzer][CTU][NFC] Add an extra regression test

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 12 02:09:53 PST 2021


steakhal created this revision.
steakhal added reviewers: martong, balazske, Szelethus, NoQ, vsavchenko, gamesh411.
Herald added subscribers: ASDenysPetrov, Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before bc713f6a004723d1325bc16e1efc32d0ac82f939 <https://reviews.llvm.org/rGbc713f6a004723d1325bc16e1efc32d0ac82f939> 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96586

Files:
  clang/test/Analysis/Inputs/ctu-inherited-default-ctor-other.cpp
  clang/test/Analysis/ctu-inherited-default-ctor.cpp


Index: clang/test/Analysis/ctu-inherited-default-ctor.cpp
===================================================================
--- /dev/null
+++ 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 at clang@S at 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
Index: clang/test/Analysis/Inputs/ctu-inherited-default-ctor-other.cpp
===================================================================
--- /dev/null
+++ 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96586.323262.patch
Type: text/x-patch
Size: 2256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210212/1a966d7d/attachment.bin>


More information about the cfe-commits mailing list