summaryrefslogtreecommitdiffstats
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-23 15:35:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-24 08:39:48 +0100
commit7a2c36bb69970f20b4896472e2d5a4e41df95b39 (patch)
treeef07b6383952d5882024531a566078e457617721 /compilerplugins
parentsd theme: add PPTX export for shape fill color (diff)
downloadcore-7a2c36bb69970f20b4896472e2d5a4e41df95b39.tar.gz
core-7a2c36bb69970f20b4896472e2d5a4e41df95b39.zip
loplugin:constantparam improvements
(1) sanitize call value output, make downstream processing easier (2) remove bad ignoreLocation() call, which was eliminating a lot of valueable data and thus generating false positives Change-Id: I39230c260c5cf717559300913fbc68bc3485b957 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131986 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/constantparam.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/compilerplugins/clang/constantparam.cxx b/compilerplugins/clang/constantparam.cxx
index f9f87b361bc5..5fd472954a9a 100644
--- a/compilerplugins/clang/constantparam.cxx
+++ b/compilerplugins/clang/constantparam.cxx
@@ -111,8 +111,6 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
return;
if (functionDecl->isVariadic())
return;
- if (ignoreLocation(functionDecl))
- return;
// ignore stuff that forms part of the stable URE interface
if (isInUnoIncludeFile(functionDecl))
return;
@@ -122,7 +120,6 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
return;
filename = filename.substr(strlen(SRCDIR)+1);
-
MyCallSiteInfo aInfo;
aInfo.returnType = functionDecl->getReturnType().getCanonicalType().getAsString();
@@ -148,8 +145,8 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
aInfo.paramIndex = paramIndex;
if (paramIndex < (int)functionDecl->getNumParams())
aInfo.paramType = functionDecl->getParamDecl(paramIndex)->getType().getCanonicalType().getAsString();
- aInfo.callValue = callValue;
+ aInfo.callValue = callValue;
aInfo.sourceLocation = filename.str() + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc));
loplugin::normalizeDotDotInFilePath(aInfo.sourceLocation);
@@ -207,10 +204,10 @@ std::string ConstantParam::getCallValue(const Expr* arg)
}
unsigned n = Lexer::MeasureTokenLength( endLoc, SM, compiler.getLangOpts());
std::string s( p1, p2 - p1 + n);
- // strip linefeed and tab characters so they don't interfere with the parsing of the log file
- std::replace( s.begin(), s.end(), '\r', ' ');
- std::replace( s.begin(), s.end(), '\n', ' ');
- std::replace( s.begin(), s.end(), '\t', ' ');
+ // sanitize call value, makes using command line tools (and python) much less error prone
+ for (auto const & ch : s)
+ if (ch < 32)
+ return "sanitised";
// now normalize the value. For some params, like OUString, we can pass it as OUString() or "" and they are the same thing
if (s == "OUString()")