From 289261b569f6ee357847882efa9605522b654e60 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Thu, 21 Sep 2017 08:18:59 +0000 Subject: [PATCH] [analyzer] Fix an assertion fail in VirtualCallChecker Differential Revision: https://reviews.llvm.org/D37978 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313866 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Checkers/VirtualCallChecker.cpp | 2 +- test/Analysis/virtualcall.cpp | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp b/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp index ea1976e020..c5010f5378 100644 --- a/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp @@ -146,7 +146,7 @@ static bool isVirtualCall(const CallExpr *CE) { if (CME->getQualifier()) CallIsNonVirtual = true; - if (const Expr *Base = CME->getBase()->IgnoreImpCasts()) { + if (const Expr *Base = CME->getBase()) { // The most derived class is marked final. if (Base->getBestDynamicClassType()->hasAttr()) CallIsNonVirtual = true; diff --git a/test/Analysis/virtualcall.cpp b/test/Analysis/virtualcall.cpp index 135fa585ec..c22a8463c0 100644 --- a/test/Analysis/virtualcall.cpp +++ b/test/Analysis/virtualcall.cpp @@ -271,3 +271,24 @@ int main() { #if !PUREONLY //expected-note-re@-2 2{{{{^}}Calling '~E'}} #endif + +namespace PR34451 { +struct a { + void b() { + a c[1]; + c->b(); + } +}; + +class e { + public: + void b() const; +}; + +class c { + void m_fn2() const; + e d[]; +}; + +void c::m_fn2() const { d->b(); } +} -- 2.40.0