[PATCH] D150209: [clang][Interp] Add more shift error checking

2023-05-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:136
+if (LHS.isNegative())
+  S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << 12;
+else if (LHS.toUnsigned().countLeadingZeros() < static_cast(RHS))

shafik wrote:
> Do we test this diagnostic?
OH! No, and the `12` was just a debug value I forgot to replace with the real 
thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150209

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-09 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 520914.
junaire added a comment.

Add some comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp

Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,180 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+extern "C" int printf(const char*,...);
+
+char c = 'a';
+c
+// CHECK: (char) 'a'
+
+const char* c_str = "Goodbye, world!";
+c_str
+// CHECK-NEXT: (const char *) "Goodbye, world!"
+
+const char* c_null_str = 0;
+c_null_str
+// CHECK-NEXT: (const char *) nullptr
+
+"Hello, world"
+// CHECK-NEXT: (const char[13]) "Hello, world"
+
+int x = 42;
+x
+// CHECK-NEXT: (int) 42
+
+&x
+// CHECK-NEXT: (int *) [[Addr:@0x.*]]
+
+x - 2
+// CHECK-NEXT: (int) 40
+
+float f = 4.2f;
+f
+// CHECK-NEXT: (float) 4.2f
+
+double d = 4.21;
+d
+// CHECK-NEXT: (double) 4.210
+
+struct S1{};
+S1 s1;
+s1
+// CHECK-NEXT: (S1 &) [[Addr:@0x.*]]
+
+S1{}
+// CHECK-NEXT: (S1) [[Addr:@0x.*]]
+
+struct S2 {int d;} E = {22};
+E
+// CHECK-NEXT: (struct S2 &) [[Addr:@0x.*]]
+E.d
+// CHECK-NEXT: (int) 22
+
+struct S3 { int* p; S3() { p = new int(42); } ~S3() { delete p; } };
+S3{}
+// CHECK-NEXT: (S3) [[Addr:@0x.*]]
+S3 s3;
+s3
+// CHECK-NEXT: (S3 &) [[Addr:@0x.*]]
+
+struct S4 { ~S4() { printf("~S4()\n"); }};
+S4{}
+// CHECK-NEXT: (S4) [[Addr:@0x.*]]
+
+enum Enum{ e1 = -12, e2, e3=33, e4, e5 = 33};
+e2
+// CHECK-NEXT: (Enum) (e2) : int -11
+::e1
+// CHECK-NEXT: (Enum) (e1) : int -12
+
+enum class Color { Black = 0, Red, Green };
+Color::Black
+// CHECK-NEXT: (Color) (Color::Black) : int 0
+
+int arr[3] = {1,2,3};
+arr
+// CHECK-NEXT: (int[3]) { 1, 2, 3 }
+
+auto Lambda1 = []{};
+Lambda1
+// CHECK-NEXT: ((lambda) &) [[Addr:@0x.*]]
+[]{}
+// CHECK-NEXT: ((lambda at input_line_84:1:1)) [[Addr:@0x.*]]
+
+template struct F{ enum {RET=F::RET*n} ; };
+template<> struct F<0> { enum {RET = 1}; };
+F<7>::RET
+// CHECK-NEXT: (F<7>::(unnamed enum at input_line_87:1:27)) (F<7>::RET) : unsigned int 5040
+
+int foo() { return 42; }
+foo()
+// CHECK-NEXT: (int) 42
+
+void bar() {}
+bar()
+
+struct S5 { int foo() { return 42; }};
+&S5::foo
+// CHECK-NEXT: (int (S5::*)()) Function [[Addr:@0x.*]]
+
+#include 
+
+auto p1 = std::make_shared(42);
+p1
+// CHECK-NEXT: (std::shared_ptr &) std::shared_ptr -> [[Addr:@0x.*]]
+
+auto p2 = std::make_unique(42);
+p2
+// CHECK-NEXT: (std::unique_ptr > &) std::unique_ptr -> [[Addr:@0x.*]]
+
+#include 
+std::array a{1, 2, 3};
+a
+// CHECK-NEXT: (std::array &) { 1, 2, 3 }
+
+#include 
+std::vector v1 = {7, 5, 16, 8};
+v1
+// CHECK-NEXT: (std::vector &) { 7, 5, 16, 8 }
+
+std::vector v = {true, false, true};
+v
+// CHECK-NEXT: (std::vector &) { true, false, true }
+
+#include 
+std::deque dq = {7, 5, 16, 8};
+dq
+// CHECK-NEXT: (std::deque &) { 7, 5, 16, 8 }
+
+#include 
+std::forward_list fl {3,4,5,6};
+fl
+// CHECK-NEXT: (std::forward_list &) { 3, 4, 5, 6 }
+
+#include 
+std::set z1 = {2,4,6,8};
+z1
+// CHECK-NEXT: (std::set &) { 2, 4, 6, 8 }
+
+#include 
+std::unordered_set z2 = {8,2,4,6};
+z2
+// CHECK-NEXT: (std::unordered_set &) { 6, 4, 2, 8 }
+
+std::multiset e {3,2,1,2,4,7,3};
+e
+// CHECK-NEXT: (std::multiset &) { 1, 2, 2, 3, 3, 4, 7 }
+
+#include 
+std::string std_str = "Hello, world!";
+std_str
+// CHECK-NEXT: (std::string &) "Hello, world!"
+
+#include 
+std::pair pr(42,'a');
+pr
+// CHECK-NEXT: (std::pair &) { 42, 'a' }
+
+#include 
+std::tuple tu(42,3.14,'a');
+tu
+// CHECK-NEXT: (std::tuple &) { 42, 3.140, 'a' }
+
+#include 
+std::map m1{{"CPU", 10}, {"GPU", 15}, {"RAM", 20}};
+m1
+// CHECK-NEXT: (std::map &) { "CPU" => 10, "GPU" => 15, "RAM" => 20 }
+
+#include 
+std::unordered_map m2 = { {"RED","#FF"}, {"GREEN","#00FF00"}};
+m2
+// CHECK-NEXT: (std::unordered_map &) { "GREEN" => "#00FF00", "RED" => "#FF" }
+
+struct MyType {};
+std::string PrintValueRuntime(const MyType*) { return "My pretty printer!"; }
+MyType{}
+// CHECK-NEXT: (MyType) My pretty printer!
+%quit
+
Index: clang/lib/Interpreter/Valu

[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-09 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 520913.
junaire added a comment.

Remove unused code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp

Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,180 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+extern "C" int printf(const char*,...);
+
+char c = 'a';
+c
+// CHECK: (char) 'a'
+
+const char* c_str = "Goodbye, world!";
+c_str
+// CHECK-NEXT: (const char *) "Goodbye, world!"
+
+const char* c_null_str = 0;
+c_null_str
+// CHECK-NEXT: (const char *) nullptr
+
+"Hello, world"
+// CHECK-NEXT: (const char[13]) "Hello, world"
+
+int x = 42;
+x
+// CHECK-NEXT: (int) 42
+
+&x
+// CHECK-NEXT: (int *) [[Addr:@0x.*]]
+
+x - 2
+// CHECK-NEXT: (int) 40
+
+float f = 4.2f;
+f
+// CHECK-NEXT: (float) 4.2f
+
+double d = 4.21;
+d
+// CHECK-NEXT: (double) 4.210
+
+struct S1{};
+S1 s1;
+s1
+// CHECK-NEXT: (S1 &) [[Addr:@0x.*]]
+
+S1{}
+// CHECK-NEXT: (S1) [[Addr:@0x.*]]
+
+struct S2 {int d;} E = {22};
+E
+// CHECK-NEXT: (struct S2 &) [[Addr:@0x.*]]
+E.d
+// CHECK-NEXT: (int) 22
+
+struct S3 { int* p; S3() { p = new int(42); } ~S3() { delete p; } };
+S3{}
+// CHECK-NEXT: (S3) [[Addr:@0x.*]]
+S3 s3;
+s3
+// CHECK-NEXT: (S3 &) [[Addr:@0x.*]]
+
+struct S4 { ~S4() { printf("~S4()\n"); }};
+S4{}
+// CHECK-NEXT: (S4) [[Addr:@0x.*]]
+
+enum Enum{ e1 = -12, e2, e3=33, e4, e5 = 33};
+e2
+// CHECK-NEXT: (Enum) (e2) : int -11
+::e1
+// CHECK-NEXT: (Enum) (e1) : int -12
+
+enum class Color { Black = 0, Red, Green };
+Color::Black
+// CHECK-NEXT: (Color) (Color::Black) : int 0
+
+int arr[3] = {1,2,3};
+arr
+// CHECK-NEXT: (int[3]) { 1, 2, 3 }
+
+auto Lambda1 = []{};
+Lambda1
+// CHECK-NEXT: ((lambda) &) [[Addr:@0x.*]]
+[]{}
+// CHECK-NEXT: ((lambda at input_line_84:1:1)) [[Addr:@0x.*]]
+
+template struct F{ enum {RET=F::RET*n} ; };
+template<> struct F<0> { enum {RET = 1}; };
+F<7>::RET
+// CHECK-NEXT: (F<7>::(unnamed enum at input_line_87:1:27)) (F<7>::RET) : unsigned int 5040
+
+int foo() { return 42; }
+foo()
+// CHECK-NEXT: (int) 42
+
+void bar() {}
+bar()
+
+struct S5 { int foo() { return 42; }};
+&S5::foo
+// CHECK-NEXT: (int (S5::*)()) Function [[Addr:@0x.*]]
+
+#include 
+
+auto p1 = std::make_shared(42);
+p1
+// CHECK-NEXT: (std::shared_ptr &) std::shared_ptr -> [[Addr:@0x.*]]
+
+auto p2 = std::make_unique(42);
+p2
+// CHECK-NEXT: (std::unique_ptr > &) std::unique_ptr -> [[Addr:@0x.*]]
+
+#include 
+std::array a{1, 2, 3};
+a
+// CHECK-NEXT: (std::array &) { 1, 2, 3 }
+
+#include 
+std::vector v1 = {7, 5, 16, 8};
+v1
+// CHECK-NEXT: (std::vector &) { 7, 5, 16, 8 }
+
+std::vector v = {true, false, true};
+v
+// CHECK-NEXT: (std::vector &) { true, false, true }
+
+#include 
+std::deque dq = {7, 5, 16, 8};
+dq
+// CHECK-NEXT: (std::deque &) { 7, 5, 16, 8 }
+
+#include 
+std::forward_list fl {3,4,5,6};
+fl
+// CHECK-NEXT: (std::forward_list &) { 3, 4, 5, 6 }
+
+#include 
+std::set z1 = {2,4,6,8};
+z1
+// CHECK-NEXT: (std::set &) { 2, 4, 6, 8 }
+
+#include 
+std::unordered_set z2 = {8,2,4,6};
+z2
+// CHECK-NEXT: (std::unordered_set &) { 6, 4, 2, 8 }
+
+std::multiset e {3,2,1,2,4,7,3};
+e
+// CHECK-NEXT: (std::multiset &) { 1, 2, 2, 3, 3, 4, 7 }
+
+#include 
+std::string std_str = "Hello, world!";
+std_str
+// CHECK-NEXT: (std::string &) "Hello, world!"
+
+#include 
+std::pair pr(42,'a');
+pr
+// CHECK-NEXT: (std::pair &) { 42, 'a' }
+
+#include 
+std::tuple tu(42,3.14,'a');
+tu
+// CHECK-NEXT: (std::tuple &) { 42, 3.140, 'a' }
+
+#include 
+std::map m1{{"CPU", 10}, {"GPU", 15}, {"RAM", 20}};
+m1
+// CHECK-NEXT: (std::map &) { "CPU" => 10, "GPU" => 15, "RAM" => 20 }
+
+#include 
+std::unordered_map m2 = { {"RED","#FF"}, {"GREEN","#00FF00"}};
+m2
+// CHECK-NEXT: (std::unordered_map &) { "GREEN" => "#00FF00", "RED" => "#FF" }
+
+struct MyType {};
+std::string PrintValueRuntime(const MyType*) { return "My pretty printer!"; }
+MyType{}
+// CHECK-NEXT: (MyType) My pretty printer!
+%quit
+
Index: clang/lib/Interpreter/Va

[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-09 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 520912.
junaire added a comment.

Fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp

Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,180 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+extern "C" int printf(const char*,...);
+
+char c = 'a';
+c
+// CHECK: (char) 'a'
+
+const char* c_str = "Goodbye, world!";
+c_str
+// CHECK-NEXT: (const char *) "Goodbye, world!"
+
+const char* c_null_str = 0;
+c_null_str
+// CHECK-NEXT: (const char *) nullptr
+
+"Hello, world"
+// CHECK-NEXT: (const char[13]) "Hello, world"
+
+int x = 42;
+x
+// CHECK-NEXT: (int) 42
+
+&x
+// CHECK-NEXT: (int *) [[Addr:@0x.*]]
+
+x - 2
+// CHECK-NEXT: (int) 40
+
+float f = 4.2f;
+f
+// CHECK-NEXT: (float) 4.2f
+
+double d = 4.21;
+d
+// CHECK-NEXT: (double) 4.210
+
+struct S1{};
+S1 s1;
+s1
+// CHECK-NEXT: (S1 &) [[Addr:@0x.*]]
+
+S1{}
+// CHECK-NEXT: (S1) [[Addr:@0x.*]]
+
+struct S2 {int d;} E = {22};
+E
+// CHECK-NEXT: (struct S2 &) [[Addr:@0x.*]]
+E.d
+// CHECK-NEXT: (int) 22
+
+struct S3 { int* p; S3() { p = new int(42); } ~S3() { delete p; } };
+S3{}
+// CHECK-NEXT: (S3) [[Addr:@0x.*]]
+S3 s3;
+s3
+// CHECK-NEXT: (S3 &) [[Addr:@0x.*]]
+
+struct S4 { ~S4() { printf("~S4()\n"); }};
+S4{}
+// CHECK-NEXT: (S4) [[Addr:@0x.*]]
+
+enum Enum{ e1 = -12, e2, e3=33, e4, e5 = 33};
+e2
+// CHECK-NEXT: (Enum) (e2) : int -11
+::e1
+// CHECK-NEXT: (Enum) (e1) : int -12
+
+enum class Color { Black = 0, Red, Green };
+Color::Black
+// CHECK-NEXT: (Color) (Color::Black) : int 0
+
+int arr[3] = {1,2,3};
+arr
+// CHECK-NEXT: (int[3]) { 1, 2, 3 }
+
+auto Lambda1 = []{};
+Lambda1
+// CHECK-NEXT: ((lambda) &) [[Addr:@0x.*]]
+[]{}
+// CHECK-NEXT: ((lambda at input_line_84:1:1)) [[Addr:@0x.*]]
+
+template struct F{ enum {RET=F::RET*n} ; };
+template<> struct F<0> { enum {RET = 1}; };
+F<7>::RET
+// CHECK-NEXT: (F<7>::(unnamed enum at input_line_87:1:27)) (F<7>::RET) : unsigned int 5040
+
+int foo() { return 42; }
+foo()
+// CHECK-NEXT: (int) 42
+
+void bar() {}
+bar()
+
+struct S5 { int foo() { return 42; }};
+&S5::foo
+// CHECK-NEXT: (int (S5::*)()) Function [[Addr:@0x.*]]
+
+#include 
+
+auto p1 = std::make_shared(42);
+p1
+// CHECK-NEXT: (std::shared_ptr &) std::shared_ptr -> [[Addr:@0x.*]]
+
+auto p2 = std::make_unique(42);
+p2
+// CHECK-NEXT: (std::unique_ptr > &) std::unique_ptr -> [[Addr:@0x.*]]
+
+#include 
+std::array a{1, 2, 3};
+a
+// CHECK-NEXT: (std::array &) { 1, 2, 3 }
+
+#include 
+std::vector v1 = {7, 5, 16, 8};
+v1
+// CHECK-NEXT: (std::vector &) { 7, 5, 16, 8 }
+
+std::vector v = {true, false, true};
+v
+// CHECK-NEXT: (std::vector &) { true, false, true }
+
+#include 
+std::deque dq = {7, 5, 16, 8};
+dq
+// CHECK-NEXT: (std::deque &) { 7, 5, 16, 8 }
+
+#include 
+std::forward_list fl {3,4,5,6};
+fl
+// CHECK-NEXT: (std::forward_list &) { 3, 4, 5, 6 }
+
+#include 
+std::set z1 = {2,4,6,8};
+z1
+// CHECK-NEXT: (std::set &) { 2, 4, 6, 8 }
+
+#include 
+std::unordered_set z2 = {8,2,4,6};
+z2
+// CHECK-NEXT: (std::unordered_set &) { 6, 4, 2, 8 }
+
+std::multiset e {3,2,1,2,4,7,3};
+e
+// CHECK-NEXT: (std::multiset &) { 1, 2, 2, 3, 3, 4, 7 }
+
+#include 
+std::string std_str = "Hello, world!";
+std_str
+// CHECK-NEXT: (std::string &) "Hello, world!"
+
+#include 
+std::pair pr(42,'a');
+pr
+// CHECK-NEXT: (std::pair &) { 42, 'a' }
+
+#include 
+std::tuple tu(42,3.14,'a');
+tu
+// CHECK-NEXT: (std::tuple &) { 42, 3.140, 'a' }
+
+#include 
+std::map m1{{"CPU", 10}, {"GPU", 15}, {"RAM", 20}};
+m1
+// CHECK-NEXT: (std::map &) { "CPU" => 10, "GPU" => 15, "RAM" => 20 }
+
+#include 
+std::unordered_map m2 = { {"RED","#FF"}, {"GREEN","#00FF00"}};
+m2
+// CHECK-NEXT: (std::unordered_map &) { "GREEN" => "#00FF00", "RED" => "#FF" }
+
+struct MyType {};
+std::string PrintValueRuntime(const MyType*) { return "My pretty printer!"; }
+MyType{}
+// CHECK-NEXT: (MyType) My pretty printer!
+%quit
+
Index: clang/lib/Interpreter/ValuePrinter.cpp
=

[PATCH] D150083: [clang-format] ObjCPropertyAttributeOrder to sort ObjC property attributes

2023-05-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Interesting




Comment at: clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp:69
+  // Ignore the comma separators.
+  continue;
+} else if (Tok->isOneOf(tok::identifier, tok::kw_class)) {

You need a unit tests  that tests all the keywords or if one becomes a non 
identifier then it will break



Comment at: clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp:70
+  continue;
+} else if (Tok->isOneOf(tok::identifier, tok::kw_class)) {
+  // Memoize the attribute. (Note that 'class' is a legal attribute!)

Make a function, isAttribute()


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

https://reviews.llvm.org/D150083

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


[PATCH] D146054: [RISCV] Add --print-supported-extensions and -march=help support

2023-05-09 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 520904.
4vtomat added a comment.

Remove -march=help alias.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-supported-extensions.c
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -139,6 +139,29 @@
 {"ztso", RISCVExtensionVersion{0, 1}},
 };
 
+void llvm::riscvMarchHelp() {
+  errs() << "All available -march extensions for RISC-V\n\n";
+  errs() << '\t' << left_justify("Name", 20) << "Version\n";
+
+  RISCVISAInfo::OrderedExtensionMap ExtMap;
+  for (const auto &E : SupportedExtensions)
+ExtMap[E.Name] = { E.Name, E.Version.Major, E.Version.Minor };
+  for (const auto &E : ExtMap)
+errs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  errs() << "\nExperimental extensions\n";
+  ExtMap.clear();
+  for (const auto &E : SupportedExperimentalExtensions)
+ExtMap[E.Name] = { E.Name, E.Version.Major, E.Version.Minor };
+  for (const auto &E : ExtMap)
+errs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  errs() << "\nUse -march to specify the target's extension.\n"
+"For example, clang -march=rv32i_v1p0\n";
+}
+
 static bool stripExperimentalPrefix(StringRef &Ext) {
   return Ext.consume_front("experimental-");
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -23,6 +23,8 @@
   unsigned MinorVersion;
 };
 
+void riscvMarchHelp();
+
 class RISCVISAInfo {
 public:
   RISCVISAInfo(const RISCVISAInfo &) = delete;
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -182,6 +183,14 @@
   return 0;
 }
 
+/// Print supported extensions of the given target.
+static int PrintSupportedExtensions(std::string TargetStr) {
+  llvm::riscvMarchHelp();
+
+  return 0;
+}
+
+
 int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) {
   ensureSufficientStack();
 
@@ -223,6 +232,10 @@
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
 return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
 
+  // --print-supported-extensions takes priority over the actual compilation.
+  if (Clang->getFrontendOpts().PrintSupportedExtensions)
+return PrintSupportedExtensions(Clang->getTargetOpts().Triple);
+
   // Infer the builtin include path if unspecified.
   if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
   Clang->getHeaderSearchOpts().ResourceDir.empty())
Index: clang/test/Driver/print-supported-extensions.c
===
--- /dev/null
+++ clang/test/Driver/print-supported-extensions.c
@@ -0,0 +1,94 @@
+// Test that --print-supported-extensions lists supported extensions.
+
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang --target=riscv64 --print-supported-extensions 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+
+// CHECK-NOT: warning: argument unused during compilation
+// CHECK-RISCV: Target: riscv64
+// CHECK-NEXT: All available -march extensions for RISC-V
+// CHECK-NEXT: 	NameVersion
+// CHECK-NEXT: 	i   2.0
+// CHECK-NEXT: 	e   1.9
+// CHECK-NEXT: 	m   2.0
+// CHECK-NEXT: 	a   2.0
+// CHECK-NEXT: 	f   2.0
+// CHECK-NEXT: 	d   2.0
+// CHECK-NEXT: 	c   2.0
+// CHECK-NEXT: 	v   1.0
+// CHECK-NEXT: 	h   1.0
+// CHECK-NEXT: 	svinval 1.0
+// CHECK-NEXT: 	svnapot 1.0
+// CHECK-NEXT: 	svpbmt  1.0
+// CHECK-NEXT: 	zicbom  1.0
+// CHECK-NEXT: 	zicbop  1.0
+// CHECK-NEXT: 	zicboz  1.0
+// CHECK-NEXT: 	zicsr   2.0
+// CHECK-NEXT: 	zifencei2.0
+// CHECK-NEXT: 	zihintpause 2.0
+// CHECK-NEXT: 	zmmul   1.0
+// CHECK-NEXT: 	zawrs   1.0
+// CHECK-NEXT: 	zfh 1.0
+// CHECK-NEXT: 	zfhmin  

[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Build failures look unrelated to my changes, it looks like it was failing 
before this.


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

https://reviews.llvm.org/D150226

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


[PATCH] D137397: [Sanitizer] [Scudo] Add riscv64 support for scudo

2023-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: asb.

2538e550420fed5036d224fd93e9145c845f0ffe 
 contains 
`Reviewers: cryptoad, eugenis, vitalybuka, luismarques, hiraditya`.
The reviewer list isn't useful. Just drop it for future commits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137397

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


[clang] 7adf384 - [docs] [C++20] [Modules] Remove the section 'Source content consistency'

2023-05-09 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-05-10T09:59:50+08:00
New Revision: 7adf3849e40e0b9faa3512874e2a1dc4cf86387a

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

LOG: [docs] [C++20] [Modules] Remove the section 'Source content consistency'

Since the C++20 named modules won't check source files consistency after
5b388f8, it would be better to remove this section in the document.

Added: 


Modified: 
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index a59a3edbbbac..ee8ffe9ec8c9 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -461,109 +461,6 @@ Note that **currently** the compiler doesn't consider 
inconsistent macro definit
 Currently Clang would accept the above example. But it may produce surprising 
results if the
 debugging code depends on consistent use of ``NDEBUG`` also in other 
translation units.
 
-Source content consistency
-^^
-
-When the compiler reads a BMI, the compiler will check the consistency of the 
corresponding
-source files. For example:
-
-.. code-block:: c++
-
-  // M.cppm
-  export module M;
-  export template 
-  T foo(T t) {
-return t;
-  }
-
-  // Use.cpp
-  import M;
-  void bar() {
-foo(5);
-  }
-
-.. code-block:: console
-
-  $ clang++ -std=c++20 M.cppm --precompile -o M.pcm
-  $ rm M.cppm
-  $ clang++ -std=c++20 Use.cpp -fmodule-file=M=M.pcm
-
-The compiler would reject the example since the compiler failed to find the 
source file to check the consistency.
-So the following example would be rejected too.
-
-.. code-block:: console
-
-  $ clang++ -std=c++20 M.cppm --precompile -o M.pcm
-  $ echo "int i=0;" >> M.cppm
-  $ clang++ -std=c++20 Use.cpp -fmodule-file=M=M.pcm
-
-The compiler would reject it too since the compiler detected the file was 
changed.
-
-But it is OK to move the BMI as long as the source files remain:
-
-.. code-block:: console
-
-  $ clang++ -std=c++20 M.cppm --precompile -o M.pcm
-  $ mkdir -p tmp
-  $ mv M.pcm tmp/M.pcm
-  $ clang++ -std=c++20 Use.cpp -fmodule-file=M=tmp/M.pcm
-
-The above example would be accepted.
-
-If the user doesn't want to follow the consistency requirement due to some 
reasons (e.g., distributing BMI),
-the user could try to use ``-Xclang -fmodules-embed-all-files`` when producing 
BMI. For example:
-
-.. code-block:: console
-
-  $ clang++ -std=c++20 M.cppm --precompile -Xclang -fmodules-embed-all-files 
-o M.pcm
-  $ rm M.cppm
-  $ clang++ -std=c++20 Use.cpp -fmodule-file=M=M.pcm
-
-Now the compiler would accept the above example.
-Important note: Xclang options are intended to be used by compiler internally 
and its semantics
-are not guaranteed to be preserved in future versions.
-
-Also the compiler will record the path to the header files included in the 
global module fragment and compare the
-headers when imported. For example,
-
-.. code-block:: c++
-
-  // foo.h
-  #include 
-  void Hello() {
-std::cout << "Hello World.\n";
-  }
-
-  // foo.cppm
-  module;
-  #include "foo.h"
-  export module foo;
-  export using ::Hello;
-
-  // Use.cpp
-  import foo;
-  int main() {
-Hello();
-  }
-
-Then it is problematic if we remove ``foo.h`` before import `foo` module.
-
-.. code-block:: console
-
-  $ clang++ -std=c++20 foo.cppm --precompile  -o foo.pcm
-  $ mv foo.h foo.orig.h
-  # The following one is rejected
-  $ clang++ -std=c++20 Use.cpp -fmodule-file=foo=foo.pcm -c
-
-The above case will rejected. And we're still able to workaround it by 
``-Xclang -fmodules-embed-all-files`` option:
-
-.. code-block:: console
-
-  $ clang++ -std=c++20 foo.cppm --precompile  -Xclang 
-fmodules-embed-all-files -o foo.pcm
-  $ mv foo.h foo.orig.h
-  $ clang++ -std=c++20 Use.cpp -fmodule-file=foo=foo.pcm -c -o Use.o
-  $ clang++ Use.o foo.pcm
-
 ABI Impacts
 ---
 



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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I am wondering what section of the release notes to put this under.


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

https://reviews.llvm.org/D150226

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 520880.
shafik added a comment.

- Apply clang-format


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

https://reviews.llvm.org/D150226

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx11.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
@@ -900,12 +900,12 @@
 namespace GH50055 {
 enum E {e1=0, e2=1};
 consteval int testDefaultArgForParam(E eParam = (E)-1) {
-// expected-error@-1 {{integer value -1 is outside the valid range of values [0, 1] for this enumeration type}}
+// expected-note@-1 {{integer value -1 is outside the valid range of values [0, 1] for this enumeration type}}
   return (int)eParam;
 }
 
 int test() {
-  return testDefaultArgForParam() + testDefaultArgForParam((E)1);
+  return testDefaultArgForParam() + testDefaultArgForParam((E)1); // expected-error {{call to consteval function 'GH50055::testDefaultArgForParam' is not a constant expression}}
 }
 }
 
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2439,39 +2439,39 @@
 
 void testValueInRangeOfEnumerationValues() {
   constexpr E1 x1 = static_cast(-8);
-  constexpr E1 x2 = static_cast(8);
-  // expected-error@-1 {{integer value 8 is outside the valid range of values [-8, 7] for this enumeration type}}
+  constexpr E1 x2 = static_cast(8); // expected-error {{constexpr variable 'x2' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values [-8, 7] for this enumeration type}}
   E1 x2b = static_cast(8); // ok, not a constant expression context
 
-  constexpr E2 x3 = static_cast(-8);
-  // expected-error@-1 {{integer value -8 is outside the valid range of values [0, 7] for this enumeration type}}
+  constexpr E2 x3 = static_cast(-8); // expected-error {{constexpr variable 'x3' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value -8 is outside the valid range of values [0, 7] for this enumeration type}}
   constexpr E2 x4 = static_cast(0);
-  constexpr E2 x5 = static_cast(8);
-  // expected-error@-1 {{integer value 8 is outside the valid range of values [0, 7] for this enumeration type}}
+  constexpr E2 x5 = static_cast(8); // expected-error {{constexpr variable 'x5' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values [0, 7] for this enumeration type}}
 
   constexpr E3 x6 = static_cast(-2048);
   constexpr E3 x7 = static_cast(-8);
   constexpr E3 x8 = static_cast(0);
   constexpr E3 x9 = static_cast(8);
-  constexpr E3 x10 = static_cast(2048);
-  // expected-error@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for this enumeration type}}
+  constexpr E3 x10 = static_cast(2048); // expected-error {{constexpr variable 'x10' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for this enumeration type}}
 
   constexpr E4 x11 = static_cast(0);
   constexpr E4 x12 = static_cast(1);
-  constexpr E4 x13 = static_cast(2);
-  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
+  constexpr E4 x13 = static_cast(2); // expected-error {{constexpr variable 'x13' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
 
   constexpr EEmpty x14 = static_cast(0);
   constexpr EEmpty x15 = static_cast(1);
-  constexpr EEmpty x16 = static_cast(2);
-  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
+  constexpr EEmpty x16 = static_cast(2);  // expected-error {{constexpr variable 'x16' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
 
   constexpr EFixed x17 = static_cast(100);
   constexpr EScoped x18 = static_cast(100);
 
   constexpr EMaxInt x19 = static_cast(__INT_MAX__-1);
-  constexpr EMaxInt x20 = static_cast((long)__INT_MAX__+1);
-  // expected-error@-1 {{integer value 2147483648 is outside the valid range of values [-2147483648, 2147483647] for this enumeration type}}
+  constexpr EMaxInt x20 = static_cast((long)__INT_MAX__+1); // expected-error {{constexpr variable 'x20' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2147483648 is outside the valid range of values [-2147483648, 2147

[PATCH] D149119: [CMake] Use LLVM own tools in extract_symbols.py

2023-05-09 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin added a comment.

In D149119#4329274 , @tmatheson wrote:

> LGTM, thank you for doing this. Please give it a couple of days in case 
> others have comments.

Thanks!

In D149119#4329285 , @jhenderson 
wrote:

> I've not really looked into this patch significantly, so this may well be 
> addressed in the patch, given I see you have modified stuff to do with the 
> NATIVE build, but in the past I have seen LLVM using its own tools to build 
> other parts of its system. I believe it was using llvm-nm to extract the list 
> of symbols needed for export, possibly to do with part of the clang build, 
> possibly even using this script, I don't remember. The problem was that it 
> was using the just-built version of llvm-nm, rather than specifically one 
> from a release build. On a debug build this caused particularly slow builds 
> for me, so much so that I stopped building the relevant parts of LLVM. Please 
> don't introduce a similar situation/make the situation worse (it's quite 
> possible this was fixed some time ago, but I haven't tried recently, nor do I 
> remember the exact thing causing the issue): much like tablegen, any parts of 
> the LLVM build that use just-built tools should make use of release builds, 
> even in debug configuration, at least if an appropriate cmake option is 
> specified.

Your concerns are legit, but the tools in this patch follow the same principle 
as `TableGen`, i.e. if `LLVM_OPTIMIZED_TABLEGEN` is `ON` then the tools are 
forced to be built with optimization.

In D149119#4329618 , @beanz wrote:

> One potential area of concern here: If `llvm-driver` is ever extended to work 
> as a plugin loader (thus exporting its symbols), removing support for the 
> pre-installed host tools could cause a cyclic dependency.

In that case, we will need to add an option to build the tools without plugin 
support so that they can be used in the build process.


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

https://reviews.llvm.org/D149119

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


[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-09 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:302
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Shift >= 64 && "Shift is out of encodable range");
   return (V << Shift) & Mask;

Manna wrote:
> sdesmalen wrote:
> > erichkeane wrote:
> > > sdesmalen wrote:
> > > > erichkeane wrote:
> > > > > Shouldn't this be: `assert(Shift < 64 &&"...")`?
> > > > > 
> > > > > `expr.shift` (https://eel.is/c++draft/expr.shift) says:
> > > > > ```
> > > > > The operands shall be of integral or unscoped enumeration type and 
> > > > > integral promotions are performed.
> > > > > The type of the result is that of the promoted left operand.
> > > > > The behavior is undefined if the right operand is negative, or 
> > > > > greater than or equal to the width of the promoted left operand.```
> > > > > 
> > > > > uint64 stays as an `unsigned long`, so it is still 64 bits, so the 
> > > > > only invalid value for `Shift` is 64 (though >64 is 'nonsense', but 
> > > > > only impossible because of `llvm::countr_zero`).
> > > > > 
> > > > > One thing to consider: I wonder if we should instead be changing the 
> > > > > 'shift' to be:
> > > > > 
> > > > > `(V << (Shift % 64)) && Mask` ?  It looks like `arm_sve.td` has the 
> > > > > `NoFlags` value as zero, which I think will end up going through here 
> > > > > possibly (or at least, inserted into `FlagTypes`.
> > > > > 
> > > > > So I suspect an assert might not be sufficient, since a 64 bit shift 
> > > > > is possible in that case (since a zero 'Mask' is the only case where 
> > > > > `countr_zero` will end up being 64).
> > > > > 
> > > > > 
> > > > > So I suspect an assert might not be sufficient, since a 64 bit shift 
> > > > > is possible in that case (since a zero 'Mask' is the only case where 
> > > > > countr_zero will end up being 64).
> > > > It should be fine to assert that `Mask != 0`, since that would be an 
> > > > invalid mask.
> > > Thanks for the comment @sdesmalen!  Is there something that prevents the 
> > > `NoFlags` from being passed as the `MaskName` here?  
> > There's nothing that actively prevents it, but `encodeFlag` is a utility 
> > function that has no uses outside this file and has only 4 uses. Adding an 
> > assert should be sufficient.
> Thank you for the explanation!
I'm not sure if asserting `Mask != 0` will suffice to silence Coverity. While 
Coverity can specifically observe that `countr_zero` might return 0 (because 
`TrailingZerosCounter::count()` has a `return 64` statement), I don't 
think Coverity can determine that the function can't return 65 or higher. I 
think Erich's initial intuition is correct; the concern that Coverity is 
reporting is that the shift might overflow, so that is what should be guarded.
  assert(Shift < 64 && "Mask value produced an invalid shift value");


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

https://reviews.llvm.org/D150140

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-09 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann requested changes to this revision.
tahonermann added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Sema/Sema.h:1786
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &&D);
+SemaDiagnosticBuilder &operator=(SemaDiagnosticBuilder &&D);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;

Manna wrote:
> tahonermann wrote:
> > Since this class declares a move constructor, the declaration of the 
> > implicit move assignment operator is inhibited and the implicitly declared 
> > assignment operator is defined as deleted. This change declares a move 
> > assignment operator but doesn't define it (perhaps `= delete` was 
> > intended?). If support for assignment is not desired, then I think a 
> > declaration of a deleted copy assignment operator is all that is needed 
> > (matching the change made for `Strategy` below). Otherwise, I think a 
> > defaulted copy assignment operator should be declared and a move assignment 
> > operator should be defined that implements the same behavior as the move 
> > constructor.
> Thanks @tahonermann for the comments. 
> 
> >> think a defaulted copy assignment operator should be declared and a move 
> >> assignment operator should be defined that implements the same behavior as 
> >> the move constructor.
> 
> I have updated patch based on further analysis and my understanding. This 
> seems reasonable to me.
This change still declares a move assignment operator, but doesn't provide a 
definition. The move constructor is implemented in `clang/lib/Sema/Sema.cpp`, 
so I would expect to see the move assignment operator definition provided there 
as well.


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

https://reviews.llvm.org/D149718

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


[PATCH] D149800: [WIP][PGO] Add ability to mark cold functions as optsize/minsize/optnone

2023-05-09 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D149800#4330831 , @davidxl wrote:

> This patch uses a cleaner method than the previous effort. There is some 
> differences:
>
> 1. yamauchi's patch works for both iFDO and autoFDO, while this patch limits 
> to iFDO
> 2. yamauchi's patch also handles size optimization (IIRC) at granularity 
> smaller than function
>
> Longer term, the previous functionality should fold into the new framework.

Could you clarify what "previous functionality" and "new framework" mean here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149800

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


[clang-tools-extra] 84deed2 - [clangd] Fix a build failure. NFC

2023-05-09 Thread Younan Zhang via cfe-commits

Author: Younan Zhang
Date: 2023-05-10T08:28:07+08:00
New Revision: 84deed2b7b6325f99d50ce46512de2c078cefb3a

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

LOG: [clangd] Fix a build failure. NFC

This is caused by 7385cc389aba.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 61bed1ad8141f..de589e70f4afa 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -468,9 +468,9 @@ struct PrintExprResult {
   std::optional PrintedValue;
   /// The Expr object that represents the closest evaluable
   /// expression.
-  const clang::Expr *Expr;
+  const clang::Expr *TheExpr;
   /// The node of selection tree where the traversal stops.
-  const SelectionTree::Node *Node;
+  const SelectionTree::Node *TheNode;
 };
 
 // Seek the closest evaluable expression along the ancestors of node N
@@ -731,12 +731,12 @@ HoverInfo evaluateMacroExpansion(unsigned int 
SpellingBeginOffset,
   // Attempt to evaluate it from Expr first.
   auto ExprResult = printExprValue(StartNode, Context);
   HI.Value = std::move(ExprResult.PrintedValue);
-  if (auto *E = ExprResult.Expr)
+  if (auto *E = ExprResult.TheExpr)
 HI.Type = printType(E->getType(), Context, PP);
 
   // If failed, extract the type from Decl if possible.
-  if (!HI.Value && !HI.Type && ExprResult.Node)
-if (auto *VD = ExprResult.Node->ASTNode.get())
+  if (!HI.Value && !HI.Type && ExprResult.TheNode)
+if (auto *VD = ExprResult.TheNode->ASTNode.get())
   HI.Type = printType(VD->getType(), Context, PP);
 
   return HI;

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 677cd5c4e6323..f95c947559936 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3998,7 +3998,8 @@ constexpr u64 pow_with_mod(u64 a, u64 b, u64 p) {
   auto H = getHover(AST, C.point(), format::getLLVMStyle(), nullptr);
 
   ASSERT_TRUE(H);
-  EXPECT_EQ(H->Value, "4");
+  EXPECT_TRUE(H->Value);
+  EXPECT_TRUE(H->Type);
 }
 
 } // namespace



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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-05-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 520861.
ahatanak added a comment.

Disable `llvm-symbolizer` individually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

Files:
  clang/test/Driver/crash-diagnostics-dir-3.c
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/emit-reproducer.c
  clang/test/Driver/output-file-cleanup.c
  clang/test/Driver/rewrite-map-in-diagnostics.c


Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf "%t"
 // RUN: mkdir -p "%t"
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
Index: clang/test/Driver/output-file-cleanup.c
===
--- clang/test/Driver/output-file-cleanup.c
+++ clang/test/Driver/output-file-cleanup.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
 //
 // RUN: touch %t.s
Index: clang/test/Driver/emit-reproducer.c
===
--- clang/test/Driver/emit-reproducer.c
+++ clang/test/Driver/emit-reproducer.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t && mkdir %t
 
 // RUN: echo "%s -fcrash-diagnostics-dir=%t -fsyntax-only" | sed -e 
's/\\//g' > %t.rsp
Index: clang/test/Driver/crash-report.cpp
===
--- clang/test/Driver/crash-report.cpp
+++ clang/test/Driver/crash-report.cpp
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
Index: clang/test/Driver/crash-report-with-asserts.c
===
--- clang/test/Driver/crash-report-with-asserts.c
+++ clang/test/Driver/crash-report-with-asserts.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
Index: clang/test/Driver/crash-report-spaces.c
===
--- clang/test/Driver/crash-report-spaces.c
+++ clang/test/Driver/crash-report-spaces.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf "%t"
 // RUN: mkdir "%t"
 // RUN: cp "%s" "%t/crash report spaces.c"
Index: clang/test/Driver/crash-report-header.h
===
--- clang/test/Driver/crash-report-header.h
+++ clang/test/Driver/crash-report-header.h
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 not %clang 
-fsyntax-only %s 2>&1 | FileCheck %s
Index: clang/test/Driver/crash-report-clang-cl.cpp
===
--- clang/test/Driver/crash-report-clang-cl.cpp
+++ clang/test/Driver/crash-report-clang-cl.cpp
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
Index: clang/test/Driver/crash-diagnostics-dir.c
===
--- clang/test/Driver/crash-diagnostics-dir.c
+++ clang/test/Driver/crash-diagnostics-dir.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
 #pragma clang __debug parser_crash
Index: clang/test/Driver/crash-diagnostics-dir-3.c
===
--- clang/test/Driver/crash-diagnostics-dir-3.c
+++ clang/test/Driver/crash-diagnostics-dir-3.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: not env CLANG_CRASH_DIAGNOSTICS_DIR=%t %clang -c %s -o - 2>&1 | 
FileCheck %s
 #pragma clang __debug parser_crash


Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,

[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D149193#4331015 , @dyung wrote:

> Hi @MaskRay, the test you modified clang/test/Driver/split-debug.c is failing 
> on the PS5 Windows bot, can you take a look?
>
> https://lab.llvm.org/buildbot/#/builders/216/builds/20981
>
>   # command stderr:
>   
> Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Driver\split-debug.c:72:21:
>  error: SPLIT_LINK_NULL: expected string not found in input
>   // SPLIT_LINK_NULL: "-dumpdir" "/dev/null-"
>   ^
>   :1:1: note: scanning from here
>   clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
> 16a0a69aadf1ad04efeaab9073bebdfb4b4fd34f)
>   ^
>   :5:130: note: possible intended match here
>"z:\\b\\llvm-clang-x86_64-sie-win\\build\\bin\\clang.exe" "-cc1" "-triple" 
> "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-dumpdir" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-" 
> "-disable-free" "-clear-ast-before-backend" "-main-file-name" "split-debug.c" 
> "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" 
> "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" 
> "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" 
> "-tune-cpu" "generic" "-debug-info-kind=constructor" "-dwarf-version=5" 
> "-debugger-tuning=gdb" "-ggnu-pubnames" "-split-dwarf-file" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
>  "-split-dwarf-output" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
>  
> "-fcoverage-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
>  "-resource-dir" "z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17" 
> "-internal-isystem" 
> "z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17\\include" 
> "-internal-isystem" "/usr/local/include" "-internal-externc-isystem" 
> "/include" "-internal-externc-isystem" "/usr/include" 
> "-fdebug-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
>  "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-faddrsig" 
> "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\split-debug-c67aff.o"
>  "-x" "c" 
> "Z:\\b\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver\\split-debug.c"
>   
>  ^
>   Input file: 
>   Check file: 
> Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Driver\split-debug.c
>   -dump-input=help explains the following input dump.
>   Input was:
>   <<
>   1: clang version 17.0.0 
> (https://github.com/llvm/llvm-project.git 
> 16a0a69aadf1ad04efeaab9073bebdfb4b4fd34f) 
>   check:72'0 
> X
>  error: no match found
>   2: Target: x86_64-unknown-linux-gnu 
>   check:72'0 ~
>   3: Thread model: posix 
>   check:72'0 
>   4: InstalledDir: z:\b\llvm-clang-x86_64-sie-win\build\bin 
>   check:72'0 ~~~
>   5:  "z:\\b\\llvm-clang-x86_64-sie-win\\build\\bin\\clang.exe" 
> "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" 
> "-dumpdir" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-" 
> "-disable-free" "-clear-ast-before-backend" "-main-file-name" "split-debug.c" 
> "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" 
> "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" 
> "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" 
> "-tune-cpu" "generic" "-debug-info-kind=constructor" "-dwarf-version=5" 
> "-debugger-tuning=gdb" "-ggnu-pubnames" "-split-dwarf-file" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
>  "-split-dwarf-output" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
>  
> "-fcoverage-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
>  "-resource-dir" "z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17" 
> "-internal-isystem" 
> "z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17\\include" 
> "-internal-isystem" "/usr/local/include" "-internal-externc-isystem" 
> "/include" "-internal-externc-isystem" "/usr/include" 
> "-fdebug-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
>  "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-faddrsig" 
> "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
> "C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\split-debug-c67aff.o"
>  "-x" "c" 
> "Z:\\b\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\

[clang] 8b16fc2 - [Driver][test] Exclude `-o /dev/null` test for Windows

2023-05-09 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-09T16:44:15-07:00
New Revision: 8b16fc2e17c0149125e339f45d66f6c4eac9fec8

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

LOG: [Driver][test] Exclude `-o /dev/null` test for Windows

lit changes /dev/null to a special filename, and `"-dumpdir" "/dev/null-"` will 
fail.

Added: 


Modified: 
clang/test/Driver/split-debug.c

Removed: 




diff  --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 19214f997c66..e45d2e19bb81 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -67,7 +67,7 @@
 
 /// GCC special cases /dev/null (HOST_BIT_BUCKET) but not other special files 
like /dev/zero.
 /// We don't apply special rules at all.
-// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o 
/dev/null 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_NULL
+// RUN: %if !system-windows %{ %clang -### --target=x86_64-unknown-linux-gnu 
-gsplit-dwarf -g %s -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=SPLIT_LINK_NULL %}
 
 // SPLIT_LINK_NULL:  "-dumpdir" "/dev/null-"
 // SPLIT_LINK_NULL-SAME: "-split-dwarf-output" "/dev/null-split-debug.dwo"



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


[PATCH] D150209: [clang][Interp] Add more shift error checking

2023-05-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:133
+// operand, and must not overflow the corresponding unsigned type.
+// C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+// E1 x 2^E2 module 2^N.

Maybe this quote for C++20 should be moved below the else block with a comment 
noting that C++20 forward the above is no longer UB? My first reading I thought 
the second quote applied to the `else if` below and was super confused.



Comment at: clang/lib/AST/Interp/Interp.h:136
+if (LHS.isNegative())
+  S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << 12;
+else if (LHS.toUnsigned().countLeadingZeros() < static_cast(RHS))

Do we test this diagnostic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150209

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


[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-05-09 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi @MaskRay, the test you modified clang/test/Driver/split-debug.c is failing 
on the PS5 Windows bot, can you take a look?

https://lab.llvm.org/buildbot/#/builders/216/builds/20981

  # command stderr:
  
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Driver\split-debug.c:72:21:
 error: SPLIT_LINK_NULL: expected string not found in input
  // SPLIT_LINK_NULL: "-dumpdir" "/dev/null-"
  ^
  :1:1: note: scanning from here
  clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
16a0a69aadf1ad04efeaab9073bebdfb4b4fd34f)
  ^
  :5:130: note: possible intended match here
   "z:\\b\\llvm-clang-x86_64-sie-win\\build\\bin\\clang.exe" "-cc1" "-triple" 
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-dumpdir" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-" 
"-disable-free" "-clear-ast-before-backend" "-main-file-name" "split-debug.c" 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" 
"-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" 
"-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" 
"-debug-info-kind=constructor" "-dwarf-version=5" "-debugger-tuning=gdb" 
"-ggnu-pubnames" "-split-dwarf-file" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
 "-split-dwarf-output" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
 
"-fcoverage-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-resource-dir" "z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17" 
"-internal-isystem" 
"z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17\\include" 
"-internal-isystem" "/usr/local/include" "-internal-externc-isystem" "/include" 
"-internal-externc-isystem" "/usr/include" 
"-fdebug-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-faddrsig" 
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\split-debug-c67aff.o"
 "-x" "c" 
"Z:\\b\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver\\split-debug.c"

   ^
  Input file: 
  Check file: 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Driver\split-debug.c
  -dump-input=help explains the following input dump.
  Input was:
  <<
  1: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
16a0a69aadf1ad04efeaab9073bebdfb4b4fd34f) 
  check:72'0 
X
 error: no match found
  2: Target: x86_64-unknown-linux-gnu 
  check:72'0 ~
  3: Thread model: posix 
  check:72'0 
  4: InstalledDir: z:\b\llvm-clang-x86_64-sie-win\build\bin 
  check:72'0 ~~~
  5:  "z:\\b\\llvm-clang-x86_64-sie-win\\build\\bin\\clang.exe" 
"-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" 
"-dumpdir" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-" 
"-disable-free" "-clear-ast-before-backend" "-main-file-name" "split-debug.c" 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" 
"-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" 
"-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" 
"-debug-info-kind=constructor" "-dwarf-version=5" "-debugger-tuning=gdb" 
"-ggnu-pubnames" "-split-dwarf-file" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
 "-split-dwarf-output" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\tmpq2vte1gy-split-debug.dwo"
 
"-fcoverage-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-resource-dir" "z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17" 
"-internal-isystem" 
"z:\\b\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\17\\include" 
"-internal-isystem" "/usr/local/include" "-internal-externc-isystem" "/include" 
"-internal-externc-isystem" "/usr/include" 
"-fdebug-compilation-dir=Z:\\b\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-faddrsig" 
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-zjxfa_79\\split-debug-c67aff.o"
 "-x" "c" 
"Z:\\b\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver\\split-debug.c"
 
  check:72'0 
~~

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-09 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 520859.
ziqingluo-90 added a comment.

Visit `LambdaExpr` properly


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

https://reviews.llvm.org/D146342

Files:
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-objc-method-traversal.mm
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -220,11 +220,11 @@
 void testTemplate(int * p) {
   int *a[10];
   foo(f(p, &p, a, a)[1]); // expected-warning{{unsafe buffer access}}
-  // expected-note@-1{{in instantiation of function template specialization 'f' requested here}}
+  // FIXME: expected note@-1{{in instantiation of function template specialization 'f' requested here}}
 
   const int **q = const_cast(&p);
 
-  testPointerArithmetic(p, q, p); //expected-note{{in instantiation of}}
+  testPointerArithmetic(p, q, p); //FIXME: expected note{{in instantiation of}}
 }
 
 void testPointerToMember() {
@@ -315,7 +315,7 @@
   foo(ar[5]);   // expected-note{{used in buffer access here}}
 }
 
-template void fArr(int t[]); // expected-note {{in instantiation of}}
+template void fArr(int t[]); // FIXME: expected note {{in instantiation of}}
 
 int testReturn(int t[]) {
   // expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-objc-method-traversal.mm
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-objc-method-traversal.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-objc-root-class -Wno-return-type -Wunsafe-buffer-usage %s -verify %s
+
+// This test is to show that ObjC methods are traversed by the
+// end-of-TU analysis properly.  Particularly, a method body will not
+// be repeatedly visited whenever a method prototype of it is visited.
+
+@interface I
++ f:(int *) p; // duplicated method prototype declaration
+
++ f:(int *) p;
+
++ f:(int *) p;
+@end
+
+@implementation I
++ f:(int *) p { // expected-warning{{'p' is an unsafe pointer used for buffer access}}
+  int tmp;
+  tmp = p[5];  // expected-note{{used in buffer access here}}
+}
+@end
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1426,6 +1426,8 @@
 }
   }
 
+  AnalysisWarnings.IssueWarnings(Context.getTranslationUnitDecl());
+
   // Check we've noticed that we're no longer parsing the initializer for every
   // variable. If we miss cases, then at best we have a performance issue and
   // at worst a rejects-valid bug.
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Sema/AnalysisBasedWarnings.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -25,6 +26,8 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
 #include "clang/Analysis/Analyses/CalledOnceCheck.h"
 #include "clang/Analysis/Analyses/Consumed.h"
@@ -2290,6 +2293,94 @@
 S.Diag(D.Loc, D.PD);
 }
 
+void clang::sema::AnalysisBasedWarnings::IssueWarnings(
+const TranslationUnitDecl *TU) {
+  if (!TU)
+return; // This is unexpected, give up quietly.
+
+  DiagnosticsEngine &Diags = S.getDiagnostics();
+  const bool EmitFixits =
+  Diags.getDiagnosticOptions().ShowFixits && S.getLangOpts().CPlusPlus20;
+
+  if (S.hasUncompilableErrorOccurred() || Diags.getIgnoreAllWarnings())
+// exit if having uncompilable errors or ignoring all warnings:
+return;
+
+  // An AST Visitor that calls analyzers on each callable definition:
+  class CallableVisitor : public RecursiveASTVisitor {
+  private:
+Sema &S;
+const bool EmitFixits;
+
+  public:
+CallableVisitor(Sema &S, bool EmitFixits) : S(S), EmitFixits(EmitFixits) {}
+
+bool TraverseDecl(Decl *Node) {
+  if (!Node)
+return true;
+
+  // Do not analyze any `Decl` if we are going to just ignore them.
+  DiagnosticsEngine &Diags = S.getDiagnostics();
+
+  if (Diags.getSuppressSystemWarnings() &&
+  S.SourceMgr.isInSystemHeader(Node->getLocation()))
+return true;
+  // Continue to

[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-09 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs added a comment.

Hi @rjmccall and @erichkeane,

I would like to inquire about the necessity of implementing excess precision 
support for `std::bfloat16_t` in this patch. In reference to the discussion on 
https://reviews.llvm.org/D136919, it was mentioned that introducing 
`std::bfloat16_t` in Clang requires proper mangling, semantics, and excess 
precision support.

However, this change includes a front-end flag that enables `bfloat16` 
arithmetic only when the target natively supports `bfloat16` operations. Given 
this restriction, is it still essential to provide excess precision support for 
`std::bfloat16_t` in this patch?

Thank you for your guidance.


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

https://reviews.llvm.org/D149573

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-05-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D146148#4330611 , @zahiraam wrote:

> In D146148#4221651 , @rjmccall 
> wrote:
>
>> In D146148#4220591 , @zahiraam 
>> wrote:
>>
>>> In D146148#4220495 , 
>>> @aaron.ballman wrote:
>>>
 In D146148#4220433 , @zahiraam 
 wrote:

> In D146148#4220268 , @rjmccall 
> wrote:
>
>> Okay, so modifying `math.h` to use this attribute is acceptable?  That's 
>> great, that's definitely the best outcome for the compiler.
>>
>> Just a minor request about the diagnostic name, but otherwise LGTM.
>
> Yes. Added the attribute inside the included math.h header file.

 How does this work for, say, glibc, musl, or MSVC CRT? Won't those math.h 
 headers lack the attribute and thus run into problems when used with Clang?
>>>
>>> Good point! @rjmccall are you thinking of something in particular with the 
>>> attribute?
>>
>> Zahira, this is what I was asking you when I asked whether modifying the 
>> math.h header was acceptable: whether you were prepared to accept that the 
>> warning would only fire on system math.h headers that we'd modified, or 
>> whether you cared about making it work with non-cooperative headers.  I 
>> wasn't asking if you were willing to change the test code.
>>
>>> If not I guess we will have to rely on string comparison for all the 
>>> typedef in the TU. Aaron pointed out the compile time overhead.
>>
>> Well, the compile-time overhead of doing this on every typedef *declaration* 
>> is way better than the overhead of doing this on every type lookup, at least.
>>
>> Anyway, there are three possibilities I can see:
>>
>> - We accept that this needs cooperative system headers.
>> - We add a math.h compiler header that `#include_next`s the system math.h 
>> and then adds the attribute.  I believe you can just add an attribute to a 
>> typedef retroactively with something like `typedef float_t float_t 
>> __attribute__((whatever))`.
>> - We do checks on every typedef declaration.  There's a builtin-identifier 
>> trick that we do with library functions that we should be able to generalize 
>> to typedefs, so you wouldn't need to actually do string comparisons, you'd 
>> just check whether the `IdentifierInfo*` was storing a special ID.  We'd set 
>> that up in `initializeBuiltins` at the start of the translation unit, so the 
>> overhead would just be that we'd create two extra `IdentifierInfo*`s in 
>> every TU.
>>
>> The builtin ID logic is currently specific to builtin *functions*, and I 
>> don't think we'd want to hack typedef names into that.  But the same storage 
>> in `IdentifierInfo*` is also used for identifying the ObjC context-sensitive 
>> keywords, by just offsetting the builtin IDs by the NUM_OBJC_KEYWORD.  You 
>> should be able to generalize that by also introducing a concept of a builtin 
>> *type* name, so that e.g. IDs in [0,NUM_OBJC_KEYWORDS) are ObjCKeywordKinds, 
>> IDs in [NUM_OBJC_KEYWORDS, NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES) are 
>> BuiltinTypeKinds (when you subtract NUM_OBJC_KEYWORDS), and IDs in 
>> [NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES,∞) are builtin function IDs (when you 
>> subtract NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES).
>
> Reading this more carefully... Does that mean that we initialize the float_t, 
> double_t in initializeBuiltins  even if they are not used in the source code?

Yes.  If we decide this is an overhead worth eliminating, we'll find a way to 
do it lazily to the builtins, and then we'll be able to take advantage of it 
here, too.  The builtins are a much larger contributor to overhead.

> Also not sure how to define the NUM_BUILTIN_TYPES since I don't need to add 
> it to TokenKinds.h? I was proposing to do something like this:
> enum InterestingIdentifierKind {
> #define Interesting_Identifier(X) X,
> #include "clang/Basic/TokenKinds.def"
>
>   NUM_INTERESTING_IDENTIFIERS
>
> };
> But I guess I don't need since we don't want to add additional storage. Do I 
> understand things correctly?

We should have an enum like this, yes.  And this is what we do in 
`IdentifierTable.h` for all the other kinds.  Alternatively, you can just 
hard-code the number and then static_assert that it's correct in some .cpp file.

FWIW, I think I like NUM_INTERESTING_IDENTIFIERS as a name rather than 
NUM_BUILTIN_TYPES.


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

https://reviews.llvm.org/D146148

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-09 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs marked an inline comment as done.
codemzs added a comment.

Hi @rjmccall and @erichkeane,

I would like to inquire about the necessity of implementing excess precision 
support for `std::bfloat16_t` in this patch. In reference to the discussion on 
https://reviews.llvm.org/D136919, it was mentioned that introducing 
`std::bfloat16_t` in Clang requires proper mangling, semantics, and excess 
precision support.

However, this change includes a front-end flag that enables `bfloat16` 
arithmetic only when the target natively supports `bfloat16` operations. Given 
this restriction, is it still essential to provide excess precision support for 
`std::bfloat16_t` in this patch?

Thank you for your guidance.


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

https://reviews.llvm.org/D149573

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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-09 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td:15
+class SiFive7IsWorstCaseMX MxList> {
+  string LLMUL = LargestLMUL.r;
+  bit c = !eq(mx, LLMUL);

pcwang-thead wrote:
> I think I have fixed the issue that `defar` can't refer to template arguments 
> in D148197. So `LMUL`, `SSEW` and other fields can be replaced with `defvar`s.
A `defvar` statement defines a global variable. `SiFive7IsWorstCaseMX.c` becomes invalid syntax since `c` is not a member of 
`SiFive7IsWorstCaseMX` now that `c` is global. If we did use `defvar` here and 
gave `c` a more unique name so that it could fit in the global space, then we 
would also need to complicate it by adding a `MXxxx_MxListxxx` suffix for all 
`mx` and `SchedMxList` pairs. 

I think we'd like to keep these as `Type Iden = Value;`. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-09 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 520847.
michaelmaitland marked an inline comment as done.
michaelmaitland added a comment.

Remove extra space before VLUpperBound.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVScheduleV.td

Index: llvm/lib/Target/RISCV/RISCVScheduleV.td
===
--- llvm/lib/Target/RISCV/RISCVScheduleV.td
+++ llvm/lib/Target/RISCV/RISCVScheduleV.td
@@ -9,7 +9,7 @@
 //===--===//
 /// Define scheduler resources associated with def operands.
 
-defvar SchedMxList = ["M1", "M2", "M4", "M8", "MF2", "MF4", "MF8"];
+defvar SchedMxList = ["MF8", "MF4", "MF2", "M1", "M2", "M4", "M8"];
 // Used for widening and narrowing instructions as it doesn't contain M8.
 defvar SchedMxListW = !listremove(SchedMxList, ["M8"]);
 defvar SchedMxListFW = !listremove(SchedMxList, ["M8", "MF8"]);
@@ -38,6 +38,32 @@
 !eq(mx, "MF4"): [16]);
 }
 
+// Helper function to get the largest LMUL from MxList
+// Precondition: MxList is sorted in ascending LMUL order.
+class LargestLMUL MxList> {
+  // MX list is sorted from smallest to largest
+  string r = !foldl(!head(MxList), MxList, last, curr, curr);
+}
+// Helper function to get the smallest SEW that can be used with LMUL mx
+// Precondition: MxList is sorted in ascending LMUL order and SchedSEWSet
+class SmallestSEW {
+  int r = !head(!if(isF, SchedSEWSetF.val, SchedSEWSet.val));
+}
+
+// Creates WriteRes for (name, mx, resources) tuple
+multiclass LMULWriteResMX resources,
+  string mx, bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+multiclass LMULSEWWriteResMXSEW resources,
+ string mx, int sew,  bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx # "_E" # sew), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+
 // Define multiclasses to define SchedWrite, SchedRead,  WriteRes, and
 // ReadAdvance for each (name, LMUL) pair and for each LMUL in each of the
 // SchedMxList variants above. Each multiclass is responsible for defining
Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -8,6 +8,131 @@
 
 //===--===//
 
+/// c is true if mx has the worst case behavior compared to LMULs in MxList.
+/// On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMX MxList> {
+  string LLMUL = LargestLMUL.r;
+  bit c = !eq(mx, LLMUL);
+}
+
+/// c is true if mx and sew have the worst case behavior compared to LMULs in
+/// MxList. On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMXSEW MxList,
+   bit isF = 0> {
+  string LLMUL = LargestLMUL.r;
+  int SSEW = SmallestSEW.r;
+  bit c = !and(!eq(mx, LLMUL), !eq(sew, SSEW));
+}
+
+class SiFive7GetCyclesDefault {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "M8") : 16,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesWidening {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesNarrowing {
+  int c = !cond(
+!eq(mx, "M1") : 4,
+!eq(mx, "M2") : 8,
+!eq(mx, "M4") : 16,
+!eq(mx, "MF2") : 2,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesOutputLMUL {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 2,
+!eq(mx, "M4") : 4,
+!eq(mx, "M8") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesVMask {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 1,
+!eq(mx, "M4") : 1,
+!eq(mx, "M8") : 2,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+// Cycles for segmented loads and stores are calculated using the
+// formula ceil(2 * nf * lmul).
+class SiFive7GetCyclesSegmented {
+  int c = !cond(
+!eq(mx, "M1") : !mul(!mul(2, nf), 1),
+!eq(mx, "M2") : !mul(!mul(2, nf), 2),
+!eq(mx, "M4") : !mul(!mul(2, nf), 4),
+!eq(mx, "M8") : !mul(!mul(2, nf), 8),
+// We can calculate ceil(a/b) using (a + b - 1) / b.
+// Since the mult

[PATCH] D149800: [WIP][PGO] Add ability to mark cold functions as optsize/minsize/optnone

2023-05-09 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

This patch uses a cleaner method than the previous effort. There is some 
differences:

1. yamauchi's patch works for both iFDO and autoFDO, while this patch limits to 
iFDO
2. yamauchi's patch also handles size optimization (IIRC) at granularity 
smaller than function

Longer term, the previous functionality should fold into the new framework.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149800

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


[PATCH] D149999: [clang-tidy] [test] Narrow down a special case to MSVC mode

2023-05-09 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb80febdf43d3: [clang-tidy] [test] Narrow down a special case 
to MSVC mode (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D14

Files:
  
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
@@ -9,7 +9,7 @@
 typedef unsigned short  uint16_t;   // NOLINT
 typedef unsigned long   uint32_t;   // NOLINT
 typedef unsigned long long  uint64_t;   // NOLINT
-#ifndef _WIN32
+#ifndef _MSC_VER
 typedef unsigned long long  size_t; // NOLINT
 #endif
 typedef longintptr_t;   // NOLINT


Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
@@ -9,7 +9,7 @@
 typedef unsigned short  uint16_t;   // NOLINT
 typedef unsigned long   uint32_t;   // NOLINT
 typedef unsigned long long  uint64_t;   // NOLINT
-#ifndef _WIN32
+#ifndef _MSC_VER
 typedef unsigned long long  size_t; // NOLINT
 #endif
 typedef longintptr_t;   // NOLINT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149997: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

2023-05-09 Thread Martin Storsjö 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 rG7f037e5645bd: [clang] [test] Narrow down MSVC specific 
behaviours from "any windows" to only… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149997

Files:
  clang/test/C/drs/dr1xx.c
  clang/test/Driver/experimental-library-flag.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp


Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -5,11 +5,11 @@
 // Should not crash.
 template 
 class __attribute__((trivial_abi)) a { a(a &&); };
-#ifdef _WIN64
-// On Windows, to be trivial-for-calls, an object must be trivially copyable.
+#if defined(_WIN64) && defined(_MSC_VER)
+// On Windows/MSVC, to be trivial-for-calls, an object must be trivially 
copyable.
 // (And it is only trivially relocatable, currently, if it is trivial for 
calls.)
 // In this case, it is suppressed by an explicitly defined move constructor.
-// Similar concerns apply to later tests that have #ifdef _WIN64.
+// Similar concerns apply to later tests that have #if defined(_WIN64) && 
defined(_MSC_VER).
 static_assert(!__is_trivially_relocatable(a), "");
 #else
 static_assert(__is_trivially_relocatable(a), "");
@@ -137,7 +137,7 @@
   CopyDeleted(const CopyDeleted &) = delete;
   CopyDeleted(CopyDeleted &&) = default;
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(CopyDeleted), "");
 #else
 static_assert(__is_trivially_relocatable(CopyDeleted), "");
@@ -163,7 +163,7 @@
 struct __attribute__((trivial_abi)) S20 {
   int &&a; // a member of rvalue reference type deletes the copy constructor.
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(S20), "");
 #else
 static_assert(__is_trivially_relocatable(S20), "");
Index: clang/test/Driver/experimental-library-flag.cpp
===
--- clang/test/Driver/experimental-library-flag.cpp
+++ clang/test/Driver/experimental-library-flag.cpp
@@ -1,6 +1,6 @@
 // On some platforms, -stdlib=libc++ is currently ignored, so 
-lc++experimental is not added.
 // Once -stdlib=libc++ works on those, this XFAIL can be removed.
-// XFAIL: target={{.*-windows.*}}, target={{.*-(ps4|ps5)}}
+// XFAIL: target={{.*-windows-msvc.*}}, target={{.*-(ps4|ps5)}}
 
 // For some reason, this fails with a core dump on AIX. This needs to be 
investigated.
 // UNSUPPORTED: target={{.*}}-aix{{.*}}
Index: clang/test/C/drs/dr1xx.c
===
--- clang/test/C/drs/dr1xx.c
+++ clang/test/C/drs/dr1xx.c
@@ -235,7 +235,7 @@
 * type at this point.
 */
 Val = sizeof(enum E)
-#ifndef _WIN32
+#ifndef _MSC_VER
 /* expected-error@-2 {{invalid application of 'sizeof' to an incomplete 
type 'enum E'}} */
 /* expected-note@-12 {{definition of 'enum E' is not complete until the 
closing '}'}} */
 #endif


Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -5,11 +5,11 @@
 // Should not crash.
 template 
 class __attribute__((trivial_abi)) a { a(a &&); };
-#ifdef _WIN64
-// On Windows, to be trivial-for-calls, an object must be trivially copyable.
+#if defined(_WIN64) && defined(_MSC_VER)
+// On Windows/MSVC, to be trivial-for-calls, an object must be trivially copyable.
 // (And it is only trivially relocatable, currently, if it is trivial for calls.)
 // In this case, it is suppressed by an explicitly defined move constructor.
-// Similar concerns apply to later tests that have #ifdef _WIN64.
+// Similar concerns apply to later tests that have #if defined(_WIN64) && defined(_MSC_VER).
 static_assert(!__is_trivially_relocatable(a), "");
 #else
 static_assert(__is_trivially_relocatable(a), "");
@@ -137,7 +137,7 @@
   CopyDeleted(const CopyDeleted &) = delete;
   CopyDeleted(CopyDeleted &&) = default;
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(CopyDeleted), "");
 #else
 static_assert(__is_trivially_relocatable(CopyDeleted), "");
@@ -163,7 +163,7 @@
 struct __attribute__((trivial_abi)) S20 {
   int &&a; // a member of rvalue reference type deletes the copy constructor.
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(S20), "");
 #else
 static_assert(__is_trivially_relocatable(S20), "");
Index: clang/test/Driver/experimental-library-flag.cpp
===
--- clang/test/Driver/experime

[clang-tools-extra] b80febd - [clang-tidy] [test] Narrow down a special case to MSVC mode

2023-05-09 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-05-10T01:07:45+03:00
New Revision: b80febdf43d33414bbc1c8d8a282a73d8f61a781

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

LOG: [clang-tidy] [test] Narrow down a special case to MSVC mode

For MinGW targets, size_t isn't a compiler defined type, just like
for unix targets.

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

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
index edec8d7380200..e1036483ee8f6 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
@@ -9,7 +9,7 @@ typedef unsigned char   uint8_t;// NOLINT
 typedef unsigned short  uint16_t;   // NOLINT
 typedef unsigned long   uint32_t;   // NOLINT
 typedef unsigned long long  uint64_t;   // NOLINT
-#ifndef _WIN32
+#ifndef _MSC_VER
 typedef unsigned long long  size_t; // NOLINT
 #endif
 typedef longintptr_t;   // NOLINT



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


[clang] 7f037e5 - [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

2023-05-09 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-05-10T01:07:37+03:00
New Revision: 7f037e5645bd62fca6fc7c3e77962aafe2bc8b27

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

LOG: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to 
only MSVC/clang-cl

This fixes running tests with a toolchain that defaults to a MinGW
target.

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

Added: 


Modified: 
clang/test/C/drs/dr1xx.c
clang/test/Driver/experimental-library-flag.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp

Removed: 




diff  --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c
index 400807ed5da84..6bbeb02408c7a 100644
--- a/clang/test/C/drs/dr1xx.c
+++ b/clang/test/C/drs/dr1xx.c
@@ -235,7 +235,7 @@ void dr118(void) {
 * type at this point.
 */
 Val = sizeof(enum E)
-#ifndef _WIN32
+#ifndef _MSC_VER
 /* expected-error@-2 {{invalid application of 'sizeof' to an incomplete 
type 'enum E'}} */
 /* expected-note@-12 {{definition of 'enum E' is not complete until the 
closing '}'}} */
 #endif

diff  --git a/clang/test/Driver/experimental-library-flag.cpp 
b/clang/test/Driver/experimental-library-flag.cpp
index 148cb7ed2adb0..db6a90b50f255 100644
--- a/clang/test/Driver/experimental-library-flag.cpp
+++ b/clang/test/Driver/experimental-library-flag.cpp
@@ -1,6 +1,6 @@
 // On some platforms, -stdlib=libc++ is currently ignored, so 
-lc++experimental is not added.
 // Once -stdlib=libc++ works on those, this XFAIL can be removed.
-// XFAIL: target={{.*-windows.*}}, target={{.*-(ps4|ps5)}}
+// XFAIL: target={{.*-windows-msvc.*}}, target={{.*-(ps4|ps5)}}
 
 // For some reason, this fails with a core dump on AIX. This needs to be 
investigated.
 // UNSUPPORTED: target={{.*}}-aix{{.*}}

diff  --git a/clang/test/SemaCXX/attr-trivial-abi.cpp 
b/clang/test/SemaCXX/attr-trivial-abi.cpp
index deae99f7d0890..2cee3bd5dd215 100644
--- a/clang/test/SemaCXX/attr-trivial-abi.cpp
+++ b/clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -5,11 +5,11 @@ void __attribute__((trivial_abi)) foo(); // expected-warning 
{{'trivial_abi' att
 // Should not crash.
 template 
 class __attribute__((trivial_abi)) a { a(a &&); };
-#ifdef _WIN64
-// On Windows, to be trivial-for-calls, an object must be trivially copyable.
+#if defined(_WIN64) && defined(_MSC_VER)
+// On Windows/MSVC, to be trivial-for-calls, an object must be trivially 
copyable.
 // (And it is only trivially relocatable, currently, if it is trivial for 
calls.)
 // In this case, it is suppressed by an explicitly defined move constructor.
-// Similar concerns apply to later tests that have #ifdef _WIN64.
+// Similar concerns apply to later tests that have #if defined(_WIN64) && 
defined(_MSC_VER).
 static_assert(!__is_trivially_relocatable(a), "");
 #else
 static_assert(__is_trivially_relocatable(a), "");
@@ -137,7 +137,7 @@ struct __attribute__((trivial_abi)) CopyDeleted {
   CopyDeleted(const CopyDeleted &) = delete;
   CopyDeleted(CopyDeleted &&) = default;
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(CopyDeleted), "");
 #else
 static_assert(__is_trivially_relocatable(CopyDeleted), "");
@@ -163,7 +163,7 @@ static_assert(!__is_trivially_relocatable(S19), "");
 struct __attribute__((trivial_abi)) S20 {
   int &&a; // a member of rvalue reference type deletes the copy constructor.
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(S20), "");
 #else
 static_assert(__is_trivially_relocatable(S20), "");



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


[PATCH] D150057: [clang-format] Fix consecutive alignments in #else blocks

2023-05-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked 2 inline comments as done.
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:6371-6380
+  verifyFormat("#if FOO\n"
+   "int a = 1;\n"
+   "#else\n"
+   "int ab = 2;\n"
+   "#endif\n"
+   "#ifdef BAR\n"
+   "int abc = 3;\n"

HazardyKnusperkeks wrote:
> owenpan wrote:
> > clang-format breaks the above into two separate sets:
> > ```
> > #if FOO
> > int a = 1;
> > #else
> > #endif
> > #if BAR
> > int abc = 3;
> > #else
> > #endif
> > ```
> > and:
> > ```
> > #if FOO
> > #else
> > int ab = 2;
> > #endif
> > #if BAR
> > #else
> > int abcd = 4;
> > #endif
> > ```
> > After it finishes with the first set, the preprocessor directives are 
> > marked as `Finalized`. Then, while the second set is being processed, the 
> > directives should //not// be skipped when tokens are added to the `Change` 
> > set. Otherwise, we would end up with the `Change` set below without any 
> > "scope" context:
> > ```
> > int ab = 2;
> > int abcd = 4;
> > ```
> Fascinating. But wouldn't the better fix be that the directives are not 
> marked as finalized?
I tried that first, but it broke a lot of unit tests. I'll give it another try 
when I have time. :)



Comment at: clang/unittests/Format/FormatTestComments.cpp:4319
 /\
-/ 
+/
   )",

HazardyKnusperkeks wrote:
> owenpan wrote:
> > HazardyKnusperkeks wrote:
> > > Unrelated?
> > My editor strips trailing whitespaces on save. I'll leave the fix in 
> > because it's not worth doing it in a separate patch.
> Okay, but that wasn't really trailing, it was part of a string.
Yeah. Fixed in e9acf00. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150057

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


[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-05-09 Thread Fangrui Song 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 rGdbedcfdc2007: [Driver] Add -dumpdir and change -gsplit-dwarf 
.dwo names for linking (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D149193?vs=520573&id=520824#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-gsplit-dwarf-options.hip
  clang/test/Driver/split-debug.c

Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -9,6 +9,7 @@
 
 // INLINE: "-fsplit-dwarf-inlining"
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
+// SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
@@ -54,8 +55,29 @@
 // SINGLE_WITH_FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
 // SINGLE_WITH_FILENAME-NOT: "-split-dwarf-output"
 
-/// Without -c, clang performs linking as well. The output is unchanged.
-// RUN: %clang -### -target x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o ignore.d 2>&1 | FileCheck %s --check-prefix=SPLIT
+/// If linking is the final phase, the .dwo filename is derived from -o (if specified) or "a".
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_A
+
+// SPLIT_LINK:  "-dumpdir" "obj/out-"
+// SPLIT_LINK:  "-debug-info-kind=constructor"
+// SPLIT_LINK-SAME: "-split-dwarf-file" "obj/out-split-debug.dwo" "-split-dwarf-output" "obj/out-split-debug.dwo"
+// SPLIT_LINK_A:  "-dumpdir" "a-"
+// SPLIT_LINK_A-SAME: "-split-dwarf-file" "a-split-debug.dwo" "-split-dwarf-output" "a-split-debug.dwo"
+
+/// GCC special cases /dev/null (HOST_BIT_BUCKET) but not other special files like /dev/zero.
+/// We don't apply special rules at all.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_NULL
+
+// SPLIT_LINK_NULL:  "-dumpdir" "/dev/null-"
+// SPLIT_LINK_NULL-SAME: "-split-dwarf-output" "/dev/null-split-debug.dwo"
+
+/// If -dumpdir is specified, use its value to derive the .dwo filename.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out -dumpdir pf/x -c 2>&1 | FileCheck %s --check-prefix=DUMPDIR
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out -dumpdir pf/x 2>&1 | FileCheck %s --check-prefix=DUMPDIR
+
+// DUMPDIR:  "-dumpdir" "pf/x"
+// DUMPDIR-SAME: "-split-dwarf-output" "pf/xsplit-debug.dwo"
 
 /// -fsplit-dwarf-inlining
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefixes=INLINE,SPLIT
Index: clang/test/Driver/hip-gsplit-dwarf-options.hip
===
--- clang/test/Driver/hip-gsplit-dwarf-options.hip
+++ clang/test/Driver/hip-gsplit-dwarf-options.hip
@@ -13,13 +13,17 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx900.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "hip-gsplit-dwarf-options.dwo"}}
+
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx900.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options.dwo"}}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChai

[clang] dbedcfd - [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-05-09 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-09T14:43:46-07:00
New Revision: dbedcfdc2007e235d97b38db7693bd1f5ff443d8

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

LOG: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

When the final phase is linking, Clang currently places `.dwo` files in the
current directory (like the `-c` behavior for multiple inputs).
Strangely, -fdebug-compilation-dir=/-ffile-compilation-dir= is considered, which
is untested.

GCC has a more useful behavior that derives auxiliary filenames from the final
output (-o).
```
gcc -c -g -gsplit-dwarf d/a.c d/b.c  # a.dwo b.dwo
gcc -g -gsplit-dwarf d/a.c d/b.c -o e/x  # e/x-a.dwo e/x-b.dwo
gcc -g -gsplit-dwarf d/a.c d/b.c # a-a.dwo a-b.dwo
```

Port a useful subset of GCC behaviors that are easy to describe to Clang.

* Add a driver and cc1 option -dumpdir
* When the final phase is link, add a default -dumpdir if not specified by the 
user
* Forward -dumpdir to -cc1 command lines
* tools::SplitDebugName prefers -dumpdir when constructing the .dwo filename

GCC provides -dumpbase. If we use just one of -dumpdir and -dumpbase,
-dumpbase isn't very useful as it appends a dash.

```
gcc -g -gsplit-dwarf -dumpdir e d/a.c   # ea.dwo
gcc -g -gsplit-dwarf -dumpdir e/ d/a.c  # e/a.dwo
gcc -g -gsplit-dwarf -dumpbase e d/a.c  # e-a.dwo
gcc -g -gsplit-dwarf -dumpbase e/ d/a.c # e/-a.dwo
```

If we specify both `-dumpdir` and `-dumpbase`, we can avoid the influence of the
source filename when there is one input file.
```
gcc -g -gsplit-dwarf -dumpdir f/ -dumpbase x d/a.c# f/x.dwo
gcc -g -gsplit-dwarf -dumpdir f/ -dumpbase x d/a.c d/b.c  # f/x-a.dwo f/x-b.dwo
```

Given the above examples, I think -dumpbase is not useful.

GCC -save-temps has interesting interaction with -dumpdir as -save-temps
generated files are considered auxiliary files like .dwo files.

For Clang, with this patch, -save-temps and -dumpdir are orthogonal, which is
easier to explain.

```
gcc -g -gsplit-dwarf d/a.c -o e/x -dumpdir f/ -save-temps=obj # e/a.{i,s,o,dwo}
gcc -g -gsplit-dwarf d/a.c -o e/x -save-temps=obj -dumpdir f/ # f/a.{i,s,o,dwo}

clang -g -gsplit-dwarf d/a.c -o e/x -save-temps=obj -dumpdir f/ # e/a.{i,s,o} 
f/a.dwo
```

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/hip-gsplit-dwarf-options.hip
clang/test/Driver/split-debug.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4ec4e4a49de6b..c0820bd01fd5f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -192,12 +192,20 @@ New Compiler Flags
 - The flag ``-std=c++23`` has been added. This behaves the same as the existing
   flag ``-std=c++2b``.
 
+- ``-dumpdir`` has been implemented to specify auxiliary and dump output
+  filenames for features like ``-gsplit-dwarf``.
+
 Deprecated Compiler Flags
 -
 
 Modified Compiler Flags
 ---
 
+- ``clang -g -gsplit-dwarf a.c -o obj/x`` (compile and link) now generates the
+  ``.dwo`` file at ``obj/x-a.dwo``, instead of a file in the temporary
+  directory (``/tmp`` on \*NIX systems, if none of the environment variables
+  TMPDIR, TMP, and TEMP are specified).
+
 Removed Compiler Flags
 -
 - The deprecated flag `-fmodules-ts` is removed. Please use ``-std=c++20``

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 496264b74d460..670003a3da847 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1142,6 +1142,10 @@ def module_dependency_dir : Separate<["-"], 
"module-dependency-dir">,
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
   Flags<[NoXarchOption, RenderAsInput]>,
   HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
+// GCC style -dumpdir. We intentionally don't implement the less useful 
-dumpbase{,-ext}.
+def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option]>,
+  MetaVarName<"">,
+  HelpText<"Use  as a prefix to form auxiliary and dump file names">;
 def dumpmachine : Flag<["-"], "dumpmachine">;
 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
 def dumpversion : Flag<["-"], "dumpversion">;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a2deb9b0dd9ad..879f3bf00d1cf 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3878,6 +3878,21 @@ void Driver::handleArguments(Compilation &C, 
DerivedArgList &Args,
 !Ar

[clang] e9acf00 - [clang-format] Put a "trailing" space back in a unit test

2023-05-09 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-05-09T14:42:32-07:00
New Revision: e9acf001e98b22ad4127155a5756402101c47795

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

LOG: [clang-format] Put a "trailing" space back in a unit test

Put an intentional "trailing" space back in
FormatTestComments.SplitCommentIntroducers. It was removed in
a4c87f8ccacc by mistake.

Added: 


Modified: 
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index 6e5b5b2d68d81..0cf74bdb2 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -4316,7 +4316,7 @@ TEST_F(FormatTestComments, SplitCommentIntroducers) {
 )",
 format(R"(//
 /\
-/
+/ 
   )",
getLLVMStyleWithColumns(10)));
 }



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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane, thakis, mstorsjo, rsmith.
Herald added a project: All.
shafik requested review of this revision.

Previously we allowed the ability to downgrade this diagnostic based on 
feedback that time was needed to fix code: D131307 


We believe sufficient time has passed and we will turn this back into a hard 
error.

This will also fix some bugs that were a consequence of the workaround:

https://github.com/llvm/llvm-project/issues/62355
https://github.com/llvm/llvm-project/issues/57176


https://reviews.llvm.org/D150226

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx11.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
@@ -900,12 +900,12 @@
 namespace GH50055 {
 enum E {e1=0, e2=1};
 consteval int testDefaultArgForParam(E eParam = (E)-1) {
-// expected-error@-1 {{integer value -1 is outside the valid range of values [0, 1] for this enumeration type}}
+// expected-note@-1 {{integer value -1 is outside the valid range of values [0, 1] for this enumeration type}}
   return (int)eParam;
 }
 
 int test() {
-  return testDefaultArgForParam() + testDefaultArgForParam((E)1);
+  return testDefaultArgForParam() + testDefaultArgForParam((E)1); // expected-error {{call to consteval function 'GH50055::testDefaultArgForParam' is not a constant expression}}
 }
 }
 
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2439,39 +2439,39 @@
 
 void testValueInRangeOfEnumerationValues() {
   constexpr E1 x1 = static_cast(-8);
-  constexpr E1 x2 = static_cast(8);
-  // expected-error@-1 {{integer value 8 is outside the valid range of values [-8, 7] for this enumeration type}}
+  constexpr E1 x2 = static_cast(8); // expected-error {{constexpr variable 'x2' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values [-8, 7] for this enumeration type}}
   E1 x2b = static_cast(8); // ok, not a constant expression context
 
-  constexpr E2 x3 = static_cast(-8);
-  // expected-error@-1 {{integer value -8 is outside the valid range of values [0, 7] for this enumeration type}}
+  constexpr E2 x3 = static_cast(-8); // expected-error {{constexpr variable 'x3' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value -8 is outside the valid range of values [0, 7] for this enumeration type}}
   constexpr E2 x4 = static_cast(0);
-  constexpr E2 x5 = static_cast(8);
-  // expected-error@-1 {{integer value 8 is outside the valid range of values [0, 7] for this enumeration type}}
+  constexpr E2 x5 = static_cast(8); // expected-error {{constexpr variable 'x5' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values [0, 7] for this enumeration type}}
 
   constexpr E3 x6 = static_cast(-2048);
   constexpr E3 x7 = static_cast(-8);
   constexpr E3 x8 = static_cast(0);
   constexpr E3 x9 = static_cast(8);
-  constexpr E3 x10 = static_cast(2048);
-  // expected-error@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for this enumeration type}}
+  constexpr E3 x10 = static_cast(2048); // expected-error {{constexpr variable 'x10' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for this enumeration type}}
 
   constexpr E4 x11 = static_cast(0);
   constexpr E4 x12 = static_cast(1);
-  constexpr E4 x13 = static_cast(2);
-  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
+  constexpr E4 x13 = static_cast(2); // expected-error {{constexpr variable 'x13' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
 
   constexpr EEmpty x14 = static_cast(0);
   constexpr EEmpty x15 = static_cast(1);
-  constexpr EEmpty x16 = static_cast(2);
-  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
+  constexpr EEmpty x16 = static_cast(2);  // expected-error {{constexpr variable 'x16' must be initialized by a constant expression}}
+  // expected-note@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
 
   constexpr EFixed x17 = static_cast(100);
   constexpr EScoped x18 = static_cast(100);
 
   constexpr EMaxInt x19 = static_cast(__INT_MAX__-1);
-  constexpr EMaxInt

[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-09 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2207
+addUsedOrCompilerUsedGlobal(GV);
+  else if (CodeGenOpts.KeepStaticConsts && 
VD->getType().isConstQualified())
+addUsedOrCompilerUsedGlobal(GV);

why not fold the `if` and `else if` together given that they perform the same 
action.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3096
+return true;
+  else if (CodeGenOpts.KeepStaticConsts && 
VD->getType().isConstQualified())
+return true;

Fold to a single return.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-05-09 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam marked an inline comment as done.
zahiraam added a comment.

In D146148#4221651 , @rjmccall wrote:

> In D146148#4220591 , @zahiraam 
> wrote:
>
>> In D146148#4220495 , 
>> @aaron.ballman wrote:
>>
>>> In D146148#4220433 , @zahiraam 
>>> wrote:
>>>
 In D146148#4220268 , @rjmccall 
 wrote:

> Okay, so modifying `math.h` to use this attribute is acceptable?  That's 
> great, that's definitely the best outcome for the compiler.
>
> Just a minor request about the diagnostic name, but otherwise LGTM.

 Yes. Added the attribute inside the included math.h header file.
>>>
>>> How does this work for, say, glibc, musl, or MSVC CRT? Won't those math.h 
>>> headers lack the attribute and thus run into problems when used with Clang?
>>
>> Good point! @rjmccall are you thinking of something in particular with the 
>> attribute?
>
> Zahira, this is what I was asking you when I asked whether modifying the 
> math.h header was acceptable: whether you were prepared to accept that the 
> warning would only fire on system math.h headers that we'd modified, or 
> whether you cared about making it work with non-cooperative headers.  I 
> wasn't asking if you were willing to change the test code.
>
>> If not I guess we will have to rely on string comparison for all the typedef 
>> in the TU. Aaron pointed out the compile time overhead.
>
> Well, the compile-time overhead of doing this on every typedef *declaration* 
> is way better than the overhead of doing this on every type lookup, at least.
>
> Anyway, there are three possibilities I can see:
>
> - We accept that this needs cooperative system headers.
> - We add a math.h compiler header that `#include_next`s the system math.h and 
> then adds the attribute.  I believe you can just add an attribute to a 
> typedef retroactively with something like `typedef float_t float_t 
> __attribute__((whatever))`.
> - We do checks on every typedef declaration.  There's a builtin-identifier 
> trick that we do with library functions that we should be able to generalize 
> to typedefs, so you wouldn't need to actually do string comparisons, you'd 
> just check whether the `IdentifierInfo*` was storing a special ID.  We'd set 
> that up in `initializeBuiltins` at the start of the translation unit, so the 
> overhead would just be that we'd create two extra `IdentifierInfo*`s in every 
> TU.
>
> The builtin ID logic is currently specific to builtin *functions*, and I 
> don't think we'd want to hack typedef names into that.  But the same storage 
> in `IdentifierInfo*` is also used for identifying the ObjC context-sensitive 
> keywords, by just offsetting the builtin IDs by the NUM_OBJC_KEYWORD.  You 
> should be able to generalize that by also introducing a concept of a builtin 
> *type* name, so that e.g. IDs in [0,NUM_OBJC_KEYWORDS) are ObjCKeywordKinds, 
> IDs in [NUM_OBJC_KEYWORDS, NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES) are 
> BuiltinTypeKinds (when you subtract NUM_OBJC_KEYWORDS), and IDs in 
> [NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES,∞) are builtin function IDs (when you 
> subtract NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES).

Reading this more carefully... Does that mean that we initialize the float_t, 
double_t in initializeBuiltins  even if they are not used in the source code?
Also not sure how to define the NUM_BUILTIN_TYPES since I don't need to add it 
to TokenKinds.h? I was proposing to do something like this:
enum InterestingIdentifierKind {
#define Interesting_Identifier(X) X,
#include "clang/Basic/TokenKinds.def"

  NUM_INTERESTING_IDENTIFIERS

};
But I guess I don't need since we don't want to add additional storage. Do I 
understand things correctly?


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

https://reviews.llvm.org/D146148

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-09 Thread Brittany Blue Gaston via Phabricator via cfe-commits
thetruestblue added a comment.

Small insignificant note from me: When this lands, please be sure to add me as 
co-author.
https://github.blog/2018-01-29-commit-together-with-co-authors/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-09 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs marked 2 inline comments as done.
codemzs added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:468
 
+LANGOPT(ExperimentalNewItaniumMangling, 1, 0, "experimental new Itanium 
mangling")
+

erichkeane wrote:
> codemzs wrote:
> > erichkeane wrote:
> > > I'm not sure I like the implications or maintainability of this.  This is 
> > > something that is likely to get out of hand too quickly.  We probably 
> > > need to just figure out what the itanium mangling is GOING to be (perhaps 
> > > @rjmccall has some  insight?), and just implement that.
> > > 
> > > Also, this isn't really a 'Language Option', so much as a codegen option.
> > Thank you for your valuable feedback. Based on your suggestion and 
> > considering that GCC has already implemented the mangling as `DF16b`, I 
> > agree that if we have reasonable confidence in the direction the mangling 
> > will take, it would be better to implement it directly instead of guarding 
> > it with an experimental flag. Therefore, I will be removing the flag. I 
> > initially added the flag since @tahonermann was on board with implementing 
> > the bf16 arithmetic type, assuming the mangling was finalized.
> > 
> > However, I understand your concerns and would appreciate further input from 
> > both @tahonermann and @rjmccall on this matter. My intention is to avoid 
> > stalling the progress of this change due to mangling finalization.
> > 
> > I'm open to further discussion and collaboration to ensure we make the 
> > right decision for our project while maintaining the momentum of the review 
> > process.
> Thanks, I think this is a good direction for this patch to take.
@erichkeane @tahonermann Itanium mangling is now finalized as `DF16b`and [[ 
https://github.com/itanium-cxx-abi/cxx-abi/pull/147#issuecomment-1540692344 | 
merged  ]]into the github repository. 


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

https://reviews.llvm.org/D149573

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-09 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:2583
+if (ArraySize->containsErrors()) {
+  RecoveryExpr *RE = RecoveryExpr::Create(
+  Context, ArraySize->getType(), ArraySize->getBeginLoc(),

erichkeane wrote:
> HerrCai0907 wrote:
> > erichkeane wrote:
> > > Actually thinking further... rather than create a NEW RecoveryExpr, is 
> > > there a problem KEEPING the ArraySize expression?  It'd likely give more 
> > > information/keep more AST consistency.
> > > 
> > > ALSO, creating this as size-0 has some implications we probably don't 
> > > want.  I wonder if a different for the placeholder would be better?  
> > > 
> > > I'D ALSO suggest hoisting this ArraySize->containsError out of the 
> > > else-if and into its own branch (rather than inside the dependent checks).
> > > KEEPING the ArraySize expression
> > Agree.
> > 
> > > creating this as size-0 has some implications we probably don't want.
> > Do you think we can modify it as 1? But I don't find a better way to 
> > identifier it as undef or other.
> > 
> > > hoisting this ArraySize->containsError out of the else-if 
> > Done
> I don't have good evidence for what else we could do (whether an incomplete 
> or variable type would be better), but at least 1 is 'legal', so perhaps we 
> can live with this for now and see if there is any fallout.
> 
> What happens if we try to 'merge' a valid and an invalid here? Does it make 
> the experience worse?  So same example you added below, but the 1st one has 
> no error in its brackets?
I add test case for this scenario. I think it will not confuse developer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-09 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 520808.
HerrCai0907 added a comment.

add more test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-dump-types-errors-json.cpp
  clang/test/AST/ast-dump-types-errors.cpp
  clang/test/Sema/merge-decls.c

Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,11 @@
   int x[5];
   test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x1[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x1[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x2[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}} expected-note {{previous definition is here}}
+char x2[10]; // expected-error {{redefinition of 'x2' with a different type: 'char[10]' vs 'char[1]'}}
+char x3[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x3[1];
\ No newline at end of file
Index: clang/test/AST/ast-dump-types-errors.cpp
===
--- clang/test/AST/ast-dump-types-errors.cpp
+++ clang/test/AST/ast-dump-types-errors.cpp
@@ -2,5 +2,5 @@
 
 void test() {
   using ContainsErrors = int[sizeof(undef())];
-  // CHECK: DependentSizedArrayType {{.*}} contains-errors dependent
+  // CHECK: ConstantArrayType {{.*}} 'int[1]' contains-errors dependent 1
 }
Index: clang/test/AST/ast-dump-types-errors-json.cpp
===
--- clang/test/AST/ast-dump-types-errors-json.cpp
+++ clang/test/AST/ast-dump-types-errors-json.cpp
@@ -24,18 +24,19 @@
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestContainsErrors",
 // CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "int[sizeof ((undef))]"
+// CHECK-NEXT:   "qualType": "int[1]"
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "DependentSizedArrayType",
+// CHECK-NEXT:"kind": "ConstantArrayType",
 // CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "int[sizeof ((undef))]"
+// CHECK-NEXT: "qualType": "int[1]"
 // CHECK-NEXT:},
 // CHECK-NEXT:"containsErrors": true,
 // CHECK-NEXT:"isDependent": true,
 // CHECK-NEXT:"isInstantiationDependent": true,
+// CHECK-NEXT:"size": 1,
 // CHECK-NEXT:"inner": [
 // CHECK-NEXT: {
 // CHECK-NEXT:  "id": "0x{{.*}}",
@@ -43,96 +44,6 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "int"
 // CHECK-NEXT:  }
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "UnaryExprOrTypeTraitExpr",
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 32,
-// CHECK-NEXT:"tokLen": 6
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 46,
-// CHECK-NEXT:"tokLen": 1
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "unsigned long"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "valueCategory": "prvalue",
-// CHECK-NEXT:  "name": "sizeof",
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "ParenExpr",
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": {{[0-9]+}},
-// CHECK-NEXT:  "col": 38,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": {{[0-9]+}},
-// CHECK-NEXT:  "col": 46,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": ""
-// CHECK-NEXT:},
-// CHECK-NEXT:"valueCategory": "lvalue",
-// CHECK-NEXT:"inner": [
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "RecoveryExpr",
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 39,
-// CHECK-NEXT:"tokLen": 5
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 45,
-// CHECK-NEXT:"tokLen": 1
-// 

[PATCH] D149612: [Sema] avoid merge error type

2023-05-09 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 520807.
HerrCai0907 added a comment.

add more test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-dump-types-errors-json.cpp
  clang/test/AST/ast-dump-types-errors.cpp
  clang/test/Sema/merge-decls.c

Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,10 @@
   int x[5];
   test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x1[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x1[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}
+
+char x2[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}} expected-note {{previous definition is here}}
+char x2[10]; // expected-error {{redefinition of 'x2' with a different type: 'char[10]' vs 'char[1]'}}
Index: clang/test/AST/ast-dump-types-errors.cpp
===
--- clang/test/AST/ast-dump-types-errors.cpp
+++ clang/test/AST/ast-dump-types-errors.cpp
@@ -2,5 +2,5 @@
 
 void test() {
   using ContainsErrors = int[sizeof(undef())];
-  // CHECK: DependentSizedArrayType {{.*}} contains-errors dependent
+  // CHECK: ConstantArrayType {{.*}} 'int[1]' contains-errors dependent 1
 }
Index: clang/test/AST/ast-dump-types-errors-json.cpp
===
--- clang/test/AST/ast-dump-types-errors-json.cpp
+++ clang/test/AST/ast-dump-types-errors-json.cpp
@@ -24,18 +24,19 @@
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestContainsErrors",
 // CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "int[sizeof ((undef))]"
+// CHECK-NEXT:   "qualType": "int[1]"
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "DependentSizedArrayType",
+// CHECK-NEXT:"kind": "ConstantArrayType",
 // CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "int[sizeof ((undef))]"
+// CHECK-NEXT: "qualType": "int[1]"
 // CHECK-NEXT:},
 // CHECK-NEXT:"containsErrors": true,
 // CHECK-NEXT:"isDependent": true,
 // CHECK-NEXT:"isInstantiationDependent": true,
+// CHECK-NEXT:"size": 1,
 // CHECK-NEXT:"inner": [
 // CHECK-NEXT: {
 // CHECK-NEXT:  "id": "0x{{.*}}",
@@ -43,96 +44,6 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "int"
 // CHECK-NEXT:  }
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "UnaryExprOrTypeTraitExpr",
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 32,
-// CHECK-NEXT:"tokLen": 6
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 46,
-// CHECK-NEXT:"tokLen": 1
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "unsigned long"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "valueCategory": "prvalue",
-// CHECK-NEXT:  "name": "sizeof",
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "ParenExpr",
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": {{[0-9]+}},
-// CHECK-NEXT:  "col": 38,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": {{[0-9]+}},
-// CHECK-NEXT:  "col": 46,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": ""
-// CHECK-NEXT:},
-// CHECK-NEXT:"valueCategory": "lvalue",
-// CHECK-NEXT:"inner": [
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "RecoveryExpr",
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 39,
-// CHECK-NEXT:"tokLen": 5
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 45,
-// CHECK-NEXT:"tokLen": 1
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": ""
-// CHECK-NEXT:  },

[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-09 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D150221#4330504 , @MaskRay wrote:

> Can you give a more compelling reason that this option is needed?

This is intended to prevent "excessive transformation" to enable migration of 
existing applications (using a non-Clang compiler) where users further 
manipulate the object or assembly after compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D148665: Change -fsanitize=function to place two words before the function entry

2023-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D148665#4316310 , @peter.smith 
wrote:

> My apologies for not responding. If I've got this right there are 4 related 
> patches:
> D148573  (approved)
> D148785  Use type hashes rather than RTTI 
> D148827  support C
> D148665  (this one)



> My initial impressions is that this makes -fsanitize=function look more like 
> -fsanitize=kcfi which makes it accessible from C and available to more 
> targets. Is there anything that we lose in the process of making these 
> changes? For example I would expect RTTI to have more information available 
> than a type hash, although this might not make any functional difference.
>
> I'll try and look over the next few days and leave some comments, apologies a 
> bit busy at work at the moment so I can't promise anything speedy.

Thanks! `-fsanitize=function` will indeed become more like `-fsanitize=kcfi`.

There is a big difference that `-fsanitize=function` instrumented code has a 
signature check for compatibility with object files not compiled with 
`-fsanitize=function` (and old implementations of `-fsanitize=function` with a 
difference location to place the signature).
-fsanitize=kcfi doesn't have the compatibility guarantee.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148665

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

GCC has -fkeep-static-consts (which Clang supports) but not 
-fkeep-static-variables.

> This could be useful in cases where the presence of all static variables as 
> symbols in the object file are required.

Can you give a more compelling reason that this option is needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D150151: [clang] Prevent creation of new submodules in ASTWriter

2023-05-09 Thread Ben Langmuir 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 rG5984ea216d2a: [clang] Prevent creation of new submodules in 
ASTWriter (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150151

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTWriter.cpp


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -185,7 +185,8 @@
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
-for (const auto &KH : HS.findAllModulesForHeader(File)) {
+for (const auto &KH :
+ HS.findAllModulesForHeader(File, /*AllowCreation=*/false)) {
   if (!KH.getModule())
 continue;
   ModulesToProcess.push_back(KH.getModule());
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -683,12 +683,12 @@
 }
 
 ArrayRef
-ModuleMap::findAllModulesForHeader(const FileEntry *File) {
+ModuleMap::findAllModulesForHeader(const FileEntry *File, bool AllowCreation) {
   HeadersMap::iterator Known = findKnownHeader(File);
   if (Known != Headers.end())
 return Known->second;
 
-  if (findOrCreateModuleForHeaderInUmbrellaDir(File))
+  if (AllowCreation && findOrCreateModuleForHeaderInUmbrellaDir(File))
 return Headers.find(File)->second;
 
   return std::nullopt;
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1565,13 +1565,14 @@
 }
 
 ArrayRef
-HeaderSearch::findAllModulesForHeader(const FileEntry *File) const {
+HeaderSearch::findAllModulesForHeader(const FileEntry *File,
+  bool AllowCreation) const {
   if (ExternalSource) {
 // Make sure the external source has handled header info about this file,
 // which includes whether the file is part of a module.
 (void)getExistingFileInfo(File);
   }
-  return ModMap.findAllModulesForHeader(File);
+  return ModMap.findAllModulesForHeader(File, AllowCreation);
 }
 
 static bool suggestModule(HeaderSearch &HS, const FileEntry *File,
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -448,9 +448,13 @@
   /// and does not consult the external source. (Those checks are the
   /// responsibility of \ref HeaderSearch.)
   ///
+  /// \param AllowCreation Whether to allow inference of a new submodule, or to
+  ///only return existing known modules.
+  ///
   /// Typically, \ref findModuleForHeader should be used instead, as it picks
   /// the preferred module for the header.
-  ArrayRef findAllModulesForHeader(const FileEntry *File);
+  ArrayRef findAllModulesForHeader(const FileEntry *File,
+bool AllowCreation = true);
 
   /// Like \ref findAllModulesForHeader, but do not attempt to infer module
   /// ownership from umbrella headers if we've not already done so.
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -665,9 +665,13 @@
 
   /// Retrieve all the modules corresponding to the given file.
   ///
+  /// \param AllowCreation Whether to allow inference of a new submodule, or to
+  ///only return existing known modules.
+  ///
   /// \ref findModuleForHeader should typically be used instead of this.
   ArrayRef
-  findAllModulesForHeader(const FileEntry *File) const;
+  findAllModulesForHeader(const FileEntry *File,
+  bool AllowCreation = true) const;
 
   /// Read the contents of the given module map file.
   ///


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -185,7 +185,8 @@
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
-for (const auto &KH : HS.findAllModulesForHeader(File)) {
+for (const auto &KH :
+ HS.findAllModulesForHeader(File, /*AllowCreation=*/false)) {
   if (!KH.getModule())
 continue;
   ModulesToProcess.push_back(KH.getModule());
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.

[clang] 5984ea2 - [clang] Prevent creation of new submodules in ASTWriter

2023-05-09 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-05-09T13:02:36-07:00
New Revision: 5984ea216d2acbe5613b0af06ea27ef395ca9904

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

LOG: [clang] Prevent creation of new submodules in ASTWriter

Avoid inferring new submodules for headers in ASTWriter's collection of
affecting modulemap files, since we don't want to pick up dependencies
that didn't actually exist during parsing.

rdar://109112624

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

Added: 


Modified: 
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 76e3e786ff070..49fb99c1483ce 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -665,9 +665,13 @@ class HeaderSearch {
 
   /// Retrieve all the modules corresponding to the given file.
   ///
+  /// \param AllowCreation Whether to allow inference of a new submodule, or to
+  ///only return existing known modules.
+  ///
   /// \ref findModuleForHeader should typically be used instead of this.
   ArrayRef
-  findAllModulesForHeader(const FileEntry *File) const;
+  findAllModulesForHeader(const FileEntry *File,
+  bool AllowCreation = true) const;
 
   /// Read the contents of the given module map file.
   ///

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index f155c609b06cb..8f8580fd11495 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -448,9 +448,13 @@ class ModuleMap {
   /// and does not consult the external source. (Those checks are the
   /// responsibility of \ref HeaderSearch.)
   ///
+  /// \param AllowCreation Whether to allow inference of a new submodule, or to
+  ///only return existing known modules.
+  ///
   /// Typically, \ref findModuleForHeader should be used instead, as it picks
   /// the preferred module for the header.
-  ArrayRef findAllModulesForHeader(const FileEntry *File);
+  ArrayRef findAllModulesForHeader(const FileEntry *File,
+bool AllowCreation = true);
 
   /// Like \ref findAllModulesForHeader, but do not attempt to infer module
   /// ownership from umbrella headers if we've not already done so.

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 5a7357a5ada43..a650bbea1e488 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1565,13 +1565,14 @@ HeaderSearch::findModuleForHeader(const FileEntry 
*File, bool AllowTextual,
 }
 
 ArrayRef
-HeaderSearch::findAllModulesForHeader(const FileEntry *File) const {
+HeaderSearch::findAllModulesForHeader(const FileEntry *File,
+  bool AllowCreation) const {
   if (ExternalSource) {
 // Make sure the external source has handled header info about this file,
 // which includes whether the file is part of a module.
 (void)getExistingFileInfo(File);
   }
-  return ModMap.findAllModulesForHeader(File);
+  return ModMap.findAllModulesForHeader(File, AllowCreation);
 }
 
 static bool suggestModule(HeaderSearch &HS, const FileEntry *File,

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 0e148a43dc92f..66e9a7e1dbea7 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -683,12 +683,12 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(const 
FileEntry *File) {
 }
 
 ArrayRef
-ModuleMap::findAllModulesForHeader(const FileEntry *File) {
+ModuleMap::findAllModulesForHeader(const FileEntry *File, bool AllowCreation) {
   HeadersMap::iterator Known = findKnownHeader(File);
   if (Known != Headers.end())
 return Known->second;
 
-  if (findOrCreateModuleForHeaderInUmbrellaDir(File))
+  if (AllowCreation && findOrCreateModuleForHeaderInUmbrellaDir(File))
 return Headers.find(File)->second;
 
   return std::nullopt;

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index e124cb4c5f81d..06d758b36c59d 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -185,7 +185,8 @@ std::set GetAffectingModuleMaps(const 
Preprocessor &PP,
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
-for (const auto &KH : HS.findAllModulesForHeader(File)) {
+for (const auto &KH :
+ HS.findAllModulesForHeader(File, /*AllowCreation=*/false)) {
   if (!KH.getModule())
 continue;
   ModulesToProcess.pus

[PATCH] D150151: [clang] Prevent creation of new submodules in ASTWriter

2023-05-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 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/D150151/new/

https://reviews.llvm.org/D150151

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


[PATCH] D150013: [Clang] Respect `-L` options when compiling directly for AMDGPU

2023-05-09 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D150013#4330452 , @MaskRay wrote:

> So it seems that there are configurations that we need -L (cross 
> compilation?). If we forward -L in some configurations, I think it'd be 
> better to do this consistently.
>
> The `LIBRARY_PATH` options seems not useful and the conditional `if (not 
> cross compiling) add LIBRARY_PATH` is more unfortunate. I wish that we don't 
> add more cases that we do something with `LIBRARY_PATH`.
> (IMO the `LIBRARY_PATH`  users can just fix their build system or use 
> `CCC_OVERRIDE_OPTIONS`)
>
> We definitely want to avoid more uses of `TC.isCrossCompiling()`.

The comment itself `// LIBRARY_PATH are included before user inputs and only 
supported on native toolchains.` suggests that something like this might be 
valid.

  // LIBRARY_PATH are included before user inputs and only supported on native
  // toolchains.
  if (!TC.isCrossCompiling())
addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
  else 
Args.AddAllArgs(CmdArgs, options::OPT_L);



  




Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:546
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+  Args.AddAllArgs(CmdArgs, options::OPT_L);

jhuber6 wrote:
> MaskRay wrote:
> > jhuber6 wrote:
> > > yaxunl wrote:
> > > > jhuber6 wrote:
> > > > > yaxunl wrote:
> > > > > > AddLinkerInputs has code doing that, and it handles env var 
> > > > > > LIBRARY_PATH. However that code is disabled for AMDGPU because 
> > > > > > AMDGPU returns true for isCrossCompiling.
> > > > > > 
> > > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/CommonArgs.cpp#L236
> > > > > > 
> > > > > > It seems isCrossCompiling is solely for controlling whether to 
> > > > > > consume `-L`. If we want amdgpu toolchain to accept `-L`, we can 
> > > > > > simply let isCrossCompiling return false.
> > > > > Good catch, we could maybe set `isCrossCompiling` to false if 
> > > > > targeted directly by the user, e.g. `--target=amdgcn-amd-amdhsa` vs 
> > > > > `--offload-arch`.
> > > > That would be better. Thanks.
> > > It still is technically cross compiling, since we are building for a 
> > > target that does not match the system's architecture. The original code 
> > > that prevents passing `-L` was contributed by @MaskRay. I understand that 
> > > we may not want to pass `LIBRARY_PATH` defines, but what's the rationale 
> > > for not passing any `-L` options manually specified by the user?
> > The `LIBRARY_PATH` code had been there when I moved it in 2019. It'd be 
> > best not to rely on `LIBRARY_PATH`. I think that forwarding `-L` seems 
> > reasonable but I am not familiar with the amdgpu ecosystem..
> The linker is just `lld` so it should be the same conceptually. I'm just 
> figuring that even if the user is cross compiling we should respect `-L` 
> passed on the command line. Should I change this patch to make that change?
For offloading I think the problem might be that we don't want to forward `-L` 
arguments from the host. In that case, we might be able to apply `


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150013

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


[PATCH] D148385: [RISCV] Implement KCFI operand bundle lowering

2023-05-09 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen updated this revision to Diff 520795.
samitolvanen added a comment.

Dropped the arch-specific KCFI machine function pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148385

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/test/CodeGen/RISCV/O0-pipeline.ll
  llvm/test/CodeGen/RISCV/O3-pipeline.ll
  llvm/test/CodeGen/RISCV/kcfi-isel.mir
  llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll
  llvm/test/CodeGen/RISCV/kcfi.ll
  llvm/test/CodeGen/RISCV/kcfi.mir

Index: llvm/test/CodeGen/RISCV/kcfi.mir
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/kcfi.mir
@@ -0,0 +1,185 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
+# RUN: llc -mtriple=riscv64 -stop-after=kcfi -o - %s | FileCheck %s
+--- |
+  ; ModuleID = ''
+  source_filename = ""
+  target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
+  target triple = "riscv64"
+
+  define void @f1(ptr noundef %x) !kcfi_type !1 {
+call void %x() [ "kcfi"(i32 12345678) ]
+ret void
+  }
+
+  define void @f2(ptr noundef %x) #0 {
+tail call void %x() [ "kcfi"(i32 12345678) ]
+ret void
+  }
+
+  attributes #0 = { "patchable-function-entry"="2" }
+
+  !llvm.module.flags = !{!0}
+
+  !0 = !{i32 4, !"kcfi", i32 1}
+  !1 = !{i32 12345678}
+
+...
+---
+name:f1
+alignment:   4
+exposesReturnsTwice: false
+legalized:   false
+regBankSelected: false
+selected:false
+failedISel:  false
+tracksRegLiveness: true
+hasWinCFI:   false
+callsEHReturn:   false
+callsUnwindInit: false
+hasEHCatchret:   false
+hasEHScopes: false
+hasEHFunclets:   false
+isOutlined:  false
+debugInstrRef:   false
+failsVerification: false
+tracksDebugUserValues: true
+registers:   []
+liveins:
+  - { reg: '$x10', virtual-reg: '' }
+frameInfo:
+  isFrameAddressTaken: false
+  isReturnAddressTaken: false
+  hasStackMap: false
+  hasPatchPoint:   false
+  stackSize:   16
+  offsetAdjustment: 0
+  maxAlignment:8
+  adjustsStack:true
+  hasCalls:true
+  stackProtector:  ''
+  functionContext: ''
+  maxCallFrameSize: 0
+  cvBytesOfCalleeSavedRegisters: 0
+  hasOpaqueSPAdjustment: false
+  hasVAStart:  false
+  hasMustTailInVarArgFunc: false
+  hasTailCall: false
+  localFrameSize:  0
+  savePoint:   ''
+  restorePoint:''
+fixedStack:  []
+stack:
+  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
+  stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true,
+  debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+callSites:   []
+debugValueSubstitutions: []
+constants:   []
+machineFunctionInfo:
+  varArgsFrameIndex: 0
+  varArgsSaveSize: 0
+body: |
+  bb.0 (%ir-block.0):
+liveins: $x10, $x1
+
+; CHECK-LABEL: name: f1
+; CHECK: liveins: $x1, $x10
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: $x2 = frame-setup ADDI $x2, -16
+; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+; CHECK-NEXT: SD $x1, $x2, 8 :: (store (s64) into %stack.1)
+; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $x1, -8
+; CHECK-NEXT: $x2 = frame-setup ADDI $x2, -16
+; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+; CHECK-NEXT: SD $x1, $x2, 8 :: (store (s64) into %stack.0)
+; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $x1, -8
+; CHECK-NEXT: BUNDLE implicit-def dead $x6, implicit-def dead $x7, implicit-def dead $x28, implicit-def dead $x29, implicit-def dead $x30, implicit-def dead $x31, implicit-def dead $x1, implicit-def $x2, implicit $x10 {
+; CHECK-NEXT:   KCFI_CHECK $x10, 12345678, implicit-def $x6, implicit-def $x7, implicit-def $x28, implicit-def $x29, implicit-def $x30, implicit-def $x31
+; CHECK-NEXT:   PseudoCALLIndirect $x10, csr_ilp32_lp64, implicit-def dead $x1, implicit-def $x2
+; CHECK-NEXT: }
+; CHECK-NEXT: dead $x1 = LD $x2, 8 :: (load (s64) from %stack.0)
+; CHECK-NEXT: $x2 = frame-destroy ADDI $x2, 16
+; CHECK-NEXT: $x1 = LD $x2, 8 :: (load (s64) from %stack.1)
+; CHECK-NEXT: $x2 = frame-destroy ADDI $x2, 16
+; CHECK-NEXT: PseudoRET
+$x2 = frame-setup ADDI $x2, -16
+frame-setup CFI_INSTRUCTION def_cfa_offset 16
+SD killed $x1, $x2, 8 :: (store (s64) into %stack.0)
+frame-setup CFI_INSTRUCTION offset $x1, -8
+BUNDLE implicit-def $x6, implicit-def $x7, implicit-def $x28, implicit-def $x29, implicit-def $x30, implicit-def $x31, implicit-def dead $x1, implicit-def $x2, impli

[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-09 Thread Zheng Qian via Phabricator via cfe-commits
qianzhen created this revision.
Herald added a project: All.
qianzhen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This patch adds a new option -fkeep-static-variables to emit all static 
variables if required. This could be useful in cases where the presence of all 
static variables as symbols in the object file are required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150221

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/keep-static-variables.cpp

Index: clang/test/CodeGen/keep-static-variables.cpp
===
--- /dev/null
+++ clang/test/CodeGen/keep-static-variables.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fkeep-static-variables -emit-llvm %s -o - -triple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-ELF
+// RUN: %clang_cc1 -fkeep-static-variables -emit-llvm %s -o - -triple=powerpc64-ibm-aix-xcoff | FileCheck %s --check-prefixes=CHECK,CHECK-NON-ELF
+
+// CHECK: @_ZL2g1 = internal global i32 0, align 4
+// CHECK: @_ZL2g2 = internal global i32 1, align 4
+// CHECK: @_ZL2g3 = internal global i32 0, align 4
+// CHECK: @_ZL2g4 = internal global i32 2, align 4
+// CHECK-ELF: @llvm.compiler.used = appending global [4 x ptr] [ptr @_ZL2g1, ptr @_ZL2g2, ptr @_ZL2g3, ptr @_ZL2g4], section "llvm.metadata"
+// CHECK-NON-ELF: @llvm.used = appending global [4 x ptr] [ptr @_ZL2g1, ptr @_ZL2g2, ptr @_ZL2g3, ptr @_ZL2g4], section "llvm.metadata"
+
+static int g1;
+static int g2 = 1;
+static int g3;
+static int g4 = 2;
+
+int test1() {
+  g1 = 3;
+  return g1;
+}
+
+int test2() {
+  return g2;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7294,6 +7294,8 @@
 
   Args.addOptInFlag(CmdArgs, options::OPT_fkeep_static_consts,
 options::OPT_fno_keep_static_consts);
+  Args.addOptInFlag(CmdArgs, options::OPT_fkeep_static_variables,
+options::OPT_fno_keep_static_variables);
   Args.addOptInFlag(CmdArgs, options::OPT_fcomplete_member_pointers,
 options::OPT_fno_complete_member_pointers);
   Args.addOptOutFlag(CmdArgs, options::OPT_fcxx_static_destructors,
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2198,11 +2198,15 @@
   if (D && D->hasAttr())
 addUsedOrCompilerUsedGlobal(GV);
 
-  if (CodeGenOpts.KeepStaticConsts && D && isa(D)) {
+  if ((CodeGenOpts.KeepStaticConsts || CodeGenOpts.KeepStaticVariables) && D &&
+  isa(D)) {
 const auto *VD = cast(D);
-if (VD->getType().isConstQualified() &&
-VD->getStorageDuration() == SD_Static)
-  addUsedOrCompilerUsedGlobal(GV);
+if (VD->getStorageDuration() == SD_Static) {
+  if (CodeGenOpts.KeepStaticVariables)
+addUsedOrCompilerUsedGlobal(GV);
+  else if (CodeGenOpts.KeepStaticConsts && VD->getType().isConstQualified())
+addUsedOrCompilerUsedGlobal(GV);
+}
   }
 }
 
@@ -3084,11 +3088,14 @@
   if (LangOpts.EmitAllDecls)
 return true;
 
-  if (CodeGenOpts.KeepStaticConsts) {
+  if (CodeGenOpts.KeepStaticConsts || CodeGenOpts.KeepStaticVariables) {
 const auto *VD = dyn_cast(Global);
-if (VD && VD->getType().isConstQualified() &&
-VD->getStorageDuration() == SD_Static)
-  return true;
+if (VD && VD->getStorageDuration() == SD_Static) {
+  if (CodeGenOpts.KeepStaticVariables)
+return true;
+  else if (CodeGenOpts.KeepStaticConsts && VD->getType().isConstQualified())
+return true;
+}
   }
 
   return getContext().DeclMustBeEmitted(Global);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1697,6 +1697,10 @@
   CodeGenOpts<"KeepStaticConsts">, DefaultFalse,
   PosFlag, NegFlag,
   BothFlags<[NoXarchOption], " static const variables if unused">>;
+defm keep_static_variables : BoolFOption<"keep-static-variables",
+  CodeGenOpts<"KeepStaticVariables">, DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[NoXarchOption], " static variables if unused">>;
 defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag, NegFlag,
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -472,6 +472,9 @@
 /// Whether to emit unused static constants.
 CODEGENOPT(KeepStaticConsts

[PATCH] D150013: [Clang] Respect `-L` options when compiling directly for AMDGPU

2023-05-09 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.

> The linker is just lld so it should be the same conceptually. I'm just 
> figuring that even if the user is cross compiling we should respect -L passed 
> on the command line. Should I change this patch to make that change?

So it seems that there are configurations that we need -L (cross compilation?). 
If we forward -L in some configurations, I think it'd be better to do this 
consistently.

The `LIBRARY_PATH` options seems not useful and the conditional `if (not cross 
compiling) add LIBRARY_PATH` is more unfortunate. I wish that we don't add more 
cases that we do something with `LIBRARY_PATH`.
(IMO the `LIBRARY_PATH`  users can just fix their build system or use 
`CCC_OVERRIDE_OPTIONS`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150013

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


[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-05-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

In D149193#4328553 , @MaskRay wrote:

> In D149193#4328452 , @dblaikie 
> wrote:
>
>>> I agree that for most(all?) split DWARF users will not see any difference 
>>> since they always use -c -o and don't combine compilation and linking in 
>>> one command.
>>
>> Given that, I'm not sure that this is worth implementing, but if it suits 
>> you I guess.
>
> The split DWARF users are about production users.
>
> There are command line users who do `clang -g -gsplit-dwarf a.c b.c -o x` and 
> I have heard about questions that the `.dwo` files go to strange directories 
> (usually `/tmp`) quite a few times.
> Fixing `-gsplit-dwarf` helps set a baseline for other options like 
> `-ftime-trace` (https://github.com/llvm/llvm-project/issues/57285).

Fair enough


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

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


[PATCH] D150083: [clang-format] ObjCPropertyAttributeOrder to sort ObjC property attributes

2023-05-09 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

LGTM, but someone other has to approve.




Comment at: clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp:43-44
+struct ObjCPropertyEntry {
+  StringRef attribute; // eg, "readwrite"
+  StringRef value; // eg, the "foo" of the attribute "getter=foo"
+};




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

https://reviews.llvm.org/D150083

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


[PATCH] D150215: [clang][CodeGen] Break up TargetInfo.cpp [7/8]

2023-05-09 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

Currently, the functions just forward their arguments to the constructors (*), 
but I think more stuff
should be pushed into them from `createTargetCodeGenInfo`. This is left for 
target maintainers.

Implementations of the added functions will be distributed across *.cpp files 
in the next commit.

(*) `isStructReturnInRegABI` calls (PPC and X86) were moved because these 
methods are not
accessible from other TUs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150215

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


[PATCH] D145262: [clang-format] Treat AttributeMacros more like attribute macros

2023-05-09 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:5473
+  if (Right.isOneOf(tok::kw___attribute, TT_AttributeMacro))
+return true;
+

jaredgrubb wrote:
> HazardyKnusperkeks wrote:
> > Does changing this return value make no difference? In other words is there 
> > no combination of `Left.is(TT_AttributeSquare)` and 
> > `Right.is(tok::kw___attribute)`?
> Yes, that combo can happen; example below.
> 
> The patch that changed the left-diff line from `true` to 
> `!Left.is(TT_AttributeSquare)`
>  was done _only_ contemplating the `[[` case 
> (5a4ddbd69db2b0e09398214510501d0e59a0c30b); tagging @MyDeveloperDay who wrote 
> that patch and can perhaps offer more insight on your question.
> 
> My reasoning is to revert that part of the patch just a bit and limit it to 
> that case only.
> 
> I couldn't come up with a use-case where you'd want to avoid splitting 
> between `TT_AttributeSquare` and `kw___attribute`, but the example below 
> shows that allowing it to break in that combination is preferable to the 
> alternative of breaking in the parens of the attribute:
> ```
> // Style: "{BasedOnStyle: LLVM, ColumnLimit: 40}"
> // Existing Behavior
> int ff(
> double)
> __attribute__((overloadable))
> [[unused]] __attribute__((
> overloadable));
> 
> // With Patch
> int ff(
> double)
> __attribute__((overloadable))
> [[unused]]
> __attribute__((overloadable));
> ```
> 
Thanks for the detailed answer. I'll wait for @MyDeveloperDay. You are right, 
it's prettier with the patch, but on the other hand it is not desirable to 
change the formatting (apart from fixing bugs) between versions.


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

https://reviews.llvm.org/D145262

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


[PATCH] D150057: [clang-format] Fix consecutive alignments in #else blocks

2023-05-09 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:6371-6380
+  verifyFormat("#if FOO\n"
+   "int a = 1;\n"
+   "#else\n"
+   "int ab = 2;\n"
+   "#endif\n"
+   "#ifdef BAR\n"
+   "int abc = 3;\n"

owenpan wrote:
> clang-format breaks the above into two separate sets:
> ```
> #if FOO
> int a = 1;
> #else
> #endif
> #if BAR
> int abc = 3;
> #else
> #endif
> ```
> and:
> ```
> #if FOO
> #else
> int ab = 2;
> #endif
> #if BAR
> #else
> int abcd = 4;
> #endif
> ```
> After it finishes with the first set, the preprocessor directives are marked 
> as `Finalized`. Then, while the second set is being processed, the directives 
> should //not// be skipped when tokens are added to the `Change` set. 
> Otherwise, we would end up with the `Change` set below without any "scope" 
> context:
> ```
> int ab = 2;
> int abcd = 4;
> ```
Fascinating. But wouldn't the better fix be that the directives are not marked 
as finalized?



Comment at: clang/unittests/Format/FormatTestComments.cpp:4319
 /\
-/ 
+/
   )",

owenpan wrote:
> HazardyKnusperkeks wrote:
> > Unrelated?
> My editor strips trailing whitespaces on save. I'll leave the fix in because 
> it's not worth doing it in a separate patch.
Okay, but that wasn't really trailing, it was part of a string.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150057

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


[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-05-09 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

In D149193#4316293 , @dblaikie wrote:

> I guess my main question is: What's the motivation for implementing this? Do 
> you have a need/use for this? (it doesn't seem to be motivated by GCC 
> compatibility - as discussed, looks like we're diverging in a bunch of ways 
> from their behavior and the argument made that these are "developer" flags, 
> so not a stable/compatible interface used across both compilers)

Even if we only align the default behavior of Clang with the default behavior 
of GCC it seems like a win. AFAIU we could implement this without `-dumpdir` at 
all, but the baseline notion of being able to specify where to put 
auxiliary/dump files seems useful.

Do we need to match every quirk and add every other knob from GCC in order to 
use the same name? Is there precedent in terms of other options where Clang is 
close but opinionated about behavior relative to GCC?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-09 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 520781.
barannikov88 added a comment.

Undo unintended formatting changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-09 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 520777.
barannikov88 added a comment.

Undo file renaming so that it does not look like the file was replaced


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-09 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 520774.
barannikov88 added a comment.

Squash commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetCodeGenInfo.cpp
  clang/lib/CodeGen/TargetCodeGenInfo.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D150215: [clang][CodeGen] Break up TargetInfo.cpp [7/8]

2023-05-09 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 created this revision.
Herald added subscribers: s.egerton, simoncook, asb, fedor.sergeev, dschuff.
Herald added a project: All.
barannikov88 published this revision for review.
barannikov88 added reviewers: rjmccall, aaron.ballman, erichkeane, jdoerfert, 
efriedma.
Herald added subscribers: cfe-commits, pcwang-thead, aheejin.
Herald added a project: clang.

Wrap calls to XXXTargetCodeGenInfo constructors into factory functions.
This allows moving implementations of TargetCodeGenInfo to dedicated cpp
files without a change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150215

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -405,6 +405,150 @@
  CodeGen::CodeGenModule &CGM) const;
 };
 
+std::unique_ptr
+createDefaultTargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class AArch64ABIKind {
+  AAPCS = 0,
+  DarwinPCS,
+  Win64,
+};
+
+std::unique_ptr
+createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind);
+
+std::unique_ptr
+createWindowsAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind K);
+
+std::unique_ptr
+createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createARCTargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class ARMABIKind {
+  APCS = 0,
+  AAPCS = 1,
+  AAPCS_VFP = 2,
+  AAPCS16_VFP = 3,
+};
+
+std::unique_ptr
+createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind);
+
+std::unique_ptr
+createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K);
+
+std::unique_ptr
+createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR);
+
+std::unique_ptr
+createBPFTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen);
+
+std::unique_ptr
+createHexagonTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createLanaiTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen,
+ unsigned FLen);
+
+std::unique_ptr
+createM68kTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
+
+std::unique_ptr
+createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createNVPTXTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createPNaClTargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class PPC64_SVR4_ABIKind {
+  ELFv1 = 0,
+  ELFv2,
+};
+
+std::unique_ptr
+createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit);
+
+std::unique_ptr
+createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI);
+
+std::unique_ptr
+createPPC64TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createPPC64_SVR4_TargetCodeGenInfo(CodeGenModule &CGM, PPC64_SVR4_ABIKind Kind,
+   bool SoftFloatABI);
+
+std::unique_ptr
+createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen);
+
+std::unique_ptr
+createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSPIRVTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSparcV8TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSparcV9TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector,
+   bool SoftFloatABI);
+
+std::unique_ptr
+createTCETargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createVETargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class WebAssemblyABIKind {
+  MVP = 0,
+  ExperimentalMV = 1,
+};
+
+std::unique_ptr
+createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K);
+
+/// The AVX ABI level for X86 targets.
+enum class X86AVXABILevel {
+  None,
+  AVX,
+  AVX512,
+};
+
+std::unique_ptr createX86_32TargetCodeGenInfo(
+CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI,
+unsigned NumRegisterParameters, bool SoftFloatABI);
+
+std::unique_ptr
+createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI,
+ bool Win32StructABI,
+ unsigned NumRegisterParameters);
+
+std::unique_ptr
+createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
+
+std::unique_ptr
+createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
+
+std::unique_ptr
+createXCoreTargetCodeGenInfo(CodeGenModule &CGM);
+
 } // namespace CodeGen
 } // namespace clang
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -827,11 +827,6 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===-

[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-09 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 520772.
barannikov88 retitled this revision from "[clang][CodeGen] Break up 
TargetInfo.cpp [7/7]" to "[clang][CodeGen] Break up TargetInfo.cpp [8/8]".
barannikov88 edited the summary of this revision.
barannikov88 added a comment.

Rebase on top of the commit that introduced factory functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp

Index: clang/lib/CodeGen/Targets/XCore.cpp
===
--- clang/lib/CodeGen/Targets/XCore.cpp
+++ clang/lib/CodeGen/Targets/XCore.cpp
@@ -77,7 +77,7 @@
 ///   been exited too soon for the encoding to be correct for the member.
 ///
 class TypeStringCache {
-  enum Status {NonRecursive, Recursive, Incomplete, IncompleteUsed};
+  enum Status { NonRecursive, Recursive, Incomplete, IncompleteUsed };
   struct Entry {
 std::string Str; // The encoded TypeString for the type.
 enum Status State;   // Information about the encoding in 'Str'.
@@ -91,8 +91,7 @@
   TypeStringCache() : IncompleteCount(0), IncompleteUsedCount(0) {}
   void addIncomplete(const IdentifierInfo *ID, std::string StubEnc);
   bool removeIncomplete(const IdentifierInfo *ID);
-  void addIfComplete(const IdentifierInfo *ID, StringRef Str,
- bool IsRecursive);
+  void addIfComplete(const IdentifierInfo *ID, StringRef Str, bool IsRecursive);
   StringRef lookupStr(const IdentifierInfo *ID);
 };
 
@@ -101,11 +100,13 @@
 class FieldEncoding {
   bool HasName;
   std::string Enc;
+
 public:
   FieldEncoding(bool b, SmallStringEnc &e) : HasName(b), Enc(e.c_str()) {}
   StringRef str() { return Enc; }
   bool operator<(const FieldEncoding &rhs) const {
-if (HasName != rhs.HasName) return HasName;
+if (HasName != rhs.HasName)
+  return HasName;
 return Enc < rhs.Enc;
   }
 };
@@ -196,7 +197,7 @@
   if (!ID)
 return;
   Entry &E = Map[ID];
-  assert( (E.Str.empty() || E.State == Recursive) &&
+  assert((E.Str.empty() || E.State == Recursive) &&
  "Incorrectly use of addIncomplete");
   assert(!StubEnc.empty() && "Passing an empty string to addIncomplete()");
   E.Swapped.swap(E.Str); // swap out the Recursive
@@ -215,8 +216,7 @@
   auto I = Map.find(ID);
   assert(I != Map.end() && "Entry not present");
   Entry &E = I->second;
-  assert( (E.State == Incomplete ||
-   E.State == IncompleteUsed) &&
+  assert((E.State == Incomplete || E.State == IncompleteUsed) &&
  "Entry must be an incomplete type");
   bool IsRecursive = false;
   if (E.State == IncompleteUsed) {
@@ -244,7 +244,7 @@
 return; // No key or it is an incomplete sub-type so don't add.
   Entry &E = Map[ID];
   if (IsRecursive && !E.Str.empty()) {
-assert(E.State==Recursive && E.Str.size() == Str.size() &&
+assert(E.State == Recursive && E.Str.size() == Str.size() &&
"This is not the same Recursive entry");
 // The parent container was not recursive after all, so we could have used
 // this Recursive sub-member entry after all, but we assumed the worse when
@@ -253,7 +253,7 @@
   }
   assert(E.Str.empty() && "Entry already present");
   E.Str = Str.str();
-  E.State = IsRecursive? Recursive : NonRecursive;
+  E.State = IsRecursive ? Recursive : NonRecursive;
 }
 
 /// Return a cached TypeString encoding for the ID. If there isn't one, or we
@@ -261,13 +261,13 @@
 /// encoding is Recursive, return an empty StringRef.
 StringRef TypeStringCache::lookupStr(const IdentifierInfo *ID) {
   if (!ID)
-return StringRef();   // We have no key.
+return StringRef(); // We have no key.
   auto I = Map.find(ID);
   if (I == Map.end())
-return StringRef();   // We have no encoding.
+return StringRef(); // We have no encoding.
   Entry &E = I->second;
   if (E.State == Recursive && IncompleteCount)
-return StringRef();   // We don't use Recursive encodings for member types.
+return StringRef(); // We don't use Recursive encodings for member types.
 
   if (E.State == Incomplete) {
 // The incomplete type is being used to 

[PATCH] D149986: AMDGPU: Force sc0 and sc1 on stores for gfx940 and gfx941

2023-05-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

In D149986#4329302 , @arsenm wrote:

> Should this be a feature set by default in the subtarget constructor instead? 
> Should you be able to turn this off?

Users should not be able to turn this off. If user wants it off, user can use 
gfx942. Should it be moved to the subtarget constructor?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149986

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


[clang] 6db007a - [Clang][Sema] Fix comparison of constraint expressions

2023-05-09 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-05-09T18:14:39Z
New Revision: 6db007a0654ed7a6ed5c3aa3b61a937c19a6bc6b

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

LOG: [Clang][Sema] Fix comparison of constraint expressions

This diff switches the approach to comparison of constraint expressions
to the new one based on template args substitution.
It continues the effort to fix our handling of out-of-line definitions
of constrained templates.
This is a recommit of 3a54022934.

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

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/concepts-friends.cpp
clang/test/SemaTemplate/concepts-out-of-line-def.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 3677335fa176f..7cd505218f2b9 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2309,9 +2309,15 @@ class ClassTemplateDecl : public 
RedeclarableTemplateDecl {
 return static_cast(RedeclarableTemplateDecl::getCommonPtr());
   }
 
+  void setCommonPtr(Common *C) {
+RedeclarableTemplateDecl::Common = C;
+  }
+
 public:
+
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
+  friend class TemplateDeclInstantiator;
 
   /// Load any lazily-loaded specializations from the external source.
   void LoadLazySpecializations() const;

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 48e8b78311e12..1de2cc6917b42 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -232,9 +232,21 @@ enum class TemplateSubstitutionKind : char {
 /// Replaces the current 'innermost' level with the provided argument list.
 /// This is useful for type deduction cases where we need to get the entire
 /// list from the AST, but then add the deduced innermost list.
-void replaceInnermostTemplateArguments(ArgList Args) {
-  assert(TemplateArgumentLists.size() > 0 && "Replacing in an empty 
list?");
-  TemplateArgumentLists[0].Args = Args;
+void replaceInnermostTemplateArguments(Decl *AssociatedDecl, ArgList Args) 
{
+  assert((!TemplateArgumentLists.empty() || NumRetainedOuterLevels) &&
+ "Replacing in an empty list?");
+
+  if (!TemplateArgumentLists.empty()) {
+assert((TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer() ||
+TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer() ==
+AssociatedDecl) &&
+   "Trying to change incorrect declaration?");
+TemplateArgumentLists[0].Args = Args;
+  } else {
+--NumRetainedOuterLevels;
+TemplateArgumentLists.push_back(
+{{AssociatedDecl, /*Final=*/false}, Args});
+  }
 }
 
 /// Add an outermost level that we are not substituting. We have no

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 7aa06b615fec2..1126c2c517fe4 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -722,7 +722,7 @@ CalculateTemplateDepthForConstraints(Sema &S, const 
NamedDecl *ND,
   ND, /*Final=*/false, /*Innermost=*/nullptr, /*RelativeToPrimary=*/true,
   /*Pattern=*/nullptr,
   /*ForConstraintInstantiation=*/true, SkipForSpecialization);
-  return MLTAL.getNumSubstitutedLevels();
+  return MLTAL.getNumLevels();
 }
 
 namespace {
@@ -753,27 +753,44 @@ namespace {
   };
 } // namespace
 
+static const Expr *SubstituteConstraintExpression(Sema &S, const NamedDecl *ND,
+  const Expr *ConstrExpr) {
+  MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
+  ND, /*Final=*/false, /*Innermost=*/nullptr,
+  /*RelativeToPrimary=*/true,
+  /*Pattern=*/nullptr, /*ForConstraintInstantiation=*/true,
+  /*SkipForSpecialization*/ false);
+  if (MLTAL.getNumSubstitutedLevels() == 0)
+return ConstrExpr;
+
+  Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/false);
+  std::optional ThisScope;
+  if (auto *RD = dyn_cast(ND->getDeclContext()))
+ThisScope.emplace(S, const_cast(RD), Qualifiers());
+  ExprResult SubstConstr =
+  S.SubstConstraintExpr(const_cast(ConstrExpr), MLTAL);
+  if (SFINAE.hasErrorOccurred() || !SubstConstr.isUsable())
+return nullptr;
+  return SubstConstr.get();
+}
+
 bool Sema::AreConstraintExpressionsEqual(co

[PATCH] D150192: Allow clang to emit inrange metadata when generating code for array subscripts

2023-05-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

From what I recall, "inrange" is actually more restrictive than the normal 
C/C++ array indexing rules.  Specifically, the bits regarding comparisons. 
"inrange" was designed to allow splitting globals indexed using inrange.

That isn't to say that functionality like this isn't useful, but we probably 
need to call it something different.  And I'm not sure an attribute on a GEP is 
actually the best way to represent the semantics. It might make sense to use a 
separate intrinsic to represent this, especially given the direction of 
https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150192

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


[PATCH] D150212: [clang][Sema] Improve diagnostics for auto return type

2023-05-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall, rsmith.
Herald added a project: All.
yaxunl requested review of this revision.

Currently when clang fails to deduce auto return type of a function,
it does not emit any notes about why it fails. This causes difficulty
for users to fix such errors.

Actually, clang already generates the information for emitting notes
about the failed deduction. There is a TODO for actually emitting
them.

This patch tries to implement the TODO. Basically it passes the
failed template specialization candidate set from the point of
specialization failure back to the point where the deduction starts.

It is not comprehensive but would be a start for further improvement.


https://reviews.llvm.org/D150212

Files:
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/auto-type-from-cxx.cpp

Index: clang/test/SemaCXX/auto-type-from-cxx.cpp
===
--- clang/test/SemaCXX/auto-type-from-cxx.cpp
+++ clang/test/SemaCXX/auto-type-from-cxx.cpp
@@ -18,3 +18,28 @@
   new __auto_type; // expected-error {{'__auto_type' not allowed in type allocated by 'new'}}
 }
 
+namespace TestDeductionFail {
+
+template
+void caller(T x) {x.fun();} // expected-note {{candidate template ignored: substitution failure [with T = TestDeductionFail::Abstract]: parameter type 'TestDeductionFail::Abstract' is an abstract class}}
+
+template
+auto getCaller(){
+  return caller; // expected-error {{cannot deduce return type 'auto' from returned value of type ''}}
+}
+
+class Abstract{
+  public:
+void fun();
+virtual void vfun()=0;
+void call(){getCaller()(*this);} // expected-note {{in instantiation of function template specialization 'TestDeductionFail::getCaller' requested here}}
+};
+
+class Derived: public Abstract{
+  public:
+void vfun();
+};
+
+Derived X;
+
+}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3748,7 +3748,8 @@
 static QualType
 ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams,
 Expr *Arg, QualType ParamType,
-bool ParamWasReference) {
+bool ParamWasReference,
+TemplateSpecCandidateSet *FailedTSC = nullptr) {
 
   OverloadExpr::FindResult R = OverloadExpr::find(Arg);
 
@@ -3770,8 +3771,10 @@
   !ParamType->isMemberFunctionPointerType()) {
 if (Ovl->hasExplicitTemplateArgs()) {
   // But we can still look for an explicit specialization.
-  if (FunctionDecl *ExplicitSpec
-= S.ResolveSingleFunctionTemplateSpecialization(Ovl))
+  if (FunctionDecl *ExplicitSpec =
+  S.ResolveSingleFunctionTemplateSpecialization(
+  Ovl, /*Complain=*/false,
+  /*FoundDeclAccessPair=*/nullptr, FailedTSC))
 return GetTypeOfFunction(S, R, ExplicitSpec);
 }
 
@@ -3853,7 +3856,8 @@
 /// overloaded function set that could not be resolved.
 static bool AdjustFunctionParmAndArgTypesForDeduction(
 Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex,
-QualType &ParamType, QualType &ArgType, Expr *Arg, unsigned &TDF) {
+QualType &ParamType, QualType &ArgType, Expr *Arg, unsigned &TDF,
+TemplateSpecCandidateSet *FailedTSC = nullptr) {
   // C++0x [temp.deduct.call]p3:
   //   If P is a cv-qualified type, the top level cv-qualifiers of P's type
   //   are ignored for type deduction.
@@ -3870,9 +3874,8 @@
   // but there are sometimes special circumstances.  Typically
   // involving a template-id-expr.
   if (ArgType == S.Context.OverloadTy) {
-ArgType = ResolveOverloadForDeduction(S, TemplateParams,
-  Arg, ParamType,
-  ParamRefType != nullptr);
+ArgType = ResolveOverloadForDeduction(S, TemplateParams, Arg, ParamType,
+  ParamRefType != nullptr, FailedTSC);
 if (ArgType.isNull())
   return true;
   }
@@ -3950,7 +3953,8 @@
 QualType ParamType, Expr *Arg, TemplateDeductionInfo &Info,
 SmallVectorImpl &Deduced,
 SmallVectorImpl &OriginalCallArgs,
-bool DecomposedParam, unsigned ArgIdx, unsigned TDF);
+bool DecomposedParam, unsigned ArgIdx, unsigned TDF,
+TemplateSpecCandidateSet *FailedTSC = nullptr);
 
 /// Attempt template argument deduction from an initializer list
 ///deemed to be an argument in a function call.
@@ -4026,14 +4030,16 @@
 QualType ParamType, Expr *Arg, TemplateDeductionInfo &Info,
 SmallVectorImpl &Deduced,
 SmallVectorImpl &OriginalCallArgs,
-bool DecomposedParam, 

[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2023-05-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for the continued work on this! In general, I think the test coverage 
should verify the deduced type information more often. e.g., if we accept the 
code, there should probably be a `static_assert` nearby that ensures the 
deduced type is what we'd expect.

I applied the patch locally and tried out various things, and here's some test 
coverage I think we're lacking.

  // Important: these two declarations are at file scope, we're testing that 
the storage
  // class specifier is ignored because we're deducing the type.
  auto i = 12; // Ok, deduces int
  auto j = 12ull; // Ok, deduces unsigned long long
  
  // This is testing whether storage specifier order matters:
  void func() {
const auto static i = 12; // Ok, static variable of type const int
  }



In D133289#4279054 , @to268 wrote:

> I have *hopefully* fixed my broken patch.
> This is all the things in need to address:
>
>   auto str2[] = "string";
>   [[clang::overloadable]] auto test(auto x) { return x; }
>
> and maybe retry to support `auto` in compound literals,
> becaue i have seen heavy macro users that want compound literals to work.
>
> I think it's safe to say that we will not support all features from N3076 
>  in this patch.

My testing of your patch suggests those aren't issues left to address 
(perhaps). e.g.,

  auto test[] = "foo";
  static_assert(_Generic(test, char * : 1, default : 0));

this matches what I'd expect (no warning, no failed assertion; string literals 
have type `char []` in C, not `const char[]`.

My testing of `__attribute__((overloadable))` with your patch is that we 
currently reject use of `auto` in those functions. I think that's good initial 
behavior -- if we want to allow `auto` there, that's probably better left to a 
follow-up patch anyway because I'd expect there to be some debate around 
whether that's a good idea or not.

As for compound literals, I think we've determined they're not supported by C 
currently.




Comment at: clang/test/C/C2x/n3007.c:20
+void test_atomic(void) {
+  _Atomic auto i = 12;  // expected-error {{_Atomic cannot be applied to type 
'auto' which is not trivially copyable}}
+  _Atomic(auto) j = 12; // expected-error {{'auto' not allowed here}} \

This diagnostic is incorrect -- I believe this code should be accepted.



Comment at: clang/test/C/C2x/n3007.c:21
+  _Atomic auto i = 12;  // expected-error {{_Atomic cannot be applied to type 
'auto' which is not trivially copyable}}
+  _Atomic(auto) j = 12; // expected-error {{'auto' not allowed here}} \
+   expected-error {{a type specifier is required for 
all declarations}}

This diagnostic is correct.



Comment at: clang/test/C/C2x/n3007.c:31-32
+  double A[3] = { 0 };
+  auto pA = A;
+  auto qA = &A;
+  auto pi = 3.14;

We should test that the types match our expectations:
```
double A[3] = { 0 };
auto pA = A; // pA is double * due to array decay on A
static_assert(_Generic(pA, double * : 1, default : 0));
auto qA = &A; // qA is double (*)[3]
static_assert(_Generic(qA, double (*)[3] : 1, default : 0));
```



Comment at: clang/test/C/C2x/n3007.c:46
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  _Alignas(auto) auto b[4];   // expected-error {{declaration of variable 
'b' with deduced type 'auto[4]' requires an initializer}} \
+ expected-error {{expected expression}}

I think this would make it more clear that what's being tested is the 
`_Alignas` behavior.



Comment at: clang/test/C/C2x/n3007.c:56-57
+void test_initializer_list(void) {
+  // FIXME: as mentioned in N3076, it seems that intializer list are allowed
+  // even with an initializer list containing one item
+  auto a = {};// expected-error {{cannot use 'auto' with 
initializer list in C}}

This should now be resolved in N3096  so the FIXME comment can be removed.



Comment at: clang/test/C/C2x/n3007.c:66
+void test_structs(void) {
+  auto a = (struct { int a; } *)0;
+  struct B { auto b; };   // expected-error {{'auto' not allowed in struct 
member}}

This is awfully close to the examples from the paper (6.7.9p3):
```
auto p1 = (struct { int a; } *)0; // error expected

struct s;
auto p2 = (struct s { int a; } *)0; // error expected
```
They are expected to be diagnosed due to changes in N3006 (underspecified 
object definitions), so I think it's fine to add a FIXME comment with the test 
cases instead of trying to also implement N3006 at the same time. We currently 
list that as `unknown` in our status page, but I think it's clearly a `no` now.



Comment at: clang/test/C/C2x/n3007.c:100
+  auto d = 

[PATCH] D150209: [clang][Interp] Add more shift error checking

2023-05-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150209

Files:
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/shifts.cpp


Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -152,4 +152,14 @@
   constexpr signed int R = (sizeof(unsigned) * 8) + 1;
   constexpr decltype(L) M  = (R > 32 && R < 64) ?  L << R : 0;
   constexpr decltype(L) M2 = (R > 32 && R < 64) ?  L >> R : 0;
+
+
+  constexpr int signedShift() { // cxx17-error {{never produces a constant 
expression}} \
+// ref-cxx17-error {{never produces a constant 
expression}}
+return 1024 << 31; // cxx17-warning {{signed shift result}} \
+   // ref-cxx17-warning {{signed shift result}} \
+   // cxx17-note {{signed left shift discards bits}} \
+   // ref-cxx17-note {{signed left shift discards bits}}
+  }
+
 };
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -109,8 +109,9 @@
 bool CheckCtorCall(InterpState &S, CodePtr OpPC, const Pointer &This);
 
 /// Checks if the shift operation is legal.
-template 
-bool CheckShift(InterpState &S, CodePtr OpPC, const RT &RHS, unsigned Bits) {
+template 
+bool CheckShift(InterpState &S, CodePtr OpPC, const LT &LHS, const RT &RHS,
+unsigned Bits) {
   if (RHS.isNegative()) {
 const SourceInfo &Loc = S.Current->getSource(OpPC);
 S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS.toAPSInt();
@@ -125,6 +126,16 @@
 QualType Ty = E->getType();
 S.CCEDiag(E, diag::note_constexpr_large_shift) << Val << Ty << Bits;
 return false;
+  } else if (LHS.isSigned() && !S.getLangOpts().CPlusPlus20) {
+const Expr *E = S.Current->getExpr(OpPC);
+// C++11 [expr.shift]p2: A signed left shift must have a non-negative
+// operand, and must not overflow the corresponding unsigned type.
+// C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+// E1 x 2^E2 module 2^N.
+if (LHS.isNegative())
+  S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << 12;
+else if (LHS.toUnsigned().countLeadingZeros() < static_cast(RHS))
+  S.CCEDiag(E, diag::note_constexpr_lshift_discards);
   }
   return true;
 }
@@ -1612,7 +1623,7 @@
   const auto &LHS = S.Stk.pop();
   const unsigned Bits = LHS.bitWidth();
 
-  if (!CheckShift(S, OpPC, RHS, Bits))
+  if (!CheckShift(S, OpPC, LHS, RHS, Bits))
 return false;
 
   Integral R;
@@ -1629,7 +1640,7 @@
   const auto &LHS = S.Stk.pop();
   const unsigned Bits = LHS.bitWidth();
 
-  if (!CheckShift(S, OpPC, RHS, Bits))
+  if (!CheckShift(S, OpPC, LHS, RHS, Bits))
 return false;
 
   Integral R;
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -127,7 +127,11 @@
 return Compare(V, RHS.V);
   }
 
-  unsigned countLeadingZeros() const { return llvm::countl_zero(V); }
+  unsigned countLeadingZeros() const {
+if constexpr (!Signed)
+  return llvm::countl_zero(V);
+llvm_unreachable("Don't call countLeadingZeros() on signed types.");
+  }
 
   Integral truncate(unsigned TruncBits) const {
 if (TruncBits >= Bits)


Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -152,4 +152,14 @@
   constexpr signed int R = (sizeof(unsigned) * 8) + 1;
   constexpr decltype(L) M  = (R > 32 && R < 64) ?  L << R : 0;
   constexpr decltype(L) M2 = (R > 32 && R < 64) ?  L >> R : 0;
+
+
+  constexpr int signedShift() { // cxx17-error {{never produces a constant expression}} \
+// ref-cxx17-error {{never produces a constant expression}}
+return 1024 << 31; // cxx17-warning {{signed shift result}} \
+   // ref-cxx17-warning {{signed shift result}} \
+   // cxx17-note {{signed left shift discards bits}} \
+   // ref-cxx17-note {{signed left shift discards bits}}
+  }
+
 };
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -109,8 +109,9 @@
 bool CheckCtorCall(InterpState &S, CodePtr OpPC, const Pointer &This);
 
 /// Checks if the shift operation is legal.
-template 
-bool CheckShift(InterpState &S, C

[PATCH] D150013: [Clang] Respect `-L` options when compiling directly for AMDGPU

2023-05-09 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:546
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+  Args.AddAllArgs(CmdArgs, options::OPT_L);

MaskRay wrote:
> jhuber6 wrote:
> > yaxunl wrote:
> > > jhuber6 wrote:
> > > > yaxunl wrote:
> > > > > AddLinkerInputs has code doing that, and it handles env var 
> > > > > LIBRARY_PATH. However that code is disabled for AMDGPU because AMDGPU 
> > > > > returns true for isCrossCompiling.
> > > > > 
> > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/CommonArgs.cpp#L236
> > > > > 
> > > > > It seems isCrossCompiling is solely for controlling whether to 
> > > > > consume `-L`. If we want amdgpu toolchain to accept `-L`, we can 
> > > > > simply let isCrossCompiling return false.
> > > > Good catch, we could maybe set `isCrossCompiling` to false if targeted 
> > > > directly by the user, e.g. `--target=amdgcn-amd-amdhsa` vs 
> > > > `--offload-arch`.
> > > That would be better. Thanks.
> > It still is technically cross compiling, since we are building for a target 
> > that does not match the system's architecture. The original code that 
> > prevents passing `-L` was contributed by @MaskRay. I understand that we may 
> > not want to pass `LIBRARY_PATH` defines, but what's the rationale for not 
> > passing any `-L` options manually specified by the user?
> The `LIBRARY_PATH` code had been there when I moved it in 2019. It'd be best 
> not to rely on `LIBRARY_PATH`. I think that forwarding `-L` seems reasonable 
> but I am not familiar with the amdgpu ecosystem..
The linker is just `lld` so it should be the same conceptually. I'm just 
figuring that even if the user is cross compiling we should respect `-L` passed 
on the command line. Should I change this patch to make that change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150013

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


[PATCH] D150013: [Clang] Respect `-L` options when compiling directly for AMDGPU

2023-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:546
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+  Args.AddAllArgs(CmdArgs, options::OPT_L);

jhuber6 wrote:
> yaxunl wrote:
> > jhuber6 wrote:
> > > yaxunl wrote:
> > > > AddLinkerInputs has code doing that, and it handles env var 
> > > > LIBRARY_PATH. However that code is disabled for AMDGPU because AMDGPU 
> > > > returns true for isCrossCompiling.
> > > > 
> > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/CommonArgs.cpp#L236
> > > > 
> > > > It seems isCrossCompiling is solely for controlling whether to consume 
> > > > `-L`. If we want amdgpu toolchain to accept `-L`, we can simply let 
> > > > isCrossCompiling return false.
> > > Good catch, we could maybe set `isCrossCompiling` to false if targeted 
> > > directly by the user, e.g. `--target=amdgcn-amd-amdhsa` vs 
> > > `--offload-arch`.
> > That would be better. Thanks.
> It still is technically cross compiling, since we are building for a target 
> that does not match the system's architecture. The original code that 
> prevents passing `-L` was contributed by @MaskRay. I understand that we may 
> not want to pass `LIBRARY_PATH` defines, but what's the rationale for not 
> passing any `-L` options manually specified by the user?
The `LIBRARY_PATH` code had been there when I moved it in 2019. It'd be best 
not to rely on `LIBRARY_PATH`. I think that forwarding `-L` seems reasonable 
but I am not familiar with the amdgpu ecosystem..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150013

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


[PATCH] D150001: [clang] Fix initializer_list matching failures with modules

2023-05-09 Thread Alan Zhao 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 rGd1d35f04c6cb: [clang] Fix initializer_list matching failures 
with modules (authored by ayzhao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150001

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Modules/match_initializer_list.cpp


Index: clang/test/Modules/match_initializer_list.cpp
===
--- /dev/null
+++ clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,10 @@
 &PP.getIdentifierTable().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+// We want the created NamespaceDecl to be available for redeclaration
+// lookups, but not for regular name lookups.
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.


Index: clang/test/Modules/match_initializer_list.cpp
===
--- /dev/null
+++ clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,10 @@
 &PP.getIdentifierTable().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+// We want the created NamespaceDecl to be available for redeclaration
+// lookups, but not for regular name lookups.
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d1d35f0 - [clang] Fix initializer_list matching failures with modules

2023-05-09 Thread Alan Zhao via cfe-commits

Author: Alan Zhao
Date: 2023-05-09T10:31:43-07:00
New Revision: d1d35f04c6cb2e3d5b0fbc6101d5425a33f8fc63

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

LOG: [clang] Fix initializer_list matching failures with modules

Previously, if a class with a defined public virtual destructor is
declared before including  and initializer_list is
provided via a Clang module, then overload resolution would fail for
std::initializer_list. This is because when Clang sees the virtual
destructor, Clang creates an implicit NamespaceDecl for std to
implicitly declare a std::bad_alloc. That NamespaceDecl is not added to
the translation unit's lookup table, so when the module containing
std::initializer_list is imported later, that module's std NamespaceDecl
can't find the previous std NamespaceDecl during redeclaration lookup,
causing overload resolution to fail.

To fix this, implicitly created std NamespaceDecls are now added to the
lookup map. At the same time, their IdentifierNamespace members are
cleared to prevent regular name lookups from finding it.

Fixes 60929

Reviewed By: ChuanqiXu, #clang-language-wg, inclyc

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

Added: 
clang/test/Modules/match_initializer_list.cpp

Modified: 
clang/include/clang/AST/DeclBase.h
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index e86eadab0a8a4..be76d1648b9ac 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@ class alignas(8) Decl {
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 4efa1b408607d..e68afaa61ef1c 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,10 @@ NamespaceDecl *Sema::getOrCreateStdNamespace() {
 &PP.getIdentifierTable().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+// We want the created NamespaceDecl to be available for redeclaration
+// lookups, but not for regular name lookups.
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();

diff  --git a/clang/test/Modules/match_initializer_list.cpp 
b/clang/test/Modules/match_initializer_list.cpp
new file mode 100644
index 0..31e2b015a9d05
--- /dev/null
+++ b/clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }



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


[PATCH] D149884: [clang][deps] Teach dep directive scanner about _Pragma

2023-05-09 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee8ed0b3099e: [clang][deps] Teach dep directive scanner 
about _Pragma (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149884

Files:
  clang/include/clang/Lex/Pragma.h
  clang/lib/Lex/DependencyDirectivesScanner.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/ClangScanDeps/_Pragma-once.c
  clang/unittests/Lex/DependencyDirectivesScannerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
@@ -503,6 +503,92 @@
   EXPECT_STREQ("#pragma clang module import\n", Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, UnderscorePragma) {
+  SmallVector Out;
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(R"(_)", Out));
+  EXPECT_STREQ("\n", Out.data());
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(R"(_Pragma)", Out));
+  EXPECT_STREQ("\n", Out.data());
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(R"(_Pragma()", Out));
+  EXPECT_STREQ("\n", Out.data());
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(R"(_Pragma())", Out));
+  EXPECT_STREQ("\n", Out.data());
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(R"(_Pragma(")", Out));
+  EXPECT_STREQ("\n", Out.data());
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(R"(_Pragma("A"))", Out));
+  EXPECT_STREQ("\n", Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"x(_Pragma("push_macro(\"MACRO\")"))x", Out));
+  EXPECT_STREQ(R"x(_Pragma("push_macro(\"MACRO\")"))x"
+   "\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"x(_Pragma("pop_macro(\"MACRO\")"))x", Out));
+  EXPECT_STREQ(R"x(_Pragma("pop_macro(\"MACRO\")"))x"
+   "\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"x(_Pragma("include_alias(\"A\", \"B\")"))x", Out));
+  EXPECT_STREQ(R"x(_Pragma("include_alias(\"A\", \"B\")"))x"
+   "\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"x(_Pragma("include_alias(, )"))x", Out));
+  EXPECT_STREQ(R"x(_Pragma("include_alias(, )"))x"
+   "\n",
+   Out.data());
+
+  ASSERT_FALSE(
+  minimizeSourceToDependencyDirectives(R"(_Pragma("clang"))", Out));
+  EXPECT_STREQ("\n", Out.data());
+
+  ASSERT_FALSE(
+  minimizeSourceToDependencyDirectives(R"(_Pragma("clang module"))", Out));
+  EXPECT_STREQ("\n", Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"(_Pragma("clang module impor"))", Out));
+  EXPECT_STREQ("\n", Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"(_Pragma("clang module import"))", Out));
+  EXPECT_STREQ(R"(_Pragma("clang module import"))"
+   "\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"(_Pragma("clang \
+  module \
+  import"))",
+  Out));
+  EXPECT_STREQ(R"(_Pragma("clang \
+  module \
+  import"))"
+   "\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"(_Pragma(L"clang module import"))", Out));
+  EXPECT_STREQ(R"(_Pragma(L"clang module import"))"
+   "\n",
+   Out.data());
+
+  // FIXME: u"" strings depend on using C11 language mode
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"(_Pragma(u"clang module import"))", Out));
+  EXPECT_STREQ("\n", Out.data());
+
+  // FIXME: R"()" strings depend on using C++ 11 language mode
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(
+  R"(_Pragma(R"abc(clang module import)abc"))", Out));
+  EXPECT_STREQ("\n", Out.data());
+}
+
 TEST(MinimizeSourceToDependencyDirectivesTest, Include) {
   SmallVector Out;
 
@@ -757,20 +843,26 @@
 #pragma once
 // another comment
 #include 
+_Pragma("once")
 )";
   ASSERT_FALSE(
   minimizeSourceToDependencyDirectives(Source, Out, Tokens, Directives));
-  EXPECT_STREQ("#pragma once\n#include \n", Out.data());
-  ASSERT_EQ(Directives.size(), 3u);
+  EXPECT_STREQ("#pragma once\n#include \n_Pragma(\"once\")\n",
+   Out.data());
+  ASSERT_EQ(Directives.size(), 4u);
   EXPECT_EQ(Directives[0].Kind, dependency_directives_scan::pp_pragma_once);
+  EXPECT_EQ(Directives[2].Kind, dependency_directives_scan::pp_pragma_once);
 
   Source = R"(// comment
 #pragma once extra tokens
 // another comment
 #include 
+_Pragma("once") extra tokens
 )";
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
-  EXPECT_STREQ("#pragma once extra tokens\n#include \n", Out.data());
+  EXPECT_STREQ("#pragma once extra tokens\n#include "
+   "\n_P

[PATCH] D150001: [clang] Fix initializer_list matching failures with modules

2023-05-09 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 520744.
ayzhao added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150001

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Modules/match_initializer_list.cpp


Index: clang/test/Modules/match_initializer_list.cpp
===
--- /dev/null
+++ clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,10 @@
 &PP.getIdentifierTable().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+// We want the created NamespaceDecl to be available for redeclaration
+// lookups, but not for regular name lookups.
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.


Index: clang/test/Modules/match_initializer_list.cpp
===
--- /dev/null
+++ clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,10 @@
 &PP.getIdentifierTable().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+// We want the created NamespaceDecl to be available for redeclaration
+// lookups, but not for regular name lookups.
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ee8ed0b - [clang][deps] Teach dep directive scanner about _Pragma

2023-05-09 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-05-09T10:05:12-07:00
New Revision: ee8ed0b3099e63ba0a18cca42b9cfdf098bc6201

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

LOG: [clang][deps] Teach dep directive scanner about _Pragma

While we cannot handle `_Pragma` used inside macros, we can handle
this at the top level, and it some projects use the `_Pragma("once")`
spelling like that, which was causing spurious failures in the scanner.

Limitations
* Cannot handle #define ONCE _Pragma("once"), same issue as using
  @import in a macro -- ideally we should diagnose this in obvious cases
* Our LangOpts are currently fixed, so we are not handling u"" strings
  or R"()" strings that require C11/C++11.

rdar://108629982

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

Added: 
clang/test/ClangScanDeps/_Pragma-once.c

Modified: 
clang/include/clang/Lex/Pragma.h
clang/lib/Lex/DependencyDirectivesScanner.cpp
clang/lib/Lex/Pragma.cpp
clang/unittests/Lex/DependencyDirectivesScannerTest.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/Pragma.h 
b/clang/include/clang/Lex/Pragma.h
index cf8cca5414eac..67eca618f6c4f 100644
--- a/clang/include/clang/Lex/Pragma.h
+++ b/clang/include/clang/Lex/Pragma.h
@@ -123,6 +123,13 @@ class PragmaNamespace : public PragmaHandler {
   PragmaNamespace *getIfNamespace() override { return this; }
 };
 
+/// Destringize a \c _Pragma("") string according to C11 6.10.9.1:
+/// "The string literal is destringized by deleting any encoding prefix,
+/// deleting the leading and trailing double-quotes, replacing each escape
+/// sequence \" by a double-quote, and replacing each escape sequence \\ by a
+/// single backslash."
+void prepare_PragmaString(SmallVectorImpl &StrVal);
+
 } // namespace clang
 
 #endif // LLVM_CLANG_LEX_PRAGMA_H

diff  --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp 
b/clang/lib/Lex/DependencyDirectivesScanner.cpp
index a506b49176302..2bd2c5f8388c0 100644
--- a/clang/lib/Lex/DependencyDirectivesScanner.cpp
+++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Lex/Pragma.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
@@ -72,6 +73,8 @@ struct Scanner {
 // Set the lexer to use 'tok::at' for '@', instead of 'tok::unknown'.
 LangOpts.ObjC = true;
 LangOpts.LineComment = true;
+// FIXME: we do not enable C11 or C++11, so we are missing u/u8/U"" and
+// R"()" literals.
 return LangOpts;
   }
 
@@ -91,6 +94,10 @@ struct Scanner {
   void skipLine(const char *&First, const char *const End);
   void skipDirective(StringRef Name, const char *&First, const char *const 
End);
 
+  /// Returns the spelling of a string literal or identifier after performing
+  /// any processing needed to handle \c clang::Token::NeedsCleaning.
+  StringRef cleanStringIfNeeded(const dependency_directives_scan::Token &Tok);
+
   /// Lexes next token and if it is identifier returns its string, otherwise
   /// it skips the current line and returns \p std::nullopt.
   ///
@@ -112,6 +119,22 @@ struct Scanner {
 const char *&First,
 const char *const End);
 
+  /// Lexes next token and returns true iff it matches the kind \p K.
+  /// Otherwise it skips the current line and returns false.
+  ///
+  /// In any case (whatever the token kind) \p First and the \p Lexer will
+  /// advance beyond the token.
+  [[nodiscard]] bool isNextTokenOrSkipLine(tok::TokenKind K, const char 
*&First,
+   const char *const End);
+
+  /// Lexes next token and if it is string literal, returns its string.
+  /// Otherwise, it skips the current line and returns \p std::nullopt.
+  ///
+  /// In any case (whatever the token kind) \p First and the \p Lexer will
+  /// advance beyond the token.
+  [[nodiscard]] std::optional
+  tryLexStringLiteralOrSkipLine(const char *&First, const char *const End);
+
   [[nodiscard]] bool scanImpl(const char *First, const char *const End);
   [[nodiscard]] bool lexPPLine(const char *&First, const char *const End);
   [[nodiscard]] bool lexAt(const char *&First, const char *const End);
@@ -119,6 +142,7 @@ struct Scanner {
   [[nodiscard]] bool lexDefine(const char *HashLoc, const char *&First,
const char *const End);
   [[nodiscard]] bool lexPragma(const char *&First, const char *const End);
+  [[nodiscard]] bool lex_Pragma(const char *&First, const char *const End);
   [[nodiscard]] bool lexEndif(const char *&First, const char *const End);
   [[nodiscard]] bool lexDef

[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-09 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks reopened this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

the following crashes with this patch:

  struct StringRef {
StringRef(const char *);
  };
  template 
  StringRef getTypeName() {
StringRef s = __func__;
  }

`clang -cc1 -fms-extensions -std=c++17 -x c++ a.cpp -fsyntax-only`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D150122: [Clang] Fix status of P0960

2023-05-09 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

In D150122#4329401 , @aaron.ballman 
wrote:

> I believe we are having another release of Clang 16, but @tstellar can 
> confirm or deny that.
>
> AIUI, there were a few issues holding us back from claiming complete support 
> (added @ayzhao as a reviewer in case he has a different opinion):
> https://github.com/llvm/llvm-project/issues/61145  (backported to 16.x)
> https://github.com/llvm/llvm-project/issues/62296  (backported to 16.x)
> https://github.com/llvm/llvm-project/issues/62266  (not backported)
> https://github.com/llvm/llvm-project/issues/61567  (not backported)
>
> If we backport the two other issues to 16, then I think the changes in this 
> review are fine. If we don't backport those two, I think we should claim 
> Clang 17 to be conservative.

I started the backporting process for the remaining 2 bugs. I'm doing 
https://github.com/llvm/llvm-project/issues/62266 first before doing 
https://github.com/llvm/llvm-project/issues/61567 because otherwise there will 
be a merge issue. Once those two commits are backported then this patch LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150122

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


[PATCH] D150071: [clang-tidy] Fix bugprone-assert-side-effect to actually give warnings

2023-05-09 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Thanks for the review! Fixed your comments before landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150071

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


[PATCH] D150071: [clang-tidy] Fix bugprone-assert-side-effect to actually give warnings

2023-05-09 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
carlosgalvezp marked 2 inline comments as done.
Closed by commit rG0d6d8a853a6e: [clang-tidy] Fix bugprone-assert-side-effect 
to actually give warnings (authored by carlosgalvezp).

Changed prior to commit:
  https://reviews.llvm.org/D150071?vs=520194&id=520732#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150071

Files:
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp
@@ -1,47 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}, {key: bugprone-assert-side-effect.IgnoredFunctions, value: 'MyClass::badButIgnoredFunc'}]}" -- -fexceptions
-
-//===--- assert definition block --===//
-int abort() { return 0; }
-
-#ifdef NDEBUG
-#define assert(x) 1
-#else
-#define assert(x)  \
-  if (!(x))\
-  (void)abort()
-#endif
-
-void print(...);
-#define assert2(e) (__builtin_expect(!(e), 0) ?\
-   print (#e, __FILE__, __LINE__) : (void)0)
-
-#ifdef NDEBUG
-#define my_assert(x) 1
-#else
-#define my_assert(x)   \
-  ((void)((x) ? 1 : abort()))
-#endif
-
-#ifdef NDEBUG
-#define not_my_assert(x) 1
-#else
-#define not_my_assert(x)   \
-  if (!(x))\
-  (void)abort()
-#endif
-
-#define real_assert(x) ((void)((x) ? 1 : abort()))
-#define wrap1(x) real_assert(x)
-#define wrap2(x) wrap1(x)
-#define convoluted_assert(x) wrap2(x)
-
-#define msvc_assert(expression) (void)(\
-(!!(expression)) ||\
-(abort(), 0)   \
-)
-
-
-//===--===//
+// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}, {key: bugprone-assert-side-effect.IgnoredFunctions, value: 'MyClass::badButIgnoredFunc'}]}" -- -fexceptions -I %S/Inputs/assert-side-effect
+#include 
 
 bool badButIgnoredFunc(int a, int b) { return a * b > 0; }
 
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h
@@ -0,0 +1,40 @@
+#pragma clang system_header
+
+int abort();
+
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  \
+  if (!(x))\
+  (void)abort()
+#endif
+
+void print(...);
+#define assert2(e) (__builtin_expect(!(e), 0) ?\
+   print (#e, __FILE__, __LINE__) : (void)0)
+
+#ifdef NDEBUG
+#define my_assert(x) 1
+#else
+#define my_assert(x)   \
+  ((void)((x) ? 1 : abort()))
+#endif
+
+#ifdef NDEBUG
+#define not_my_assert(x) 1
+#else
+#define not_my_assert(x)   \
+  if (!(x))\
+  (void)abort()
+#endif
+
+#define real_assert(x) ((void)((x) ? 1 : abort()))
+#define wrap1(x) real_assert(x)
+#define wrap2(x) wrap1(x)
+#define convoluted_assert(x) wrap2(x)
+
+#define msvc_assert(expression) (void)(\
+(!!(expression)) ||\
+(abort(), 0)   \
+)
Index: clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
=

[clang-tools-extra] 0d6d8a8 - [clang-tidy] Fix bugprone-assert-side-effect to actually give warnings

2023-05-09 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2023-05-09T16:45:02Z
New Revision: 0d6d8a853a6ea29b5f461a475a8f8eb7e7ba18e2

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

LOG: [clang-tidy] Fix bugprone-assert-side-effect to actually give warnings

Some time ago a patch was merged to disable all clang-tidy warnings
from system macros. This led to bugprone-assert-side-effect
silently no longer working, since the warnings came from a system
macro. The problem was not detected because the fake assert functions
were implemented in the same file as the test, instead of being a
system include like it's done in the real world.

Move the assert to a proper system header, and fix the code to
warn at the correct location.

This patch is breakdown from https://reviews.llvm.org/D147081
by PiotrZSL.

Fixes https://github.com/llvm/llvm-project/issues/62314

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h

Modified: 
clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
index 600a923b211cf..07a987359d4d8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
@@ -117,13 +117,13 @@ void AssertSideEffectCheck::check(const 
MatchFinder::MatchResult &Result) {
   StringRef AssertMacroName;
   while (Loc.isValid() && Loc.isMacroID()) {
 StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
+Loc = SM.getImmediateMacroCallerLoc(Loc);
 
 // Check if this macro is an assert.
 if (llvm::is_contained(AssertMacros, MacroName)) {
   AssertMacroName = MacroName;
   break;
 }
-Loc = SM.getImmediateMacroCallerLoc(Loc);
   }
   if (AssertMacroName.empty())
 return;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h
new file mode 100644
index 0..904597ff2184e
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/assert-side-effect/assert.h
@@ -0,0 +1,40 @@
+#pragma clang system_header
+
+int abort();
+
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  
\
+  if (!(x))
\
+  (void)abort()
+#endif
+
+void print(...);
+#define assert2(e) (__builtin_expect(!(e), 0) ?
\
+   print (#e, __FILE__, __LINE__) : (void)0)
+
+#ifdef NDEBUG
+#define my_assert(x) 1
+#else
+#define my_assert(x)   
\
+  ((void)((x) ? 1 : abort()))
+#endif
+
+#ifdef NDEBUG
+#define not_my_assert(x) 1
+#else
+#define not_my_assert(x)   
\
+  if (!(x))
\
+  (void)abort()
+#endif
+
+#define real_assert(x) ((void)((x) ? 1 : abort()))
+#define wrap1(x) real_assert(x)
+#define wrap2(x) wrap1(x)
+#define convoluted_assert(x) wrap2(x)
+
+#define msvc_assert(expression) (void)(
\
+(!!(expression)) ||
\
+(abort(), 0)   
\
+)

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp
index c327007651d4c..ccafeb4b7f3b1 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/assert-side-effect.cpp
@@ -1,47 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- 
-config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, 
value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 
'assert,assert2,my_assert,convoluted_assert,msvc_assert'}, {key: 
bugprone-assert-side-effect.IgnoredFunctions, value: 
'MyClass::badButIgnoredFunc'}]}" -- -fexceptions
-
-//===--- assert definition block 
--===//
-int abort() { return 0; }
-
-#ifdef NDEBUG
-#define assert(x) 1
-#else
-#define assert(x)  
\
-  if (!(x))   

[PATCH] D149872: [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

2023-05-09 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 520730.
TIFitis added a comment.

Addressed reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4368,6 +4368,260 @@
 Builder.CreatePointerCast(Info.RTArgs.MappersArray, VoidPtrPtrTy);
 }
 
+void OpenMPIRBuilder::emitNonContiguousDescriptor(InsertPointTy AllocaIP,
+  InsertPointTy CodeGenIP,
+  MapInfosTy &CombinedInfo,
+  TargetDataInfo &Info) {
+  MapInfosTy::StructNonContiguousInfo &NonContigInfo =
+  CombinedInfo.NonContigInfo;
+
+  // Build an array of struct descriptor_dim and then assign it to
+  // offload_args.
+  //
+  // struct descriptor_dim {
+  //  uint64_t offset;
+  //  uint64_t count;
+  //  uint64_t stride
+  // };
+  Type *Int64Ty = Builder.getInt64Ty();
+  StructType *DimTy = StructType::create(
+  M.getContext(), ArrayRef({Int64Ty, Int64Ty, Int64Ty}),
+  "struct.descriptor_dim");
+
+  enum { OffsetFD = 0, CountFD, StrideFD };
+  // We need two index variable here since the size of "Dims" is the same as
+  // the size of Components, however, the size of offset, count, and stride is
+  // equal to the size of base declaration that is non-contiguous.
+  for (unsigned I = 0, L = 0, E = NonContigInfo.Dims.size(); I < E; ++I) {
+// Skip emitting ir if dimension size is 1 since it cannot be
+// non-contiguous.
+if (NonContigInfo.Dims[I] == 1)
+  continue;
+Builder.restoreIP(AllocaIP);
+ArrayType *ArrayTy = ArrayType::get(DimTy, NonContigInfo.Dims[I]);
+AllocaInst *DimsAddr =
+Builder.CreateAlloca(ArrayTy, /* ArraySize = */ nullptr, "dims");
+Builder.restoreIP(CodeGenIP);
+for (unsigned II = 0, EE = NonContigInfo.Dims[I]; II < EE; ++II) {
+  unsigned RevIdx = EE - II - 1;
+  Value *DimsLVal = Builder.CreateInBoundsGEP(
+  DimsAddr->getAllocatedType(), DimsAddr,
+  {Builder.getInt64(0), Builder.getInt64(II)});
+  // Offset
+  Value *OffsetLVal = Builder.CreateStructGEP(DimTy, DimsLVal, OffsetFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Offsets[L][RevIdx], OffsetLVal,
+  M.getDataLayout().getPrefTypeAlign(OffsetLVal->getType()));
+  // Count
+  Value *CountLVal = Builder.CreateStructGEP(DimTy, DimsLVal, CountFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Counts[L][RevIdx], CountLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+  // Stride
+  Value *StrideLVal = Builder.CreateStructGEP(DimTy, DimsLVal, StrideFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Strides[L][RevIdx], StrideLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+}
+// args[I] = &dims
+Builder.restoreIP(CodeGenIP);
+Value *DAddr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+DimsAddr, Builder.getInt8PtrTy());
+Value *P = Builder.CreateConstInBoundsGEP2_32(
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs),
+Info.RTArgs.PointersArray, 0, I);
+Builder.CreateAlignedStore(
+DAddr, P, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
+++L;
+  }
+}
+
+void OpenMPIRBuilder::emitOffloadingArrays(
+InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
+TargetDataInfo &Info, bool IsNonContiguous,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
+
+  // Reset the array information.
+  Info.clearArrayInfo();
+  Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
+
+  if (Info.NumberOfPtrs) {
+Builder.restoreIP(AllocaIP);
+// Detect if we have any capture size requiring runtime evaluation of the
+// size so that a constant array could be eventually used.
+ArrayType *PointerArrayType =
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs);
+
+Info.RTArgs.BasePointersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_baseptrs");
+
+Info.RTArgs.PointersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_ptrs");
+AllocaInst *MappersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_mappers");
+Info.RTArgs.MappersArray = MappersArray;
+
+// If we don't have any VLA types or other types that require runtime
+// evaluation, we can use a constant array for the map sizes, otherwise we
+ 

[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:14473
+  // directive and has static storage duration.
+  if (auto *VD = dyn_cast_or_null(D);
+  LangOpts.OpenMP && VD && VD->hasAttr() &&

В is already checked that is not nullptr, so just a dyn_cast should be enough



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23094-23095
+public:
+  SmallVector DeclVector;
+  Decl *TargetDecl;
+  void VisitDeclRefExpr(const DeclRefExpr *Node) {

Why public?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23098
+Decl *DeclVar = nullptr;
+if (const VarDecl *VD = dyn_cast(Node->getDecl())) {
+  DeclVar = (Decl *)Node->getDecl();

const auto *VD



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23099
+if (const VarDecl *VD = dyn_cast(Node->getDecl())) {
+  DeclVar = (Decl *)Node->getDecl();
+  
DeclVar->addAttr((this->TargetDecl)->getAttr());

Use VD instead of this and drop const



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23100-23101
+  DeclVar = (Decl *)Node->getDecl();
+  
DeclVar->addAttr((this->TargetDecl)->getAttr());
+  (this->DeclVector).push_back(DeclVar);
+}

Drop this and extra parens



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23107-23110
+  if (isa(*it))
+VisitExpr(dyn_cast(*it));
+  if (isa(*it))
+Visit(*it);

Just Visit(*it)?


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

https://reviews.llvm.org/D146418

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-09 Thread Ritanya via Phabricator via cfe-commits
RitanyaB updated this revision to Diff 520729.

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

https://reviews.llvm.org/D146418

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_variables_ast_print.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===
--- clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
+++ clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
@@ -95,7 +95,7 @@
 int (*D)() = C; // expected-note {{used here}}
 // host-note@-1 {{used here}}
 #pragma omp end declare target
-int foobar3() { throw 1; }
+int foobar3() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
 
 // Check no infinite recursion in deferred diagnostic emitter.
 long E = (long)&E;
Index: clang/test/OpenMP/declare_target_variables_ast_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_variables_ast_print.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -w -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s --check-prefix=CHECK
+// expected-no-diagnostics
+
+static int variable = 100; 
+static float variable1 = 200;
+static float variable2 = variable1; 
+
+static int var = 1;
+
+static int var1 = 10;
+static int *var2 = &var1;
+static int **ptr1 = &var2;
+
+int arr[2] = {1,2};
+int (*arrptr)[2] = &arr;
+
+class declare{
+  public: int x;
+  void print();
+};
+declare obj1;
+declare *obj2 = &obj1;
+
+struct target{
+  int x;
+  void print();
+};
+static target S;
+
+#pragma omp declare target
+int target_var = variable;
+float target_var1 = variable2;
+int *ptr = &var;
+int ***ptr2 = &ptr1;
+int (**ptr3)[2] = &arrptr;
+declare **obj3 = &obj2;
+target *S1 = &S;
+#pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK-NEXT: static int variable = 100;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static float variable1 = 200;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static float variable2 = variable1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK: #pragma omp declare target
+// CHECK-NEXT: static int var = 1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int var1 = 10;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int *var2 = &var1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int **ptr1 = &var2;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int arr[2] = {1, 2};
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int (*arrptr)[2] = &arr;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: class declare {
+// CHECK-NEXT: public: 
+// CHECK-NEXT:  int x;
+// CHECK-NEXT:  void print();
+// CHECK-NEXT: };
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare obj1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare *obj2 = &obj1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: struct target {
+// CHECK-NEXT:  int x;
+// CHECK-NEXT:  void print();
+// CHECK-NEXT: };
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static target S;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int target_var = variable;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: float target_var1 = variable2;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int *ptr = &var;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int ***ptr2 = &ptr1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int (**ptr3)[2] = &arrptr;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare **obj3 = &obj2; 
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: target *S1 = &S;
+// CHECK-NEXT: #pragma omp end declare target
Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -233,6 +233,42 @@
 #pragma omp declar

[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-05-09 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 520725.
chaitanyav added a comment.

Rebase with upstream and remove duplicate line from ReleaseNotes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  libcxx/include/__chrono/duration.h
  libcxx/include/strstream
  libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
  libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
  libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
  libcxxabi/src/cxa_personality.cpp

Index: libcxxabi/src/cxa_personality.cpp
===
--- libcxxabi/src/cxa_personality.cpp
+++ libcxxabi/src/cxa_personality.cpp
@@ -718,9 +718,7 @@
 if (actionEntry == 0)
 {
 // Found a cleanup
-results.reason = actions & _UA_SEARCH_PHASE
- ? _URC_CONTINUE_UNWIND
- : _URC_HANDLER_FOUND;
+results.reason = ((actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND);
 return;
 }
 // Convert 1-based byte offset into
@@ -832,9 +830,8 @@
 // End of action list. If this is phase 2 and we have found
 // a cleanup (ttypeIndex=0), return _URC_HANDLER_FOUND;
 // otherwise return _URC_CONTINUE_UNWIND.
-results.reason = hasCleanup && actions & _UA_CLEANUP_PHASE
- ? _URC_HANDLER_FOUND
- : _URC_CONTINUE_UNWIND;
+results.reason =
+(hasCleanup && (actions & _UA_CLEANUP_PHASE)) ? _URC_HANDLER_FOUND : _URC_CONTINUE_UNWIND;
 return;
 }
 // Go to next action
@@ -1243,10 +1240,9 @@
 {
 const __shim_type_info* excpType =
 static_cast(new_exception_header->exceptionType);
-adjustedPtr =
-__getExceptionClass(&new_exception_header->unwindHeader) == kOurDependentExceptionClass ?
-((__cxa_dependent_exception*)new_exception_header)->primaryException :
-new_exception_header + 1;
+adjustedPtr = (__getExceptionClass(&new_exception_header->unwindHeader) == kOurDependentExceptionClass)
+  ? ((__cxa_dependent_exception*)new_exception_header)->primaryException
+  : new_exception_header + 1;
 if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
   excpType, adjustedPtr,
   unwind_exception, base))
Index: libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
===
--- libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
+++ libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
@@ -32,7 +32,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   std::less comp;
   std::__sort_dispatch(v.begin(), v.end(), comp);
@@ -44,7 +44,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   auto deterministic_v = deterministic();
   std::sort(v.begin(), v.end());
@@ -62,7 +62,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   auto snapshot_v = v;
   auto snapshot_custom_v = v;
Index: libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
===
--- libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
+++ libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
@@ -32,7 +32,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = (i % 2 ? 1 : kSize / 2 + i);
+v[i].value = ((i % 2) ? 1 : kSize / 2 + i);
   }
   auto comp = std::less();
   std::__partial_sort_impl(v.begin(), v.begin() + kSize / 2, v.end(), comp);
@@ -44,7 +44,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = (i % 2 ? 1 : kSize / 2 + i);
+v[i].value = ((i % 2) ? 1 : kSize / 2 + i)

[libclc] 21508fa - libclc: clspv: fix fma, add vstore and fix inlining issues

2023-05-09 Thread Kévin Petit via cfe-commits

Author: Kévin Petit
Date: 2023-05-09T16:52:13+01:00
New Revision: 21508fa76914a5e4281dc5bc77cac7f2e8bc3aef

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

LOG: libclc: clspv: fix fma, add vstore and fix inlining issues

https://reviews.llvm.org/D147773

Patch by Romaric Jodin 

Added: 
libclc/clspv/lib/shared/vstore_half.cl
libclc/clspv/lib/shared/vstore_half.inc

Modified: 
libclc/CMakeLists.txt
libclc/clspv/lib/SOURCES
libclc/clspv/lib/math/fma.cl
libclc/generic/include/clc/clcfunc.h

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 89f08b889ea1e..0eda12670b710 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -271,11 +271,11 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
set( spvflags --spirv-max-version=1.1 )
elseif( ${ARCH} STREQUAL "clspv" )
set( t "spir--" )
-   set( build_flags )
+   set( build_flags "-Wno-unknown-assumption")
set( opt_flags -O3 )
elseif( ${ARCH} STREQUAL "clspv64" )
set( t "spir64--" )
-   set( build_flags )
+   set( build_flags "-Wno-unknown-assumption")
set( opt_flags -O3 )
else()
set( build_flags )

diff  --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES
index 98bc71a869b2a..7c369aa379e98 100644
--- a/libclc/clspv/lib/SOURCES
+++ b/libclc/clspv/lib/SOURCES
@@ -1,5 +1,6 @@
 math/fma.cl
 math/nextafter.cl
+shared/vstore_half.cl
 subnormal_config.cl
 ../../generic/lib/geometric/distance.cl
 ../../generic/lib/geometric/length.cl
@@ -45,6 +46,12 @@ subnormal_config.cl
 ../../generic/lib/math/frexp.cl
 ../../generic/lib/math/half_cos.cl
 ../../generic/lib/math/half_divide.cl
+../../generic/lib/math/half_exp.cl
+../../generic/lib/math/half_exp10.cl
+../../generic/lib/math/half_exp2.cl
+../../generic/lib/math/half_log.cl
+../../generic/lib/math/half_log10.cl
+../../generic/lib/math/half_log2.cl
 ../../generic/lib/math/half_powr.cl
 ../../generic/lib/math/half_recip.cl
 ../../generic/lib/math/half_sin.cl

diff  --git a/libclc/clspv/lib/math/fma.cl b/libclc/clspv/lib/math/fma.cl
index fdc8b8b296876..4f2806933eda9 100644
--- a/libclc/clspv/lib/math/fma.cl
+++ b/libclc/clspv/lib/math/fma.cl
@@ -34,6 +34,92 @@ struct fp {
   uint sign;
 };
 
+static uint2 u2_set(uint hi, uint lo) {
+  uint2 res;
+  res.lo = lo;
+  res.hi = hi;
+  return res;
+}
+
+static uint2 u2_set_u(uint val) { return u2_set(0, val); }
+
+static uint2 u2_mul(uint a, uint b) {
+  uint2 res;
+  res.hi = mul_hi(a, b);
+  res.lo = a * b;
+  return res;
+}
+
+static uint2 u2_sll(uint2 val, uint shift) {
+  if (shift == 0)
+return val;
+  if (shift < 32) {
+val.hi <<= shift;
+val.hi |= val.lo >> (32 - shift);
+val.lo <<= shift;
+  } else {
+val.hi = val.lo << (shift - 32);
+val.lo = 0;
+  }
+  return val;
+}
+
+static uint2 u2_srl(uint2 val, uint shift) {
+  if (shift == 0)
+return val;
+  if (shift < 32) {
+val.lo >>= shift;
+val.lo |= val.hi << (32 - shift);
+val.hi >>= shift;
+  } else {
+val.lo = val.hi >> (shift - 32);
+val.hi = 0;
+  }
+  return val;
+}
+
+static uint2 u2_or(uint2 a, uint b) {
+  a.lo |= b;
+  return a;
+}
+
+static uint2 u2_and(uint2 a, uint2 b) {
+  a.lo &= b.lo;
+  a.hi &= b.hi;
+  return a;
+}
+
+static uint2 u2_add(uint2 a, uint2 b) {
+  uint carry = (hadd(a.lo, b.lo) >> 31) & 0x1;
+  a.lo += b.lo;
+  a.hi += b.hi + carry;
+  return a;
+}
+
+static uint2 u2_add_u(uint2 a, uint b) { return u2_add(a, u2_set_u(b)); }
+
+static uint2 u2_inv(uint2 a) {
+  a.lo = ~a.lo;
+  a.hi = ~a.hi;
+  return u2_add_u(a, 1);
+}
+
+static uint u2_clz(uint2 a) {
+  uint leading_zeroes = clz(a.hi);
+  if (leading_zeroes == 32) {
+leading_zeroes += clz(a.lo);
+  }
+  return leading_zeroes;
+}
+
+static bool u2_eq(uint2 a, uint2 b) { return a.lo == b.lo && a.hi == b.hi; }
+
+static bool u2_zero(uint2 a) { return u2_eq(a, u2_set_u(0)); }
+
+static bool u2_gt(uint2 a, uint2 b) {
+  return a.hi > b.hi || (a.hi == b.hi && a.lo > b.lo);
+}
+
 _CLC_DEF _CLC_OVERLOAD float fma(float a, float b, float c) {
   /* special cases */
   if (isnan(a) || isnan(b) || isnan(c) || isinf(a) || isinf(b)) {
@@ -63,12 +149,9 @@ _CLC_DEF _CLC_OVERLOAD float fma(float a, float b, float c) 
{
   st_b.exponent = b == .0f ? 0 : ((as_uint(b) & 0x7f80) >> 23) - 127;
   st_c.exponent = c == .0f ? 0 : ((as_uint(c) & 0x7f80) >> 23) - 127;
 
-  st_a.mantissa.lo = a == .0f ? 0 : (as_uint(a) & 0x7f) | 0x80;
-  st_b.mantissa.lo = b == .0f ? 0 : (as_uint(b) & 0x7f) | 0x80;
-  st_c.mantissa.lo = c == .0f ? 0 : (as_uint(c

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-09 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 520716.
bolshakov-a added a comment.

Rebased.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7305,6 +7305,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -849,6 +849,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1049,13 +1049,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   ca

[PATCH] D149110: [HIP] Detect HIP for Ubuntu, Mint, Gentoo, etc.

2023-05-09 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8598357662d: [HIP] Detect HIP for Ubuntu, Mint, Gentoo, 
etc. (authored by cgmb, committed by yaxunl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149110

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp


Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -11,7 +11,6 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
@@ -309,13 +308,10 @@
 ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
 /*StrictChecking=*/true);
 
-  Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
-  if (Dist.IsDebian() || Dist.IsRedhat()) {
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
-/*StrictChecking=*/true);
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
-/*StrictChecking=*/true);
-  }
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
+  /*StrictChecking=*/true);
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
+  /*StrictChecking=*/true);
 
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;


Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -11,7 +11,6 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
@@ -309,13 +308,10 @@
 ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
 /*StrictChecking=*/true);
 
-  Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
-  if (Dist.IsDebian() || Dist.IsRedhat()) {
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
-/*StrictChecking=*/true);
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
-/*StrictChecking=*/true);
-  }
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
+  /*StrictChecking=*/true);
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
+  /*StrictChecking=*/true);
 
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f859835 - [HIP] Detect HIP for Ubuntu, Mint, Gentoo, etc.

2023-05-09 Thread Yaxun Liu via cfe-commits

Author: Cordell Bloor
Date: 2023-05-09T11:31:57-04:00
New Revision: f8598357662dc8dd0f4400bcaeb48e8befe43ecc

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

LOG: [HIP] Detect HIP for Ubuntu, Mint, Gentoo, etc.

HIP may be installed into /usr or /usr/local on a variety of Linux
operating systems. It may become unwieldy to list them all.

Reviewed by: Siu Chi Chan, Yaxun Liu

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index acedcfabefe1..1eb22ed8704c 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -11,7 +11,6 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
@@ -309,13 +308,10 @@ RocmInstallationDetector::getInstallationPathCandidates() 
{
 ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
 /*StrictChecking=*/true);
 
-  Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
-  if (Dist.IsDebian() || Dist.IsRedhat()) {
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
-/*StrictChecking=*/true);
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
-/*StrictChecking=*/true);
-  }
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
+  /*StrictChecking=*/true);
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
+  /*StrictChecking=*/true);
 
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;



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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-09 Thread Philip Reames via Phabricator via cfe-commits
reames accepted this revision.
reames added a comment.
This revision is now accepted and ready to land.

LGTM, thought please wait for other review feedback to settle.

I am very very happy to have this upstream, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

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


[PATCH] D149162: [Clang][OpenMP][IRBuilder] Move registerTargetGlobalVariable & getAddrOfDeclareTargetVar into the OMPIRBuilder

2023-05-09 Thread Jan Sjödin via Phabricator via cfe-commits
jsjodin added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:865
+  TargetRegionEntryInfo EntryInfo, StringRef MangledName,
+  Module *LlvmModule, std::vector &GeneratedRefs,
+  bool OpenMPSIMD, std::vector TargetTriple,

Instead of passing in the Module, we should be able to use M in the 
OpenMPIRBuilder.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:5225
+std::function VariableLinkage,
+llvm::Type *LlvmPtrTy, llvm::Constant *Addr) {
+  if (DeviceClause != OffloadEntriesInfoManager::OMPTargetDeviceClauseAny ||

no llvm::prefix (look for more occurrences)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149162

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


[PATCH] D150043: [InferAddressSpaces] Handle vector of pointers type & Support intrinsic masked gather/scatter

2023-05-09 Thread CaprYang via Phabricator via cfe-commits
CaprYang added inline comments.



Comment at: llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll:3
+
+; CHECK-LABEL: @masked_gather_inferas(
+; CHECK: tail call <4 x i32> @llvm.masked.gather.v4i32.v4p1

arsenm wrote:
> Generate full checks 
updated


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

https://reviews.llvm.org/D150043

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


[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-09 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 520693.
Manna marked an inline comment as done.

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

https://reviews.llvm.org/D150140

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -299,6 +299,7 @@
 if (It != FlagTypes.end()) {
   uint64_t Mask = It->getValue();
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Mask != 0 && "Invalid mask value");
   return (V << Shift) & Mask;
 }
 llvm_unreachable("Unsupported flag");


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -299,6 +299,7 @@
 if (It != FlagTypes.end()) {
   uint64_t Mask = It->getValue();
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Mask != 0 && "Invalid mask value");
   return (V << Shift) & Mask;
 }
 llvm_unreachable("Unsupported flag");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150043: [InferAddressSpaces] Handle vector of pointers type & Support intrinsic masked gather/scatter

2023-05-09 Thread CaprYang via Phabricator via cfe-commits
CaprYang updated this revision to Diff 520692.

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

https://reviews.llvm.org/D150043

Files:
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/icmp.ll
  llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll
  llvm/test/Transforms/InferAddressSpaces/vector-of-pointers.ll

Index: llvm/test/Transforms/InferAddressSpaces/vector-of-pointers.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/vector-of-pointers.ll
@@ -0,0 +1,104 @@
+; RUN: opt -S -passes=infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck %s
+
+; CHECK-LABEL: @double_ascast(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[INPUT:%.*]])
+; CHECK-NEXT: ret void
+define void @double_ascast(<4 x ptr addrspace(3)> %input) {
+entry:
+  %tmp0 = addrspacecast <4 x ptr addrspace(3)> %input to <4 x ptr>
+  %tmp1 = addrspacecast <4 x ptr> %tmp0 to <4 x ptr addrspace(3)>
+  call void @use(<4 x ptr addrspace(3)> %tmp1)
+  ret void
+}
+
+; CHECK-LABEL: @double_gep(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr float, ptr addrspace(3) [[INPUT:%.*]], <4 x i64> [[I:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = getelementptr float, <4 x ptr addrspace(3)> [[TMP1]], i64 [[J:%.*]]
+; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[TMP2]])
+; CHECK-NEXT: ret void
+define void @double_gep(ptr addrspace(3) %input, <4 x i64> %i, i64 %j) {
+entry:
+  %tmp0 = addrspacecast ptr addrspace(3) %input to ptr
+  %tmp1 = getelementptr float, ptr %tmp0, <4 x i64> %i
+  %tmp2 = getelementptr float, <4 x ptr> %tmp1, i64 %j
+  %tmp3 = addrspacecast <4 x ptr> %tmp2 to <4 x ptr addrspace(3)>
+  call void @use(<4 x ptr addrspace(3)> %tmp3)
+  ret void
+}
+
+; CHECK-LABEL: @inferas_phi(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label %inc, label %end
+; CHECK: inc:
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr float, <4 x ptr addrspace(3)> [[INPUT:%.*]], i64 1
+; CHECK-NEXT: br label %end
+; CHECK: end:
+; CHECK-NEXT: [[TMP2:%.*]] = phi <4 x ptr addrspace(3)> [ [[INPUT]], %entry ], [ [[TMP1]], %inc ]
+; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[TMP2]])
+; CHECK-NEXT: ret void
+define void @inferas_phi(<4 x ptr addrspace(3)> %input, i1 %cond) {
+entry:
+  %tmp0 = addrspacecast <4 x ptr addrspace(3)> %input to <4 x ptr>
+  br i1 %cond, label %inc, label %end
+
+inc:
+  %tmp1 = getelementptr float, <4 x ptr> %tmp0, i64 1
+  br label %end
+
+end:
+  %tmp2 = phi <4 x ptr> [ %tmp0, %entry ], [ %tmp1, %inc ]
+  %tmp3 = addrspacecast <4 x ptr> %tmp2 to <4 x ptr addrspace(3)>
+  call void @use(<4 x ptr addrspace(3)> %tmp3)
+  ret void
+}
+
+; CHECK-LABEL: @inferas_ptr2int2ptr(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[INPUT:%.*]])
+; CHECK-NEXT: ret void
+define void @inferas_ptr2int2ptr(<4 x ptr addrspace(3)> %input) {
+entry:
+  %tmp0 = addrspacecast <4 x ptr addrspace(3)> %input to <4 x ptr>
+  %tmp1 = ptrtoint <4 x ptr> %tmp0 to <4 x i64>
+  %tmp2 = inttoptr <4 x i64> %tmp1 to <4 x ptr>
+  %tmp3 = addrspacecast <4 x ptr> %tmp2 to <4 x ptr addrspace(3)>
+  call void @use(<4 x ptr addrspace(3)> %tmp3)
+  ret void
+}
+
+; CHECK-LABEL: @inferas_loop(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label %loop
+; CHECK: loop:
+; CHECK-NEXT: [[NOW:%.*]] = phi <4 x ptr addrspace(3)> [ [[BEGIN:%.*]], %entry ], [ [[NEXT:%.*]], %loop ]
+; CHECK-NEXT: call void @use(<4 x ptr addrspace(3)> [[NOW]])
+; CHECK-NEXT: [[NEXT]] = getelementptr float, <4 x ptr addrspace(3)> [[NOW]], i64 1
+; CHECK-NEXT: [[VEQ:%.*]] = icmp eq <4 x ptr addrspace(3)> [[NEXT]], [[END:%.*]]
+; CHECK-NEXT: [[MASK:%.*]] = bitcast <4 x i1> [[VEQ]] to i4
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i4 [[MASK]], 0
+; CHECK-NEXT: br i1 [[COND]], label %loop, label %exit
+; CHECK: exit:
+; CHECK-NEXT: ret void
+define void @inferas_loop(<4 x ptr addrspace(3)> %begin, <4 x ptr addrspace(3)> %end) {
+entry:
+  %begin0 = addrspacecast <4 x ptr addrspace(3)> %begin to <4 x ptr>
+  %end0 = addrspacecast <4 x ptr addrspace(3)> %end to <4 x ptr>
+  br label %loop
+
+loop:
+  %now = phi <4 x ptr> [ %begin0, %entry ], [ %next, %loop ]
+  %now3 = addrspacecast <4 x ptr> %now to <4 x ptr addrspace(3)>
+  call void @use(<4 x ptr addrspace(3)> %now3)
+  %next = getelementptr float, <4 x ptr> %now, i64 1
+  %veq = icmp eq <4 x ptr> %next, %end0
+  %mask = bitcast <4 x i1> %veq to i4
+  %cond = icmp eq i4 %mask, 0
+  br i1 %cond, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+declare void @use(<4 x ptr addrspace(3)>)
\ No newline at end of file
Index: llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll
@@ -0,0 +1,31 @@
+; RUN: opt -S -passes=infer-address-spaces -assume-default-is-flat-ad

[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-09 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked 4 inline comments as done.
Manna added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:302
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Shift >= 64 && "Shift is out of encodable range");
   return (V << Shift) & Mask;

sdesmalen wrote:
> erichkeane wrote:
> > sdesmalen wrote:
> > > erichkeane wrote:
> > > > Shouldn't this be: `assert(Shift < 64 &&"...")`?
> > > > 
> > > > `expr.shift` (https://eel.is/c++draft/expr.shift) says:
> > > > ```
> > > > The operands shall be of integral or unscoped enumeration type and 
> > > > integral promotions are performed.
> > > > The type of the result is that of the promoted left operand.
> > > > The behavior is undefined if the right operand is negative, or greater 
> > > > than or equal to the width of the promoted left operand.```
> > > > 
> > > > uint64 stays as an `unsigned long`, so it is still 64 bits, so the only 
> > > > invalid value for `Shift` is 64 (though >64 is 'nonsense', but only 
> > > > impossible because of `llvm::countr_zero`).
> > > > 
> > > > One thing to consider: I wonder if we should instead be changing the 
> > > > 'shift' to be:
> > > > 
> > > > `(V << (Shift % 64)) && Mask` ?  It looks like `arm_sve.td` has the 
> > > > `NoFlags` value as zero, which I think will end up going through here 
> > > > possibly (or at least, inserted into `FlagTypes`.
> > > > 
> > > > So I suspect an assert might not be sufficient, since a 64 bit shift is 
> > > > possible in that case (since a zero 'Mask' is the only case where 
> > > > `countr_zero` will end up being 64).
> > > > 
> > > > 
> > > > So I suspect an assert might not be sufficient, since a 64 bit shift is 
> > > > possible in that case (since a zero 'Mask' is the only case where 
> > > > countr_zero will end up being 64).
> > > It should be fine to assert that `Mask != 0`, since that would be an 
> > > invalid mask.
> > Thanks for the comment @sdesmalen!  Is there something that prevents the 
> > `NoFlags` from being passed as the `MaskName` here?  
> There's nothing that actively prevents it, but `encodeFlag` is a utility 
> function that has no uses outside this file and has only 4 uses. Adding an 
> assert should be sufficient.
Thank you for the explanation!


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

https://reviews.llvm.org/D150140

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


[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-09 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 520681.
Manna edited the summary of this revision.
Manna added a comment.

Thank you for reviews and comments @erichkeane and @sdesmalen!  I have updated 
patch.


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

https://reviews.llvm.org/D150140

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -299,6 +299,7 @@
 if (It != FlagTypes.end()) {
   uint64_t Mask = It->getValue();
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Mask != 0 && "Mask is out of encodable range");
   return (V << Shift) & Mask;
 }
 llvm_unreachable("Unsupported flag");


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -299,6 +299,7 @@
 if (It != FlagTypes.end()) {
   uint64_t Mask = It->getValue();
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Mask != 0 && "Mask is out of encodable range");
   return (V << Shift) & Mask;
 }
 llvm_unreachable("Unsupported flag");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149119: [CMake] Use LLVM own tools in extract_symbols.py

2023-05-09 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

One potential area of concern here: If `llvm-driver` is ever extended to work 
as a plugin loader (thus exporting its symbols), removing support for the 
pre-installed host tools could cause a cyclic dependency.


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

https://reviews.llvm.org/D149119

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


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-05-09 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 520678.
bolshakov-a added a comment.

Fix MS compatibility mangling algorithm. Tested with MSVC ver. 19.35 (toolset 
ver. 143).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Index/USR/structural-value-tpl-arg.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7305,6 +7305,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::StructuralValue:
+return eTemplateArgumentKindStructuralValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -849,6 +849,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindStructuralValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. declared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::StructuralValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::StructuralValue:
+if (Expr *E = TAL.getSourceStructuralValueExpression())
+  return Vis

  1   2   >