[PATCH] D37978: [analyzer] Fix an assertion fail in VirtualCallChecker
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 08:09:38 PDT 2017
xazax.hun created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.
This patch attempts to fix PR34451.
The `getBestDynamicClassType` call can only handle `RecordDecls` and pointers to `RecordDecls`. The code removed all the implicit casts, this includes the array to pointer decay. After removing the decay, the checker passed an array type to `getBestDynamicClassType` which triggered the assertion.
Repository:
rL LLVM
https://reviews.llvm.org/D37978
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: test/Analysis/virtualcall.cpp
===================================================================
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -271,3 +271,24 @@
#if !PUREONLY
//expected-note-re at -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(); }
+}
Index: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -146,7 +146,7 @@
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<FinalAttr>())
CallIsNonVirtual = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37978.115656.patch
Type: text/x-patch
Size: 1064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170918/d58dac42/attachment.bin>
More information about the cfe-commits
mailing list