aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/fuchsia
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-07-27 14:05:39 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-07-27 14:05:39 +0000
commitf2d6b39b43a19a020b0cf50b9379e7d70b3ae4de (patch)
tree165781da46947f6526d3bf47d938e644f2b9e4e2 /clang-tidy/fuchsia
parent9fb58aa2f667ea3a557b607e6dfcb035cf0d219d (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@338124 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/fuchsia')
-rw-r--r--clang-tidy/fuchsia/MultipleInheritanceCheck.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
index d4624d01..35504c98 100644
--- a/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ b/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -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))