[PATCH] D126158: [MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

2022-06-05 Thread Christian Sigg via Phabricator via cfe-commits
csigg added a comment.

This diff was recommited in 400fef081adbafc358858709861cdb14303de0e9 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126158/new/

https://reviews.llvm.org/D126158

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


[PATCH] D127054: [clang-format] Handle attributes for for/while loops

2022-06-05 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

Great!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127054/new/

https://reviews.llvm.org/D127054

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


[clang-tools-extra] d86a206 - Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options

2022-06-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-06-05T00:31:44-07:00
New Revision: d86a206f06a51c12a9fcf2c20199f4e819751c0c

URL: 
https://github.com/llvm/llvm-project/commit/d86a206f06a51c12a9fcf2c20199f4e819751c0c
DIFF: 
https://github.com/llvm/llvm-project/commit/d86a206f06a51c12a9fcf2c20199f4e819751c0c.diff

LOG: Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options

Added: 


Modified: 
clang-tools-extra/modularize/Modularize.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenPGO.cpp
clang/tools/clang-import-test/clang-import-test.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/tools/clang-rename/ClangRename.cpp
clang/tools/clang-repl/ClangRepl.cpp
libc/benchmarks/automemcpy/lib/ResultAnalyzerMain.cpp

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
llvm/lib/Analysis/DDGPrinter.cpp
llvm/lib/Analysis/DependenceAnalysis.cpp
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp
llvm/lib/CodeGen/VLIWMachineScheduler.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Target/AArch64/AArch64StackTaggingPreRA.cpp
llvm/lib/Target/ARM/ARMSubtarget.cpp
llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/SampleProfileInference.cpp
llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp
llvm/tools/bugpoint/ExecutionDriver.cpp
llvm/tools/bugpoint/OptimizerDriver.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
llvm/tools/llvm-dwp/llvm-dwp.cpp
llvm/tools/llvm-extract/llvm-extract.cpp
llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/tools/llvm-link/llvm-link.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/llvm-profgen.cpp
llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
llvm/tools/llvm-undname/llvm-undname.cpp
llvm/tools/lto/lto.cpp
llvm/unittests/Support/CommandLineTest.cpp
mlir/lib/ExecutionEngine/JitRunner.cpp
mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
polly/lib/Analysis/PolyhedralInfo.cpp
polly/lib/Analysis/ScopBuilder.cpp
polly/lib/Analysis/ScopInfo.cpp
polly/lib/CodeGen/PPCGCodeGeneration.cpp
polly/lib/Support/RegisterPasses.cpp
polly/lib/Support/ScopHelper.cpp
polly/lib/Transform/ScheduleOptimizer.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 7f73749f5b540..4b95711813d9e 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -310,13 +310,12 @@ cl::desc("Only warn if #include directives are inside 
extern or namespace"
 
 // Option for include paths for coverage check.
 static cl::list
-IncludePaths("I", cl::desc("Include path for coverage check."),
-cl::ZeroOrMore, cl::value_desc("path"));
+IncludePaths("I", cl::desc("Include path for coverage check."),
+ cl::value_desc("path"));
 
 // Option for disabling the coverage check.
-static cl::opt
-NoCoverageCheck("no-coverage-check", cl::init(false),
-cl::desc("Don't do the coverage check."));
+static cl::opt NoCoverageCheck("no-coverage-check",
+ cl::desc("Don't do the coverage check."));
 
 // Option for just doing the coverage check.
 static cl::opt

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 758887a3b627d..afb28c1e5cc97 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -70,9 +70,8 @@ using namespace clang;
 using namespace CodeGen;
 
 static llvm::cl::opt Limite

[clang] d86a206 - Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options

2022-06-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-06-05T00:31:44-07:00
New Revision: d86a206f06a51c12a9fcf2c20199f4e819751c0c

URL: 
https://github.com/llvm/llvm-project/commit/d86a206f06a51c12a9fcf2c20199f4e819751c0c
DIFF: 
https://github.com/llvm/llvm-project/commit/d86a206f06a51c12a9fcf2c20199f4e819751c0c.diff

LOG: Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options

Added: 


Modified: 
clang-tools-extra/modularize/Modularize.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenPGO.cpp
clang/tools/clang-import-test/clang-import-test.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/tools/clang-rename/ClangRename.cpp
clang/tools/clang-repl/ClangRepl.cpp
libc/benchmarks/automemcpy/lib/ResultAnalyzerMain.cpp

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
llvm/lib/Analysis/DDGPrinter.cpp
llvm/lib/Analysis/DependenceAnalysis.cpp
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp
llvm/lib/CodeGen/VLIWMachineScheduler.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Target/AArch64/AArch64StackTaggingPreRA.cpp
llvm/lib/Target/ARM/ARMSubtarget.cpp
llvm/lib/Target/Hexagon/HexagonNewValueJump.cpp
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/SampleProfileInference.cpp
llvm/lib/Transforms/Utils/SampleProfileLoaderBaseUtil.cpp
llvm/tools/bugpoint/ExecutionDriver.cpp
llvm/tools/bugpoint/OptimizerDriver.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
llvm/tools/llvm-dwp/llvm-dwp.cpp
llvm/tools/llvm-extract/llvm-extract.cpp
llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/tools/llvm-link/llvm-link.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/llvm-profgen.cpp
llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
llvm/tools/llvm-undname/llvm-undname.cpp
llvm/tools/lto/lto.cpp
llvm/unittests/Support/CommandLineTest.cpp
mlir/lib/ExecutionEngine/JitRunner.cpp
mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
polly/lib/Analysis/PolyhedralInfo.cpp
polly/lib/Analysis/ScopBuilder.cpp
polly/lib/Analysis/ScopInfo.cpp
polly/lib/CodeGen/PPCGCodeGeneration.cpp
polly/lib/Support/RegisterPasses.cpp
polly/lib/Support/ScopHelper.cpp
polly/lib/Transform/ScheduleOptimizer.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 7f73749f5b540..4b95711813d9e 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -310,13 +310,12 @@ cl::desc("Only warn if #include directives are inside 
extern or namespace"
 
 // Option for include paths for coverage check.
 static cl::list
-IncludePaths("I", cl::desc("Include path for coverage check."),
-cl::ZeroOrMore, cl::value_desc("path"));
+IncludePaths("I", cl::desc("Include path for coverage check."),
+ cl::value_desc("path"));
 
 // Option for disabling the coverage check.
-static cl::opt
-NoCoverageCheck("no-coverage-check", cl::init(false),
-cl::desc("Don't do the coverage check."));
+static cl::opt NoCoverageCheck("no-coverage-check",
+ cl::desc("Don't do the coverage check."));
 
 // Option for just doing the coverage check.
 static cl::opt

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 758887a3b627d..afb28c1e5cc97 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -70,9 +70,8 @@ using namespace clang;
 using namespace CodeGen;
 
 static llvm::cl::opt Limite

[clang] 95a1342 - Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options

2022-06-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-06-05T01:07:51-07:00
New Revision: 95a134254a403750ddfee7c056efdf2359a7dc8c

URL: 
https://github.com/llvm/llvm-project/commit/95a134254a403750ddfee7c056efdf2359a7dc8c
DIFF: 
https://github.com/llvm/llvm-project/commit/95a134254a403750ddfee7c056efdf2359a7dc8c.diff

LOG: Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-rename/ClangRename.cpp

llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/CodeGen/VLIWMachineScheduler.cpp
llvm/lib/IR/DiagnosticHandler.cpp
llvm/lib/Support/DebugCounter.cpp
llvm/lib/Support/TypeSize.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
llvm/lib/Target/Hexagon/HexagonGenInsert.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/lib/Transforms/Scalar/LoopFuse.cpp
llvm/tools/bugpoint/ExecutionDriver.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-extract/llvm-extract.cpp
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
llvm/tools/llvm-strings/llvm-strings.cpp
llvm/tools/opt/opt.cpp
llvm/unittests/Support/CommandLineTest.cpp
polly/lib/Analysis/DependenceInfo.cpp
polly/lib/Analysis/ScopDetection.cpp
polly/lib/Analysis/ScopInfo.cpp
polly/lib/CodeGen/BlockGenerators.cpp
polly/lib/CodeGen/CodeGeneration.cpp
polly/lib/CodeGen/IslAst.cpp
polly/lib/CodeGen/IslExprBuilder.cpp
polly/lib/CodeGen/ManagedMemoryRewrite.cpp
polly/lib/CodeGen/PPCGCodeGeneration.cpp
polly/lib/Support/RegisterPasses.cpp
polly/lib/Transform/DeadCodeElimination.cpp
polly/lib/Transform/MatmulOptimizer.cpp
polly/lib/Transform/ScheduleOptimizer.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index e7eec16e51150..4e0b5ab2024cc 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -109,7 +109,7 @@ static cl::list
   cl::cat(ClangLinkerWrapperCategory));
 
 static cl::list
-LinkerArgs("device-linker", cl::ZeroOrMore,
+LinkerArgs("device-linker",
cl::desc("Arguments to pass to the device linker invocation"),
cl::value_desc(" or ="),
cl::cat(ClangLinkerWrapperCategory));

diff  --git a/clang/tools/clang-rename/ClangRename.cpp 
b/clang/tools/clang-rename/ClangRename.cpp
index 12f20243a9633..e7ceac7dbf303 100644
--- a/clang/tools/clang-rename/ClangRename.cpp
+++ b/clang/tools/clang-rename/ClangRename.cpp
@@ -74,7 +74,7 @@ static cl::opt Inplace("i", cl::desc("Overwrite edited 
s."),
 static cl::list
 QualifiedNames("qualified-name",
cl::desc("The fully qualified name of the symbol."),
-   cl::ZeroOrMore, cl::cat(ClangRenameOptions));
+   cl::cat(ClangRenameOptions));
 
 static cl::list
 NewNames("new-name", cl::desc("The new name to change the symbol to."),

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp
index 795c167c5271d..291f14e1d7d7a 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp
@@ -105,7 +105,7 @@ static cl::list InputFiles(cl::Positional, 
cl::OneOrMore,
 // Command line arguments to pass to the JITed main function.
 static cl::list InputArgv("args", cl::Positional,
cl::desc("..."),
-   cl::ZeroOrMore, cl::PositionalEatsArgs);
+   cl::PositionalEatsArgs);
 
 // Given paths must exist on the remote target.
 static cl::list

diff  --git a/llvm/lib/CodeGen/MachinePipeliner.cpp 
b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 51f4cc30c45bc..e6619e180758d 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -146,8 +146,8 @@ static cl::opt SwpLoopLimit("pipeliner-max", 
cl::Hi

[PATCH] D127074: [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127074

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -125,6 +125,17 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -125,6 +125,17 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127074: [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 434334.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127074/new/

https://reviews.llvm.org/D127074

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -125,6 +125,17 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+void test4(A1 a) { // PR54341
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -125,6 +125,17 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+void test4(A1 a) { // PR54341
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127074: [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 434335.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127074/new/

https://reviews.llvm.org/D127074

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked 
deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2 {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+  void test4(A1 a) {
+void f(decltype((throw a, 0)));
+// expected-warning@-1 {{has no effect}}
+
+void g(int = decltype(throw a, 0){});
+// expected-warning@-1 {{has no effect}}
+  }
+
+  void test5(A1 a, int = decltype(throw a, 0){}) {}
+  // expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2 {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+  void test4(A1 a) {
+void f(decltype((throw a, 0)));
+// expected-warning@-1 {{has no effect}}
+
+void g(int = decltype(throw a, 0){});
+// expected-warning@-1 {{has no effect}}
+  }
+
+  void test5(A1 a, int = decltype(throw a, 0){}) {}
+  // expected-error@-1 {{call to deleted constructor of 'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127074: [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 434336.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127074/new/

https://reviews.llvm.org/D127074

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked 
deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+  void test4(A1 a) {
+void f(decltype((throw a, 0)));
+// expected-warning@-1 {{has no effect}}
+
+void g(int = decltype(throw a, 0){});
+// expected-warning@-1 {{has no effect}}
+  }
+
+  void test5(A1 a, int = decltype(throw a, 0){}) {}
+  // expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+  void test4(A1 a) {
+void f(decltype((throw a, 0)));
+// expected-warning@-1 {{has no effect}}
+
+void g(int = decltype(throw a, 0){});
+// expected-warning@-1 {{has no effect}}
+  }
+
+  void test5(A1 a, int = decltype(throw a, 0){}) {}
+  // expected-error@-1 {{call to deleted constructor of 'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127074: [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 434337.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127074/new/

https://reviews.llvm.org/D127074

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked 
deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+
+void test5(A1 a, int = decltype(throw a, 0){}) {}
+// expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+
+void test5(A1 a, int = decltype(throw a, 0){}) {}
+// expected-error@-1 {{call to deleted constructor of 'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f62433f - [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2022-06-05T20:34:28+02:00
New Revision: f62433f17c304a8bd8458a60eb32cd86ecf507a4

URL: 
https://github.com/llvm/llvm-project/commit/f62433f17c304a8bd8458a60eb32cd86ecf507a4
DIFF: 
https://github.com/llvm/llvm-project/commit/f62433f17c304a8bd8458a60eb32cd86ecf507a4.diff

LOG: [NFC] Add test cases reported in PR54341

Signed-off-by: Matheus Izvekov 

Differential Revision: https://reviews.llvm.org/D127074

Added: 


Modified: 
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

Removed: 




diff  --git a/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp 
b/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
index 7055acad6ccf..d7b52c561a54 100644
--- a/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ b/clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@ void func();
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked 
deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@ void test3(A1 a) try {
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+
+void test5(A1 a, int = decltype(throw a, 0){}) {}
+// expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no



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


[PATCH] D127074: [NFC] Add test cases reported in PR54341

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf62433f17c30: [NFC] Add test cases reported in PR54341 
(authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127074/new/

https://reviews.llvm.org/D127074

Files:
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked 
deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+
+void test5(A1 a, int = decltype(throw a, 0){}) {}
+// expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -96,7 +96,9 @@
 
 struct A1 {
   A1(const A1 &);
-  A1(A1 &&) = delete; // expected-note 2{{'A1' has been explicitly marked deleted here}}
+  A1(A1 &&) = delete;
+  // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -125,6 +127,22 @@
 } catch (...) {
   throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
+
+#if __cplusplus >= 201103L
+namespace PR54341 {
+void test4(A1 a) {
+  void f(decltype((throw a, 0)));
+  // expected-warning@-1 {{has no effect}}
+
+  void g(int = decltype(throw a, 0){});
+  // expected-warning@-1 {{has no effect}}
+}
+
+void test5(A1 a, int = decltype(throw a, 0){}) {}
+// expected-error@-1 {{call to deleted constructor of 'test_throw_parameter::A1'}}
+} // namespace PR54341
+#endif
+
 } // namespace test_throw_parameter
 
 // During the first overload resolution, the selected function no
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126865: [clang] [Headers] Check __SEH__, when checking if ARM EHABI is implied

2022-06-05 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

@MaskRay Thanks for the other reviews! This one is the last one with the same 
condition added.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126865/new/

https://reviews.llvm.org/D126865

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


[PATCH] D126865: [clang] [Headers] Check __SEH__, when checking if ARM EHABI is implied

2022-06-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126865/new/

https://reviews.llvm.org/D126865

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


[PATCH] D127075: [clang] P2266: apply move elision rules on throw expr nested in function prototypes

2022-06-05 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Our rules to determine if the throw expression are within the variable
scope were giving a false negative result in case the throw expression
would appear within a decltype in a nested function declaration.

Per P2266R3, the relevant rule is: [expr.prim.id.unqual]/2

  if the id-expression (possibly parenthesized) is the operand of a 
throw-expression, and names an implicitly movable entity that belongs to a 
scope that does not contain the compound-statement of the innermost 
lambda-expression, try-block , or function-try-block (if any) whose 
compound-statement or ctor-initializer encloses the throw-expression.

This fixes PR54341.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127075

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -98,7 +98,7 @@
   A1(const A1 &);
   A1(A1 &&) = delete;
   // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
-  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2 3{{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -132,10 +132,10 @@
 namespace PR54341 {
 void test4(A1 a) {
   void f(decltype((throw a, 0)));
-  // expected-warning@-1 {{has no effect}}
+  // expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 
   void g(int = decltype(throw a, 0){});
-  // expected-warning@-1 {{has no effect}}
+  // expected-error@-1 {{call to deleted constructor of 
'test_throw_parameter::A1'}}
 }
 
 void test5(A1 a, int = decltype(throw a, 0){}) {}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -845,8 +845,7 @@
 
 if (S->getFlags() &
 (Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
- Scope::FunctionPrototypeScope | Scope::ObjCMethodScope |
- Scope::TryScope))
+ Scope::ObjCMethodScope | Scope::TryScope))
   break;
   }
 }


Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -98,7 +98,7 @@
   A1(const A1 &);
   A1(A1 &&) = delete;
   // expected-note@-1 2{{'A1' has been explicitly marked deleted here}}
-  // cxx11_2b-note@-2  {{'A1' has been explicitly marked deleted here}}
+  // cxx11_2b-note@-2 3{{'A1' has been explicitly marked deleted here}}
 };
 void test1() {
   try {
@@ -132,10 +132,10 @@
 namespace PR54341 {
 void test4(A1 a) {
   void f(decltype((throw a, 0)));
-  // expected-warning@-1 {{has no effect}}
+  // expected-error@-1 {{call to deleted constructor of 'test_throw_parameter::A1'}}
 
   void g(int = decltype(throw a, 0){});
-  // expected-warning@-1 {{has no effect}}
+  // expected-error@-1 {{call to deleted constructor of 'test_throw_parameter::A1'}}
 }
 
 void test5(A1 a, int = decltype(throw a, 0){}) {}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -845,8 +845,7 @@
 
 if (S->getFlags() &
 (Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
- Scope::FunctionPrototypeScope | Scope::ObjCMethodScope |
- Scope::TryScope))
+ Scope::ObjCMethodScope | Scope::TryScope))
   break;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 434352.
abrachet marked an inline comment as done.
abrachet edited the summary of this revision.
abrachet added a comment.

Better handling of names with version, ie `llvm-cxxfilt-15` -> `cxxfilt`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -30,6 +30,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,79 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+constexpr char subcommands[] =
+#define LLVM_DRIVER_TOOL(tool, entry, key) "  " tool "\n"
+#include "LLVMDriverTools.def"
+;
+
+static void printHelpMessage() {
+  llvm::outs() << "OVERVIEW: llvm toolchain driver\n\n"
+   << "USAGE: llvm [subcommand] [options]\n\n"
+   << "SUBCOMMANDS:\n\n"
+   << subcommands
+   << "\n  Type \"llvm  --help\" to get more help on a "
+  "specific subcommand\n\n"
+   << "OPTIONS:\n\n  --help - Display this message";
+}
+
+static int findTool(int Argc, char **Argv) {
+  if (!Argc) {
+printHelpMessage();
+return 1;
+  }
+
+  StringRef ToolName = Argv[0];
+
+  if (ToolName == "--help") {
+printHelpMessage();
+return 0;
+  }
+  if (ToolName == "--version") {
+cl::PrintVersionMessage();
+return 0;
+  }
+
+  StringRef Stem = sys::path::stem(ToolName);
+  auto Is = [=](StringRef Tool) {
+auto I = Stem.rfind_insensitive(Tool);
+return I != StringRef::npos && (I + Tool.size() == Stem.size() ||
+!llvm::isAlnum(Stem[I + Tool.size()]));
+  };
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  if (Is(tool))\
+return entry##_main(Argc, Argv);
+#include "LLVMDriverTools.def"
+
+  if (Is("llvm"))
+return findTool(Argc - 1, Argv + 1);
+
+  printHelpMessage();
+  return 1;
+}
+
+extern bool IsLLVMDriver;
+
+int main(int Argc, char **Argv) {
+  IsLLVMDriver = true;
+  return findTool(Argc, Argv);
+}
Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- /dev/null
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -0,0 +1,31 @@
+get_property(LLVM_COMMON_DEPENDS GLOBAL PROPERTY LLVM_DRIVER_DEPS)
+get_property(LLVM_DRIVER_OBJLIBS GLOBAL PROPERTY LLVM_DRIVER_OBJLIBS)
+
+get_property(LLVM_D

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 5 inline comments as done.
abrachet added a comment.

In D109977#3558762 , @MaskRay wrote:

> Thanks for picking up the change. I confirm that I can build `llvm` without 
> an error and it appears to work fine.
>
>> llvm-driver can be disabled from builds by setting 
>> LLVM_TOOL_LLVM_DRIVER_BUILD=Off.
>
> I think this should be opt-in. The new `llvm` executable takes a lot of space 
> and not needed by many developers/build bots.
> It's useful to some groups (distributions) but they can specify the option 
> themselves.
> I think the modified code is quite stable, so don't worry about regressions 
> just because this is not opt-in.

I didn't update the commits message, now it properly says that it can be opted 
in by setting `LLVM_TOOL_LLVM_DRIVER_BUILD` to `On`

In D109977#3558768 , @MaskRay wrote:

>   % /tmp/out/custom1/bin/llvm --help
>   ...

The output now looks like:

  OVERVIEW: llvm toolchain driver
  
  USAGE: llvm [subcommand] [options]
  
  SUBCOMMANDS:
  
ar
clang
dsymutil
cxxfilt
objcopy
ranlib
lib
dlltool
clang++
clang-cl
clang-cpp
install-name-tool
bitcode-strip
strip
  
Type "llvm  --help" to get more help on a specific subcommand
  
  OPTIONS:
  
--help - Display this message

What do you think?




Comment at: llvm/tools/llvm-driver/llvm-driver.cpp:50
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+if (Argc < 2)

MaskRay wrote:
> Some distributions may want to use something like llvm-15. See some binary 
> utilities how the version is handled.
Thank's I've taken this from objcopy's code


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM from my perspective, but this needs someone else's review.




Comment at: llvm/tools/llvm-driver/llvm-driver.cpp:50
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+if (Argc < 2)

abrachet wrote:
> MaskRay wrote:
> > Some distributions may want to use something like llvm-15. See some binary 
> > utilities how the version is handled.
> Thank's I've taken this from objcopy's code
The format of `cl::PrintVersionMessage();` is not so good for user-facing 
tools. Consider omitting it.

`llvm-objcopy --version` should probably use a style similar to `clang 
--version` but the priority isn't high.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

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


[clang] 8f7b148 - [NFC] Make comment consistent with allow|ignore list renamings

2022-06-05 Thread Aditya Kumar via cfe-commits

Author: Aditya Kumar
Date: 2022-06-05T14:49:01-07:00
New Revision: 8f7b14898fe32f9c41059517a5a3872ef089174b

URL: 
https://github.com/llvm/llvm-project/commit/8f7b14898fe32f9c41059517a5a3872ef089174b
DIFF: 
https://github.com/llvm/llvm-project/commit/8f7b14898fe32f9c41059517a5a3872ef089174b.diff

LOG: [NFC] Make comment consistent with allow|ignore list renamings

Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D123640

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index fbabd1a3e38aa..9ebcc9e76e228 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -175,7 +175,7 @@ static void addDefaultIgnorelists(const Driver &D, 
SanitizerMask Kinds,
   DiagnoseErrors);
 }
 
-/// Parse -f(no-)?sanitize-(coverage-)?(white|ignore)list argument's values,
+/// Parse -f(no-)?sanitize-(coverage-)?(allow|ignore)list argument's values,
 /// diagnosing any invalid file paths and validating special case list format.
 static void parseSpecialCaseListArg(const Driver &D,
 const llvm::opt::ArgList &Args,
@@ -185,7 +185,7 @@ static void parseSpecialCaseListArg(const Driver &D,
 unsigned MalformedSCLErrorDiagID,
 bool DiagnoseErrors) {
   for (const auto *Arg : Args) {
-// Match -fsanitize-(coverage-)?(white|ignore)list.
+// Match -fsanitize-(coverage-)?(allow|ignore)list.
 if (Arg->getOption().matches(SCLOptionID)) {
   Arg->claim();
   std::string SCLPath = Arg->getValue();
@@ -788,7 +788,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
   CoverageFeatures |= CoverageFunc;
   }
 
-  // Parse -fsanitize-coverage-(ignore|white)list options if coverage enabled.
+  // Parse -fsanitize-coverage-(allow|ignore)list options if coverage enabled.
   // This also validates special case lists format.
   // Here, OptSpecifier() acts as a never-matching command-line argument.
   // So, there is no way to clear coverage lists but you can append to them.



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


[PATCH] D123640: [NFC] Make comment consistent with allow|ignore list renamings

2022-06-05 Thread Aditya Kumar via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f7b14898fe3: [NFC] Make comment consistent with 
allow|ignore list renamings (authored by hiraditya).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123640/new/

https://reviews.llvm.org/D123640

Files:
  clang/lib/Driver/SanitizerArgs.cpp


Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -175,7 +175,7 @@
   DiagnoseErrors);
 }
 
-/// Parse -f(no-)?sanitize-(coverage-)?(white|ignore)list argument's values,
+/// Parse -f(no-)?sanitize-(coverage-)?(allow|ignore)list argument's values,
 /// diagnosing any invalid file paths and validating special case list format.
 static void parseSpecialCaseListArg(const Driver &D,
 const llvm::opt::ArgList &Args,
@@ -185,7 +185,7 @@
 unsigned MalformedSCLErrorDiagID,
 bool DiagnoseErrors) {
   for (const auto *Arg : Args) {
-// Match -fsanitize-(coverage-)?(white|ignore)list.
+// Match -fsanitize-(coverage-)?(allow|ignore)list.
 if (Arg->getOption().matches(SCLOptionID)) {
   Arg->claim();
   std::string SCLPath = Arg->getValue();
@@ -788,7 +788,7 @@
   CoverageFeatures |= CoverageFunc;
   }
 
-  // Parse -fsanitize-coverage-(ignore|white)list options if coverage enabled.
+  // Parse -fsanitize-coverage-(allow|ignore)list options if coverage enabled.
   // This also validates special case lists format.
   // Here, OptSpecifier() acts as a never-matching command-line argument.
   // So, there is no way to clear coverage lists but you can append to them.


Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -175,7 +175,7 @@
   DiagnoseErrors);
 }
 
-/// Parse -f(no-)?sanitize-(coverage-)?(white|ignore)list argument's values,
+/// Parse -f(no-)?sanitize-(coverage-)?(allow|ignore)list argument's values,
 /// diagnosing any invalid file paths and validating special case list format.
 static void parseSpecialCaseListArg(const Driver &D,
 const llvm::opt::ArgList &Args,
@@ -185,7 +185,7 @@
 unsigned MalformedSCLErrorDiagID,
 bool DiagnoseErrors) {
   for (const auto *Arg : Args) {
-// Match -fsanitize-(coverage-)?(white|ignore)list.
+// Match -fsanitize-(coverage-)?(allow|ignore)list.
 if (Arg->getOption().matches(SCLOptionID)) {
   Arg->claim();
   std::string SCLPath = Arg->getValue();
@@ -788,7 +788,7 @@
   CoverageFeatures |= CoverageFunc;
   }
 
-  // Parse -fsanitize-coverage-(ignore|white)list options if coverage enabled.
+  // Parse -fsanitize-coverage-(allow|ignore)list options if coverage enabled.
   // This also validates special case lists format.
   // Here, OptSpecifier() acts as a never-matching command-line argument.
   // So, there is no way to clear coverage lists but you can append to them.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32199: [TySan] A Type Sanitizer (Clang)

2022-06-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Having the feature will be useful.

`curl -L 'https://reviews.llvm.org/D32199?download=1' | patch -p1` doesn't 
apply cleanly. This needs a rebase.




Comment at: clang/test/Driver/sanitizer-ld.c:250
 
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ 
\

Most `-no-canonical-prefixes` were cargo cult. I have removed them. The test 
needs a rebase.

Avoid legacy `-target `



Comment at: clang/test/Driver/sanitizer-ld.c:259
+// CHECK-TYSAN-LINUX-CXX-NOT: stdc++
+// CHECK-TYSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tysan-x86_64.a" 
"-no-whole-archive"
+// CHECK-TYSAN-LINUX-CXX: stdc++

`{{.*}}libclang_rt.tysan{{[^.]*}}.a"`

LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on builds use `libclang_rt.tysan-x86_64.a` 
(see D107799)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D32199/new/

https://reviews.llvm.org/D32199

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


[clang] fc1c160 - [clang-format] Handle attributes for for/while loops

2022-06-05 Thread via cfe-commits

Author: owenca
Date: 2022-06-05T15:45:25-07:00
New Revision: fc1c160f73304d474198d9a21e857b47df2acd3a

URL: 
https://github.com/llvm/llvm-project/commit/fc1c160f73304d474198d9a21e857b47df2acd3a
DIFF: 
https://github.com/llvm/llvm-project/commit/fc1c160f73304d474198d9a21e857b47df2acd3a.diff

LOG: [clang-format] Handle attributes for for/while loops

Fixes #55853.

Differential Revision: https://reviews.llvm.org/D127054

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 8de7fae9ae51d..30bdbdfb2c702 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2889,6 +2889,7 @@ void UnwrappedLineParser::parseForOrWhileLoop() {
   if (FormatTok->is(tok::l_paren))
 parseParens();
 
+  handleAttributes();
   parseLoopBody(KeepBraces, /*WrapRightBrace=*/true);
 }
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index f8f2715c39768..264f50ab980ea 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -23846,6 +23846,22 @@ TEST_F(FormatTest, LikelyUnlikely) {
"  return 29;\n",
Style);
 
+  verifyFormat("while (limit > 0) [[unlikely]] {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+  verifyFormat("for (auto &limit : limits) [[likely]] {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+
+  verifyFormat("for (auto &limit : limits) [[unlikely]]\n"
+   "  --limit;",
+   Style);
+  verifyFormat("while (limit > 0) [[likely]]\n"
+   "  --limit;",
+   Style);
+
   Style.AttributeMacros.push_back("UNLIKELY");
   Style.AttributeMacros.push_back("LIKELY");
   verifyFormat("if (argc > 5) UNLIKELY\n"
@@ -23874,6 +23890,22 @@ TEST_F(FormatTest, LikelyUnlikely) {
"  return 42;\n"
"}\n",
Style);
+
+  verifyFormat("for (auto &limit : limits) UNLIKELY {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+  verifyFormat("while (limit > 0) LIKELY {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+
+  verifyFormat("while (limit > 0) UNLIKELY\n"
+   "  --limit;",
+   Style);
+  verifyFormat("for (auto &limit : limits) LIKELY\n"
+   "  --limit;",
+   Style);
 }
 
 TEST_F(FormatTest, PenaltyIndentedWhitespace) {



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


[PATCH] D127054: [clang-format] Handle attributes for for/while loops

2022-06-05 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc1c160f7330: [clang-format] Handle attributes for for/while 
loops (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127054/new/

https://reviews.llvm.org/D127054

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23846,6 +23846,22 @@
"  return 29;\n",
Style);
 
+  verifyFormat("while (limit > 0) [[unlikely]] {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+  verifyFormat("for (auto &limit : limits) [[likely]] {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+
+  verifyFormat("for (auto &limit : limits) [[unlikely]]\n"
+   "  --limit;",
+   Style);
+  verifyFormat("while (limit > 0) [[likely]]\n"
+   "  --limit;",
+   Style);
+
   Style.AttributeMacros.push_back("UNLIKELY");
   Style.AttributeMacros.push_back("LIKELY");
   verifyFormat("if (argc > 5) UNLIKELY\n"
@@ -23874,6 +23890,22 @@
"  return 42;\n"
"}\n",
Style);
+
+  verifyFormat("for (auto &limit : limits) UNLIKELY {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+  verifyFormat("while (limit > 0) LIKELY {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+
+  verifyFormat("while (limit > 0) UNLIKELY\n"
+   "  --limit;",
+   Style);
+  verifyFormat("for (auto &limit : limits) LIKELY\n"
+   "  --limit;",
+   Style);
 }
 
 TEST_F(FormatTest, PenaltyIndentedWhitespace) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2889,6 +2889,7 @@
   if (FormatTok->is(tok::l_paren))
 parseParens();
 
+  handleAttributes();
   parseLoopBody(KeepBraces, /*WrapRightBrace=*/true);
 }
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23846,6 +23846,22 @@
"  return 29;\n",
Style);
 
+  verifyFormat("while (limit > 0) [[unlikely]] {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+  verifyFormat("for (auto &limit : limits) [[likely]] {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+
+  verifyFormat("for (auto &limit : limits) [[unlikely]]\n"
+   "  --limit;",
+   Style);
+  verifyFormat("while (limit > 0) [[likely]]\n"
+   "  --limit;",
+   Style);
+
   Style.AttributeMacros.push_back("UNLIKELY");
   Style.AttributeMacros.push_back("LIKELY");
   verifyFormat("if (argc > 5) UNLIKELY\n"
@@ -23874,6 +23890,22 @@
"  return 42;\n"
"}\n",
Style);
+
+  verifyFormat("for (auto &limit : limits) UNLIKELY {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+  verifyFormat("while (limit > 0) LIKELY {\n"
+   "  --limit;\n"
+   "}",
+   Style);
+
+  verifyFormat("while (limit > 0) UNLIKELY\n"
+   "  --limit;",
+   Style);
+  verifyFormat("for (auto &limit : limits) LIKELY\n"
+   "  --limit;",
+   Style);
 }
 
 TEST_F(FormatTest, PenaltyIndentedWhitespace) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2889,6 +2889,7 @@
   if (FormatTok->is(tok::l_paren))
 parseParens();
 
+  handleAttributes();
   parseLoopBody(KeepBraces, /*WrapRightBrace=*/true);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM




Comment at: llvm/cmake/modules/AddLLVM.cmake:2030
+string(REPLACE "-" "_" key ${link_name})
+string(REPLACE "+" "p" key ${key})
+string(REPLACE "llvm-" "" tool_name ${link_name})

Alternative substitution for `+` would be `x` which is used elsewhere in LLVM, 
for example `libcxx`, `libcxxabi` or `cxxfilt`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

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


[clang] d937289 - [clang] Use llvm::is_contained (NFC)

2022-06-05 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-05T17:56:40-07:00
New Revision: d93728978b24da15c1a9e2847c36d031aa737f33

URL: 
https://github.com/llvm/llvm-project/commit/d93728978b24da15c1a9e2847c36d031aa737f33
DIFF: 
https://github.com/llvm/llvm-project/commit/d93728978b24da15c1a9e2847c36d031aa737f33.diff

LOG: [clang] Use llvm::is_contained (NFC)

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 7de40b5db04a3..9120808e298df 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -594,12 +594,12 @@ bool PPCTargetInfo::initFeatureMap(
   }
 
   if (!(ArchDefs & ArchDefinePwr10)) {
-if (llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
+if (llvm::is_contained(FeaturesVec, "+mma")) {
   // MMA operations are not available pre-Power10.
   Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
   return false;
 }
-if (llvm::find(FeaturesVec, "+pcrel") != FeaturesVec.end()) {
+if (llvm::is_contained(FeaturesVec, "+pcrel")) {
   // PC-Relative instructions are not available pre-Power10,
   // and these instructions also require prefixed instructions support.
   Diags.Report(diag::err_opt_not_valid_without_opt)
@@ -607,13 +607,13 @@ bool PPCTargetInfo::initFeatureMap(
   << "-mcpu=pwr10 -mprefixed";
   return false;
 }
-if (llvm::find(FeaturesVec, "+prefixed") != FeaturesVec.end()) {
+if (llvm::is_contained(FeaturesVec, "+prefixed")) {
   // Prefixed instructions are not available pre-Power10.
   Diags.Report(diag::err_opt_not_valid_without_opt) << "-mprefixed"
 << "-mcpu=pwr10";
   return false;
 }
-if (llvm::find(FeaturesVec, "+paired-vector-memops") != FeaturesVec.end()) 
{
+if (llvm::is_contained(FeaturesVec, "+paired-vector-memops")) {
   // Paired vector memops are not available pre-Power10.
   Diags.Report(diag::err_opt_not_valid_without_opt)
   << "-mpaired-vector-memops"

diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index cc51bf78f0c1a..098bf21d6caa0 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -235,11 +235,9 @@ bool RISCVTargetInfo::initFeatureMap(
   // RISCVISAInfo makes implications for ISA features
   std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
   // Add non-ISA features like `relax` and `save-restore` back
-  for (std::string Feature : FeaturesVec) {
-if (std::find(begin(ImpliedFeatures), end(ImpliedFeatures), Feature) ==
-end(ImpliedFeatures))
+  for (const std::string &Feature : FeaturesVec)
+if (!llvm::is_contained(ImpliedFeatures, Feature))
   ImpliedFeatures.push_back(Feature);
-  }
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures);
 }

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b629fcb91b25a..ef01bef2a9dff 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3498,7 +3498,7 @@ bool Sema::checkTargetClonesAttrString(SourceLocation 
LiteralLoc, StringRef Str,
   return Diag(CurLoc, diag::warn_unsupported_target_attribute)
  << Unsupported << None << Cur << TargetClones;
 
-if (llvm::find(Strings, Cur) != Strings.end() || DefaultIsDupe)
+if (llvm::is_contained(Strings, Cur) || DefaultIsDupe)
   Diag(CurLoc, diag::warn_target_clone_duplicate_options);
 // Note: Add even if there are duplicates, since it changes name mangling.
 Strings.push_back(Cur);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6627aaf3e6d88..01a3599087f84 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19606,7 +19606,7 @@ class EvaluatedExprMarker : public 
UsedDeclVisitor {
   }
 
   void Visit(Expr *E) {
-if (std::find(StopAt.begin(), StopAt.end(), E) != StopAt.end())
+if (llvm::is_contained(StopAt, E))
   return;
 Inherited::Visit(E);
   }



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


[clang] 52818fd - [Clang][FP16] Add 4 builtins for _Float16

2022-06-05 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2022-06-06T09:00:26+08:00
New Revision: 52818fd97f0f2b13d12e66de9f06b9f4cbc0be07

URL: 
https://github.com/llvm/llvm-project/commit/52818fd97f0f2b13d12e66de9f06b9f4cbc0be07
DIFF: 
https://github.com/llvm/llvm-project/commit/52818fd97f0f2b13d12e66de9f06b9f4cbc0be07.diff

LOG: [Clang][FP16] Add 4 builtins for _Float16

We are lacking builtins support for `_Float16`. In most cases, we can use other 
floating-type builtins and truncate them to `_Float16`.
But it's a problem to SNaN, e.g., https://gcc.godbolt.org/z/cqr5nG1jh
This patch adds `__builtin_nansf16` support as well as other 3 ones since they 
are usually used together.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D127050

Added: 
clang/test/CodeGen/builtin_Float16.c

Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 6fb6d97d2..f47e8de806e21 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -142,10 +142,12 @@ BUILTIN(__builtin_frexpf128, "LLdLLdi*", "Fn")
 BUILTIN(__builtin_huge_val, "d", "nc")
 BUILTIN(__builtin_huge_valf, "f", "nc")
 BUILTIN(__builtin_huge_vall, "Ld", "nc")
+BUILTIN(__builtin_huge_valf16, "x", "nc")
 BUILTIN(__builtin_huge_valf128, "LLd", "nc")
 BUILTIN(__builtin_inf  , "d"   , "nc")
 BUILTIN(__builtin_inff , "f"   , "nc")
 BUILTIN(__builtin_infl , "Ld"  , "nc")
+BUILTIN(__builtin_inff16 , "x"  , "nc")
 BUILTIN(__builtin_inff128 , "LLd"  , "nc")
 BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
 BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
@@ -160,10 +162,12 @@ BUILTIN(__builtin_modff128, "LLdLLdLLd*", "Fn")
 BUILTIN(__builtin_nan,  "dcC*" , "FnU")
 BUILTIN(__builtin_nanf, "fcC*" , "FnU")
 BUILTIN(__builtin_nanl, "LdcC*", "FnU")
+BUILTIN(__builtin_nanf16, "xcC*", "FnU")
 BUILTIN(__builtin_nanf128, "LLdcC*", "FnU")
 BUILTIN(__builtin_nans,  "dcC*" , "FnU")
 BUILTIN(__builtin_nansf, "fcC*" , "FnU")
 BUILTIN(__builtin_nansl, "LdcC*", "FnU")
+BUILTIN(__builtin_nansf16, "xcC*", "FnU")
 BUILTIN(__builtin_nansf128, "LLdcC*", "FnU")
 BUILTIN(__builtin_powi , "ddi"  , "Fnc")
 BUILTIN(__builtin_powif, "ffi"  , "Fnc")

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f679dba44f001..896650e7f4c67 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -13880,10 +13880,12 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   case Builtin::BI__builtin_huge_val:
   case Builtin::BI__builtin_huge_valf:
   case Builtin::BI__builtin_huge_vall:
+  case Builtin::BI__builtin_huge_valf16:
   case Builtin::BI__builtin_huge_valf128:
   case Builtin::BI__builtin_inf:
   case Builtin::BI__builtin_inff:
   case Builtin::BI__builtin_infl:
+  case Builtin::BI__builtin_inff16:
   case Builtin::BI__builtin_inff128: {
 const llvm::fltSemantics &Sem =
   Info.Ctx.getFloatTypeSemantics(E->getType());
@@ -13894,6 +13896,7 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   case Builtin::BI__builtin_nans:
   case Builtin::BI__builtin_nansf:
   case Builtin::BI__builtin_nansl:
+  case Builtin::BI__builtin_nansf16:
   case Builtin::BI__builtin_nansf128:
 if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
true, Result))
@@ -13903,6 +13906,7 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   case Builtin::BI__builtin_nan:
   case Builtin::BI__builtin_nanf:
   case Builtin::BI__builtin_nanl:
+  case Builtin::BI__builtin_nanf16:
   case Builtin::BI__builtin_nanf128:
 // If this is __builtin_nan() turn this into a nan, otherwise we
 // can't constant fold it.

diff  --git a/clang/test/CodeGen/builtin_Float16.c 
b/clang/test/CodeGen/builtin_Float16.c
new file mode 100644
index 0..099d2ad5697e3
--- /dev/null
+++ b/clang/test/CodeGen/builtin_Float16.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-linux-pc -target-feature 
+avx512fp16 %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck 
%s
+// RUN: %clang_cc1 -emit-llvm -o - -triple armv7a--none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-linux-gnu %s | FileCheck %s
+
+void test_float16_builtins(void) {
+  volatile _Float16 res;
+
+  // CHECK: store volatile half 0xH7C00, ptr %res, align 2
+  res = __builtin_huge_valf16();
+  // CHECK: store volatile half 0xH7C00, ptr %res, align 2
+  res = __builtin_inff16();
+  // CHECK: store volatile half 0xH7E00, ptr %res, align 2
+  res = __builtin_nanf16("");
+  // CHECK: store volatile half 0xH7D00, ptr %res, align 2
+  res = __builtin_nansf16("");
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists

[PATCH] D127050: [Clang][FP16] Add 4 builtins for _Float16

2022-06-05 Thread Phoebe Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52818fd97f0f: [Clang][FP16] Add 4 builtins for _Float16 
(authored by pengfei).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127050/new/

https://reviews.llvm.org/D127050

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGen/builtin_Float16.c


Index: clang/test/CodeGen/builtin_Float16.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin_Float16.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-linux-pc -target-feature 
+avx512fp16 %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck 
%s
+// RUN: %clang_cc1 -emit-llvm -o - -triple armv7a--none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-linux-gnu %s | FileCheck %s
+
+void test_float16_builtins(void) {
+  volatile _Float16 res;
+
+  // CHECK: store volatile half 0xH7C00, ptr %res, align 2
+  res = __builtin_huge_valf16();
+  // CHECK: store volatile half 0xH7C00, ptr %res, align 2
+  res = __builtin_inff16();
+  // CHECK: store volatile half 0xH7E00, ptr %res, align 2
+  res = __builtin_nanf16("");
+  // CHECK: store volatile half 0xH7D00, ptr %res, align 2
+  res = __builtin_nansf16("");
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -13880,10 +13880,12 @@
   case Builtin::BI__builtin_huge_val:
   case Builtin::BI__builtin_huge_valf:
   case Builtin::BI__builtin_huge_vall:
+  case Builtin::BI__builtin_huge_valf16:
   case Builtin::BI__builtin_huge_valf128:
   case Builtin::BI__builtin_inf:
   case Builtin::BI__builtin_inff:
   case Builtin::BI__builtin_infl:
+  case Builtin::BI__builtin_inff16:
   case Builtin::BI__builtin_inff128: {
 const llvm::fltSemantics &Sem =
   Info.Ctx.getFloatTypeSemantics(E->getType());
@@ -13894,6 +13896,7 @@
   case Builtin::BI__builtin_nans:
   case Builtin::BI__builtin_nansf:
   case Builtin::BI__builtin_nansl:
+  case Builtin::BI__builtin_nansf16:
   case Builtin::BI__builtin_nansf128:
 if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
true, Result))
@@ -13903,6 +13906,7 @@
   case Builtin::BI__builtin_nan:
   case Builtin::BI__builtin_nanf:
   case Builtin::BI__builtin_nanl:
+  case Builtin::BI__builtin_nanf16:
   case Builtin::BI__builtin_nanf128:
 // If this is __builtin_nan() turn this into a nan, otherwise we
 // can't constant fold it.
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -142,10 +142,12 @@
 BUILTIN(__builtin_huge_val, "d", "nc")
 BUILTIN(__builtin_huge_valf, "f", "nc")
 BUILTIN(__builtin_huge_vall, "Ld", "nc")
+BUILTIN(__builtin_huge_valf16, "x", "nc")
 BUILTIN(__builtin_huge_valf128, "LLd", "nc")
 BUILTIN(__builtin_inf  , "d"   , "nc")
 BUILTIN(__builtin_inff , "f"   , "nc")
 BUILTIN(__builtin_infl , "Ld"  , "nc")
+BUILTIN(__builtin_inff16 , "x"  , "nc")
 BUILTIN(__builtin_inff128 , "LLd"  , "nc")
 BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
 BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
@@ -160,10 +162,12 @@
 BUILTIN(__builtin_nan,  "dcC*" , "FnU")
 BUILTIN(__builtin_nanf, "fcC*" , "FnU")
 BUILTIN(__builtin_nanl, "LdcC*", "FnU")
+BUILTIN(__builtin_nanf16, "xcC*", "FnU")
 BUILTIN(__builtin_nanf128, "LLdcC*", "FnU")
 BUILTIN(__builtin_nans,  "dcC*" , "FnU")
 BUILTIN(__builtin_nansf, "fcC*" , "FnU")
 BUILTIN(__builtin_nansl, "LdcC*", "FnU")
+BUILTIN(__builtin_nansf16, "xcC*", "FnU")
 BUILTIN(__builtin_nansf128, "LLdcC*", "FnU")
 BUILTIN(__builtin_powi , "ddi"  , "Fnc")
 BUILTIN(__builtin_powif, "ffi"  , "Fnc")


Index: clang/test/CodeGen/builtin_Float16.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin_Float16.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-linux-pc -target-feature +avx512fp16 %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple armv7a--none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-linux-gnu %s | FileCheck %s
+
+void test_float16_builtins(void) {
+  volatile _Float16 res;
+
+  // CHECK: store volatile half 0xH7C00, ptr %res, align 2
+  res = __builtin_huge_valf16();
+  // CHECK: store volatile half 0xH7C00, ptr %res, align 2
+  res = __builtin_inff16();
+  // CHECK: store volatile half 0xH7E00, ptr %res, align 2
+  res = __builtin_nanf16("");
+  // CHECK: store volatile half 0xH7D00, ptr %res, align 2
+  res = __builtin_nansf16("");
+}
Index: clang/lib/AST/ExprConstant.cpp
==

[PATCH] D127005: [clang-format][NFC] Clean up the unwrapped line parser

2022-06-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 434366.
owenpan edited the summary of this revision.
owenpan added a comment.

Restored the return type of `parseLevel()` and reordered the parameters of 
`parseStructuralElement()`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127005/new/

https://reviews.llvm.org/D127005

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h

Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -92,16 +92,18 @@
   void reset();
   void parseFile();
   bool precededByCommentOrPPDirective() const;
-  bool parseLevel(const FormatToken *OpeningBrace, bool CanContainBracedList,
-  IfStmtKind *IfKind = nullptr,
-  TokenType NextLBracesType = TT_Unknown);
+  bool parseLevel(const FormatToken *OpeningBrace = nullptr,
+  bool CanContainBracedList = true,
+  TokenType NextLBracesType = TT_Unknown,
+  IfStmtKind *IfKind = nullptr);
   bool mightFitOnOneLine(UnwrappedLine &Line,
  const FormatToken *OpeningBrace = nullptr) const;
-  IfStmtKind parseBlock(bool MustBeDeclaration = false, unsigned AddLevels = 1u,
-bool MunchSemi = true, bool KeepBraces = true,
-bool UnindentWhitesmithsBraces = false,
-bool CanContainBracedList = true,
-TokenType NextLBracesType = TT_Unknown);
+  void parseBlock(bool MustBeDeclaration = false, unsigned AddLevels = 1u,
+  bool MunchSemi = true, bool KeepBraces = true,
+  IfStmtKind *IfKind = nullptr,
+  bool UnindentWhitesmithsBraces = false,
+  bool CanContainBracedList = true,
+  TokenType NextLBracesType = TT_Unknown);
   void parseChildBlock(bool CanContainBracedList = true,
TokenType NextLBracesType = TT_Unknown);
   void parsePPDirective();
@@ -112,9 +114,9 @@
   void parsePPEndIf();
   void parsePPUnknown();
   void readTokenWithJavaScriptASI();
-  void parseStructuralElement(IfStmtKind *IfKind = nullptr,
-  bool IsTopLevel = false,
+  void parseStructuralElement(bool IsTopLevel = false,
   TokenType NextLBracesType = TT_Unknown,
+  IfStmtKind *IfKind = nullptr,
   bool *HasDoWhile = nullptr,
   bool *HasLabel = nullptr);
   bool tryToParseBracedList();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -395,7 +395,7 @@
   if (Style.Language == FormatStyle::LK_TextProto)
 parseBracedList();
   else
-parseLevel(/*OpeningBrace=*/nullptr, /*CanContainBracedList=*/true);
+parseLevel();
   // Make sure to format the remaining tokens.
   //
   // LK_TextProto is special since its top-level is parsed as the body of a
@@ -469,12 +469,13 @@
 /// \param CanContainBracedList If the content can contain (at any level) a
 /// braced list.
 /// \param NextLBracesType The type for left brace found in this level.
+/// \param IfKind The if statement kind in the level.
 /// \returns true if a simple block of if/else/for/while, or false otherwise.
 /// (A simple block has a single statement.)
 bool UnwrappedLineParser::parseLevel(const FormatToken *OpeningBrace,
  bool CanContainBracedList,
- IfStmtKind *IfKind,
- TokenType NextLBracesType) {
+ TokenType NextLBracesType,
+ IfStmtKind *IfKind) {
   auto NextLevelLBracesType = NextLBracesType == TT_CompoundRequirementLBrace
   ? TT_BracedListLBrace
   : TT_Unknown;
@@ -484,6 +485,7 @@
   bool HasLabel = false;
   unsigned StatementCount = 0;
   bool SwitchLabelEncountered = false;
+
   do {
 if (FormatTok->getType() == TT_AttributeMacro) {
   nextToken();
@@ -495,9 +497,9 @@
 else if (FormatTok->getType() == TT_MacroBlockEnd)
   kind = tok::r_brace;
 
-auto ParseDefault = [this, OpeningBrace, IfKind, NextLevelLBracesType,
+auto ParseDefault = [this, OpeningBrace, NextLevelLBracesType, IfKind,
  &HasDoWhile, &HasLabel, &StatementCount] {
-  parseStructuralElement(IfKind, !OpeningBrace, NextLevelLBracesType,
+  parseStructuralElement(!OpeningBrace, NextLevelLBracesType, IfKind,
  HasDoWhile ? nullptr : &HasDoWhile,
  HasLabel ? nullptr : &HasLabel);
   ++StatementCount;
@@ -524,7 +526

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 434370.
abrachet marked an inline comment as done.
abrachet added a comment.

- Fix bazel build, `llvm-driver` can't be built by bazel, but the existing 
tools which lost their `main` will still work.
- Remove `--version`
- Fix `dsymutil` not depending on `DsymutilTableGen` which caused a dependency 
ordering problem on the bots


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -2594,12 +2594,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "dsymutil_main",
+src = "cmake/driver-template.cpp.in",
+out = "dsymutil_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "dsymutil"
+},
+)
+
 cc_binary(
 name = "dsymutil",
 srcs = glob([
 "tools/dsymutil/*.cpp",
 "tools/dsymutil/*.h",
-]),
+]) + ["dsymutil_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2689,12 +2698,21 @@
 ],
 )
 
+template_rule(
+name = "ar_main",
+src = "cmake/driver-template.cpp.in",
+out = "ar_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_ar"
+},
+)
+
 cc_binary(
 name = "llvm-ar",
 srcs = glob([
 "tools/llvm-ar/*.cpp",
 "tools/llvm-ar/*.h",
-]),
+]) + ["ar_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2882,12 +2900,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "cxxfilt_main",
+src = "cmake/driver-template.cpp.in",
+out = "cxxfilt_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_cxxfilt"
+},
+)
+
 cc_binary(
 name = "llvm-cxxfilt",
 srcs = glob([
 "tools/llvm-cxxfilt/*.cpp",
 "tools/llvm-cxxfilt/*.h",
-]),
+]) + ["cxxfilt_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -3416,12 +3443,22 @@
 ],
 )
 
+template_rule(
+name = "objcopy_main",
+src = "cmake/driver-template.cpp.in",
+out = "objcopy_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_objcopy"
+},
+)
+
+
 cc_binary(
 name = "llvm-objcopy",
 srcs = glob([
 "tools/llvm-objcopy/*.cpp",
 "tools/llvm-objcopy/*.h",
-]),
+]) + ["objcopy_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -5,6 +5,7 @@
 load("//llvm:tblgen.bzl", "gentbl")
 load("//llvm:binary_alias.bzl", "binary_alias")
 load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
+load("//llvm:template_rule.bzl", "template_rule")
 
 package(
 default_visibility = ["//visibility:public"],
@@ -1925,12 +1926,21 @@
 ],
 )
 
+template_rule(
+name = "clang_main",
+src = "//llvm:cmake/driver-template.cpp.in",
+out = "clang_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "clang"
+},
+)
+
 cc_library(
 name = "clang-driver",
 srcs = glob([
 "tools/driver/*.cpp",
 "tools/driver/*.h",
-]),
+]) + ["clang_main.cpp"],
 copts = [
 # Disable stack frame size checks in the driver because
 # clang::ensureStackAddressSpace allocates a large array on the stack.
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(i

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 2 inline comments as done.
abrachet added inline comments.



Comment at: llvm/cmake/modules/AddLLVM.cmake:2030
+string(REPLACE "-" "_" key ${link_name})
+string(REPLACE "+" "p" key ${key})
+string(REPLACE "llvm-" "" tool_name ${link_name})

phosek wrote:
> Alternative substitution for `+` would be `x` which is used elsewhere in 
> LLVM, for example `libcxx`, `libcxxabi` or `cxxfilt`.
Upon closer inspection we are no longer using that parameter of the macro, so I 
have removed it.



Comment at: llvm/tools/llvm-driver/llvm-driver.cpp:50
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+if (Argc < 2)

MaskRay wrote:
> abrachet wrote:
> > MaskRay wrote:
> > > Some distributions may want to use something like llvm-15. See some 
> > > binary utilities how the version is handled.
> > Thank's I've taken this from objcopy's code
> The format of `cl::PrintVersionMessage();` is not so good for user-facing 
> tools. Consider omitting it.
> 
> `llvm-objcopy --version` should probably use a style similar to `clang 
> --version` but the priority isn't high.
I've just removed `--version` completely for now. I don't think it is that 
pressing. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

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


[PATCH] D126757: Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl

2022-06-05 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a reviewer: sammccall.
nridge added a subscriber: sammccall.
nridge added a comment.

Thanks, the patch looks good to me, but someone else should probably take a 
look and approve.

Adding @sammccall who has looked at RecursiveASTVisitor recently in D120498 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126757/new/

https://reviews.llvm.org/D126757

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


[PATCH] D119646: [clang] Allow consteval functions in default arguments

2022-06-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu commandeered this revision.
ChuanqiXu edited reviewers, added: Izaron; removed: ChuanqiXu.
ChuanqiXu added a comment.

Given this is close to complete and @Izaron is not active recently, let me take 
this over. The authority would be remained, of course.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119646/new/

https://reviews.llvm.org/D119646

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


[PATCH] D119646: [clang] Allow consteval functions in default arguments

2022-06-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 434373.
ChuanqiXu added a comment.

Add release notes.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119646/new/

https://reviews.llvm.org/D119646

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -651,6 +651,27 @@
 
 } // namespace value_dependent
 
+namespace default_argument {
+
+// Previously calls of consteval functions in default arguments were rejected.
+// Now we show that we don't reject such calls.
+consteval int foo() { return 1; }
+consteval int bar(int i = foo()) { return i * i; }
+
+struct Test1 {
+  Test1(int i = bar(13)) {}
+  void v(int i = bar(13) * 2 + bar(15)) {}
+};
+Test1 t1;
+
+struct Test2 {
+  constexpr Test2(int i = bar()) {}
+  constexpr void v(int i = bar(bar(bar(foo() {}
+};
+Test2 t2;
+
+} // namespace default_argument
+
 namespace PR50779 {
 struct derp {
   int b = 0;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19611,6 +19611,12 @@
 Inherited::Visit(E);
   }
 
+  void VisitConstantExpr(ConstantExpr *E) {
+// Don't mark declarations within a ConstantExpression, as this expression
+// will be evaluated and folded to a value.
+return;
+  }
+
   void VisitDeclRefExpr(DeclRefExpr *E) {
 // If we were asked not to visit local variables, don't.
 if (SkipLocalVariables) {
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -2867,7 +2867,8 @@
 
   Expr *Arg = getInit();
   if (auto *E = dyn_cast_or_null(Arg))
-return E->getSubExpr();
+if (!isa(E))
+  return E->getSubExpr();
 
   return Arg;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -163,6 +163,8 @@
 - Unscoped and scoped enumeration types can no longer be initialized from a
   brace-init-list containing a single element of a different scoped enumeration
   type.
+- Clang will allow constexpr function in default argument. This fixes
+  `Issue 48230 `_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -651,6 +651,27 @@
 
 } // namespace value_dependent
 
+namespace default_argument {
+
+// Previously calls of consteval functions in default arguments were rejected.
+// Now we show that we don't reject such calls.
+consteval int foo() { return 1; }
+consteval int bar(int i = foo()) { return i * i; }
+
+struct Test1 {
+  Test1(int i = bar(13)) {}
+  void v(int i = bar(13) * 2 + bar(15)) {}
+};
+Test1 t1;
+
+struct Test2 {
+  constexpr Test2(int i = bar()) {}
+  constexpr void v(int i = bar(bar(bar(foo() {}
+};
+Test2 t2;
+
+} // namespace default_argument
+
 namespace PR50779 {
 struct derp {
   int b = 0;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19611,6 +19611,12 @@
 Inherited::Visit(E);
   }
 
+  void VisitConstantExpr(ConstantExpr *E) {
+// Don't mark declarations within a ConstantExpression, as this expression
+// will be evaluated and folded to a value.
+return;
+  }
+
   void VisitDeclRefExpr(DeclRefExpr *E) {
 // If we were asked not to visit local variables, don't.
 if (SkipLocalVariables) {
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -2867,7 +2867,8 @@
 
   Expr *Arg = getInit();
   if (auto *E = dyn_cast_or_null(Arg))
-return E->getSubExpr();
+if (!isa(E))
+  return E->getSubExpr();
 
   return Arg;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -163,6 +163,8 @@
 - Unscoped and scoped enumeration types can no longer be initialized from a
   brace-init-list containing a single element of a different scoped enumeration
   type.
+- Clang will allow constexpr function in default argument. This fixes
+  `Issue 48230 `_.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lis

[PATCH] D126959: [C++20][Modules] Introduce an implementation module.

2022-06-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Lex/ModuleMap.cpp:910
+  return Result;
+}
+

The implementation looks similar to `createModuleForInterfaceUnit` really. It 
looks better to refactor it to `createModuleUnits` (or 
createModuleForCXX20Modules)  which containing an additional argument 
`Module::ModuleKind`. It would optimize the case for partitions too, which uses 
`createModuleForInterfaceUnit ` now and it is a little bit odd.



Comment at: clang/lib/Sema/SemaModule.cpp:306
+  Path[0].second);
+  // now create the implementation module
+  Mod = Map.createModuleForImplementationUnit(ModuleLoc, ModuleName,

I feel like the 3 comments are redundant.



Comment at: clang/lib/Sema/SemaModule.cpp:348-352
+  // We already potentially made an implicit import (in the case of a module
+  // implementation unit importing its interface).  Make this module visible
+  // and return the import decl to be added to the current TU.
+  if (Import)
+VisibleModules.setVisible(Import->getImportedModule(), ModuleLoc);

We could move this logic to the place `Import` is created.



Comment at: clang/lib/Sema/SemaModule.cpp:355-357
+  // If we made an implicit import of the module interface, then return the
+  // imported module decl.
+  return Import ? ConvertDeclToDeclGroup(Import) : nullptr;

Is it necessary/helpful to return the import declaration? Although there is a 
FIXME, I think the current method looks a little bit confusing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126959/new/

https://reviews.llvm.org/D126959

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


[PATCH] D125095: [Clang][AIX] Add .ref in frontend for AIX XCOFF to support `-bcdtors:csect` linker option

2022-06-05 Thread Ting Wang via Phabricator via cfe-commits
tingwang added a comment.

In D125095#3552451 , @shchenz wrote:

> Thanks for doing this. I am not familiar with the frontend, so I may be 
> wrong/stupid in the follow comments : )
> Hope other experts like @hubert.reinterpretcast can give more meaningful 
> comments.
>
> I tested on AIX, seems for static variable `static int x = foo();` in global 
> scope, even compile with `-bcdtors:csect`, the init function also will not be 
> eliminated. Could you please give an example to show why we need the new 
> associated metadata for this case? Thanks.

Here is one example to show:

TEST_FOLDER=/tmp/test
mkdir -p $TEST_FOLDER
cd $TEST_FOLDER
cat > libbar.cc < libbaz.cc <
struct A {

  ~A() { puts("struct A ~A() 2"); }
  static A instance;

};

template  A A::instance;
void *zap() { return &A<>::instance; }

EOF

cat > uselib.cc <

int main(void) {

  void *handle = dlopen("./libbaz.so", RTLD_NOW | RTLD_LOCAL);
  dlclose(handle);

}
EOF

g++
===

XLC=g++
$XLC -fno-exceptions -c libbar.cc
rm -f libbar.a
ar qs libbar.a libbar.o
ranlib libbar.a
$XLC -fno-exceptions -c libbaz.cc
$XLC -shared -o libbaz.so libbaz.o libbar.a
$XLC -fno-exceptions -ldl uselib.cc -o uselib -ldl
./uselib 
foo
struct A ~A() 2

XLC 16.1.0
==

XLC=/gsa/rtpgsa/projects/x/xlcmpbld/run/vacpp/16.1.0/aix/daily/191109/bin/xlclang++
$XLC -g -qnoeh -qfuncsect -c libbar.cc
rm -f libbar.a
ar qs libbar.a libbar.o
ranlib libbar.a
$XLC -g -qnoeh -qfuncsect -c libbaz.cc
$XLC -g -qtwolink -G -o libbaz.so libbaz.o libbar.a
$XLC -g -qnoeh uselib.cc -o uselib
./uselib 
foo
struct A ~A() 2

clang++ baseline


XLC=/home/tingwa/repo/llvm-project-base/dev/build/bin/clang++
$XLC -g -fignore-exceptions -ffunction-sections -c libbar.cc
rm -f libbar.a
ar qs libbar.a libbar.o
ranlib libbar.a
$XLC -g -fignore-exceptions -ffunction-sections -c libbaz.cc
$XLC -g -bcdtors:csect -shared -Wl,-G -o libbaz.so libbaz.o libbar.a
$XLC -g -fignore-exceptions uselib.cc -o uselib
./uselib
struct A ~A() 2

clang++ .ref


XLC=/home/tingwa/repo/llvm-project-12514-BE/dev/build/bin/clang++
$XLC -g -fignore-exceptions -ffunction-sections -c libbar.cc
rm -f libbar.a
ar qs libbar.a libbar.o
ranlib libbar.a
$XLC -g -fignore-exceptions -ffunction-sections -c libbaz.cc
$XLC -g -bcdtors:csect -shared -Wl,-G -o libbaz.so libbaz.o libbar.a
$XLC -g -fignore-exceptions uselib.cc -o uselib
./uselib 
foo
struct A ~A() 2

As shown in this example: without .ref association, clang++ baseline case will 
be wrong, since globalVar is updated in the init function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125095/new/

https://reviews.llvm.org/D125095

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


[PATCH] D126959: [C++20][Modules] Introduce an implementation module.

2022-06-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D126959#3556115 , @iains wrote:

> In D126959#3556074 , @tahonermann 
> wrote:
>
>>> Implementation modules are never serialized (-emit-module-interface for an 
>>> implementation unit is diagnosed and rejected).
>>
>> Never? Or just not via -emit-module-interface? I would expect to be able to 
>> serialize via -emit-ast.
>
> My current intent is that this is a implementation detail (a mechanism for 
> maintaining the module purview and type for Sema and CG).
>
> As things stand, I do not think we are set up to handle (de-)serialization of 
> two kinds of module with the same name, so I'd prefer to defer
> possible extension to allow this for now (not against the principle, just 
> trying avoid a rabbit hole that's tangential to the current purpose).

I think Iain's "(de-)serialization" means "generating PCM files". And it makes 
no sense to block users to use `emit-ast` for implementation units. I don't 
think we have divergence here since I don't find codes which try to emit an 
error if we are attempting to generate a PCM file for an implementation unit.

---

I feel better if we could add some tests:

- As mentioned above, emit an error when we trying to generate a PCM file for 
an implementation unit.
- Currently, when we use implementation units, we need to specify 
`-fmodule-file=/path/to/the/pcm/of/primary/interface` in the command line. It 
looks like we could omit it after the patch (as long as the PCM file of primary 
interface lives in the path specified by `-fprebuilt-module-path`)




Comment at: clang/lib/Frontend/FrontendActions.cpp:835
+  case Module::ModuleImplementationUnit:
+return "Implementation Unit (should never be serialized)";
   case Module::ModulePartitionInterface:

Since `ModuleKindName()` here is used as a helpful for printers, it looks odd 
to contain the `should never be serialized` part. I think we should check this 
when we try to generate PCM files for ModuleImplementationUnit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126959/new/

https://reviews.llvm.org/D126959

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


[PATCH] D127082: Add Macro Expansion to Hover

2022-06-05 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz created this revision.
daiyousei-qz added reviewers: nridge, sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
daiyousei-qz requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This patch adds macro expansion preview to hover info. Basically, the refactor 
infrastructure for expanding macro is used for this purpose. The following 
steps are added to getHoverContents for macros:

1. calling AST.getTokens().expansionStartingAt(...) to get expanded tokens
2. calling reformat(...) to format expanded tokens

Some opinions are wanted:

1. Should we present macro expansion before definition in the hover card?
2. Should we truncate/ignore macro expansion if it's too long?

Also, some limitation applies:

1. Expansion isn't available in macro definition/arguments as the refactor code 
action isn't either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127082

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -478,15 +478,46 @@
  HI.Definition = "Foo";
}},
 
-  // macro
+  // variable-like macro
+  {R"cpp(
+#define MACRO 41
+int x = [[MAC^RO]];
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "MACRO";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define MACRO 41";
+ HI.MacroExpansion = "41";
+   }},
+
+  // function-like macro
   {R"cpp(
 // Best MACRO ever.
-#define MACRO(x,y,z) void foo(x, y, z);
+#define MACRO(x,y,z) void foo(x, y, z)
 [[MAC^RO]](int, double d, bool z = false);
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "MACRO", HI.Kind = index::SymbolKind::Macro,
- HI.Definition = "#define MACRO(x, y, z) void foo(x, y, z);";
+ HI.Name = "MACRO";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define MACRO(x, y, z) void foo(x, y, z)";
+ HI.MacroExpansion = "void foo(int, double d, bool z = false)";
+   }},
+
+  // nested macro
+  {R"cpp(
+#define STRINGIFY_AUX(s) #s
+#define STRINGIFY(s) STRINGIFY_AUX(s)
+#define DECL_STR(NAME, VALUE) const char *v_##NAME = STRINGIFY(VALUE)
+#define FOO 41
+
+[[DECL^_STR]](foo, FOO);
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "DECL_STR";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define DECL_STR(NAME, VALUE) const char *v_##NAME = "
+ "STRINGIFY(VALUE)";
+ HI.MacroExpansion = "const char *v_foo = \"41\"";
}},
 
   // constexprs
@@ -1070,6 +1101,7 @@
 EXPECT_EQ(H->Kind, Expected.Kind);
 EXPECT_EQ(H->Documentation, Expected.Documentation);
 EXPECT_EQ(H->Definition, Expected.Definition);
+EXPECT_EQ(H->MacroExpansion, Expected.MacroExpansion);
 EXPECT_EQ(H->Type, Expected.Type);
 EXPECT_EQ(H->ReturnType, Expected.ReturnType);
 EXPECT_EQ(H->Parameters, Expected.Parameters);
@@ -1567,6 +1599,7 @@
 HI.Name = "MACRO";
 HI.Kind = index::SymbolKind::Macro;
 HI.Definition = "#define MACRO 0";
+HI.MacroExpansion = "0";
   }},
   {
   R"cpp(// Macro
@@ -1577,6 +1610,8 @@
 HI.Name = "MACRO";
 HI.Kind = index::SymbolKind::Macro;
 HI.Definition = "#define MACRO 0";
+// FIXME: expansion of MACRO isn't available in macro
+// definition/arguments
   }},
   {
   R"cpp(// Macro
@@ -1591,6 +1626,7 @@
 HI.Definition =
 R"cpp(#define MACRO  \
   { return 0; })cpp";
+HI.MacroExpansion = "{ return 0; }";
   }},
   {
   R"cpp(// Forward class declaration
@@ -2625,6 +2661,7 @@
 EXPECT_EQ(H->Kind, Expected.Kind);
 EXPECT_EQ(H->Documentation, Expected.Documentation);
 EXPECT_EQ(H->Definition, Expected.Definition);
+EXPECT_EQ(H->MacroExpansion, Expected.MacroExpansion);
 EXPECT_EQ(H->Type, Expected.Type);
 EXPECT_EQ(H->ReturnType, Expected.ReturnType);
 EXPECT_EQ(H->Parameters, Expected.Parameters);
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -71,6 +71,7 @@
   std::string Documentation;
   /// Source code containing the definition of the symbol.
   std::string Definition;
+  std::string MacroExpansion;
   const char *DefinitionLanguage = "cpp";

[clang] f06abbb - LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via cfe-commits

Author: Chris Bieneman
Date: 2022-06-06T04:27:32Z
New Revision: f06abbb393800b0d466c88e283c06f75561c432c

URL: 
https://github.com/llvm/llvm-project/commit/f06abbb393800b0d466c88e283c06f75561c432c
DIFF: 
https://github.com/llvm/llvm-project/commit/f06abbb393800b0d466c88e283c06f75561c432c.diff

LOG: LLVM Driver Multicall tool

This patch adds an llvm-driver multicall tool that can combine multiple
LLVM-based tools. The build infrastructure is enabled for a tool by
adding the GENERATE_DRIVER option to the add_llvm_executable CMake
call, and changing the tool's main function to a canonicalized
tool_name_main format (i.e. llvm_ar_main, clang_main, etc...).

As currently implemented llvm-driver contains dsymutil, llvm-ar,
llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the
build).

llvm-driver can be enabled from builds by setting
LLVM_TOOL_LLVM_DRIVER_BUILD=On.

There are several limitations in the current implementation, which can
be addressed in subsequent patches:

(1) the multicall binary cannot currently properly handle
multi-dispatch tools. This means symlinking llvm-ranlib to llvm-driver
will not properly result in llvm-ar's main being called.
(2) the multicall binary cannot be comprised of tools containing
conflicting cl::opt options as the global cl::opt option list cannot
contain duplicates.

These limitations can be addressed in subsequent patches.

Differential revision: https://reviews.llvm.org/D109977

Added: 
llvm/cmake/driver-template.cpp.in
llvm/test/tools/llvm-driver/help-passthrough.test
llvm/test/tools/llvm-driver/help.test
llvm/test/tools/llvm-driver/symlink-call.test
llvm/tools/llvm-driver/CMakeLists.txt
llvm/tools/llvm-driver/llvm-driver.cpp

Modified: 
clang/cmake/modules/AddClang.cmake
clang/tools/driver/CMakeLists.txt
clang/tools/driver/driver.cpp
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/Support/Path.cpp
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc
llvm/test/CMakeLists.txt
llvm/test/lit.cfg.py
llvm/test/lit.site.cfg.py.in
llvm/tools/CMakeLists.txt
llvm/tools/dsymutil/CMakeLists.txt
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-ar/CMakeLists.txt
llvm/tools/llvm-ar/llvm-ar.cpp
llvm/tools/llvm-cxxfilt/CMakeLists.txt
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-objcopy/CMakeLists.txt
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
utils/bazel/llvm-project-overlay/clang/BUILD.bazel
utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 9bbbfc032b7df..299f8ce6e2fb4 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -184,5 +184,8 @@ function(clang_target_link_libraries target type)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
+  if (TARGET obj.${target})
+target_link_libraries(obj.${target} ${ARGN})
+  endif()
 
 endfunction()

diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 6b3e159d1b648..d05b71db13f21 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -31,6 +31,7 @@ add_clang_tool(clang
   DEPENDS
   intrinsics_gen
   ${support_plugins}
+  GENERATE_DRIVER
   )
 
 clang_target_link_libraries(clang

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index d361457f8cecd..fa1f09b44f4da 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -327,7 +327,7 @@ static int ExecuteCC1Tool(SmallVectorImpl 
&ArgV) {
   return 1;
 }
 
-int main(int Argc, const char **Argv) {
+int clang_main(int Argc, char **Argv) {
   noteBottomOfStack();
   llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 1effbde06b80e..fab16edd7d532 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -269,6 +269,8 @@ include(VersionFromVCS)
 option(LLVM_APPEND_VC_REV
   "Embed the version control system revision in LLVM" ON)
 
+option(LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" 
OFF)
+
 set(PACKAGE_NAME LLVM)
 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
 set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/";)

diff  --git a/llvm/cmake/driver-template.cpp.in 
b/llvm/cmake/driver-template.cpp.in
new file mode 100644
index 0..2164fb00d168f
--- /dev/null
+++ b/llvm/cmake/driver-template.cpp.in
@@ -0,0 +1,11 @@
+//===-- driver-template.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
abrachet marked 2 inline comments as done.
Closed by commit rGf06abbb39380: LLVM Driver Multicall tool (authored by beanz, 
committed by abrachet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -2594,12 +2594,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "dsymutil_main",
+src = "cmake/driver-template.cpp.in",
+out = "dsymutil_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "dsymutil"
+},
+)
+
 cc_binary(
 name = "dsymutil",
 srcs = glob([
 "tools/dsymutil/*.cpp",
 "tools/dsymutil/*.h",
-]),
+]) + ["dsymutil_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2689,12 +2698,21 @@
 ],
 )
 
+template_rule(
+name = "ar_main",
+src = "cmake/driver-template.cpp.in",
+out = "ar_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_ar"
+},
+)
+
 cc_binary(
 name = "llvm-ar",
 srcs = glob([
 "tools/llvm-ar/*.cpp",
 "tools/llvm-ar/*.h",
-]),
+]) + ["ar_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2882,12 +2900,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "cxxfilt_main",
+src = "cmake/driver-template.cpp.in",
+out = "cxxfilt_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_cxxfilt"
+},
+)
+
 cc_binary(
 name = "llvm-cxxfilt",
 srcs = glob([
 "tools/llvm-cxxfilt/*.cpp",
 "tools/llvm-cxxfilt/*.h",
-]),
+]) + ["cxxfilt_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -3416,12 +3443,22 @@
 ],
 )
 
+template_rule(
+name = "objcopy_main",
+src = "cmake/driver-template.cpp.in",
+out = "objcopy_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_objcopy"
+},
+)
+
+
 cc_binary(
 name = "llvm-objcopy",
 srcs = glob([
 "tools/llvm-objcopy/*.cpp",
 "tools/llvm-objcopy/*.h",
-]),
+]) + ["objcopy_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -5,6 +5,7 @@
 load("//llvm:tblgen.bzl", "gentbl")
 load("//llvm:binary_alias.bzl", "binary_alias")
 load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
+load("//llvm:template_rule.bzl", "template_rule")
 
 package(
 default_visibility = ["//visibility:public"],
@@ -1925,12 +1926,21 @@
 ],
 )
 
+template_rule(
+name = "clang_main",
+src = "//llvm:cmake/driver-template.cpp.in",
+out = "clang_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "clang"
+},
+)
+
 cc_library(
 name = "clang-driver",
 srcs = glob([
 "tools/driver/*.cpp",
 "tools/driver/*.h",
-]),
+]) + ["clang_main.cpp"],
 copts = [
 # Disable stack frame size checks in the driver because
 # clang::ensureStackAddressSpace allocates a large array on the stack.
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   

[PATCH] D126757: [AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl

2022-06-05 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks Richard for the review!

@daiyousei-qz would you like me to commit the patch for you? (If so, I need a 
name + email for attribution, there doesn't seem to be one in the revision 
metadata.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126757/new/

https://reviews.llvm.org/D126757

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


[clang] 448995c - [NFC] [Coroutines] Add test for ambiguous allocation functions in

2022-06-05 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-06-06T14:23:35+08:00
New Revision: 448995c521b5ccef71d063bb80f084138ac9d352

URL: 
https://github.com/llvm/llvm-project/commit/448995c521b5ccef71d063bb80f084138ac9d352
DIFF: 
https://github.com/llvm/llvm-project/commit/448995c521b5ccef71d063bb80f084138ac9d352.diff

LOG: [NFC] [Coroutines] Add test for ambiguous allocation functions in
promise_type

Address the post-commit comment in
https://reviews.llvm.org/D125517#inline-1217244

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp
clang/test/SemaCXX/coroutine-allocs.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 55f1c2989578d..a738befdd6cea 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1324,7 +1324,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
   bool PassAlignment = false;
   SmallVector PlacementArgs;
 
-  bool PromiseContainNew = [this, &PromiseType]() -> bool {
+  bool PromiseContainsNew = [this, &PromiseType]() -> bool {
 DeclarationName NewName =
 S.getASTContext().DeclarationNames.getCXXOperatorName(OO_New);
 LookupResult R(S, NewName, Loc, Sema::LookupOrdinaryName);
@@ -1343,7 +1343,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
 // - If no declarations are found in the scope of the promise type, a 
search
 // is performed in the global scope.
 Sema::AllocationFunctionScope NewScope =
-PromiseContainNew ? Sema::AFS_Class : Sema::AFS_Global;
+PromiseContainsNew ? Sema::AFS_Class : Sema::AFS_Global;
 S.FindAllocationFunctions(Loc, SourceRange(),
   NewScope,
   /*DeleteScope*/ Sema::AFS_Both, PromiseType,
@@ -1354,7 +1354,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
   // We don't expect to call to global operator new with (size, p0, …, pn).
   // So if we choose to lookup the allocation function in global scope, we
   // shouldn't lookup placement arguments.
-  if (PromiseContainNew && !collectPlacementArgs(S, FD, Loc, PlacementArgs))
+  if (PromiseContainsNew && !collectPlacementArgs(S, FD, Loc, PlacementArgs))
 return false;
 
   LookupAllocationFunction();
@@ -1363,7 +1363,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
   //   If no viable function is found ([over.match.viable]), overload 
resolution
   // is performed again on a function call created by passing just the amount 
of
   // space required as an argument of type std::size_t.
-  if (!OperatorNew && !PlacementArgs.empty() && PromiseContainNew) {
+  if (!OperatorNew && !PlacementArgs.empty() && PromiseContainsNew) {
 PlacementArgs.clear();
 LookupAllocationFunction();
   }
@@ -1386,7 +1386,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
   }
 
   if (!OperatorNew) {
-if (PromiseContainNew)
+if (PromiseContainsNew)
   S.Diag(Loc, diag::err_coroutine_unusable_new) << PromiseType << &FD;
 
 return false;

diff  --git a/clang/test/SemaCXX/coroutine-allocs.cpp 
b/clang/test/SemaCXX/coroutine-allocs.cpp
index 4ffb080c9828f..c9797208e2dc5 100644
--- a/clang/test/SemaCXX/coroutine-allocs.cpp
+++ b/clang/test/SemaCXX/coroutine-allocs.cpp
@@ -19,7 +19,7 @@ struct resumable {
   };
 };
 
-resumable f1() { // expected-error {{'operator new' provided by 
'std::coroutine_traits::promise_type' (aka 
'resumable::promise_type') is not usable}}
+resumable f1() { // expected-error {{'operator new' provided by 
'std::coroutine_traits::promise_type' (aka 
'resumable::promise_type') is not usable with the function signature of 'f1'}}
   co_return;
 }
 
@@ -37,7 +37,7 @@ resumable f1() { // expected-error {{'operator new' provided 
by 'std::coroutine_
 //   The first argument is the amount of space requested, and has type 
std::size_­t.
 //   The lvalues p1…pn are the succeeding arguments.
 //
-// So the acctual type passed to resumable::promise_type::operator new is 
lvalue
+// So the actual type passed to resumable::promise_type::operator new is lvalue
 // Allocator. It is allowed  to convert a lvalue to a lvalue reference. So the 
 // following one is valid.
 resumable f2(Allocator &&) {
@@ -59,3 +59,25 @@ resumable f5(const Allocator) { // expected-error {{operator 
new' provided by 's
 resumable f6(const Allocator &) { // expected-error {{operator new' provided 
by 'std::coroutine_traits::promise_type' (aka 
'resumable::promise_type') is not usable}}
   co_return;
 }
+
+struct promise_base1 {
+  void *operator new(std::size_t sz); // expected-note {{member found by 
ambiguous name lookup}}
+};
+
+struct promise_base2 {
+  void *operator new(std::size_t sz); // expected-note {{member found by 
ambiguous name lookup}}
+};
+
+struct resumable2 {
+  struct promise_type : public promise_base1, public promise_base2 {
+resumable2 get_return_object() { return {}; }
+auto initial_suspend() { ret

[PATCH] D125517: [Frontend] [Coroutines] Emit error when we found incompatible allocation function in promise_type

2022-06-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked an inline comment as done.
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1320
+
+return !R.empty() && !R.isAmbiguous();
+  }();

rsmith wrote:
> I don't see any tests covering the case where the lookup is ambiguous. Eg, 
> you find `operator new` in two different base classes of the promise type. 
> Please can you add one?
Sure. I've addressed this in 
https://github.com/llvm/llvm-project/commit/448995c521b5ccef71d063bb80f084138ac9d352



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1337
+
+  LookupAllocationFunction();
 

rsmith wrote:
> This is no longer correct given [the resolution of 
> DR2585](https://wiki.edg.com/pub/Wg21telecons2022/Teleconference2022-06-03/cwg_active.html#2585):
>  the function arguments should only be passed to a class-scope allocation 
> function, not to a global one.
> 
> The logic should be:
> 
> 1) See if there's any class-scope allocation functions. If so, form an 
> argument list based on the function's parameters and try looking for an 
> allocation function. If that succeeds, we're done.
> 2) Try looking for an allocation function in class scope (if there were any 
> class-scope allocation functions) or in global scope (if not), passing just 
> the size argument.
Yeah. This is addressed in 
https://github.com/llvm/llvm-project/commit/a1ffba8d528681d55c901a997beedbc69946eb90



Comment at: clang/test/SemaCXX/coroutine-allocs.cpp:22
+
+resumable f1() { // expected-error {{'operator new' provided by 
'std::coroutine_traits::promise_type' (aka 
'resumable::promise_type') is not usable}}
+  co_return;

rsmith wrote:
> Please can you include a complete error including the "with the function 
> signature of 'f1'" part?
> 
> I also wonder if there's some way we can get a candidate list included here.
Done. It should be possible and helpful to add a candidate list here. But it 
might be fine in practice since promise_type wouldn't contain too many 
allocation functions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125517/new/

https://reviews.llvm.org/D125517

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


[PATCH] D126757: [AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl

2022-06-05 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

Yes, please do so. I'm using the web interface since the arc tool isn't very 
friendly to Windows user :(

Name: Qingyuan Zheng
Email: qyzhe...@outlook.com


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126757/new/

https://reviews.llvm.org/D126757

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


[clang-tools-extra] c119a17 - [AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl

2022-06-05 Thread Nathan Ridge via cfe-commits

Author: Qingyuan Zheng
Date: 2022-06-06T02:35:34-04:00
New Revision: c119a17e7fd6fb528d8c1e1bbb0ad1fac93f896a

URL: 
https://github.com/llvm/llvm-project/commit/c119a17e7fd6fb528d8c1e1bbb0ad1fac93f896a
DIFF: 
https://github.com/llvm/llvm-project/commit/c119a17e7fd6fb528d8c1e1bbb0ad1fac93f896a.diff

LOG: [AST] Fix clang RecursiveASTVisitor for definition of 
XXXTemplateSpecializationDecl

Fixes https://github.com/clangd/clangd/issues/1132
where clangd's semantic highlighting is missing for symbols of a template
specialization definition. It turns out the visitor didn't traverse the
base classes of Class/Var##TemplateSpecializationDecl, i.e.
CXXRecordDecl/VarDecl. This patch adds them back as what is done in
DEF_TRAVERSE_TMPL_PART_SPEC_DECL.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D126757

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang/include/clang/AST/RecursiveASTVisitor.h

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 2f4e8e57a81f1..f60c62500c7de 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -807,6 +807,19 @@ sizeof...($TemplateParameter[[Elements]]);
 $Function_deprecated[[Foo]]($Parameter[[x]]); 
 $Function_deprecated[[Foo]]($Parameter[[x]]); 
 }
+  )cpp",
+  // Explicit template specialization
+  R"cpp(
+struct $Class_decl[[Base]]{};
+template 
+struct $Class_decl[[S]] : public $Class[[Base]] {};
+template <> 
+struct $Class_decl[[S]] : public $Class[[Base]] {};
+
+template 
+$TemplateParameter[[T]] $Variable_decl[[x]] = {};
+template <>
+int $Variable_decl[[x]] = (int)sizeof($Class[[Base]]);
   )cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index ae6442d75dd4b..c6d74d94194bd 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2021,7 +2021,7 @@ DEF_TRAVERSE_DECL(RecordDecl, { 
TRY_TO(TraverseRecordHelper(D)); })
 
 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
 
-#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)  
\
+#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {
\
 /* For implicit instantiations ("set x;"), we don't want to   
\
recurse at all, since the instatiated template isn't written in 
\
@@ -2034,18 +2034,23 @@ DEF_TRAVERSE_DECL(CXXRecordDecl, { 
TRY_TO(TraverseCXXRecordHelper(D)); })
 if (TypeSourceInfo *TSI = D->getTypeAsWritten())   
\
   TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));  
\

\
-TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));  
\
-if (!getDerived().shouldVisitTemplateInstantiations() &&   
\
-D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization)  
\
+if (getDerived().shouldVisitTemplateInstantiations() ||
\
+D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
\
+  /* Traverse base definition for explicit specializations */  
\
+  TRY_TO(Traverse##DECLKIND##Helper(D));   
\
+} else {   
\
+  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
\
+   
\
   /* Returning from here skips traversing the  
\
  declaration context of the *TemplateSpecializationDecl
\
  (embedded in the DEF_TRAVERSE_DECL() macro)   
\
  which contains the instantiated members of the template. */   
\
   return true; 
\
+}  
\
   })
 
-DEF_TRAVERSE_TMPL_SPEC_DECL(Class)
-DEF_TRAVERSE_TMPL_SPEC_DECL(Var)
+DEF_TRAVERSE_TMPL_SPEC_DECL(Class, CXXRecord)
+DEF_TRAVERSE_TMPL_SPEC_DECL(Var, Var)
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(



___
cfe-commits mailing list
cfe-co

[PATCH] D126757: [AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl

2022-06-05 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc119a17e7fd6: [AST] Fix clang RecursiveASTVisitor for 
definition of… (authored by daiyousei-qz, committed by nridge).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126757/new/

https://reviews.llvm.org/D126757

Files:
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang/include/clang/AST/RecursiveASTVisitor.h


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2021,7 +2021,7 @@
 
 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
 
-#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)  
\
+#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {
\
 /* For implicit instantiations ("set x;"), we don't want to   
\
recurse at all, since the instatiated template isn't written in 
\
@@ -2034,18 +2034,23 @@
 if (TypeSourceInfo *TSI = D->getTypeAsWritten())   
\
   TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));  
\

\
-TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));  
\
-if (!getDerived().shouldVisitTemplateInstantiations() &&   
\
-D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization)  
\
+if (getDerived().shouldVisitTemplateInstantiations() ||
\
+D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
\
+  /* Traverse base definition for explicit specializations */  
\
+  TRY_TO(Traverse##DECLKIND##Helper(D));   
\
+} else {   
\
+  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
\
+   
\
   /* Returning from here skips traversing the  
\
  declaration context of the *TemplateSpecializationDecl
\
  (embedded in the DEF_TRAVERSE_DECL() macro)   
\
  which contains the instantiated members of the template. */   
\
   return true; 
\
+}  
\
   })
 
-DEF_TRAVERSE_TMPL_SPEC_DECL(Class)
-DEF_TRAVERSE_TMPL_SPEC_DECL(Var)
+DEF_TRAVERSE_TMPL_SPEC_DECL(Class, CXXRecord)
+DEF_TRAVERSE_TMPL_SPEC_DECL(Var, Var)
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -807,6 +807,19 @@
 $Function_deprecated[[Foo]]($Parameter[[x]]); 
 $Function_deprecated[[Foo]]($Parameter[[x]]); 
 }
+  )cpp",
+  // Explicit template specialization
+  R"cpp(
+struct $Class_decl[[Base]]{};
+template 
+struct $Class_decl[[S]] : public $Class[[Base]] {};
+template <> 
+struct $Class_decl[[S]] : public $Class[[Base]] {};
+
+template 
+$TemplateParameter[[T]] $Variable_decl[[x]] = {};
+template <>
+int $Variable_decl[[x]] = (int)sizeof($Class[[Base]]);
   )cpp"};
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2021,7 +2021,7 @@
 
 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
 
-#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)  \
+#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {\
 /* For implicit instantiations ("set x;"), we don't want to   \
recurse at all, since the instatiated template isn't written in \
@@ -2034,18 +2034,23 @@
 if (TypeSourceInfo *TSI = D->getTypeAsWritten())   \
   TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));  \

[PATCH] D125863: [clangd] Dont mark terminating PP-directives as skipped

2022-06-05 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

I have a similar change recently presented in 
https://github.com/clangd/clangd/issues/1181 that makes all conditional 
preprocessor lines active. Please refer to the change if that's helpful :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125863/new/

https://reviews.llvm.org/D125863

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