[PATCH] D129348: [clang-format] Fix an assertion failure on -lines=0:n

2022-07-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also fixed the error message for start line > end line and added test cases.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129348

Files:
  clang/test/Format/line-ranges.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -246,8 +246,12 @@
 errs() << "error: invalid : pair\n";
 return true;
   }
+  if (FromLine < 1) {
+errs() << "error: start line should be at least 1\n";
+return true;
+  }
   if (FromLine > ToLine) {
-errs() << "error: start line should be less than end line\n";
+errs() << "error: start line should not exceed end line\n";
 return true;
   }
   SourceLocation Start = Sources.translateLineCol(ID, FromLine, 1);
Index: clang/test/Format/line-ranges.cpp
===
--- clang/test/Format/line-ranges.cpp
+++ clang/test/Format/line-ranges.cpp
@@ -9,3 +9,11 @@
 
 // CHECK: {{^int\ \*i;$}}
 int   *   i;
+
+// RUN: not clang-format -lines=0:1 < %s 2>&1 \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK0 %s
+// CHECK0: error: start line should be at least 1
+
+// RUN: not clang-format -lines=2:1 < %s 2>&1 \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// CHECK1: error: start line should not exceed end line


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -246,8 +246,12 @@
 errs() << "error: invalid : pair\n";
 return true;
   }
+  if (FromLine < 1) {
+errs() << "error: start line should be at least 1\n";
+return true;
+  }
   if (FromLine > ToLine) {
-errs() << "error: start line should be less than end line\n";
+errs() << "error: start line should not exceed end line\n";
 return true;
   }
   SourceLocation Start = Sources.translateLineCol(ID, FromLine, 1);
Index: clang/test/Format/line-ranges.cpp
===
--- clang/test/Format/line-ranges.cpp
+++ clang/test/Format/line-ranges.cpp
@@ -9,3 +9,11 @@
 
 // CHECK: {{^int\ \*i;$}}
 int   *   i;
+
+// RUN: not clang-format -lines=0:1 < %s 2>&1 \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK0 %s
+// CHECK0: error: start line should be at least 1
+
+// RUN: not clang-format -lines=2:1 < %s 2>&1 \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// CHECK1: error: start line should not exceed end line
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129348: [clang-format] Fix an assertion failure on -lines=0:n

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

👍


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129348

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


[PATCH] D129100: [clangd] Support external throttler for preamble builds

2022-07-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:499
 // Build the preamble and let the waiters know about it.
 build(std::move(*CurrentReq));
   }

regarding the flakiness, what about resetting the `Throttle` here to trigger 
the release? it's right after the build and would make sure release happens 
before the context is destroyed (+ we're not holding any locks)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129100

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


[PATCH] D128328: [C++20][Modules] Improve handing of Private Module Fragment diagnostics.

2022-07-08 Thread Iain Sandoe via Phabricator via cfe-commits
iains added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11155
+def err_export_inline_not_defined : Error<
+  "exported inline functions must be defined within the module purview"
+  " and before any private module fragment">;

ChuanqiXu wrote:
> iains wrote:
> > iains wrote:
> > > ChuanqiXu wrote:
> > > > iains wrote:
> > > > > iains wrote:
> > > > > > ChuanqiXu wrote:
> > > > > > > From my reading, 'exported' is not emphasized.
> > > > > > it is here:
> > > > > > https://eel.is/c++draft/module#private.frag-2.1
> > > > > > ( I agree it is somewhat confusing, but the export makes the 
> > > > > > linkage external, which the example treats differently from the 
> > > > > > fn_m() case which has module linkage).
> > > > > > 
> > > > > > It is possible that we might need to pull together several pieces 
> > > > > > of the std and maybe ask core for clarification?
> > > > > > it is here:
> > > > > > https://eel.is/c++draft/module#private.frag-2.1
> > > > > > ( I agree it is somewhat confusing, but the export makes the 
> > > > > > linkage external, which the example treats differently from the 
> > > > > > fn_m() case which has module linkage).
> > > > > 
> > > > > hmm... my linkage comment is wrong - however the distinction between 
> > > > > exported and odr-used seems to be made here (fn_m() and fn_e()).
> > > > > > 
> > > > > > It is possible that we might need to pull together several pieces 
> > > > > > of the std and maybe ask core for clarification?
> > > > > 
> > > > > 
> > > > What I read is:
> > > > > [dcl.inline]p7: https://eel.is/c++draft/dcl.inline#7
> > > > > If an inline function or variable that is attached to a named 
> > > > > module is declared in a definition domain, it shall be defined in 
> > > > > that domain.
> > > > 
> > > > and the definition of `definition domain` is:
> > > > > [basic.def.odr]p12: https://eel.is/c++draft/basic#def.odr-12
> > > > >   A definition domain is a private-module-fragment or the portion 
> > > > > of a translation unit excluding its private-module-fragment (if any).
> > > > 
> > > > The definition of "attached to a named module" is:
> > > > > [module.unit]p7: https://eel.is/c++draft/module.unit#7
> > > > >  A module is either a named module or the global module. A 
> > > > > declaration is attached to a module as follows: ...
> > > > 
> > > > So it is clearly not consistency with [module.private.frag]p2.1. I 
> > > > would send this to WG21.
> > > Yes, that was what I found - maybe we are  missing something about the 
> > > export that changes those rules.
> > > .
> > I think that we can consider this closed by the question to the ext 
> > reflector and the amendment proposed by core.
> I prefer `inline function attached to a named module not defined %select{| 
> before the private module fragment}1`. Since the `export` part is not 
> important here and the important part is whether or not they are attached to 
> a named module.
I took the error message from here:
https://github.com/cplusplus/draft/pull/5537
which was prepared after the dicussion that you started on the ext reflector.  
Actually, I do not have a strong feeling either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128328

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


[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-07-08 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D126694#3637690 , @ChuanqiXu wrote:

> In D126694#3635207 , @iains wrote:
>
>> @rsmith, @ChuanqiXu apologies for the multiple revisions, this has turned 
>> out to be much more involved than I imagined from the standard's text.
>>
>> In D126694#3629254 , @ChuanqiXu 
>> wrote:
>>
>>> In D126694#3629251 , @iains wrote:
>>>
 In D126694#3629094 , @ChuanqiXu 
 wrote:

> BTW, after I applied the patch, the compiler crashes at 
> https://github.com/ChuanqiXu9/stdmodules.

 That link points to a project - is there (say) a gist of the crash 
 information?
>>>
>>> Here is the crash log:
>>
>> this code now compiles without error,
>
> Thanks for looking into it!
>
> My personal plan for this revision is to review the details after we add more 
> large tests (at least we have a more complete std modules implementation and 
> I am trying for it. But I find another bug now). So we might need to wait for 
> a while for this patch. How do you think about it?

Well, the difficulty there is that "add more large tests" is not a very 
specific objective.
I will be first to say that we can tell that the implementation here is 
necessary, but we cannot tell if it is sufficient - however, IMO we need to 
find a more definite way to make progress.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

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


[PATCH] D128328: [C++20][Modules] Improve handing of Private Module Fragment diagnostics.

2022-07-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11155
+def err_export_inline_not_defined : Error<
+  "exported inline functions must be defined within the module purview"
+  " and before any private module fragment">;

iains wrote:
> ChuanqiXu wrote:
> > iains wrote:
> > > iains wrote:
> > > > ChuanqiXu wrote:
> > > > > iains wrote:
> > > > > > iains wrote:
> > > > > > > ChuanqiXu wrote:
> > > > > > > > From my reading, 'exported' is not emphasized.
> > > > > > > it is here:
> > > > > > > https://eel.is/c++draft/module#private.frag-2.1
> > > > > > > ( I agree it is somewhat confusing, but the export makes the 
> > > > > > > linkage external, which the example treats differently from the 
> > > > > > > fn_m() case which has module linkage).
> > > > > > > 
> > > > > > > It is possible that we might need to pull together several pieces 
> > > > > > > of the std and maybe ask core for clarification?
> > > > > > > it is here:
> > > > > > > https://eel.is/c++draft/module#private.frag-2.1
> > > > > > > ( I agree it is somewhat confusing, but the export makes the 
> > > > > > > linkage external, which the example treats differently from the 
> > > > > > > fn_m() case which has module linkage).
> > > > > > 
> > > > > > hmm... my linkage comment is wrong - however the distinction 
> > > > > > between exported and odr-used seems to be made here (fn_m() and 
> > > > > > fn_e()).
> > > > > > > 
> > > > > > > It is possible that we might need to pull together several pieces 
> > > > > > > of the std and maybe ask core for clarification?
> > > > > > 
> > > > > > 
> > > > > What I read is:
> > > > > > [dcl.inline]p7: https://eel.is/c++draft/dcl.inline#7
> > > > > > If an inline function or variable that is attached to a named 
> > > > > > module is declared in a definition domain, it shall be defined in 
> > > > > > that domain.
> > > > > 
> > > > > and the definition of `definition domain` is:
> > > > > > [basic.def.odr]p12: https://eel.is/c++draft/basic#def.odr-12
> > > > > >   A definition domain is a private-module-fragment or the 
> > > > > > portion of a translation unit excluding its private-module-fragment 
> > > > > > (if any).
> > > > > 
> > > > > The definition of "attached to a named module" is:
> > > > > > [module.unit]p7: https://eel.is/c++draft/module.unit#7
> > > > > >  A module is either a named module or the global module. A 
> > > > > > declaration is attached to a module as follows: ...
> > > > > 
> > > > > So it is clearly not consistency with [module.private.frag]p2.1. I 
> > > > > would send this to WG21.
> > > > Yes, that was what I found - maybe we are  missing something about the 
> > > > export that changes those rules.
> > > > .
> > > I think that we can consider this closed by the question to the ext 
> > > reflector and the amendment proposed by core.
> > I prefer `inline function attached to a named module not defined %select{| 
> > before the private module fragment}1`. Since the `export` part is not 
> > important here and the important part is whether or not they are attached 
> > to a named module.
> I took the error message from here:
> https://github.com/cplusplus/draft/pull/5537
> which was prepared after the dicussion that you started on the ext reflector. 
>  Actually, I do not have a strong feeling either way.
Oh, I didn't track that. I feel my suggested version is slightly better. 
Otherwise users might want to make it work by adding/removing `export` clause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128328

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


[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-07-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D126694#3638069 , @iains wrote:

> In D126694#3637690 , @ChuanqiXu 
> wrote:
>
>> In D126694#3635207 , @iains wrote:
>>
>>> @rsmith, @ChuanqiXu apologies for the multiple revisions, this has turned 
>>> out to be much more involved than I imagined from the standard's text.
>>>
>>> In D126694#3629254 , @ChuanqiXu 
>>> wrote:
>>>
 In D126694#3629251 , @iains 
 wrote:

> In D126694#3629094 , @ChuanqiXu 
> wrote:
>
>> BTW, after I applied the patch, the compiler crashes at 
>> https://github.com/ChuanqiXu9/stdmodules.
>
> That link points to a project - is there (say) a gist of the crash 
> information?

 Here is the crash log:
>>>
>>> this code now compiles without error,
>>
>> Thanks for looking into it!
>>
>> My personal plan for this revision is to review the details after we add 
>> more large tests (at least we have a more complete std modules 
>> implementation and I am trying for it. But I find another bug now). So we 
>> might need to wait for a while for this patch. How do you think about it?
>
> Well, the difficulty there is that "add more large tests" is not a very 
> specific objective.
> I will be first to say that we can tell that the implementation here is 
> necessary, but we cannot tell if it is sufficient - however, IMO we need to 
> find a more definite way to make progress.

Yeah, clearness matters. Let me try to state my idea clearly:
(1) Make std modules sufficient to be able to cover at least , 
, , ,  and . So that we could run 
the tests from cppreference at least.
(2) Make https://github.com/alibaba/async_simple/tree/CXX20Modules compilable 
by clang trunk and std modules

Then we could use (1) or (2) to check some relatively large patches (including 
this one but not limited). In this way, I  feel like we have more confident to 
say the C++20 Modules in Clang is workable. (Tests is never enough. I know). I 
would like to see how far I can go in the next month. So I would like to give a 
more specific answer what test ((1) or (2) or others) we need to use. I think 
one month might not be super long time in this area. How do you think about it?

---

BTW, I've sent two patches to enhance the usability: D128974 
 and D129068 
. And I am fighting with the other problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

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


[PATCH] D128977: [clangd] Support "usedAsMutableReference" in member initializations

2022-07-08 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128977

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


[PATCH] D129353: [clang-tidy] Improve check cert-dcl58-cpp.

2022-07-08 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: carlosgalvezp, steakhal, martong, gamesh411, 
Szelethus, dkrupp, xazax.hun.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Detect template specializations that should be handled specially.
In some cases it is allowed to extend the `std` namespace with
template specializations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129353

Files:
  clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-simulation.h
  clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cert-dcl58-cpp %t -- -- -std=c++1z -I %clang_tidy_headers
+// RUN: %check_clang_tidy -std=c++17-or-later %s cert-dcl58-cpp %t -- -- -I %clang_tidy_headers
 
 #include "system-header-simulation.h"
 
@@ -15,14 +15,20 @@
 }
 
 namespace posix {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'posix' namespace can result in undefined behavior [cert-dcl58-cpp]
-  namespace vmi {
-  }
+// CHECK-MESSAGES: :[[@LINE+2]]:11: warning: modification of 'posix' namespace can result in undefined behavior [cert-dcl58-cpp]
+// CHECK-MESSAGES: :[[@LINE-2]]:11: note: 'posix' namespace opened here
+namespace foo {
+int foobar;
+}
 }
 
 namespace std {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'std' namespace can
-  int stdInt;
+// CHECK-MESSAGES: :[[@LINE+2]]:5: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-2]]:11: note: 'std' namespace opened here
+int stdInt;
+// CHECK-MESSAGES: :[[@LINE+2]]:5: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-5]]:11: note: 'std' namespace opened here
+int stdInt1;
 }
 
 namespace foobar {
@@ -31,37 +37,231 @@
   }
 }
 
+namespace posix {
+// CHECK-MESSAGES: :[[@LINE+2]]:11: warning: modification of 'posix' namespace
+// CHECK-MESSAGES: :[[@LINE-2]]:11: note: 'posix' namespace opened here
+namespace std {
+}
+} // namespace posix
+
 namespace posix::a {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'posix' namespace 
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: modification of 'posix' namespace
+// CHECK-MESSAGES: :[[@LINE-2]]:11: note: 'posix' namespace opened here
 }
 
+namespace std {
+// no-warning: empty
+} // namespace std
+
+namespace std {
+// Warn for non-NamedDecls as well.
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-3]]:11: note: 'std' namespace opened here
+static_assert(1 == 1, "non-NamedDecl");
+} // namespace std
+
 enum class MyError {
   ErrorA,
   ErrorB
 };
 
 namespace std {
+// no-warning: Class template specialized by a program-defined type.
 template <>
 struct is_error_code_enum : std::true_type {};
 
+// no-warning: Function template specialized by a program-defined type.
 template<>
 void swap(MyError &a, MyError &b);
 }
 
-enum class MyError2 {
-  Error2A,
-  Error2B
-};
+using ConstBoolPtr = const bool *;
 
 namespace std {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'std' namespace 
+// class template, builtin type
+// CHECK-MESSAGES: :[[@LINE+3]]:8: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-3]]:11: note: 'std' namespace opened here
+template <>
+struct is_error_code_enum : std::true_type {};
+// function template, builtin type
+// CHECK-MESSAGES: :[[@LINE+3]]:6: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-8]]:11: note: 'std' namespace opened here
 template <>
-struct is_error_code_enum : std::true_type {};
+void swap(bool &, bool &);
+// CHECK-MESSAGES: :[[@LINE+3]]:6: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-12]]:11: note: 'std' namespace opened here
+template <>
+void swap(ConstBoolPtr &, ConstBoolPtr &);
+} // namespace std
 
-int foobar;
+namespace std {
+// class template, std type
+// CHECK-MESSAGES: :[[@LINE+3]]:8: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-3]]:11: note: 'std' namespace opened here
+template <>
+struct is_error_code_enum : std::true_type {};
+// function template, std type
+// CHECK-MESSAGES: :[[@LINE+3]]:6: warning: modification of 'std' namespace
+// CHECK-MESSAGES: :[[@LINE-8]]:11: note: 'std' namespace opened here
+template <>
+void swap(std::io_errc &, std::io_errc &);
+} // namespace std
+
+// parameter pack, has program-defined type
+namespace std {
+// no-warning: there is one program-defined type.
+templ

[PATCH] D128977: [clangd] Support "usedAsMutableReference" in member initializations

2022-07-08 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

Can you please merge it as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128977

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


[PATCH] D128977: [clangd] Support "usedAsMutableReference" in member initializations

2022-07-08 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Yes, I plan to. I'm just building it locally to verify the tests are passing. 
(And sometimes, for reasons I don't understand, LLVM's build system triggers a 
full rebuild even though I've only applied a patch that touches a couple of 
files...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128977

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


[PATCH] D128977: [clangd] Support "usedAsMutableReference" in member initializations

2022-07-08 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

In D128977#3638198 , @nridge wrote:

> Yes, I plan to. I'm just building it locally to verify the tests are passing. 
> (And sometimes, for reasons I don't understand, LLVM's build system triggers 
> a full rebuild even though I've only applied a patch that touches a couple of 
> files...)

I see, thanks.
Regarding the scope of rebuilds, it seems to me that the build system pulls in 
repository meta data, as there's lots of files rebuilt after simply amending a 
commit with no sources having changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128977

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


[PATCH] D128411: [syntax] Introduce a BaseToken class.

2022-07-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 443173.
hokein marked 9 inline comments as done.
hokein added a comment.
Herald added a subscriber: mgorny.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128411

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/SyntaxTokenManager.h
  clang/include/clang/Tooling/Syntax/TokenManager.h
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/ComputeReplacements.cpp
  clang/lib/Tooling/Syntax/SyntaxTokenManager.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/tools/clang-check/ClangCheck.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -17,6 +17,7 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/SyntaxTokenManager.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/StringRef.h"
@@ -51,6 +52,7 @@
   std::shared_ptr Invocation;
   // Set after calling buildTree().
   std::unique_ptr TB;
+  std::unique_ptr TM;
   std::unique_ptr Arena;
 };
 
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -22,6 +22,7 @@
 #include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/SyntaxTokenManager.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -35,13 +36,13 @@
 using namespace clang::syntax;
 
 namespace {
-ArrayRef tokens(syntax::Node *N) {
+ArrayRef tokens(syntax::Node *N, const SyntaxTokenManager &STM) {
   assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
   if (auto *L = dyn_cast(N))
-return llvm::makeArrayRef(L->getToken(), 1);
+return llvm::makeArrayRef(STM.getToken(L->getTokenKey()), 1);
   auto *T = cast(N);
-  return llvm::makeArrayRef(T->findFirstLeaf()->getToken(),
-T->findLastLeaf()->getToken() + 1);
+  return llvm::makeArrayRef(STM.getToken(T->findFirstLeaf()->getTokenKey()),
+STM.getToken(T->findLastLeaf()->getTokenKey()) + 1);
 }
 } // namespace
 
@@ -70,23 +71,26 @@
   public:
 BuildSyntaxTree(syntax::TranslationUnit *&Root,
 std::unique_ptr &TB,
+std::unique_ptr &TM,
 std::unique_ptr &Arena,
 std::unique_ptr Tokens)
-: Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
+: Root(Root), TB(TB), TM(TM), Arena(Arena), Tokens(std::move(Tokens)) {
   assert(this->Tokens);
 }
 
 void HandleTranslationUnit(ASTContext &Ctx) override {
   TB = std::make_unique(std::move(*Tokens).consume());
   Tokens = nullptr; // make sure we fail if this gets called twice.
-  Arena = std::make_unique(Ctx.getSourceManager(),
-  Ctx.getLangOpts(), *TB);
+  TM = std::make_unique(*TB, Ctx.getLangOpts(),
+Ctx.getSourceManager());
+  Arena = std::make_unique(*TM);
   Root = syntax::buildSyntaxTree(*Arena, Ctx);
 }
 
   private:
 syntax::TranslationUnit *&Root;
 std::unique_ptr &TB;
+std::unique_ptr &TM;
 std::unique_ptr &Arena;
 std::unique_ptr Tokens;
   };
@@ -94,21 +98,23 @@
   class BuildSyntaxTreeAction : public ASTFrontendAction {
   public:
 BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+  std::unique_ptr &TM,
   std::unique_ptr &TB,
   std::unique_ptr &Arena)
-: Root(Root), TB(TB), Arena(Arena) {}
+: Root(Root), TM(TM), TB(TB), Arena(Arena) {}
 
 std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override {
   // We start recording the tokens, ast consumer will take on the result.
   auto Tokens =
   std::make_unique(CI.getPreprocessor());
-  return std::make_unique(Root, TB, Arena,

[PATCH] D129280: [analyzer] PlacementNewChecker, properly handle array overhead (cookie)

2022-07-08 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 443174.
martong added a comment.

- Replace "might" with "unspecified value"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129280

Files:
  clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
  clang/test/Analysis/placement-new.cpp

Index: clang/test/Analysis/placement-new.cpp
===
--- clang/test/Analysis/placement-new.cpp
+++ clang/test/Analysis/placement-new.cpp
@@ -2,7 +2,14 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=cplusplus.NewDelete \
 // RUN:   -analyzer-checker=cplusplus.PlacementNew \
-// RUN:   -analyzer-output=text -verify \
+// RUN:   -analyzer-output=text -verify=expected,cpp11 \
+// RUN:   -triple x86_64-unknown-linux-gnu
+
+// RUN: %clang_analyze_cc1 -std=c++20 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=cplusplus.NewDelete \
+// RUN:   -analyzer-checker=cplusplus.PlacementNew \
+// RUN:   -analyzer-output=text -verify=expected \
 // RUN:   -triple x86_64-unknown-linux-gnu
 
 #include "Inputs/system-header-simulator-cxx.h"
@@ -157,27 +164,51 @@
 } // namespace testHierarchy
 
 namespace testArrayTypesAllocation {
-void f1() {
+void test_less() {
   struct S {
 short a;
   };
-
-  // bad (not enough space).
   const unsigned N = 32;
-  alignas(S) unsigned char buffer1[sizeof(S) * N]; // expected-note {{'buffer1' initialized here}}
-  ::new (buffer1) S[N];// expected-warning{{Storage provided to placement new is only 64 bytes, whereas the allocated array type requires more space for internal needs}} expected-note 1 {{}}
+  alignas(S) unsigned char buffer1[sizeof(S) * N/2]; // expected-note {{'buffer1' initialized here}}
+  ::new (buffer1) S[N];  // expected-warning{{Storage provided to placement new is only 32 bytes, whereas the allocated type requires 64 bytes}} expected-note 1 {{}}
 }
 
-void f2() {
+void test_equal() {
   struct S {
 short a;
   };
+  // Bad (not enough space).
+  // This should not appear if the standard is >= C++20.
+  // C++20 states that array overhead(cookie) is not created if the new
+  // expression calls the non-allocating (placement) form of the allocation
+  // function.
+  // C++20, section 7.6.2.7 [expr.new], paragraph 15:
+  //   That argument shall be no less than the size of the object being
+  //   created; it may be greater than the size of the object being created
+  //   only if the object is an array and the allocation function is not a
+  //   non-allocating form (17.6.2.3).
+  // C++20, section 7.6.2.7 [expr.new], paragraph 19:
+  //This overhead may be applied in all array new-expressions, including
+  //those referencing a placement allocation function, except when
+  //referencing the library function operator new[](std::size_t, void*).
+  // Related Defect Report:
+  // 2382. Array allocation overhead for non-allocating placement new
+  // https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2382
 
-  // maybe ok but we need to warn.
   const unsigned N = 32;
-  alignas(S) unsigned char buffer2[sizeof(S) * N + sizeof(int)]; // expected-note {{'buffer2' initialized here}}
-  ::new (buffer2) S[N];  // expected-warning{{68 bytes is possibly not enough for array allocation which requires 64 bytes. Current overhead requires the size of 4 bytes}} expected-note 1 {{}}
+  alignas(S) unsigned char buffer1[sizeof(S) * N]; // cpp11-note {{'buffer1' initialized here}}
+  ::new (buffer1) S[N];// cpp11-warning{{Storage provided to placement new is only 64 bytes, whereas the allocated array type requires a non-negative unspecified amount for array allocation overhead}} cpp11-note 1 {{}}
+}
+
+int test_greater() {
+  struct s {
+int x;
+  };
+  s arr[4];
+  new (arr + 1) s[1]; // no-warning
+  return 0;
 }
+
 } // namespace testArrayTypesAllocation
 
 namespace testStructAlign {
Index: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -111,32 +111,57 @@
   if (!SizeOfPlaceCI)
 return true;
 
-  if ((SizeOfPlaceCI->getValue() < SizeOfTargetCI->getValue()) ||
-  (IsArrayTypeAllocated &&
-   SizeOfPlaceCI->getValue() >= SizeOfTargetCI->getValue())) {
+  const llvm::APSInt &PlaceSize = SizeOfPlaceCI->getValue();
+  const llvm::APSInt &TargetSize = SizeOfTargetCI->getValue();
+
+  bool ArrayOverheadCondition =
+  // C++17 and earlier standards state that:
+  //   new(2, f) T[5] results in a call of operator new[](sizeof(T) * 5 +
+  //   y, 2, f). Here, ... and y are non-negative unspecified values
+  //   representing array allocation overhead; the resul

[PATCH] D129280: [analyzer] PlacementNewChecker, properly handle array overhead (cookie)

2022-07-08 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:157
 "Storage provided to placement new is only {0} bytes, "
-"whereas the allocated array type requires more space for "
-"internal needs",
-SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue()));
+"whereas the allocated array type might require more space for "
+"allocation overhead",

NoQ wrote:
> "might" is not very convincing, it may cause a reaction like "I've no idea 
> what it's talking about and the compiler itself isn't sure, must be false 
> positive". Can we do anything to point the user in the right direction? Say, 
> if this is implementation-defined, are we looking at a portability issue?
Okay, I see your point. Let's dissect the corresponding sections of the 
standard:
```
new(2, f) T[5] results in a call of operator new[](sizeof(T) * 5 + y, 2, f).

Here, ... and y are non-negative unspecified values representing array 
allocation overhead;
```
The array overhead is an **unspecified value**. What does it mean exactly? My 
understanding is that this means it is implementation defined and the 
implementation is not required to document or guarantee anything. I came to 
this conclusion based on this [[ 
https://stackoverflow.com/questions/2397984/undefined-unspecified-and-implementation-defined-behavior
 | stackoverflow question ]]. 

My interpretation could be wrong, but that does not matter. I think, we should 
just simply display the user what the standard says, and let them digest 
themselves the meaning of "unspecified". I am updating the patch like so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129280

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


[PATCH] D128411: [syntax] Introduce a BaseToken class.

2022-07-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/TokenManager.h:37
+
+  // FIXME: add an interface for getting token kind.
+};

sammccall wrote:
> I wouldn't want to prejudge this: this is a very basic attribute similar to 
> kind/role, and we may want to store it in Leaf and avoid the virtual stuff.
> 
> There's certainly enough space, e.g. of the current 16-bit `kind` use the top 
> bit to denote leaf-or-not and the bottom 15 bits to store kind-or-tokenkind.
This sounds good. Adjust the FIXME.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:463
+/// It tracks the underlying token buffers, source manager, etc.
+class SyntaxTokenManager : public TokenManager {
+public:

ilya-biryukov wrote:
> sammccall wrote:
> > conceptually this is just "TokenBuffer implements TokenManager"
> > 
> > The main reason I can see not to actually write that is to avoid the 
> > dependency from TokenBuffer (tokens library) to TokenManager (syntax 
> > library). But here you've added that dependency anyway.
> > 
> > So I think we'd be better either with `TokenBuffer : TokenManager` or 
> > moving this class to its own header.
> I would argue they should be separate concepts.
> - `TokenBuffer` is about storing tokens and mapping between expanded and 
> spelled token streams.
> - `SyntaxTokenManager` is about implementing relevant certain operations on 
> `syntax::Token` and hiding the actual token type.
> Conceptually those things are different and decoupling them allows for more 
> flexibility and allows reasoning about them independently. In particular, one 
> could imagine having a `SyntaxTokenManager` without a `TokenBuffer` if we do 
> not need to deal with two streams of tokens.
> 
> I would suggest keeping `SyntaxTokenManager` as a separate class.
> I would suggest keeping SyntaxTokenManager as a separate class.

+1. Moved to a separate file.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:465
+public:
+  SyntaxTokenManager(SourceManager &SourceMgr, const LangOptions &LangOpts,
+ const TokenBuffer &Tokens)

sammccall wrote:
> no need to take SourceManager, TokenBuffer already includes it.
> LangOpts is unused here.
> no need to take SourceManager, TokenBuffer already includes it.

The SourceMgr can be mutated by the class (it stores the underlying tokens for 
`ExtraTokens`), while the SourceManager in TokenBuffer is immutable.

> LangOpts is unused here.
It is used in SyntaxTokenManager::lexBuffer.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:475
+assert(Token);
+// Handle 'eof' separately, calling text() on it produces an empty string.
+if (Token->kind() == tok::eof)

sammccall wrote:
> Empty string seems like the correct return value here to me.
> If you want a special case for dump, I think that belongs in dump().
> 
> If this is because we currently provide no way to get the token kind, then 
> this should be a FIXME
Yeah, this special case is for the Leaf node dump. Added a FIXME. 

(I even double whether we need this special case at all, do we really want to 
build a Leaf node for eof token?)



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:504
+  /// IDs and storage for additional tokenized files.
+  llvm::DenseMap> ExtraTokens;
+};

sammccall wrote:
> aren't we trying to store these on the syntax arena?
> We never do lookups into this map, maybe lexbuffer just allocates storage on 
> the arena('s allocator) instead of using this map?
> aren't we trying to store these on the syntax arena?

We could do that, but I'd try to avoid that. Now the allocator of syntax::Arena 
is a storage for syntax-tree nodes only. Allocation for token-related stuff is 
on the `SyntaxTokenManager`.

> We never do lookups into this map, maybe lexbuffer just allocates storage on 
> the arena('s allocator) instead of using this map?

This map is moved from the syntax::Arena. 

You're right, there is no usage of the key at the moment, and the only use-case 
is to create a syntax leaf node that not backed by the source code (for 
refactoring usecase), it is unclear whether we will use it in the future. I 
will keep it as-is (this is not the scope of this patch).



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.cpp:116
 syntax::TranslationUnit *&Root;
+std::unique_ptr &TM;
 std::unique_ptr &TB;

ilya-biryukov wrote:
> NIT: it´s not breaking anything now, but I suggest putting SyntaxTokenManager 
> after TokenBuffer.
> The reason is that it´s the right destruction order, TokenManager has 
> references to TokenBuffer, so it could potentially access it in destructor 
> some time in the future (e.g. imagine asserting something on tokens).
> 
> Not that it actually breaks today, but seems like a potential surprising bug 
> in the fu

[PATCH] D129202: [clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS

2022-07-08 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 443180.
njames93 added a comment.

Attach fix directly to the warning.
Extend checking to also work with move assignments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129202

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/warn-self-assign-builtin.cpp
  clang/test/SemaCXX/warn-self-assign-field-builtin.cpp
  clang/test/SemaCXX/warn-self-move.cpp

Index: clang/test/SemaCXX/warn-self-move.cpp
===
--- clang/test/SemaCXX/warn-self-move.cpp
+++ clang/test/SemaCXX/warn-self-move.cpp
@@ -39,6 +39,9 @@
 other.x = std::move(x);
 other.x = std::move(other.x);  // expected-warning{{explicitly moving}}
   }
+  void withSuggest(int x) {
+x = std::move(x); // expected-warning{{explicitly moving variable of type 'int' to itself; did you mean to move to member 'x'?}}
+  }
 };
 
 struct A {};
Index: clang/test/SemaCXX/warn-self-assign-field-builtin.cpp
===
--- clang/test/SemaCXX/warn-self-assign-field-builtin.cpp
+++ clang/test/SemaCXX/warn-self-assign-field-builtin.cpp
@@ -4,6 +4,8 @@
   int a;
   int b;
 
+  C(int a, int b) : a(a), b(b) {}
+
   void f() {
 a = a; // expected-warning {{assigning field to itself}}
 b = b; // expected-warning {{assigning field to itself}}
Index: clang/test/SemaCXX/warn-self-assign-builtin.cpp
===
--- clang/test/SemaCXX/warn-self-assign-builtin.cpp
+++ clang/test/SemaCXX/warn-self-assign-builtin.cpp
@@ -65,3 +65,26 @@
   g();
   g();
 }
+
+struct Foo {
+  int A;
+
+  Foo(int A) : A(A) {}
+
+  void setA(int A) {
+A = A; // expected-warning{{explicitly assigning value of variable of type 'int' to itself; did you mean to assign to member 'A'?}}
+  }
+
+  void setThroughLambda() {
+[](int A) {
+  // To fix here we would need to insert an explicit capture 'this'
+  A = A; // expected-warning{{explicitly assigning}}
+}(5);
+
+[this](int A) {
+  this->A = 0;
+  // This fix would be possible by just adding this-> as above, but currently unsupported.
+  A = A; // expected-warning{{explicitly assigning}}
+}(5);
+  }
+};
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14600,6 +14600,40 @@
   return Opc;
 }
 
+FieldDecl *
+Sema::getSelfAssignmentClassMemberCandidate(const ValueDecl *SelfAssigned) {
+  // Explore the case for adding 'this->' to the LHS of a self assignment, very
+  // common for setters.
+  // struct A {
+  // int X;
+  // -void setX(int X) { X = X; }
+  // +void setX(int X) { this->X = X; }
+  // };
+
+  // Only consider parameters for self assignment fixes.
+  if (!isa(SelfAssigned))
+return nullptr;
+  const auto *Method =
+  dyn_cast_or_null(getCurFunctionDecl(true));
+  if (!Method)
+return nullptr;
+
+  const CXXRecordDecl *Parent = Method->getParent();
+  // In theory this is fixable if the lambda explicitly captures this, but
+  // that's added complexity that's rarely going to be used.
+  if (Parent->isLambda())
+return nullptr;
+
+  // FIXME: Use an actual Lookup operation instead of just traversing fields
+  // in order to get base class fields.
+  auto Field =
+  llvm::find_if(Parent->fields(),
+[Name(SelfAssigned->getDeclName())](const FieldDecl *F) {
+  return F->getDeclName() == Name;
+});
+  return (Field != Parent->field_end()) ? *Field : nullptr;
+}
+
 /// DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
 /// This warning suppressed in the event of macro expansions.
 static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr,
@@ -14630,10 +14664,16 @@
 if (RefTy->getPointeeType().isVolatileQualified())
   return;
 
-  S.Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
-  : diag::warn_self_assignment_overloaded)
-  << LHSDeclRef->getType() << LHSExpr->getSourceRange()
-  << RHSExpr->getSourceRange();
+  auto Diag = S.Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
+  : diag::warn_self_assignment_overloaded)
+  << LHSDeclRef->getType() << LHSExpr->getSourceRange()
+  << RHSExpr->getSourceRange();
+  if (FieldDecl *SelfAssignField =
+  S.getSelfAssignmentClassMemberCandidate(RHSDecl))
+Diag << 1 << SelfAssignField
+ << FixItHint::CreateInsertion(LHSDeclRef->getBeginLoc(), "this->");
+  else
+Diag << 0;
 }
 
 /// Check if a bitwise-& is performed on an Objective-C

[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-07-08 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 443185.
serge-sans-paille marked 4 inline comments as done.
serge-sans-paille added a comment.

Take reviews into account, basically spreading a lot of FIXME across the 
codebase :'(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/CodeGen/bounds-checking-fam.c
  clang/test/CodeGen/bounds-checking-fam.cpp
  clang/test/CodeGen/object-size-flex-array.c
  clang/test/CodeGenObjC/ubsan-array-bounds.m
  clang/test/Sema/array-bounds-ptr-arith.c
  clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
  clang/test/SemaCXX/array-bounds.cpp

Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -208,12 +208,15 @@
 
 namespace metaprogramming {
 #define ONE 1
-  struct foo { char c[ONE]; }; // expected-note {{declared here}}
+struct foo {
+  char c[ONE]; // expected-note {{array 'c' declared here}}
+};
+
   template  struct bar { char c[N]; }; // expected-note {{declared here}}
 
   char test(foo *F, bar<1> *B) {
 return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
-   B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+   B->c[3];  // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
   }
 }
 
Index: clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -verify -fstrict-flex-arrays=2 %s
+
+// We cannot know for sure the size of a flexible array.
+struct t {
+  int f;
+  int a[];
+};
+void test(t *s2) {
+  s2->a[2] = 0; // no-warning
+}
+
+// Under -fstrict-flex-arrays `a` is not a flexible array.
+struct t1 {
+  int f;
+  int a[1]; // expected-note {{array 'a' declared here}}
+};
+void test1(t1 *s2) {
+  s2->a[2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+}
+
+// Under -fstrict-flex-arrays `a` is a flexible array.
+struct t2 {
+  int f;
+  int a[0];
+};
+void test1(t2 *s2) {
+  s2->a[2] = 0; // no-warning
+}
Index: clang/test/Sema/array-bounds-ptr-arith.c
===
--- clang/test/Sema/array-bounds-ptr-arith.c
+++ clang/test/Sema/array-bounds-ptr-arith.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify=expected -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify=expected -Warray-bounds-pointer-arithmetic %s -fstrict-flex-arrays=0
+// RUN: %clang_cc1 -verify=expected,strict -Warray-bounds-pointer-arithmetic %s -fstrict-flex-arrays=2
 
 // Test case from PR10615
 struct ext2_super_block{
@@ -14,7 +16,9 @@
 }
 
 // Test case reduced from PR11594
-struct S { int n; };
+struct S {
+  int n;
+};
 void pr11594(struct S *s) {
   int a[10];
   int *p = a - s->n;
@@ -26,26 +30,28 @@
 struct RDar11387038 {};
 typedef struct RDar11387038 RDar11387038Array[1];
 struct RDar11387038_Table {
-  RDar11387038Array z;
+  RDar11387038Array z; // strict-note {{array 'z' declared here}}
 };
-typedef struct RDar11387038_Table * TPtr;
+typedef struct RDar11387038_Table *TPtr;
 typedef TPtr *TabHandle;
-struct RDar11387038_B { TabHandle x; };
+struct RDar11387038_B {
+  TabHandle x;
+};
 typedef struct RDar11387038_B RDar11387038_B;
 
 void radar11387038(void) {
   RDar11387038_B *pRDar11387038_B;
-  struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4];
+  struct RDar11387038 *y = &(*pRDar11387038_B->x)->z[4]; // strict-warning {{array index 4 is past the end of the array (which contains 1 element)}}
 }
 
-void pr51682 (void) {
-  int arr [1];
+void pr51682(void) {
+  int arr[1];
   switch (0) {
-case 0:
-  break;
-case 1:
-  asm goto (""::"r"(arr[42] >> 1)::failed); // no-warning
-  break;
+  case 0:
+break;
+  case 1:
+asm goto("" ::"r"(arr[42] >> 1)::failed);
+break;
   }
 failed:;
 }
Index: clang/test/CodeGenObjC/ubsan-array-bounds.m
===
--- clang/test/CodeGenObjC/ubsan-array-bounds.m
+++ clang/test/CodeGenObjC/ubsan-array-bounds.m
@@ -14,46 +14,3 @@
   return FA1->chars[1];
   // CHECK: }
 }
-
-@interface FlexibleArr

[PATCH] D129100: [clangd] Support external throttler for preamble builds

2022-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:499
 // Build the preamble and let the waiters know about it.
 build(std::move(*CurrentReq));
   }

kadircet wrote:
> regarding the flakiness, what about resetting the `Throttle` here to trigger 
> the release? it's right after the build and would make sure release happens 
> before the context is destroyed (+ we're not holding any locks)
The critical case never gets here: done() is called while waiting for the 
throttler, and we never get to build anything.

(And by the time that wait is interrupted, the context is already concurrently 
being destroyed.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129100

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


[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-08 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5400-5401
+SourceLocation KWLoc) {
+  if (!S.getLangOpts().CPlusPlus11)
+return;
+

aaron.ballman wrote:
> erichkeane wrote:
> > royjacobson wrote:
> > > erichkeane wrote:
> > > > royjacobson wrote:
> > > > > aaron.ballman wrote:
> > > > > > I think we should always warn on these, not just in C++11.
> > > > > I'm not convinced we should. My reasoning is that we need a pretty 
> > > > > good reason to start issuing warnings for 20 years old code. The 
> > > > > usage of those builtins with deleted functions after C++11 is pretty 
> > > > > broken which is a pretty good reason, but for earlier language 
> > > > > versions they work 'fine' and if people want to use C++03 I prefer 
> > > > > leaving them at peace :)
> > > > > 
> > > > > People on C++03 are also probably using pretty old versions of 
> > > > > libstdc++ and/or boost type_traits, so this could have some impact.
> > > > > 
> > > > > WDYT?
> > > > > 
> > > > warnings don't get emitted for code in header files, so at least that 
> > > > part isn't a concern.  
> > > Any header files, or just system headers?
> > Sorry, yes, Phab is a mess on a cell phone... in things included as System 
> > Headers.
> Agreed with Erich -- warnings in system headers (but not regular headers) are 
> silenced by default, you need to pass `-Wsystem-headers` to enable them.
To clarify my position, I think about those builtins as an unofficial part of 
the C++03 standard and I think we should support them as long as we support 
C++03.

Do you think that's reasonable?

I agree we should update the documentation in this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

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


[PATCH] D129359: [pseudo] Generate an enum type for identifying grammar rules.

2022-07-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

The Rule enum type enables us to identify a grammar rule within C++'s
type system.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129359

Files:
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -114,6 +114,21 @@
   EXPECT_NE(G.lookupRule(ruleFor("x")).Guard, G.lookupRule(ruleFor("y")).Guard);
 }
 
+TEST_F(GrammarTest, MangleName) {
+  build(R"bnf(
+_ := declaration
+
+declaration := ptr-declarator ;
+ptr-declarator := * IDENTIFIER
+
+  )bnf");
+  ASSERT_TRUE(Diags.empty());
+  EXPECT_EQ(G.mangleRule(ruleFor("declaration")),
+"declaration_0ptr_declarator_1semi");
+  EXPECT_EQ(G.mangleRule(ruleFor("ptr-declarator")),
+"ptr_declarator_0star_1identifier");
+}
+
 TEST_F(GrammarTest, Diagnostics) {
   build(R"cpp(
 _ := ,_opt
Index: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -45,6 +45,28 @@
   return T->Nonterminals[SID].Name;
 }
 
+std::string Grammar::mangleSymbol(SymbolID SID) const {
+  static const char *const TokNames[] = {
+#define TOK(X) #X,
+#define KEYWORD(X, Y) #X,
+#include "clang/Basic/TokenKinds.def"
+  nullptr};
+  if (clang::pseudo::isToken(SID))
+return TokNames[clang::pseudo::symbolToToken(SID)];
+  std::string Name = symbolName(SID).str();
+  // translation-unit -> translation_unit
+  std::replace(Name.begin(), Name.end(), '-', '_');
+  return Name;
+}
+
+std::string Grammar::mangleRule(RuleID RID) const {
+  const auto &R = lookupRule(RID);
+  std::string MangleName = mangleSymbol(R.Target);
+  for (size_t I = 0; I < R.seq().size(); ++I)
+MangleName += llvm::formatv("_{0}{1}", I, mangleSymbol(R.seq()[I]));
+  return MangleName;
+}
+
 llvm::Optional Grammar::findNonterminal(llvm::StringRef Name) const {
   auto It = llvm::partition_point(
   T->Nonterminals,
Index: clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
===
--- clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
+++ clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
@@ -165,6 +165,17 @@
   // Terminals have names like "," (kw_comma) or "OPERATOR" (kw_operator).
   llvm::StringRef symbolName(SymbolID) const;
 
+  // Gets the mangled name for a terminal/nonterminal.
+  // Compared to names in the grammar,
+  //   nonterminals `ptr-declartor` becomes `ptr_declarator`;
+  //   terminal `,` becomes `comma`;
+  //   terminal `INT` becomes `int`;
+  std::string mangleSymbol(SymbolID) const;
+  // Gets the mangled name for the rule.
+  // E.g. for the grammar rule `ptr-declarator := ptr-operator ptr-declarator`,
+  // it is `ptr_declarator_0ptr_operator_1ptr_declarator`.
+  std::string mangleRule(RuleID) const;
+
   // Lookup the SymbolID of the nonterminal symbol by Name.
   llvm::Optional findNonterminal(llvm::StringRef Name) const;
 
Index: clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
===
--- clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
+++ clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
@@ -37,6 +37,12 @@
 #undef NONTERMINAL
 };
 
+enum class Rule : RuleID {
+#define RULE(X, Y) X = Y,
+#include "CXXSymbols.inc"
+#undef RULE
+};
+
 enum class Extension : ExtensionID {
 #define EXTENSION(X, Y) X = Y,
 #include "CXXSymbols.inc"
Index: clang-tools-extra/pseudo/gen/Main.cpp
===
--- clang-tools-extra/pseudo/gen/Main.cpp
+++ clang-tools-extra/pseudo/gen/Main.cpp
@@ -83,17 +83,19 @@
 #ifndef NONTERMINAL
 #define NONTERMINAL(X, Y)
 #endif
+#ifndef RULE
+#define RULE(X, Y)
+#endif
 #ifndef EXTENSION
 #define EXTENSION(X, Y)
 #endif
-)cpp";
+)cpp";
 for (clang::pseudo::SymbolID ID = 0; ID < G.table().Nonterminals.size();
- ++ID) {
-  std::string Name = G.symbolName(ID).str();
-  // translation-unit -> translation_unit
-  std::replace(Name.begin(), Name.end(), '-', '_');
-  Out.os() << llvm::formatv("NONTERMINAL({0}, {1})\n", Name, ID);
-}
+ ++ID)
+  Out.os() << llvm::formatv("NONTERMINAL({0}, {1})\n", G.mangleSymbol(ID),
+

[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/pseudo/gen/Main.cpp:114
+  const clang::pseudo::Rule &R = G.table().Rules[RID];
+  // lhs$$rhs$rhs$rhs
+  std::string EnumName = symbolName(R.Target, G) + "$";

sammccall wrote:
> hokein wrote:
> > sammccall wrote:
> > > so the dollar signs are a practical problem: at least on my machine the 
> > > warning is on by default, so we emit thousands of warnings and it's 
> > > impossible to find the error among them.
> > > 
> > > At *minimum* we need to use pragmas or something to suppress the warning.
> > > 
> > > But using nonstandard C++ seems likely to cause other problems and limit 
> > > portability for not-great reasons.
> > > 
> > > Some ideas:
> > >  -`Rule::ptr_declarator__EQUALS__ptr_operator__ptr_declarator` (this 
> > > violates the internal `__` rule, though that one is widely ignored)
> > >  - `Rule::ptr_declarator_0ptr_operator_1ptr_declarator`
> > >  - `Rule::PtrDeclarator_EQ_PtrOperator_PtrDeclarator` (yet another 
> > > spelling variation, but quite readable. We could even change the 
> > > spellings in the BNF file...)
> > > so the dollar signs are a practical problem: at least on my machine the 
> > > warning is on by default, so we emit thousands of warnings and it's 
> > > impossible to find the error among them.
> > 
> > I didn't see this warning on my machine, I'm using the `g++`.
> > 
> > 
> > > Rule::ptr_declarator__EQUALS__ptr_operator__ptr_declarator (this violates 
> > > the internal __ rule, though that one is widely ignored)
> > 
> > It is not quite readable to me. 
> > 
> > > Rule::PtrDeclarator_EQ_PtrOperator_PtrDeclarator (yet another spelling 
> > > variation, but quite readable. We could even change the spellings in the 
> > > BNF file...)
> > 
> > It is better, but I'm not willing to change the spelling to CamelCase in 
> > bnf grammar, I like the current `ptr-declarator` name, and it matches the 
> > standard style. We could keep them unchanged in the bnf, and do the 
> > conversion during the mangling.
> > 
> > > Rule::ptr_declarator_0ptr_operator_1ptr_declarator
> > 
> > I'm starting to like it now. I find that encoding the index for RHS is 
> > useful, especially when we  do some work on the ForestNode based on the 
> > rules. So I will vote this one.
> > 
> > I didn't see this warning on my machine, I'm using the g++.
> 
> Clang seems to enable -Wdollar-in-identifier-extension by default.
> 
> > It is better, but I'm not willing to change the spelling to CamelCase in 
> > bnf grammar
> 
> Fair enough. I find this option the most readable, but the lack of 
> consistency is annoying.
> 
> > I'm starting to like it now. I find that encoding the index for RHS is 
> > useful, especially when we do some work on the ForestNode based on the 
> > rules. So I will vote this one.
> 
> Ok, i find this least readable, but good in all other respects. Let's go for 
> it.
Sounds good, separated it in https://reviews.llvm.org/D129359.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D129174: [C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]

2022-07-08 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 443194.
iains retitled this revision from "[C++20][Modules] Invalidate internal-linkage 
functions in overload sets [P1815R2 part 1]" to "[C++20][Modules] Update ADL to 
handle basic.lookup.argdep p4 [P1815R2 part 1]".
iains edited the summary of this revision.
iains added a comment.

updated after clarification of the provisions of basic.lookup.argdep p4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129174

Files:
  clang/include/clang/Sema/Overload.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/basic/basic.link/p10-ex2.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp

Index: clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp
===
--- /dev/null
+++ clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp
@@ -0,0 +1,68 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm
+// RUN: %clang_cc1 -std=c++20 N.cpp -emit-module-interface -o N.pcm \
+// RUN:   -fmodule-file=M.pcm
+// RUN: %clang_cc1 -std=c++20 Q.cpp -emit-module-interface -o Q.pcm
+// RUN: %clang_cc1 -std=c++20 Q-impl.cpp -fsyntax-only -fmodule-file=Q.pcm \
+// RUN:   -fmodule-file=N.pcm -verify
+
+//--- M.cpp
+export module M;
+namespace R {
+export struct X {};
+export void f(X);
+} // namespace R
+namespace S {
+export void f(R::X, R::X);
+}
+
+//--- N.cpp
+export module N;
+import M;
+export R::X make();
+namespace R {
+static int g(X);
+}
+export template 
+void apply(T t, U u) {
+  f(t, u);
+  g(t);
+}
+
+//--- Q.cpp
+export module Q;
+
+//--- Q-impl.cpp
+module Q;
+import N;
+
+namespace S {
+struct Z {
+  template  operator T();
+};
+} // namespace S
+void test() {
+  // OK, decltype(x) is R::X in module M
+  auto x = make();
+
+  // error: R and R::f are not visible here
+  R::f(x); // expected-error {{declaration of 'R' must be imported from module 'N' before it is required}}
+  // expected-n...@n.cpp:4 {{declaration here is not visible}}
+  // expected-error@-2 {{no type named 'f' in namespace 'R'}}
+
+  f(x); // Found by [basic.lookup.argdep] / p4.3
+
+  // error: S::f in module M not considered even though S is an associated
+  // namespace, since the entity Z is in a different module from f.
+  f(x, S::Z()); // expected-error {{no matching function for call to 'f'}}
+  // expected-n...@m.cpp:4 {{candidate function not viable: requires 1 argument, but 2 were provided}}
+
+  // error: S::f is visible in instantiation context, but  R::g has internal
+  // linkage and cannot be used outside N.cpp
+  apply(x, S::Z()); // expected-er...@n.cpp:10 {{no matching function for call to 'g'}}
+// expected-note@-1 {{in instantiation of function template specialization 'apply' requested here}}
+}
Index: clang/test/CXX/basic/basic.link/p10-ex2.cpp
===
--- /dev/null
+++ clang/test/CXX/basic/basic.link/p10-ex2.cpp
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 M.cpp -fsyntax-only -DTEST_INTERFACE -verify
+// RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm
+// RUN: %clang_cc1 -std=c++20 useM.cpp -fsyntax-only -fmodule-file=M.pcm -verify
+
+//--- decls.h
+int f(); // #1, attached to the global module
+int g(); // #2, attached to the global module
+
+//--- M.cpp
+module;
+#include "decls.h"
+export module M;
+export using ::f; // OK, does not declare an entity, exports #1
+#if TEST_INTERFACE
+// error: matches #2, but attached to M
+int g(); // expected-error {{declaration of 'g' in module M follows declaration in the global module}}
+// expected-note@decls.h:2 {{previous declaration is here}}
+#endif
+export int h(); // #3
+export int k(); // #4
+
+//--- useM.cpp
+import M;
+// error: matches #3
+static int h(); // expected-error {{static declaration of 'h' follows non-static declaration}}
+// expected-n...@m.cpp:10 {{previous declaration is here}}
+
+// error: matches #4
+int k(); // expected-error {{declaration of 'k' in the global module follows declaration in module M}}
+// expected-n...@m.cpp:11 {{previous declaration is here}}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -6400,6 +6400,17 @@
 return;
   }
 
+  // Functions with internal linkage are only viable in the same module unit.
+  if (auto *MF = Function->getOwningModule()) {
+if (Function->getFormalLinkage() <= Linkage::InternalLinkage &&
+getLangOpts().CPlusPlusModules &&
+MF->getTopLevelModule() != getCurrentModule()->getTopLevelModule()) {
+  Candidate.Viable = false;
+  Ca

[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Pinging about updates to this, because if this really does fix 
https://github.com/llvm/llvm-project/issues/55560, I think we want to get that 
fix into Clang 15. The release branch point is coming up pretty soon 
(https://discourse.llvm.org/t/llvm-15-0-0-release-schedule/63495/10).


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

https://reviews.llvm.org/D128119

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


[PATCH] D128697: [clang-tidy] Add new check `bugprone-unhandled-exception-at-sto`

2022-07-08 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

In D128697#3615404 , @Eugene.Zelenko 
wrote:

> I think will be good idea to make check more generic and allow user-defined 
> list of unsafe functions.

I understand that user-defined is implemented through the config, but some 
types of information of user customization cannot be well described here. Maybe 
use function name and argument counts only to match unsafe functions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128697

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


[PATCH] D128697: [clang-tidy] Add new check `bugprone-unhandled-exception-at-sto`

2022-07-08 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

In D128697#3619310 , 
@LegalizeAdulthood wrote:

> This whole check seems weird to me.  I mean, almost every use of a standard 
> container could throw `std::bad_alloc` but we don't insist on a local `catch` 
> for `bad_alloc` at every possible throwing call site.
>
> Why would we assume that every call site of `stoi` or `stod` **must** have an 
> exception handler immediately around it?  It's perfectly acceptable for an 
> application to handle this at an outer scope that can't be detected by 
> clang-tidy.

Makes sense, I implemented this check here because some projects in ByteDance 
used stoi with missing exception handlers caused an online crash, I think this 
is a relatively common problem.  Perhaps only report diagnostics for stoi calls 
in nothrow functions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128697

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


[PATCH] D127293: [clang-tidy] Ignore other members in a union if any member of it is initialized in cppcoreguidelines-pro-type-member-init

2022-07-08 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Friendly ping.


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

https://reviews.llvm.org/D127293

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


[PATCH] D129362: Undeprecate ATOMIC_FLAG_INIT in C++

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: clang-language-wg, erichkeane, cor3ntin, tambre, 
ldionne.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

C++20 deprecated ATOMIC_FLAG_INIT thinking it was deprecated in C when it 
wasn't. It is expected to be undeprecated in C++23 as part of LWG3659 
(https://wg21.link/LWG3659), which is currently Tentatively Ready as of 
yesterday.

I think similar changes should happen on the libc++ side, basically to undo 
parts of 4e730aeb731cb9b7116ed51bbef662d363f72b66 
, so I've 
included some of the libc++ folks here to see if they agree.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129362

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/stdatomic.h
  clang/test/Headers/stdatomic-deprecations.c


Index: clang/test/Headers/stdatomic-deprecations.c
===
--- clang/test/Headers/stdatomic-deprecations.c
+++ clang/test/Headers/stdatomic-deprecations.c
@@ -12,7 +12,6 @@
 void func(void) {
   _Atomic int i = ATOMIC_VAR_INIT(12); // expected-warning {{macro 
'ATOMIC_VAR_INIT' has been marked as deprecated}} \
// expected-note@stdatomic.h:* {{macro 
marked 'deprecated' here}}
-  #if defined(ATOMIC_FLAG_INIT) // cxx-warning {{macro 'ATOMIC_FLAG_INIT' has 
been marked as deprecated}} \
-// cxx-note@stdatomic.h:* {{macro marked 
'deprecated' here}}
+  #if defined(ATOMIC_FLAG_INIT) // Ok, deprecated in C++20, undeprecated in 
C++23 via LWG4659.
   #endif
 }
Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -158,10 +158,6 @@
 typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
 
 #define ATOMIC_FLAG_INIT { 0 }
-#if __cplusplus >= 202002L && !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
-/* ATOMIC_FLAG_INIT was deprecated in C++20 but is not deprecated in C. */
-#pragma clang deprecated(ATOMIC_FLAG_INIT)
-#endif
 
 /* These should be provided by the libc implementation. */
 #ifdef __cplusplus
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -476,6 +476,7 @@
 - Implemented `P2128R6: Multidimensional subscript operator 
`_.
 - Implemented `P0849R8: auto(x): decay-copy in the language 
`_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in 
constexpr functions`_.
+- Implemented `LWG3659: Consider ATOMIC_FLAG_INIT undeprecation 
`_.
 
 CUDA/HIP Language Changes in Clang
 --


Index: clang/test/Headers/stdatomic-deprecations.c
===
--- clang/test/Headers/stdatomic-deprecations.c
+++ clang/test/Headers/stdatomic-deprecations.c
@@ -12,7 +12,6 @@
 void func(void) {
   _Atomic int i = ATOMIC_VAR_INIT(12); // expected-warning {{macro 'ATOMIC_VAR_INIT' has been marked as deprecated}} \
// expected-note@stdatomic.h:* {{macro marked 'deprecated' here}}
-  #if defined(ATOMIC_FLAG_INIT) // cxx-warning {{macro 'ATOMIC_FLAG_INIT' has been marked as deprecated}} \
-// cxx-note@stdatomic.h:* {{macro marked 'deprecated' here}}
+  #if defined(ATOMIC_FLAG_INIT) // Ok, deprecated in C++20, undeprecated in C++23 via LWG4659.
   #endif
 }
Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -158,10 +158,6 @@
 typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
 
 #define ATOMIC_FLAG_INIT { 0 }
-#if __cplusplus >= 202002L && !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
-/* ATOMIC_FLAG_INIT was deprecated in C++20 but is not deprecated in C. */
-#pragma clang deprecated(ATOMIC_FLAG_INIT)
-#endif
 
 /* These should be provided by the libc implementation. */
 #ifdef __cplusplus
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -476,6 +476,7 @@
 - Implemented `P2128R6: Multidimensional subscript operator `_.
 - Implemented `P0849R8: auto(x): decay-copy in the language `_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in constexpr functions	`_.
+- Implemented `LWG3659: Consider ATOMIC_FLAG_INIT undeprecation `_.
 
 CUDA/HIP Language Changes in Clang
 -

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

2022-07-08 Thread Ting Wang via Phabricator via cfe-commits
tingwang updated this revision to Diff 443201.
tingwang added a comment.

Add guards against TLS variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125095

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/PowerPC/aix-init-ref-null.cpp
  clang/test/CodeGen/PowerPC/aix-ref-static-var.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7091,6 +7091,10 @@
 @b = internal global i32 2, comdat $a, section "abc", !associated !0
 !0 = !{i32* @a}
 
+On XCOFF target, the ``associated`` metadata indicates connection among static
+variables (static global variable, static class member etc.) and static init/
+term functions. This metadata lowers to ``.ref`` assembler pseudo-operation
+which prevents discarding of the functions in linker GC.
 
 '``prof``' Metadata
 ^^^
Index: clang/test/CodeGenCXX/aix-static-init.cpp
===
--- clang/test/CodeGenCXX/aix-static-init.cpp
+++ clang/test/CodeGenCXX/aix-static-init.cpp
@@ -38,6 +38,10 @@
   }
 } // namespace test4
 
+// CHECK: @_ZN5test12t1E = global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
+// CHECK: @_ZN5test12t2E = global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
+// CHECK: @_ZN5test21xE = global i32 0, align {{[0-9]+}}, !associated ![[ASSOC1:[0-9]+]]
+// CHECK: @_ZN5test31tE = global %"struct.test3::Test3" undef, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
 // CHECK: @_ZGVZN5test41fEvE11staticLocal = internal global i64 0, align 8
 // CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }]
 // CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }]
@@ -49,7 +53,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZN5test12t1E() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZN5test12t1E() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t1E)
 // CHECK:   ret void
@@ -80,7 +84,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
 // CHECK:   ret void
@@ -114,7 +118,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZN5test31tE() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZN5test31tE() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test35Test3D1Ev(%"struct.test3::Test3"* @_ZN5test31tE)
 // CHECK:   ret void
@@ -155,7 +159,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZZN5test41fEvE11staticLocal() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZZN5test41fEvE11staticLocal() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test45Test4D1Ev(%"struct.test4::Test4"* @_ZZN5test41fEvE11staticLocal)
 // CHECK:   ret void
@@ -192,3 +196,7 @@
 // CHECK:   call void @__finalize__ZN5test12t1E()
 // CHECK:   ret void
 // CHECK: }
+
+// CHECK: ![[ASSOC0]] = !{void ()* @{{_GLOBAL__sub_I__|_GLOBAL__D_a}}, void ()* @{{_GLOBAL__sub_I__|_GLOBAL__D_a}}}
+// CHECK: ![[ASSOC1]] = !{void ()* @_GLOBAL__sub_I__}
+// CHECK: ![[ASSOC2]] = !{void ()* @_GLOBAL__D_a}
Index: clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
===
--- clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
+++ clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
@@ -44,8 +44,13 @@
 A A::instance = bar();
 } // namespace test2
 
+// CHECK: @_ZN5test12t0E = global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
+// CHECK: @_ZN5test12t2E = linkonce_odr global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC1:[0-9]+]]
 // CHECK: @_ZGVN5test12t2E = linkonce_odr global i64 0, align 8
+// CHECK: @_ZN5test12t1IiEE = linkonce_odr global %"struct.test1::Test1" zero

[PATCH] D129362: Undeprecate ATOMIC_FLAG_INIT in C++

2022-07-08 Thread Raul Tambre via Phabricator via cfe-commits
tambre accepted this revision.
tambre added a comment.
This revision is now accepted and ready to land.

Makes sense to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129362

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


[clang] 35f4857 - Fix the Clang sphinx bot

2022-07-08 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-08T07:23:40-04:00
New Revision: 35f48572e3c752cea281ba62292f682bfd98ff18

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

LOG: Fix the Clang sphinx bot

This should resolve the issues with:
https://lab.llvm.org/buildbot/#/builders/92/builds/29439

Added: 


Modified: 
clang/docs/DebuggingCoroutines.rst

Removed: 




diff  --git a/clang/docs/DebuggingCoroutines.rst 
b/clang/docs/DebuggingCoroutines.rst
index 1d07542872cbd..e6942a4be6dbf 100644
--- a/clang/docs/DebuggingCoroutines.rst
+++ b/clang/docs/DebuggingCoroutines.rst
@@ -139,7 +139,7 @@ print the coroutine frame by:
 Just as printing the `promise_type` is possible from the coroutine address,
 printing the details of the coroutine frame from an address is also possible:
 
-.. parsed-literal::
+::
 
   (gdb) # Get the address of coroutine frame
   (gdb) print/x *0x418eb0



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


[clang] fee77a2 - Disable clang-format entirely for test directories

2022-07-08 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-08T07:34:18-04:00
New Revision: fee77a20732cb629629c52123643fa5928ebfc1c

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

LOG: Disable clang-format entirely for test directories

See discussion here:

https://github.com/llvm/llvm-project/issues/55982

And the RFC here:
https://discourse.llvm.org/t/rfc-disable-clang-format-in-the-clang-test-tree/63498/2

We don't generally expect test files to be formatted according to the
style guide. Indeed, some tests may require specific formatting for the
purposes of the test.

When tests intentionally do not conform to the "correct" formatting,
this causes errors in the CI, which can drown out real errors and causes
people to stop trusting the CI over time.

>From the history of the clang/test/.clang-format file, it looks as if
there have been attempts to make clang-format do a subset of formatting
that would be useful for tests. However, it looks as if it's hard to
make clang-format do exactly the right thing -- see the back-and-forth
between
13316a7
and
7b5bddf.

These changes disable the .clang-format file for clang/test, llvm/test,
and clang-tools-extra/test.

Fixes #55982
Differential Revision: https://reviews.llvm.org/D128706

Added: 


Modified: 
clang-tools-extra/test/.clang-format
clang/test/.clang-format
llvm/test/.clang-format

Removed: 




diff  --git a/clang-tools-extra/test/.clang-format 
b/clang-tools-extra/test/.clang-format
index 4799b66f3e9a6..e3845288a2aec 100644
--- a/clang-tools-extra/test/.clang-format
+++ b/clang-tools-extra/test/.clang-format
@@ -1,2 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
+DisableFormat: true

diff  --git a/clang/test/.clang-format b/clang/test/.clang-format
index f7fb083d1055d..e3845288a2aec 100644
--- a/clang/test/.clang-format
+++ b/clang/test/.clang-format
@@ -1,3 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
-AlwaysBreakTemplateDeclarations: No
+DisableFormat: true

diff  --git a/llvm/test/.clang-format b/llvm/test/.clang-format
index 4799b66f3e9a6..e3845288a2aec 100644
--- a/llvm/test/.clang-format
+++ b/llvm/test/.clang-format
@@ -1,2 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
+DisableFormat: true



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


[PATCH] D128706: [Clang] Disable clang-format entirely for clang/test tree.

2022-07-08 Thread Aaron Ballman 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 rGfee77a20732c: Disable clang-format entirely for test 
directories (authored by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128706

Files:
  clang-tools-extra/test/.clang-format
  clang/test/.clang-format
  llvm/test/.clang-format


Index: llvm/test/.clang-format
===
--- llvm/test/.clang-format
+++ llvm/test/.clang-format
@@ -1,2 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
+DisableFormat: true
Index: clang/test/.clang-format
===
--- clang/test/.clang-format
+++ clang/test/.clang-format
@@ -1,3 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
-AlwaysBreakTemplateDeclarations: No
+DisableFormat: true
Index: clang-tools-extra/test/.clang-format
===
--- clang-tools-extra/test/.clang-format
+++ clang-tools-extra/test/.clang-format
@@ -1,2 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
+DisableFormat: true


Index: llvm/test/.clang-format
===
--- llvm/test/.clang-format
+++ llvm/test/.clang-format
@@ -1,2 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
+DisableFormat: true
Index: clang/test/.clang-format
===
--- clang/test/.clang-format
+++ clang/test/.clang-format
@@ -1,3 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
-AlwaysBreakTemplateDeclarations: No
+DisableFormat: true
Index: clang-tools-extra/test/.clang-format
===
--- clang-tools-extra/test/.clang-format
+++ clang-tools-extra/test/.clang-format
@@ -1,2 +1 @@
-BasedOnStyle: LLVM
-ColumnLimit: 0
+DisableFormat: true
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129202: [clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with some minor stuff you can fix when landing. Thank you for this!




Comment at: clang/include/clang/Sema/Sema.h:5170-5171
 
+  FieldDecl *
+  getSelfAssignmentClassMemberCandidate(const ValueDecl *SelfAssigned);
+

Should this return a `const` pointer, and have some comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129202

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


[PATCH] D124447: [clang-tidy] Add infrastructure support for running on project-level information

2022-07-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

The idea looks great in general, I didn't get a chance to look at all the 
details but this also creates some concerns for integrations of clang-tidy 
checks in other environments (like clangd or tidy running in distributed 
systems) as the workflow actually needs to be run twice and be able to write to 
disk.

So I'd actually ask for changing the way the outputting is performed. It'd be 
better to have an interface where checks can perform this finding reporting 
operation, that way clangd and other means of running clang-tidy can implement 
that interface as they see fit (put everything into a database, collect in 
memory, etc.) and clang-tidy binary by default can implement writing to disk 
(through VFS rather than physical FS operations if possible).
In addition to that it'd be nice to have a flag on checks to indicate whether 
they can work in a certain phase, and make sure instantiation only happens for 
checks that can run at a certain phase. This ensures checks can have 
assumptions about the phase they're being run at and also drivers can assume 
checks won't perform invalid operations. That way we should get to reduce 
complexity on both sides. We can by default say that checks work in diagnose 
phase and doesn't work in other phases, then relevant checks can override these 
bits.

As a more general comment to the overall approach, the "compact" phase probably 
doesn't require any tidy specific infrastructure. Only pieces that can benefit 
re-use is outputting edits, but this is already common infra across all 
clang-tools. So another direction overall here could be to actually change the 
way clang-tidy outputs findings into two forms:

- a machine readable format, that can later on be used by other tools to 
perform more analysis
- a human readable format, the usual thing today.

Have we considered this? Any reason for not going down this path?




Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:98
+  OS << Context->getGlobalOptions().MultipassDirectory << get_separator()
+ << CheckName << '.' << filename(CurrentFile) << '.'
+ << hash_value(CurrentFile) << ".yaml";

filename and contents might not be enough here. as clang-tidy is usually run 
over a compilation database and there might be multiple entries for the same 
file with different compile flags. i think we also want to include a hash of 
the flags in the filename.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124447

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 443222.
cor3ntin added a comment.

Fix bound check in the non vectorized case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  clang/test/Lexer/comment-utf8.c
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length <= sourceEnd - source && isLegalUTF8(source, length)) ? length
+ : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu -Wno-invalid-utf8
 
 int f(); // expected-note {{declared here}}
 
Index: clang/test/Lexer/comment-utf8.c
===
--- /dev/null
+++ clang/test/Lexer/comment-utf8.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Winvalid-utf8 -verify
+// expected-no-diagnostics
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©©©
+*/
+
+/* § § § 😀 你好 © */
+/*
+a longer comment to exerce the vectorized code path
+
+αααααααααααααααααααααα  // here is some unicode
+
+
+*/
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2392,13 +2392,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2665,6 +2689,12 @@
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   while (true) {
 // Ski

[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

I only spotted one thing I think is actually an issue, the rest is style 
related. LGTM with the one issue fixed.




Comment at: clang/lib/Lex/Lexer.cpp:2707-2709
+if (!isASCII(C)) {
+  goto MultiByteUTF8;
+}





Comment at: clang/lib/Lex/Lexer.cpp:2754
 #else
-  // Scan for '/' quickly.  Many block comments are very large.
-  while (CurPtr[0] != '/' &&
- CurPtr[1] != '/' &&
- CurPtr[2] != '/' &&
- CurPtr[3] != '/' &&
- CurPtr+4 < BufferEnd) {
-CurPtr += 4;
+  while (CurPtr + 16 <= BufferEnd) {
+bool HasNonASCII = false;

`<` instead of `<=`?



Comment at: clang/lib/Lex/Lexer.cpp:2756-2758
+for (unsigned I = 0; I < 16; ++I) {
+  HasNonASCII |= !isASCII(CurPtr[I]);
+}





Comment at: clang/lib/Lex/Lexer.cpp:2764-2766
+for (unsigned I = 0; I < 16; ++I) {
+  HasSlash |= CurPtr[I] == '/';
+}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 443225.
cor3ntin marked 19 inline comments as done.
cor3ntin added a comment.

Remove superfuous braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  clang/test/Lexer/comment-utf8.c
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length <= sourceEnd - source && isLegalUTF8(source, length)) ? length
+ : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu -Wno-invalid-utf8
 
 int f(); // expected-note {{declared here}}
 
Index: clang/test/Lexer/comment-utf8.c
===
--- /dev/null
+++ clang/test/Lexer/comment-utf8.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Winvalid-utf8 -verify
+// expected-no-diagnostics
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©©©
+*/
+
+/* § § § 😀 你好 © */
+/*
+a longer comment to exerce the vectorized code path
+
+αααααααααααααααααααααα  // here is some unicode
+
+
+*/
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2392,13 +2392,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2665,6 +2689,12 @@
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
  

[PATCH] D129359: [pseudo] Generate an enum type for identifying grammar rules.

2022-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h:172
+  //   terminal `,` becomes `comma`;
+  //   terminal `INT` becomes `int`;
+  std::string mangleSymbol(SymbolID) const;

I hope you mean kw_int? I'd like this to compile :-)

Can you also give the example for IDENTIFIER?



Comment at: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp:48
 
+std::string Grammar::mangleSymbol(SymbolID SID) const {
+  static const char *const TokNames[] = {

I'm not sure exposing these from `Grammar` is an improvement, i think even in 
principle we'd only want to use these for codegen.

The need for testing is real, but i guess you can add a test that uses the CXX 
generated grammar, assert the elements of Rule::whatever, and the name of 
Symbol::whatever?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129359

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


[PATCH] D128119: [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

2022-07-08 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 443230.
serge-sans-paille retitled this revision from "[clang] enforce instantiation of 
constexpr template functions" to "[clang] Enforce instantiation of constexpr 
template functions during non-constexpr evaluation".
serge-sans-paille edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128119

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
  clang/test/SemaCXX/constexpr-late-instantiation.cpp


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,15 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 -S -emit-llvm %s -fsyntax-only 2>&1 | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+int main() {
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // CHECK: error: constexpr variable 'j' must 
be initialized by a constant expression
+}
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+
+// CHECK-LABEL: define {{.*}} @_Z3fooIiET_S0_
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4840,7 +4840,8 @@
  /*Complain*/DefinitionRequired)) {
 if (DefinitionRequired)
   Function->setInvalidDecl();
-else if (TSK == TSK_ExplicitInstantiationDefinition) {
+else if (TSK == TSK_ExplicitInstantiationDefinition ||
+ (Function->isConstexpr() && !Recursive)) {
   // Try again at the end of the translation unit (at which point a
   // definition will be required).
   assert(!Recursive);
@@ -4855,7 +4856,7 @@
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
-<< Function;
+  << Function;
   }
 }
 


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,15 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 -S -emit-llvm %s -fsyntax-only 2>&1 | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+int main() {
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // CHECK: error: constexpr variable 'j' must be initialized by a constant expression
+}
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+
+// CHECK-LABEL: define {{.*}} @_Z3fooIiET_S0_
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4840,7 +4840,8 @@
  /*Complain*/DefinitionRequired)) {
 if (DefinitionRequired)
   Function->setInvalidDecl();
-else if (TSK == TSK_ExplicitInstantiationDefinition) {
+else if (TSK == TSK_ExplicitInstantiationDefinition ||
+ (Function->isConstexpr() && !Recursive)) {
   // Try again at the end of the translation unit (at which point a
   // definition will be required).
   assert(!Recursive);
@@ -4855,7 +4856,7 @@
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
-<< Function;
+  << Function;
   }
  

[PATCH] D128119: [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

2022-07-08 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@shafik: I've implemented your patch which indeed looks closer to the original 
intent
@aaron.ballman : test case and code updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128119

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


[PATCH] D129298: Add denormal-fp-math attribute for f16

2022-07-08 Thread David Candler via Phabricator via cfe-commits
dcandler added a comment.

There are currently no Arm specific changes, this is just being able to more 
accurately describe the floating point environment via attributes in the case 
where singles and doubles should be flushed, but not halves.

With three precisions to control, an alternative may be to specify them 
individually (denormal-fp-math-f64, denormal-fp-math-f32 and 
denormal-fp-math-f16) so that one doesn't override another, but that would be a 
much larger and more intrusive change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129298

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


[PATCH] D124446: [clang-tidy] Add the misc-discarded-return-value check

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: alexfh, LegalizeAdulthood.
aaron.ballman added a subscriber: alexfh.
aaron.ballman added a comment.

Precommit CI has found some build errors with the changes that should be 
addressed.

Thank you for all the timing measurement information, that's really helpful! It 
seems that this check takes about half again longer than 
`bugprone-unused-return-value`, and `bugprone-unused-return-value` seems to 
take about 10-15% of the total check time compared to the core checkers 
(roughly). That seems surprisingly heavy (for both checks).

I'm adding some more reviewers, but I'd especially like to hear from @alexfh on 
this patch stack.




Comment at: clang-tools-extra/clang-tidy/misc/DiscardedReturnValueCheck.cpp:181
+
+  static const auto Decltype = decltypeType(hasUnderlyingExpr(Call));
+  static const auto TemplateArg =

whisperity wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > whisperity wrote:
> > > > > whisperity wrote:
> > > > > > whisperity wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > So, I'm not super keen on this approach of having to try to 
> > > > > > > > identify every single place in which an expression is 
> > > > > > > > considered to be "used" -- this is going to be fragile because 
> > > > > > > > we'll miss places and it's going to be a maintenance burden 
> > > > > > > > because new places will be added as the languages evolve.
> > > > > > > > 
> > > > > > > > For example, if we're handling `decltype` as a use, why not 
> > > > > > > > `noexcept`? Or conditional `explicit`? What about a `co_return` 
> > > > > > > > statement?
> > > > > > > > 
> > > > > > > > I'm not certain what we can do to improve this, but I think 
> > > > > > > > it's worth trying to explore options to see if we can 
> > > > > > > > generalize what constitutes a use so that we can write a few 
> > > > > > > > custom matchers to do the heavy lifting instead of trying to 
> > > > > > > > play whack-a-mole.
> > > > > > > I've been having other thoughts about this `decltype` here... 
> > > > > > > Actually, neither `decltype` nor `noexcept` should be handled as 
> > > > > > > a //"use"// at all, while `co_return` should be the same as a 
> > > > > > > `return` -- however, I think it was due to lack of projects where 
> > > > > > > such could be meaningfully measured as a missed case was why 
> > > > > > > implementing that failed.
> > > > > > > 
> > > > > > > For `decltype`, `typedef`, and `noexcept` (and perhaps several 
> > > > > > > others), the good solution would be having a third route: calls 
> > > > > > > that //should not be counted//. Neither as a "consumed call", nor 
> > > > > > > as a "bare call". Ignored, from both calculations. Maybe even for 
> > > > > > > template arguments below.
> > > > > > As for better matching... Unfortunately, types in the AST are so 
> > > > > > varied and `hasDescendant` is too generic to express something like 
> > > > > > `stmt(anyOf(ifStmt(), forStmt(), switchStmt()), 
> > > > > > hasDescendant(Call))` to express in a single expression matching 
> > > > > > uses... The conditions are not always direct children of the outer 
> > > > > > node, while `hasDescendant` will match not just the condition but 
> > > > > > the entire tree... resulting in things like //both// functions in
> > > > > > 
> > > > > > ```lang=cpp
> > > > > > if (foo())
> > > > > >   bar()
> > > > > > ```
> > > > > > 
> > > > > > matching.
> > > > > > 
> > > > > > Well... generalisation... I can throw in a formal fluke:
> > > > > > 
> > > > > > > A **use** is a //context// for a specific `CallExpr C` in which 
> > > > > > > we can reasonably assume that the value produced by evaluating 
> > > > > > > `C` is loaded by another expression.
> > > > > > 
> > > > > > Now what I found is `-Wunused-result`, aka 
> > > > > > `SemaDiagnostics::warn_unused_expr`, which is triggered in the 
> > > > > > function `ExprResult Sema::ActOnFinishFullExpr(Expr* FE, 
> > > > > > SourceLocation CC, bool DiscardedValue, bool IsConstexpr);`. Now 
> > > > > > this function itself does //some// heuristics inside (with a 
> > > > > > **lot** of `FIXME`s as of 
> > > > > > rGdab5e10ea5dbc2e6314e0e7ce54a9c51fbcb44bd), but notably, 
> > > > > > `DiscardedValue` is a parameter. According to a quick search, this 
> > > > > > function (and its overloads) have **82** callsites within `Sema`, 
> > > > > > with many of them just tougher to decipher than others. Some of the 
> > > > > > other ways this function is called, e.g. `ActOnStmtExprResult`, 
> > > > > > have codes like this:
> > > > > > 
> > > > > > ```lang=cpp
> > > > > > IsStmtExprResult = GetLookAheadToken(LookAhead).is(tok::r_brace) && 
> > > > > > GetLookAheadToken(LookAhead + 1).is(tok::r_paren);
> > > > > > ```
> > > > > > 
> > > > > > So I would say most of the logic there is **very** parsing 
> > > > > > specific, and requires information that is only available during 

[PATCH] D128119: [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

2022-07-08 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 443243.

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

https://reviews.llvm.org/D128119

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
  clang/test/SemaCXX/constexpr-late-instantiation.cpp


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,15 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 -S -emit-llvm %s -fsyntax-only 2>&1 | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+int main() {
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // CHECK: error: constexpr variable 'j' must 
be initialized by a constant expression
+}
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+// CHECK: }
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4840,7 +4840,8 @@
  /*Complain*/DefinitionRequired)) {
 if (DefinitionRequired)
   Function->setInvalidDecl();
-else if (TSK == TSK_ExplicitInstantiationDefinition) {
+else if (TSK == TSK_ExplicitInstantiationDefinition ||
+ (Function->isConstexpr() && !Recursive)) {
   // Try again at the end of the translation unit (at which point a
   // definition will be required).
   assert(!Recursive);
@@ -4855,7 +4856,7 @@
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
-<< Function;
+  << Function;
   }
 }
 


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,15 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 -S -emit-llvm %s -fsyntax-only 2>&1 | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+int main() {
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // CHECK: error: constexpr variable 'j' must be initialized by a constant expression
+}
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+// CHECK: }
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4840,7 +4840,8 @@
  /*Complain*/DefinitionRequired)) {
 if (DefinitionRequired)
   Function->setInvalidDecl();
-else if (TSK == TSK_ExplicitInstantiationDefinition) {
+else if (TSK == TSK_ExplicitInstantiationDefinition ||
+ (Function->isConstexpr() && !Recursive)) {
   // Try again at the end of the translation unit (at which point a
   // definition will be required).
   assert(!Recursive);
@@ -4855,7 +4856,7 @@
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
-<< Function;
+  << Function;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129362: Undeprecate ATOMIC_FLAG_INIT in C++

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D129362#3638485 , @tambre wrote:

> Makes sense to me, thanks!

Thanks! Would you mind handling the libc++ side like last time, or do you 
prefer I handle it as part of the changes in this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129362

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


[PATCH] D129373: [NFC] Minor cleanup of usage of FloatModeKind with bitmask enums

2022-07-08 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen created this revision.
Herald added a project: All.
jolanta.jensen 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/D129373

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -421,8 +421,8 @@
 
 // Use fpret for all types.
 RealTypeUsesObjCFPRetMask =
-(int)(FloatModeKind::Float | FloatModeKind::Double |
-  FloatModeKind::LongDouble);
+(unsigned)(FloatModeKind::Float | FloatModeKind::Double |
+   FloatModeKind::LongDouble);
 
 // x86-32 has atomics up to 8 bytes
 MaxAtomicPromoteWidth = 64;
@@ -701,7 +701,7 @@
 "64-i64:64-f80:128-n8:16:32:64-S128");
 
 // Use fpret only for long double.
-RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
+RealTypeUsesObjCFPRetMask = (unsigned)FloatModeKind::LongDouble;
 
 // Use fp2ret for _Complex long double.
 ComplexLongDoubleUsesFP2Ret = true;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -222,9 +222,7 @@
   mutable VersionTuple PlatformMinVersion;
 
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRetMask
-  : llvm::BitmaskEnumDetail::bitWidth(
-(int)FloatModeKind::LLVM_BITMASK_LARGEST_ENUMERATOR);
+  unsigned RealTypeUsesObjCFPRetMask : llvm::BitWidth;
   unsigned ComplexLongDoubleUsesFP2Ret : 1;
 
   unsigned HasBuiltinMSVaList : 1;
@@ -893,7 +891,7 @@
   /// Check whether the given real type should use the "fpret" flavor of
   /// Objective-C message passing on this target.
   bool useObjCFPRetForRealType(FloatModeKind T) const {
-return RealTypeUsesObjCFPRetMask & llvm::BitmaskEnumDetail::Underlying(T);
+return (int)((FloatModeKind)RealTypeUsesObjCFPRetMask & T);
   }
 
   /// Check whether _Complex long double should use the "fp2ret" flavor


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -421,8 +421,8 @@
 
 // Use fpret for all types.
 RealTypeUsesObjCFPRetMask =
-(int)(FloatModeKind::Float | FloatModeKind::Double |
-  FloatModeKind::LongDouble);
+(unsigned)(FloatModeKind::Float | FloatModeKind::Double |
+   FloatModeKind::LongDouble);
 
 // x86-32 has atomics up to 8 bytes
 MaxAtomicPromoteWidth = 64;
@@ -701,7 +701,7 @@
 "64-i64:64-f80:128-n8:16:32:64-S128");
 
 // Use fpret only for long double.
-RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
+RealTypeUsesObjCFPRetMask = (unsigned)FloatModeKind::LongDouble;
 
 // Use fp2ret for _Complex long double.
 ComplexLongDoubleUsesFP2Ret = true;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -222,9 +222,7 @@
   mutable VersionTuple PlatformMinVersion;
 
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRetMask
-  : llvm::BitmaskEnumDetail::bitWidth(
-(int)FloatModeKind::LLVM_BITMASK_LARGEST_ENUMERATOR);
+  unsigned RealTypeUsesObjCFPRetMask : llvm::BitWidth;
   unsigned ComplexLongDoubleUsesFP2Ret : 1;
 
   unsigned HasBuiltinMSVaList : 1;
@@ -893,7 +891,7 @@
   /// Check whether the given real type should use the "fpret" flavor of
   /// Objective-C message passing on this target.
   bool useObjCFPRetForRealType(FloatModeKind T) const {
-return RealTypeUsesObjCFPRetMask & llvm::BitmaskEnumDetail::Underlying(T);
+return (int)((FloatModeKind)RealTypeUsesObjCFPRetMask & T);
   }
 
   /// Check whether _Complex long double should use the "fp2ret" flavor
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128119: [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you also add a release note for the fix?




Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:2
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 -S -emit-llvm %s -fsyntax-only 2>&1 | FileCheck %s
+





Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:9
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // CHECK: error: constexpr variable 'j' must 
be initialized by a constant expression
+}




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

https://reviews.llvm.org/D128119

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


[PATCH] D129353: [clang-tidy] Improve check cert-dcl58-cpp.

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp:29
+  continue;
+ArrayRef List1 = Arg.getPackAsArray();
+if (matchesFirstInRange(InnerMatcher, List1.begin(), List1.end(), Finder,

Might as well give this a better name so it's less similar to `List`.



Comment at: clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp:92
+  auto BadFunctionTemplateSpec =
+  functionDecl(unless(cxxMethodDecl()), isExplicitTemplateSpecialization(),
+   HasNoProgramDefinedTemplateArgument, HasStdParent);

This one is missing the system header check, but I wonder if that can be 
handled once in the call to `addMatcher()` instead of needing to be sprinkled 
here?



Comment at: 
clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp:138
+}
\ No newline at end of file


You should add the newline back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129353

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


[PATCH] D129231: [Builtins] Do not claim all libfuncs are readnone with trapping math.

2022-07-08 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

Looking at the descriptions of maths functions in C99 (and I expect C11 will be 
the same) it looks like there are three kinds:

- Those that can report error by errno and floating-point exeption, and may 
also raise the inexact exception
- Those that don't set errno, but may raise the inexact exception
- Those that neither set errno or raise an exception

Looking at this patch and the attributes of the various function intrinsics it 
looks like you have:

- Marked "e": Can set errno, can't raise exception
- Marked "eg": Can set errno and raise exception
- Marked "cg": Can't set errno, can raise an exception
- Marked "c": Can't set errno or raise an exception

Given that the functions that set errno also raise exceptions I think it would 
make sense to have the "e" attribute cover both errno and exceptions, and have 
"g" just for those that can only raise exceptions. Also "cg" looks like it's 
probably wrong and should be "g" (given that "c" means "always const" and "g" 
means "const only when we don't have exceptions", and that's also how "e" is 
used in that we don't have functions with "cg").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129231

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


[PATCH] D129277: [clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D129277#3637317 , @mstorsjo wrote:

> In D129277#3636795 , @aaron.ballman 
> wrote:
>
>> In D129277#3636596 , @mstorsjo 
>> wrote:
>>
>>> In D129277#3636567 , 
>>> @aaron.ballman wrote:
>>>
 Thanks for catching this! Is it really an NFC change though (it seems like 
 it would change some of the diagnostic behavior and the list of suggested 
 predefines)? Can you add test coverage for the change?
>>>
>>> TBH I haven’t tried to follow exactly where this case would matter in the 
>>> current state of affairs - the function is called in three places, and 
>>> maybe the individual roles of the parameters currently only make a 
>>> difference in the other callers. As it didn’t break any tests I presumed 
>>> it’s NFC.
>>
>> Heh, I presumed we just lacked test coverage. :-) But I also don't know 
>> enough about this interface to know exactly how to test it. I would imagine 
>> that this would be caught through using a PCH that was compiled with 
>> different preprocessor options than the code consuming the header. I'm not 
>> certain if `-D` or `-U` is sufficient to demonstrate the issue or not, but 
>> maybe `-fallow-editor-placeholders` and `-fno-allow-editor-placeholders` 
>> would work?
>
> The thing is that this particular caller passes `nullptr` for `Diags`, so no 
> diagnostics are emitted, and the generated `SuggestedPredefines` string is 
> ignored by the one caller (`ASTReader::isAcceptableASTFile`). So within that 
> function, the only thing that is returned is a boolean for whether the two 
> (AST file and command line parameters) are compatible, and in that respect, 
> the two parameters are commutative - so I think it's not possible to observe 
> whether these two parameters are passed correctly or not, right now. Hence 
> NFC.

Ah, I see it now, this really is an NFC change, thank you for the explanation. 
LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129277

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


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-07-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne marked an inline comment as done.
ldionne added a comment.

Thanks @mstorsjo! Regarding `_LIBCPP_EXPERIMENTAL_FUNC_VIS`, yes I think it 
would make sense to use a different visibility macro for symbols that we know 
are provided only as part of a static library. I would not call it 
`_LIBCPP_EXPERIMENTAL_FUNC_VIS` though, I would call it something like 
`_LIBCPP_STATIC_LIBRARY_FUNC_VIS` or something like that.




Comment at: libcxx/utils/libcxx/test/params.py:68
+  if hasCompileFlag(cfg, '-funstable') and False: # TODO: Enable this once the 
design of `-funstable` is finished
+return '-funstable'
+  else:

mstorsjo wrote:
> Actually, I'm not entirely convinced that this is a good way to handle 
> linking against the library for tests.
> 
> When building tests, we don't rely on the compiler to implicitly link in our 
> C++ library, but we link with `-nostdlib++` (or `-nodefaultlibs`) and 
> explicitly tell the compiler how to link in specifically the C++ library 
> we've just built (in the test config files).
> 
> So in general, if linking with `-nostdlib++ -fexperimental-library` I kinda 
> wouldn't expect the compiler driver to link against the library at all? It's 
> kinda the same as if you'd do `-stdlib=libstdc++ -fexperimental-library` - we 
> can't have that add `-lc++experimental`, as that only makes sense as long as 
> we have `-stdlib=libc++`. So subsequently I don't think the compiler driver 
> should be adding `-lc++experimental` as long as we're passing `-nostdlib++` 
> either?
> 
> But if libc++experimental is built unconditionally, wouldn't it be simplest 
> to just always link against it in the test config files (just like how we 
> force it to link against specifically the just-built libc++.a) - that would 
> make it much more symmetrcial to how we handle the main `-lc++`?
Interesting point. It does mean that we can never rely on `-funstable` adding 
`-lc++experimental` from our test suite -- I think that's OK.

However, I'd like to avoid linking against `-lc++experimental` in the base test 
configuration, simply because the base test configuration should mirror the 
minimal way of invoking Clang to use libc++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-07-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 443252.
ldionne marked an inline comment as done.
ldionne added a comment.

Windows fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libcxx/CMakeLists.txt
  libcxx/appveyor.yml
  libcxx/cmake/caches/AIX.cmake
  libcxx/cmake/caches/Apple.cmake
  libcxx/cmake/caches/Generic-no-experimental.cmake
  libcxx/cmake/caches/MinGW.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/UsingLibcxx.rst
  libcxx/src/CMakeLists.txt
  libcxx/test/CMakeLists.txt
  
libcxx/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp
  
libcxx/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/not_equal.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_const_lvalue_pair.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_rvalue.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_values.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/destroy.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/resource.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/select_on_container_copy_construction.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_deque_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_forward_list_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_list_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_map_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_regex_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_set_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_string_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_unordered_map_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_unordered_set_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_vector_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.global/default_resource.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.global/new_delete_resource.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.global/null_memory_resource.pass.cpp
  libcxx/utils/ci/run-buildbot
  libcxx/utils/libcxx/test/params.py

Index: libcxx/utils/libcxx/test/params.py
===
--- libcxx/utils/libcxx/test/params.py
+++ libcxx/utils/libcxx/test/params.py
@@ -156,15 +156,19 @@
 ])),
 
   Parameter(name='enable_experimental', choices=[True, False], type=bool, default=True,
-help="Whether to enable tests for experimental C++ libraries (typically Library Fundamentals TSes).",
+help="Whether to enable tests for experimental C++ Library features.",
 actions=lambda experimental: [] if not experimental else [
-  AddFeature('c++experimental'),
   # When linking in MSVC mode via the Clang driver, a -l
   # maps to .lib, so we need to use -llibc++expe

[clang] d2ead9e - [LinkerWrapper][NFC] Rework command line argument handling in the linker wrapper

2022-07-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-08T11:18:38-04:00
New Revision: d2ead9e324d4d268e8c0634849d6081e177c9dd7

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

LOG: [LinkerWrapper][NFC] Rework command line argument handling in the linker 
wrapper

Summary:
This patch reworks the command line argument handling in the linker
wrapper from using the LLVM `cl` interface to using the `Option`
interface with TableGen. This has several benefits compared to the old
method.

We use arguments from the linker arguments in the linker
wrapper, such as the libraries and input files, this allows us to
properly parse these. Additionally we can now easily set up aliases to
the linker wrapper arguments and pass them in the linker input directly.
That is, pass an option like `cuda-path=` as `--offload-arg=cuda-path=`
in the linker's inputs. This will allow us to handle offloading
compilation in the linker itself some day. Finally, this is also a much
cleaner interface for passing arguments to the individual device linking
jobs.

Added: 
clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c
clang/test/Driver/openmp-offload.c
clang/tools/clang-linker-wrapper/CMakeLists.txt
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index bc437d66a03ce..c11806ff692a5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8393,7 +8393,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
 
 for (StringRef LibName : BCLibs)
   CmdArgs.push_back(Args.MakeArgString(
-  "-target-library=" + Action::GetOffloadKindName(Action::OFK_OpenMP) +
+  "--target-library=" + Action::GetOffloadKindName(Action::OFK_OpenMP) 
+
   "-" + TC->getTripleString() + "-" + Arch + "=" + LibName));
   }
 
@@ -8413,41 +8413,35 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
   } else if (A->getOption().matches(options::OPT_O0))
 OOpt = "0";
   if (!OOpt.empty())
-CmdArgs.push_back(Args.MakeArgString(Twine("-opt-level=O") + OOpt));
+CmdArgs.push_back(Args.MakeArgString(Twine("--opt-level=O") + OOpt));
 }
   }
 
-  CmdArgs.push_back("-host-triple");
-  CmdArgs.push_back(Args.MakeArgString(TheTriple.getTriple()));
+  CmdArgs.push_back(
+  Args.MakeArgString("--host-triple=" + TheTriple.getTriple()));
   if (Args.hasArg(options::OPT_v))
-CmdArgs.push_back("-v");
+CmdArgs.push_back("--verbose");
 
-  // Add debug information if present.
   if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) {
-const Option &Opt = A->getOption();
-if (Opt.matches(options::OPT_gN_Group)) {
-  if (Opt.matches(options::OPT_gline_directives_only) ||
-  Opt.matches(options::OPT_gline_tables_only))
-CmdArgs.push_back("-gline-directives-only");
-} else
-  CmdArgs.push_back("-g");
+if (!A->getOption().matches(options::OPT_g0))
+  CmdArgs.push_back("--device-debug");
   }
 
   for (const auto &A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
-CmdArgs.push_back(Args.MakeArgString("-ptxas-args=" + A));
+CmdArgs.push_back(Args.MakeArgString("--ptxas-args=" + A));
 
   // Forward remarks passes to the LLVM backend in the wrapper.
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
 CmdArgs.push_back(
-Args.MakeArgString(Twine("-pass-remarks=") + A->getValue()));
+Args.MakeArgString(Twine("--pass-remarks=") + A->getValue()));
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
 CmdArgs.push_back(
-Args.MakeArgString(Twine("-pass-remarks-missed=") + A->getValue()));
+Args.MakeArgString(Twine("--pass-remarks-missed=") + A->getValue()));
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
 CmdArgs.push_back(
-Args.MakeArgString(Twine("-pass-remarks-analysis=") + A->getValue()));
+Args.MakeArgString(Twine("--pass-remarks-analysis=") + A->getValue()));
   if (Args.getLastArg(options::OPT_save_temps_EQ))
-CmdArgs.push_back("-save-temps");
+CmdArgs.push_back("--save-temps");
 
   // Construct the link job so we can wrap around it.
   Linker->ConstructJob(C, JA, Output, Inputs, Args, LinkingOutput);
@@ -8458,18 +8452,18 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
 StringRef Val = Arg->getValue(0);
 if (Val.empty())
   CmdArgs.push_back(
-  Args.MakeArgString(Twine("-device-linker=") + Arg->getValue(1)));
+  Args.MakeArgString(Twine("-

[clang] e0de264 - [LinkerWrapper][NFC] Move error handling to a common function

2022-07-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-08T11:18:38-04:00
New Revision: e0de264f6355c397e91927827a9cbb940c903607

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

LOG: [LinkerWrapper][NFC] Move error handling to a common function

Summary:
This patch merges all the error handling functions to a single function
call so we don't define the same lambda many times.

Added: 


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

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 4e4f85cbcd02..75e1a1b8a72c 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -186,6 +186,13 @@ void printCommands(ArrayRef CmdArgs) {
 llvm::errs() << *IC << (std::next(IC) != IE ? " " : "\n");
 }
 
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E),
+WithColor::error(errs(), LinkerExecutable));
+  exit(EXIT_FAILURE);
+}
+
 /// Create an extra user-specified \p OffloadFile.
 /// TODO: We should find a way to wrap these as libraries instead.
 Expected getInputBitcodeLibrary(StringRef Input) {
@@ -764,23 +771,18 @@ std::unique_ptr createLTO(
   Conf.PTO.SLPVectorization = Conf.OptLevel > 1;
 
   if (SaveTemps) {
-auto HandleError = [=](Error Err) {
-  logAllUnhandledErrors(std::move(Err),
-WithColor::error(errs(), LinkerExecutable));
-  exit(1);
-};
 Conf.PostInternalizeModuleHook = [&, Arch](size_t, const Module &M) {
   auto TempFileOrErr =
   createOutputFile(sys::path::filename(ExecutableName) + "-" +
Triple.getTriple() + "-" + Arch,
"bc");
   if (!TempFileOrErr)
-HandleError(TempFileOrErr.takeError());
+reportError(TempFileOrErr.takeError());
 
   std::error_code EC;
   raw_fd_ostream LinkedBitcode(*TempFileOrErr, EC, sys::fs::OF_None);
   if (EC)
-HandleError(errorCodeToError(EC));
+reportError(errorCodeToError(EC));
   WriteBitcodeToFile(M, LinkedBitcode);
   return true;
 };
@@ -863,12 +865,6 @@ Error linkBitcodeFiles(SmallVectorImpl 
&InputFiles,
   // Remove all the bitcode files that we moved from the original input.
   llvm::erase_if(InputFiles, [](OffloadFile &F) { return !F.getBinary(); });
 
-  auto HandleError = [&](Error Err) {
-logAllUnhandledErrors(std::move(Err),
-  WithColor::error(errs(), LinkerExecutable));
-exit(1);
-  };
-
   // LTO Module hook to output bitcode without running the backend.
   SmallVector BitcodeOutput;
   auto OutputBitcode = [&](size_t Task, const Module &M) {
@@ -876,12 +872,12 @@ Error linkBitcodeFiles(SmallVectorImpl 
&InputFiles,
   "-jit-" + Triple.getTriple(),
   "bc");
 if (!TempFileOrErr)
-  HandleError(TempFileOrErr.takeError());
+  reportError(TempFileOrErr.takeError());
 
 std::error_code EC;
 raw_fd_ostream LinkedBitcode(*TempFileOrErr, EC, sys::fs::OF_None);
 if (EC)
-  HandleError(errorCodeToError(EC));
+  reportError(errorCodeToError(EC));
 WriteBitcodeToFile(M, LinkedBitcode);
 BitcodeOutput.push_back(*TempFileOrErr);
 return false;
@@ -964,10 +960,10 @@ Error linkBitcodeFiles(SmallVectorImpl 
&InputFiles,
   "-device-" + Triple.getTriple(),
   Extension);
 if (!TempFileOrErr)
-  HandleError(TempFileOrErr.takeError());
+  reportError(TempFileOrErr.takeError());
 TempFile = *TempFileOrErr;
 if (std::error_code EC = sys::fs::openFileForWrite(TempFile, FD))
-  HandleError(errorCodeToError(EC));
+  reportError(errorCodeToError(EC));
 return std::make_unique(
 std::make_unique(FD, true));
   };
@@ -1323,10 +1319,6 @@ int main(int Argc, char **Argv) {
 
   LinkerExecutable = Argv[0];
   sys::PrintStackTraceOnErrorSignal(Argv[0]);
-  auto reportError = [Argv](Error E) {
-logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Argv[0]));
-return EXIT_FAILURE;
-  };
 
   const OptTable &Tbl = getOptTable();
   BumpPtrAllocator Alloc;
@@ -1380,13 +1372,13 @@ int main(int Argc, char **Argv) {
 ErrorOr> BufferOrErr =
 MemoryBuffer::getFileOrSTDIN(Filename);
 if (std::error_code EC = BufferOrErr.getError())
-  return reportError(createFileError(Filename, EC));
+  reportError(createFileError(Filename, EC));
 
 bool IsLazy =
 identify_magic((*BufferOrErr)->getBuffer()) == file_magic::archive;
 if

[PATCH] D129373: [NFC] Minor cleanup of usage of FloatModeKind with bitmask enums

2022-07-08 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen updated this revision to Diff 443258.
jolanta.jensen added a comment.

Removing a tab.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129373

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -421,8 +421,8 @@
 
 // Use fpret for all types.
 RealTypeUsesObjCFPRetMask =
-(int)(FloatModeKind::Float | FloatModeKind::Double |
-  FloatModeKind::LongDouble);
+(unsigned)(FloatModeKind::Float | FloatModeKind::Double |
+   FloatModeKind::LongDouble);
 
 // x86-32 has atomics up to 8 bytes
 MaxAtomicPromoteWidth = 64;
@@ -701,7 +701,7 @@
 "64-i64:64-f80:128-n8:16:32:64-S128");
 
 // Use fpret only for long double.
-RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
+RealTypeUsesObjCFPRetMask = (unsigned)FloatModeKind::LongDouble;
 
 // Use fp2ret for _Complex long double.
 ComplexLongDoubleUsesFP2Ret = true;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -222,9 +222,7 @@
   mutable VersionTuple PlatformMinVersion;
 
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRetMask
-  : llvm::BitmaskEnumDetail::bitWidth(
-(int)FloatModeKind::LLVM_BITMASK_LARGEST_ENUMERATOR);
+  unsigned RealTypeUsesObjCFPRetMask : llvm::BitWidth;
   unsigned ComplexLongDoubleUsesFP2Ret : 1;
 
   unsigned HasBuiltinMSVaList : 1;
@@ -893,7 +891,7 @@
   /// Check whether the given real type should use the "fpret" flavor of
   /// Objective-C message passing on this target.
   bool useObjCFPRetForRealType(FloatModeKind T) const {
-return RealTypeUsesObjCFPRetMask & llvm::BitmaskEnumDetail::Underlying(T);
+return (int)((FloatModeKind)RealTypeUsesObjCFPRetMask & T);
   }
 
   /// Check whether _Complex long double should use the "fp2ret" flavor


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -421,8 +421,8 @@
 
 // Use fpret for all types.
 RealTypeUsesObjCFPRetMask =
-(int)(FloatModeKind::Float | FloatModeKind::Double |
-  FloatModeKind::LongDouble);
+(unsigned)(FloatModeKind::Float | FloatModeKind::Double |
+   FloatModeKind::LongDouble);
 
 // x86-32 has atomics up to 8 bytes
 MaxAtomicPromoteWidth = 64;
@@ -701,7 +701,7 @@
 "64-i64:64-f80:128-n8:16:32:64-S128");
 
 // Use fpret only for long double.
-RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
+RealTypeUsesObjCFPRetMask = (unsigned)FloatModeKind::LongDouble;
 
 // Use fp2ret for _Complex long double.
 ComplexLongDoubleUsesFP2Ret = true;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -222,9 +222,7 @@
   mutable VersionTuple PlatformMinVersion;
 
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRetMask
-  : llvm::BitmaskEnumDetail::bitWidth(
-(int)FloatModeKind::LLVM_BITMASK_LARGEST_ENUMERATOR);
+  unsigned RealTypeUsesObjCFPRetMask : llvm::BitWidth;
   unsigned ComplexLongDoubleUsesFP2Ret : 1;
 
   unsigned HasBuiltinMSVaList : 1;
@@ -893,7 +891,7 @@
   /// Check whether the given real type should use the "fpret" flavor of
   /// Objective-C message passing on this target.
   bool useObjCFPRetForRealType(FloatModeKind T) const {
-return RealTypeUsesObjCFPRetMask & llvm::BitmaskEnumDetail::Underlying(T);
+return (int)((FloatModeKind)RealTypeUsesObjCFPRetMask & T);
   }
 
   /// Check whether _Complex long double should use the "fp2ret" flavor
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5400-5401
+SourceLocation KWLoc) {
+  if (!S.getLangOpts().CPlusPlus11)
+return;
+

royjacobson wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > royjacobson wrote:
> > > > erichkeane wrote:
> > > > > royjacobson wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > I think we should always warn on these, not just in C++11.
> > > > > > I'm not convinced we should. My reasoning is that we need a pretty 
> > > > > > good reason to start issuing warnings for 20 years old code. The 
> > > > > > usage of those builtins with deleted functions after C++11 is 
> > > > > > pretty broken which is a pretty good reason, but for earlier 
> > > > > > language versions they work 'fine' and if people want to use C++03 
> > > > > > I prefer leaving them at peace :)
> > > > > > 
> > > > > > People on C++03 are also probably using pretty old versions of 
> > > > > > libstdc++ and/or boost type_traits, so this could have some impact.
> > > > > > 
> > > > > > WDYT?
> > > > > > 
> > > > > warnings don't get emitted for code in header files, so at least that 
> > > > > part isn't a concern.  
> > > > Any header files, or just system headers?
> > > Sorry, yes, Phab is a mess on a cell phone... in things included as 
> > > System Headers.
> > Agreed with Erich -- warnings in system headers (but not regular headers) 
> > are silenced by default, you need to pass `-Wsystem-headers` to enable them.
> To clarify my position, I think about those builtins as an unofficial part of 
> the C++03 standard and I think we should support them as long as we support 
> C++03.
> 
> Do you think that's reasonable?
> 
> I agree we should update the documentation in this case.
I still don't see the benefit of undeprecating these in C++03. The replacement 
interfaces are available for use in C++03 mode, so there's nothing that 
prevents a user from being pushed to use the supported interfaces instead, 
right? To me, the older interfaces were not clean/correct and the replacement 
interfaces are the ones that we want people to use, and that's language mode 
agnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

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


[PATCH] D128449: [clang] Introduce -Warray-parameter

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the new diagnostic!




Comment at: clang/lib/Sema/SemaDecl.cpp:3213
+static bool EquivalentArrayTypes(QualType Old, QualType New,
+ ASTContext const &Ctx) {
+

East const? MONSTEROUS! ;-) (We tend to use west const mostly in the code base.)


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

https://reviews.llvm.org/D128449

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


[clang] 74a8fce - [LinkerWrapper] Fix save-temps and argument name

2022-07-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-08T11:38:33-04:00
New Revision: 74a8fce6e87e81802b4fe69769daec19504753bf

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

LOG: [LinkerWrapper] Fix save-temps and argument name

Summary:
The previous path reworked some handling of temporary files which
exposed some bugs related to capturing local state by reference in the
callback labmda. Squashing this by copying in everything instead. There
was also a problem where the argument name was changed for
`--bitcode-library=` but clang still used `--target-library=`.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c11806ff692a..10d2b9202b7c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8393,7 +8393,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
 
 for (StringRef LibName : BCLibs)
   CmdArgs.push_back(Args.MakeArgString(
-  "--target-library=" + Action::GetOffloadKindName(Action::OFK_OpenMP) 
+
+  "--bitcode-library=" + 
Action::GetOffloadKindName(Action::OFK_OpenMP) +
   "-" + TC->getTripleString() + "-" + Arch + "=" + LibName));
   }
 

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 75e1a1b8a72c..06e5cf843da0 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -236,7 +236,7 @@ Expected createOutputFile(const Twine &Prefix, 
StringRef Extension) {
   return createFileError(OutputFile, EC);
   }
 
-  TempFiles.push_back(OutputFile);
+  TempFiles.emplace_back(std::move(OutputFile));
   return TempFiles.back();
 }
 
@@ -771,16 +771,12 @@ std::unique_ptr createLTO(
   Conf.PTO.SLPVectorization = Conf.OptLevel > 1;
 
   if (SaveTemps) {
-Conf.PostInternalizeModuleHook = [&, Arch](size_t, const Module &M) {
-  auto TempFileOrErr =
-  createOutputFile(sys::path::filename(ExecutableName) + "-" +
-   Triple.getTriple() + "-" + Arch,
-   "bc");
-  if (!TempFileOrErr)
-reportError(TempFileOrErr.takeError());
-
+std::string TempName = (sys::path::filename(ExecutableName) + "-" +
+Triple.getTriple() + "-" + Arch + ".bc")
+   .str();
+Conf.PostInternalizeModuleHook = [=](size_t, const Module &M) {
   std::error_code EC;
-  raw_fd_ostream LinkedBitcode(*TempFileOrErr, EC, sys::fs::OF_None);
+  raw_fd_ostream LinkedBitcode(TempName, EC, sys::fs::OF_None);
   if (EC)
 reportError(errorCodeToError(EC));
   WriteBitcodeToFile(M, LinkedBitcode);



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


[PATCH] D128182: [NFC] Switch FloatModeKind enum class to use bitmask enums

2022-07-08 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen added a comment.

@tahonermann, I addressed your comments in https://reviews.llvm.org/D129373. I 
just need to remove a tab that crept in and it seems to be more difficult than 
I thought as my code does not seem to have any tab and reformatting the code 
does not change the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128182

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


[clang] 0d7161a - [Clang] Fix test failing due to renamed arg

2022-07-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-08T11:50:56-04:00
New Revision: 0d7161af89f91db798f7be2a521568a4cd754214

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

LOG: [Clang] Fix test failing due to renamed arg

Added: 


Modified: 
clang/test/Driver/amdgpu-openmp-toolchain-new.c
clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Removed: 




diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain-new.c 
b/clang/test/Driver/amdgpu-openmp-toolchain-new.c
index 2ddc5a12c200..1551917ea50f 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain-new.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain-new.c
@@ -50,4 +50,4 @@
 // CHECK-EMIT-LLVM-IR: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -lm --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode 
-fopenmp-new-driver %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIB-DEVICE-NEW
-// CHECK-LIB-DEVICE-NEW: 
{{.*}}clang-linker-wrapper{{.*}}-target-library=openmp-amdgcn-amd-amdhsa-gfx803={{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
+// CHECK-LIB-DEVICE-NEW: 
{{.*}}clang-linker-wrapper{{.*}}--bitcode-library=openmp-amdgcn-amd-amdhsa-gfx803={{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"

diff  --git a/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td 
b/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
index 0b0b2c901361..7620873aa8f6 100644
--- a/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ b/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -75,27 +75,33 @@ def sysroot_EQ : Joined<["--"], "sysroot">, HelpText<"Set 
the system root">;
 
 def o : JoinedOrSeparate<["-"], "o">, MetaVarName<"">,
   HelpText<"Path to file to write output">;
-def output_EQ : Joined<["--"], "output=">, Alias, HelpText<"Alias for -o">;
-def output : Separate<["--"], "output">, Alias, HelpText<"Alias for -o">;
+def output_EQ : Joined<["--"], "output=">, Alias, Flags<[HelpHidden]>,
+  HelpText<"Alias for -o">;
+def output : Separate<["--"], "output">, Alias, Flags<[HelpHidden]>,
+  HelpText<"Alias for -o">;
 
 def library_path : JoinedOrSeparate<["-"], "L">, MetaVarName<"">,
   HelpText<"Add  to the library search path">;
-def library_path_S : Separate<["--", "-"], "library-path">, 
Alias;
-def library_path_EQ : Joined<["--", "-"], "library-path=">, 
Alias;
+def library_path_S : Separate<["--", "-"], "library-path">, 
Flags<[HelpHidden]>,
+  Alias;
+def library_path_EQ : Joined<["--", "-"], "library-path=">, 
Flags<[HelpHidden]>,
+  Alias;
 
 def library : JoinedOrSeparate<["-"], "l">, MetaVarName<"">,
   HelpText<"Search for library ">;
-def library_S : Separate<["--", "-"], "library">, Alias;
-def library_EQ : Joined<["--", "-"], "library=">, Alias;
+def library_S : Separate<["--", "-"], "library">, Flags<[HelpHidden]>,
+  Alias;
+def library_EQ : Joined<["--", "-"], "library=">, Flags<[HelpHidden]>,
+  Alias;
 
 def as_needed : Flag<["--", "-"], "as-needed">;
 def no_as_needed : Flag<["--", "-"], "no-as-needed">;
 
 def rpath : Separate<["--", "-"], "rpath">;
-def rpath_EQ : Joined<["--", "-"], "rpath=">, Alias;
+def rpath_EQ : Joined<["--", "-"], "rpath=">, Flags<[HelpHidden]>, 
Alias;
 
 def dynamic_linker : Separate<["--", "-"], "dynamic-linker">;
 def dynamic_linker_EQ : Joined<["--", "-"], "dynamic-linker=">, 
Alias;
 
 def v : Flag<["--", "-"], "v">, HelpText<"Display the version number and 
exit">;
-def version : Flag<["--", "-"], "version">, Alias;
+def version : Flag<["--", "-"], "version">, Flags<[HelpHidden]>, Alias;



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


[PATCH] D75788: [OpenMP] Provide math functions in OpenMP device code via OpenMP variants

2022-07-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:145
 
 set(openmp_wrapper_files
   openmp_wrappers/math.h

chapuni wrote:
> It doesn't contain , intentional?
We don't wrap that yet. Do you need it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788

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


[PATCH] D129362: Undeprecate ATOMIC_FLAG_INIT in C++

2022-07-08 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D129362#3638896 , @aaron.ballman 
wrote:

> In D129362#3638485 , @tambre wrote:
>
>> Makes sense to me, thanks!
>
> Thanks! Would you mind handling the libc++ side like last time, or do you 
> prefer I handle it as part of the changes in this patch?

Yeah, sure, see D129380 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129362

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


[PATCH] D121141: [Clang] Add `-funstable` flag to enable unstable and experimental features: follow-up fixes

2022-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:276
+
+Enable unstable and experimental language and library features.
+

The doc is auto-generated by tablegen 
(https://discourse.llvm.org/t/clang-driver-options-td-docs-usersmanual-rst-and-docs-clangcommandlinereference-rst/56540).
For lengthy documentation, use `clang/docs/UsersManual.rst` instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121141

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


[PATCH] D119051: Extend the C++03 definition of POD to include defaulted functions

2022-07-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D129362: Undeprecate ATOMIC_FLAG_INIT in C++

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D129362#3639193 , @tambre wrote:

> In D129362#3638896 , @aaron.ballman 
> wrote:
>
>> In D129362#3638485 , @tambre wrote:
>>
>>> Makes sense to me, thanks!
>>
>> Thanks! Would you mind handling the libc++ side like last time, or do you 
>> prefer I handle it as part of the changes in this patch?
>
> Yeah, sure, see D129380 .

Thank you! :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129362

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


[PATCH] D128119: [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

2022-07-08 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 443276.
serge-sans-paille added a comment.

+ release note
+ take review into account


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128119

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
  clang/test/SemaCXX/constexpr-late-instantiation.cpp


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,15 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 %s -fsyntax-only -verify
+
+template 
+constexpr T foo(T a);
+
+int main() {
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // expected-error {{constexpr variable 'j' 
must be initialized by a constant expression}}
+}
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+// CHECK: }
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4840,7 +4840,8 @@
  /*Complain*/DefinitionRequired)) {
 if (DefinitionRequired)
   Function->setInvalidDecl();
-else if (TSK == TSK_ExplicitInstantiationDefinition) {
+else if (TSK == TSK_ExplicitInstantiationDefinition ||
+ (Function->isConstexpr() && !Recursive)) {
   // Try again at the end of the translation unit (at which point a
   // definition will be required).
   assert(!Recursive);
@@ -4855,7 +4856,7 @@
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
-<< Function;
+  << Function;
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -181,6 +181,8 @@
   emitted as a dynamic initializer. Previously the variable would
   incorrectly be zero-initialized. In contexts where a dynamic
   initializer is not allowed this is now diagnosed as an error.
+- Clang now correctly emit symbols for implicitly instanciated constexpr
+  template function. Fixes `Issue 55560 
`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,15 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 %s -fsyntax-only -verify
+
+template 
+constexpr T foo(T a);
+
+int main() {
+  int k = foo(5);   // Ok
+  constexpr int j = foo(5); // expected-error {{constexpr variable 'j' must be initialized by a constant expression}}
+}
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is instantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+// CHECK: }
+
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4840,7 +4840,8 @@
  /*Complain*/DefinitionRequired)) {
 if (DefinitionRequired)
   Function->setInvalidDecl();
-else if (TSK == TSK_ExplicitInstantiationDefinition) {
+else if (TSK == TSK_ExplicitInstantiationDefinition ||
+ (Function->isConstexpr() && !Recursive)) {
   // Try again at the end of the translation unit

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Sema/riscv-bad-intrnisic-pragma.c:1
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v %s -emit-llvm -o - \
+// RUN:2>&1 | FileCheck %s

this test file name is misspelled



Comment at: clang/test/Sema/riscv-intrnisic-pragma.c:1
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -emit-llvm -o - -verify 
%s
+

test file name is misspelled


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:17
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include 

Do we need the header or is a forward declaration enough?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D128119: [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

2022-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from some test changes, assuming that precommit CI comes back green.




Comment at: clang/docs/ReleaseNotes.rst:184
   initializer is not allowed this is now diagnosed as an error.
+- Clang now correctly emit symbols for implicitly instanciated constexpr
+  template function. Fixes `Issue 55560 
`_.





Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:1
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 %s -fsyntax-only -verify

You can remove this comment since this is no longer testing the IR.



Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:2
+// Make sure foo is instantiated and we don't get a link error
+// RUN: not %clang_cc1 %s -fsyntax-only -verify
+

Oops, I missed that in my earlier suggestion!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128119

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


[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D129301#3637664 , @jhuber6 wrote:

> In D129301#3637642 , @jdoerfert 
> wrote:
>
>> Isn't the offload bundler on it's "way out" (=replaced and then deleted 
>> soon)?
>
> HIP still uses it to create their `fatbinary` format for CUDA-like support 
> for multi-architecture binaries as well as their object file format. Once 
> D128914  is landed we can at least compile 
> HIP without it, but we would still need to use it to create the bundled image 
> until AMD decides to support my stuff in their runtime. Beyond that I'm not 
> aware of what the users will be now that OpenMP uses the new interface by 
> default. I'm not in a big hurry to delete this if people still have a use for 
> it, but I'd prefer things to use the new interface if possible. Are there any 
> other situations where we still need the `clang-offload-bundler`? If there's 
> anything the new interface is lacking I could add it in.

I think before the new binary format supports Windows and -fno-gpu-rdc and HIP 
runtime support the new binary format, we cannot deprecate 
clang-offload-bundler. I expect that would take some time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129301

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


[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D129301#3637641 , @lamb-j wrote:

> @yaxunl Are you recommending I combine all 4 patches down into 1 patch? Or 
> combine a subset of patches?

I recommend combining all patches as one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129301

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


[PATCH] D129383: [LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries

2022-07-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, ye-luo.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch removes some uses of string savers that are no-longer needed.
We also create a new string saver when linking bitcode files. It seems
that occasionally the symbol string references can go out of scope when
they are added to the LTO input so we need to save these names that are
used for symbol resolution. Additionally, a previous patch added new
logic for handling bitcode libraries, but failed to actually add them to
the input. This bug has been fixed.

Fixes #56445


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129383

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -525,17 +525,15 @@
   if (!TempFileOrErr)
 return TempFileOrErr.takeError();
 
-  BumpPtrAllocator Alloc;
-  StringSaver Saver(Alloc);
-
   SmallVector CmdArgs;
   CmdArgs.push_back(*FatBinaryPath);
   CmdArgs.push_back(Triple.isArch64Bit() ? "-64" : "-32");
   CmdArgs.push_back("--create");
   CmdArgs.push_back(*TempFileOrErr);
   for (const auto &FileAndArch : InputFiles)
-CmdArgs.push_back(Saver.save("--image=profile=" + std::get<1>(FileAndArch) 
+
- ",file=" + std::get<0>(FileAndArch)));
+CmdArgs.push_back(
+Args.MakeArgString("--image=profile=" + std::get<1>(FileAndArch) +
+   ",file=" + std::get<0>(FileAndArch)));
 
   if (Error Err = executeCommands(*FatBinaryPath, CmdArgs))
 return std::move(Err);
@@ -808,6 +806,8 @@
   SmallVector BitcodeInputFiles;
   DenseSet UsedInRegularObj;
   DenseSet UsedInSharedLib;
+  BumpPtrAllocator Alloc;
+  StringSaver Saver(Alloc);
 
   // Search for bitcode files in the input and create an LTO input file. If it
   // is not a bitcode file, scan its symbol table for symbols we need to save.
@@ -844,9 +844,9 @@
 
 // Record if we've seen these symbols in any object or shared 
libraries.
 if ((*ObjFile)->isRelocatableObject())
-  UsedInRegularObj.insert(*Name);
+  UsedInRegularObj.insert(Saver.save(*Name));
 else
-  UsedInSharedLib.insert(*Name);
+  UsedInSharedLib.insert(Saver.save(*Name));
   }
   continue;
 }
@@ -908,7 +908,8 @@
   // We will use this as the prevailing symbol definition in LTO unless
   // it is undefined or another definition has already been used.
   Res.Prevailing =
-  !Sym.isUndefined() && PrevailingSymbols.insert(Sym.getName()).second;
+  !Sym.isUndefined() &&
+  PrevailingSymbols.insert(Saver.save(Sym.getName())).second;
 
   // We need LTO to preseve the following global symbols:
   // 1) Symbols used in regular objects.
@@ -1193,8 +1194,6 @@
 InputsForTarget[File].emplace_back(std::move(File));
   LinkerInputFiles.clear();
 
-  BumpPtrAllocator Alloc;
-  UniqueStringSaver Saver(Alloc);
   DenseMap> Images;
   for (auto &InputForTarget : InputsForTarget) {
 SmallVector &Input = InputForTarget.getSecond();
@@ -1395,6 +1394,7 @@
 auto FileOrErr = getInputBitcodeLibrary(Library);
 if (!FileOrErr)
   reportError(FileOrErr.takeError());
+InputFiles.push_back(std::move(*FileOrErr));
   }
 
   DenseSet IsTargetUsed;


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -525,17 +525,15 @@
   if (!TempFileOrErr)
 return TempFileOrErr.takeError();
 
-  BumpPtrAllocator Alloc;
-  StringSaver Saver(Alloc);
-
   SmallVector CmdArgs;
   CmdArgs.push_back(*FatBinaryPath);
   CmdArgs.push_back(Triple.isArch64Bit() ? "-64" : "-32");
   CmdArgs.push_back("--create");
   CmdArgs.push_back(*TempFileOrErr);
   for (const auto &FileAndArch : InputFiles)
-CmdArgs.push_back(Saver.save("--image=profile=" + std::get<1>(FileAndArch) +
- ",file=" + std::get<0>(FileAndArch)));
+CmdArgs.push_back(
+Args.MakeArgString("--image=profile=" + std::get<1>(FileAndArch) +
+   ",file=" + std::get<0>(FileAndArch)));
 
   if (Error Err = executeCommands(*FatBinaryPath, CmdArgs))
 return std::move(Err);
@@ -808,6 +806,8 @@
   SmallVector BitcodeInputFiles;
   DenseSet UsedInRegularObj;
   DenseSet UsedInSharedLib;
+  BumpPtrAllocator Alloc;
+  StringSaver Saver(Alloc);
 
   // Search for bitcode files in the input and create an LTO input file. If it
   // is not a bitcode file, scan its symbol table for symbols we need to

[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D129301#3639318 , @yaxunl wrote:

> I think before the new binary format supports Windows and -fno-gpu-rdc and 
> HIP runtime support the new binary format, we cannot deprecate 
> clang-offload-bundler. I expect that would take some time.

Supporting `-fno-gpu-rdc` should be easy, this will just require a few tweaks 
to the driver phases and passing it to the host backend directly. Supporting 
Windows would be a little tougher, we would need to make sure we can embed / 
extract the device code with Windows. After that we would need to synthesize 
the start / stop pointers differently. There is a way to do this on Windows 
similar to how Unix linkers, there's some examples in ASAN or HWSAN I believe. 
It's definitely doable but would take some effort, so it definitely won't work 
in time for the 15 release. I personally don't have much interest in Mac or 
Windows, but if I want to make this format universal I may need to actually sit 
down and implement it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129301

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


[PATCH] D129384: [objcxx] Fix `std::addressof` for `id`.

2022-07-08 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
Herald added a project: All.
zoecarver 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/D129384

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm


Index: clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+template 
+T* addressof(T&);
+}
+
+void f(id obj) {
+(void)std::addressof(*obj);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@
 bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
   BuiltinID == Builtin::BI__addressof;
 if (!(Param->isReferenceType() &&
-  (ReturnsPointer ? Result->isPointerType()
+  (ReturnsPointer ? Result->isAnyPointerType()
   : Result->isReferenceType()) &&
   Context.hasSameUnqualifiedType(Param->getPointeeType(),
  Result->getPointeeType( {


Index: clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+template 
+T* addressof(T&);
+}
+
+void f(id obj) {
+(void)std::addressof(*obj);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@
 bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
   BuiltinID == Builtin::BI__addressof;
 if (!(Param->isReferenceType() &&
-  (ReturnsPointer ? Result->isPointerType()
+  (ReturnsPointer ? Result->isAnyPointerType()
   : Result->isReferenceType()) &&
   Context.hasSameUnqualifiedType(Param->getPointeeType(),
  Result->getPointeeType( {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128830: [Pipelines] Introduce DAE after ArgumentPromotion

2022-07-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

moving DAE after the function simplification pipeline makes sense

In D128830#3622736 , @psamolysov 
wrote:

> In D128830#3622467 , @fhahn wrote:
>
>> Do we need to retain the run of `DeadArgumentEliminationPass` in the 
>> original position or is a single run at the new position sufficient?
>
> Good point! I tried and also removed the guard that the DAE pass should run 
> with O3  only (currently it run 
> exactly as the pass in the original position did: with any O > 0). I have a 
> chance to run the LLVM :: Transforms tests only, one test failed - `LLVM :: 
> Transforms\InstCombine\unused-nonnull.ll`:
>
>   error: CHECK-SAME: expected string not found in input
>   ; CHECK-SAME: (i32 [[ARGC:%.*]], i8** nocapture readnone [[ARGV:%.*]]) 
> local_unnamed_addr #[[ATTR0:[0-9]+]] {
> ^
>   :7:17: note: scanning from here
>   define i32 @main(i32 %argc, i8** nocapture readonly %argv) 
> local_unnamed_addr #0 {
>
> The difference is that the `%argv` argument has the `readonly` attribute, not 
> `readnone`. I'm not sure whether this makes much sense (I guess this  could 
> because `readnone` can theoretically open a door for some optimizations for 
> which `readonly` cannot).

this would be fixed by running `PostOrderFunctionAttrsPass` after the function 
simplification pipeline which is something I've wanted to do but never got 
around to testing. we should be inferring more precise attributes after fully 
simplifying functions. the only case that might regress is recursive functions 
since when visiting the recursive calls we haven't computed attributes for the 
recursive functions yet

this test is regressing with this patch because previously DAE would replace 
passed arguments with poison if the argument isn't used in the function, 
removing the use of `%argv` in `@main` and func-attrs would mark `%argv` as 
readnone, but with this patch func-attrs runs on `@main` before the use of 
`%argv` is eliminated. the call to `@compute` is eliminated in all cases in the 
function simplification pipeline due to inferring the `returned` attribute on 
`%x`, which is why running func-attrs after the function simplification 
pipeline fixes this issue

  @@ -759,9 +758,6 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
 if (AttributorRun & AttributorRunOption::CGSCC)
   MainCGPipeline.addPass(AttributorCGSCCPass());
   
  -  // Now deduce any function attributes based in the current code.
  -  MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
  -
 // When at O3 add argument promotion to the pass pipeline.
 // FIXME: It isn't at all clear why this should be limited to O3.
 if (Level == OptimizationLevel::O3)
  @@ -781,6 +777,9 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
 buildFunctionSimplificationPipeline(Level, Phase),
 PTO.EagerlyInvalidateAnalyses, EnableNoRerunSimplificationPipeline));
   
  +  // Now deduce any function attributes based in the current code.
  +  MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
  +
 MainCGPipeline.addPass(CoroSplitPass(Level != OptimizationLevel::O0));


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128830

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


[clang] bc2a6de - [C++20][Modules] Allow for redeclarations in partitions.

2022-07-08 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-07-08T19:02:59+01:00
New Revision: bc2a6defc853553b3896cb853bb84fe663f6bfd0

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

LOG: [C++20][Modules] Allow for redeclarations in partitions.

The existing provision is not sufficient, it did not allow for the cases
where an implementation partition includes the primary module interface,
or for the case that an exported interface partition is contains a decl
that is then implemented in a regular implementation unit.

It is somewhat unfortunate that we have to compare top level module names
to achieve this, since built modules are not necessarily available.

TODO: It might be useful to cache a hash of the primary module name if
this test proves to be a  significant load.

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

Added: 
clang/test/Modules/cxx20-partition-redeclarations.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1139088ecde27..d6c89d525cdc2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1625,22 +1625,20 @@ bool Sema::CheckRedeclarationModuleOwnership(NamedDecl 
*New, NamedDecl *Old) {
   Module *NewM = New->getOwningModule();
   Module *OldM = Old->getOwningModule();
 
-  if (NewM && NewM->Kind == Module::PrivateModuleFragment)
+  if (NewM && NewM->isPrivateModule())
 NewM = NewM->Parent;
-  if (OldM && OldM->Kind == Module::PrivateModuleFragment)
+  if (OldM && OldM->isPrivateModule())
 OldM = OldM->Parent;
 
-  // If we have a decl in a module partition, it is part of the containing
-  // module (which is the only thing that can be importing it).
-  if (NewM && OldM &&
-  (OldM->Kind == Module::ModulePartitionInterface ||
-   OldM->Kind == Module::ModulePartitionImplementation)) {
-return false;
-  }
-
   if (NewM == OldM)
 return false;
 
+  // Partitions are part of the module, but a partition could import another
+  // module, so verify that the PMIs agree.
+  if (NewM && OldM && (NewM->isModulePartition() || OldM->isModulePartition()))
+return NewM->getPrimaryModuleInterfaceName() ==
+   OldM->getPrimaryModuleInterfaceName();
+
   bool NewIsModuleInterface = NewM && NewM->isModulePurview();
   bool OldIsModuleInterface = OldM && OldM->isModulePurview();
   if (NewIsModuleInterface || OldIsModuleInterface) {

diff  --git a/clang/test/Modules/cxx20-partition-redeclarations.cpp 
b/clang/test/Modules/cxx20-partition-redeclarations.cpp
new file mode 100644
index 0..f99ef009a79af
--- /dev/null
+++ b/clang/test/Modules/cxx20-partition-redeclarations.cpp
@@ -0,0 +1,55 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 A-intf-part.cpp -emit-module-interface \
+// RUN:  -o A-PubPart.pcm
+// RUN: %clang_cc1 -std=c++20 A-interface.cpp -emit-module-interface \
+// RUN:   -fmodule-file=A-PubPart.pcm -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fmodule-file=A.pcm
+
+//--- A-interface.cpp
+export module A;
+
+export import :PubPart;
+
+export void do_something();
+
+void helper1();
+void helper3();
+
+//--- A-intf-part.cpp
+export module A:PubPart;
+
+void helper2();
+
+//--- A-impl-top.cpp
+
+module A;
+
+void do_something() {
+  helper1();
+  helper2();
+  helper3();
+}
+
+//--- A-impl-part.cpp
+module A:Secret;
+
+import A;
+
+void helper3() {}
+
+//--- A-impl-1.cpp
+module A;
+
+void helper1() {}
+
+//--- A-impl-2.cpp
+module A;
+
+void helper2() {}



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


[PATCH] D127624: [C++20][Modules] Allow for redeclarations in partitions.

2022-07-08 Thread Iain Sandoe 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 rGbc2a6defc853: [C++20][Modules] Allow for redeclarations in 
partitions. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127624

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Modules/cxx20-partition-redeclarations.cpp


Index: clang/test/Modules/cxx20-partition-redeclarations.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-partition-redeclarations.cpp
@@ -0,0 +1,55 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 A-intf-part.cpp -emit-module-interface \
+// RUN:  -o A-PubPart.pcm
+// RUN: %clang_cc1 -std=c++20 A-interface.cpp -emit-module-interface \
+// RUN:   -fmodule-file=A-PubPart.pcm -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fmodule-file=A.pcm
+
+//--- A-interface.cpp
+export module A;
+
+export import :PubPart;
+
+export void do_something();
+
+void helper1();
+void helper3();
+
+//--- A-intf-part.cpp
+export module A:PubPart;
+
+void helper2();
+
+//--- A-impl-top.cpp
+
+module A;
+
+void do_something() {
+  helper1();
+  helper2();
+  helper3();
+}
+
+//--- A-impl-part.cpp
+module A:Secret;
+
+import A;
+
+void helper3() {}
+
+//--- A-impl-1.cpp
+module A;
+
+void helper1() {}
+
+//--- A-impl-2.cpp
+module A;
+
+void helper2() {}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1625,22 +1625,20 @@
   Module *NewM = New->getOwningModule();
   Module *OldM = Old->getOwningModule();
 
-  if (NewM && NewM->Kind == Module::PrivateModuleFragment)
+  if (NewM && NewM->isPrivateModule())
 NewM = NewM->Parent;
-  if (OldM && OldM->Kind == Module::PrivateModuleFragment)
+  if (OldM && OldM->isPrivateModule())
 OldM = OldM->Parent;
 
-  // If we have a decl in a module partition, it is part of the containing
-  // module (which is the only thing that can be importing it).
-  if (NewM && OldM &&
-  (OldM->Kind == Module::ModulePartitionInterface ||
-   OldM->Kind == Module::ModulePartitionImplementation)) {
-return false;
-  }
-
   if (NewM == OldM)
 return false;
 
+  // Partitions are part of the module, but a partition could import another
+  // module, so verify that the PMIs agree.
+  if (NewM && OldM && (NewM->isModulePartition() || OldM->isModulePartition()))
+return NewM->getPrimaryModuleInterfaceName() ==
+   OldM->getPrimaryModuleInterfaceName();
+
   bool NewIsModuleInterface = NewM && NewM->isModulePurview();
   bool OldIsModuleInterface = OldM && OldM->isModulePurview();
   if (NewIsModuleInterface || OldIsModuleInterface) {


Index: clang/test/Modules/cxx20-partition-redeclarations.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-partition-redeclarations.cpp
@@ -0,0 +1,55 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 A-intf-part.cpp -emit-module-interface \
+// RUN:  -o A-PubPart.pcm
+// RUN: %clang_cc1 -std=c++20 A-interface.cpp -emit-module-interface \
+// RUN:   -fmodule-file=A-PubPart.pcm -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fmodule-file=A.pcm
+// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fmodule-file=A.pcm
+
+//--- A-interface.cpp
+export module A;
+
+export import :PubPart;
+
+export void do_something();
+
+void helper1();
+void helper3();
+
+//--- A-intf-part.cpp
+export module A:PubPart;
+
+void helper2();
+
+//--- A-impl-top.cpp
+
+module A;
+
+void do_something() {
+  helper1();
+  helper2();
+  helper3();
+}
+
+//--- A-impl-part.cpp
+module A:Secret;
+
+import A;
+
+void helper3() {}
+
+//--- A-impl-1.cpp
+module A;
+
+void helper1() {}
+
+//--- A-impl-2.cpp
+module A;
+
+void helper2() {}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1625,22 +1625,20 @@
   Module *NewM = New->getOwningModule();
   Module *OldM = Old->getOwningModule();
 
-  if (NewM && NewM->Kind == Module::PrivateModuleFragment)
+  if (NewM && NewM->isPrivateModule())
 NewM = NewM->Parent;
-  if (OldM && OldM->Kind == Module::PrivateModuleFragment)
+  if (OldM && OldM->isPrivateModule())

[clang] eb1ffd8 - Update references to Discourse instead of the mailing lists.

2022-07-08 Thread via cfe-commits

Author: tlattner
Date: 2022-07-08T11:16:47-07:00
New Revision: eb1ffd817c3ce5120c3f9d4152de65954314a8d5

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

LOG: Update references to Discourse instead of the mailing lists.

Update the references to the old Mailman mailing lists to point to Discourse 
forums.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ExternalClangExamples.rst
clang/docs/InternalsManual.rst
clang/docs/OpenCLSupport.rst
clang/docs/OpenMPSupport.rst
clang/docs/ReleaseNotes.rst
clang/www/get_involved.html

Removed: 




diff  --git a/clang/docs/ExternalClangExamples.rst 
b/clang/docs/ExternalClangExamples.rst
index 58c605a9a8363..080114740ddb8 100644
--- a/clang/docs/ExternalClangExamples.rst
+++ b/clang/docs/ExternalClangExamples.rst
@@ -18,9 +18,9 @@ where Clang is used are:
 - Static analysis.
 - Documentation/cross-reference generation.
 
-If you know of (or wrote!) a tool or project using Clang, please send an
-email to Clang's `development discussion mailing list
-`_ to have it added.
+If you know of (or wrote!) a tool or project using Clang, please post on 
+`the Discourse forums (Clang Frontend category)
+`_ to have it added.
 (or if you are already a Clang contributor, feel free to directly commit
 additions). Since the primary purpose of this page is to provide examples
 that can help developers, generally they must have code available.

diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index 72228fcc2e0ae..8d18ff01be043 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -537,7 +537,7 @@ token.  This concept maps directly to the "spelling 
location" for the token.
 ``SourceRange`` and ``CharSourceRange``
 ---
 
-.. mostly taken from 
https://lists.llvm.org/pipermail/cfe-dev/2010-August/010595.html
+.. mostly taken from 
https://discourse.llvm.org/t/code-ranges-of-tokens-ast-elements/16893/2
 
 Clang represents most source ranges by [first, last], where "first" and "last"
 each point to the beginning of their respective tokens.  For example consider

diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 3fa0c774f5bc9..9372e63c0e621 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -408,8 +408,8 @@ Experimental features
 
 Clang provides the following new WIP features for the developers to experiment
 and provide early feedback or contribute with further improvements.
-Feel free to contact us on `cfe-dev
-`_ or file `a GitHub issue
+Feel free to contact us on `the Discourse forums (Clang Frontend category)
+`_ or file `a GitHub issue
 `_.
 
 .. _opencl_experimental_cxxlibs:

diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index c94bc0b0de362..efabe927d6df5 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -110,8 +110,9 @@ OpenMP 5.0 Implementation Details
 =
 
 The following table provides a quick overview over various OpenMP 5.0 features
-and their implementation status. Please contact *openmp-dev* at
-*lists.llvm.org* for more information or if you want to help with the
+and their implementation status. Please post on the
+`Discourse forums (Runtimes - OpenMP category)`_ for more 
+information or if you want to help with the
 implementation.
 
 
+--+--+--+---+
@@ -256,8 +257,10 @@ OpenMP 5.1 Implementation Details
 
 The following table provides a quick overview over various OpenMP 5.1 features
 and their implementation status, as defined in the technical report 8 (TR8).
-Please contact *openmp-dev* at *lists.llvm.org* for more information or if you
-want to help with the implementation.
+Please post on the 
+`Discourse forums (Runtimes - OpenMP category)`_ for more 
+information or if you want to help with the
+implementation.
 
 
+--+--+--+---+
 |Category  | Feature   
   | Status   | Reviews 
  |
@@ -362,12 +365,

[PATCH] D128766: Update references to Discourse instead of the mailing lists.

2022-07-08 Thread Tanya Lattner 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 rGeb1ffd817c3c: Update references to Discourse instead of the 
mailing lists. (authored by tonic).

Changed prior to commit:
  https://reviews.llvm.org/D128766?vs=441800&id=443296#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128766

Files:
  clang/docs/ExternalClangExamples.rst
  clang/docs/InternalsManual.rst
  clang/docs/OpenCLSupport.rst
  clang/docs/OpenMPSupport.rst
  clang/docs/ReleaseNotes.rst
  clang/www/get_involved.html

Index: clang/www/get_involved.html
===
--- clang/www/get_involved.html
+++ clang/www/get_involved.html
@@ -28,41 +28,28 @@
 
 Follow what's going on
 
-Clang is a subproject of the https://llvm.org";>LLVM Project, but
-has its own mailing lists because the communities have people with different
-interests.  The two clang lists are:
+Clang is a subproject of the https://llvm.org";>LLVM Project
+and has a Discourse forum and mailing list:
 
 
 https://lists.llvm.org/mailman/listinfo/cfe-commits";>cfe-commits
  - This list is for patch submission/discussion.
 
-https://lists.llvm.org/mailman/listinfo/cfe-dev";>cfe-dev -
-This list is for everything else Clang related (questions and answers, design
+https://discourse.llvm.org/c/clang/6";>Clang Frontend Discourse forum -
+This forum is for everything else Clang related (questions and answers, design
 discussions, etc).
 
 
 
-If you are interested in clang only, these two lists should be all
-you need.  If you are interested in the LLVM optimizer and code generator,
-please consider signing up for https://lists.llvm.org/mailman/listinfo/llvm-dev";>llvm-dev and https://lists.llvm.org/mailman/listinfo/llvm-commits";>llvm-commits
-as well.
-
-
 The most common way to talk with other developers on the project is through
-the https://lists.llvm.org/mailman/listinfo/cfe-dev";>cfe-dev mailing
-list.  The clang mailing list is a very friendly place and we welcome
-newcomers.  In addition to the cfe-dev list, a significant amount of design
+the https://discourse.llvm.org/c/clang/6";>Clang Frontend Discourse forum
+.  The clang forum is a very friendly place and we welcome
+newcomers.  In addition to the forum, a significant amount of design
 discussion takes place on the https://lists.llvm.org/mailman/listinfo/cfe-commits";>cfe-commits mailing
 list.  All of these lists have archives, so you can browse through previous
 discussions or follow the list development on the web if you prefer.
 
-You can also follow the http://planet.clang.org/";>Planet Clang
-community news feed which offers a window into the world, work and lives of
-Clang developers, contributors and the standards they implement.
-
 If you're looking for something to work on, check out our Open Projects page or look through the https://github.com/llvm/llvm-project/issues/";>LLVM bug tracker.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -675,5 +675,5 @@
 tree.
 
 If you have any questions or comments about Clang, please feel free to
-contact us via the `mailing
-list `_.
+contact us on the Discourse forums (Clang Frontend category)
+`_.
Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -110,8 +110,9 @@
 =
 
 The following table provides a quick overview over various OpenMP 5.0 features
-and their implementation status. Please contact *openmp-dev* at
-*lists.llvm.org* for more information or if you want to help with the
+and their implementation status. Please post on the
+`Discourse forums (Runtimes - OpenMP category)`_ for more 
+information or if you want to help with the
 implementation.
 
 +--+--+--+---+
@@ -256,8 +257,10 @@
 
 The following table provides a quick overview over various OpenMP 5.1 features
 and their implementation status, as defined in the technical report 8 (TR8).
-Please contact *openmp-dev* at *lists.llvm.org* for more information or if you
-want to help with the implementation.
+Please post on the 
+`Discourse forums (Runtimes - OpenMP category)`_ for more 
+information or if you want to help with the
+implementation.
 
 +--+--+--+---+
 |Category

[clang-tools-extra] ea61750 - [NFC] Refactor llvm::zlib namespace

2022-07-08 Thread Cole Kissane via cfe-commits

Author: Cole Kissane
Date: 2022-07-08T11:19:07-07:00
New Revision: ea61750c35a11140e9245bd9cbeb383c37f6e031

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

LOG: [NFC] Refactor llvm::zlib namespace

* Refactor compression namespaces across the project, making way for a possible
  introduction of alternatives to zlib compression.
  Changes are as follows:
  * Relocate the `llvm::zlib` namespace to `llvm::compression::zlib`.

Reviewed By: MaskRay, leonardchan, phosek

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/unittests/SerializationTests.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
lld/ELF/Driver.cpp
lld/ELF/InputSection.cpp
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Support/Compression.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/lib/Object/Decompressor.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/lib/Support/Compression.cpp
llvm/tools/llvm-mc/llvm-mc.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/unittests/ProfileData/InstrProfTest.cpp
llvm/unittests/Support/CompressionTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index f7045f0be3fde..ee86ed5714ecc 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -190,9 +190,9 @@ class StringTableOut {
   RawTable.append(std::string(S));
   RawTable.push_back(0);
 }
-if (llvm::zlib::isAvailable()) {
+if (llvm::compression::zlib::isAvailable()) {
   llvm::SmallString<1> Compressed;
-  llvm::zlib::compress(RawTable, Compressed);
+  llvm::compression::zlib::compress(RawTable, Compressed);
   write32(RawTable.size(), OS);
   OS << Compressed;
 } else {
@@ -223,7 +223,7 @@ llvm::Expected 
readStringTable(llvm::StringRef Data) {
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else if (llvm::zlib::isAvailable()) {
+  else if (llvm::compression::zlib::isAvailable()) {
 // Don't allocate a massive buffer if UncompressedSize was corrupted
 // This is effective for sharded index, but not big monolithic ones, as
 // once compressed size reaches 4MB nothing can be ruled out.
@@ -233,8 +233,8 @@ llvm::Expected 
readStringTable(llvm::StringRef Data) {
   return error("Bad stri table: uncompress {0} -> {1} bytes is 
implausible",
R.rest().size(), UncompressedSize);
 
-if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
-   UncompressedSize))
+if (llvm::Error E = llvm::compression::zlib::uncompress(
+R.rest(), UncompressedStorage, UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
   } else

diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 70873efe5776c..e99626ba75d77 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -391,7 +391,7 @@ TEST(SerializationTest, NoCrashOnBadArraySize) {
 // Check we detect invalid string table size size without allocating it first.
 // If this detection fails, the test should allocate a huge array and crash.
 TEST(SerializationTest, NoCrashOnBadStringTableSize) {
-  if (!llvm::zlib::isAvailable()) {
+  if (!llvm::compression::zlib::isAvailable()) {
 log("skipping test, no zlib");
 return;
   }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 10d2b9202b7c6..2c4d39343183c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1144,7 +1144,7 @@ static void RenderDebugInfoCompressionArgs(const ArgList 
&Args,
 if (Value == "none") {
   CmdArgs.push_back("--compress-debug-sections=none");
 } else if (Value == "zlib") {
-  if (llvm::zlib::isAvailable()) {
+  if (llvm::compression::zlib::isAvailable()) {
 CmdArgs.push_back(
 Args.MakeArgString("--compress-debug-sections=" + Twine(Value)));
   } else {

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
i

[clang] ea61750 - [NFC] Refactor llvm::zlib namespace

2022-07-08 Thread Cole Kissane via cfe-commits

Author: Cole Kissane
Date: 2022-07-08T11:19:07-07:00
New Revision: ea61750c35a11140e9245bd9cbeb383c37f6e031

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

LOG: [NFC] Refactor llvm::zlib namespace

* Refactor compression namespaces across the project, making way for a possible
  introduction of alternatives to zlib compression.
  Changes are as follows:
  * Relocate the `llvm::zlib` namespace to `llvm::compression::zlib`.

Reviewed By: MaskRay, leonardchan, phosek

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/unittests/SerializationTests.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
lld/ELF/Driver.cpp
lld/ELF/InputSection.cpp
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Support/Compression.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/lib/Object/Decompressor.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/lib/Support/Compression.cpp
llvm/tools/llvm-mc/llvm-mc.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/unittests/ProfileData/InstrProfTest.cpp
llvm/unittests/Support/CompressionTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index f7045f0be3fde..ee86ed5714ecc 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -190,9 +190,9 @@ class StringTableOut {
   RawTable.append(std::string(S));
   RawTable.push_back(0);
 }
-if (llvm::zlib::isAvailable()) {
+if (llvm::compression::zlib::isAvailable()) {
   llvm::SmallString<1> Compressed;
-  llvm::zlib::compress(RawTable, Compressed);
+  llvm::compression::zlib::compress(RawTable, Compressed);
   write32(RawTable.size(), OS);
   OS << Compressed;
 } else {
@@ -223,7 +223,7 @@ llvm::Expected 
readStringTable(llvm::StringRef Data) {
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else if (llvm::zlib::isAvailable()) {
+  else if (llvm::compression::zlib::isAvailable()) {
 // Don't allocate a massive buffer if UncompressedSize was corrupted
 // This is effective for sharded index, but not big monolithic ones, as
 // once compressed size reaches 4MB nothing can be ruled out.
@@ -233,8 +233,8 @@ llvm::Expected 
readStringTable(llvm::StringRef Data) {
   return error("Bad stri table: uncompress {0} -> {1} bytes is 
implausible",
R.rest().size(), UncompressedSize);
 
-if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
-   UncompressedSize))
+if (llvm::Error E = llvm::compression::zlib::uncompress(
+R.rest(), UncompressedStorage, UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
   } else

diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 70873efe5776c..e99626ba75d77 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -391,7 +391,7 @@ TEST(SerializationTest, NoCrashOnBadArraySize) {
 // Check we detect invalid string table size size without allocating it first.
 // If this detection fails, the test should allocate a huge array and crash.
 TEST(SerializationTest, NoCrashOnBadStringTableSize) {
-  if (!llvm::zlib::isAvailable()) {
+  if (!llvm::compression::zlib::isAvailable()) {
 log("skipping test, no zlib");
 return;
   }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 10d2b9202b7c6..2c4d39343183c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1144,7 +1144,7 @@ static void RenderDebugInfoCompressionArgs(const ArgList 
&Args,
 if (Value == "none") {
   CmdArgs.push_back("--compress-debug-sections=none");
 } else if (Value == "zlib") {
-  if (llvm::zlib::isAvailable()) {
+  if (llvm::compression::zlib::isAvailable()) {
 CmdArgs.push_back(
 Args.MakeArgString("--compress-debug-sections=" + Twine(Value)));
   } else {

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
i

[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-08 Thread Cole Kissane 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 rGea61750c35a1: [NFC] Refactor llvm::zlib namespace (authored 
by ckissane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -18,6 +18,7 @@
 #include "gtest/gtest.h"
 
 using namespace llvm;
+using namespace llvm::compression;
 
 namespace {
 
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1147,14 +1147,16 @@
 // Compressing:
 std::string FuncNameStrings1;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
+  FuncNames1,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings1),
   Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
+  FuncNames2,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings2),
   Succeeded());
 
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -22,11 +22,9 @@
 #endif
 
 using namespace llvm;
+using namespace llvm::compression;
 
 #if LLVM_ENABLE_ZLIB
-static Error createError(StringRef Err) {
-  return make_error(Err, inconvertibleErrorCode());
-}
 
 static StringRef convertZlibCodeToString(int Code) {
   switch (Code) {
@@ -70,15 +68,17 @@
   // Tell MemorySanitizer that zlib output buffer is fully initialized.
   // This avoids a false report when running LLVM with uninstrumented ZLib.
   __msan_unpoison(UncompressedBuffer, UncompressedSize);
-  return Res ? createError(convertZlibCodeToString(Res)) : Error::success();
+  return Res ? make_error(convertZlibCodeToString(Res),
+   inconvertibleErrorCode())
+ : Error::success();
 }
 
 Error zlib::uncompress(StringRef InputBuffer,

[PATCH] D128754: [llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace

2022-07-08 Thread Cole Kissane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG96063bfa9088: [llvm] Remove unused and redundant crc32 
funcction from llvm::compression::zlib… (authored by ckissane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128754

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  llvm/unittests/Support/CompressionTest.cpp


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -63,12 +63,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -83,10 +83,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -102,7 +98,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -41,8 +41,6 @@
  SmallVectorImpl &UncompressedBuffer,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 } // End of namespace compression
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -206,6 +206,7 @@
   introduction of alternatives to zlib compression in the llvm toolchain.
   Changes are as follows:
   * Relocate the ``llvm::zlib`` namespace to ``llvm::compression::zlib``.
+  * Remove crc32 from zlib compression namespace, people should use the 
``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -63,12 +63,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -83,10 +83,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -102,7 +98,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -41,8 +41,6 @@
  SmallVectorImpl &UncompressedBuffer,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 } // End of namespace compression
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -206,6 +206,7 @@
   introduction of alternatives to zlib compression in the llvm toolchain.
   Changes are as follows:
   * Relocate the ``llvm::zlib`` namespace to ``llvm::compression::zlib``.
+  * Remove crc32 from zlib compression namespace, people should use the ``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 22c7a6d - [objcxx] Fix `std::addressof` for `id`.

2022-07-08 Thread via cfe-commits

Author: zoecarver
Date: 2022-07-08T11:29:30-07:00
New Revision: 22c7a6ec6d62e627ca66b886b60ba1ce1e7c

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

LOG: [objcxx] Fix `std::addressof` for `id`.

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

Added: 
clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm

Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4ac3fd38438ca..3ed745c5634c8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
   BuiltinID == Builtin::BI__addressof;
 if (!(Param->isReferenceType() &&
-  (ReturnsPointer ? Result->isPointerType()
+  (ReturnsPointer ? Result->isAnyPointerType()
   : Result->isReferenceType()) &&
   Context.hasSameUnqualifiedType(Param->getPointeeType(),
  Result->getPointeeType( {

diff  --git a/clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm 
b/clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
new file mode 100644
index 0..a591163714ee5
--- /dev/null
+++ b/clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+template 
+T* addressof(T&);
+}
+
+void f(id obj) {
+(void)std::addressof(*obj);
+}



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


[PATCH] D129384: [objcxx] Fix `std::addressof` for `id`.

2022-07-08 Thread Zoe Carver via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22c7a6ec: [objcxx] Fix `std::addressof` for `id`. 
(authored by zoecarver).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129384

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm


Index: clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+template 
+T* addressof(T&);
+}
+
+void f(id obj) {
+(void)std::addressof(*obj);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@
 bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
   BuiltinID == Builtin::BI__addressof;
 if (!(Param->isReferenceType() &&
-  (ReturnsPointer ? Result->isPointerType()
+  (ReturnsPointer ? Result->isAnyPointerType()
   : Result->isReferenceType()) &&
   Context.hasSameUnqualifiedType(Param->getPointeeType(),
  Result->getPointeeType( {


Index: clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+template 
+T* addressof(T&);
+}
+
+void f(id obj) {
+(void)std::addressof(*obj);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@
 bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
   BuiltinID == Builtin::BI__addressof;
 if (!(Param->isReferenceType() &&
-  (ReturnsPointer ? Result->isPointerType()
+  (ReturnsPointer ? Result->isAnyPointerType()
   : Result->isReferenceType()) &&
   Context.hasSameUnqualifiedType(Param->getPointeeType(),
  Result->getPointeeType( {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7ecec30 - [Clang][Docs] Update the clang-linker-wrapper documentation.

2022-07-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-08T14:30:07-04:00
New Revision: 7ecec30e43987f4851130fc08423ab23fec234a4

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

LOG: [Clang][Docs] Update the clang-linker-wrapper documentation.

Added: 


Modified: 
clang/docs/ClangLinkerWrapper.rst

Removed: 




diff  --git a/clang/docs/ClangLinkerWrapper.rst 
b/clang/docs/ClangLinkerWrapper.rst
index 58fa7f9900e4..28c4086d6b5c 100644
--- a/clang/docs/ClangLinkerWrapper.rst
+++ b/clang/docs/ClangLinkerWrapper.rst
@@ -10,44 +10,56 @@ Clang Linker Wrapper
 Introduction
 
 
-This tool works as a wrapper over a linking job. The tool is used to create
-linked device images for offloading. It scans the linker's input for embedded
-device offloading data stored in sections ``.llvm.offloading..``
-and extracts it as a temporary file. The extracted device files will then be
-passed to a device linking job to create a final device image. The sections 
will
-also be stripped and the resulting file passed back to the host linker.
+This tool works as a wrapper of the normal host linking job. This tool is used
+to create linked device images for offloading and the necessary runtime calls 
to
+register them. It works by first scanning the linker's input for embedded 
device
+offloading data stored at the ``.llvm.offloading`` section. This section
+contains binary data created by the :doc:`ClangOffloadPackager`. The extracted
+device files will then be linked. The linked modules will then be wrapped into 
a
+new object file containing the code necessary to register it with the 
offloading
+runtime.
 
 Usage
 =
 
-This tool can be used with the following options. Arguments to the host linker
-being wrapper around are passed as positional arguments using the ``--`` flag 
to
-override parsing.
+This tool can be used with the following options. Any arguments not intended
+only for the linker wrapper will be forwarded to the wrapped linker job.
 
 .. code-block:: console
 
-  USAGE: clang-linker-wrapper [options] ...
+  USAGE: clang-linker-wrapper [options] -- 
   
   OPTIONS:
-  
-  Generic Options:
-  
---help- Display available options (--help-hidden for 
more)
---help-list   - Display list of available options 
(--help-list-hidden for more)
---version - Display the version of this program
-  
-  clang-linker-wrapper options:
-  
---host-triple= - Triple to use for the host compilation
---linker-path= - Path of linker binary
---opt-level=   - Optimization level for LTO
---ptxas-option=- Argument to pass to the ptxas invocation
---save-temps   - Save intermediary results.
---strip-sections   - Strip offloading sections from the host 
object file.
---target-embed-bc  - Embed linked bitcode instead of an executable 
device image
---target-feature=  - Target features for triple
---bitcode-library= - Path for the target bitcode library
--v - Verbose output from tools
+--bitcode-library=--=
+   Extra bitcode library to link
+--cuda-path=  Set the system CUDA path
+--device-debug Use debugging
+--device-linker= or =
+   Arguments to pass to the device linker invocation
+--dry-run  Print program arguments without running
+--embed-bitcodeEmbed linked bitcode in the module
+--help-hidden  Display all available options
+--help Display available options (--help-hidden for more)
+--host-triple= Triple to use for the host compilation
+--linker-path=   The linker executable to invoke
+-LAdd  to the library search path
+-lSearch for library 
+--opt-level=
+   Optimization level for LTO
+-o   Path to file to write output
+--pass-remarks-analysis=
+   Pass remarks for LTO
+--pass-remarks-missed=
+   Pass remarks for LTO
+--pass-remarks= Pass remarks for LTO
+--print-wrapped-module Print the wrapped module's IR for testing
+--ptxas-arg=Argument to pass to the 'ptxas' invocation
+--save-temps   Save intermediate results
+--sysroot   Set the system root
+--verbose  Verbose output from tools
+--vDisplay the version number and exit
+-- The separator for the wrapped linker arguments
+
 
 Example
 ===
@@ -59,4 +71,4 @@ section and run a device linking job on it.
 
 .. code-block:: console
 
-  clang-linker-wrapper -host-triple x86_64 -linker-path /usr/bin/ld -- 
+  clang-linker-wra

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-08 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:3541
 .getPointerType(CGF.getContext().getPointerType(
 CGF.getContext().VoidPtrTy))
 .castAs());

This should be VoidTy now that GlobalArgs type has changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 443308.
ckissane added a comment.

- Merge remote-tracking branch 'origin/main' into ckissane.add-zstd.0-cmake
- added have_zstd to compiler-rt/test/lit.common.cfg.py, 
clang-tools-extra/clangd/test/lit.cfg.py and several lit.site.cfg.py.in files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/lit.site.cfg.py.in
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -18,6 +18,7 @@
 #include "gtest/gtest.h"
 
 using namespace llvm;
+using namespace llvm::compression;
 
 namespace {
 
@@ -62,12 +63,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1147,14 +1147,16 @@
 // Compressing:
 std::string FuncNameStrings1;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
+  FuncNames1,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings1),
   Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
+  FuncNames2,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings2),
   Succeeded());
 
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
   

[PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via cfe-commits
ckissane marked 2 inline comments as done.
ckissane added a comment.

marked fixed comments as done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 443310.
ckissane added a comment.

- Merge remote-tracking branch 'origin/main' into ckissane.add-zstd.0-cmake


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/lit.site.cfg.py.in
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -37,6 +37,7 @@
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.have_libxar = @LLVM_HAVE_LIBXAR@
 config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
 config.have_curl = @LLVM_ENABLE_CURL@
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -73,6 +73,12 @@
   find_package(ZLIB)
 endif()
 
+set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@)
+if(LLVM_ENABLE_ZSTD)
+  set(ZSTD_ROOT @ZSTD_ROOT@)
+  find_package(ZSTD)
+endif()
+
 set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@)
 if(LLVM_ENABLE_LIBXML2)
   find_package(LibXml2)
Index: llvm/cmake/modules/FindZSTD.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindZSTD.cmake
@@ -0,0 +1,21 @@
+find_path(ZSTD_INCLUDE_DIR
+  NAMES zstd.h
+  HINTS ${ZSTD_ROOT_DIR}/include)
+
+find_library(ZSTD_LIBRARY
+  NAMES zstd
+  HINTS ${ZSTD_ROOT_DIR}/lib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ZSTD DEFAULT_MSG
+ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
+
+if(ZSTD_FOUND)
+set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
+set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(
+  ZSTD_INCLUDE_DIR
+  ZSTD_LIBRARY)
Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -136,6 +136,27 @@
   set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
 endif()
 
+if(LLVM_ENABLE_ZSTD)
+  if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
+find_package(ZSTD REQUIRED)
+  elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
+find_package(ZSTD)
+  endif()
+  if(ZSTD_FOUND)
+# Check if zstd we found is usable; for example, we may have found a 32-bit
+# library on a 64-bit system which would result in a link-time failure.
+cmake_push_check_state()
+list(APPEND CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
+check_symbol_exists(ZSTD_compress zstd.h HAVE_ZSTD)
+cmake_pop_check_state()
+if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON AND NOT HAVE_ZSTD)
+  message(FATAL_ERROR "Failed to configure zstd")
+endif()
+  endif()
+  set(LLVM_ENABLE_ZSTD "${HAVE_ZSTD}")
+endif()
+
 if(LLVM_ENABLE_LIBXML2)
   if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
 find_package(LibXml2 REQUIRED)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/C

[PATCH] D128550: [OpenMP] Change OpenMP code generation for target region entries

2022-07-08 Thread Joseph Huber 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 rG1fff116645b3: [OpenMP] Change OpenMP code generation for 
target region entries (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128550

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_data_member_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_codegen_02.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_06.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_08.cpp
  clang/test/OpenMP/target_map_codegen_09.cpp
  clang/test/OpenMP/target_map_codegen_10.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_16.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_19.cpp
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_21.cpp
  clang/test/OpenMP/target_map_codegen_22.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_24.cpp
  clang/test/OpenMP/target_map_codegen_25.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_30.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_33.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_names.cpp
  clang/test/OpenMP/target_map_names_attr.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_paral

[PATCH] D128816: [OpenMP] Add loop tripcount argument to kernel launch and remove push function

2022-07-08 Thread Joseph Huber 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 rG5300263c70da: [OpenMP] Add loop tripcount argument to kernel 
launch and remove push function (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128816

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_proc_bind_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute

[PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane 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 rGf07caf20b9d3: [llvm] cmake config groundwork to have ZSTD in 
LLVM (authored by ckissane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/lit.site.cfg.py.in
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -37,6 +37,7 @@
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.have_libxar = @LLVM_HAVE_LIBXAR@
 config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
 config.have_curl = @LLVM_ENABLE_CURL@
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -73,6 +73,12 @@
   find_package(ZLIB)
 endif()
 
+set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@)
+if(LLVM_ENABLE_ZSTD)
+  set(ZSTD_ROOT @ZSTD_ROOT@)
+  find_package(ZSTD)
+endif()
+
 set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@)
 if(LLVM_ENABLE_LIBXML2)
   find_package(LibXml2)
Index: llvm/cmake/modules/FindZSTD.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindZSTD.cmake
@@ -0,0 +1,21 @@
+find_path(ZSTD_INCLUDE_DIR
+  NAMES zstd.h
+  HINTS ${ZSTD_ROOT_DIR}/include)
+
+find_library(ZSTD_LIBRARY
+  NAMES zstd
+  HINTS ${ZSTD_ROOT_DIR}/lib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ZSTD DEFAULT_MSG
+ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
+
+if(ZSTD_FOUND)
+set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
+set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(
+  ZSTD_INCLUDE_DIR
+  ZSTD_LIBRARY)
Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -136,6 +136,27 @@
   set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
 endif()
 
+if(LLVM_ENABLE_ZSTD)
+  if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
+find_package(ZSTD REQUIRED)
+  elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
+find_package(ZSTD)
+  endif()
+  if(ZSTD_FOUND)
+# Check if zstd we found is usable; for example, we may have found a 32-bit
+# library on a 64-bit system which would result in a link-time failure.
+cmake_push_check_state()
+list(APPEND CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
+check_symbol_exists(ZSTD_compress zstd.h HAVE_ZSTD)
+cmake_pop_check_state()
+if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON AND NOT HAVE_ZSTD)
+  message(FATAL_ERROR "Failed to configure zstd")
+endif()
+  endif()
+  set(LLVM_ENABLE_ZSTD "${HAVE_ZSTD}")
+endif()
+
 if(LLVM_ENABLE_LIBXML2)
   if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
 find_package(LibXml2 REQUIRED)
Index: llvm/CMakeLists.txt
=

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-08 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

Is there an llvm/utils script to update clang tests that have RUN lines at the 
top? An example is clang/test/OpenMP/debug_threadprivate_copyin.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D102107#3639551 , @dhruvachak 
wrote:

> Is there an llvm/utils script to update clang tests that have RUN lines at 
> the top? An example is clang/test/OpenMP/debug_threadprivate_copyin.c.

You can create the run lines with the `llvm/utils/update_cc_test_checks.py` 
script but those tests have manual lines for now.
I usually run `llvm/utils/update_cc_test_checks.py -u 
clang/test/OpenMP/*.{c,cpp}` to update all autogenerated tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D129389: [clang][deps] Override dependency and serialized diag files for modules

2022-07-08 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jansvoboda11, Bigcheese.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When building modules, override secondary outputs (dependency file, dependency 
targets, serialized diagnostic file) in addition to the pcm file path. This 
avoids inheriting per-TU command-line options that cause non-determinism in the 
results (non-deterministic command-line for the module build, non-determinism 
in which TU's .diag and .d files will contain the module outputs). In 
clang-scan-deps we infer whether to generate dependency or serialized 
diagnostic files based on an original command-line. In a real build system this 
should be modeled explicitly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129389

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
  clang/test/ClangScanDeps/generate-modules-path-args.c
  clang/test/ClangScanDeps/preserved-args.c
  clang/test/ClangScanDeps/removed-args.c
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -288,11 +288,16 @@
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-ID.CommandLine = GenerateModulesPathArgs
- ? FD.getCommandLine(
-   [&](ModuleID MID) { return lookupPCMPath(MID); })
- : FD.getCommandLineWithoutModulePaths();
-
+if (Inputs.size() == 0)
+  inferOutputOptions(FD.OriginalCommandLine);
+
+ID.CommandLine =
+GenerateModulesPathArgs
+? FD.getCommandLine(
+  [&](ModuleID MID) -> const ModuleOutputOptions & {
+return lookupModuleOutputs(MID);
+  })
+: FD.getCommandLineWithoutModulePaths();
 Inputs.push_back(std::move(ID));
   }
 
@@ -325,7 +330,9 @@
   {"command-line",
GenerateModulesPathArgs
? MD.getCanonicalCommandLine(
- [&](ModuleID MID) { return lookupPCMPath(MID); })
+ [&](ModuleID MID) -> const ModuleOutputOptions & {
+   return lookupModuleOutputs(MID);
+ })
: MD.getCanonicalCommandLineWithoutModulePaths()},
   };
   OutModules.push_back(std::move(O));
@@ -352,11 +359,17 @@
   }
 
 private:
-  StringRef lookupPCMPath(ModuleID MID) {
-auto PCMPath = PCMPaths.insert({MID, ""});
-if (PCMPath.second)
-  PCMPath.first->second = constructPCMPath(MID);
-return PCMPath.first->second;
+  const ModuleOutputOptions &lookupModuleOutputs(const ModuleID &MID) {
+auto MO = ModuleOutputs.insert({MID, {}});
+if (MO.second) {
+  ModuleOutputOptions &Opts = MO.first->second;
+  Opts.ModuleFile = constructPCMPath(MID);
+  if (DependencyOutputFile)
+Opts.DependencyFile = Opts.ModuleFile + ".d";
+  if (SerializeDiags)
+Opts.DiagnosticSerializationFile = Opts.ModuleFile + ".diag";
+}
+return MO.first->second;
   }
 
   /// Construct a path for the explicitly built PCM.
@@ -375,6 +388,19 @@
 return std::string(ExplicitPCMPath);
   }
 
+  /// Infer whether modules should write serialized diagnostic, .d, etc.
+  ///
+  /// A build system should model this directly, but here we infer it from an
+  /// original TU command.
+  void inferOutputOptions(ArrayRef Args) {
+for (StringRef Arg : Args) {
+  if (Arg == "-serialize-diagnostics")
+SerializeDiags = true;
+  else if (Arg == "-M" || Arg == "-MM" || Arg == "-MMD" || Arg == "-MD")
+DependencyOutputFile = true;
+}
+  }
+
   struct IndexedModuleID {
 ModuleID ID;
 mutable size_t InputIndex;
@@ -404,8 +430,11 @@
   std::mutex Lock;
   std::unordered_map
   Modules;
-  std::unordered_map PCMPaths;
+  std::unordered_map
+  ModuleOutputs;
   std::vector Inputs;
+  bool SerializeDiags = false;
+  bool DependencyOutputFile = false;
 };
 
 static bool handleFullDependencyToolResult(
Index: clang/test/ClangScanDeps/removed-args.c
===
--- clang/test/ClangScanDeps/removed-args.c
+++ clang/test/ClangScanDeps/removed-args.c
@@ -29,6 +29,9 @@
 // CHECK-NOT:  "-fbuild-session-timestamp=
 // CHECK-NOT:  "-fmodules-prune-interval=
 // CHECK-NOT:  "-fmodules-prune-after=
+// CHECK-NOT:  "-dependency-file"
+// CHECK-NOT: 

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-08 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

In D102107#3639556 , @jdoerfert wrote:

> In D102107#3639551 , @dhruvachak 
> wrote:
>
>> Is there an llvm/utils script to update clang tests that have RUN lines at 
>> the top? An example is clang/test/OpenMP/debug_threadprivate_copyin.c.
>
> You can create the run lines with the `llvm/utils/update_cc_test_checks.py` 
> script but those tests have manual lines for now.
> I usually run `llvm/utils/update_cc_test_checks.py -u 
> clang/test/OpenMP/*.{c,cpp}` to update all autogenerated tests.

Okay, I will convert those few manual OpenMP tests to autogen format.

How about the AST ones? Do they have to be manually updated? Example: 
clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D129393: [Clang] Fix the wrong features being derivec in the offload packager

2022-07-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, ye-luo, tra.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a project: clang.

The offload packager embeds the features in the offloading binary when
performing LTO. This had an incorrect interaction with the
`--cuda-feature` option because we weren't deriving the features from
the CUDA toolchain arguments when it was being specified. This patch
fixes this so the features are correctly overrideen when using this
argument.

However, this brings up a question of how best to handle conflicting
target features. The user could compile many libraries with different
features, in this case we do not know which one to pick. This was not
previously a problem when we simply passed the features in from the CUDA
installation at link-link because we just defaulted to whatever was
current on the system.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129393

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/openmp-offload-gpu-new.c


Index: clang/test/Driver/openmp-offload-gpu-new.c
===
--- clang/test/Driver/openmp-offload-gpu-new.c
+++ clang/test/Driver/openmp-offload-gpu-new.c
@@ -120,3 +120,9 @@
 // RUN: -foffload-lto %s 2>&1 | FileCheck 
--check-prefix=CHECK-LTO-FEATURES %s
 
 // CHECK-LTO-FEATURES: 
clang-offload-packager{{.*}}--image={{.*}}feature=+ptx{{[0-9]+}}
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
--offload-arch=sm_52 -nogpulib \
+// RUN: -Xopenmp-target=nvptx64-nvidia-cuda --cuda-feature=+ptx64 
-foffload-lto %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-SET-FEATURES %s
+
+// CHECK-SET-FEATURES: clang-offload-packager{{.*}}--image={{.*}}feature=+ptx64
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8325,7 +8325,8 @@
 
 ArgStringList Features;
 SmallVector FeatureArgs;
-getTargetFeatures(TC->getDriver(), TC->getTriple(), Args, Features, false);
+getTargetFeatures(TC->getDriver(), TC->getTriple(), TCArgs, Features,
+  false);
 llvm::copy_if(Features, std::back_inserter(FeatureArgs),
   [](StringRef Arg) { return !Arg.startswith("-target"); });
 


Index: clang/test/Driver/openmp-offload-gpu-new.c
===
--- clang/test/Driver/openmp-offload-gpu-new.c
+++ clang/test/Driver/openmp-offload-gpu-new.c
@@ -120,3 +120,9 @@
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-FEATURES %s
 
 // CHECK-LTO-FEATURES: clang-offload-packager{{.*}}--image={{.*}}feature=+ptx{{[0-9]+}}
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp --offload-arch=sm_52 -nogpulib \
+// RUN: -Xopenmp-target=nvptx64-nvidia-cuda --cuda-feature=+ptx64 -foffload-lto %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-SET-FEATURES %s
+
+// CHECK-SET-FEATURES: clang-offload-packager{{.*}}--image={{.*}}feature=+ptx64
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8325,7 +8325,8 @@
 
 ArgStringList Features;
 SmallVector FeatureArgs;
-getTargetFeatures(TC->getDriver(), TC->getTriple(), Args, Features, false);
+getTargetFeatures(TC->getDriver(), TC->getTriple(), TCArgs, Features,
+  false);
 llvm::copy_if(Features, std::back_inserter(FeatureArgs),
   [](StringRef Arg) { return !Arg.startswith("-target"); });
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-07-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D128927#3638973 , @ldionne wrote:

> Thanks @mstorsjo! Regarding `_LIBCPP_EXPERIMENTAL_FUNC_VIS`, yes I think it 
> would make sense to use a different visibility macro for symbols that we know 
> are provided only as part of a static library. I would not call it 
> `_LIBCPP_EXPERIMENTAL_FUNC_VIS` though, I would call it something like 
> `_LIBCPP_STATIC_LIBRARY_FUNC_VIS` or something like that.

Sure, `_LIBCPP_STATIC_LIBRARY_FUNC_VIS` sounds good to me too.




Comment at: libcxx/utils/libcxx/test/params.py:68
+  if hasCompileFlag(cfg, '-funstable') and False: # TODO: Enable this once the 
design of `-funstable` is finished
+return '-funstable'
+  else:

ldionne wrote:
> mstorsjo wrote:
> > Actually, I'm not entirely convinced that this is a good way to handle 
> > linking against the library for tests.
> > 
> > When building tests, we don't rely on the compiler to implicitly link in 
> > our C++ library, but we link with `-nostdlib++` (or `-nodefaultlibs`) and 
> > explicitly tell the compiler how to link in specifically the C++ library 
> > we've just built (in the test config files).
> > 
> > So in general, if linking with `-nostdlib++ -fexperimental-library` I kinda 
> > wouldn't expect the compiler driver to link against the library at all? 
> > It's kinda the same as if you'd do `-stdlib=libstdc++ 
> > -fexperimental-library` - we can't have that add `-lc++experimental`, as 
> > that only makes sense as long as we have `-stdlib=libc++`. So subsequently 
> > I don't think the compiler driver should be adding `-lc++experimental` as 
> > long as we're passing `-nostdlib++` either?
> > 
> > But if libc++experimental is built unconditionally, wouldn't it be simplest 
> > to just always link against it in the test config files (just like how we 
> > force it to link against specifically the just-built libc++.a) - that would 
> > make it much more symmetrcial to how we handle the main `-lc++`?
> Interesting point. It does mean that we can never rely on `-funstable` adding 
> `-lc++experimental` from our test suite -- I think that's OK.
> 
> However, I'd like to avoid linking against `-lc++experimental` in the base 
> test configuration, simply because the base test configuration should mirror 
> the minimal way of invoking Clang to use libc++.
Yep. Also another example of why we can't really rely on the compiler driver 
adding it - technically I guess the compiler driver might even choose not to 
pass a generic `-lc++` or `-lc++experimental`, but pass an absolute path to the 
`libc++.{a,so,dylib}` that is bundled with the compiler (clang does this for 
compiler-rt builtins) - so we really do need to rely on `-nodefaultlibs` and/or 
`-nostdlib++` omitting the compiler-provided defaults.

Keeping adding `-lc++experimental` here instead of adding it in the base config 
files is fine with me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D102107#3639615 , @dhruvachak 
wrote:

> In D102107#3639556 , @jdoerfert 
> wrote:
>
>> In D102107#3639551 , @dhruvachak 
>> wrote:
>>
>>> Is there an llvm/utils script to update clang tests that have RUN lines at 
>>> the top? An example is clang/test/OpenMP/debug_threadprivate_copyin.c.
>>
>> You can create the run lines with the `llvm/utils/update_cc_test_checks.py` 
>> script but those tests have manual lines for now.
>> I usually run `llvm/utils/update_cc_test_checks.py -u 
>> clang/test/OpenMP/*.{c,cpp}` to update all autogenerated tests.
>
> Okay, I will convert those few manual OpenMP tests to autogen format.
>
> How about the AST ones? Do they have to be manually updated? Example: 
> clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c

For these ones I have a script locally (attached) that need some manual doing 
but it helps:

  1. run the ast dump and store the result (same as RUN line), e.g.,
{F23722650} clang -cc1 -internal-isystem 
/data/build/llvm-project/lib/clang/13.0.0/include -nostdsysteminc -triple 
x86_64-unknown-unknown -fopenmp -verify -ast-dump 
/data/src/llvm-project/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_4.cpp
 &> /tmp/ast
  2. python3 ast_dump_2_check.py /tmp/ast CHECK
  3. replace the check lines with the content of /tmp/ast.check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


  1   2   >