[PATCH] D16854: [clang-tidy] Fix a crash issue on misc-virtual-near-miss check.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 3 09:26:04 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259668: [clang-tidy] Fix a crash issue on misc-virtual-near-miss check. (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D16854?vs=46787&id=46800#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16854
Files:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
Index: clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
@@ -1,10 +1,14 @@
// RUN: %check_clang_tidy %s misc-virtual-near-miss %t
+class NoDefinedClass1;
+class NoDefinedClass2;
+
struct Base {
virtual void func();
virtual void gunk();
virtual ~Base();
virtual Base &operator=(const Base &);
+ virtual NoDefinedClass1 *f();
};
struct Derived : Base {
@@ -24,6 +28,8 @@
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
Derived &operator==(const Base &); // Should not warn: operators are ignored.
+
+ virtual NoDefinedClass2 *f1(); // Should not crash: non-defined class return type is ignored.
};
typedef Derived derived_type;
Index: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
@@ -72,6 +72,9 @@
if (DRD == nullptr || BRD == nullptr)
return false;
+ if (!DRD->hasDefinition() || !BRD->hasDefinition())
+ return false;
+
if (DRD == BRD)
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16854.46800.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160203/adc572b9/attachment.bin>
More information about the cfe-commits
mailing list