================
@@ -207,6 +207,13 @@ void ConstCorrectnessCheck::check(const 
MatchFinder::MatchResult &Result) {
 
   assert(Variable && LocalScope && Function);
 
+  // If a variable (e.g. function parameter) is unnamed, don't report it. Being
+  // unnamed already guarantees that the variable can't be accessed, so
+  // 'const'ness (can't be modified) doesn't add extra information. Also, the
+  // messages would be awkward in this case.
+  if (Variable->getDeclName().isIdentifier() && Variable->getName().empty())
----------------
NagyDonat wrote:

I really liked this idea and tried to implement it, but unfortunately `hasName` 
asserts that its argument is nonempty. As its implementation is not trivial 
(has slow and fast variants, handles qualified names etc.) I think it is better 
to keep this logic instead of trying to remove that assertion.

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

Reply via email to