summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/cfg-rich-constructors.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-03-21 00:15:07 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-03-21 00:15:07 +0000
commitaa40315c69fb667c070293ea94f6caaf4a0a6ec6 (patch)
tree78b67bc379605102073514154a02c0af3841283e /clang/test/Analysis/cfg-rich-constructors.cpp
parentf1d87f8b4c430d72e7ab07e13508336a7841c3e6 (diff)
downloadbcm5719-llvm-aa40315c69fb667c070293ea94f6caaf4a0a6ec6.tar.gz
bcm5719-llvm-aa40315c69fb667c070293ea94f6caaf4a0a6ec6.zip
[CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in constructors.
When searching for construction contexts, i.e. figuring out which statements define the object that is constructed by each construct-expression, ignore transparent init-list expressions because they don't add anything to the context. This allows the Static Analyzer to model construction, destruction, materialization, lifetime extension correctly in more cases. Also fixes a crash caused by incorrectly evaluating initial values of variables initialized with such expressions. Differential Revision: https://reviews.llvm.org/D59573 llvm-svn: 356634
Diffstat (limited to 'clang/test/Analysis/cfg-rich-constructors.cpp')
-rw-r--r--clang/test/Analysis/cfg-rich-constructors.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Analysis/cfg-rich-constructors.cpp b/clang/test/Analysis/cfg-rich-constructors.cpp
index 31c306bbfe9..0125c9bf523 100644
--- a/clang/test/Analysis/cfg-rich-constructors.cpp
+++ b/clang/test/Analysis/cfg-rich-constructors.cpp
@@ -1043,3 +1043,23 @@ void testCrashOnVariadicArgument() {
C c(variadic(0 ? c : 0)); // no-crash
}
} // namespace variadic_function_arguments
+
+// CHECK: void testTransparentInitListExprs()
+// CHECK: [B1]
+// CHECK-NEXT: 1: getC
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class transparent_init_list_exprs::C (*)(void))
+// CXX11-ELIDE-NEXT: 3: [B1.2]() (CXXRecordTypedCall, [B1.4], [B1.5])
+// CXX11-NOELIDE-NEXT: 3: [B1.2]() (CXXRecordTypedCall, [B1.4])
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: {[B1.4]} (CXXConstructExpr, [B1.6], class transparent_init_list_exprs::C)
+// CXX11-NEXT: 6: transparent_init_list_exprs::C c{getC()};
+// CXX17-NEXT: 3: [B1.2]() (CXXRecordTypedCall, [B1.5])
+// CXX17-NEXT: 4: {[B1.3]}
+// CXX17-NEXT: 5: transparent_init_list_exprs::C c{getC()};
+namespace transparent_init_list_exprs {
+class C {};
+C getC();
+void testTransparentInitListExprs() {
+ C c{getC()};
+}
+} // namespace transparent_init_list_exprs
OpenPOWER on IntegriCloud