Skip to content

Commit 03c9499

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] CHERIUtils: Print aka type in messages
1 parent 3c12dfa commit 03c9499

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

clang/lib/StaticAnalyzer/Checkers/CHERI/CHERIUtils.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,28 @@ bool hasCapability(const QualType OrigTy, ASTContext &Ctx) {
5252
return false;
5353
}
5454

55+
namespace {
56+
void printType(raw_ostream &OS, const QualType &Ty, const PrintingPolicy &PP) {
57+
OS << "'";
58+
Ty.print(OS, PP);
59+
OS << "'";
60+
const QualType &CanTy = Ty.getCanonicalType();
61+
if (CanTy != Ty) {
62+
OS << " (aka '";
63+
CanTy.print(OS, PP);
64+
OS << "')";
65+
}
66+
}
67+
} // namespace
68+
5569
void describeCast(raw_ostream &OS, const CastExpr *CE,
5670
const LangOptions &LangOpts) {
71+
const PrintingPolicy &PP = PrintingPolicy(LangOpts);
5772
OS << (dyn_cast<ImplicitCastExpr>(CE) ? "implicit" : "explicit");
58-
OS << " cast from '";
59-
CE->getSubExpr()->getType().print(OS, PrintingPolicy(LangOpts));
60-
OS << "' to '";
61-
CE->getType().print(OS, PrintingPolicy(LangOpts));
62-
OS << "'";
73+
OS << " cast from ";
74+
printType(OS, CE->getSubExpr()->getType(), PP);
75+
OS << " to ";
76+
printType(OS, CE->getType(), PP);
6377
}
6478

6579
} // namespace cheri

0 commit comments

Comments
 (0)