diff options
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 2 | ||||
-rw-r--r-- | clang/test/Analysis/diagnostics/dtors.cpp | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 691176dfc1f..3e93bb6a7c4 100644 --- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -723,6 +723,8 @@ PathDiagnosticLocation::create(const ProgramPoint& P, } else if (Optional<PostInitializer> PIP = P.getAs<PostInitializer>()) { return PathDiagnosticLocation(PIP->getInitializer()->getSourceLocation(), SMng); + } else if (Optional<PreImplicitCall> PIC = P.getAs<PreImplicitCall>()) { + return PathDiagnosticLocation(PIC->getLocation(), SMng); } else if (Optional<PostImplicitCall> PIE = P.getAs<PostImplicitCall>()) { return PathDiagnosticLocation(PIE->getLocation(), SMng); } else if (Optional<CallEnter> CE = P.getAs<CallEnter>()) { diff --git a/clang/test/Analysis/diagnostics/dtors.cpp b/clang/test/Analysis/diagnostics/dtors.cpp new file mode 100644 index 00000000000..094917e432f --- /dev/null +++ b/clang/test/Analysis/diagnostics/dtors.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,cplusplus -verify %s + +// expected-no-diagnostics + +namespace no_crash_on_delete_dtor { +// We were crashing when producing diagnostics for this code. +struct S { + void foo(); + ~S(); +}; + +struct smart_ptr { + int x; + S *s; + smart_ptr(S *); + S *get() { + return (x || 0) ? nullptr : s; + } +}; + +void bar(smart_ptr p) { + delete p.get(); + p.get()->foo(); +} +} // namespace no_crash_on_delete_dtor |