[clang] [clang][dataflow][NFC] Move `parseAll()` to TestingSupport and rename `parseFormulas()` (PR #70437)

2023-10-27 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/70437

I'm working on a patch that will use this function from a different test.


>From 34daee21bca7dbfe906e270a88e829e6beb79c97 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Fri, 27 Oct 2023 09:27:12 +
Subject: [PATCH] [clang][dataflow][NFC] Move `parseAll()` to TestingSupport
 and rename `parseFormulas()`

I'm working on a patch that will use this function from a different test.
---
 .../Analysis/FlowSensitive/SolverTest.cpp | 30 +--
 .../Analysis/FlowSensitive/TestingSupport.cpp | 16 ++
 .../Analysis/FlowSensitive/TestingSupport.h   |  4 +++
 3 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/clang/unittests/Analysis/FlowSensitive/SolverTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
index a61e692088a8717..71f6da93594e30e 100644
--- a/clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -25,6 +25,7 @@ using namespace clang;
 using namespace dataflow;
 
 using test::ConstraintContext;
+using test::parseFormulas;
 using testing::_;
 using testing::AnyOf;
 using testing::Pair;
@@ -33,21 +34,6 @@ using testing::UnorderedElementsAre;
 constexpr auto AssignedTrue = Solver::Result::Assignment::AssignedTrue;
 constexpr auto AssignedFalse = Solver::Result::Assignment::AssignedFalse;
 
-std::vector parseAll(Arena , StringRef Lines) {
-  std::vector Result;
-  while (!Lines.empty()) {
-auto [First, Rest] = Lines.split('\n');
-Lines = Rest;
-if (First.trim().empty())
-  continue;
-if (auto F = A.parseFormula(First))
-  Result.push_back(&*F);
-else
-  ADD_FAILURE() << llvm::toString(F.takeError());
-  }
-  return Result;
-}
-
 // Checks if the conjunction of `Vals` is satisfiable and returns the
 // corresponding result.
 Solver::Result solve(llvm::ArrayRef Vals) {
@@ -277,7 +263,7 @@ TEST(SolverTest, IffWithUnits) {
 
 TEST(SolverTest, IffWithUnitsConflict) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  (V0 = V1)
  V0
  !V1
@@ -287,7 +273,7 @@ TEST(SolverTest, IffWithUnitsConflict) {
 
 TEST(SolverTest, IffTransitiveConflict) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  (V0 = V1)
  (V1 = V2)
  V2
@@ -298,7 +284,7 @@ TEST(SolverTest, IffTransitiveConflict) {
 
 TEST(SolverTest, DeMorgan) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  (!(V0 | V1) = (!V0 & !V1))
  (!(V2 & V3) = (!V2 | !V3))
   )");
@@ -307,7 +293,7 @@ TEST(SolverTest, DeMorgan) {
 
 TEST(SolverTest, RespectsAdditionalConstraints) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  (V0 = V1)
  V0
  !V1
@@ -317,7 +303,7 @@ TEST(SolverTest, RespectsAdditionalConstraints) {
 
 TEST(SolverTest, ImplicationIsEquivalentToDNF) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  !((V0 => V1) = (!V0 | V1))
   )");
   EXPECT_THAT(solve(Constraints), unsat());
@@ -325,7 +311,7 @@ TEST(SolverTest, ImplicationIsEquivalentToDNF) {
 
 TEST(SolverTest, ImplicationConflict) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  (V0 => V1)
  (V0 & !V1)
   )");
@@ -334,7 +320,7 @@ TEST(SolverTest, ImplicationConflict) {
 
 TEST(SolverTest, ReachedLimitsReflectsTimeouts) {
   Arena A;
-  auto Constraints = parseAll(A, R"(
+  auto Constraints = parseFormulas(A, R"(
  (!(V0 | V1) = (!V0 & !V1))
  (!(V2 & V3) = (!V2 & !V3))
   )");
diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
index 65c527ae63d2d71..e24ff25cb8292fb 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
+#include "gtest/gtest.h"
 #include 
 #include 
 #include 
@@ -218,3 +219,18 @@ const IndirectFieldDecl 
*test::findIndirectFieldDecl(ASTContext ,
   assert(Result != nullptr);
   return Result;
 }
+
+std::vector test::parseFormulas(Arena , StringRef Lines) {
+  std::vector Result;
+  while (!Lines.empty()) {
+auto [First, Rest] = Lines.split('\n');
+Lines = Rest;
+if (First.trim().empty())
+  continue;
+if (auto F = A.parseFormula(First))
+  Result.push_back(&*F);
+else
+  ADD_FAILURE() << llvm::toString(F.takeError());
+  }
+  return Result;
+}
diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index a8089d9b8c7a13f..100d78378695d3c 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ 

[clang] 6c3bc91 - [clang-format][NFC] Remove more extraneous newlines in unit tests

2023-10-27 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-10-27T02:22:36-07:00
New Revision: 6c3bc910588f962e49470098ccc3b13c29cae493

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

LOG: [clang-format][NFC] Remove more extraneous newlines in unit tests

Also removed a duplicate test case.

Added: 


Modified: 
clang/unittests/Format/FormatTestObjC.cpp
clang/unittests/Format/FormatTestProto.cpp
clang/unittests/Format/FormatTestSelective.cpp
clang/unittests/Format/FormatTestTableGen.cpp
clang/unittests/Format/FormatTestTextProto.cpp
clang/unittests/Format/FormatTestVerilog.cpp
clang/unittests/Format/QualifierFixerTest.cpp
clang/unittests/Format/UsingDeclarationsSorterTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTestObjC.cpp 
b/clang/unittests/Format/FormatTestObjC.cpp
index 84a3d240055ff68..cd4f9d934127bfd 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -62,35 +62,33 @@ TEST(FormatTestObjCStyle, DetectsObjCInHeaders) {
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end\n");
+  Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
   Style = getStyle("{}", "a.h", "none",
-   "const int interface = 1;\nconst int end = 2;\n");
+   "const int interface = 1;\nconst int end = 2;");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end\n");
+  Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
   Style = getStyle("{}", "a.h", "none",
-   "const int protocol = 1;\nconst int end = 2;\n");
+   "const int protocol = 1;\nconst int end = 2;");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
+  Style = getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
-  Style =
-  getStyle("{}", "a.h", "none", "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
+  Style = getStyle("{}", "a.h", "none", "typedef NS_CLOSED_ENUM(int, Foo) 
{};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
-  Style =
-  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  Style = getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
@@ -118,45 +116,43 @@ FOUNDATION_EXPORT void DoStuff(void);
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
-  Style =
-  getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
+  Style = getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); 
}");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
-  Style =
-  getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }\n");
+  Style = getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
   Style =
-  getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; 
}\n");
+  getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; }");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
   Style = getStyle("{}", "a.h", "none",
-   "inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }\n");
+   "inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
   Style = getStyle("{}", "a.h", "none",
-   "inline void Foo() { int foo[] = {1, 2, 3}; }\n");
+   "inline void Foo() { int foo[] = {1, 2, 3}; }");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
   // ObjC characteristic types.
-  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
-  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
-  Style = getStyle("{}", 

[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor (NFC) (PR #70427)

2023-10-27 Thread Kohei Asano via cfe-commits

https://github.com/khei4 updated https://github.com/llvm/llvm-project/pull/70427

>From 1ae7edddc79a0e96fd4b142d09b0752aa3d9ff85 Mon Sep 17 00:00:00 2001
From: khei4 
Date: Fri, 27 Oct 2023 17:46:34 +0900
Subject: [PATCH] use: create instead of protected Constructor

handle: expected
---
 clang/docs/LibTooling.rst | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c7..73f7deb2dd87627 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -69,9 +69,16 @@ and automatic location of the compilation database using 
source files paths.
   static llvm::cl::OptionCategory MyToolCategory("my-tool options");
 
   int main(int argc, const char **argv) {
-// CommonOptionsParser constructor will parse arguments and create a
-// CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+// CommonOptionsParser::create will parse arguments and create a
+// CompilationDatabase. In case of error it will terminate the program.
+llvm::Expected Expected =
+CommonOptionsParser::create(argc, argv, MyToolCategory);
+if (!Expected)
+{
+  llvm::errs() << Expected.takeError();
+  return 1;
+}
+CommonOptionsParser  = Expected.get();
 
 // Use OptionsParser.getCompilations() and 
OptionsParser.getSourcePathList()
 // to retrieve CompilationDatabase and the list of input file paths.

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


[clang] [Driver] Silence stdlib warning when linking C on *BSD / Solaris / Haiku (PR #70434)

2023-10-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Brad Smith (brad0)


Changes

Same as 12b87f6ef720080fab1e2d48ca2d8c5ba478ee5d

---
Full diff: https://github.com/llvm/llvm-project/pull/70434.diff


5 Files Affected:

- (modified) clang/lib/Driver/ToolChains/DragonFly.cpp (+3) 
- (modified) clang/lib/Driver/ToolChains/Haiku.cpp (+3) 
- (modified) clang/lib/Driver/ToolChains/NetBSD.cpp (+3) 
- (modified) clang/lib/Driver/ToolChains/OpenBSD.cpp (+3) 
- (modified) clang/lib/Driver/ToolChains/Solaris.cpp (+3) 


``diff
diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 500dd98665075b1..3e43652b8a307a9 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -191,6 +191,9 @@ void dragonfly::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 172f16cc46e328e..ef0fc732d2680ab 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -134,6 +134,9 @@ void haiku::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 245553d46055a27..c5c533584ad7033 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -364,6 +364,9 @@ void netbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 4e14c3d140a1da2..1dae7fff8468fad 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -269,6 +269,9 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 3d5a710842eca44..0ff8e3cc356a09a 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -286,6 +286,9 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(getLinkerPath(Args));
   C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));

``




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


[clang] [Driver] Silence stdlib warning when linking C on *BSD / Solaris / Haiku (PR #70434)

2023-10-27 Thread Brad Smith via cfe-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/70434

Same as 12b87f6ef720080fab1e2d48ca2d8c5ba478ee5d

>From 0c21090272eb3e1d6477585ef223413dc627a451 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Fri, 27 Oct 2023 05:13:59 -0400
Subject: [PATCH] [Driver] Silence stdlib warning when linking C on *BSD /
 Solaris / Haiku

Same as 12b87f6ef720080fab1e2d48ca2d8c5ba478ee5d
---
 clang/lib/Driver/ToolChains/DragonFly.cpp | 3 +++
 clang/lib/Driver/ToolChains/Haiku.cpp | 3 +++
 clang/lib/Driver/ToolChains/NetBSD.cpp| 3 +++
 clang/lib/Driver/ToolChains/OpenBSD.cpp   | 3 +++
 clang/lib/Driver/ToolChains/Solaris.cpp   | 3 +++
 5 files changed, 15 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 500dd98665075b1..3e43652b8a307a9 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -191,6 +191,9 @@ void dragonfly::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 172f16cc46e328e..ef0fc732d2680ab 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -134,6 +134,9 @@ void haiku::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 245553d46055a27..c5c533584ad7033 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -364,6 +364,9 @@ void netbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 4e14c3d140a1da2..1dae7fff8468fad 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -269,6 +269,9 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 3d5a710842eca44..0ff8e3cc356a09a 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -286,6 +286,9 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
   const char *Exec = Args.MakeArgString(getLinkerPath(Args));
   C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));

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


[clang] [clang]set invalid for lambda which missing capture `this` (PR #70432)

2023-10-27 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/70432

It can suppression further crash.
Fixes: #67687

>From c12aeb6f2a83b9cb3c3815e72d57638cf7de43a0 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Fri, 27 Oct 2023 16:51:59 +0800
Subject: [PATCH] WIP fix lambda invalid

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaExprCXX.cpp | 6 --
 clang/test/SemaCXX/gh67687.cpp | 7 +++
 3 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaCXX/gh67687.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 42f20b9a9bb0410..940dc3f22b89dc0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -507,6 +507,8 @@ Bug Fixes in This Version
   ``thread_local`` instead of ``_Thread_local``.
   Fixes (`#70068 `_) and
   (`#69167 `_)
+- Fix crash in evaluating invalid lambda expression which forget capture this.
+  Fixes (`#67687 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 1153049496d129f..6344c9102330a00 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1333,6 +1333,7 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, const 
bool Explicit,
   if (LSI && isGenericLambdaCallOperatorSpecialization(LSI->CallOperator)) 
{
 // This context can't implicitly capture 'this'; fail out.
 if (BuildAndDiagnose) {
+  LSI->CallOperator->setInvalidDecl();
   Diag(Loc, diag::err_this_capture)
   << (Explicit && idx == MaxFunctionScopesIndex);
   if (!Explicit)
@@ -1354,10 +1355,11 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, 
const bool Explicit,
 continue;
   }
   // This context can't implicitly capture 'this'; fail out.
-  if (BuildAndDiagnose)
+  if (BuildAndDiagnose) {
+LSI->CallOperator->setInvalidDecl();
 Diag(Loc, diag::err_this_capture)
 << (Explicit && idx == MaxFunctionScopesIndex);
-
+  }
   if (!Explicit)
 buildLambdaThisCaptureFixit(*this, LSI);
   return true;
diff --git a/clang/test/SemaCXX/gh67687.cpp b/clang/test/SemaCXX/gh67687.cpp
new file mode 100644
index 000..36b9ac67ca14e13
--- /dev/null
+++ b/clang/test/SemaCXX/gh67687.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++17 %s
+
+struct S {
+  int n;
+  int d = (4, []() { return n; }());  // expected-error {{'this' cannot be 
implicitly captured in this context}} \
+  // expected-note {{explicitly capture 
'this'}}
+};

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


[clang-tools-extra] [libc++] Fix complexity guarantee in ranges::clamp (PR #68413)

2023-10-27 Thread via cfe-commits

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


[clang] [libc++] Implement ranges::iota (PR #68494)

2023-10-27 Thread via cfe-commits

philnik777 wrote:

Why does the proxy not satisfy `weakly_incrementable`? Is it maybe just missing 
some member functions?

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


[clang-tools-extra] [libc++] Implement ranges::iota (PR #68494)

2023-10-27 Thread via cfe-commits

philnik777 wrote:

Why does the proxy not satisfy `weakly_incrementable`? Is it maybe just missing 
some member functions?

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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor (NFC) (PR #70427)

2023-10-27 Thread Kohei Asano via cfe-commits

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


[clang] [Driver] Handle Flang in same manner between Gnu and *BSD/Solaris ToolChain (PR #70429)

2023-10-27 Thread Brad Smith via cfe-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/70429

None

>From d8a4aecf5a22382fe57f654616fa59358477d9a4 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Fri, 27 Oct 2023 04:53:19 -0400
Subject: [PATCH] [Driver] Handle Flang in same manner between Gnu and
 *BSD/Solaris ToolChain

---
 clang/lib/Driver/ToolChains/Gnu.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2515f85432d7542..93785ca14eaf8bd 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -574,7 +574,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation , 
const JobAction ,
   // to generate executables. As Fortran runtime depends on the C runtime,
   // these dependencies need to be listed before the C runtime below (i.e.
   // AddRuntTimeLibs).
-  if (D.IsFlangMode()) {
+  if (D.IsFlangMode() &&
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
 addFortranRuntimeLibs(ToolChain, CmdArgs);
 CmdArgs.push_back("-lm");

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


[clang] [clang-format] Don't break between string literal operands of << (PR #69871)

2023-10-27 Thread Owen Pan via cfe-commits

owenca wrote:

IMO, the new behavior is consistent with the 
[documentation](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#columnlimit)
 for `ColumnLimt: 0`.

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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor (NFC) (PR #70427)

2023-10-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kohei Asano (khei4)


Changes

This patch fixes the code example on CommonOptionParser on 
https://intel.github.io/llvm-docs/clang/LibTooling.html

CommonOptionParser's constructor is protected and we can use 
`CommonOptionParser::create` instead of that.

I'm still not so sure whether other old examples are around there.

---
Full diff: https://github.com/llvm/llvm-project/pull/70427.diff


1 Files Affected:

- (modified) clang/docs/LibTooling.rst (+1-1) 


``diff
diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c7..cf0e0d005f45e16 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -71,7 +71,7 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
 
 // Use OptionsParser.getCompilations() and 
OptionsParser.getSourcePathList()
 // to retrieve CompilationDatabase and the list of input file paths.

``




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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor (NFC) (PR #70427)

2023-10-27 Thread Kohei Asano via cfe-commits

https://github.com/khei4 created https://github.com/llvm/llvm-project/pull/70427

This patch fixes the code example on CommonOptionParser on 
https://intel.github.io/llvm-docs/clang/LibTooling.html

CommonOptionParser's constructor is protected and we can use 
`CommonOptionParser::create` instead of that.

I'm still not so sure whether other old examples are around there.

>From 5b781734df6d3c49a6c387374c980693392fcabf Mon Sep 17 00:00:00 2001
From: khei4 
Date: Fri, 27 Oct 2023 17:46:34 +0900
Subject: [PATCH] use: create instead of protected Constructor

---
 clang/docs/LibTooling.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c7..cf0e0d005f45e16 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -71,7 +71,7 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
 
 // Use OptionsParser.getCompilations() and 
OptionsParser.getSourcePathList()
 // to retrieve CompilationDatabase and the list of input file paths.

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


[clang] e9a7876 - [C++20] [Modules] Chose BMI from for module m with the last

2023-10-27 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-10-27T16:52:21+08:00
New Revision: e9a7876c2c81423f2289aa85eeac32d7a55cd3c8

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

LOG: [C++20] [Modules] Chose BMI from for module m with the last
-fmodule-file== option

Currently if we have multiple `-fmodule-file==`
flags for the same ``, we will pick the BMI-path from the
first flag. And this is inconsistent with what users generally expect.
e.g, we might expect the latter flags can override the former ones.

This patch changes the behavior to match user's expectation.

Added: 
clang/test/Modules/duplicated-module-file-eq-module-name.cppm

Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 4e6d7bb16f51beb..fd6c250efeda2a8 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3163,8 +3163,8 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions 
, ArgList ,
 StringRef Val = A->getValue();
 if (Val.contains('=')) {
   auto Split = Val.split('=');
-  Opts.PrebuiltModuleFiles.insert(
-  {std::string(Split.first), std::string(Split.second)});
+  Opts.PrebuiltModuleFiles.insert_or_assign(
+  std::string(Split.first), std::string(Split.second));
 }
   }
   for (const auto *A : Args.filtered(OPT_fprebuilt_module_path))

diff  --git a/clang/test/Modules/duplicated-module-file-eq-module-name.cppm 
b/clang/test/Modules/duplicated-module-file-eq-module-name.cppm
new file mode 100644
index 000..e86dbe2b941ef88
--- /dev/null
+++ b/clang/test/Modules/duplicated-module-file-eq-module-name.cppm
@@ -0,0 +1,21 @@
+// Tests that we will pick the last `-fmodule-file==` flag
+// for .
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/u.cpp -fmodule-file=a=%t/unexist.pcm \
+// RUN:  -fmodule-file=a=%t/a.pcm -verify -fsyntax-only
+
+//--- a.cppm
+export module a;
+export int a();
+
+//--- u.cpp
+// expected-no-diagnostics
+import a;
+int u() {
+return a();
+}



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


[clang] e64e478 - [clang][Interp][NFC] Rename a parameter

2023-10-27 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-10-27T10:43:35+02:00
New Revision: e64e4784ee1c3ed9bb06458e9c427542927224ab

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

LOG: [clang][Interp][NFC] Rename a parameter

Added: 


Modified: 
clang/lib/AST/Interp/Program.cpp
clang/lib/AST/Interp/Program.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Program.cpp 
b/clang/lib/AST/Interp/Program.cpp
index c6d19afd7d2219d..52e13398163ecf7 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -138,14 +138,13 @@ std::optional Program::getOrCreateGlobal(const 
ValueDecl *VD,
   return std::nullopt;
 }
 
-std::optional Program::getOrCreateDummy(const ValueDecl *PD) {
+std::optional Program::getOrCreateDummy(const ValueDecl *VD) {
   // Dedup blocks since they are immutable and pointers cannot be compared.
-  if (auto It = DummyParams.find(PD);
-  It != DummyParams.end())
+  if (auto It = DummyParams.find(VD); It != DummyParams.end())
 return It->second;
 
   // Create dummy descriptor.
-  Descriptor *Desc = allocateDescriptor(PD, std::nullopt);
+  Descriptor *Desc = allocateDescriptor(VD, std::nullopt);
   // Allocate a block for storage.
   unsigned I = Globals.size();
 
@@ -154,7 +153,7 @@ std::optional Program::getOrCreateDummy(const 
ValueDecl *PD) {
   G->block()->invokeCtor();
 
   Globals.push_back(G);
-  DummyParams[PD] = I;
+  DummyParams[VD] = I;
   return I;
 }
 

diff  --git a/clang/lib/AST/Interp/Program.h b/clang/lib/AST/Interp/Program.h
index d843fa06538f514..17342680102cffb 100644
--- a/clang/lib/AST/Interp/Program.h
+++ b/clang/lib/AST/Interp/Program.h
@@ -83,7 +83,7 @@ class Program final {
 const Expr *Init = nullptr);
 
   /// Returns or creates a dummy value for unknown declarations.
-  std::optional getOrCreateDummy(const ValueDecl *PD);
+  std::optional getOrCreateDummy(const ValueDecl *VD);
 
   /// Creates a global and returns its index.
   std::optional createGlobal(const ValueDecl *VD, const Expr *E);



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


[clang] 051fade - [clang][Interp][NFC] Use delegate() address-of operators

2023-10-27 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-10-27T10:43:35+02:00
New Revision: 051fade10f03515b0980c58541fe4c28220e0e67

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

LOG: [clang][Interp][NFC] Use delegate() address-of operators

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index a5141d728d8322e..195af664c13dafc 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2549,9 +2549,7 @@ bool ByteCodeExprGen::VisitUnaryOperator(const 
UnaryOperator *E) {
 return DiscardResult ? this->emitPop(*T, E) : true;
   case UO_AddrOf: // 
 // We should already have a pointer when we get here.
-if (!this->visit(SubExpr))
-  return false;
-return DiscardResult ? this->emitPop(*T, E) : true;
+return this->delegate(SubExpr);
   case UO_Deref:  // *x
 return dereference(
 SubExpr, DerefKind::Read,



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


[clang] [Driver] Link Flang runtime on FreeBSD, NetBSD, OpenBSD, DragonFly and Haiku (PR #69817)

2023-10-27 Thread Brad Smith via cfe-commits

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


[clang] c149ff3 - [Driver] Link Flang runtime on FreeBSD, NetBSD, OpenBSD, DragonFly and Haiku (#69817)

2023-10-27 Thread via cfe-commits

Author: Brad Smith
Date: 2023-10-27T04:43:19-04:00
New Revision: c149ff3d372a70e7d9de838a1ff0357394b8d017

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

LOG: [Driver] Link Flang runtime on FreeBSD, NetBSD, OpenBSD, DragonFly and 
Haiku (#69817)

Added: 


Modified: 
clang/lib/Driver/ToolChains/DragonFly.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Haiku.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.cpp
flang/test/Driver/linker-flags.f90

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 9dc8d9d4363bd71..500dd98665075b1 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -144,6 +144,16 @@ void dragonfly::Linker::ConstructJob(Compilation , const 
JobAction ,
   CmdArgs.push_back("-lm");
 }
 
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below (i.e.
+// AddRuntTimeLibs).
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
+  addFortranRuntimeLibs(ToolChain, CmdArgs);
+  CmdArgs.push_back("-lm");
+}
+
 if (Args.hasArg(options::OPT_pthread))
   CmdArgs.push_back("-lpthread");
 

diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 054f57c21ee6ba0..a5be32b4a2f07fd 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -290,6 +290,20 @@ void freebsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   else
 CmdArgs.push_back("-lm");
 }
+
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below (i.e.
+// AddRuntTimeLibs).
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
+  addFortranRuntimeLibs(ToolChain, CmdArgs);
+  if (Profiling)
+CmdArgs.push_back("-lm_p");
+  else
+CmdArgs.push_back("-lm");
+}
+
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
 if (NeedsXRayDeps)

diff  --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 4212dd8de293b06..172f16cc46e328e 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -95,6 +95,15 @@ void haiku::Linker::ConstructJob(Compilation , const 
JobAction ,
 if (D.CCCIsCXX() && ToolChain.ShouldLinkCXXStdlib(Args))
   ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
 
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below (i.e.
+// AddRuntTimeLibs).
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
+  addFortranRuntimeLibs(ToolChain, CmdArgs);
+}
+
 CmdArgs.push_back("-lgcc");
 
 CmdArgs.push_back("--push-state");

diff  --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 3bf8af642b3349b..245553d46055a27 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -314,6 +314,17 @@ void netbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
 ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below (i.e.
+// AddRuntTimeLibs).
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
+  addFortranRuntimeLibs(ToolChain, CmdArgs);
+  CmdArgs.push_back("-lm");
+}
+
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
 if (NeedsXRayDeps)

diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 8df6dae3dd6ba6b..4e14c3d140a1da2 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -213,6 +213,20 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   else
 CmdArgs.push_back("-lm");
 }
+
+// Additional linker 

[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

2023-10-27 Thread Balázs Kéri via cfe-commits

https://github.com/balazske commented:

The fix looks good but the formatting of the test code could be better, like in 
the other tests.

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


[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

2023-10-27 Thread Balázs Kéri via cfe-commits


@@ -1373,6 +1373,40 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportCorrectTemplatedDecl) {
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportTemplateSpecializationStaticMember) {
+  auto FromCode = R"(
+  template  class Test{
+  public:
+ static const unsigned int length;
+  };
+
+  template<> const unsigned int Test::length;
+  template<> const unsigned int Test::length = 0;
+  )";
+  auto ToCode = R"(
+template  class Test
+{
+public:
+   static const unsigned int length;
+};
+template<> const unsigned int Test::length;
+
+void foo(){
+int i = 1 / Test::length;
+}
+)";

balazske wrote:

It is better to have the usual code formatting in the test code.

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


[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

2023-10-27 Thread Balázs Kéri via cfe-commits

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


[PATCH] D70401: [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs

2023-10-27 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu accepted this revision.
zixuan-wu added a comment.
This revision is now accepted and ready to land.

LGTM if nobody objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[clang] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)

2023-10-27 Thread Mitch Phillips via cfe-commits

hctim wrote:

I talked with some folks internally and we came to the consensus that this'll 
almost certainly break some debugging tools and such, it probably won't effect 
the runtime of binaries, but I wouldn't say that this is a super 
confidence-inspiring thing to do.

> AMD language runtimes provide queries for the size of device global symbols 
> and functions to copy data to and from device global variables. Runtime gets 
> the needed information form the ELF symbol table. So, when it querires the 
> size of device global variable, it gets the padded size rather than actual 
> size.

It's my understanding your problem is that you are asan-trapping on the 
redzones when you copy data to/from the device. Is it possible instead to just 
make those copy-from and copy-to functions in the runtime 
`__attribute__((no_sanitize("address")))` and copy the padding as well?

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


[clang] Disable memtag sanitization for global fnptrs going into .ctors (PR #70186)

2023-10-27 Thread Mitch Phillips via cfe-commits

hctim wrote:

(friendly ping @eugenis / @vitalybuka)

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


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread via cfe-commits


@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {

cor3ntin wrote:

@erichkeane @AaronBallman wdyt?

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


[clang] [clang][Interp] Implement __builtin_bit_cast (PR #68288)

2023-10-27 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,816 @@
+// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only 
-fexperimental-new-constant-interpreter %s
+// RUN: %clang_cc1 -verify=ref -std=c++2a -fsyntax-only %s
+// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -triple 
aarch64_be-linux-gnu -fexperimental-new-constant-interpreter %s
+// RUN: %clang_cc1 -verify=ref -std=c++2a -fsyntax-only -triple 
aarch64_be-linux-gnu %s
+// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only 
-fexperimental-new-constant-interpreter -triple powerpc64le-unknown-unknown 
-mabi=ieeelongdouble %s
+// RUN: %clang_cc1 -verify=ref -std=c++2a -fsyntax-only -triple 
powerpc64le-unknown-unknown -mabi=ieeelongdouble %s
+// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only 
-fexperimental-new-constant-interpreter -triple powerpc64-unknown-unknown 
-mabi=ieeelongdouble %s
+// RUN: %clang_cc1 -verify=ref -std=c++2a -fsyntax-only -triple 
powerpc64-unknown-unknown -mabi=ieeelongdouble %s
+
+/// FIXME: This is a version of
+///   clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp with the currently
+///   supported subset of operations. They should *all* be supported though.
+
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#  define LITTLE_END 1
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#  define LITTLE_END 0
+#else
+#  error "huh?"
+#endif
+
+typedef decltype(nullptr) nullptr_t;
+
+
+
+static_assert(sizeof(int) == 4);
+static_assert(sizeof(long long) == 8);
+
+template 
+constexpr To bit_cast(const From ) {
+  static_assert(sizeof(To) == sizeof(From));
+  return __builtin_bit_cast(To, from); // ref-note 2{{indeterminate value can 
only initialize}} \
+   // expected-note 2{{indeterminate value 
can only initialize}} \
+   // ref-note {{subexpression not valid}}
+}
+
+
+/// Current interpreter does not support this.
+/// https://github.com/llvm/llvm-project/issues/63686
+constexpr int FromString = bit_cast("abc"); // ref-error {{must be 
initialized by a constant expression}} \
+ // ref-note {{in call to}} \
+ // ref-note {{declared here}}
+#if LITTLE_END
+static_assert(FromString == 6513249); // ref-error {{is not an integral 
constant expression}} \
+  // ref-note {{initializer of 
'FromString' is not a constant expression}}
+#else
+static_assert(FromString == 1633837824); // ref-error {{is not an integral 
constant expression}} \

tbaederr wrote:

No this bitcasts the contents, I've compared this to gcc's output: 
https://godbolt.org/z/azPj4eqjr and it's the same.

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


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread via cfe-commits


@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {

cor3ntin wrote:

I had a chat with @Endilll offline.
The reason for this change is that `preferred_type` (#69104) warns when the 
enumerator has a different underlying type as the bit field. 
https://godbolt.org/z/zz99s6M3j

This warning does seem a bit off to me - but I really like its intent.
The warning only triggers on enumerators (which probably make sense as a 
general warning may have too many false positives), but I think the warning is 
too restrictive.
If the underlying type has the same signedness and has a size equal to **or 
smaller**  than the the size of the type of the bitfield, I don't think a 
warning should be produced.

I have convinced myself that the changes here are most likely fine 
(`TypeDependence` is (afaict) only stored in TypeBitfields, as far as i can 
tell, and this uses the number of bits of the greatest enumerator, which i did 
not initially realize).

Yet I do not like the idea that we would change the underlying type of all 
enums used in bitfields for the sake of that warning.

My preferred solution would be to make `-Wbitfield-type` less aggressive and 
not change the underlying types of enums is this patch.





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


[clang] [Driver] Link Flang runtime on FreeBSD, NetBSD, OpenBSD, DragonFly and Haiku (PR #69817)

2023-10-27 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space approved this pull request.

LGTM, thanks!

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


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

That's a good point. I'm not opposed to wrap this attribute if we must. I'd 
like to hear from @AaronBallman on this matter.

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


[clang] [Driver][NFC] Make use of final (PR #70416)

2023-10-27 Thread Brad Smith via cfe-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/70416

None

>From 6247344956c34137ced2ae89be1154bd31173d46 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Fri, 27 Oct 2023 02:22:21 -0400
Subject: [PATCH] [Driver][NFC] Make use of final

---
 clang/lib/Driver/ToolChains/AIX.h| 4 ++--
 clang/lib/Driver/ToolChains/AMDGPU.h | 2 +-
 clang/lib/Driver/ToolChains/AVR.h| 2 +-
 clang/lib/Driver/ToolChains/BareMetal.h  | 2 +-
 clang/lib/Driver/ToolChains/CSKYToolChain.h  | 2 +-
 clang/lib/Driver/ToolChains/CrossWindows.h   | 4 ++--
 clang/lib/Driver/ToolChains/Cuda.h   | 4 ++--
 clang/lib/Driver/ToolChains/DragonFly.h  | 4 ++--
 clang/lib/Driver/ToolChains/FreeBSD.h| 4 ++--
 clang/lib/Driver/ToolChains/Fuchsia.h| 2 +-
 clang/lib/Driver/ToolChains/HIPAMD.h | 2 +-
 clang/lib/Driver/ToolChains/HIPSPV.h | 2 +-
 clang/lib/Driver/ToolChains/Hexagon.h| 4 ++--
 clang/lib/Driver/ToolChains/MSP430.h | 2 +-
 clang/lib/Driver/ToolChains/MSVC.h   | 2 +-
 clang/lib/Driver/ToolChains/MinGW.h  | 2 +-
 clang/lib/Driver/ToolChains/NaCl.h   | 2 +-
 clang/lib/Driver/ToolChains/NetBSD.h | 4 ++--
 clang/lib/Driver/ToolChains/OpenBSD.h| 4 ++--
 clang/lib/Driver/ToolChains/PS4CPU.h | 4 ++--
 clang/lib/Driver/ToolChains/RISCVToolchain.h | 2 +-
 clang/lib/Driver/ToolChains/SPIRV.h  | 2 +-
 clang/lib/Driver/ToolChains/Solaris.h| 4 ++--
 clang/lib/Driver/ToolChains/WebAssembly.h| 2 +-
 clang/lib/Driver/ToolChains/XCore.h  | 4 ++--
 clang/lib/Driver/ToolChains/ZOS.h| 4 ++--
 26 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AIX.h 
b/clang/lib/Driver/ToolChains/AIX.h
index 04f9b2240999cc2..755d87e07ec5003 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -19,7 +19,7 @@ namespace tools {
 /// Directly call system default assembler and linker.
 namespace aix {
 
-class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool {
 public:
   Assembler(const ToolChain ) : Tool("aix::Assembler", "assembler", TC) {}
 
@@ -31,7 +31,7 @@ class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
 const char *LinkingOutput) const override;
 };
 
-class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
 public:
   Linker(const ToolChain ) : Tool("aix::Linker", "linker", TC) {}
 
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index d10d487dd44c582..b3361b1e3607964 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -26,7 +26,7 @@ namespace driver {
 namespace tools {
 namespace amdgpu {
 
-class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
 public:
   Linker(const ToolChain ) : Tool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
diff --git a/clang/lib/Driver/ToolChains/AVR.h 
b/clang/lib/Driver/ToolChains/AVR.h
index d432d81744b9281..247188b7eaad749 100644
--- a/clang/lib/Driver/ToolChains/AVR.h
+++ b/clang/lib/Driver/ToolChains/AVR.h
@@ -49,7 +49,7 @@ class LLVM_LIBRARY_VISIBILITY AVRToolChain : public 
Generic_ELF {
 
 namespace tools {
 namespace AVR {
-class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
 public:
   Linker(const llvm::Triple , const ToolChain )
   : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple) {}
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index fc39a2a10e01990..f602ef2be3542fb 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -98,7 +98,7 @@ class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool {
 const char *LinkingOutput) const override;
 };
 
-class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
 public:
   Linker(const ToolChain ) : Tool("baremetal::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
diff --git a/clang/lib/Driver/ToolChains/CSKYToolChain.h 
b/clang/lib/Driver/ToolChains/CSKYToolChain.h
index 52b37539cc5f1a9..a57324a426416d9 100644
--- a/clang/lib/Driver/ToolChains/CSKYToolChain.h
+++ b/clang/lib/Driver/ToolChains/CSKYToolChain.h
@@ -44,7 +44,7 @@ class LLVM_LIBRARY_VISIBILITY CSKYToolChain : public 
Generic_ELF {
 
 namespace tools {
 namespace CSKY {
-class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
 public:
   Linker(const ToolChain ) : Tool("CSKY::Linker", "ld", TC) {}
   bool hasIntegratedCPP() const override { return false; }
diff --git 

[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Sure but clang 16 will emit a warning for them: https://godbolt.org/z/jnsc4336G 
- are we passing `-Wno-unknown-attributes` to the build?

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


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

@tbaederr As highlighted in https://github.com/llvm/llvm-project/pull/69104, 
this attribute doesn't change semantics of the program, so it's safe to ignore.

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


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Since this is done unconditionally, doesn't this mean we now need an unreleased 
clang to compile? Or are `[[clang::]]` attributes just ignored if they are 
unknown?

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


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-27 Thread Vlad Serebrennikov via cfe-commits


@@ -20,7 +20,7 @@ namespace clang {
 
 /// Describes the different kinds of linkage
 /// (C++ [basic.link], C99 6.2.2) that an entity may have.
-enum Linkage : unsigned char {
+enum Linkage : unsigned {

Endilll wrote:

This case is similar to `TypeDependence` we discuss in another thread, except 
that I can't find references to this type in data member declaration in our 
headers, which suggests that bit-field it stored in has hard-coded width, and 
has nothing to do with underlying type declared here.

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


[clang] [RISCV] Support Xsfvfnrclipxfqf extensions (PR #68297)

2023-10-27 Thread Craig Topper via cfe-commits

https://github.com/topperc approved this pull request.

LGTM

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


[clang] [clang] Change representation of CurLexerKind (PR #70381)

2023-10-27 Thread via cfe-commits


@@ -751,13 +751,8 @@ class Preprocessor {
   std::unique_ptr CurTokenLexer;
 
   /// The kind of lexer we're currently working with.
-  enum CurLexerKind {
-CLK_Lexer,
-CLK_TokenLexer,
-CLK_CachingLexer,
-CLK_DependencyDirectivesLexer,
-CLK_LexAfterModuleImport
-  } CurLexerKind = CLK_Lexer;
+  typedef bool (*CurLexerKindType)(Preprocessor &, Token &);

cor3ntin wrote:

```suggestion
  typedef bool (*LexerCallback)(Preprocessor &, Token &);
```

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


[clang] [clang] Change representation of CurLexerKind (PR #70381)

2023-10-27 Thread via cfe-commits

https://github.com/cor3ntin commented:

This is excellent!
I made some naming suggestion. Now that we don't have an enum i think it is 
clearer to drop the "kind" terminology

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


[clang] [clang] Change representation of CurLexerKind (PR #70381)

2023-10-27 Thread via cfe-commits


@@ -643,23 +643,7 @@ void Preprocessor::SkipTokensWhileUsingPCH() {
   while (true) {
 bool InPredefines =
 (CurLexer && CurLexer->getFileID() == getPredefinesFileID());
-switch (CurLexerKind) {
-case CLK_Lexer:
-  CurLexer->Lex(Tok);
- break;
-case CLK_TokenLexer:
-  CurTokenLexer->Lex(Tok);
-  break;
-case CLK_CachingLexer:
-  CachingLex(Tok);
-  break;
-case CLK_DependencyDirectivesLexer:
-  CurLexer->LexDependencyDirectiveToken(Tok);
-  break;
-case CLK_LexAfterModuleImport:
-  LexAfterModuleImport(Tok);
-  break;
-}
+(void)CurLexerKind(*this, Tok);

cor3ntin wrote:

I don't think you need the cast to void here

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


[clang] [clang] Change representation of CurLexerKind (PR #70381)

2023-10-27 Thread via cfe-commits


@@ -751,13 +751,8 @@ class Preprocessor {
   std::unique_ptr CurTokenLexer;
 
   /// The kind of lexer we're currently working with.
-  enum CurLexerKind {
-CLK_Lexer,
-CLK_TokenLexer,
-CLK_CachingLexer,
-CLK_DependencyDirectivesLexer,
-CLK_LexAfterModuleImport
-  } CurLexerKind = CLK_Lexer;
+  typedef bool (*CurLexerKindType)(Preprocessor &, Token &);
+  CurLexerKindType CurLexerKind = _Lexer;

cor3ntin wrote:

```suggestion
  LexerCallback CurLexerCallback = _Lexer;
```

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


[clang] [clang] Change representation of CurLexerKind (PR #70381)

2023-10-27 Thread via cfe-commits

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


<    1   2   3   4