[clang] aa42785 - [clang] Simplify CFG block printing code a bit
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 26 06:45:36 PDT 2021
Author: Nico Weber
Date: 2021-10-26T09:45:22-04:00
New Revision: aa42785d01cb498c1eb880e9f0e08f01006839c6
URL: https://github.com/llvm/llvm-project/commit/aa42785d01cb498c1eb880e9f0e08f01006839c6
DIFF: https://github.com/llvm/llvm-project/commit/aa42785d01cb498c1eb880e9f0e08f01006839c6.diff
LOG: [clang] Simplify CFG block printing code a bit
No behavior change.
Added:
Modified:
clang/lib/Analysis/CFG.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 190e0d94ee99..39c0f14c7b89 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -5683,21 +5683,18 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
OS << L->getName();
else if (CaseStmt *C = dyn_cast<CaseStmt>(Label)) {
OS << "case ";
- if (C->getLHS())
- C->getLHS()->printPretty(OS, &Helper,
- PrintingPolicy(Helper.getLangOpts()));
- if (C->getRHS()) {
+ if (const Expr *LHS = C->getLHS())
+ LHS->printPretty(OS, &Helper, PrintingPolicy(Helper.getLangOpts()));
+ if (const Expr *RHS = C->getRHS()) {
OS << " ... ";
- C->getRHS()->printPretty(OS, &Helper,
- PrintingPolicy(Helper.getLangOpts()));
+ RHS->printPretty(OS, &Helper, PrintingPolicy(Helper.getLangOpts()));
}
} else if (isa<DefaultStmt>(Label))
OS << "default";
else if (CXXCatchStmt *CS = dyn_cast<CXXCatchStmt>(Label)) {
OS << "catch (";
- if (CS->getExceptionDecl())
- CS->getExceptionDecl()->print(OS, PrintingPolicy(Helper.getLangOpts()),
- 0);
+ if (const VarDecl *ED = CS->getExceptionDecl())
+ ED->print(OS, PrintingPolicy(Helper.getLangOpts()), 0);
else
OS << "...";
OS << ")";
More information about the cfe-commits
mailing list