Bug 1282172 - Detect enum constants generated by macros when generating the Searchfox index. r?billm
MozReview-Commit-ID: 5RUsVSMTU8
--- a/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
+++ b/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
@@ -1035,16 +1035,26 @@ public:
return SourceRange();
}
return Range;
}
bool VisitNamedDecl(NamedDecl *D) {
SourceLocation Loc = D->getLocation();
+
+ if (isa<EnumConstantDecl>(D) && SM.isMacroBodyExpansion(Loc)) {
+ // for enum constants generated by macro expansion, update location
+ // to point to the expansion location as that is more useful. We might
+ // want to do this for more token types but until we have good regression
+ // testing for the Indexer it's best to be as conservative and explicit
+ // as possible with the changes.
+ Loc = SM.getFileLoc(Loc);
+ }
+
normalizeLocation(&Loc);
if (!isInterestingLocation(Loc)) {
return true;
}
if (isa<ParmVarDecl>(D) && !D->getDeclName().getAsIdentifierInfo()) {
// Unnamed parameter in function proto.
return true;