compilerplugins/clang/stringadd.cxx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
New commits: commit 754e2d9be1dd5ab1f8b231063c69abf916c49c56 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Oct 23 17:53:43 2019 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Oct 23 22:09:38 2019 +0200 Don't use broken StringAdd::getSourceAsString it caused clang-cl to crash when processing desktop/source/app/opencl.cxx Change-Id: I0a39697e75242cd00f12b60477d51a1e5bf96a4f Reviewed-on: https://gerrit.libreoffice.org/81409 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/stringadd.cxx b/compilerplugins/clang/stringadd.cxx index 1a9c7c90d152..67d3adc6c131 100644 --- a/compilerplugins/clang/stringadd.cxx +++ b/compilerplugins/clang/stringadd.cxx @@ -78,7 +78,6 @@ private: void checkForCompoundAssign(Stmt const* stmt1, Stmt const* stmt2, VarDecl const* varDecl); Expr const* ignore(Expr const*); - std::string getSourceAsString(SourceLocation startLoc, SourceLocation endLoc); bool isSideEffectFree(Expr const*); }; @@ -171,9 +170,8 @@ void StringAdd::checkForCompoundAssign(Stmt const* stmt1, Stmt const* stmt2, Var if (!isSideEffectFree(rhs)) return; // if we cross a #ifdef boundary - auto s - = getSourceAsString(stmt1->getSourceRange().getBegin(), stmt2->getSourceRange().getEnd()); - if (s.find("#if") != std::string::npos) + if (containsPreprocessingConditionalInclusion( + SourceRange(stmt1->getSourceRange().getBegin(), stmt2->getSourceRange().getEnd()))) return; report(DiagnosticsEngine::Warning, "simplify by merging with the preceding assignment", compat::getBeginLoc(stmt2)) @@ -314,18 +312,6 @@ bool StringAdd::isSideEffectFree(Expr const* expr) return false; } -std::string StringAdd::getSourceAsString(SourceLocation startLoc, SourceLocation endLoc) -{ - SourceManager& SM = compiler.getSourceManager(); - char const* p1 = SM.getCharacterData(startLoc); - char const* p2 = SM.getCharacterData(endLoc); - p2 += Lexer::MeasureTokenLength(endLoc, SM, compiler.getLangOpts()); - // sometimes we get weird results, probably from crossing internal LLVM buffer boundaries - if (p2 - p1 < 0) - return std::string(); - return std::string(p1, p2 - p1); -} - loplugin::Plugin::Registration<StringAdd> stringadd("stringadd"); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits