Remove unreachable that was reached in modernize-use-nullptr.
Summary: When traversing the parent map, the check assumed that all the nodes would be either Stmt or Decl. After r251101, this is no longer true: there can be TypeLoc and NestedNameSpecifierLoc nodes.
Reviewers: alexfh
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D14229
llvm-svn: 251803
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index 665b645..99e4406 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -435,12 +435,14 @@
Loc = D->getLocStart();
else if (const auto *S = Parent.get<Stmt>())
Loc = S->getLocStart();
- else
- llvm_unreachable("Expected to find Decl or Stmt containing ancestor");
- if (!expandsFrom(Loc, MacroLoc)) {
- Result = Parent;
- return true;
+ // TypeLoc and NestedNameSpecifierLoc are members of the parent map. Skip
+ // them and keep going up.
+ if (Loc.isValid()) {
+ if (!expandsFrom(Loc, MacroLoc)) {
+ Result = Parent;
+ return true;
+ }
}
Start = Parent;
}