================
@@ -135,20 +147,83 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder 
*Finder) {
           .bind("function-decl");
 
   Finder->addMatcher(FunctionScope, this);
+
+  if (AnalyzeParameters) {
+    const auto ParamMatcher =
+        parmVarDecl(unless(CommonExcludeTypes),
+                    anyOf(hasType(referenceType()), hasType(pointerType())))
+            .bind("param-var");
+
+    // Match function parameters which could be 'const' if not modified later.
+    // Example: `void foo(int* ptr)` would match `int* ptr`.
+    const auto FunctionWithParams =
+        functionDecl(
+            hasBody(stmt().bind("scope-params")),
+            has(typeLoc(forEach(ParamMatcher))), unless(cxxMethodDecl()),
----------------
vbvictor wrote:

Currently, ExprMutationAnalyzer can't handle init-list in ctors like `B::B(int 
x) : A(x)`, and I also don't want to deal with virtual/override for now because 
it brings complexity to an already big patch.
I'll look into Methods later.

https://github.com/llvm/llvm-project/pull/171215
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to