juliehockett created this revision.
juliehockett added reviewers: aaron.ballman, hokein, ilya-biryukov.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.
Bug 36150 found a segfault on mac when a CXXRecordDecl has no IdentifierInfo,
this fixes it.
https://reviews.llvm.org/D49158
Files:
clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -30,21 +30,27 @@
// previously.
void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
bool isInterface) {
- StringRef Name = Node->getIdentifier()->getName();
- InterfaceMap.insert(std::make_pair(Name, isInterface));
+ if (const auto *Id = Node->getIdentifier()) {
+ StringRef Name = Id->getName();
+ InterfaceMap.insert(std::make_pair(Name, isInterface));
+ }
}
// Returns "true" if the boolean "isInterface" has been set to the
// interface status of the current Node. Return "false" if the
// interface status for the current node is not yet known.
bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
bool &isInterface) const {
- StringRef Name = Node->getIdentifier()->getName();
- llvm::StringMapConstIterator<bool> Pair = InterfaceMap.find(Name);
- if (Pair == InterfaceMap.end())
- return false;
- isInterface = Pair->second;
- return true;
+ if (!Node) return false;
+ if (const auto *Id = Node->getIdentifier()) {
+ StringRef Name = Id->getName();
+ llvm::StringMapConstIterator<bool> Pair = InterfaceMap.find(Name);
+ if (Pair == InterfaceMap.end())
+ return false;
+ isInterface = Pair->second;
+ return true;
+ }
+ return false;
}
bool MultipleInheritanceCheck::isCurrentClassInterface(
@@ -104,7 +110,7 @@
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
if (!isInterface(Base)) NumConcrete++;
}
-
+
// Check virtual bases to see if there is more than one concrete
// non-virtual base.
for (const auto &V : D->vbases()) {
Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -30,21 +30,27 @@
// previously.
void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
bool isInterface) {
- StringRef Name = Node->getIdentifier()->getName();
- InterfaceMap.insert(std::make_pair(Name, isInterface));
+ if (const auto *Id = Node->getIdentifier()) {
+ StringRef Name = Id->getName();
+ InterfaceMap.insert(std::make_pair(Name, isInterface));
+ }
}
// Returns "true" if the boolean "isInterface" has been set to the
// interface status of the current Node. Return "false" if the
// interface status for the current node is not yet known.
bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
bool &isInterface) const {
- StringRef Name = Node->getIdentifier()->getName();
- llvm::StringMapConstIterator<bool> Pair = InterfaceMap.find(Name);
- if (Pair == InterfaceMap.end())
- return false;
- isInterface = Pair->second;
- return true;
+ if (!Node) return false;
+ if (const auto *Id = Node->getIdentifier()) {
+ StringRef Name = Id->getName();
+ llvm::StringMapConstIterator<bool> Pair = InterfaceMap.find(Name);
+ if (Pair == InterfaceMap.end())
+ return false;
+ isInterface = Pair->second;
+ return true;
+ }
+ return false;
}
bool MultipleInheritanceCheck::isCurrentClassInterface(
@@ -104,7 +110,7 @@
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
if (!isInterface(Base)) NumConcrete++;
}
-
+
// Check virtual bases to see if there is more than one concrete
// non-virtual base.
for (const auto &V : D->vbases()) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits