This revision was automatically updated to reflect the committed changes.
Closed by commit rL338124: [clang-tidy] Fix a crash in
fuchsia-multiple-inheritance (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D49862
Files:
clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
Index: clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -30,6 +30,7 @@
// previously.
void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
bool isInterface) {
+ assert(Node->getIdentifier());
StringRef Name = Node->getIdentifier()->getName();
InterfaceMap.insert(std::make_pair(Name, isInterface));
}
@@ -39,6 +40,7 @@
// interface status for the current node is not yet known.
bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
bool &isInterface) const {
+ assert(Node->getIdentifier());
StringRef Name = Node->getIdentifier()->getName();
llvm::StringMapConstIterator<bool> Pair = InterfaceMap.find(Name);
if (Pair == InterfaceMap.end())
@@ -59,6 +61,9 @@
}
bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
+ if (!Node->getIdentifier())
+ return false;
+
// Short circuit the lookup if we have analyzed this record before.
bool PreviousIsInterfaceResult;
if (getInterfaceStatus(Node, PreviousIsInterfaceResult))
Index: clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -134,3 +134,14 @@
template<typename> struct C {};
template<typename T> struct D : C<T> {};
+
+// Check clang_tidy does not crash on this code.
+template <class T>
+struct WithTemplBase : T {
+ WithTemplBase();
+};
+
+int test_no_crash() {
+ auto foo = []() {};
+ WithTemplBase<decltype(foo)>();
+}
Index: clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -30,6 +30,7 @@
// previously.
void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
bool isInterface) {
+ assert(Node->getIdentifier());
StringRef Name = Node->getIdentifier()->getName();
InterfaceMap.insert(std::make_pair(Name, isInterface));
}
@@ -39,6 +40,7 @@
// interface status for the current node is not yet known.
bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
bool &isInterface) const {
+ assert(Node->getIdentifier());
StringRef Name = Node->getIdentifier()->getName();
llvm::StringMapConstIterator<bool> Pair = InterfaceMap.find(Name);
if (Pair == InterfaceMap.end())
@@ -59,6 +61,9 @@
}
bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
+ if (!Node->getIdentifier())
+ return false;
+
// Short circuit the lookup if we have analyzed this record before.
bool PreviousIsInterfaceResult;
if (getInterfaceStatus(Node, PreviousIsInterfaceResult))
Index: clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -134,3 +134,14 @@
template<typename> struct C {};
template<typename T> struct D : C<T> {};
+
+// Check clang_tidy does not crash on this code.
+template <class T>
+struct WithTemplBase : T {
+ WithTemplBase();
+};
+
+int test_no_crash() {
+ auto foo = []() {};
+ WithTemplBase<decltype(foo)>();
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits