summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-07 19:59:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-08 11:01:14 +0200
commit32343bcbb786168df62f85a57e30c620c3d3bdb4 (patch)
treea38537c56f5e708a88c9371dcd5c6dd14055eab6 /compilerplugins
parentf2053a6accc2e68aa2920d4d3f46f82909415666 (diff)
loplugin:flatten in i18npool
and workaround a clang crash Change-Id: Ida94c8abb4b2e997d38a7f430e59f73aadf8fcc8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91844 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/flatten.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx
index 68baa742dcca..a084fabb9204 100644
--- a/compilerplugins/clang/flatten.cxx
+++ b/compilerplugins/clang/flatten.cxx
@@ -650,6 +650,11 @@ std::string Flatten::getSourceAsString(SourceRange range)
char const *p1 = SM.getCharacterData( startLoc );
char const *p2 = SM.getCharacterData( endLoc );
p2 += Lexer::MeasureTokenLength( endLoc, SM, compiler.getLangOpts());
+ if (p2 < p1) {
+ // workaround clang weirdness, but don't return empty string
+ // in case it happens during code replacement
+ return "clang returned bad pointers";
+ }
return std::string( p1, p2 - p1);
}