summaryrefslogtreecommitdiffstats
path: root/lib/Rewrite
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
commit8a8409652339fa1ee1446b12b75a29e808cd8816 (patch)
tree02d381a96820cd2a803ad4baa3a79aad55ae2646 /lib/Rewrite
parent38d0c47ac00718bc55655b6e9cbc9029c0b458b3 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite')
-rw-r--r--lib/Rewrite/Core/Rewriter.cpp3
-rw-r--r--lib/Rewrite/Frontend/RewriteModernObjC.cpp2
-rw-r--r--lib/Rewrite/Frontend/RewriteObjC.cpp3
3 files changed, 8 insertions, 0 deletions
diff --git a/lib/Rewrite/Core/Rewriter.cpp b/lib/Rewrite/Core/Rewriter.cpp
index 8b17b654d6..eb123ad702 100644
--- a/lib/Rewrite/Core/Rewriter.cpp
+++ b/lib/Rewrite/Core/Rewriter.cpp
@@ -332,6 +332,8 @@ bool Rewriter::ReplaceText(SourceRange range, SourceRange replacementRange) {
/// printer to generate the replacement code. This returns true if the input
/// could not be rewritten, or false if successful.
bool Rewriter::ReplaceStmt(Stmt *From, Stmt *To) {
+ assert(From != nullptr && To != nullptr && "Expected non-null Stmt's");
+
// Measaure the old text.
int Size = getRangeSize(From->getSourceRange());
if (Size == -1)
@@ -348,6 +350,7 @@ bool Rewriter::ReplaceStmt(Stmt *From, Stmt *To) {
}
std::string Rewriter::ConvertToString(Stmt *From) {
+ assert(From != nullptr && "Expected non-null Stmt");
std::string SStr;
llvm::raw_string_ostream S(SStr);
From->printPretty(S, nullptr, PrintingPolicy(*LangOpts));
diff --git a/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/lib/Rewrite/Frontend/RewriteModernObjC.cpp
index 3cacbdddf3..43de31c516 100644
--- a/lib/Rewrite/Frontend/RewriteModernObjC.cpp
+++ b/lib/Rewrite/Frontend/RewriteModernObjC.cpp
@@ -267,6 +267,7 @@ namespace {
}
void ReplaceStmtWithRange(Stmt *Old, Stmt *New, SourceRange SrcRange) {
+ assert(Old != nullptr && New != nullptr && "Expected non-null Stmt's");
if (DisableReplaceStmt)
return;
@@ -2587,6 +2588,7 @@ void RewriteModernObjC::SynthGetMetaClassFunctionDecl() {
}
Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
+ assert (Exp != nullptr && "Expected non-null ObjCStringLiteral");
QualType strType = getConstantStringStructType();
std::string S = "__NSConstantStringImpl_";
diff --git a/lib/Rewrite/Frontend/RewriteObjC.cpp b/lib/Rewrite/Frontend/RewriteObjC.cpp
index beadb931a9..dfeb11a9aa 100644
--- a/lib/Rewrite/Frontend/RewriteObjC.cpp
+++ b/lib/Rewrite/Frontend/RewriteObjC.cpp
@@ -216,6 +216,7 @@ namespace {
}
void ReplaceStmtWithRange(Stmt *Old, Stmt *New, SourceRange SrcRange) {
+ assert(Old != nullptr && New != nullptr && "Expected non-null Stmt's");
if (DisableReplaceStmt)
return;
@@ -1697,6 +1698,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
CK, syncExpr);
std::string syncExprBufS;
llvm::raw_string_ostream syncExprBuf(syncExprBufS);
+ assert(syncExpr != nullptr && "Expected non-null Expr");
syncExpr->printPretty(syncExprBuf, nullptr, PrintingPolicy(LangOpts));
syncBuf += syncExprBuf.str();
syncBuf += ");";
@@ -2485,6 +2487,7 @@ void RewriteObjC::SynthGetMetaClassFunctionDecl() {
}
Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
+ assert(Exp != nullptr && "Expected non-null ObjCStringLiteral");
QualType strType = getConstantStringStructType();
std::string S = "__NSConstantStringImpl_";