[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 7 09:49:57 PDT 2026


https://github.com/StarOne01 updated https://github.com/llvm/llvm-project/pull/123495

>From 11889be9b1e203c192559d2a94c49a9874eb1351 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Sun, 19 Jan 2025 07:28:24 +0530
Subject: [PATCH 01/14] [clang][Sema] Add diagnostic note for function-like
 macros requiring parentheses

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/SemaExpr.cpp                      | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9bd0a526654c7..faa3fef1a1c74 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6345,6 +6345,8 @@ def err_fold_expression_limit_exceeded: Error<
   "instantiating fold expression with %0 arguments exceeded expression nesting "
   "limit of %1">, DefaultFatal, NoSFINAE;
 
+def note_function_like_macro_requires_parens : Note<
+  "'%0' exists, but as a function-like macro; perhaps, did you forget the parentheses?">;
 def err_unexpected_typedef : Error<
   "unexpected type name %0: expected expression">;
 def err_unexpected_namespace : Error<
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c93efeb928c56..dc23c9ebb4711 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2690,6 +2690,19 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
     DC = DC->getLookupParent();
   }
 
+  // Check whether a similar function-like macro exists and suggest it
+  if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
+    if (II->hasMacroDefinition()) {
+      MacroInfo *MI = PP.getMacroInfo(II);
+      if (MI && MI->isFunctionLike()) {
+        Diag( R.getNameLoc() ,diag::err_undeclared_var_use) << II->getName();
+        Diag(MI->getDefinitionLoc(), diag::note_function_like_macro_requires_parens)
+            << II->getName();
+        return true;
+      }
+    }
+  }
+
   // We didn't find anything, so try to correct for a typo.
   TypoCorrection Corrected;
   if (S && (Corrected =
@@ -2791,7 +2804,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
         << Name << computeDeclContext(SS, false) << NameRange;
     return true;
   }
-
+  
   // Give up, we can't recover.
   Diag(R.getNameLoc(), diagnostic) << Name << NameRange;
   return true;

>From 83b06d43ab80470f8dbc9324b65a7781929b3d46 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Sun, 19 Jan 2025 08:30:39 +0530
Subject: [PATCH 02/14] [clang][Tests] Modify tests for function-like macros
 according to the new behavior and Format the changes

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td        | 5 +++--
 clang/lib/Sema/SemaExpr.cpp                             | 7 ++++---
 clang/test/Preprocessor/macro_with_initializer_list.cpp | 6 ++++--
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index faa3fef1a1c74..baabacbdd3c9c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6345,8 +6345,9 @@ def err_fold_expression_limit_exceeded: Error<
   "instantiating fold expression with %0 arguments exceeded expression nesting "
   "limit of %1">, DefaultFatal, NoSFINAE;
 
-def note_function_like_macro_requires_parens : Note<
-  "'%0' exists, but as a function-like macro; perhaps, did you forget the parentheses?">;
+def note_function_like_macro_requires_parens
+    : Note<"'%0' exists, but as a function-like macro; perhaps, did you forget "
+           "the parentheses?">;
 def err_unexpected_typedef : Error<
   "unexpected type name %0: expected expression">;
 def err_unexpected_namespace : Error<
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index dc23c9ebb4711..184257b3bb6a1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2695,8 +2695,9 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
     if (II->hasMacroDefinition()) {
       MacroInfo *MI = PP.getMacroInfo(II);
       if (MI && MI->isFunctionLike()) {
-        Diag( R.getNameLoc() ,diag::err_undeclared_var_use) << II->getName();
-        Diag(MI->getDefinitionLoc(), diag::note_function_like_macro_requires_parens)
+        Diag(R.getNameLoc(), diag::err_undeclared_var_use) << II->getName();
+        Diag(MI->getDefinitionLoc(),
+             diag::note_function_like_macro_requires_parens)
             << II->getName();
         return true;
       }
@@ -2804,7 +2805,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
         << Name << computeDeclContext(SS, false) << NameRange;
     return true;
   }
-  
+
   // Give up, we can't recover.
   Diag(R.getNameLoc(), diagnostic) << Name << NameRange;
   return true;
diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp
index 40f53164b263d..cc7dae0b5a3e0 100644
--- a/clang/test/Preprocessor/macro_with_initializer_list.cpp
+++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp
@@ -134,6 +134,7 @@ void test_NE() {
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
 
 #define INIT(var, init) Foo var = init; // expected-note 3{{defined here}}
+// expected-note at -1 2{{'INIT' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
 // Can't use an initializer list as a macro argument.  The commas in the list
 // will be interpretted as argument separaters and adding parenthesis will
 // make it no longer an initializer list.
@@ -159,12 +160,13 @@ void test() {
   // expected-note at -3 {{cannot use initializer list at the beginning of a macro argument}}
 }
 
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:11-145:11}:"("
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:23-145:23}:")"
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:11-146:11}:"("
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:23-146:23}:")"
 
 #define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
   Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
 // expected-note at -2 2{{defined here}}
+// expected-note at -3 {{'M' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
 void test2() {
   M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
         Foo(), Foo(), Foo(), Foo(), Foo(), Foo());

>From 1deb668c83ef7cca313092ffa082fd5b4c133faf Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Mon, 20 Jan 2025 13:34:48 +0530
Subject: [PATCH 03/14] Change the note for reference of function-like macros
 requiring without parentheses

Co-authored-by: Sirraide <aeternalmail at gmail.com>
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index baabacbdd3c9c..453e186c62e15 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6346,8 +6346,7 @@ def err_fold_expression_limit_exceeded: Error<
   "limit of %1">, DefaultFatal, NoSFINAE;
 
 def note_function_like_macro_requires_parens
-    : Note<"'%0' exists, but as a function-like macro; perhaps, did you forget "
-           "the parentheses?">;
+    : Note<"'%0' is defined here as a function-like macro; did you mean to write '%0(...)'">;
 def err_unexpected_typedef : Error<
   "unexpected type name %0: expected expression">;
 def err_unexpected_namespace : Error<

>From 1bd69fb8ffe5f8951f8cb9446e455397ea72ca2d Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Tue, 21 Jan 2025 16:20:10 +0530
Subject: [PATCH 04/14] [clang][Tests] Update diagnostic tests for
 function-like macros to clarify usage and improve error messages

---
 .../Preprocessor/macro_with_initializer_list.cpp   | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp
index cc7dae0b5a3e0..f7f645cce1180 100644
--- a/clang/test/Preprocessor/macro_with_initializer_list.cpp
+++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp
@@ -133,8 +133,8 @@ void test_NE() {
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:9-110:9}:"("
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
 
-#define INIT(var, init) Foo var = init; // expected-note 3{{defined here}}
-// expected-note at -1 2{{'INIT' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
+#define INIT(var, init) Foo var = init; // expected-note 3{{macro 'INIT' defined here}}
+// expected-note at -1 2{{'INIT' is defined here as a function-like macro; did you mean to write 'INIT(...)'}}
 // Can't use an initializer list as a macro argument.  The commas in the list
 // will be interpretted as argument separaters and adding parenthesis will
 // make it no longer an initializer list.
@@ -166,7 +166,7 @@ void test() {
 #define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
   Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
 // expected-note at -2 2{{defined here}}
-// expected-note at -3 {{'M' exists, but as a function-like macro; perhaps, did you forget the parentheses?}}
+// expected-note at -3 {{'M' is defined here as a function-like macro; did you mean to write 'M(...)'}}
 void test2() {
   M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
         Foo(), Foo(), Foo(), Foo(), Foo(), Foo());
@@ -182,3 +182,11 @@ void test2() {
   // expected-error at -3 {{use of undeclared identifier}}
   // expected-note at -4 {{cannot use initializer list at the beginning of a macro argument}}
 }
+
+#define LIM() 10 
+// expected-note at -1 {{'LIM' is defined here as a function-like macro; did you mean to write 'LIM(...)'}}
+
+void test3() {
+  int iter = LIM;
+  // expected-error at -1 {{use of undeclared identifier LIM}}
+}
\ No newline at end of file

>From 8e5ea45f63f010758a381d1a6ca3afeaed78a3cd Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Tue, 21 Jan 2025 16:22:39 +0530
Subject: [PATCH 05/14] Change the note for reference of function-like macros
 requiring without parentheses

Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva at intel.com>
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 453e186c62e15..54e161d9645ac 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6346,7 +6346,7 @@ def err_fold_expression_limit_exceeded: Error<
   "limit of %1">, DefaultFatal, NoSFINAE;
 
 def note_function_like_macro_requires_parens
-    : Note<"'%0' is defined here as a function-like macro; did you mean to write '%0(...)'">;
+    : Note<"'%0' is defined here as a function-like macro; did you mean '%0(...)'">;
 def err_unexpected_typedef : Error<
   "unexpected type name %0: expected expression">;
 def err_unexpected_namespace : Error<

>From 5f0569178eb0f58ef2c30c23c6ae6f80327475d9 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Tue, 21 Jan 2025 17:03:21 +0530
Subject: [PATCH 06/14] [clang][Tests] Update diagnostic tests for
 function-like macros for the updated note

---
 clang/test/Preprocessor/macro_with_initializer_list.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp
index f7f645cce1180..cf1d137eadcbe 100644
--- a/clang/test/Preprocessor/macro_with_initializer_list.cpp
+++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp
@@ -134,7 +134,7 @@ void test_NE() {
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
 
 #define INIT(var, init) Foo var = init; // expected-note 3{{macro 'INIT' defined here}}
-// expected-note at -1 2{{'INIT' is defined here as a function-like macro; did you mean to write 'INIT(...)'}}
+// expected-note at -1 2{{'INIT' is defined here as a function-like macro; did you mean 'INIT(...)'}}
 // Can't use an initializer list as a macro argument.  The commas in the list
 // will be interpretted as argument separaters and adding parenthesis will
 // make it no longer an initializer list.
@@ -166,7 +166,7 @@ void test() {
 #define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
   Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
 // expected-note at -2 2{{defined here}}
-// expected-note at -3 {{'M' is defined here as a function-like macro; did you mean to write 'M(...)'}}
+// expected-note at -3 {{'M' is defined here as a function-like macro; did you mean 'M(...)'}}
 void test2() {
   M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
         Foo(), Foo(), Foo(), Foo(), Foo(), Foo());
@@ -184,7 +184,7 @@ void test2() {
 }
 
 #define LIM() 10 
-// expected-note at -1 {{'LIM' is defined here as a function-like macro; did you mean to write 'LIM(...)'}}
+// expected-note at -1 {{'LIM' is defined here as a function-like macro; did you mean 'LIM(...)'}}
 
 void test3() {
   int iter = LIM;

>From 1bd294622e1808049cf3a451db524f8d3c87c041 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Sun, 9 Feb 2025 14:20:36 +0530
Subject: [PATCH 07/14] [clang][Sema] Improve diagnostics for undeclared
 function-like macros

---
 .../clang/Basic/DiagnosticSemaKinds.td        |  4 +-
 clang/lib/Sema/SemaExpr.cpp                   | 74 +++++++++++++++----
 .../macro_with_initializer_list.cpp           | 14 +---
 clang/test/Sema/typo-correction.c             | 22 ++++++
 4 files changed, 87 insertions(+), 27 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 54e161d9645ac..739aad0b516a8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6346,7 +6346,7 @@ def err_fold_expression_limit_exceeded: Error<
   "limit of %1">, DefaultFatal, NoSFINAE;
 
 def note_function_like_macro_requires_parens
-    : Note<"'%0' is defined here as a function-like macro; did you mean '%0(...)'">;
+    : Note<"'%0' defined here as a function-like macro">;
 def err_unexpected_typedef : Error<
   "unexpected type name %0: expected expression">;
 def err_unexpected_namespace : Error<
@@ -11691,6 +11691,8 @@ def err_undeclared_use_suggest : Error<
   "use of undeclared %0; did you mean %1?">;
 def err_undeclared_var_use_suggest : Error<
   "use of undeclared identifier %0; did you mean %1?">;
+def err_undeclared_var_use_suggest_func_like_macro
+    : Error<"use of undeclared identifier %0; did you mean %0(...)?">;
 def err_no_template : Error<"no template named %0">;
 def err_no_template_suggest : Error<"no template named %0; did you mean %1?">;
 def err_no_member_template : Error<"no template named %0 in %1">;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 184257b3bb6a1..173094f730723 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2548,6 +2548,27 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
   return E;
 }
 
+// Check whether a similar function-like macro exists and suggest it
+static bool isFunctionLikeMacro(const DeclarationName &Name, Sema &SemaRef,
+                                const SourceLocation &TypoLoc) {
+
+  if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
+    if (II->hasMacroDefinition()) {
+      MacroInfo *MI = SemaRef.PP.getMacroInfo(II);
+      if (MI && MI->isFunctionLike()) {
+        SemaRef.Diag(TypoLoc,
+                     diag::err_undeclared_var_use_suggest_func_like_macro)
+            << II->getName();
+        SemaRef.Diag(MI->getDefinitionLoc(),
+                     diag::note_function_like_macro_requires_parens)
+            << II->getName();
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
 void
 Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
                              TemplateArgumentListInfo &Buffer,
@@ -2571,6 +2592,42 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
   }
 }
 
+static void emitEmptyLookupTypoDiagnostic(
+    const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS,
+    DeclarationName Typo, SourceLocation TypoLoc, ArrayRef<Expr *> Args,
+    unsigned DiagnosticID, unsigned DiagnosticSuggestID) {
+  DeclContext *Ctx =
+      SS.isEmpty() ? nullptr : SemaRef.computeDeclContext(SS, false);
+  if (!TC) {
+    // Emit a special diagnostic for failed member lookups.
+    // FIXME: computing the declaration context might fail here (?)
+    if (Ctx)
+      SemaRef.Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
+                                                 << SS.getRange();
+    else {
+      if (isFunctionLikeMacro(Typo, SemaRef, TypoLoc))
+        return;
+      SemaRef.Diag(TypoLoc, DiagnosticID) << Typo;
+    }
+    return;
+  }
+
+  std::string CorrectedStr = TC.getAsString(SemaRef.getLangOpts());
+  bool DroppedSpecifier =
+      TC.WillReplaceSpecifier() && Typo.getAsString() == CorrectedStr;
+  unsigned NoteID = TC.getCorrectionDeclAs<ImplicitParamDecl>()
+                        ? diag::note_implicit_param_decl
+                        : diag::note_previous_decl;
+  if (!Ctx)
+    SemaRef.diagnoseTypo(TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo,
+                         SemaRef.PDiag(NoteID));
+  else
+    SemaRef.diagnoseTypo(TC, SemaRef.PDiag(diag::err_no_member_suggest)
+                                 << Typo << Ctx << DroppedSpecifier
+                                 << SS.getRange(),
+                         SemaRef.PDiag(NoteID));
+}
+
 bool Sema::DiagnoseDependentMemberLookup(const LookupResult &R) {
   // During a default argument instantiation the CurContext points
   // to a CXXMethodDecl; but we can't apply a this-> fixit inside a
@@ -2690,20 +2747,6 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
     DC = DC->getLookupParent();
   }
 
-  // Check whether a similar function-like macro exists and suggest it
-  if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
-    if (II->hasMacroDefinition()) {
-      MacroInfo *MI = PP.getMacroInfo(II);
-      if (MI && MI->isFunctionLike()) {
-        Diag(R.getNameLoc(), diag::err_undeclared_var_use) << II->getName();
-        Diag(MI->getDefinitionLoc(),
-             diag::note_function_like_macro_requires_parens)
-            << II->getName();
-        return true;
-      }
-    }
-  }
-
   // We didn't find anything, so try to correct for a typo.
   TypoCorrection Corrected;
   if (S && (Corrected =
@@ -2798,6 +2841,9 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
   }
   R.clear();
 
+  if (isFunctionLikeMacro(Name, SemaRef, R.getNameLoc()))
+    return true;
+
   // Emit a special diagnostic for failed member lookups.
   // FIXME: computing the declaration context might fail here (?)
   if (!SS.isEmpty()) {
diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp
index cf1d137eadcbe..5f66971622ce7 100644
--- a/clang/test/Preprocessor/macro_with_initializer_list.cpp
+++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp
@@ -134,7 +134,6 @@ void test_NE() {
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
 
 #define INIT(var, init) Foo var = init; // expected-note 3{{macro 'INIT' defined here}}
-// expected-note at -1 2{{'INIT' is defined here as a function-like macro; did you mean 'INIT(...)'}}
 // Can't use an initializer list as a macro argument.  The commas in the list
 // will be interpretted as argument separaters and adding parenthesis will
 // make it no longer an initializer list.
@@ -160,13 +159,12 @@ void test() {
   // expected-note at -3 {{cannot use initializer list at the beginning of a macro argument}}
 }
 
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:11-146:11}:"("
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:23-146:23}:")"
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:11-145:11}:"("
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:23-145:23}:")"
 
 #define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
   Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
 // expected-note at -2 2{{defined here}}
-// expected-note at -3 {{'M' is defined here as a function-like macro; did you mean 'M(...)'}}
 void test2() {
   M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
         Foo(), Foo(), Foo(), Foo(), Foo(), Foo());
@@ -181,12 +179,4 @@ void test2() {
   // expected-error at -2 {{too many arguments provided}}
   // expected-error at -3 {{use of undeclared identifier}}
   // expected-note at -4 {{cannot use initializer list at the beginning of a macro argument}}
-}
-
-#define LIM() 10 
-// expected-note at -1 {{'LIM' is defined here as a function-like macro; did you mean 'LIM(...)'}}
-
-void test3() {
-  int iter = LIM;
-  // expected-error at -1 {{use of undeclared identifier LIM}}
 }
\ No newline at end of file
diff --git a/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c
index 510a67e725f9c..5ffbc512ef73b 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -118,3 +118,25 @@ void PR40286_3(int the_value) { // expected-note {{'the_value' declared here}}
 void PR40286_4(int the_value) { // expected-note {{'the_value' declared here}}
   PR40286_h(the_value, the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'?}}
 }
+
+#define FOO1() 10
+// expected-note at -1 4 {{'FOO1' defined here as a function-like macro}}
+
+int x = FOO1; // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+
+void test3() {
+  int iter = FOO1;
+  // expected-error at -1 {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+}
+
+void bar(int);
+
+void test4() {
+    int FOO; // expected-note {{'FOO' declared here}}
+    int x = FOO1; // expected-error {{use of undeclared identifier 'FOO1'; did you mean 'FOO'?}}
+}
+
+void test5() {
+    FOO1 + 1; // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+    bar(FOO1); // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+}

>From 5bdd6dca50130cf8e0222fd031930cb895f5f448 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Sun, 9 Feb 2025 14:50:49 +0530
Subject: [PATCH 08/14] [clang][Tests] Enhance diagnostic notes for
 function-like macros in initializer list tests

---
 clang/test/Preprocessor/macro_with_initializer_list.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp
index 5f66971622ce7..dab60e60b14a1 100644
--- a/clang/test/Preprocessor/macro_with_initializer_list.cpp
+++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp
@@ -134,6 +134,7 @@ void test_NE() {
 // CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{110:32-110:32}:")"
 
 #define INIT(var, init) Foo var = init; // expected-note 3{{macro 'INIT' defined here}}
+// expected-note at -1 2{{'INIT' defined here as a function-like macro}}
 // Can't use an initializer list as a macro argument.  The commas in the list
 // will be interpretted as argument separaters and adding parenthesis will
 // make it no longer an initializer list.
@@ -159,12 +160,13 @@ void test() {
   // expected-note at -3 {{cannot use initializer list at the beginning of a macro argument}}
 }
 
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:11-145:11}:"("
-// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{145:23-145:23}:")"
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:11-146:11}:"("
+// CHECK: fix-it:"{{.*}}macro_with_initializer_list.cpp":{146:23-146:23}:")"
 
 #define M(name,a,b,c,d,e,f,g,h,i,j,k,l) \
   Foo name = a + b + c + d + e + f + g + h + i + j + k + l;
 // expected-note at -2 2{{defined here}}
+// expected-note at -3 {{'M' defined here as a function-like macro}}
 void test2() {
   M(F1, Foo(), Foo(), Foo(), Foo(), Foo(), Foo(),
         Foo(), Foo(), Foo(), Foo(), Foo(), Foo());
@@ -179,4 +181,4 @@ void test2() {
   // expected-error at -2 {{too many arguments provided}}
   // expected-error at -3 {{use of undeclared identifier}}
   // expected-note at -4 {{cannot use initializer list at the beginning of a macro argument}}
-}
\ No newline at end of file
+}

>From 65118140ad5b06caec01ff8b578f4d30885f298f Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Sun, 9 Feb 2025 20:28:12 +0530
Subject: [PATCH 09/14] [clang][Docs] Add release note for diagnosing missing
 parentheses in function-like macros

---
 clang/docs/ReleaseNotes.rst | 304 ++++++++++++++++++++++++++++++++++++
 1 file changed, 304 insertions(+)
 create mode 100644 clang/docs/ReleaseNotes.rst

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
new file mode 100644
index 0000000000000..a469e5a97a4ac
--- /dev/null
+++ b/clang/docs/ReleaseNotes.rst
@@ -0,0 +1,304 @@
+===========================================
+Clang |release| |ReleaseNotesTitle|
+===========================================
+
+.. contents::
+   :local:
+   :depth: 2
+
+Written by the `LLVM Team <https://llvm.org/>`_
+
+.. only:: PreRelease
+
+  .. warning::
+     These are in-progress notes for the upcoming Clang |version| release.
+     Release notes for previous releases can be found on
+     `the Releases Page <https://llvm.org/releases/>`_.
+
+Introduction
+============
+
+This document contains the release notes for the Clang C/C++/Objective-C
+frontend, part of the LLVM Compiler Infrastructure, release |release|. Here we
+describe the status of Clang in some detail, including major
+improvements from the previous release and new feature work. For the
+general LLVM release notes, see `the LLVM
+documentation <https://llvm.org/docs/ReleaseNotes.html>`_. For the libc++ release notes,
+see `this page <https://libcxx.llvm.org/ReleaseNotes.html>`_. All LLVM releases
+may be downloaded from the `LLVM releases web site <https://llvm.org/releases/>`_.
+
+For more information about Clang or LLVM, including information about the
+latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
+`LLVM Web Site <https://llvm.org>`_.
+
+Potentially Breaking Changes
+============================
+
+- The Objective-C ARC migrator (ARCMigrate) has been removed.
+
+C/C++ Language Potentially Breaking Changes
+-------------------------------------------
+
+C++ Specific Potentially Breaking Changes
+-----------------------------------------
+
+- The type trait builtin ``__is_referenceable`` has been removed, since it has
+  very few users and all the type traits that could benefit from it in the
+  standard library already have their own bespoke builtins.
+
+ABI Changes in This Version
+---------------------------
+
+- Return larger CXX records in memory instead of using AVX registers. Code compiled with older clang will be incompatible with newer version of the clang unless -fclang-abi-compat=20 is provided. (#GH120670)
+
+AST Dumping Potentially Breaking Changes
+----------------------------------------
+
+Clang Frontend Potentially Breaking Changes
+-------------------------------------------
+
+Clang Python Bindings Potentially Breaking Changes
+--------------------------------------------------
+
+What's New in Clang |release|?
+==============================
+
+C++ Language Changes
+--------------------
+
+C++2c Feature Support
+^^^^^^^^^^^^^^^^^^^^^
+
+C++23 Feature Support
+^^^^^^^^^^^^^^^^^^^^^
+
+C++20 Feature Support
+^^^^^^^^^^^^^^^^^^^^^
+
+C++17 Feature Support
+^^^^^^^^^^^^^^^^^^^^^
+
+Resolutions to C++ Defect Reports
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- The flag `-frelaxed-template-template-args`
+  and its negation have been removed, having been deprecated since the previous
+  two releases. The improvements to template template parameter matching implemented
+  in the previous release, as described in P3310 and P3579, made this flag unnecessary.
+
+C Language Changes
+------------------
+
+- Clang now allows an ``inline`` specifier on a typedef declaration of a
+  function type in Microsoft compatibility mode. #GH124869
+
+C2y Feature Support
+^^^^^^^^^^^^^^^^^^^
+
+C23 Feature Support
+^^^^^^^^^^^^^^^^^^^
+
+Non-comprehensive list of changes in this release
+-------------------------------------------------
+
+New Compiler Flags
+------------------
+
+Deprecated Compiler Flags
+-------------------------
+
+Modified Compiler Flags
+-----------------------
+
+Removed Compiler Flags
+-------------------------
+
+Attribute Changes in Clang
+--------------------------
+
+- The ``no_sanitize`` attribute now accepts both ``gnu`` and ``clang`` names.
+
+Improvements to Clang's diagnostics
+-----------------------------------
+
+- Improve the diagnostics for deleted default constructor errors for C++ class
+  initializer lists that don't explicitly list a class member and thus attempt
+  to implicitly default construct that member.
+- The ``-Wunique-object-duplication`` warning has been added to warn about objects
+  which are supposed to only exist once per program, but may get duplicated when
+  built into a shared library.
+- Fixed a bug where Clang's Analysis did not correctly model the destructor behavior of ``union`` members (#GH119415).
+- Clang now provides a diagnostic note for ``function-like macros`` that are missing the required parentheses.
+
+Improvements to Clang's time-trace
+----------------------------------
+
+Improvements to Coverage Mapping
+--------------------------------
+
+Bug Fixes in This Version
+-------------------------
+
+Bug Fixes to Compiler Builtins
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- The behvaiour of ``__add_pointer`` and ``__remove_pointer`` for Objective-C++'s ``id`` and interfaces has been fixed.
+
+Bug Fixes to Attribute Support
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ - Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125
+
+Bug Fixes to C++ Support
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
+- The initialization kind of elements of structured bindings
+  direct-list-initialized from an array is corrected to direct-initialization.
+
+Bug Fixes to AST Handling
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Miscellaneous Bug Fixes
+^^^^^^^^^^^^^^^^^^^^^^^
+
+- HTML tags in comments that span multiple lines are now parsed correctly by Clang's comment parser. (#GH120843)
+
+Miscellaneous Clang Crashes Fixed
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+OpenACC Specific Changes
+------------------------
+
+Target Specific Changes
+-----------------------
+
+AMDGPU Support
+^^^^^^^^^^^^^^
+
+NVPTX Support
+^^^^^^^^^^^^^^
+
+Hexagon Support
+^^^^^^^^^^^^^^^
+
+-  The default compilation target has been changed from V60 to V68.
+
+X86 Support
+^^^^^^^^^^^
+
+- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
+  options.
+- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
+  256 and 512 bit instructions.
+
+Arm and AArch64 Support
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Android Support
+^^^^^^^^^^^^^^^
+
+Windows Support
+^^^^^^^^^^^^^^^
+
+LoongArch Support
+^^^^^^^^^^^^^^^^^
+
+RISC-V Support
+^^^^^^^^^^^^^^
+
+CUDA/HIP Language Changes
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+CUDA Support
+^^^^^^^^^^^^
+
+AIX Support
+^^^^^^^^^^^
+
+NetBSD Support
+^^^^^^^^^^^^^^
+
+WebAssembly Support
+^^^^^^^^^^^^^^^^^^^
+
+AVR Support
+^^^^^^^^^^^
+
+DWARF Support in Clang
+----------------------
+
+Floating Point Support in Clang
+-------------------------------
+
+Fixed Point Support in Clang
+----------------------------
+
+AST Matchers
+------------
+
+clang-format
+------------
+
+- Adds ``BreakBeforeTemplateCloser`` option.
+- Adds ``BinPackLongBracedList`` option to override bin packing options in
+  long (20 item or more) braced list initializer lists.
+
+libclang
+--------
+
+Code Completion
+---------------
+
+Static Analyzer
+---------------
+
+New features
+^^^^^^^^^^^^
+
+A new flag - `-static-libclosure` was introduced to support statically linking
+the runtime for the Blocks extension on Windows. This flag currently only
+changes the code generation, and even then, only on Windows. This does not
+impact the linker behaviour like the other `-static-*` flags.
+
+Crash and bug fixes
+^^^^^^^^^^^^^^^^^^^
+
+Improvements
+^^^^^^^^^^^^
+
+Moved checkers
+^^^^^^^^^^^^^^
+
+- After lots of improvements, the checker ``alpha.security.ArrayBoundV2`` is
+  renamed to ``security.ArrayBound``. As this checker is stable now, the old
+  checker ``alpha.security.ArrayBound`` (which was searching for the same kind
+  of bugs with an different, simpler and less accurate algorithm) is removed.
+
+.. _release-notes-sanitizers:
+
+Sanitizers
+----------
+
+Python Binding Changes
+----------------------
+
+OpenMP Support
+--------------
+- Added support 'no_openmp_constructs' assumption clause.
+
+Improvements
+^^^^^^^^^^^^
+
+Additional Information
+======================
+
+A wide variety of additional information is available on the `Clang web
+page <https://clang.llvm.org/>`_. The web page contains versions of the
+API documentation which are up-to-date with the Git version of
+the source code. You can access versions of these documents specific to
+this release by going into the "``clang/docs/``" directory in the Clang
+tree.
+
+If you have any questions or comments about Clang, please feel free to
+contact us on the `Discourse forums (Clang Frontend category)
+<https://discourse.llvm.org/c/clang/6>`_.

>From 17a50dbfa8b0bfd6aac2aab2f6395e6dc521da61 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Wed, 12 Feb 2025 09:52:23 +0530
Subject: [PATCH 10/14] [clang][Sema] Improve diagnostics for function-like
 macros and update related notes

---
 clang/docs/ReleaseNotes.rst                    |  5 +++--
 .../include/clang/Basic/DiagnosticSemaKinds.td |  4 ++--
 clang/lib/Sema/SemaExpr.cpp                    | 18 +++++++++---------
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a469e5a97a4ac..c37c3d586de7b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -128,8 +128,9 @@ Improvements to Clang's diagnostics
   which are supposed to only exist once per program, but may get duplicated when
   built into a shared library.
 - Fixed a bug where Clang's Analysis did not correctly model the destructor behavior of ``union`` members (#GH119415).
-- Clang now provides a diagnostic note for ``function-like macros`` that are missing the required parentheses.
-
+- Clang now provides a diagnostic note for function-like macros that are
+  missing the required parentheses (#GH123038).
+  
 Improvements to Clang's time-trace
 ----------------------------------
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 739aad0b516a8..96351168bd17e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11691,8 +11691,8 @@ def err_undeclared_use_suggest : Error<
   "use of undeclared %0; did you mean %1?">;
 def err_undeclared_var_use_suggest : Error<
   "use of undeclared identifier %0; did you mean %1?">;
-def err_undeclared_var_use_suggest_func_like_macro
-    : Error<"use of undeclared identifier %0; did you mean %0(...)?">;
+def err_undeclared_var_use_suggest_func_like_macro : Error<
+  "%0 is defined as an object-like macro; did you mean '%0(...)'?">;
 def err_no_template : Error<"no template named %0">;
 def err_no_template_suggest : Error<"no template named %0; did you mean %1?">;
 def err_no_member_template : Error<"no template named %0 in %1">;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 173094f730723..4821334e510a8 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2548,9 +2548,10 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
   return E;
 }
 
-// Check whether a similar function-like macro exists and suggest it
-static bool isFunctionLikeMacro(const DeclarationName &Name, Sema &SemaRef,
-                                const SourceLocation &TypoLoc) {
+// Diagnose when a macro cannot be expanded because it's a function-like macro
+// being used as an object-like macro. Returns true if a diagnostic is emitted.
+static bool diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name,
+                                      SourceLocation TypoLoc) {
 
   if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
     if (II->hasMacroDefinition()) {
@@ -2558,7 +2559,7 @@ static bool isFunctionLikeMacro(const DeclarationName &Name, Sema &SemaRef,
       if (MI && MI->isFunctionLike()) {
         SemaRef.Diag(TypoLoc,
                      diag::err_undeclared_var_use_suggest_func_like_macro)
-            << II->getName();
+            << II;
         SemaRef.Diag(MI->getDefinitionLoc(),
                      diag::note_function_like_macro_requires_parens)
             << II->getName();
@@ -2604,11 +2605,10 @@ static void emitEmptyLookupTypoDiagnostic(
     if (Ctx)
       SemaRef.Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
                                                  << SS.getRange();
-    else {
-      if (isFunctionLikeMacro(Typo, SemaRef, TypoLoc))
-        return;
+    else if (diagnoseFunctionLikeMacro(SemaRef, Typo, TypoLoc))
+      return;
+    else
       SemaRef.Diag(TypoLoc, DiagnosticID) << Typo;
-    }
     return;
   }
 
@@ -2841,7 +2841,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
   }
   R.clear();
 
-  if (isFunctionLikeMacro(Name, SemaRef, R.getNameLoc()))
+  if (diagnoseFunctionLikeMacro(SemaRef, Name, R.getNameLoc()))
     return true;
 
   // Emit a special diagnostic for failed member lookups.

>From 82f09221cce7b010d9759a5074823a07c00b4254 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Wed, 12 Feb 2025 16:17:08 +0530
Subject: [PATCH 11/14] [clang][Sema] Update diagnostic tests for object-like
 macros in initializer list tests

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td        | 2 +-
 clang/lib/Sema/SemaExpr.cpp                             | 2 +-
 clang/test/Preprocessor/macro_with_initializer_list.cpp | 6 +++---
 clang/test/Sema/typo-correction.c                       | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 96351168bd17e..fb8ccda59e687 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11692,7 +11692,7 @@ def err_undeclared_use_suggest : Error<
 def err_undeclared_var_use_suggest : Error<
   "use of undeclared identifier %0; did you mean %1?">;
 def err_undeclared_var_use_suggest_func_like_macro : Error<
-  "%0 is defined as an object-like macro; did you mean '%0(...)'?">;
+  "'%0' is defined as an object-like macro; did you mean '%0(...)'?">;
 def err_no_template : Error<"no template named %0">;
 def err_no_template_suggest : Error<"no template named %0; did you mean %1?">;
 def err_no_member_template : Error<"no template named %0 in %1">;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4821334e510a8..e3511823fa1da 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2559,7 +2559,7 @@ static bool diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name,
       if (MI && MI->isFunctionLike()) {
         SemaRef.Diag(TypoLoc,
                      diag::err_undeclared_var_use_suggest_func_like_macro)
-            << II;
+            << II ->getName();
         SemaRef.Diag(MI->getDefinitionLoc(),
                      diag::note_function_like_macro_requires_parens)
             << II->getName();
diff --git a/clang/test/Preprocessor/macro_with_initializer_list.cpp b/clang/test/Preprocessor/macro_with_initializer_list.cpp
index dab60e60b14a1..d9e653106d4a1 100644
--- a/clang/test/Preprocessor/macro_with_initializer_list.cpp
+++ b/clang/test/Preprocessor/macro_with_initializer_list.cpp
@@ -150,13 +150,13 @@ void test() {
   // Can't be fixed by parentheses.
   INIT(e, {1, 2, 3});
   // expected-error at -1 {{too many arguments provided}}
-  // expected-error at -2 {{use of undeclared identifier}}
+  // expected-error at -2 {{'INIT' is defined as an object-like macro; did you mean 'INIT(...)'?}}
   // expected-note at -3 {{cannot use initializer list at the beginning of a macro argument}}
 
   // Can't be fixed by parentheses.
   INIT(e, {1, 2, 3} + {1, 2, 3});
   // expected-error at -1 {{too many arguments provided}}
-  // expected-error at -2 {{use of undeclared identifier}}
+  // expected-error at -2 {{'INIT' is defined as an object-like macro; did you mean 'INIT(...)'?}}
   // expected-note at -3 {{cannot use initializer list at the beginning of a macro argument}}
 }
 
@@ -179,6 +179,6 @@ void test2() {
   M(F3, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3},
         {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3});
   // expected-error at -2 {{too many arguments provided}}
-  // expected-error at -3 {{use of undeclared identifier}}
+  // expected-error at -3 {{'M' is defined as an object-like macro; did you mean 'M(...)'?}}
   // expected-note at -4 {{cannot use initializer list at the beginning of a macro argument}}
 }
diff --git a/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c
index 5ffbc512ef73b..cc52229078691 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -122,11 +122,11 @@ void PR40286_4(int the_value) { // expected-note {{'the_value' declared here}}
 #define FOO1() 10
 // expected-note at -1 4 {{'FOO1' defined here as a function-like macro}}
 
-int x = FOO1; // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+int x = FOO1; // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
 
 void test3() {
   int iter = FOO1;
-  // expected-error at -1 {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+  // expected-error at -1 {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
 }
 
 void bar(int);
@@ -137,6 +137,6 @@ void test4() {
 }
 
 void test5() {
-    FOO1 + 1; // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
-    bar(FOO1); // expected-error {{use of undeclared identifier FOO1; did you mean FOO1(...)?}}
+    FOO1 + 1; // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
+    bar(FOO1); // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1'(...)'?}}
 }

>From 9c5eb95cae197b49c663413c36fadd05b2315325 Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Wed, 12 Feb 2025 18:04:00 +0530
Subject: [PATCH 12/14] [clang][test]fix overlooked testcase

---
 clang/test/Sema/typo-correction.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c
index cc52229078691..65729c60f8825 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -138,5 +138,5 @@ void test4() {
 
 void test5() {
     FOO1 + 1; // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
-    bar(FOO1); // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1'(...)'?}}
+    bar(FOO1); // expected-error {{'FOO1' is defined as an object-like macro; did you mean 'FOO1(...)'?}}
 }

>From a4b8828ca13689f434db347f59d14ed9e9317c14 Mon Sep 17 00:00:00 2001
From: Prashanth <thestarone01 at proton.me>
Date: Mon, 7 Sep 2026 15:58:26 +0530
Subject: [PATCH 13/14] Update c23-varargs.c test expectations for
 function-like macro diagnostic

---
 clang/lib/Sema/SemaExpr.cpp   | 37 +----------------------------------
 clang/test/Sema/c23-varargs.c | 16 +++++++++------
 2 files changed, 11 insertions(+), 42 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e3511823fa1da..6f960d4a5bd87 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2559,7 +2559,7 @@ static bool diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name,
       if (MI && MI->isFunctionLike()) {
         SemaRef.Diag(TypoLoc,
                      diag::err_undeclared_var_use_suggest_func_like_macro)
-            << II ->getName();
+            << II->getName();
         SemaRef.Diag(MI->getDefinitionLoc(),
                      diag::note_function_like_macro_requires_parens)
             << II->getName();
@@ -2593,41 +2593,6 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
   }
 }
 
-static void emitEmptyLookupTypoDiagnostic(
-    const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS,
-    DeclarationName Typo, SourceLocation TypoLoc, ArrayRef<Expr *> Args,
-    unsigned DiagnosticID, unsigned DiagnosticSuggestID) {
-  DeclContext *Ctx =
-      SS.isEmpty() ? nullptr : SemaRef.computeDeclContext(SS, false);
-  if (!TC) {
-    // Emit a special diagnostic for failed member lookups.
-    // FIXME: computing the declaration context might fail here (?)
-    if (Ctx)
-      SemaRef.Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
-                                                 << SS.getRange();
-    else if (diagnoseFunctionLikeMacro(SemaRef, Typo, TypoLoc))
-      return;
-    else
-      SemaRef.Diag(TypoLoc, DiagnosticID) << Typo;
-    return;
-  }
-
-  std::string CorrectedStr = TC.getAsString(SemaRef.getLangOpts());
-  bool DroppedSpecifier =
-      TC.WillReplaceSpecifier() && Typo.getAsString() == CorrectedStr;
-  unsigned NoteID = TC.getCorrectionDeclAs<ImplicitParamDecl>()
-                        ? diag::note_implicit_param_decl
-                        : diag::note_previous_decl;
-  if (!Ctx)
-    SemaRef.diagnoseTypo(TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo,
-                         SemaRef.PDiag(NoteID));
-  else
-    SemaRef.diagnoseTypo(TC, SemaRef.PDiag(diag::err_no_member_suggest)
-                                 << Typo << Ctx << DroppedSpecifier
-                                 << SS.getRange(),
-                         SemaRef.PDiag(NoteID));
-}
-
 bool Sema::DiagnoseDependentMemberLookup(const LookupResult &R) {
   // During a default argument instantiation the CurContext points
   // to a CXXMethodDecl; but we can't apply a this-> fixit inside a
diff --git a/clang/test/Sema/c23-varargs.c b/clang/test/Sema/c23-varargs.c
index 1700d5a429160..9bc72f21358d1 100644
--- a/clang/test/Sema/c23-varargs.c
+++ b/clang/test/Sema/c23-varargs.c
@@ -26,18 +26,22 @@ void bar(int x, int y, ...) {
   // follow-on diagnostic that should be silenced.
   va_list list;
   va_start();           // pre-c23-error {{too few arguments provided to function-like macro invocation}} \
-                           pre-c23-error {{use of undeclared identifier 'va_start'}} \
-                           expected-error{{too few arguments to function call, expected 1, have 0}}
+                           expected-error{{too few arguments to function call, expected 1, have 0}} \
+                           pre-c23-error{{'va_start' is defined as an object-like macro; did you mean 'va_start(...)'?}} \
+                           pre-c23-note at __stdarg_va_arg.h:17{{'va_start' defined here as a function-like macro}}
   va_start(list);       // pre-c23-error {{too few arguments provided to function-like macro invocation}} \
-                           pre-c23-error {{use of undeclared identifier 'va_start'}}
+                           pre-c23-error{{'va_start' is defined as an object-like macro; did you mean 'va_start(...)'?}} \
+                           pre-c23-note at __stdarg_va_arg.h:17{{'va_start' defined here as a function-like macro}}                          
   va_start(list, 0);    // both-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
   va_start(list, x);    // both-warning {{second argument to 'va_start' is not the last non-variadic parameter}}
   va_start(list, y);    // ok
   va_start(list, 0, 1); // pre-c23-error {{too many arguments provided to function-like macro invocation}} \
-                           pre-c23-error {{use of undeclared identifier 'va_start'}} \
+                           pre-c23-error{{'va_start' is defined as an object-like macro; did you mean 'va_start(...)'?}} \
+                           pre-c23-note at __stdarg_va_arg.h:17{{'va_start' defined here as a function-like macro}} \
                            expected-error {{too many arguments to function call, expected at most 2, have 3}}
   va_start(list, y, y); // pre-c23-error {{too many arguments provided to function-like macro invocation}} \
-                           pre-c23-error {{use of undeclared identifier 'va_start'}} \
-                           expected-error {{too many arguments to function call, expected at most 2, have 3}}	
+                           expected-error {{too many arguments to function call, expected at most 2, have 3}}	\
+                           pre-c23-error{{'va_start' is defined as an object-like macro; did you mean 'va_start(...)'?}} \
+                           pre-c23-note at __stdarg_va_arg.h:17{{'va_start' defined here as a function-like macro}} \
   // pre-c23-note at __stdarg_va_arg.h:* 4 {{macro 'va_start' defined here}}
 }

>From 8f8e1751e1f0846c558861f88430588c15a7e76f Mon Sep 17 00:00:00 2001
From: Prashanth <TheStarOne01 at proton.me>
Date: Mon, 7 Sep 2026 22:19:41 +0530
Subject: [PATCH 14/14] Delete clang/docs/ReleaseNotes.rst

---
 clang/docs/ReleaseNotes.rst | 305 ------------------------------------
 1 file changed, 305 deletions(-)
 delete mode 100644 clang/docs/ReleaseNotes.rst

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
deleted file mode 100644
index c37c3d586de7b..0000000000000
--- a/clang/docs/ReleaseNotes.rst
+++ /dev/null
@@ -1,305 +0,0 @@
-===========================================
-Clang |release| |ReleaseNotesTitle|
-===========================================
-
-.. contents::
-   :local:
-   :depth: 2
-
-Written by the `LLVM Team <https://llvm.org/>`_
-
-.. only:: PreRelease
-
-  .. warning::
-     These are in-progress notes for the upcoming Clang |version| release.
-     Release notes for previous releases can be found on
-     `the Releases Page <https://llvm.org/releases/>`_.
-
-Introduction
-============
-
-This document contains the release notes for the Clang C/C++/Objective-C
-frontend, part of the LLVM Compiler Infrastructure, release |release|. Here we
-describe the status of Clang in some detail, including major
-improvements from the previous release and new feature work. For the
-general LLVM release notes, see `the LLVM
-documentation <https://llvm.org/docs/ReleaseNotes.html>`_. For the libc++ release notes,
-see `this page <https://libcxx.llvm.org/ReleaseNotes.html>`_. All LLVM releases
-may be downloaded from the `LLVM releases web site <https://llvm.org/releases/>`_.
-
-For more information about Clang or LLVM, including information about the
-latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
-`LLVM Web Site <https://llvm.org>`_.
-
-Potentially Breaking Changes
-============================
-
-- The Objective-C ARC migrator (ARCMigrate) has been removed.
-
-C/C++ Language Potentially Breaking Changes
--------------------------------------------
-
-C++ Specific Potentially Breaking Changes
------------------------------------------
-
-- The type trait builtin ``__is_referenceable`` has been removed, since it has
-  very few users and all the type traits that could benefit from it in the
-  standard library already have their own bespoke builtins.
-
-ABI Changes in This Version
----------------------------
-
-- Return larger CXX records in memory instead of using AVX registers. Code compiled with older clang will be incompatible with newer version of the clang unless -fclang-abi-compat=20 is provided. (#GH120670)
-
-AST Dumping Potentially Breaking Changes
-----------------------------------------
-
-Clang Frontend Potentially Breaking Changes
--------------------------------------------
-
-Clang Python Bindings Potentially Breaking Changes
---------------------------------------------------
-
-What's New in Clang |release|?
-==============================
-
-C++ Language Changes
---------------------
-
-C++2c Feature Support
-^^^^^^^^^^^^^^^^^^^^^
-
-C++23 Feature Support
-^^^^^^^^^^^^^^^^^^^^^
-
-C++20 Feature Support
-^^^^^^^^^^^^^^^^^^^^^
-
-C++17 Feature Support
-^^^^^^^^^^^^^^^^^^^^^
-
-Resolutions to C++ Defect Reports
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-- The flag `-frelaxed-template-template-args`
-  and its negation have been removed, having been deprecated since the previous
-  two releases. The improvements to template template parameter matching implemented
-  in the previous release, as described in P3310 and P3579, made this flag unnecessary.
-
-C Language Changes
-------------------
-
-- Clang now allows an ``inline`` specifier on a typedef declaration of a
-  function type in Microsoft compatibility mode. #GH124869
-
-C2y Feature Support
-^^^^^^^^^^^^^^^^^^^
-
-C23 Feature Support
-^^^^^^^^^^^^^^^^^^^
-
-Non-comprehensive list of changes in this release
--------------------------------------------------
-
-New Compiler Flags
-------------------
-
-Deprecated Compiler Flags
--------------------------
-
-Modified Compiler Flags
------------------------
-
-Removed Compiler Flags
--------------------------
-
-Attribute Changes in Clang
---------------------------
-
-- The ``no_sanitize`` attribute now accepts both ``gnu`` and ``clang`` names.
-
-Improvements to Clang's diagnostics
------------------------------------
-
-- Improve the diagnostics for deleted default constructor errors for C++ class
-  initializer lists that don't explicitly list a class member and thus attempt
-  to implicitly default construct that member.
-- The ``-Wunique-object-duplication`` warning has been added to warn about objects
-  which are supposed to only exist once per program, but may get duplicated when
-  built into a shared library.
-- Fixed a bug where Clang's Analysis did not correctly model the destructor behavior of ``union`` members (#GH119415).
-- Clang now provides a diagnostic note for function-like macros that are
-  missing the required parentheses (#GH123038).
-  
-Improvements to Clang's time-trace
-----------------------------------
-
-Improvements to Coverage Mapping
---------------------------------
-
-Bug Fixes in This Version
--------------------------
-
-Bug Fixes to Compiler Builtins
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-- The behvaiour of ``__add_pointer`` and ``__remove_pointer`` for Objective-C++'s ``id`` and interfaces has been fixed.
-
-Bug Fixes to Attribute Support
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- - Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125
-
-Bug Fixes to C++ Support
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
-- The initialization kind of elements of structured bindings
-  direct-list-initialized from an array is corrected to direct-initialization.
-
-Bug Fixes to AST Handling
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Miscellaneous Bug Fixes
-^^^^^^^^^^^^^^^^^^^^^^^
-
-- HTML tags in comments that span multiple lines are now parsed correctly by Clang's comment parser. (#GH120843)
-
-Miscellaneous Clang Crashes Fixed
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-OpenACC Specific Changes
-------------------------
-
-Target Specific Changes
------------------------
-
-AMDGPU Support
-^^^^^^^^^^^^^^
-
-NVPTX Support
-^^^^^^^^^^^^^^
-
-Hexagon Support
-^^^^^^^^^^^^^^^
-
--  The default compilation target has been changed from V60 to V68.
-
-X86 Support
-^^^^^^^^^^^
-
-- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
-  options.
-- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
-  256 and 512 bit instructions.
-
-Arm and AArch64 Support
-^^^^^^^^^^^^^^^^^^^^^^^
-
-Android Support
-^^^^^^^^^^^^^^^
-
-Windows Support
-^^^^^^^^^^^^^^^
-
-LoongArch Support
-^^^^^^^^^^^^^^^^^
-
-RISC-V Support
-^^^^^^^^^^^^^^
-
-CUDA/HIP Language Changes
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-CUDA Support
-^^^^^^^^^^^^
-
-AIX Support
-^^^^^^^^^^^
-
-NetBSD Support
-^^^^^^^^^^^^^^
-
-WebAssembly Support
-^^^^^^^^^^^^^^^^^^^
-
-AVR Support
-^^^^^^^^^^^
-
-DWARF Support in Clang
-----------------------
-
-Floating Point Support in Clang
--------------------------------
-
-Fixed Point Support in Clang
-----------------------------
-
-AST Matchers
-------------
-
-clang-format
-------------
-
-- Adds ``BreakBeforeTemplateCloser`` option.
-- Adds ``BinPackLongBracedList`` option to override bin packing options in
-  long (20 item or more) braced list initializer lists.
-
-libclang
---------
-
-Code Completion
----------------
-
-Static Analyzer
----------------
-
-New features
-^^^^^^^^^^^^
-
-A new flag - `-static-libclosure` was introduced to support statically linking
-the runtime for the Blocks extension on Windows. This flag currently only
-changes the code generation, and even then, only on Windows. This does not
-impact the linker behaviour like the other `-static-*` flags.
-
-Crash and bug fixes
-^^^^^^^^^^^^^^^^^^^
-
-Improvements
-^^^^^^^^^^^^
-
-Moved checkers
-^^^^^^^^^^^^^^
-
-- After lots of improvements, the checker ``alpha.security.ArrayBoundV2`` is
-  renamed to ``security.ArrayBound``. As this checker is stable now, the old
-  checker ``alpha.security.ArrayBound`` (which was searching for the same kind
-  of bugs with an different, simpler and less accurate algorithm) is removed.
-
-.. _release-notes-sanitizers:
-
-Sanitizers
-----------
-
-Python Binding Changes
-----------------------
-
-OpenMP Support
---------------
-- Added support 'no_openmp_constructs' assumption clause.
-
-Improvements
-^^^^^^^^^^^^
-
-Additional Information
-======================
-
-A wide variety of additional information is available on the `Clang web
-page <https://clang.llvm.org/>`_. The web page contains versions of the
-API documentation which are up-to-date with the Git version of
-the source code. You can access versions of these documents specific to
-this release by going into the "``clang/docs/``" directory in the Clang
-tree.
-
-If you have any questions or comments about Clang, please feel free to
-contact us on the `Discourse forums (Clang Frontend category)
-<https://discourse.llvm.org/c/clang/6>`_.



More information about the cfe-commits mailing list