summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/stringviewparam.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/stringviewparam.cxx')
-rw-r--r--compilerplugins/clang/stringviewparam.cxx42
1 files changed, 41 insertions, 1 deletions
diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx
index 76c34cd2adb9..040f8f63b502 100644
--- a/compilerplugins/clang/stringviewparam.cxx
+++ b/compilerplugins/clang/stringviewparam.cxx
@@ -222,7 +222,6 @@ public:
return ret;
}
- // TODO Need to duplicate this method for CXXConstructorDecl
bool TraverseCXXMethodDecl(CXXMethodDecl* decl)
{
if (ignoreLocation(decl))
@@ -264,6 +263,47 @@ public:
return ret;
}
+ bool TraverseCXXConstructorDecl(CXXConstructorDecl* decl)
+ {
+ if (ignoreLocation(decl))
+ {
+ return true;
+ }
+ if (!relevantFunctionDecl(decl))
+ {
+ return FunctionAddress::TraverseCXXConstructorDecl(decl);
+ }
+ auto const oldParams = currentParams_;
+ auto const n = decl->getNumParams();
+ for (unsigned i = 0; i != n; ++i)
+ {
+ auto const d = decl->getParamDecl(i);
+ if (relevantParmVarDecl(d))
+ {
+ currentParams_.insert(d);
+ }
+ }
+ auto const ret = FunctionAddress::TraverseCXXConstructorDecl(decl);
+ if (ret)
+ {
+ for (unsigned i = 0; i != n; ++i)
+ {
+ auto const d1 = decl->getParamDecl(i);
+ if (currentParams_.find(d1) == currentParams_.end())
+ {
+ continue;
+ }
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange()))
+ {
+ break;
+ }
+ badParams_.push_back(d1);
+ }
+ }
+ currentParams_ = oldParams;
+ return ret;
+ }
+
bool TraverseImplicitCastExpr(ImplicitCastExpr* expr)
{
if (ignoreLocation(expr))