================
@@ -105,12 +117,26 @@ void NamedParameterCheck::check(const
MatchFinder::MatchResult &Result) {
NewName = Name;
}
- // Now insert the comment. Note that getLocation() points to the place
+ // Now insert the fix. Note that getLocation() points to the place
// where the name would be, this allows us to also get complex cases like
// function pointers right.
const ParmVarDecl *Parm = P.first->getParamDecl(P.second);
- D << FixItHint::CreateInsertion(Parm->getLocation(),
- " /*" + NewName.str() + "*/");
+
+ // The fix depends on the InsertPlainNamesInForwardDecls option,
+ // whether this is a forward declaration and whether the parameter has
+ // a real name.
+ const bool IsForwardDeclaration = (!Definition || Function !=
Definition);
+ if (InsertPlainNamesInForwardDecls && IsForwardDeclaration &&
+ NewName != FallbackName) {
+ // For forward declarations with InsertPlainNamesInForwardDecls
enabled,
+ // insert the parameter name without comments
+ D << FixItHint::CreateInsertion(Parm->getLocation(),
+ " " + NewName.str());
+ } else {
+ // Default behavior: insert the parameter name as a comment
----------------
vbvictor wrote:
nit: Maybe this comment is not need, we get from context that it is default
behavoir
https://github.com/llvm/llvm-project/pull/147953
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits