ilya-biryukov created this revision. ilya-biryukov added reviewers: juliehockett, ioeric, hokein, aaron.ballman. Herald added a subscriber: xazax.hun.
See the test case for a repro. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49862 Files: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp test/clang-tidy/fuchsia-multiple-inheritance-crash.cpp Index: test/clang-tidy/fuchsia-multiple-inheritance-crash.cpp =================================================================== --- /dev/null +++ test/clang-tidy/fuchsia-multiple-inheritance-crash.cpp @@ -0,0 +1,10 @@ +// RUN: clang-tidy -checks='fuchsia-multiple-inheritance' %s -- +template <class T> +struct X : T { + X(); +}; + +int test() { + auto foo = []() {}; + X<decltype(foo)>(); +} Index: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp =================================================================== --- clang-tidy/fuchsia/MultipleInheritanceCheck.cpp +++ 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: test/clang-tidy/fuchsia-multiple-inheritance-crash.cpp =================================================================== --- /dev/null +++ test/clang-tidy/fuchsia-multiple-inheritance-crash.cpp @@ -0,0 +1,10 @@ +// RUN: clang-tidy -checks='fuchsia-multiple-inheritance' %s -- +template <class T> +struct X : T { + X(); +}; + +int test() { + auto foo = []() {}; + X<decltype(foo)>(); +} Index: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp =================================================================== --- clang-tidy/fuchsia/MultipleInheritanceCheck.cpp +++ 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))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits