Bug 1467658 - Allow the mozsearch-plugin code to build against clang 6. r?kats
Also work around https://bugs.llvm.org/show_bug.cgi?id=37746 by
explicitly handling ObjC interface variables separately. This actually
allows the searchfox macosx build to go much further than it used to (it
now fails during make package with apparently no output for rust code)
--- a/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
+++ b/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
@@ -266,17 +266,20 @@ private:
for (const DeclContext *DC : Contexts) {
if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
Result += Spec->getNameAsString();
if (Spec->getSpecializationKind() == TSK_ExplicitSpecialization) {
std::string Backing;
llvm::raw_string_ostream Stream(Backing);
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
-#if CLANG_VERSION_MAJOR > 3 || \
+#if CLANG_VERSION_MAJOR > 5
+ printTemplateArgumentList(
+ Stream, TemplateArgs.asArray(), PrintingPolicy(CI.getLangOpts()));
+#elif CLANG_VERSION_MAJOR > 3 || \
(CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR >= 9)
TemplateSpecializationType::PrintTemplateArgumentList(
Stream, TemplateArgs.asArray(), PrintingPolicy(CI.getLangOpts()));
#else
TemplateSpecializationType::PrintTemplateArgumentList(
stream, templateArgs.data(), templateArgs.size(),
PrintingPolicy(CI.getLangOpts()));
#endif
@@ -355,30 +358,35 @@ private:
} else {
Ctx->mangleName(Decl, Out);
}
return Out.str().str();
} else {
return std::string("V_") + mangleLocation(Decl->getLocation()) +
std::string("_") + hash(Decl->getName());
}
- } else if (isa<TagDecl>(Decl) || isa<TypedefNameDecl>(Decl)) {
+ } else if (isa<TagDecl>(Decl) || isa<TypedefNameDecl>(Decl) ||
+ isa<ObjCInterfaceDecl>(Decl)) {
if (!Decl->getIdentifier()) {
// Anonymous.
return std::string("T_") + mangleLocation(Decl->getLocation());
}
return std::string("T_") + mangleQualifiedName(getQualifiedName(Decl));
} else if (isa<NamespaceDecl>(Decl) || isa<NamespaceAliasDecl>(Decl)) {
if (!Decl->getIdentifier()) {
// Anonymous.
return std::string("NS_") + mangleLocation(Decl->getLocation());
}
return std::string("NS_") + mangleQualifiedName(getQualifiedName(Decl));
+ } else if (const ObjCIvarDecl *D2 = dyn_cast<ObjCIvarDecl>(Decl)) {
+ const ObjCInterfaceDecl *Iface = D2->getContainingInterface();
+ return std::string("F_<") + getMangledName(Ctx, Iface) + ">_" +
+ D2->getNameAsString();
} else if (const FieldDecl *D2 = dyn_cast<FieldDecl>(Decl)) {
const RecordDecl *Record = D2->getParent();
return std::string("F_<") + getMangledName(Ctx, Record) + ">_" +
toString(D2->getFieldIndex());
} else if (const EnumConstantDecl *D2 = dyn_cast<EnumConstantDecl>(Decl)) {
const DeclContext *DC = Decl->getDeclContext();
if (const NamedDecl *Named = dyn_cast<NamedDecl>(DC)) {
return std::string("E_<") + getMangledName(Ctx, Named) + ">_" +