Skip to content

Commit 1295c39

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] CHERIUtils: Print aka type in messages
1 parent dc20a8a commit 1295c39

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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

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

55+
namespace {
56+
void printType(raw_ostream &OS, const QualType &Ty,
57+
const PrintingPolicy &PP) {
58+
OS << "'";
59+
Ty.print(OS, PP);
60+
OS << "'";
61+
const QualType &CanTy = Ty.getCanonicalType();
62+
if (CanTy != Ty) {
63+
OS << " (aka '";
64+
CanTy.print(OS, PP);
65+
OS << "')";
66+
}
67+
}
68+
} // namespace
69+
5570
void describeCast(raw_ostream &OS, const CastExpr *CE,
5671
const LangOptions &LangOpts) {
72+
const PrintingPolicy &PP = PrintingPolicy(LangOpts);
5773
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 << "'";
74+
OS << " cast from ";
75+
printType(OS, CE->getSubExpr()->getType(), PP);
76+
OS << " to ";
77+
printType(OS, CE->getType(), PP);
6378
}
6479

6580

0 commit comments

Comments
 (0)