[clang-tools-extra] [clangd] Add inlay hints for default function arguments (PR #95712)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 8 23:56:39 PDT 2024


================
@@ -1465,6 +1469,34 @@ TEST(TypeHints, DefaultTemplateArgs) {
                   ExpectedHint{": A<float>", "binding"});
 }
 
+TEST(DefaultArguments, Smoke) {
+  Config Cfg;
+  Cfg.InlayHints.Parameters =
+      true; // To test interplay of parameters and default parameters
+  Cfg.InlayHints.DeducedTypes = false;
+  Cfg.InlayHints.Designators = false;
+  Cfg.InlayHints.BlockEnd = false;
+
+  Cfg.InlayHints.DefaultArguments = true;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+
+  const auto *Code = R"cpp(
+    int foo(int A = 4) { return A; }
+    int bar(int A, int B = 1, bool C = foo($default1[[)]]) { return A; }
+    int A = bar($explicit[[2]]$default2[[)]];
+
+    void baz(int = 5) { if (false) baz($unnamed[[)]]; };
+  )cpp";
+
+  assertHints(InlayHintKind::DefaultArgument, Code,
----------------
HighCommander4 wrote:

It would be nice to have one check where the token the hint is attached to is an R-brace rather than an R-paren

https://github.com/llvm/llvm-project/pull/95712


More information about the cfe-commits mailing list