[clang] [clang] MangledSymbol: Added move to Names param in init list (PR #87287)

2024-04-01 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer created 
https://github.com/llvm/llvm-project/pull/87287

Fixes #87255

>From 4d0290b2dc10705cf229e4c1c3b40dd5155ea61c Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 1 Apr 2024 18:09:59 -0400
Subject: [PATCH] Added move for Names parameter in MangledSymbol ctor

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..81a827dba26b90 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
 
 MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding,
   std::vector Names)
-: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {}
+: ParentName(ParentName), Type(Type), Binding(Binding),
+  Names(std::move(Names)) {}
   };
   using MangledSymbols = std::map;
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] MangledSymbol: Added move to Names param in init list (PR #87287)

2024-04-12 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/87287

>From 4d0290b2dc10705cf229e4c1c3b40dd5155ea61c Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 1 Apr 2024 18:09:59 -0400
Subject: [PATCH] Added move for Names parameter in MangledSymbol ctor

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..81a827dba26b90 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
 
 MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding,
   std::vector Names)
-: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {}
+: ParentName(ParentName), Type(Type), Binding(Binding),
+  Names(std::move(Names)) {}
   };
   using MangledSymbols = std::map;
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-07 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer created 
https://github.com/llvm/llvm-project/pull/94827

Implements -Wmissing-include-dirs #92015 

This is my first contribution and would love some feedback. Thanks

>From 317e4c2fe7fb0ee76f7917b64ee447ba3ed838bc Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Fri, 7 Jun 2024 21:38:04 -0400
Subject: [PATCH] Implement -Wmissing-include-dirs

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 +-
 clang/lib/Driver/Driver.cpp| 6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..b7d50e22cc0d0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <
+   "the included directory %0 is missing">, InGroup;
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..5bc737a43338e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories
+  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+if (!llvm::sys::fs::is_directory(IncludeDir))
+  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-07 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer edited 
https://github.com/llvm/llvm-project/pull/94827
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-08 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/94827

>From 317e4c2fe7fb0ee76f7917b64ee447ba3ed838bc Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Fri, 7 Jun 2024 21:38:04 -0400
Subject: [PATCH] Implement -Wmissing-include-dirs

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 +-
 clang/lib/Driver/Driver.cpp| 6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..b7d50e22cc0d0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <
+   "the included directory %0 is missing">, InGroup;
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..5bc737a43338e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories
+  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+if (!llvm::sys::fs::is_directory(IncludeDir))
+  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-10 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/94827

>From 317e4c2fe7fb0ee76f7917b64ee447ba3ed838bc Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Fri, 7 Jun 2024 21:38:04 -0400
Subject: [PATCH 1/2] Implement -Wmissing-include-dirs

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 +-
 clang/lib/Driver/Driver.cpp| 6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..b7d50e22cc0d0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <
+   "the included directory %0 is missing">, InGroup;
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..5bc737a43338e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories
+  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+if (!llvm::sys::fs::is_directory(IncludeDir))
+  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

>From 6bd7085136d100bf13a7df41075e356999e18b2d Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 10 Jun 2024 15:03:25 -0400
Subject: [PATCH 2/2] Add test and address PR comments

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td |  4 ++--
 clang/lib/Driver/Driver.cpp| 10 ++
 clang/test/Driver/warning-options.cpp  |  4 
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index b7d50e22cc0d0..9490e4b1df711 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -810,6 +810,6 @@ def warn_android_unversioned_fallback : Warning<
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
 
-def warn_missing_include_dirs : Warning <
-   "the included directory %0 is missing">, InGroup;
+def warn_missing_include_dirs : Warning<
+  "the included directory %0 is missing">, InGroup, 
DefaultIgnore;
 }
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5bc737a43338e..67bf0604acd6e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,10 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
-  // Check for missing include directories
-  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
-if (!llvm::sys::fs::is_directory(IncludeDir))
-  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  // Check for missing include directories.
+  if (!Diags.isIgnored(diag::warn_missing_include_dirs, SourceLocation())) {
+for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+  if (!VFS->exists(IncludeDir))
+Diag(diag::warn_missing_include_dirs) << IncludeDir;
+}
   }
 
   // FIXME: This stuff needs to go into the Compilation, not the driver.
diff --git a/clang/test/Driver/warning-options.cpp 
b/clang/test/Driver/warning-options.cpp
index d836ad143a1c5..8eceb8f5f5544 100644
--- a/clang/test/Driver/warning-options.cpp
+++ b/clang/test/Driver/warning-options.cpp
@@ -6,3 +6,7 @@
 // Check that -isysroot warns on nonexistent paths.
 // RUN: %clang -### -c -target i386-apple-darwin10 -isysroot 
%t/warning-options %s 2>&

[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-10 Thread Braden Helmer via cfe-commits


@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <

bradenhelmer wrote:

Tested with GCC, its not enabled in `-Wall` or `-Wextra`, leaving as 
`DefaultIgnore` for now.

https://github.com/llvm/llvm-project/pull/94827
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-11 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/94827

>From 317e4c2fe7fb0ee76f7917b64ee447ba3ed838bc Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Fri, 7 Jun 2024 21:38:04 -0400
Subject: [PATCH 1/3] Implement -Wmissing-include-dirs

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 +-
 clang/lib/Driver/Driver.cpp| 6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..b7d50e22cc0d0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <
+   "the included directory %0 is missing">, InGroup;
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..5bc737a43338e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories
+  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+if (!llvm::sys::fs::is_directory(IncludeDir))
+  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

>From 6bd7085136d100bf13a7df41075e356999e18b2d Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 10 Jun 2024 15:03:25 -0400
Subject: [PATCH 2/3] Add test and address PR comments

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td |  4 ++--
 clang/lib/Driver/Driver.cpp| 10 ++
 clang/test/Driver/warning-options.cpp  |  4 
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index b7d50e22cc0d0..9490e4b1df711 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -810,6 +810,6 @@ def warn_android_unversioned_fallback : Warning<
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
 
-def warn_missing_include_dirs : Warning <
-   "the included directory %0 is missing">, InGroup;
+def warn_missing_include_dirs : Warning<
+  "the included directory %0 is missing">, InGroup, 
DefaultIgnore;
 }
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5bc737a43338e..67bf0604acd6e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,10 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
-  // Check for missing include directories
-  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
-if (!llvm::sys::fs::is_directory(IncludeDir))
-  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  // Check for missing include directories.
+  if (!Diags.isIgnored(diag::warn_missing_include_dirs, SourceLocation())) {
+for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+  if (!VFS->exists(IncludeDir))
+Diag(diag::warn_missing_include_dirs) << IncludeDir;
+}
   }
 
   // FIXME: This stuff needs to go into the Compilation, not the driver.
diff --git a/clang/test/Driver/warning-options.cpp 
b/clang/test/Driver/warning-options.cpp
index d836ad143a1c5..8eceb8f5f5544 100644
--- a/clang/test/Driver/warning-options.cpp
+++ b/clang/test/Driver/warning-options.cpp
@@ -6,3 +6,7 @@
 // Check that -isysroot warns on nonexistent paths.
 // RUN: %clang -### -c -target i386-apple-darwin10 -isysroot 
%t/warning-options %s 2>&

[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-11 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/94827

>From 317e4c2fe7fb0ee76f7917b64ee447ba3ed838bc Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Fri, 7 Jun 2024 21:38:04 -0400
Subject: [PATCH 1/4] Implement -Wmissing-include-dirs

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 +-
 clang/lib/Driver/Driver.cpp| 6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..b7d50e22cc0d0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <
+   "the included directory %0 is missing">, InGroup;
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..5bc737a43338e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories
+  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+if (!llvm::sys::fs::is_directory(IncludeDir))
+  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

>From 6bd7085136d100bf13a7df41075e356999e18b2d Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 10 Jun 2024 15:03:25 -0400
Subject: [PATCH 2/4] Add test and address PR comments

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td |  4 ++--
 clang/lib/Driver/Driver.cpp| 10 ++
 clang/test/Driver/warning-options.cpp  |  4 
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index b7d50e22cc0d0..9490e4b1df711 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -810,6 +810,6 @@ def warn_android_unversioned_fallback : Warning<
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
 
-def warn_missing_include_dirs : Warning <
-   "the included directory %0 is missing">, InGroup;
+def warn_missing_include_dirs : Warning<
+  "the included directory %0 is missing">, InGroup, 
DefaultIgnore;
 }
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5bc737a43338e..67bf0604acd6e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,10 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
-  // Check for missing include directories
-  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
-if (!llvm::sys::fs::is_directory(IncludeDir))
-  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  // Check for missing include directories.
+  if (!Diags.isIgnored(diag::warn_missing_include_dirs, SourceLocation())) {
+for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+  if (!VFS->exists(IncludeDir))
+Diag(diag::warn_missing_include_dirs) << IncludeDir;
+}
   }
 
   // FIXME: This stuff needs to go into the Compilation, not the driver.
diff --git a/clang/test/Driver/warning-options.cpp 
b/clang/test/Driver/warning-options.cpp
index d836ad143a1c5..8eceb8f5f5544 100644
--- a/clang/test/Driver/warning-options.cpp
+++ b/clang/test/Driver/warning-options.cpp
@@ -6,3 +6,7 @@
 // Check that -isysroot warns on nonexistent paths.
 // RUN: %clang -### -c -target i386-apple-darwin10 -isysroot 
%t/warning-options %s 2>&

[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-12 Thread Braden Helmer via cfe-commits

bradenhelmer wrote:

> Do you have access to press the "Squash and merge" button, or should I do it?

You'll have to, i dont have access yet, thx

https://github.com/llvm/llvm-project/pull/94827
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Template Diagnostic Improvements (PR #99933)

2024-07-23 Thread Braden Helmer via cfe-commits

bradenhelmer wrote:

I don't have write access, if someone could merge that would be great!

https://github.com/llvm/llvm-project/pull/99933
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix confusing diagnostic with explicit 'this' parameters. (PR #99824)

2024-07-23 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer edited 
https://github.com/llvm/llvm-project/pull/99824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix confusing diagnostic with explicit 'this' parameters. (PR #99824)

2024-07-23 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/99824

>From e4c3701ea6be894b1094f45d0590c61e5aa44897 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Sun, 21 Jul 2024 14:10:17 -0400
Subject: [PATCH 1/3] Fix diag mismatch

---
 clang/lib/Sema/SemaOverload.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5ea6b06121c7c..102cb5f7baef2 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11152,7 +11152,8 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   // non-constructor method.  Note that 'I' corresponds the
   // conversion-slot index.
   bool isObjectArgument = false;
-  if (isa(Fn) && !isa(Fn)) {
+  if (isa(Fn) && !isa(Fn) &&
+  !Fn->hasCXXExplicitFunctionObjectParameter()) {
 if (I == 0)
   isObjectArgument = true;
 else

>From 7f15d3d1a58f11c0ec2b6e646131c0fc0b7a9d5b Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Sun, 21 Jul 2024 15:37:09 -0400
Subject: [PATCH 2/3] Small change and add test

---
 clang/lib/Sema/SemaOverload.cpp| 5 ++---
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 8 
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1ef43b2103a9b..ac90ccd5643c1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11146,11 +11146,10 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   // non-constructor method.  Note that 'I' corresponds the
   // conversion-slot index.
   bool isObjectArgument = false;
-  if (isa(Fn) && !isa(Fn) &&
-  !Fn->hasCXXExplicitFunctionObjectParameter()) {
+  if (isa(Fn) && !isa(Fn)) {
 if (I == 0)
   isObjectArgument = true;
-else
+else if (!Fn->hasCXXExplicitFunctionObjectParameter())
   I--;
   }
 
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..6ad54b9b2c63d 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -959,3 +959,11 @@ void f();
 };
 void a::f(this auto) {} // expected-error {{an explicit object parameter 
cannot appear in a non-member function}}
 }
+
+struct R {
+  void f(this auto &&self, int &&r_value_ref) {} // expected-note {{candidate 
function template not viable: expects an rvalue for 2nd argument}}
+  void g(int &&r_value_ref) {
+   f(r_value_ref); // expected-error {{no matching member function for 
call to 'f'}}
+  }
+};
+

>From 19c05ce1b9b30a75ca72de1393d15b4e07e4c5e1 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Tue, 23 Jul 2024 07:09:50 -0400
Subject: [PATCH 3/3] Add release note

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4638b91b48f95..481b6313974ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -746,6 +746,8 @@ Improvements to Clang's diagnostics
 - Clang now diagnoses dangling assignments for pointer-like objects (annotated 
with `[[gsl::Pointer]]`) under `-Wdangling-assignment-gsl` (off by default)
   Fixes #GH63310.
 
+- Clang now has improved diagnostics for functions with explicit 'this' 
parameters. Fixes #GH97878
+
 Improvements to Clang's time-trace
 --
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [llvm] [Clang] Fix confusing diagnostic with explicit 'this' parameters. (PR #99824)

2024-07-23 Thread Braden Helmer via cfe-commits

bradenhelmer wrote:

Crud, I think I messed up fixing a conflict

https://github.com/llvm/llvm-project/pull/99824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [llvm] [Clang] Fix confusing diagnostic with explicit 'this' parameters. (PR #99824)

2024-07-23 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer closed 
https://github.com/llvm/llvm-project/pull/99824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fixed confusing diagnostics / add release notes (PR #100351)

2024-07-24 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer created 
https://github.com/llvm/llvm-project/pull/100351

New PR for #97878.

>From 4e0845195d6593b907bbf65d436ededee9c2aacd Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Tue, 23 Jul 2024 11:04:06 -0400
Subject: [PATCH] Fixed confusing diagnostics / add release notes

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaOverload.cpp| 2 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac1de0db9ce48..81624902c4f43 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -120,6 +120,8 @@ Improvements to Clang's diagnostics
   template  int i; // error: non-static data member 'i' cannot 
be declared as a template
  };
 
+- Clang now has improved diagnostics for functions with explicit 'this' 
parameters. Fixes #GH97878
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a8d250fbabfed..ac90ccd5643c1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11149,7 +11149,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   if (isa(Fn) && !isa(Fn)) {
 if (I == 0)
   isObjectArgument = true;
-else
+else if (!Fn->hasCXXExplicitFunctionObjectParameter())
   I--;
   }
 
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..f5cae2ecb5f08 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -959,3 +959,10 @@ void f();
 };
 void a::f(this auto) {} // expected-error {{an explicit object parameter 
cannot appear in a non-member function}}
 }
+
+struct R {
+  void f(this auto &&self, int &&r_value_ref) {} // expected-note {{candidate 
function template not viable: expects an rvalue for 2nd argument}}
+  void g(int &&r_value_ref) {
+   f(r_value_ref); // expected-error {{no matching member function for 
call to 'f'}}
+  }
+};

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix confusing diagnositcs related to explicit this parameters (PR #100351)

2024-07-24 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer edited 
https://github.com/llvm/llvm-project/pull/100351
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix confusing diagnositcs related to explicit this parameters (PR #100351)

2024-07-25 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/100351

>From 4e0845195d6593b907bbf65d436ededee9c2aacd Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Tue, 23 Jul 2024 11:04:06 -0400
Subject: [PATCH] Fixed confusing diagnostics / add release notes

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaOverload.cpp| 2 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac1de0db9ce48..81624902c4f43 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -120,6 +120,8 @@ Improvements to Clang's diagnostics
   template  int i; // error: non-static data member 'i' cannot 
be declared as a template
  };
 
+- Clang now has improved diagnostics for functions with explicit 'this' 
parameters. Fixes #GH97878
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a8d250fbabfed..ac90ccd5643c1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11149,7 +11149,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   if (isa(Fn) && !isa(Fn)) {
 if (I == 0)
   isObjectArgument = true;
-else
+else if (!Fn->hasCXXExplicitFunctionObjectParameter())
   I--;
   }
 
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..f5cae2ecb5f08 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -959,3 +959,10 @@ void f();
 };
 void a::f(this auto) {} // expected-error {{an explicit object parameter 
cannot appear in a non-member function}}
 }
+
+struct R {
+  void f(this auto &&self, int &&r_value_ref) {} // expected-note {{candidate 
function template not viable: expects an rvalue for 2nd argument}}
+  void g(int &&r_value_ref) {
+   f(r_value_ref); // expected-error {{no matching member function for 
call to 'f'}}
+  }
+};

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix confusing diagnositcs related to explicit this parameters (PR #100351)

2024-07-25 Thread Braden Helmer via cfe-commits

bradenhelmer wrote:

I'll need the merge button clicked, thanks

https://github.com/llvm/llvm-project/pull/100351
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Diag mismatch 97878 (PR #99824)

2024-07-21 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer created 
https://github.com/llvm/llvm-project/pull/99824

Fixes #97878 

>From e4c3701ea6be894b1094f45d0590c61e5aa44897 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Sun, 21 Jul 2024 14:10:17 -0400
Subject: [PATCH 1/2] Fix diag mismatch

---
 clang/lib/Sema/SemaOverload.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5ea6b06121c7c..102cb5f7baef2 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11152,7 +11152,8 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   // non-constructor method.  Note that 'I' corresponds the
   // conversion-slot index.
   bool isObjectArgument = false;
-  if (isa(Fn) && !isa(Fn)) {
+  if (isa(Fn) && !isa(Fn) &&
+  !Fn->hasCXXExplicitFunctionObjectParameter()) {
 if (I == 0)
   isObjectArgument = true;
 else

>From 7f15d3d1a58f11c0ec2b6e646131c0fc0b7a9d5b Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Sun, 21 Jul 2024 15:37:09 -0400
Subject: [PATCH 2/2] Small change and add test

---
 clang/lib/Sema/SemaOverload.cpp| 5 ++---
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 8 
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1ef43b2103a9b..ac90ccd5643c1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11146,11 +11146,10 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   // non-constructor method.  Note that 'I' corresponds the
   // conversion-slot index.
   bool isObjectArgument = false;
-  if (isa(Fn) && !isa(Fn) &&
-  !Fn->hasCXXExplicitFunctionObjectParameter()) {
+  if (isa(Fn) && !isa(Fn)) {
 if (I == 0)
   isObjectArgument = true;
-else
+else if (!Fn->hasCXXExplicitFunctionObjectParameter())
   I--;
   }
 
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..6ad54b9b2c63d 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -959,3 +959,11 @@ void f();
 };
 void a::f(this auto) {} // expected-error {{an explicit object parameter 
cannot appear in a non-member function}}
 }
+
+struct R {
+  void f(this auto &&self, int &&r_value_ref) {} // expected-note {{candidate 
function template not viable: expects an rvalue for 2nd argument}}
+  void g(int &&r_value_ref) {
+   f(r_value_ref); // expected-error {{no matching member function for 
call to 'f'}}
+  }
+};
+

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Template Diagnostic Improvements (PR #99933)

2024-07-22 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer created 
https://github.com/llvm/llvm-project/pull/99933

This is for #17959.

 It turns out `SemaTemplate` handles this type of diagnostic already, however 
when  template gets encountered, it never gets parsed as a possible statement 
or declaration, only as an expression. 

Would like some feedback as I am unsure if this is the right fix. Thanks

>From 1aaa6ff0f1843f10606064f6b285c7070aaa5b44 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 16:46:04 -0400
Subject: [PATCH] Fix template error message

---
 clang/lib/Parse/ParseStmt.cpp   | 9 +
 clang/test/Parser/cxx-template-decl.cpp | 4 
 2 files changed, 13 insertions(+)

diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 22d38adc28ebe..bdb3fc051d0b3 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -299,6 +299,15 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
 goto Retry;
   }
 
+  case tok::kw_template: {
+SourceLocation DeclEnd;
+ParsedAttributes Attrs(AttrFactory);
+ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd,
+ Attrs,
+ getAccessSpecifierIfPresent());
+return StmtError();
+  }
+
   case tok::kw_case:// C99 6.8.1: labeled-statement
 return ParseCaseStatement(StmtCtx);
   case tok::kw_default: // C99 6.8.1: labeled-statement
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 734438069b9ae..5a2d1cec9ad31 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -297,3 +297,7 @@ namespace PR46231 {
   template<> int; // expected-error {{declaration does not declare anything}}
   template int; // expected-error {{declaration does not declare 
anything}}
 }
+
+namespace NoTemplateInBlockScope {
+  void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Template Diagnostic Improvements (PR #99933)

2024-07-22 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/99933

>From 1aaa6ff0f1843f10606064f6b285c7070aaa5b44 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 16:46:04 -0400
Subject: [PATCH 1/2] Fix template error message

---
 clang/lib/Parse/ParseStmt.cpp   | 9 +
 clang/test/Parser/cxx-template-decl.cpp | 4 
 2 files changed, 13 insertions(+)

diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 22d38adc28ebe..bdb3fc051d0b3 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -299,6 +299,15 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
 goto Retry;
   }
 
+  case tok::kw_template: {
+SourceLocation DeclEnd;
+ParsedAttributes Attrs(AttrFactory);
+ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd,
+ Attrs,
+ getAccessSpecifierIfPresent());
+return StmtError();
+  }
+
   case tok::kw_case:// C99 6.8.1: labeled-statement
 return ParseCaseStatement(StmtCtx);
   case tok::kw_default: // C99 6.8.1: labeled-statement
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 734438069b9ae..5a2d1cec9ad31 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -297,3 +297,7 @@ namespace PR46231 {
   template<> int; // expected-error {{declaration does not declare anything}}
   template int; // expected-error {{declaration does not declare 
anything}}
 }
+
+namespace NoTemplateInBlockScope {
+  void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
+}

>From 26853b9c5d65f6bcc74d52cdaeec333e8bd0422c Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 17:46:27 -0400
Subject: [PATCH 2/2] Update another template error message, add and fixed
 tests accordingly

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td| 2 +-
 clang/test/Parser/cxx-template-decl.cpp | 2 +-
 clang/test/SemaCXX/invalid-template-declaration.cpp | 6 ++
 clang/test/SemaTemplate/class-template-decl.cpp | 2 +-
 clang/test/SemaTemplate/nested-template.cpp | 2 +-
 5 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaCXX/invalid-template-declaration.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c4a4e8064fac2..7790982301177 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5165,7 +5165,7 @@ def warn_cxx11_compat_variable_template : Warning<
   InGroup, DefaultIgnore;
 def err_template_variable_noparams : Error<
   "extraneous 'template<>' in declaration of variable %0">;
-def err_template_member : Error<"member %0 declared as a template">;
+def err_template_member : Error<"non-static data member %0 cannot be declared 
as a template">;
 def err_member_with_template_arguments : Error<"member %0 cannot have template 
arguments">;
 def err_template_member_noparams : Error<
   "extraneous 'template<>' in declaration of member %0">;
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 5a2d1cec9ad31..476341686a64b 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -298,6 +298,6 @@ namespace PR46231 {
   template int; // expected-error {{declaration does not declare 
anything}}
 }
 
-namespace NoTemplateInBlockScope {
+namespace PR99933 {
   void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
 }
diff --git a/clang/test/SemaCXX/invalid-template-declaration.cpp 
b/clang/test/SemaCXX/invalid-template-declaration.cpp
new file mode 100644
index 0..fda147520cca8
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-template-declaration.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// PR99933
+
+struct S {
+  template  int i; // expected-error {{non-static data member 'i' 
cannot be declared as a template}}
+};
diff --git a/clang/test/SemaTemplate/class-template-decl.cpp 
b/clang/test/SemaTemplate/class-template-decl.cpp
index c054a6a8d82f7..0374c4eba982a 100644
--- a/clang/test/SemaTemplate/class-template-decl.cpp
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -63,7 +63,7 @@ class X {
 };
 
 void f() {
-  template class X; // expected-error{{expression}}
+  template class X; // expected-error{{templates can only be 
declared in namespace or class scope}}
 }
 
 template class X1 var; // expected-error {{variable has incomplete 
type 'class X1'}} \
diff --git a/clang/test/SemaTemplate/nested-template.cpp 
b/clang/test/SemaTemplate/nested-template.cpp
index a6ede8e99037e..a54992a397187 100644
--- a/c

[clang] Template Diagnostic Improvements (PR #99933)

2024-07-22 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/99933

>From 1aaa6ff0f1843f10606064f6b285c7070aaa5b44 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 16:46:04 -0400
Subject: [PATCH 1/3] Fix template error message

---
 clang/lib/Parse/ParseStmt.cpp   | 9 +
 clang/test/Parser/cxx-template-decl.cpp | 4 
 2 files changed, 13 insertions(+)

diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 22d38adc28ebe..bdb3fc051d0b3 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -299,6 +299,15 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
 goto Retry;
   }
 
+  case tok::kw_template: {
+SourceLocation DeclEnd;
+ParsedAttributes Attrs(AttrFactory);
+ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd,
+ Attrs,
+ getAccessSpecifierIfPresent());
+return StmtError();
+  }
+
   case tok::kw_case:// C99 6.8.1: labeled-statement
 return ParseCaseStatement(StmtCtx);
   case tok::kw_default: // C99 6.8.1: labeled-statement
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 734438069b9ae..5a2d1cec9ad31 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -297,3 +297,7 @@ namespace PR46231 {
   template<> int; // expected-error {{declaration does not declare anything}}
   template int; // expected-error {{declaration does not declare 
anything}}
 }
+
+namespace NoTemplateInBlockScope {
+  void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
+}

>From 26853b9c5d65f6bcc74d52cdaeec333e8bd0422c Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 17:46:27 -0400
Subject: [PATCH 2/3] Update another template error message, add and fixed
 tests accordingly

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td| 2 +-
 clang/test/Parser/cxx-template-decl.cpp | 2 +-
 clang/test/SemaCXX/invalid-template-declaration.cpp | 6 ++
 clang/test/SemaTemplate/class-template-decl.cpp | 2 +-
 clang/test/SemaTemplate/nested-template.cpp | 2 +-
 5 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaCXX/invalid-template-declaration.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c4a4e8064fac2..7790982301177 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5165,7 +5165,7 @@ def warn_cxx11_compat_variable_template : Warning<
   InGroup, DefaultIgnore;
 def err_template_variable_noparams : Error<
   "extraneous 'template<>' in declaration of variable %0">;
-def err_template_member : Error<"member %0 declared as a template">;
+def err_template_member : Error<"non-static data member %0 cannot be declared 
as a template">;
 def err_member_with_template_arguments : Error<"member %0 cannot have template 
arguments">;
 def err_template_member_noparams : Error<
   "extraneous 'template<>' in declaration of member %0">;
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 5a2d1cec9ad31..476341686a64b 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -298,6 +298,6 @@ namespace PR46231 {
   template int; // expected-error {{declaration does not declare 
anything}}
 }
 
-namespace NoTemplateInBlockScope {
+namespace PR99933 {
   void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
 }
diff --git a/clang/test/SemaCXX/invalid-template-declaration.cpp 
b/clang/test/SemaCXX/invalid-template-declaration.cpp
new file mode 100644
index 0..fda147520cca8
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-template-declaration.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// PR99933
+
+struct S {
+  template  int i; // expected-error {{non-static data member 'i' 
cannot be declared as a template}}
+};
diff --git a/clang/test/SemaTemplate/class-template-decl.cpp 
b/clang/test/SemaTemplate/class-template-decl.cpp
index c054a6a8d82f7..0374c4eba982a 100644
--- a/clang/test/SemaTemplate/class-template-decl.cpp
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -63,7 +63,7 @@ class X {
 };
 
 void f() {
-  template class X; // expected-error{{expression}}
+  template class X; // expected-error{{templates can only be 
declared in namespace or class scope}}
 }
 
 template class X1 var; // expected-error {{variable has incomplete 
type 'class X1'}} \
diff --git a/clang/test/SemaTemplate/nested-template.cpp 
b/clang/test/SemaTemplate/nested-template.cpp
index a6ede8e99037e..a54992a397187 100644
--- a/c

[clang] Template Diagnostic Improvements (PR #99933)

2024-07-22 Thread Braden Helmer via cfe-commits

bradenhelmer wrote:

This is handling the other non-local case now, and the release notes have been 
updated. The local class case was already being handled.

https://github.com/llvm/llvm-project/pull/99933
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Template Diagnostic Improvements (PR #99933)

2024-07-22 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/99933

>From 1aaa6ff0f1843f10606064f6b285c7070aaa5b44 Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 16:46:04 -0400
Subject: [PATCH 1/4] Fix template error message

---
 clang/lib/Parse/ParseStmt.cpp   | 9 +
 clang/test/Parser/cxx-template-decl.cpp | 4 
 2 files changed, 13 insertions(+)

diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 22d38adc28ebe..bdb3fc051d0b3 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -299,6 +299,15 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
 goto Retry;
   }
 
+  case tok::kw_template: {
+SourceLocation DeclEnd;
+ParsedAttributes Attrs(AttrFactory);
+ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd,
+ Attrs,
+ getAccessSpecifierIfPresent());
+return StmtError();
+  }
+
   case tok::kw_case:// C99 6.8.1: labeled-statement
 return ParseCaseStatement(StmtCtx);
   case tok::kw_default: // C99 6.8.1: labeled-statement
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 734438069b9ae..5a2d1cec9ad31 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -297,3 +297,7 @@ namespace PR46231 {
   template<> int; // expected-error {{declaration does not declare anything}}
   template int; // expected-error {{declaration does not declare 
anything}}
 }
+
+namespace NoTemplateInBlockScope {
+  void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
+}

>From 26853b9c5d65f6bcc74d52cdaeec333e8bd0422c Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 22 Jul 2024 17:46:27 -0400
Subject: [PATCH 2/4] Update another template error message, add and fixed
 tests accordingly

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td| 2 +-
 clang/test/Parser/cxx-template-decl.cpp | 2 +-
 clang/test/SemaCXX/invalid-template-declaration.cpp | 6 ++
 clang/test/SemaTemplate/class-template-decl.cpp | 2 +-
 clang/test/SemaTemplate/nested-template.cpp | 2 +-
 5 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaCXX/invalid-template-declaration.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c4a4e8064fac2..7790982301177 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5165,7 +5165,7 @@ def warn_cxx11_compat_variable_template : Warning<
   InGroup, DefaultIgnore;
 def err_template_variable_noparams : Error<
   "extraneous 'template<>' in declaration of variable %0">;
-def err_template_member : Error<"member %0 declared as a template">;
+def err_template_member : Error<"non-static data member %0 cannot be declared 
as a template">;
 def err_member_with_template_arguments : Error<"member %0 cannot have template 
arguments">;
 def err_template_member_noparams : Error<
   "extraneous 'template<>' in declaration of member %0">;
diff --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index 5a2d1cec9ad31..476341686a64b 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -298,6 +298,6 @@ namespace PR46231 {
   template int; // expected-error {{declaration does not declare 
anything}}
 }
 
-namespace NoTemplateInBlockScope {
+namespace PR99933 {
   void foo() { template  int i; } // expected-error {{templates can 
only be declared in namespace or class scope}}
 }
diff --git a/clang/test/SemaCXX/invalid-template-declaration.cpp 
b/clang/test/SemaCXX/invalid-template-declaration.cpp
new file mode 100644
index 0..fda147520cca8
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-template-declaration.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// PR99933
+
+struct S {
+  template  int i; // expected-error {{non-static data member 'i' 
cannot be declared as a template}}
+};
diff --git a/clang/test/SemaTemplate/class-template-decl.cpp 
b/clang/test/SemaTemplate/class-template-decl.cpp
index c054a6a8d82f7..0374c4eba982a 100644
--- a/clang/test/SemaTemplate/class-template-decl.cpp
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -63,7 +63,7 @@ class X {
 };
 
 void f() {
-  template class X; // expected-error{{expression}}
+  template class X; // expected-error{{templates can only be 
declared in namespace or class scope}}
 }
 
 template class X1 var; // expected-error {{variable has incomplete 
type 'class X1'}} \
diff --git a/clang/test/SemaTemplate/nested-template.cpp 
b/clang/test/SemaTemplate/nested-template.cpp
index a6ede8e99037e..a54992a397187 100644
--- a/c

[clang] [clang] MangledSymbol: Added move to Names param in init list (PR #87287)

2024-05-10 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/87287

>From 4d0290b2dc10705cf229e4c1c3b40dd5155ea61c Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Mon, 1 Apr 2024 18:09:59 -0400
Subject: [PATCH] Added move for Names parameter in MangledSymbol ctor

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb091990..81a827dba26b9 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
 
 MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding,
   std::vector Names)
-: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {}
+: ParentName(ParentName), Type(Type), Binding(Binding),
+  Names(std::move(Names)) {}
   };
   using MangledSymbols = std::map;
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] MangledSymbol: Added move to Names param in init list (PR #87287)

2024-05-24 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer closed 
https://github.com/llvm/llvm-project/pull/87287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits