summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclPrinter.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-06-09 22:53:25 +0000
committerRichard Trieu <rtrieu@google.com>2014-06-09 22:53:25 +0000
commitddd01cec0e4ecec0ca2f6e02c38281ee562fcd8d (patch)
tree37c95111a4e9ec687e3be04eb7f4e149d693c0e2 /clang/lib/AST/DeclPrinter.cpp
parenta23043cb9c1ef021a9cf05cd62cce76cd03c0ba2 (diff)
downloadbcm5719-llvm-ddd01cec0e4ecec0ca2f6e02c38281ee562fcd8d.tar.gz
bcm5719-llvm-ddd01cec0e4ecec0ca2f6e02c38281ee562fcd8d.zip
Removing an "if (this == nullptr)" check from two print methods. The condition
will never be true in a well-defined context. The checking for null pointers has been moved into the caller logic so it does not rely on undefined behavior. llvm-svn: 210498
Diffstat (limited to 'clang/lib/AST/DeclPrinter.cpp')
-rw-r--r--clang/lib/AST/DeclPrinter.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 558654d8875..e5e5130f695 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -536,6 +536,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
SimpleInit->printPretty(Out, nullptr, Policy, Indentation);
else {
for (unsigned I = 0; I != NumArgs; ++I) {
+ assert(Args[I] != nullptr && "Expected non-null Expr");
if (isa<CXXDefaultArgExpr>(Args[I]))
break;
@@ -586,7 +587,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
} else
Out << ' ';
- D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation);
+ if (D->getBody())
+ D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation);
Out << '\n';
}
}
OpenPOWER on IntegriCloud