fix name for unnamed undeclared types
type->getAsTagDecl() may return null, e.g. in the following example:
struct Foo {
struct {
uint64_t len;
uint64_t flags;
} __attribute__((packed)) bars[BARS];
...
};
This commit is contained in:
@@ -150,7 +150,13 @@ std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx,
|
||||
result = "(anonymous)";
|
||||
else if (util::contains(result, "unnamed struct") ||
|
||||
util::contains(result, "unnamed union")) {
|
||||
result = common::get_tag_name(*type->getAsTagDecl());
|
||||
auto declarationTag = type->getAsTagDecl();
|
||||
if (declarationTag == NULL) {
|
||||
result = "(unnamed undeclared)";
|
||||
}
|
||||
else {
|
||||
result = common::get_tag_name(*declarationTag);
|
||||
}
|
||||
}
|
||||
else if (util::contains(result, "anonymous struct") ||
|
||||
util::contains(result, "anonymous union")) {
|
||||
|
||||
Reference in New Issue
Block a user