mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-12 01:18:53 +00:00
[clang-tidy] Fix a crash in fuchsia-multiple-inheritance
Summary: See the test case for a repro. Reviewers: juliehockett, ioeric, hokein, aaron.ballman Reviewed By: hokein Subscribers: lebedev.ri, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D49862 llvm-svn: 338124
This commit is contained in:
parent
fcb636d222
commit
778a33a0bb
@ -30,6 +30,7 @@ AST_MATCHER(CXXRecordDecl, hasBases) {
|
||||
// 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 @@ void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
|
||||
// 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::isCurrentClassInterface(
|
||||
}
|
||||
|
||||
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))
|
||||
|
@ -134,3 +134,14 @@ template<typename T> struct B : virtual T {};
|
||||
|
||||
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)>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user