versioner: properly handle declarations with no identifier.

Some declarations, like bitfield members, don't need identifiers.

Bug: https://github.com/android-ndk/ndk/issues/440
Test: ran versioner with -x c++ on a manually reduced <linux/timex.h>
Change-Id: Ic7eea780762cff653c54fdde4d10df203d630c25
This commit is contained in:
Josh Gao 2017-10-24 17:03:58 -07:00
parent 5317f2d48b
commit 0062b3e60a

View file

@ -54,17 +54,19 @@ class Visitor : public RecursiveASTVisitor<Visitor> {
}
}
if (mangler->shouldMangleDeclName(decl)) {
std::string mangled;
llvm::raw_string_ostream ss(mangled);
mangler->mangleName(decl, ss);
return mangled;
}
// The decl might not have a name (e.g. bitfields).
if (auto identifier = decl->getIdentifier()) {
if (mangler->shouldMangleDeclName(decl)) {
std::string mangled;
llvm::raw_string_ostream ss(mangled);
mangler->mangleName(decl, ss);
return mangled;
}
return identifier->getName();
}
return "<error>";
return "<unnamed>";
}
bool VisitDecl(Decl* decl) {