diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
--- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -1238,7 +1238,8 @@
// the processing of DISPATCH what __VA_ARGS__ maps to, so we'll
// retrieve the next series of tokens from that.
if (TheTok.getIdentifierInfo() == VariadicParamII) {
- TStream.injectRange(PrevParamMap.at(VariadicParamII));
+ if (PrevParamMap.find(VariadicParamII) != PrevParamMap.end())
+ TStream.injectRange(PrevParamMap.at(VariadicParamII));
TStream.next(TheTok);
continue;
}
diff --git a/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist b/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
--- a/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
+++ b/clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
@@ -6923,6 +6923,142 @@
+
+ path
+
+
+ kindevent
+ location
+
+ line560
+ col3
+ file0
+
+ ranges
+
+
+
+ line560
+ col3
+ file0
+
+
+ line560
+ col14
+ file0
+
+
+
+ depth0
+ extended_message
+ 'localvar' declared without an initial value
+ message
+ 'localvar' declared without an initial value
+
+
+ kindcontrol
+ edges
+
+
+ start
+
+
+ line560
+ col3
+ file0
+
+
+ line560
+ col5
+ file0
+
+
+ end
+
+
+ line561
+ col3
+ file0
+
+
+ line561
+ col15
+ file0
+
+
+
+
+
+
+ kindevent
+ location
+
+ line561
+ col3
+ file0
+
+ ranges
+
+
+
+ line561
+ col3
+ file0
+
+
+ line564
+ col12
+ file0
+
+
+
+ depth0
+ extended_message
+ 4th function call argument is an uninitialized value
+ message
+ 4th function call argument is an uninitialized value
+
+
+ macro_expansions
+
+
+ location
+
+ line561
+ col3
+ file0
+
+ nameTRACE_WRAPPER
+ expansion{ trace((0), traceid("formatstr " str), 0, tracelevel,); }
+
+
+ description4th function call argument is an uninitialized value
+ categoryLogic error
+ typeUninitialized argument value
+ check_namecore.CallAndMessage
+
+ issue_hash_content_of_line_in_context7b4de363511977d731e5dfab4fd89c66
+ issue_context_kindfunction
+ issue_contextfuncXXX
+ issue_hash_function_offset2
+ location
+
+ line561
+ col3
+ file0
+
+ ExecutedLines
+
+ 0
+
+ 557
+ 558
+ 559
+ 560
+ 561
+
+
+
files
diff --git a/clang/test/Analysis/plist-macros-with-expansion.cpp b/clang/test/Analysis/plist-macros-with-expansion.cpp
--- a/clang/test/Analysis/plist-macros-with-expansion.cpp
+++ b/clang/test/Analysis/plist-macros-with-expansion.cpp
@@ -543,3 +543,23 @@
// CHECK: nameBZ44493_GNUVA
// CHECK-NEXT: expansion--(a);
+
+// Expected warning, and don't crash
+const char *traceid(const char *);
+int trace(int, const char *, int, ...);
+#define TRACE_CALL(tracelevel, ...) \
+ { __VA_ARGS__; }
+
+#define TRACE(tracelevel, str, ...) \
+ TRACE_CALL((tracelevel), trace((0), traceid("formatstr " str), 0, tracelevel, __VA_ARGS__))
+
+#define TRACE_WRAPPER TRACE
+
+void funcXXX(
+ void *Context_p) {
+ int localvar;
+ TRACE_WRAPPER(
+ localvar,
+ "localvar=%u ",
+ 0); // expected-warning{{4th function call argument is an uninitialized value}}
+}