summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/APValue.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/APValue.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/APValue.cpp')
-rw-r--r--clang/lib/AST/APValue.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index e7b5a6be34b..0fa0216d9da 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -403,9 +403,13 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{
if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>())
Out << *VD;
- else
+ else {
+ assert(Base.get<const Expr *>() != nullptr &&
+ "Expecting non-null Expr");
Base.get<const Expr*>()->printPretty(Out, nullptr,
Ctx.getPrintingPolicy());
+ }
+
if (!O.isZero()) {
Out << " + " << (O / S);
if (IsReference)
@@ -426,6 +430,7 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{
ElemTy = VD->getType();
} else {
const Expr *E = Base.get<const Expr*>();
+ assert(E != nullptr && "Expecting non-null Expr");
E->printPretty(Out, nullptr, Ctx.getPrintingPolicy());
ElemTy = E->getType();
}
OpenPOWER on IntegriCloud