diff options
author | Richard Trieu <rtrieu@google.com> | 2014-06-09 22:53:25 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2014-06-09 22:53:25 +0000 |
commit | ddd01cec0e4ecec0ca2f6e02c38281ee562fcd8d (patch) | |
tree | 37c95111a4e9ec687e3be04eb7f4e149d693c0e2 /clang/lib/Rewrite/Core | |
parent | a23043cb9c1ef021a9cf05cd62cce76cd03c0ba2 (diff) | |
download | bcm5719-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/Rewrite/Core')
-rw-r--r-- | clang/lib/Rewrite/Core/Rewriter.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Rewrite/Core/Rewriter.cpp b/clang/lib/Rewrite/Core/Rewriter.cpp index 8b17b654d6c..eb123ad7024 100644 --- a/clang/lib/Rewrite/Core/Rewriter.cpp +++ b/clang/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)); |