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

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

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?

> I would try to add more tests about C++20 Modules.

of course, more tests can be useful, but it would be better to try to be 
specific - it does not crash for any of the tests in the clang test suite.


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] D128715: [clang-tidy] Fix confusable identifiers interaction with DeclContext

2022-07-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/61559/step_8.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128715

___
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-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

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:

  unhandled type: 0x7cda9e0 LValueReferenceType 0x7cda9e0 'const struct 
std::_PairT &'
  `-QualType 0x7cd85f1 'const struct std::_PairT' const
`-RecordType 0x7cd85f0 'struct std::_PairT'
  `-CXXRecord 0x7cd8540 '_PairT'
  unhandled type: 0x7cdabb0 RValueReferenceType 0x7cdabb0 'struct std::_PairT 
&&'
  `-RecordType 0x7cd85f0 'struct std::_PairT'
`-CXXRecord 0x7cd8540 '_PairT'
  unhandled type: 0x80e0400 LValueReferenceType 0x80e0400 'struct std::_PairT &'
  `-RecordType 0x7cd85f0 'struct std::_PairT'
`-CXXRecord 0x7cd8540 '_PairT'
  unhandled type: 0x7c0e1a0 TemplateTypeParmType 0x7c0e1a0 '_T1' dependent 
depth 0 index 0
  `-TemplateTypeParm 0x7c0e148 '_T1'
  unhandled type: 0x7c0e220 TemplateTypeParmType 0x7c0e220 '_T2' dependent 
depth 0 index 1
  `-TemplateTypeParm 0x7c0e1d0 '_T2'
  unhandled type: 0x7c0e6a0 LValueReferenceType 0x7c0e6a0 'const pair<_T1, _T2> 
&' dependent
  `-QualType 0x7ace031 'const pair<_T1, _T2>' const
`-InjectedClassNameType 0x7ace030 'pair<_T1, _T2>' dependent
  `-CXXRecord 0x7c0e290 'pair'
  unhandled type: 0x7c0e8e0 RValueReferenceType 0x7c0e8e0 'pair<_T1, _T2> &&' 
dependent
  `-InjectedClassNameType 0x7ace030 'pair<_T1, _T2>' dependent
`-CXXRecord 0x7c0e290 'pair'
  clang++: 
/home/chuanqi.xcq/workspace.xuchuanqi/llvm-project-for-work/clang/lib/Sema/SemaModule.cpp:1084:
 void clang::Sema::markGMFDeclsReachableFrom(clang::Decl*, bool): Assertion 
`T->isRecordType() && "base not a record?"' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: clang++ -std=c++20 --precompile 
-fprebuilt-module-path=. coroutine.cppm -o std-coroutine.pcm -isystem 
../build_libcxx/include/c++/v1 
-I../build_libcxx/include/x86_64-unknown-linux-gnu/c++/v1 -nostdinc++
  1. parser at end of file
  2.../build_libcxx/include/c++/v1/__functional/hash.h:308:12: 
instantiating function definition 'std::__scalar_hash::operator()'
  3.../build_libcxx/include/c++/v1/__functional/hash.h:93:18: instantiating 
function definition 'std::__murmur2_or_cityhash::operator()'
   #0 0x01f60f90 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
   #1 0x01f5ede4 llvm::sys::CleanupOnSignal(unsigned long) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x1f5ede4)
   #2 0x01eaa468 CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
   #3 0x77fb29d0 __restore_rt sigaction.c:0:0
   #4 0x77675f35 raise (/lib64/libc.so.6+0x3bf35)
   #5 0x7765f8d7 abort (/lib64/libc.so.6+0x258d7)
   #6 0x7765f7a7 _nl_load_domain.cold loadmsgcat.c:0:0
   #7 0x7766e536 (/lib64/libc.so.6+0x34536)
   #8 0x04696390 clang::Sema::markGMFDeclsReachableFrom(clang::Decl*, 
bool) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x4696390)
   #9 0x04695d87 clang::Sema::markGMFDeclsReachableFrom(clang::Decl*, 
bool) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x4695d87)
  #10 0x04696559 clang::Sema::findGMFReachableDeclsForType(clang::Type 
const*) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x4696559)
  #11 0x0469689b clang::Sema::findGMFReachableDeclExprs(clang::Stmt*) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x469689b)
  #12 0x046967bd clang::Sema::findGMFReachableDeclExprs(clang::Stmt*) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x46967bd)
  #13 0x046967bd clang::Sema::findGMFReachableDeclExprs(clang::Stmt*) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x46967bd)
  #14 0x046967bd clang::Sema::findGMFReachableDeclExprs(clang::Stmt*) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x46967bd)
  #15 0x046967bd clang::Sema::findGMFReachableDeclExprs(clang::Stmt*) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x46967bd)
  #16 0x046958c2 clang::Sema::markGMFDeclsReachableFrom(clang::Decl*, 
bool) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x46958c2)
  #17 0x04695749 clang::Sema::markGMFDeclsReachableFrom(clang::Decl*, 
bool) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x4695749)
  #18 0x04695e75 clang::Sema::markGMFDeclsReachableFrom(clang::Decl*, 
bool) 
(/disk2/workspace.xuchuanqi/llvm-project-for-work/build/bin/clang-14+0x4695e75)
  

[PATCH] D125291: Introduce @llvm.threadlocal.address intrinsic to access TLS variable

2022-07-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

FWIW the bitcode patch has landed, so implementing the variant using a token 
type should be possible now. I'm not sure whether it's better to start with the 
current patch where the intrinsic is optional, or go directly to the one where 
it is required.




Comment at: llvm/docs/LangRef.rst:24415
+
+  declare ptr @llvm.threadlocal.address(ptr) nounwind readnone willreturn
+

Don't we need to overload this intrinsic by return type, so it works with 
different address spaces?



Comment at: llvm/docs/LangRef.rst:24420
+
+The first argument is pointer, which refers to a thread local variable.
+

Should we enforce here (with a verifier check) that the argument is a 
thread-local global variable? I assume we //don't// want to allow weird things 
like `@llvm.threadlocal.address(c ? @g1 : @g2)` right? (Though I guess, without 
thread-local globals using a token type, nothing would prevent optimizations 
from forming this.)



Comment at: llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp:231
+  Changed |= lowerThreadLocalIntrinsics(F);
+  break;
 }

I don't think this belongs here, this should get dropped by SelectionDAGBuilder.



Comment at: 
llvm/test/Transforms/PreISelIntrinsicLowering/threadlocal_address.ll:1
+; RUN: opt -pre-isel-intrinsic-lowering -opaque-pointers -S -o - < %s | 
FileCheck %s
+

`-opaque-pointers` flag is not necessary.


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

https://reviews.llvm.org/D125291

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442188.
Codesbyusman added a comment.

All changes in one place


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/modules-ts.cppm


Index: clang/test/SemaCXX/modules-ts.cppm
===
--- clang/test/SemaCXX/modules-ts.cppm
+++ clang/test/SemaCXX/modules-ts.cppm
@@ -54,7 +54,7 @@
   ;   // expected-warning {{ISO C++20 does not permit an empty declaration 
to appear in an export block}}
 }
 export {   // expected-note {{begins here}}
-  static_assert(true); // expected-warning {{ISO C++20 does not permit a 
static_assert declaration to appear in an export block}}
+  static_assert(true); // expected-warning {{ISO C++20 does not permit a 
static assertion declaration to appear in an export block}}
 }
 
 int use_b = b;
Index: clang/test/SemaCXX/cxx98-compat.cpp
===
--- clang/test/SemaCXX/cxx98-compat.cpp
+++ clang/test/SemaCXX/cxx98-compat.cpp
@@ -152,7 +152,7 @@
 void no_except() noexcept; // expected-warning {{noexcept specifications are 
incompatible with C++98}}
 bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept 
expressions are incompatible with C++98}}
 void *null = nullptr; // expected-warning {{'nullptr' is incompatible with 
C++98}}
-static_assert(true, "!"); // expected-warning {{static assertion declarations 
are incompatible with C++98}}
+static_assert(true, "!"); // expected-warning {{static_assert declarations are 
incompatible with C++98}}
 
 struct InhCtorBase {
   InhCtorBase(int);
Index: 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
===
--- 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
+++ 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -81,4 +81,4 @@
   // expected-note@-3{{during template argument deduction for variable 
template partial specialization 'v1' [with T = int]}}
   // expected-error@-4{{static assertion failed due to requirement 'v1'}}
 
-}
\ No newline at end of file
+}
Index: clang/test/CXX/module/module.interface/p3.cpp
===
--- clang/test/CXX/module/module.interface/p3.cpp
+++ clang/test/CXX/module/module.interface/p3.cpp
@@ -11,7 +11,7 @@
 
 export { // expected-note 3{{export block begins here}}
   ; // expected-error {{ISO C++20 does not permit an empty declaration to 
appear in an export block}}
-  static_assert(true); // expected-error {{ISO C++20 does not permit a 
static_assert declaration to appear in an export block}}
+  static_assert(true); // expected-error {{ISO C++20 does not permit a static 
assertion declaration to appear in an export block}}
   using namespace A;   // expected-error {{ISO C++20 does not permit using 
directive to be exported}}
 }
 
Index: clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
@@ -44,4 +44,4 @@
   requires a == 0; // expected-note{{because 'a == 0' would be invalid: 
constraint variable 'a' cannot be used in an evaluated context}}
 };
   static_assert(C2); // expected-note{{because 'int' does not satisfy 
'C2'}} expected-error{{static assertion failed}}
-}
\ No newline at end of file
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11130,7 +11130,7 @@
   "export declaration appears within anonymous namespace">;
 def note_anonymous_namespace : Note<"anonymous namespace begins here">;
 def ext_export_no_name_block : ExtWarn<
-  "ISO C++20 does not permit %select{an empty|a static_assert}0 declaration "
+  "ISO C++20 does not permit %select{an empty|a static assertion}0 declaration 
"
   "to appear in an export block">, InGroup;
 def ext_export_no_names : ExtWarn<
   "ISO C++20 does not permit a declaration that does not introduce any names "
@@ -11139,7 +11139,7 @@
   "declaration does not introduce any names to be exported">;
 def note_export : Note<"export block begins here">;
 def err_export_no_name : Error<
-  "%select{empty|static_assert|asm}0 declaration cannot be exported">;
+  "%select{empt

[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442189.
Codesbyusman added a comment.

all changes in one patch revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/Modules/cxx20-10-2-ex7.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/Parser/objc-static-assert.m
  clang/test/Parser/objc-static-assert.mm
  clang/test/Sema/builtin-align.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/access-base-class.cpp
  clang/test/SemaCXX/alias-template.cpp
  clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/complex-folding.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx2a-template-lambdas.cpp
  clang/test/SemaCXX/delete-and-function-templates.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/modules-ts.cppm
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/static-assert-cxx17.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/test/SemaCXX/using-decl-templates.cpp
  clang/test/SemaCXX/weak-init.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/pr52909.cpp
  clang/test/SemaTemplate/pr52970.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -184,7 +184,7 @@
 
 namespace Diags {
   struct A { int n, m; };
-  template struct X { static_assert(a.n == a.m); }; // expected-error {{static_assert failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
+  template struct X { static_assert(a.n == a.m); }; // expected-error {{static assertion failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
   template struct X; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}}
 }
 
Index: clang/test/SemaTemplate/pr52970.cpp
===
--- clang/test/SemaTemplate/pr52970.cpp
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -32,7 +32,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingFunctionName
@@ -57,7 +57,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingPointer
Index: clang/test/SemaTemplate/pr52909.cpp
===
--- clang/test/SemaTemplate/pr52909.cpp
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -15,7 +15,7 @@
   // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
 };
 
-static_assert(Beginable); // expected-error {{static_assert failed}}
+static_assert(Beginable); // expected-error {{static assertion failed}}
  // expected-note@-1 {{does not satisfy 'Beginable'}}
 } // namespace PR52905
 
@@ -48,7 +48,7 @@
 static void begin(double);
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
 
 } // namespace PR52909b
@@ -65,7 +65,7 @@
 int *f() const;
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
 
 } // namespace PR53075
Index: clang/test/SemaTemplate/instantiate-var-template.cpp
===
--- clang/test/SemaTemplate/instantiate-var-template.cpp
+++ clang/test/SemaTemplate/instantiate-var-templa

[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442191.
Codesbyusman added a comment.

all


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/modules-ts.cppm


Index: clang/test/SemaCXX/modules-ts.cppm
===
--- clang/test/SemaCXX/modules-ts.cppm
+++ clang/test/SemaCXX/modules-ts.cppm
@@ -54,7 +54,7 @@
   ;   // expected-warning {{ISO C++20 does not permit an empty declaration 
to appear in an export block}}
 }
 export {   // expected-note {{begins here}}
-  static_assert(true); // expected-warning {{ISO C++20 does not permit a 
static_assert declaration to appear in an export block}}
+  static_assert(true); // expected-warning {{ISO C++20 does not permit a 
static assertion declaration to appear in an export block}}
 }
 
 int use_b = b;
Index: clang/test/SemaCXX/cxx98-compat.cpp
===
--- clang/test/SemaCXX/cxx98-compat.cpp
+++ clang/test/SemaCXX/cxx98-compat.cpp
@@ -152,7 +152,7 @@
 void no_except() noexcept; // expected-warning {{noexcept specifications are 
incompatible with C++98}}
 bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept 
expressions are incompatible with C++98}}
 void *null = nullptr; // expected-warning {{'nullptr' is incompatible with 
C++98}}
-static_assert(true, "!"); // expected-warning {{static assertion declarations 
are incompatible with C++98}}
+static_assert(true, "!"); // expected-warning {{static_assert declarations are 
incompatible with C++98}}
 
 struct InhCtorBase {
   InhCtorBase(int);
Index: 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
===
--- 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
+++ 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -81,4 +81,4 @@
   // expected-note@-3{{during template argument deduction for variable 
template partial specialization 'v1' [with T = int]}}
   // expected-error@-4{{static assertion failed due to requirement 'v1'}}
 
-}
\ No newline at end of file
+}
Index: clang/test/CXX/module/module.interface/p3.cpp
===
--- clang/test/CXX/module/module.interface/p3.cpp
+++ clang/test/CXX/module/module.interface/p3.cpp
@@ -11,7 +11,7 @@
 
 export { // expected-note 3{{export block begins here}}
   ; // expected-error {{ISO C++20 does not permit an empty declaration to 
appear in an export block}}
-  static_assert(true); // expected-error {{ISO C++20 does not permit a 
static_assert declaration to appear in an export block}}
+  static_assert(true); // expected-error {{ISO C++20 does not permit a static 
assertion declaration to appear in an export block}}
   using namespace A;   // expected-error {{ISO C++20 does not permit using 
directive to be exported}}
 }
 
Index: clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
@@ -44,4 +44,4 @@
   requires a == 0; // expected-note{{because 'a == 0' would be invalid: 
constraint variable 'a' cannot be used in an evaluated context}}
 };
   static_assert(C2); // expected-note{{because 'int' does not satisfy 
'C2'}} expected-error{{static assertion failed}}
-}
\ No newline at end of file
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11130,7 +11130,7 @@
   "export declaration appears within anonymous namespace">;
 def note_anonymous_namespace : Note<"anonymous namespace begins here">;
 def ext_export_no_name_block : ExtWarn<
-  "ISO C++20 does not permit %select{an empty|a static_assert}0 declaration "
+  "ISO C++20 does not permit %select{an empty|a static assertion}0 declaration 
"
   "to appear in an export block">, InGroup;
 def ext_export_no_names : ExtWarn<
   "ISO C++20 does not permit a declaration that does not introduce any names "
@@ -11139,7 +11139,7 @@
   "declaration does not introduce any names to be exported">;
 def note_export : Note<"export block begins here">;
 def err_export_no_name : Error<
-  "%select{empty|static_assert|asm}0 declaration cannot be exported">;
+  "%select{empty|static assertion|as

[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-07-05 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Ran some internal benchmarks on 1570 files (C and C++ mixed but much more C++ 
than C):

Running clang-extdef-mapping on the source files took: 268s 
Running clang-extdef-mapping on the AST: 102s

That's quite a large speed up if you already need to generate the AST files.

I'll fix the variable names and then merge this one unless someone complains.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442197.
Codesbyusman added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/modules-ts.cppm


Index: clang/test/SemaCXX/modules-ts.cppm
===
--- clang/test/SemaCXX/modules-ts.cppm
+++ clang/test/SemaCXX/modules-ts.cppm
@@ -54,7 +54,7 @@
   ;   // expected-warning {{ISO C++20 does not permit an empty declaration 
to appear in an export block}}
 }
 export {   // expected-note {{begins here}}
-  static_assert(true); // expected-warning {{ISO C++20 does not permit a 
static_assert declaration to appear in an export block}}
+  static_assert(true); // expected-warning {{ISO C++20 does not permit a 
static assertion declaration to appear in an export block}}
 }
 
 int use_b = b;
Index: clang/test/SemaCXX/cxx98-compat.cpp
===
--- clang/test/SemaCXX/cxx98-compat.cpp
+++ clang/test/SemaCXX/cxx98-compat.cpp
@@ -152,7 +152,7 @@
 void no_except() noexcept; // expected-warning {{noexcept specifications are 
incompatible with C++98}}
 bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept 
expressions are incompatible with C++98}}
 void *null = nullptr; // expected-warning {{'nullptr' is incompatible with 
C++98}}
-static_assert(true, "!"); // expected-warning {{static assertion declarations 
are incompatible with C++98}}
+static_assert(true, "!"); // expected-warning {{static_assert declarations are 
incompatible with C++98}}
 
 struct InhCtorBase {
   InhCtorBase(int);
Index: 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
===
--- 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
+++ 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -81,4 +81,4 @@
   // expected-note@-3{{during template argument deduction for variable 
template partial specialization 'v1' [with T = int]}}
   // expected-error@-4{{static assertion failed due to requirement 'v1'}}
 
-}
\ No newline at end of file
+}
Index: clang/test/CXX/module/module.interface/p3.cpp
===
--- clang/test/CXX/module/module.interface/p3.cpp
+++ clang/test/CXX/module/module.interface/p3.cpp
@@ -11,7 +11,7 @@
 
 export { // expected-note 3{{export block begins here}}
   ; // expected-error {{ISO C++20 does not permit an empty declaration to 
appear in an export block}}
-  static_assert(true); // expected-error {{ISO C++20 does not permit a 
static_assert declaration to appear in an export block}}
+  static_assert(true); // expected-error {{ISO C++20 does not permit a static 
assertion declaration to appear in an export block}}
   using namespace A;   // expected-error {{ISO C++20 does not permit using 
directive to be exported}}
 }
 
Index: clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
@@ -44,4 +44,4 @@
   requires a == 0; // expected-note{{because 'a == 0' would be invalid: 
constraint variable 'a' cannot be used in an evaluated context}}
 };
   static_assert(C2); // expected-note{{because 'int' does not satisfy 
'C2'}} expected-error{{static assertion failed}}
-}
\ No newline at end of file
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11130,7 +11130,7 @@
   "export declaration appears within anonymous namespace">;
 def note_anonymous_namespace : Note<"anonymous namespace begins here">;
 def ext_export_no_name_block : ExtWarn<
-  "ISO C++20 does not permit %select{an empty|a static_assert}0 declaration "
+  "ISO C++20 does not permit %select{an empty|a static assertion}0 declaration 
"
   "to appear in an export block">, InGroup;
 def ext_export_no_names : ExtWarn<
   "ISO C++20 does not permit a declaration that does not introduce any names "
@@ -11139,7 +11139,7 @@
   "declaration does not introduce any names to be exported">;
 def note_export : Note<"export block begins here">;
 def err_export_no_name : Error<
-  "%select{empty|static_assert|asm}0 declaration cannot be exported">;
+  "%select{empty|static assertion

[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442199.
Codesbyusman added a comment.

new changes as required -- final


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/Modules/cxx20-10-2-ex7.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/Parser/objc-static-assert.m
  clang/test/Parser/objc-static-assert.mm
  clang/test/Sema/builtin-align.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/access-base-class.cpp
  clang/test/SemaCXX/alias-template.cpp
  clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/complex-folding.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx2a-template-lambdas.cpp
  clang/test/SemaCXX/delete-and-function-templates.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/modules-ts.cppm
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/static-assert-cxx17.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/test/SemaCXX/using-decl-templates.cpp
  clang/test/SemaCXX/weak-init.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/pr52909.cpp
  clang/test/SemaTemplate/pr52970.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -184,7 +184,7 @@
 
 namespace Diags {
   struct A { int n, m; };
-  template struct X { static_assert(a.n == a.m); }; // expected-error {{static_assert failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
+  template struct X { static_assert(a.n == a.m); }; // expected-error {{static assertion failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
   template struct X; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}}
 }
 
Index: clang/test/SemaTemplate/pr52970.cpp
===
--- clang/test/SemaTemplate/pr52970.cpp
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -32,7 +32,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingFunctionName
@@ -57,7 +57,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingPointer
Index: clang/test/SemaTemplate/pr52909.cpp
===
--- clang/test/SemaTemplate/pr52909.cpp
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -15,7 +15,7 @@
   // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
 };
 
-static_assert(Beginable); // expected-error {{static_assert failed}}
+static_assert(Beginable); // expected-error {{static assertion failed}}
  // expected-note@-1 {{does not satisfy 'Beginable'}}
 } // namespace PR52905
 
@@ -48,7 +48,7 @@
 static void begin(double);
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
 
 } // namespace PR52909b
@@ -65,7 +65,7 @@
 int *f() const;
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
 
 } // namespace PR53075
Index: clang/test/SemaTemplate/instantiate-var-template.cpp
===
--- clang/test/SemaTemplate/instantiate-var-template.cpp
+++ clang/test/SemaTemplate/instantiate-var-templat

[clang] 4de0680 - Fix use of pointer arithmetic instead of iterators.

2022-07-05 Thread Manuel Klimek via cfe-commits

Author: Manuel Klimek
Date: 2022-07-05T08:23:42Z
New Revision: 4de0680fbf4e4a9b9136ab5ee1ca549954eb8590

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

LOG: Fix use of pointer arithmetic instead of iterators.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index d3383292f7a38..97c3d86282a02 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -15,6 +15,7 @@
 #include "UnwrappedLineParser.h"
 #include "FormatToken.h"
 #include "TokenAnnotator.h"
+#include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1910,15 +1911,12 @@ void UnwrappedLineParser::parseStructuralElement(
 break;
 
   auto OneTokenSoFar = [&]() {
-const UnwrappedLineNode *Tok = &Line->Tokens.front(),
-*End = Tok + Line->Tokens.size();
-while (Tok != End && Tok->Tok->is(tok::comment))
-  ++Tok;
-// In Verilog, macro invocations start with a backtick which the code
-// treats as a hash.  Skip it.
-if (Style.isVerilog() && Tok != End && Tok->Tok->is(tok::hash))
-  ++Tok;
-return End - Tok == 1;
+auto I = Line->Tokens.begin(), E = Line->Tokens.end();
+while (I != E && I->Tok->is(tok::comment))
+  ++I;
+while (I != E && Style.isVerilog() && I->Tok->is(tok::hash))
+  ++I;
+return I != E && (++I == E);
   };
   if (OneTokenSoFar()) {
 if (FormatTok->is(tok::colon) && !Line->MustBeDeclaration) {



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


[PATCH] D128415: [ARM] Add Support for Cortex-M85

2022-07-05 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

@tschuett I've corrected the patch based on your feedback. If you're happy, I'm 
going to land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128415

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


[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-07-05 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 442211.
thieta marked 3 inline comments as done.
thieta added a comment.

Uppercase all variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Analysis/func-mapping-test.cpp
  clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp

Index: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
===
--- clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -1,4 +1,4 @@
-//===- ClangExtDefMapGen.cpp ---===//
+//===- ClangExtDefMapGen.cpp -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,10 +13,12 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -29,12 +31,16 @@
 using namespace clang::cross_tu;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangExtDefMapGenCategory("clang-extdefmapgen options");
+static cl::OptionCategory
+ClangExtDefMapGenCategory("clang-extdefmapgen options");
 
 class MapExtDefNamesConsumer : public ASTConsumer {
 public:
-  MapExtDefNamesConsumer(ASTContext &Context)
-  : Ctx(Context), SM(Context.getSourceManager()) {}
+  MapExtDefNamesConsumer(ASTContext &Context,
+ StringRef astFilePath = StringRef())
+  : Ctx(Context), SM(Context.getSourceManager()) {
+CurrentFileName = astFilePath.str();
+  }
 
   ~MapExtDefNamesConsumer() {
 // Flush results to standard output.
@@ -111,6 +117,82 @@
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 
+static IntrusiveRefCntPtr Diags;
+
+IntrusiveRefCntPtr GetDiagnosticsEngine() {
+  if (Diags) {
+// Call reset to make sure we don't mix errors
+Diags->Reset(false);
+return Diags;
+  }
+
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  DiagClient->setPrefix("clang-extdef-mappping");
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+
+  IntrusiveRefCntPtr DiagEngine(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+  Diags.swap(DiagEngine);
+
+  // Retain this one time so it's not destroyed by ASTUnit::LoadFromASTFile
+  Diags->Retain();
+  return Diags;
+}
+
+static CompilerInstance *CI = nullptr;
+
+static bool HandleAST(StringRef AstPath) {
+
+  if (!CI)
+CI = new CompilerInstance();
+
+  IntrusiveRefCntPtr DiagEngine = GetDiagnosticsEngine();
+
+  std::unique_ptr Unit = ASTUnit::LoadFromASTFile(
+  AstPath.str(), CI->getPCHContainerOperations()->getRawReader(),
+  ASTUnit::LoadASTOnly, DiagEngine, CI->getFileSystemOpts());
+
+  if (!Unit)
+return false;
+
+  FileManager FM(CI->getFileSystemOpts());
+  SmallString<128> AbsPath(AstPath);
+  FM.makeAbsolutePath(AbsPath);
+
+  MapExtDefNamesConsumer Consumer =
+  MapExtDefNamesConsumer(Unit->getASTContext(), AbsPath);
+  Consumer.HandleTranslationUnit(Unit->getASTContext());
+
+  return true;
+}
+
+static int HandleFiles(ArrayRef SourceFiles,
+   CompilationDatabase &compilations) {
+  std::vector SourcesToBeParsed;
+
+  // Loop over all input files, if they are pre-compiled AST
+  // process them directly in HandleAST, otherwise put them
+  // on a list for ClangTool to handle.
+  for (StringRef Src : SourceFiles) {
+if (Src.endswith(".ast")) {
+  if (!HandleAST(Src)) {
+return 1;
+  }
+} else {
+  SourcesToBeParsed.push_back(Src.str());
+}
+  }
+
+  if (!SourcesToBeParsed.empty()) {
+ClangTool Tool(compilations, SourcesToBeParsed);
+return Tool.run(newFrontendActionFactory().get());
+  }
+
+  return 0;
+}
+
 int main(int argc, const char **argv) {
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0], false);
@@ -118,7 +200,10 @@
 
   const char *Overview = "\nThis tool collects the USR name and location "
  "of external definitions in the source files "
- "(excluding headers).\n";
+ "(excluding headers).\n"
+ "Input can be either source files that are compiled "
+ "with compile database or .ast files that are "
+   

[PATCH] D128715: [clang-tidy] Fix confusable identifiers interaction with DeclContext

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

In D128715#3629253 , @thakis wrote:

> Looks like this breaks tests on windows: 
> http://45.33.8.238/win/61559/step_8.txt

I'm on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128715

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


[PATCH] D129118: CommandLine: add and use cl::SubCommand::get{All,TopLevel}

2022-07-05 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle created this revision.
nhaehnle added reviewers: efriedma, lattner.
Herald added subscribers: ayermolo, hiraditya.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added subscribers: cfe-commits, yota9.
Herald added projects: clang, LLVM.

Prefer using these accessors to access the special sub-commands
corresponding to the top-level (no subcommand) and all sub-commands.

This is a preparatory step towards removing the use of ManagedStatic:
with a subsequent change, these global instances will be moved to
be regular function-scope statics.

It is split up to give downstream projects a (albeit short) window in
which they can switch to using the accessors in a forward-compatible
way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129118

Files:
  bolt/lib/Utils/CommandLineOpts.cpp
  bolt/tools/driver/llvm-bolt.cpp
  clang/lib/Tooling/CommonOptionsParser.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/tools/llvm-xray/llvm-xray.cpp
  llvm/unittests/Support/CommandLineInit/CommandLineInitTest.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -99,7 +99,7 @@
   static const char ValueString[] = "Integer";
 
   StringMap &Map =
-  cl::getRegisteredOptions(*cl::TopLevelSubCommand);
+  cl::getRegisteredOptions(cl::SubCommand::getTopLevel());
 
   ASSERT_EQ(Map.count("test-option"), 1u) << "Could not find option in map.";
 
@@ -420,7 +420,7 @@
   << "Hid extra option that should be visable.";
 
   StringMap &Map =
-  cl::getRegisteredOptions(*cl::TopLevelSubCommand);
+  cl::getRegisteredOptions(cl::SubCommand::getTopLevel());
   ASSERT_TRUE(Map.count("help") == (size_t)0 ||
   cl::NotHidden == Map["help"]->getOptionHiddenFlag())
   << "Hid default option that should be visable.";
@@ -446,7 +446,7 @@
   << "Hid extra option that should be visable.";
 
   StringMap &Map =
-  cl::getRegisteredOptions(*cl::TopLevelSubCommand);
+  cl::getRegisteredOptions(cl::SubCommand::getTopLevel());
   ASSERT_TRUE(Map.count("help") == (size_t)0 ||
   cl::NotHidden == Map["help"]->getOptionHiddenFlag())
   << "Hid default option that should be visable.";
@@ -529,7 +529,7 @@
   cl::ResetCommandLineParser();
 
   StackSubCommand SC1("sc1", "First subcommand");
-  StackOption AllOpt("everywhere", cl::sub(*cl::AllSubCommands),
+  StackOption AllOpt("everywhere", cl::sub(cl::SubCommand::getAll()),
cl::init(false));
   StackSubCommand SC2("sc2", "Second subcommand");
 
@@ -566,8 +566,8 @@
 TEST(CommandLineTest, ReparseCommandLineOptions) {
   cl::ResetCommandLineParser();
 
-  StackOption TopLevelOpt("top-level", cl::sub(*cl::TopLevelSubCommand),
-cl::init(false));
+  StackOption TopLevelOpt(
+  "top-level", cl::sub(cl::SubCommand::getTopLevel()), cl::init(false));
 
   const char *args[] = {"prog", "-top-level"};
 
@@ -614,10 +614,12 @@
 TEST(CommandLineTest, RemoveFromTopLevelSubCommand) {
   cl::ResetCommandLineParser();
 
-  StackOption TopLevelRemove(
-  "top-level-remove", cl::sub(*cl::TopLevelSubCommand), cl::init(false));
-  StackOption TopLevelKeep(
-  "top-level-keep", cl::sub(*cl::TopLevelSubCommand), cl::init(false));
+  StackOption TopLevelRemove("top-level-remove",
+   cl::sub(cl::SubCommand::getTopLevel()),
+   cl::init(false));
+  StackOption TopLevelKeep("top-level-keep",
+ cl::sub(cl::SubCommand::getTopLevel()),
+ cl::init(false));
 
   const char *args[] = {"prog", "-top-level-remove"};
 
@@ -638,9 +640,9 @@
 
   StackSubCommand SC1("sc1", "First Subcommand");
   StackSubCommand SC2("sc2", "Second Subcommand");
-  StackOption RemoveOption("remove-option", cl::sub(*cl::AllSubCommands),
- cl::init(false));
-  StackOption KeepOption("keep-option", cl::sub(*cl::AllSubCommands),
+  StackOption RemoveOption(
+  "remove-option", cl::sub(cl::SubCommand::getAll()), cl::init(false));
+  StackOption KeepOption("keep-option", cl::sub(cl::SubCommand::getAll()),
cl::init(false));
 
   const char *args0[] = {"prog", "-remove-option"};
@@ -719,13 +721,13 @@
 TEST(CommandLineTest, DefaultOptions) {
   cl::ResetCommandLineParser();
 
-  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+  StackOption Bar("bar", cl::sub(cl::SubCommand::getAll()),
cl::DefaultOption);
   StackOption Bar_Alias(
   "b", cl::desc("Alias for -bar"),

[PATCH] D129131: Remove uses of llvm_shutdown

2022-07-05 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle created this revision.
nhaehnle added reviewers: efriedma, lattner.
Herald added a reviewer: bollu.
Herald added subscribers: anlunx, bzcheeseman, ayermolo, sdasgup3, wenzhicui, 
wrengr, dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, jvesely, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, hiraditya.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits, yota9, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

With the removal of ManagedStatic, llvm_shutdown will be removed as
well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129131

Files:
  bolt/tools/driver/llvm-bolt.cpp
  bolt/tools/merge-fdata/merge-fdata.cpp
  clang/include/clang/Frontend/CompilerInstance.h
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp
  clang/utils/TableGen/TableGen.cpp
  libclc/utils/prepare-builtins.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-test/lldb-test.cpp
  lldb/unittests/Utility/LogTest.cpp
  lldb/utils/TableGen/LLDBTableGen.cpp
  llvm/examples/BrainF/BrainFDriver.cpp
  llvm/examples/HowToUseJIT/HowToUseJIT.cpp
  llvm/include/llvm/PassRegistry.h
  llvm/include/llvm/Support/DynamicLibrary.h
  llvm/include/llvm/Support/InitLLVM.h
  llvm/lib/IR/Pass.cpp
  llvm/lib/Support/InitLLVM.cpp
  llvm/lib/Support/Unix/DynamicLibrary.inc
  llvm/lib/Support/Unix/Signals.inc
  llvm/lib/Support/Windows/DynamicLibrary.inc
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
  llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
  llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
  llvm/utils/KillTheDoctor/KillTheDoctor.cpp
  mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
  polly/lib/External/isl/interface/extract_interface.cc

Index: polly/lib/External/isl/interface/extract_interface.cc
===
--- polly/lib/External/isl/interface/extract_interface.cc
+++ polly/lib/External/isl/interface/extract_interface.cc
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -587,7 +586,6 @@
 
 	delete sema;
 	delete Clang;
-	llvm::llvm_shutdown();
 
 	if (Diags.hasErrorOccurred())
 		return EXIT_FAILURE;
Index: mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
===
--- mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
+++ mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
@@ -62,7 +62,6 @@
 }
 
 int main(int argc, char **argv) {
-  llvm::llvm_shutdown_obj x;
   registerPassManagerCLOptions();
 
   llvm::InitLLVM y(argc, argv);
Index: llvm/utils/KillTheDoctor/KillTheDoctor.cpp
===
--- llvm/utils/KillTheDoctor/KillTheDoctor.cpp
+++ llvm/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -36,7 +36,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -297,7 +296,6 @@
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0]);
   PrettyStackTraceProgram X(argc, argv);
-  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   ToolName = argv[0];
 
Index: llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
===
--- llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
@@ -9,7 +9,6 @@
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
@@ -59,7 +58,6 @@
 TEST(DynamicLibrary, Overload) {
   {
 std::string Err;
-llvm_shutdown_obj Shutdown;
 DynamicLibrary DL =
 DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err);
 EXPECT_TRUE(DL.isValid());
@@ -109,9 +107,6 @@
   }
   EXPECT_TRUE(FuncPtr(DynamicLibrary::SearchForAddressOfSymbol(
   "TestA")) == nullptr);
-
-  // Check serach ordering is reset to default after call to llvm_shutdown
-  EXPECT_EQ(DynamicLibrary::SearchOrder, DynamicLibrary::SO_Linker);
 }
 
 TEST(DynamicLibrary, Shutdown) {
@@ -119,7 +114,6 @@
   std::vector Order;
   {
 std::string Err;
-llvm_shutdown_obj Shutdown;
 DynamicLibrary DL =
 DynamicLibrary::getPermanentLibrary(LibPath(A).c_str(), &Err);
 EXPECT_TRUE(DL.isVal

[clang] f8e658e - [OpenCL] Remove fast_ half geometric builtins

2022-07-05 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-07-05T10:22:34+01:00
New Revision: f8e658ec9ff5b82d0c1f9d54d78c137b539319ca

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

LOG: [OpenCL] Remove fast_ half geometric builtins

These are not mentioned in the OpenCL C Specification nor in the
OpenCL Extension Specification.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index ed647d9e9c064..72a6bfeafd6a2 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -10467,12 +10467,6 @@ float __ovld __cnfn fast_distance(float, float);
 float __ovld __cnfn fast_distance(float2, float2);
 float __ovld __cnfn fast_distance(float3, float3);
 float __ovld __cnfn fast_distance(float4, float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_distance(half, half);
-half __ovld __cnfn fast_distance(half2, half2);
-half __ovld __cnfn fast_distance(half3, half3);
-half __ovld __cnfn fast_distance(half4, half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns the length of vector p computed as:
@@ -10482,12 +10476,6 @@ float __ovld __cnfn fast_length(float);
 float __ovld __cnfn fast_length(float2);
 float __ovld __cnfn fast_length(float3);
 float __ovld __cnfn fast_length(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_length(half);
-half __ovld __cnfn fast_length(half2);
-half __ovld __cnfn fast_length(half3);
-half __ovld __cnfn fast_length(half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns a vector in the same direction as p but with a
@@ -10514,12 +10502,6 @@ float __ovld __cnfn fast_normalize(float);
 float2 __ovld __cnfn fast_normalize(float2);
 float3 __ovld __cnfn fast_normalize(float3);
 float4 __ovld __cnfn fast_normalize(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_normalize(half);
-half2 __ovld __cnfn fast_normalize(half2);
-half3 __ovld __cnfn fast_normalize(half3);
-half4 __ovld __cnfn fast_normalize(half4);
-#endif //cl_khr_fp16
 
 // OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
 



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


[PATCH] D128436: [OpenCL] Remove fast_ half geometric builtins

2022-07-05 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8e658ec9ff5: [OpenCL] Remove fast_ half geometric builtins 
(authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128436

Files:
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -10467,12 +10467,6 @@
 float __ovld __cnfn fast_distance(float2, float2);
 float __ovld __cnfn fast_distance(float3, float3);
 float __ovld __cnfn fast_distance(float4, float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_distance(half, half);
-half __ovld __cnfn fast_distance(half2, half2);
-half __ovld __cnfn fast_distance(half3, half3);
-half __ovld __cnfn fast_distance(half4, half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns the length of vector p computed as:
@@ -10482,12 +10476,6 @@
 float __ovld __cnfn fast_length(float2);
 float __ovld __cnfn fast_length(float3);
 float __ovld __cnfn fast_length(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_length(half);
-half __ovld __cnfn fast_length(half2);
-half __ovld __cnfn fast_length(half3);
-half __ovld __cnfn fast_length(half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns a vector in the same direction as p but with a
@@ -10514,12 +10502,6 @@
 float2 __ovld __cnfn fast_normalize(float2);
 float3 __ovld __cnfn fast_normalize(float3);
 float4 __ovld __cnfn fast_normalize(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_normalize(half);
-half2 __ovld __cnfn fast_normalize(half2);
-half3 __ovld __cnfn fast_normalize(half3);
-half4 __ovld __cnfn fast_normalize(half4);
-#endif //cl_khr_fp16
 
 // OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
 


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -10467,12 +10467,6 @@
 float __ovld __cnfn fast_distance(float2, float2);
 float __ovld __cnfn fast_distance(float3, float3);
 float __ovld __cnfn fast_distance(float4, float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_distance(half, half);
-half __ovld __cnfn fast_distance(half2, half2);
-half __ovld __cnfn fast_distance(half3, half3);
-half __ovld __cnfn fast_distance(half4, half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns the length of vector p computed as:
@@ -10482,12 +10476,6 @@
 float __ovld __cnfn fast_length(float2);
 float __ovld __cnfn fast_length(float3);
 float __ovld __cnfn fast_length(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_length(half);
-half __ovld __cnfn fast_length(half2);
-half __ovld __cnfn fast_length(half3);
-half __ovld __cnfn fast_length(half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns a vector in the same direction as p but with a
@@ -10514,12 +10502,6 @@
 float2 __ovld __cnfn fast_normalize(float2);
 float3 __ovld __cnfn fast_normalize(float3);
 float4 __ovld __cnfn fast_normalize(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_normalize(half);
-half2 __ovld __cnfn fast_normalize(half2);
-half3 __ovld __cnfn fast_normalize(half3);
-half4 __ovld __cnfn fast_normalize(half4);
-#endif //cl_khr_fp16
 
 // OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128166: ManagedStatic: Destroy from destructor

2022-07-05 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.
Herald added a subscriber: anlunx.

Abandoning this in favor of removing ManagedStatic entirely via the stack of 
changes that ends in D129134 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128166

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm created this revision.
peterwaller-arm added reviewers: rsandifo-arm, kristof.beyls.
Herald added subscribers: ctetreau, tschuett.
Herald added a project: All.
peterwaller-arm requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

D127209  fixed LLVM to bring it in line with 
the AAPCS. This affects
functions where the first SVE parameter appears in the 9th or later
arguments, and the function does not return an SVE type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129135

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,15 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, LLVM now only preserves the z8-z23 registers across
+  a call if the registers z0-z7 are used to pass data into or out of a
+  subroutine. This new behavior now matches the AAPCS. Previously LLVM
+  preserved z8-z23 across a call if the callee had an SVE type anywhere
+  in its signature. This would cause an incorrect use of the
+  caller-preserved z8-z23 ABI for example if the 9th argument to a
+  function were an SVE type. The analogous issue and fix applies to
+  predicate register arguments (p0-p3 for passing between subroutines,
+  and p4-15 preserved).
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted 
constructor,
   fixing dr2171.


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,15 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, LLVM now only preserves the z8-z23 registers across
+  a call if the registers z0-z7 are used to pass data into or out of a
+  subroutine. This new behavior now matches the AAPCS. Previously LLVM
+  preserved z8-z23 across a call if the callee had an SVE type anywhere
+  in its signature. This would cause an incorrect use of the
+  caller-preserved z8-z23 ABI for example if the 9th argument to a
+  function were an SVE type. The analogous issue and fix applies to
+  predicate register arguments (p0-p3 for passing between subroutines,
+  and p4-15 preserved).
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted constructor,
   fixing dr2171.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f6fa998 - Fix tests with non-default CLANG_DEFAULT_LINKER

2022-07-05 Thread Yi Kong via cfe-commits

Author: Yi Kong
Date: 2022-07-05T17:26:34+08:00
New Revision: f6fa9985900ee757a2cfce0f472ff1fc84463242

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

LOG: Fix tests with non-default CLANG_DEFAULT_LINKER

Force -fuse-ld option, as some other tests in the same file do.

Added: 


Modified: 
clang/test/Driver/instrprof-ld.c

Removed: 




diff  --git a/clang/test/Driver/instrprof-ld.c 
b/clang/test/Driver/instrprof-ld.c
index 3a6cdab10c393..9a58cd3a0be75 100644
--- a/clang/test/Driver/instrprof-ld.c
+++ b/clang/test/Driver/instrprof-ld.c
@@ -154,7 +154,7 @@
 //
 // RUN: %clang -### %s 2>&1 \
 // RUN: --target=i386-pc-win32 -fprofile-instr-generate \
-// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -resource-dir=%S/Inputs/resource_dir -fuse-ld=link \
 // RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-I386 %s
 //
 // CHECK-WINDOWS-I386: "{{.*}}link{{(.exe)?}}"
@@ -162,7 +162,7 @@
 //
 // RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-pc-win32 -fprofile-instr-generate \
-// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: -resource-dir=%S/Inputs/resource_dir -fuse-ld=link \
 // RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64 %s
 //
 // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"



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


[PATCH] D128415: [ARM] Add Support for Cortex-M85

2022-07-05 Thread Thorsten via Phabricator via cfe-commits
tschuett accepted this revision.
tschuett added a comment.

LGTM.

Please update the summary before you commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128415

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss accepted this revision.
danielkiss added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

From reading the release note my understanding is that before this fix the 
caller of a function would store `z0-z7` in situations where it did not need 
to. Which seems low impact unless you were doing something that read the 
previous stack frame (but nevertheless a difference from the AAPCS).

If that's what you were trying to get across then great!

> This affects functions where the first SVE parameter appears in the 9th or 
> later arguments

I'm reading 
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#642parameter-passing-rules.
 Wouldn't the type of the preceding 8 arguments also be relevant?

Though I was surprised to see that "NSRN" covers floating point and SVE 
registers, so I'm hardly an expert here.

> and the function does not return an SVE type.

This is because the function would return in `z0` therefore the caller must 
preserve at least `z0` and the ABI tells you to preserve `z0-z7` to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[clang] 1666f09 - [ARM] Add Support for Cortex-M85

2022-07-05 Thread Archibald Elliott via cfe-commits

Author: Archibald Elliott
Date: 2022-07-05T10:43:31+01:00
New Revision: 1666f09933eefdd666be4c46887ba59ae089361c

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

LOG: [ARM] Add Support for Cortex-M85

This patch adds support for Arm's Cortex-M85 CPU. The Cortex-M85 CPU is
an Arm v8.1m Mainline CPU, with optional support for MVE and PACBTI,
both of which are enabled by default.

Parts have been coauthored by by Mark Murray, Alexandros Lamprineas and
David Green.

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

Added: 
clang/test/Driver/arm-nopacbti-disabled-features.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/test/CodeGen/arm-target-features.c
clang/test/Driver/arm-cortex-cpus-2.c
clang/test/Driver/arm-nofp-disabled-features.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Target/ARM/ARM.td
llvm/test/CodeGen/ARM/build-attributes.ll
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3342f6208c4f8..f074d1bf204f7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -537,6 +537,10 @@ DWARF Support in Clang
 Arm and AArch64 Support in Clang
 
 
+- clang now supports the Cortex-M85 CPU, which can be chosen with
+  `-mcpu=cortex-m85`. By default, this has PACBTI turned on, but it can be
+  disabled with `-mcpu=cortex-m85+nopacbti`.
+
 Floating Point Support in Clang
 ---
 

diff  --git a/clang/test/CodeGen/arm-target-features.c 
b/clang/test/CodeGen/arm-target-features.c
index 8dbd90080a532..d0569c2d59443 100644
--- a/clang/test/CodeGen/arm-target-features.c
+++ b/clang/test/CodeGen/arm-target-features.c
@@ -110,4 +110,7 @@
 // RUN: %clang_cc1 -triple thumb-linux-gnueabi -target-cpu cortex-m55 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-ARMV81M-MAIN-LINUX
 // CHECK-ARMV81M-MAIN-LINUX: 
"target-features"="+armv8.1-m.main,+dsp,+fp-armv8d16,+fp-armv8d16sp,+fp16,+fp64,+fullfp16,+hwdiv,+lob,+mve,+mve.fp,+ras,+thumb-mode,+vfp2,+vfp2sp,+vfp3d16,+vfp3d16sp,+vfp4d16,+vfp4d16sp"
 
+// RUN: %clang_cc1 -triple thumb-linux-gnueabi -target-cpu cortex-m85 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-ARMV81M-CORTEX-M85-LINUX
+// CHECK-ARMV81M-CORTEX-M85-LINUX: 
"target-features"="+armv8.1-m.main,+dsp,+fp-armv8d16,+fp-armv8d16sp,+fp16,+fp64,+fullfp16,+hwdiv,+lob,+mve,+mve.fp,+pacbti,+ras,+thumb-mode,+vfp2,+vfp2sp,+vfp3d16,+vfp3d16sp,+vfp4d16,+vfp4d16sp"
+
 void foo() {}

diff  --git a/clang/test/Driver/arm-cortex-cpus-2.c 
b/clang/test/Driver/arm-cortex-cpus-2.c
index 7d2c38b7cc0e3..5441e4da2462c 100644
--- a/clang/test/Driver/arm-cortex-cpus-2.c
+++ b/clang/test/Driver/arm-cortex-cpus-2.c
@@ -559,6 +559,9 @@
 // RUN: %clang -target arm -mcpu=cortex-m55 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CORTEX-M55 %s
 // CHECK-CORTEX-M55:  "-cc1"{{.*}} "-triple" "thumbv8.1m.main-{{.*}} 
"-target-cpu" "cortex-m55"
 
+// RUN: %clang -target arm -mcpu=cortex-m85 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CORTEX-M85 %s
+// CHECK-CORTEX-M85:  "-cc1"{{.*}} "-triple" "thumbv8.1m.main-{{.*}} 
"-target-cpu" "cortex-m85"
+
 // RUN: %clang -target arm -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-NEOVERSE-N2 %s
 // CHECK-NEOVERSE-N2: "-cc1"{{.*}} "-triple" "armv8.5a-{{.*}}" "-target-cpu" 
"neoverse-n2"
 

diff  --git a/clang/test/Driver/arm-nofp-disabled-features.c 
b/clang/test/Driver/arm-nofp-disabled-features.c
index 432e4a98cffc6..247d67084d21a 100644
--- a/clang/test/Driver/arm-nofp-disabled-features.c
+++ b/clang/test/Driver/arm-nofp-disabled-features.c
@@ -9,8 +9,10 @@
 // RUN: %clang -target arm-arm-none-eabi -mfpu=none %s -### 2>&1 | FileCheck %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8-a+nofp %s -### 2>&1 | 
FileCheck %s
 // RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a35+nofp %s -### 2>&1 | 
FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-m85+nofp %s -### 2>&1 | 
FileCheck %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8-a+nofp+nomve %s -### 
2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOMVE
 // RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a35+nofp+nomve %s -### 
2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOMVE
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-m85+nofp+nomve %s -### 
2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOMVE
 // CHECK: "-target-feature" "-dotprod"
 // CHECK: "-target-feature" "-fp16fml"
 // CHECK: "-target-feature" "-bf16"

diff  --git a/clang/test/Driver/arm-nopacbti-disabled-features.c 
b/clang/test/Driver/arm-nopacbti-disabled-features.c
new file mode 100644
i

[PATCH] D128415: [ARM] Add Support for Cortex-M85

2022-07-05 Thread Sam Elliott 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 rG1666f09933ee: [ARM] Add Support for Cortex-M85 (authored by 
lenary).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128415

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/CodeGen/arm-target-features.c
  clang/test/Driver/arm-cortex-cpus-2.c
  clang/test/Driver/arm-nofp-disabled-features.c
  clang/test/Driver/arm-nopacbti-disabled-features.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/ARM/ARM.td
  llvm/test/CodeGen/ARM/build-attributes.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -395,13 +395,19 @@
  ARM::AEK_FP | ARM::AEK_RAS | ARM::AEK_LOB |
  ARM::AEK_FP16,
  "8.1-M.Mainline"),
+ARMCPUTestParams("cortex-m85", "armv8.1-m.main",
+ "fp-armv8-fullfp16-d16",
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_SIMD |
+ ARM::AEK_FP | ARM::AEK_RAS | ARM::AEK_LOB |
+ ARM::AEK_FP16 | ARM::AEK_PACBTI,
+ "8.1-M.Mainline"),
 ARMCPUTestParams("iwmmxt", "iwmmxt", "none", ARM::AEK_NONE, "iwmmxt"),
 ARMCPUTestParams("xscale", "xscale", "none", ARM::AEK_NONE, "xscale"),
 ARMCPUTestParams("swift", "armv7s", "neon-vfpv4",
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
  "7-S")));
 
-static constexpr unsigned NumARMCPUArchs = 88;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/ARM/build-attributes.ll
===
--- llvm/test/CodeGen/ARM/build-attributes.ll
+++ llvm/test/CodeGen/ARM/build-attributes.ll
@@ -235,6 +235,8 @@
 ; RUN: llc < %s -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve.fp | FileCheck %s --check-prefix=ARMv81M-MAIN-MVEFP
 ; RUN: llc < %s -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+pacbti | FileCheck %s --check-prefix=ARMv81M-MAIN-PACBTI
 ; RUN: llc < %s -mtriple=arm-none-none-eabi -mcpu=cortex-m55 | FileCheck %s --check-prefix=CORTEX-M55
+; RUN: llc < %s -mtriple=arm-none-none-eabi -mcpu=cortex-m85 | FileCheck %s --check-prefix=CORTEX-M85
+; RUN: llc < %s -mtriple=arm-none-none-eabi -mcpu=cortex-m85+nopacbti | FileCheck %s --check-prefix=CHECK-NO-PACBTI
 
 ; CPU-SUPPORTED-NOT: is not a recognized processor for this target
 
@@ -1748,6 +1750,23 @@
 ; CORTEX-M55: .eabi_attribute 38, 1
 ; CORTEX-M55: .eabi_attribute 14, 0
 
+; CORTEX-M85: .cpu cortex-m85
+; CORTEX-M85: .eabi_attribute 6, 21   @ Tag_CPU_arch
+; CORTEX-M85: .eabi_attribute 7, 77   @ Tag_CPU_arch_profile
+; CORTEX-M85: .eabi_attribute 8, 0@ Tag_ARM_ISA_use
+; CORTEX-M85: .eabi_attribute 9, 3@ Tag_THUMB_ISA_use
+; CORTEX-M85: .fpufpv5-d16
+; CORTEX-M85: .eabi_attribute 36, 1   @ Tag_FP_HP_extension
+; CORTEX-M85: .eabi_attribute 48, 2   @ Tag_MVE_arch
+; CORTEX-M85: .eabi_attribute 46, 1   @ Tag_DSP_extension
+; CORTEX-M85: .eabi_attribute 34, 1   @ Tag_CPU_unaligned_access
+; CORTEX-M85: .eabi_attribute 50, 2   @ Tag_PAC_extension
+; CORTEX-M85: .eabi_attribute 52, 2   @ Tag_BTI_extension
+
+; CHECK-NO-PACBTI-NOT: .eabi_attribute 50
+; CHECK-NO-PACBTI-NOT: .eabi_attribute 52
+
+
 define i32 @f(i64 %z) {
 ret i32 0
 }
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -1450,6 +1450,13 @@
  HasMVEFloatOps,
  FeatureFixCMSE_CVE_2021_35465]>;
 
+def : ProcessorModel<"cortex-m85", CortexM7Model,   [ARMv81mMainline,
+ FeatureDSP,
+ FeatureFPARMv8_D16,
+ FeaturePACBTI,
+ FeatureUseMISched,
+ HasMVEFloatOps]>;
+
 def : ProcNoItin<"cortex-a32",   [ARMv8a,
  FeatureHWDivThumb,
  FeatureHWDivARM,
Index: llvm/include/llvm/Support/ARMTargetParser.def
===
--

[PATCH] D128981: [C++20][Modules] Implement include translation.

2022-07-05 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 442242.
iains added a comment.

addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128981

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Modules/cxx20-include-translation.cpp

Index: clang/test/Modules/cxx20-include-translation.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-include-translation.cpp
@@ -0,0 +1,109 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h1.h -emit-header-unit -o h1.pcm
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h2.h -emit-header-unit -o h2.pcm
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h3.h -emit-header-unit -o h3.pcm
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h4.h -emit-header-unit -o h4.pcm
+
+// RUN: %clang_cc1 -std=c++20 Xlate.cpp -emit-module-interface -o Xlate.pcm \
+// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \
+// RUN: -fmodule-file=h4.pcm -fsyntax-only -Wauto-import -verify
+
+// Check that we do the intended translation and not more.
+// RUN: %clang_cc1 -std=c++20 Xlate.cpp \
+// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \
+// RUN: -fmodule-file=h4.pcm  -E -undef | FileCheck %s
+
+// We expect no diagnostics here, the used functions should all be available.
+// RUN: %clang_cc1 -std=c++20 Xlate.cpp -emit-module-interface \
+// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \
+// RUN: -fmodule-file=h4.pcm -fsyntax-only
+
+// The content of the headers is not terribly important, we just want to check
+// whether they are textually included or include-translated.
+//--- h1.h
+#ifndef H1_GUARD
+#define H1_GUARD
+
+#define ONE 1
+
+void foo();
+
+#endif // H1_GUARD
+
+//--- h2.h
+#ifndef H2_GUARD
+#define H2_GUARD
+
+#define TWO 2
+
+void bar();
+
+#endif // H2_GUARD
+
+//--- h3.h
+#ifndef H3_GUARD
+#define H3_GUARD
+
+#define THREE 3
+
+void baz();
+
+#endif // H3_GUARD
+
+//--- h4.h
+#ifndef H4_GUARD
+#define H4_GUARD
+
+#define FOUR 4
+
+void boo();
+
+#endif // H4_GUARD
+
+//--- h5.h
+#ifndef H5_GUARD
+#define H5_GUARD
+
+#define FIVE 5
+
+void five();
+
+#endif // H4_GUARD
+
+//--- Xlate.cpp
+/* some comment ...
+  ... */
+module /*nothing here*/;
+
+// This should be include-translated, when the header unit for h1 is available.
+#include "h1.h" // expected-warning {{treating #include as an import of module './h1.h'}}
+// Import of a header unit is allowed, named modules are not.
+import "h2.h";
+// A regular, untranslated, header
+#include "h5.h"
+
+export module Xlate;
+
+// This is OK, the import immediately follows the module decl.
+import "h3.h";
+
+// This should *not* be include-translated, even if header unit for h4 is
+// available.
+#include "h4.h"
+
+export void charlie() {
+  foo();
+  bar();
+  baz();
+  boo();
+  five();
+}
+
+// CHECK: #pragma clang module import "./h1.h"
+// CHECK: import ./h2.h
+// CHECK: import ./h3.h
+// CHECK-NOT: #pragma clang module import "./h4.h"
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -663,12 +663,22 @@
 return false;
   }
 
-  case tok::annot_module_include:
-Actions.ActOnModuleInclude(Tok.getLocation(),
-   reinterpret_cast(
-   Tok.getAnnotationValue()));
+  case tok::annot_module_include: {
+auto Loc = Tok.getLocation();
+Module *Mod = reinterpret_cast(Tok.getAnnotationValue());
+// FIXME: We need a better way to disambiguate C++ clang modules and
+// standard C++ modules.
+if (!getLangOpts().CPlusPlusModules || !Mod->isHeaderUnit())
+  Actions.ActOnModuleInclude(Loc, Mod);
+else {
+  DeclResult Import =
+  Actions.ActOnModuleImport(Loc, SourceLocation(), Loc, Mod);
+  Decl *ImportDecl = Import.isInvalid() ? nullptr : Import.get();
+  Result = Actions.ConvertDeclToDeclGroup(ImportDecl);
+}
 ConsumeAnnotationToken();
 return false;
+  }
 
   case tok::annot_module_begin:
 Actions.ActOnModuleBegin(Tok.getLocation(), reinterpret_cast(
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -941,6 +941,9 @@
 
   // Update ImportSeqState to track our position within a C++20 import-seq
   // if this token is being produced as a result of phase 4 of translation.
+  // Update TrackGMFState to decide if we are currently in a Global Module
+  // Fragment. GMF state updates should precede ImportSeq ones, since GMF state
+  // depends on the prevailing ImportSeq state in 

[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm added a comment.

In D129135#3629833 , @DavidSpickett 
wrote:

> From reading the release note my understanding is that before this fix the 
> caller of a function would store `z0-z7` in situations where it did not need 
> to.

I believe you are correct, with an inkling of doubt in the back of my mind, but 
I can't identify a specific worse issue at present.

> Wouldn't the type of the preceding 8 arguments also be relevant?

My intent was to express that the issue is present where it's the 9th or later 
arguments.

> This is because the function would return in `z0` therefore the caller must 
> preserve at least `z0` and the ABI tells you to preserve `z0-z7` to do that?

Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm added a comment.

In D129135#3629860 , @peterwaller-arm 
wrote:

> but I can't identify a specific worse issue at present.

Thinking a little harder, one breaking case is where a 
callee-compiled-with-wrong-logic looks at its signature, concludes it does not 
need to preserve the regs (because the SVE type is in the 9th argument, for 
example), but is called by a different compiler which correctly implements the 
ABI, so neither side preserves registers which require preservation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Could you cite a Diff where this was changed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[clang] f03b876 - Reland "Reland "[NFC] Add a missing test for for clang-repl""

2022-07-05 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-07-05T18:23:26+08:00
New Revision: f03b876e7e9567ee71ee66f8f194918aac37d5fa

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

LOG: Reland "Reland "[NFC] Add a missing test for for clang-repl""

This reverts commit 6956840b5c0029d7f8e043b3c77bb1ffc230e4d5.
Try to use `XFAIL: windows-msvc || ps4` to disable all unsupported targets.

Signed-off-by: Jun Zhang 

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index f5c70c21ac507..734127ea8eef6 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -3,6 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// XFAIL: windows-msvc || ps4
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -18,4 +19,8 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, 
reinterpret_casthttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129093: [pseudo] Eliminate LRTable::Action. NFC

2022-07-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h:84
-
-  // NOTE: there are no typical accept actions in the LRtable, accept
-  // actions are handled specifically in the parser -- if the parser

I think this comment has some value, it is worth to keep it in some form (might 
be append to the LRTable class comment).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129093

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:503
+- Targeting AArch64, LLVM now only preserves the z8-z23 registers across
+  a call if the registers z0-z7 are used to pass data into or out of a
+  subroutine. This new behavior now matches the AAPCS. Previously LLVM

Pedantically, I think it should be “the registers z0-z7 or p0-p3”.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[clang-tools-extra] 3897d3c - [clang-tidy] By-pass portability issues in confusable-identifiers test

2022-07-05 Thread via cfe-commits

Author: serge-sans-paille
Date: 2022-07-05T12:36:00+02:00
New Revision: 3897d3cf71efa50da755e2fc3514b6c2bd4f1433

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

LOG: [clang-tidy] By-pass portability issues in confusable-identifiers test

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
index 8529d1ef8e8b5..cdfed7edb431d 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
@@ -1,8 +1,8 @@
 // RUN: %check_clang_tidy %s misc-confusable-identifiers %t
 
-int fo;
-int 𝐟o;
-// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: '𝐟o' is confusable with 'fo' 
[misc-confusable-identifiers]
+int l0;
+int lO;
+// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'lO' is confusable with 'l0' 
[misc-confusable-identifiers]
 // CHECK-MESSAGES: :[[#@LINE-3]]:5: note: other declaration found here
 
 void no() {
@@ -12,9 +12,9 @@ void no() {
 void worry() {
   int foo;
 }
-int 𝐟i;
-int fi;
-// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'fi' is confusable with '𝐟i' 
[misc-confusable-identifiers]
+int l1;
+int ll;
+// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'll' is confusable with 'l1' 
[misc-confusable-identifiers]
 // CHECK-MESSAGES: :[[#@LINE-3]]:5: note: other declaration found here
 
 bool f0(const char *q1, const char *ql) {
@@ -55,14 +55,6 @@ void f5(int il) {
   // CHECK-MESSAGES: :[[#@LINE-3]]:20: note: other declaration found here
 }
 
-template 
-void f6() {
-  int OO = 0;
-  // CHECK-MESSAGES: :[[#@LINE-1]]:7: warning: 'OO' is confusable with 'O0' 
[misc-confusable-identifiers]
-  // CHECK-MESSAGES: :[[#@LINE-4]]:20: note: other declaration found here
-}
-int OO = 0; // no warning, not same scope as f6
-
 namespace f7 {
 int i1;
 }



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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

> My intent was to express that the issue is present where it's the 9th or 
> later arguments.

So I take from that that it does not matter if arguments 1-8 were all integers 
and so did not get put in SIMD/floating point registers. I think I am confusing 
what the ABI says (and what llvm *now does*) with the way the previous llvm 
behaviour. So the statement answers the question "of the functions in my 
project which ones might change", it's the ones where the first SVE type 
argument was argument 9 or greater.

Should the release note also say that the key is the *first* SVE type parameter 
being argument 9, not just having an SVE type in argument 9 at all?

Commit msg:

> This affects functions where the first SVE parameter appears in the 9th or 
> later arguments, and the function does not return an SVE type.

Note:

> This would cause an incorrect use of the caller-preserved z8-z23 ABI for 
> example if the 9th argument to a function were an SVE type.

Or in other words what about arguments 1-8, can they be SVE and still hit this 
issue? I realise this is not supposed to be a full on super detailed report but 
mentioning because the "first" stood out to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[clang] bc36618 - Correct XFAIL according to bot owner's advice

2022-07-05 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-07-05T18:46:59+08:00
New Revision: bc366183a5928d7a7d5fd9d6971f43ff1358

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

LOG: Correct XFAIL according to bot owner's advice

Signed-off-by: Jun Zhang 

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 734127ea8eef..b5dad4722c0b 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -3,7 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// XFAIL: windows-msvc || ps4
+// XFAIL: system-windows
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);



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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm updated this revision to Diff 442251.
peterwaller-arm added a comment.

- Cite D127209  in the release note per 
tschuett comment.
- Be more specific about p0-p4, remove 'by analogy', per rsandifo-arm comment.
- Clarify 9th argument or greater, per DavidSpicket comment.

Thank you everyone for your inputs, hope this addresses everything so far, 
happy to receive further input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,14 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p4 are
+  used to pass data into or out of a subroutine. The new behavior
+  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
+  a call if the callee had an SVE type anywhere in its signature. This
+  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
+  ABI for example if the 9th argument or greater were the first SVE type
+  in the signature of a function.
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted 
constructor,
   fixing dr2171.


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,14 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p4 are
+  used to pass data into or out of a subroutine. The new behavior
+  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
+  a call if the callee had an SVE type anywhere in its signature. This
+  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
+  ABI for example if the 9th argument or greater were the first SVE type
+  in the signature of a function.
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted constructor,
   fixing dr2171.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm marked an inline comment as done.
peterwaller-arm added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:503
+- Targeting AArch64, LLVM now only preserves the z8-z23 registers across
+  a call if the registers z0-z7 are used to pass data into or out of a
+  subroutine. This new behavior now matches the AAPCS. Previously LLVM

rsandifo-arm wrote:
> Pedantically, I think it should be “the registers z0-z7 or p0-p3”.
I've now switched to writing out all of the registers every time, hope that's 
clearer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm updated this revision to Diff 442253.
peterwaller-arm marked an inline comment as done.
peterwaller-arm edited the summary of this revision.
peterwaller-arm added a comment.

- Update commit message: "This affects" -> "The fix affects"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,14 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p4 are
+  used to pass data into or out of a subroutine. The new behavior
+  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
+  a call if the callee had an SVE type anywhere in its signature. This
+  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
+  ABI for example if the 9th argument or greater were the first SVE type
+  in the signature of a function.
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted 
constructor,
   fixing dr2171.


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,14 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p4 are
+  used to pass data into or out of a subroutine. The new behavior
+  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
+  a call if the callee had an SVE type anywhere in its signature. This
+  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
+  ABI for example if the 9th argument or greater were the first SVE type
+  in the signature of a function.
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted constructor,
   fixing dr2171.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

___
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-05 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 442257.
ckandeler marked 4 inline comments as done.
ckandeler added a comment.

Implemented reviewer suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128977

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -745,6 +745,23 @@
 int &operator[](int &);
 int operator[](int) const;
 };
+struct $Class_decl[[ClassWithStaticMember]] {
+static inline int $StaticField_decl_static[[j]] = 0;
+};
+struct $Class_decl[[ClassWithRefMembers]] {
+  $Class_decl[[ClassWithRefMembers]](int $Parameter_decl[[i]])
+: $Field[[i1]]($Parameter[[i]]),
+  $Field_readonly[[i2]]($Parameter[[i]]),
+  $Field[[i3]]($Parameter_usedAsMutableReference[[i]]),
+  $Field_readonly[[i4]]($Class[[ClassWithStaticMember]]::$StaticField_static[[j]]),
+  $Field[[i5]]($Class[[ClassWithStaticMember]]::$StaticField_static_usedAsMutableReference[[j]])
+  {}
+  int $Field_decl[[i1]];
+  const int &$Field_decl_readonly[[i2]];
+  int &$Field_decl[[i3]];
+  const int &$Field_decl_readonly[[i4]];
+  int &$Field_decl[[i5]];
+};
 void $Function_decl[[fun]](int, const int,
int*, const int*,
int&, const int&,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -523,6 +523,8 @@
 /// e.g. highlights dependent names and 'auto' as the underlying type.
 class CollectExtraHighlightings
 : public RecursiveASTVisitor {
+  using Base = RecursiveASTVisitor;
+
 public:
   CollectExtraHighlightings(HighlightingsBuilder &H) : H(H) {}
 
@@ -533,6 +535,13 @@
 return true;
   }
 
+  bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
+if (Init->isMemberInitializer())
+  if (auto *Member = Init->getMember())
+highlightMutableReferenceArgument(Member->getType(), Init->getInit());
+return Base::TraverseConstructorInitializer(Init);
+  }
+
   bool VisitCallExpr(CallExpr *E) {
 // Highlighting parameters passed by non-const reference does not really
 // make sense for literals...
@@ -542,8 +551,8 @@
 // FIXME: consider highlighting parameters of some other overloaded
 // operators as well
 llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()};
-if (const auto callOp = dyn_cast(E)) {
-  switch (callOp->getOperator()) {
+if (auto *CallOp = dyn_cast(E)) {
+  switch (CallOp->getOperator()) {
   case OO_Call:
   case OO_Subscript:
 Args = Args.drop_front(); // Drop object parameter
@@ -559,6 +568,33 @@
 return true;
   }
 
+  void highlightMutableReferenceArgument(QualType T, const Expr *Arg) {
+if (!Arg)
+  return;
+
+// Is this parameter passed by non-const reference?
+// FIXME The condition T->idDependentType() could be relaxed a bit,
+// e.g. std::vector& is dependent but we would want to highlight it
+if (!T->isLValueReferenceType() ||
+T.getNonReferenceType().isConstQualified() || T->isDependentType()) {
+  return;
+}
+
+llvm::Optional Location;
+
+// FIXME Add "unwrapping" for ArraySubscriptExpr and UnaryOperator,
+//  e.g. highlight `a` in `a[i]`
+// FIXME Handle dependent expression types
+if (auto *DR = dyn_cast(Arg))
+  Location = DR->getLocation();
+else if (auto *M = dyn_cast(Arg))
+  Location = M->getMemberLoc();
+
+if (Location)
+  H.addExtraModifier(*Location,
+ HighlightingModifier::UsedAsMutableReference);
+  }
+
   void
   highlightMutableReferenceArguments(const FunctionDecl *FD,
  llvm::ArrayRef Args) {
@@ -571,31 +607,7 @@
   // highlighting modifier to the corresponding expression
   for (size_t I = 0;
I < std::min(size_t(ProtoType->getNumParams()), Args.size()); ++I) {
-auto T = ProtoType->getParamType(I);
-
-// Is this parameter passed by non-const reference?
-// FIXME The condition !T->idDependentType() could be relaxed a bit,
-// e.g. std::vector& is dependent but we would want to highlight it
-if (T->isLValueReferenceType() &&
-!T.getNonReferenceType().isConstQualified() &&
-!T->isDependentType()) {
-  if (

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

2022-07-05 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:541
+  return Base::TraverseConstructorInitializer(Init);
+if (const auto Member = Init->getMember()) {
+  const auto MemberType = Member->getType();

nridge wrote:
> Use `auto *Member` to make clang-tidy happy (`const auto *` is also fine)
> 
> Likewise in a few places below
Ewww... But okay.


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] D129138: [clang] [docs] Update the changes of C++20 Modules in clang15

2022-07-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: iains, aaron.ballman, erichkeane.
ChuanqiXu added a project: clang-language-wg.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Since clang15 is going to be branched in July 26, and C++ modules still lack an 
update on ReleaseNotes. Although it is not complete yet, I think it would be 
better to add one since we've done many works for C++20 Modules in clang15.

@iains would you like to check if the list is complete or not? I don't include 
D126694  since I feel like it might not be 
possible to be landed in 3 weeks. And I know there some other patches not 
covered, but I feel it might be chaos to our users.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129138

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -462,6 +462,12 @@
   that can be used for such compatibility. The demangler now demangles
   symbols with named module attachment.
 
+- Implemented some features for C++20 Modules, including: Partitions, 
+  Reachability, Header Unit and ``extern "C++"`` semantics.
+
+- Implemented `P1779R3: ABI isolation for member functions 
`_.
+- Implemented `P1874R1: Dynamic Initialization Order of Non-Local Variables in 
Modules `_.
+
 - As per "Conditionally Trivial Special Member Functions" (P0848), it is
   now possible to overload destructors using concepts. Note that the rest
   of the paper about other special member functions is not yet implemented.


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -462,6 +462,12 @@
   that can be used for such compatibility. The demangler now demangles
   symbols with named module attachment.
 
+- Implemented some features for C++20 Modules, including: Partitions, 
+  Reachability, Header Unit and ``extern "C++"`` semantics.
+
+- Implemented `P1779R3: ABI isolation for member functions `_.
+- Implemented `P1874R1: Dynamic Initialization Order of Non-Local Variables in Modules `_.
+
 - As per "Conditionally Trivial Special Member Functions" (P0848), it is
   now possible to overload destructors using concepts. Note that the rest
   of the paper about other special member functions is not yet implemented.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129048: Rewording the "static_assert" to static assertion

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

Thank you for getting a great start on this diagnostic rewording!

I think we should also update DiagnosticParseKinds.td at the same time, but 
because that's about parsing rather than semantics, not all of the diagnostics 
should be reworded to use "static assertion".

`err_expected_semi_after_static_assert` should switch to use `%0` and pass in 
the actual parsed token -- I am pretty sure (but not 100% sure because I didn't 
try this myself) that it will print the actual spelling used for the token in 
that case.

`warn_cxx98_compat_static_assert` should get single quotes around the 
`static_assert` in the message, but is otherwise fine.

`ext_ms_static_assert`, `ext_cxx_static_assert_no_message`, 
`ext_c_static_assert_no_message`, `warn_cxx14_compat_static_assert_no_message`, 
`warn_c17_compat_static_assert_no_message`, and 
`err_templated_invalid_declaration` are all fine as-is.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11133
 def ext_export_no_name_block : ExtWarn<
-  "ISO C++20 does not permit %select{an empty|a static_assert}0 declaration "
+  "ISO C++20 does not permit %select{an empty|a static assertion}0 declaration 
"
   "to appear in an export block">, InGroup;

This is a case where the original text was slightly better -- this diagnostic 
is only issued for C++ code (modules don't exist in C), so using 
`static_assert` was fine.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11142
 def err_export_no_name : Error<
-  "%select{empty|static_assert|asm}0 declaration cannot be exported">;
+  "%select{empty|static assertion|asm}0 declaration cannot be exported">;
 def ext_export_using_directive : ExtWarn<

Same is true here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-07-05 Thread Tobias Hieta 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 rGe6ff553979e8: [clang-extdef-mapping] Directly process .ast 
files (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Analysis/func-mapping-test.cpp
  clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp

Index: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
===
--- clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -1,4 +1,4 @@
-//===- ClangExtDefMapGen.cpp ---===//
+//===- ClangExtDefMapGen.cpp -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,10 +13,12 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -29,12 +31,16 @@
 using namespace clang::cross_tu;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangExtDefMapGenCategory("clang-extdefmapgen options");
+static cl::OptionCategory
+ClangExtDefMapGenCategory("clang-extdefmapgen options");
 
 class MapExtDefNamesConsumer : public ASTConsumer {
 public:
-  MapExtDefNamesConsumer(ASTContext &Context)
-  : Ctx(Context), SM(Context.getSourceManager()) {}
+  MapExtDefNamesConsumer(ASTContext &Context,
+ StringRef astFilePath = StringRef())
+  : Ctx(Context), SM(Context.getSourceManager()) {
+CurrentFileName = astFilePath.str();
+  }
 
   ~MapExtDefNamesConsumer() {
 // Flush results to standard output.
@@ -111,6 +117,82 @@
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 
+static IntrusiveRefCntPtr Diags;
+
+IntrusiveRefCntPtr GetDiagnosticsEngine() {
+  if (Diags) {
+// Call reset to make sure we don't mix errors
+Diags->Reset(false);
+return Diags;
+  }
+
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  DiagClient->setPrefix("clang-extdef-mappping");
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+
+  IntrusiveRefCntPtr DiagEngine(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+  Diags.swap(DiagEngine);
+
+  // Retain this one time so it's not destroyed by ASTUnit::LoadFromASTFile
+  Diags->Retain();
+  return Diags;
+}
+
+static CompilerInstance *CI = nullptr;
+
+static bool HandleAST(StringRef AstPath) {
+
+  if (!CI)
+CI = new CompilerInstance();
+
+  IntrusiveRefCntPtr DiagEngine = GetDiagnosticsEngine();
+
+  std::unique_ptr Unit = ASTUnit::LoadFromASTFile(
+  AstPath.str(), CI->getPCHContainerOperations()->getRawReader(),
+  ASTUnit::LoadASTOnly, DiagEngine, CI->getFileSystemOpts());
+
+  if (!Unit)
+return false;
+
+  FileManager FM(CI->getFileSystemOpts());
+  SmallString<128> AbsPath(AstPath);
+  FM.makeAbsolutePath(AbsPath);
+
+  MapExtDefNamesConsumer Consumer =
+  MapExtDefNamesConsumer(Unit->getASTContext(), AbsPath);
+  Consumer.HandleTranslationUnit(Unit->getASTContext());
+
+  return true;
+}
+
+static int HandleFiles(ArrayRef SourceFiles,
+   CompilationDatabase &compilations) {
+  std::vector SourcesToBeParsed;
+
+  // Loop over all input files, if they are pre-compiled AST
+  // process them directly in HandleAST, otherwise put them
+  // on a list for ClangTool to handle.
+  for (StringRef Src : SourceFiles) {
+if (Src.endswith(".ast")) {
+  if (!HandleAST(Src)) {
+return 1;
+  }
+} else {
+  SourcesToBeParsed.push_back(Src.str());
+}
+  }
+
+  if (!SourcesToBeParsed.empty()) {
+ClangTool Tool(compilations, SourcesToBeParsed);
+return Tool.run(newFrontendActionFactory().get());
+  }
+
+  return 0;
+}
+
 int main(int argc, const char **argv) {
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0], false);
@@ -118,7 +200,10 @@
 
   const char *Overview = "\nThis tool collects the USR name and location "
  "of external definitions in the source files "
- "(excluding headers).\n";
+ "(excluding headers).\n"
+ "Input can be either source files that are compiled

[clang] e6ff553 - [clang-extdef-mapping] Directly process .ast files

2022-07-05 Thread Tobias Hieta via cfe-commits

Author: Tobias Hieta
Date: 2022-07-05T13:45:52+02:00
New Revision: e6ff553979e850eeb7f0bbe77deab1c88fc764b3

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

LOG: [clang-extdef-mapping] Directly process .ast files

When doing CTU analysis setup you pre-compile .cpp to .ast and then
you run clang-extdef-mapping on the .cpp file as well. This is a
pretty slow process since we have to recompile the file each time.

With this patch you can now run clang-extdef-mapping directly on
the .ast file. That saves a lot of time.

I tried this on llvm/lib/AsmParser/Parser.cpp and running
extdef-mapping on the .cpp file took 5.4s on my machine.

While running it on the .ast file it took 2s.

This can save a lot of time for the setup phase of CTU analysis.

Reviewed By: martong

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/test/Analysis/func-mapping-test.cpp
clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f074d1bf204f..1be63b539441 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -587,6 +587,13 @@ clang-format
 - Option ``InsertBraces`` has been added to insert optional braces after 
control
   statements.
 
+clang-extdef-mapping
+
+
+- clang-extdef-mapping now accepts .ast files as input. This is faster than to
+  recompile the files from sources when extracting method definitons. This can
+  be really beneficial when creating .ast files for input to the 
clang-static-analyzer.
+
 libclang
 
 

diff  --git a/clang/test/Analysis/func-mapping-test.cpp 
b/clang/test/Analysis/func-mapping-test.cpp
index a56c0075db1a..e5d242d67758 100644
--- a/clang/test/Analysis/func-mapping-test.cpp
+++ b/clang/test/Analysis/func-mapping-test.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_extdef_map %s -- | FileCheck --implicit-check-not "c:@y" 
--implicit-check-not "c:@z" %s
+// RUN: %clang -emit-ast %s -o %t.ast
+// RUN: %clang_extdef_map %t.ast -- | FileCheck --implicit-check-not "c:@y" 
--implicit-check-not "c:@z" %s
 
 int f(int) {
   return 0;

diff  --git a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp 
b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
index bc8d2581c1b9..ebeef5dce1eb 100644
--- a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -1,4 +1,4 @@
-//===- ClangExtDefMapGen.cpp 
---===//
+//===- ClangExtDefMapGen.cpp -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,10 +13,12 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -29,12 +31,16 @@ using namespace clang;
 using namespace clang::cross_tu;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangExtDefMapGenCategory("clang-extdefmapgen 
options");
+static cl::OptionCategory
+ClangExtDefMapGenCategory("clang-extdefmapgen options");
 
 class MapExtDefNamesConsumer : public ASTConsumer {
 public:
-  MapExtDefNamesConsumer(ASTContext &Context)
-  : Ctx(Context), SM(Context.getSourceManager()) {}
+  MapExtDefNamesConsumer(ASTContext &Context,
+ StringRef astFilePath = StringRef())
+  : Ctx(Context), SM(Context.getSourceManager()) {
+CurrentFileName = astFilePath.str();
+  }
 
   ~MapExtDefNamesConsumer() {
 // Flush results to standard output.
@@ -111,6 +117,82 @@ class MapExtDefNamesAction : public ASTFrontendAction {
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 
+static IntrusiveRefCntPtr Diags;
+
+IntrusiveRefCntPtr GetDiagnosticsEngine() {
+  if (Diags) {
+// Call reset to make sure we don't mix errors
+Diags->Reset(false);
+return Diags;
+  }
+
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  DiagClient->setPrefix("clang-extdef-mappping");
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+
+  IntrusiveRefCntPtr DiagEngine(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+  Diags.swap(DiagEngine);
+
+  // 

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

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



Comment at: clang/docs/ReleaseNotes.rst:324-326
+- Added the ``-Warray-parameter`` warning. It detects function redefinition,
+  where different definition involve argument type that decay to the same
+  pointer type from different array types.





Comment at: clang/lib/Sema/SemaDecl.cpp:3226-3227
+  if (Old->isVariableArrayType() && New->isVariableArrayType()) {
+const auto *OldVAT = cast(Old);
+const auto *NewVAT = cast(New);
+if ((OldVAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star) ^

Same here.



Comment at: clang/lib/Sema/SemaDecl.cpp:3216
+   (Ty->isVariableArrayType() &&
+cast(Ty)->getSizeModifier() ==
+ArrayType::ArraySizeModifier::Star);

aaron.ballman wrote:
> I forgot about this gotcha -- arrays are special in that you shouldn't be 
> using `cast<>` and friends on them, you need to ask the `ASTContext` to go 
> from the `QualType` to the correct array type. e.g., 
> `ASTContext::getAsConstantArrayType()` and 
> `ASTContext::getAsVariableArrayType()` -- I think this is the cause of the 
> failed assertions we're seeing in precommit CI.
I'm still not comfortable with the way this is written -- please go through the 
`ASTContext` instead, with something like:
```
if (Ty->isIncompleteArrayType() || Ty->isPointerType())
  return true;

if (const auto *VAT = Ctx.getAsVariableArrayType(Ty))
  return VAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star;

return false;
```




Comment at: clang/test/Sema/array-parameter.c:17
+
+void f5(int a[restrict 2]);
+void f5(int a[2]); // no warning

shafik wrote:
> Since we are covering `static`, `const` and `restict` we should also cover 
> `volatile` for completeness. 
+1, might as well round out the set.



Comment at: clang/test/Sema/array-parameter.cpp:3-7
+template 
+void func(int i[10]); // expected-note {{previously declared as 'int[10]' 
here}}
+
+template 
+void func(int i[N]); // expected-warning {{argument 'i' of type 'int[N]' with 
mismatched bound}}

One more test, now that I'm thinking about explicit specializations:
```
template 
void func(int (&Val)[N]);

template <>
void func<10>(int (&Val)[10]) {
}
```
I don't think this should get any diagnostics.


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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:503
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p4 are
+  used to pass data into or out of a subroutine. The new behavior

Should be p0-p3 rather than p0-p4.  LGTM with that change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

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


[PATCH] D129135: [doc][ReleaseNotes] Document AArch64 SVE ABI fix from D127209

2022-07-05 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm updated this revision to Diff 442264.
peterwaller-arm added a comment.

s/p0-p4/p0-p3/, thanks for the keen eye, rsandifo-arm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129135

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,14 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p3 are
+  used to pass data into or out of a subroutine. The new behavior
+  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
+  a call if the callee had an SVE type anywhere in its signature. This
+  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
+  ABI for example if the 9th argument or greater were the first SVE type
+  in the signature of a function.
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted 
constructor,
   fixing dr2171.


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -499,6 +499,14 @@
   (e.g. ``int : 0``) no longer prevents the structure from being considered a
   homogeneous floating-point or vector aggregate. The new behavior agrees with
   the AAPCS specification, and matches the similar bug fix in GCC 12.1.
+- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
+  and p4-p15 registers across a call if the registers z0-z7 or p0-p3 are
+  used to pass data into or out of a subroutine. The new behavior
+  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
+  a call if the callee had an SVE type anywhere in its signature. This
+  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
+  ABI for example if the 9th argument or greater were the first SVE type
+  in the signature of a function.
 - All copy constructors can now be trivial if they are not user-provided,
   regardless of the type qualifiers of the argument of the defaulted constructor,
   fixing dr2171.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127448: [pseudo] Implement guard extension.

2022-07-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Great!




Comment at: clang-tools-extra/pseudo/include/clang-pseudo/GLR.h:117
 struct ParseParams {
-  // The grammar of the language we're going to parse.
-  const Grammar &G;
-  // The LR table which GLR uses to parse the input, should correspond to the
-  // Grammar G.
-  const LRTable &Table;
+  // The token stream being to parse.
+  const TokenStream &Code;

delete "being".
Or possibly the whole comment, this seems obvious?



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:254
 private:
+  bool canReduce(ExtensionID GuardID, SequenceRef RHS) const {
+if (!GuardID)

nit: hadn't really intended SequenceRef to be a general vocabulary type, you 
might just want ArrayRef to match the guard signature, up to you



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:258
+auto It = Lang.Guards.find(GuardID);
+if (It == Lang.Guards.end()) {
+  llvm::dbgs() << " missing {0} guard implementation for rule {0}\n";

this should be guarded by LLVM_DEBUG

this whole thing might be clearer with lookup

```
if (auto Guard = Lang.Guards.lookup(GuardID))
  return Guard(RHS.S, Params.Code);

LLVM_DEBUG(...);
return true;
```



Comment at: clang-tools-extra/pseudo/unittests/GLRTest.cpp:486
+  )bnf");
+  TestLang.Guards.insert(std::make_pair(
+  extensionID("TestOnly"),

insert(make_pair(...)) => emplace(...)?



Comment at: clang-tools-extra/pseudo/unittests/GLRTest.cpp:489
+  [&](llvm::ArrayRef RHS, const TokenStream &Tokens) {
+llvm::errs() << "callback!\n";
+assert(RHS.size() == 1 &&

remove


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127448

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


[clang-tools-extra] 9fbf110 - [pseudo] Eliminate LRTable::Action. NFC

2022-07-05 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-05T14:35:41+02:00
New Revision: 9fbf1107cc763783a82b89953be8a45097ba3390

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

LOG: [pseudo] Eliminate LRTable::Action. NFC

The last remaining uses are in tests/test builders.
Replace with a builder struct.

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

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp
clang-tools-extra/pseudo/unittests/LRTableTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
index cd183b552d6f..7575b3271dc2 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -39,6 +39,7 @@
 #include "clang-pseudo/grammar/Grammar.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/Capacity.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
@@ -58,71 +59,15 @@ namespace pseudo {
 // Unlike the typical LR parsing table which allows at most one available 
action
 // per entry, conflicted actions are allowed in LRTable. The LRTable is 
designed
 // to be used in nondeterministic LR parsers (e.g. GLR).
+//
+// There are no "accept" actions in the LRTable, instead the stack is inspected
+// after parsing completes: is the state goto(StartState, StartSymbol)?
 class LRTable {
 public:
   // StateID is only 13 bits wide.
   using StateID = uint16_t;
   static constexpr unsigned StateBits = 13;
 
-  // Action represents the terminal and nonterminal actions, it combines the
-  // entry of the ACTION and GOTO tables from the LR literature.
-  //
-  // FIXME: as we move away from a homogeneous table structure shared between
-  // action types, this class becomes less useful. Remove it.
-  class Action {
-  public:
-enum Kind : uint8_t {
-  Sentinel = 0,
-  // Terminal actions, corresponding to entries of ACTION table.
-
-  // Shift to state n: move forward with the lookahead, and push state n
-  // onto the state stack.
-  // A shift is a forward transition, and the value n is the next state 
that
-  // the parser is to enter.
-  Shift,
-
-  // NOTE: there are no typical accept actions in the LRtable, accept
-  // actions are handled specifically in the parser -- if the parser
-  // reaches to a target state (which is goto(StartState, StartSymbol)) at
-  // the EOF token after a reduce, this indicates the input has been parsed
-  // as the StartSymbol successfully.
-
-  // Nonterminal actions, corresponding to entry of GOTO table.
-
-  // Go to state n: push state n onto the state stack.
-  // Similar to Shift, but it is a nonterminal forward transition.
-  GoTo,
-};
-
-static Action goTo(StateID S) { return Action(GoTo, S); }
-static Action shift(StateID S) { return Action(Shift, S); }
-static Action sentinel() { return Action(Sentinel, 0); }
-
-StateID getShiftState() const {
-  assert(kind() == Shift);
-  return Value;
-}
-StateID getGoToState() const {
-  assert(kind() == GoTo);
-  return Value;
-}
-Kind kind() const { return static_cast(K); }
-
-bool operator==(const Action &L) const { return opaque() == L.opaque(); }
-uint16_t opaque() const { return K << ValueBits | Value; };
-
-  private:
-Action(Kind K1, unsigned Value) : K(K1), Value(Value) {}
-static constexpr unsigned ValueBits = StateBits;
-static constexpr unsigned KindBits = 3;
-static_assert(ValueBits >= RuleBits, "Value must be able to store RuleID");
-static_assert(KindBits + ValueBits <= 16,
-  "Must be able to store kind and value efficiently");
-uint16_t K : KindBits;
-// Either StateID or RuleID, depending on the Kind.
-uint16_t Value : ValueBits;
-  };
-
   // Returns the state after we reduce a nonterminal.
   // Expected to be called by LR parsers.
   // If the nonterminal is invalid here, returns None.
@@ -184,20 +129,27 @@ class LRTable {
   // Build a SLR(1) parsing table.
   static LRTable buildSLR(const Grammar &G);
 
-  struct Builder;
-  // Represents an entry in the table, used for building the LRTable.
-  struct Entry {
-StateID State;
-SymbolID Symbol;
-Action Act;
-  };
-  struct ReduceEntry {
-StateID State;
-RuleID Rule;
+  // Helper for building a table with specified actions/states.
+  struct Builder {
+Buil

[PATCH] D129093: [pseudo] Eliminate LRTable::Action. NFC

2022-07-05 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG9fbf1107cc76: [pseudo] Eliminate LRTable::Action. NFC 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D129093?vs=442127&id=442267#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129093

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp
  clang-tools-extra/pseudo/unittests/LRTableTest.cpp

Index: clang-tools-extra/pseudo/unittests/LRTableTest.cpp
===
--- clang-tools-extra/pseudo/unittests/LRTableTest.cpp
+++ clang-tools-extra/pseudo/unittests/LRTableTest.cpp
@@ -20,7 +20,7 @@
 
 using llvm::ValueIs;
 using testing::ElementsAre;
-using Action = LRTable::Action;
+using StateID = LRTable::StateID;
 
 TEST(LRTable, Builder) {
   std::vector GrammarDiags;
@@ -38,22 +38,20 @@
   SymbolID Identifier = tokenSymbol(tok::identifier);
   SymbolID Plus = tokenSymbol(tok::plus);
 
+  LRTable::Builder B(G);
   //   eof  IDENT   term
   // +---++---+--+
   // |state0 || s0|  |
   // |state1 ||   | g3   |
   // |state2 ||   |  |
   // +---++---+--+---
-  std::vector Entries = {
-  {/* State */ 0, Identifier, Action::shift(0)},
-  {/* State */ 1, Term, Action::goTo(3)},
-  };
-  std::vector ReduceEntries = {
-  {/*State=*/0, /*Rule=*/0},
-  {/*State=*/1, /*Rule=*/2},
-  {/*State=*/2, /*Rule=*/1},
-  };
-  LRTable T = LRTable::buildForTests(G, Entries, ReduceEntries);
+  B.Transition[{StateID{0}, Identifier}] = StateID{0};
+  B.Transition[{StateID{1}, Term}] = StateID{3};
+  B.Reduce[StateID{0}].insert(RuleID{0});
+  B.Reduce[StateID{1}].insert(RuleID{2});
+  B.Reduce[StateID{2}].insert(RuleID{1});
+  LRTable T = std::move(B).build();
+
   EXPECT_EQ(T.getShiftState(0, Eof), llvm::None);
   EXPECT_THAT(T.getShiftState(0, Identifier), ValueIs(0));
   EXPECT_THAT(T.getReduceRules(0), ElementsAre(0));
Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -30,7 +30,7 @@
 
 namespace {
 
-using Action = LRTable::Action;
+using StateID = LRTable::StateID;
 using testing::AllOf;
 using testing::ElementsAre;
 using testing::UnorderedElementsAre;
@@ -122,13 +122,11 @@
/*Parents=*/{GSSNode0});
 
   buildGrammar({}, {}); // Create a fake empty grammar.
-  TestLang.Table =
-  LRTable::buildForTests(TestLang.G, /*Entries=*/{
- {1, tokenSymbol(tok::semi), Action::shift(4)},
- {2, tokenSymbol(tok::semi), Action::shift(4)},
- {3, tokenSymbol(tok::semi), Action::shift(5)},
- },
- {});
+  LRTable::Builder B(TestLang.G);
+  B.Transition[{StateID{1}, tokenSymbol(tok::semi)}] = StateID{4};
+  B.Transition[{StateID{2}, tokenSymbol(tok::semi)}] = StateID{4};
+  B.Transition[{StateID{3}, tokenSymbol(tok::semi)}] = StateID{5};
+  TestLang.Table = std::move(B).build();
 
   ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
@@ -152,17 +150,12 @@
   //└--3(enum-name) // 3 is goto(0, enum-name)
   buildGrammar({"class-name", "enum-name"},
{"class-name := IDENTIFIER", "enum-name := IDENTIFIER"});
-
-  TestLang.Table = LRTable::buildForTests(
-  TestLang.G,
-  {
-  {/*State=*/0, id("class-name"), Action::goTo(2)},
-  {/*State=*/0, id("enum-name"), Action::goTo(3)},
-  },
-  {
-  {/*State=*/1, ruleFor("class-name")},
-  {/*State=*/1, ruleFor("enum-name")},
-  });
+  LRTable::Builder B(TestLang.G);
+  B.Transition[{StateID{0}, id("class-name")}] = StateID{2};
+  B.Transition[{StateID{0}, id("enum-name")}] = StateID{3};
+  B.Reduce[StateID{1}].insert(ruleFor("class-name"));
+  B.Reduce[StateID{1}].insert(ruleFor("enum-name"));
+  TestLang.Table = std::move(B).build();
 
   const auto *GSSNode0 =
   GSStack.addNode(/*State=*/0, /*ForestNode=*/nullptr, /*Parents=*/{});
@@ -202,15 +195,12 @@
   /*State=*/4, &Arena.createTerminal(tok::star, /*TokenIndex=*/1),
   /*Parents=*/{GSSNode2, GSSNode3});
 
-  TestLang.Table = LRTable::buildForTests(
-  TestLang.G,
-  {
-  {/*State=*/2, id("ptr-operator"), Action::goTo(/*NextState=*/5)},
-  {/*State=*/3, id("ptr-operator"), Action::goTo(/*NextState=*/6)},
-  },
-  {
-  {/*State=*/4, ruleFor("ptr-operator")},
- 

[PATCH] D124159: [SimplifyCFG] Thread branches on same condition in more cases (PR54980)

2022-07-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

@HanKuanChen Thanks for the report! I've landed a fix for this test case in 
https://github.com/llvm/llvm-project/commit/dc969061c68e62328607d68215ed8b9ef4a1e4b1.
 This is based on making SimplifyCFG behave more like JumpThreading, which does 
not have an infinite loop for this case. Let me know if you see further issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124159

___
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-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall planned changes to this revision.
sammccall added a comment.

Summarizing an offline discussion:

- ThrottlerState isolates complexity inside TUScheduler by absolving Throttler 
of the need to worry about callback lifetimes
- but it does so at the cost of extra aggregate complexity (third object with 
different lifetime & own threading model)
- the main alternative seems to be to allow deregistration of callbacks on 
throttler (addListener/removeListener)
  - planning to give that a try.


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] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-05 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu added a comment.

@MaskRay PTAL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D129097: [clang][dataflow] Handle null pointers of type std::nullptr_t

2022-07-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp:61
+  auto CanonicalPointeeType =
+  PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType();
   auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr);

Could you add a comment to the header that a caller may pass a null PointeeType 
as a "pointee" of a nullptr_t?



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:2216-2226
 struct Baz {};
 void target() {
   int *FooX = nullptr;
   int *FooY = nullptr;
   bool **Bar = nullptr;
   Baz *Baz = nullptr;
+  // Use decltype to avoid needing to include . This generates an




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129097

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


[PATCH] D129061: [Lex] Diagnose macro in command lines

2022-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: serge-sans-paille.
aaron.ballman added a comment.

Thank you for looking into this! I think we may need to figure out something 
better for handling macros defined by the driver, because otherwise we're going 
to get a bunch of false positives from this. For example, the clang-cl driver 
adds command line flags like `-D_DEBUG` and `-D_MT`, etc, the same as what 
happens for `__GCC_HAVE_DWARF2_CFI_ASM`. I'm not certain if there's an easy way 
to differentiate between driver-added `-D` flags and user-added `-D` flags, 
though. If we don't have anything that suffices already, we could invent 
something (either a new form of `-D` at the cc1 level that the driver emits for 
its defines, or some sort of cc1 flag to say "here's where user command line 
options begin", etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129061

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


[clang-tools-extra] 70c0d92 - [pseudo] Use the prebuilt cxx grammar for the lit tests, NFC.

2022-07-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-05T15:17:18+02:00
New Revision: 70c0d92930b28104324b0888d6c6fdde2ffa5a07

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

LOG: [pseudo] Use the prebuilt cxx grammar for the lit tests, NFC.

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

Added: 


Modified: 
clang-tools-extra/pseudo/test/cxx/capture-list.cpp
clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
clang-tools-extra/pseudo/test/cxx/keyword.cpp
clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp
clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
clang-tools-extra/pseudo/test/cxx/unsized-array.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/test/cxx/capture-list.cpp 
b/clang-tools-extra/pseudo/test/cxx/capture-list.cpp
index 8659a6acae809..fde46e4f0e038 100644
--- a/clang-tools-extra/pseudo/test/cxx/capture-list.cpp
+++ b/clang-tools-extra/pseudo/test/cxx/capture-list.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 // We loosely allow capture defaults in any position/multiple times.
 auto lambda = [&, &foo, bar(x), =]{};
 // CHECK:  lambda-introducer := [ capture-list ]

diff  --git a/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp 
b/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
index 0de4ec14ffcd0..59dccf993af47 100644
--- a/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
+++ b/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
@@ -4,7 +4,7 @@
 // FIXME: eliminate this false parse.
 // XFAIL: *
 
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void s(){};
 // CHECK-NOT:  simple-declaration
 // CHECK:  function-definition := decl-specifier-seq declarator

diff  --git a/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp 
b/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
index a5adb43dc3c5c..057ec55b1c925 100644
--- a/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
+++ b/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
@@ -4,7 +4,7 @@
 // FIXME: eliminate this false parse.
 // XFAIL: *
 
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void (*s)(){};
 // CHECK-NOT:  function-definition
 // CHECK:  init-declarator := declarator initializer

diff  --git a/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp 
b/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
index 6d7a6823d0bf0..e6dbbddf09062 100644
--- a/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
+++ b/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 class Foo {
 public:
 };

diff  --git a/clang-tools-extra/pseudo/test/cxx/keyword.cpp 
b/clang-tools-extra/pseudo/test/cxx/keyword.cpp
index b58c250c763f0..318db4ccc49b9 100644
--- a/clang-tools-extra/pseudo/test/cxx/keyword.cpp
+++ b/clang-tools-extra/pseudo/test/cxx/keyword.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 bool operator<();
 // CHECK:  translation-unit~simple-declaration := decl-specifier-seq 
init-declarator-list ;
 // CHECK-NEXT: ├─decl-specifier-seq~BOOL

diff  --git a/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp 
b/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
index ec5683905..5a89f4d57a528 100644
--- a/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
+++ b/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 // FIXME: tighten CHECK to CHECK-NEXT once numeric literals are unambiguous.
 auto x = { 1, .f = 2, [c]{3} };
 // CHECK:  initializer-clause~braced-init-list

diff  --git a/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp 
b/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp
index 7de65687e1d15..18584ded9b5b4 100644
--- a/clang-tools-extra/pseudo/

[PATCH] D129074: [pseudo] Use the prebuilt cxx grammar for the lit tests, NFC.

2022-07-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70c0d92930b2: [pseudo] Use the prebuilt cxx grammar for the 
lit tests, NFC. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129074

Files:
  clang-tools-extra/pseudo/test/cxx/capture-list.cpp
  clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
  clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
  clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
  clang-tools-extra/pseudo/test/cxx/keyword.cpp
  clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
  clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp
  clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
  clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
  clang-tools-extra/pseudo/test/cxx/unsized-array.cpp

Index: clang-tools-extra/pseudo/test/cxx/unsized-array.cpp
===
--- clang-tools-extra/pseudo/test/cxx/unsized-array.cpp
+++ clang-tools-extra/pseudo/test/cxx/unsized-array.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void s(int[]);
 // CHECK:  parameter-declaration-clause~parameter-declaration := decl-specifier-seq abstract-declarator
 // CHECK-NEXT: ├─decl-specifier-seq~INT := tok[3]
Index: clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
===
--- clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
+++ clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
@@ -1,3 +1,3 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 template  struct MatchParents;
 // CHECK: template-parameter-list~TYPENAME := tok[2]
Index: clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
===
--- clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
+++ clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void s() {
   __func__;
   // CHECK: expression~__FUNC__ := tok[5]
Index: clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp
===
--- clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp
+++ clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void foo2(int, ...);
 // CHECK:  translation-unit~simple-declaration := decl-specifier-seq init-declarator-list ;
 // CHECK-NEXT: ├─decl-specifier-seq~VOID :=
Index: clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
===
--- clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
+++ clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 // FIXME: tighten CHECK to CHECK-NEXT once numeric literals are unambiguous.
 auto x = { 1, .f = 2, [c]{3} };
 // CHECK:  initializer-clause~braced-init-list
Index: clang-tools-extra/pseudo/test/cxx/keyword.cpp
===
--- clang-tools-extra/pseudo/test/cxx/keyword.cpp
+++ clang-tools-extra/pseudo/test/cxx/keyword.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 bool operator<();
 // CHECK:  translation-unit~simple-declaration := decl-specifier-seq init-declarator-list ;
 // CHECK-NEXT: ├─decl-specifier-seq~BOOL
Index: clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
===
--- clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
+++ clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 class Foo {
 public:
 };
Index: clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
===
--- clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
+++ clang-tools-extra/p

[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442276.
Codesbyusman added a comment.

updating some to the back strings becaue the orginal were more better


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/Modules/cxx20-10-2-ex7.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/Parser/objc-static-assert.m
  clang/test/Parser/objc-static-assert.mm
  clang/test/Sema/builtin-align.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/access-base-class.cpp
  clang/test/SemaCXX/alias-template.cpp
  clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/complex-folding.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx2a-template-lambdas.cpp
  clang/test/SemaCXX/delete-and-function-templates.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/modules-ts.cppm
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/static-assert-cxx17.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/test/SemaCXX/using-decl-templates.cpp
  clang/test/SemaCXX/weak-init.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/pr52909.cpp
  clang/test/SemaTemplate/pr52970.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -184,7 +184,7 @@
 
 namespace Diags {
   struct A { int n, m; };
-  template struct X { static_assert(a.n == a.m); }; // expected-error {{static_assert failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
+  template struct X { static_assert(a.n == a.m); }; // expected-error {{static assertion failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
   template struct X; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}}
 }
 
Index: clang/test/SemaTemplate/pr52970.cpp
===
--- clang/test/SemaTemplate/pr52970.cpp
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -32,7 +32,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingFunctionName
@@ -57,7 +57,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingPointer
Index: clang/test/SemaTemplate/pr52909.cpp
===
--- clang/test/SemaTemplate/pr52909.cpp
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -15,7 +15,7 @@
   // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
 };
 
-static_assert(Beginable); // expected-error {{static_assert failed}}
+static_assert(Beginable); // expected-error {{static assertion failed}}
  // expected-note@-1 {{does not satisfy 'Beginable'}}
 } // namespace PR52905
 
@@ -48,7 +48,7 @@
 static void begin(double);
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
 
 } // namespace PR52909b
@@ -65,7 +65,7 @@
 int *f() const;
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
 
 } // namespace PR53075
Index: clang/test/SemaTemplate/instantiate-var-template.cpp
===
--- clang/test/SemaTemplate/instantiate-var-template.cpp
+++ clang/test

[PATCH] D129138: [clang] [docs] Update the changes of C++20 Modules in clang15

2022-07-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Wording looks fine to me, though unsure if this is a complete/accurate list for 
obvious reasons.  If @iains  can take a quick look, it woudl be greatly 
appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129138

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


[PATCH] D129104: [Modules] Add ODR Check for concepts

2022-07-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:6532
+  const Expr *XCE = ConceptX->getConstraintExpr();
+  const Expr *YCE = ConceptY->getConstraintExpr();
+  assert(XCE && YCE && "ConceptDecl wihtout constraint expression?");

This isn't necessarily valid here, you did a dyn_cast above.



Comment at: clang/lib/AST/ASTContext.cpp:6533
+  const Expr *YCE = ConceptY->getConstraintExpr();
+  assert(XCE && YCE && "ConceptDecl wihtout constraint expression?");
+  llvm::FoldingSetNodeID XID, YID;




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

https://reviews.llvm.org/D129104

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


[PATCH] D129061: [Lex] Diagnose macro in command lines

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

great addition. Missing a test case though, which would probably trigger 
@aaron.ballman scenario


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129061

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


[clang-tools-extra] d263447 - [pseudo] Fix the build for the benchmark tool.

2022-07-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-05T15:42:41+02:00
New Revision: d26344731128ccdd8eeb27a12b2c3bd75e5e3a63

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

LOG: [pseudo] Fix the build for the benchmark tool.

Added: 


Modified: 
clang-tools-extra/pseudo/benchmarks/Benchmark.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp 
b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
index 5bf6ff2c08f32..02f4a40fae7c7 100644
--- a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
+++ b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
@@ -117,12 +117,12 @@ static void preprocess(benchmark::State &State) {
 BENCHMARK(preprocess);
 
 static void glrParse(benchmark::State &State) {
-  SymbolID StartSymbol = *Lang->G->findNonterminal("translation-unit");
+  SymbolID StartSymbol = *Lang->G.findNonterminal("translation-unit");
   TokenStream Stream = lexAndPreprocess();
   for (auto _ : State) {
 pseudo::ForestArena Forest;
 pseudo::GSS GSS;
-pseudo::glrParse(Stream, ParseParams{*Lang->G, Lang->Table, Forest, GSS},
+pseudo::glrParse(Stream, ParseParams{Lang->G, Lang->Table, Forest, GSS},
  StartSymbol);
   }
   State.SetBytesProcessed(static_cast(State.iterations()) *



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


[PATCH] D127448: [pseudo] Implement guard extension.

2022-07-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 442290.
hokein marked 5 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127448

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cli/CLI.cpp
  clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -81,6 +81,14 @@
 ADD_FAILURE() << "No such symbol found: " << Name;
 return 0;
   }
+  ExtensionID extensionID(llvm::StringRef AttrValueName) const {
+for (ExtensionID EID = 0; EID < TestLang.G.table().AttributeValues.size();
+ ++EID)
+  if (TestLang.G.table().AttributeValues[EID] == AttrValueName)
+return EID;
+ADD_FAILURE() << "No such attribute value found: " << AttrValueName;
+return 0;
+  }
 
   RuleID ruleFor(llvm::StringRef NonterminalName) const {
 auto RuleRange =
@@ -131,7 +139,7 @@
   ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
   glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal,
-   {TestLang.G, TestLang.Table, Arena, GSStack}, NewHeads);
+   {emptyTokenStream(), Arena, GSStack}, TestLang, NewHeads);
 
   EXPECT_THAT(NewHeads,
   UnorderedElementsAre(AllOf(state(4), parsedSymbol(&SemiTerminal),
@@ -164,7 +172,7 @@
 
   std::vector Heads = {GSSNode1};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode1,
  AllOf(state(2), parsedSymbolID(id("class-name")),
@@ -202,7 +210,8 @@
   TestLang.Table = std::move(B).build();
 
   std::vector Heads = {GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode4,
@@ -254,7 +263,8 @@
   TestLang.Table = std::move(B).build();
 
   std::vector Heads = {GSSNode3, GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   // Verify that the stack heads are joint at state 5 after reduces.
   EXPECT_THAT(Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -309,7 +319,7 @@
 
   std::vector Heads = {GSSNode3, GSSNode4};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
 
   EXPECT_THAT(
   Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -343,14 +353,16 @@
 
   // When the lookahead is +, reduce is performed.
   std::vector Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::plus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::plus), {emptyTokenStream(), Arena, GSStack},
+TestLang);
   EXPECT_THAT(Heads,
   ElementsAre(GSSNode1, AllOf(state(2), parsedSymbolID(id("term")),
   parents(Root;
 
   // When the lookahead is -, reduce is not performed.
   Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::minus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::minus),
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, ElementsAre(GSSNode1));
 }
 
@@ -376,7 +388,7 @@
   const TokenStream &Tokens = cook(lex("{ abc", LOptions), LOptions);
 
   const ForestNode &Parsed =
-  glrParse(Tokens, {TestLang.G, TestLang.Table, Arena, GSStack}, id("test"));
+  glrParse({Tokens, Arena, GSStack}, id("test"), TestLang);
   // Verify that there is no duplicated sequence node of `expr := IDENTIFIER`
   // in the forest, see the `#1` and `=#1` in the dump string.
   EXPECT_EQ(Parsed.dumpRecursive(TestLang.G),
@@ -413,7 +425,7 @@
   TestLang.Table = LRTable::buildSLR(TestLang.G);
 
   const ForestNode &Parsed =
- 

[PATCH] D129097: [clang][dataflow] Handle null pointers of type std::nullptr_t

2022-07-05 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua updated this revision to Diff 442291.
li.zhe.hua marked 2 inline comments as done.
li.zhe.hua added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129097

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2213,12 +2213,14 @@
 
 TEST(TransferTest, NullToPointerCast) {
   std::string Code = R"(
+using my_nullptr_t = decltype(nullptr);
 struct Baz {};
 void target() {
   int *FooX = nullptr;
   int *FooY = nullptr;
   bool **Bar = nullptr;
   Baz *Baz = nullptr;
+  my_nullptr_t Null = 0;
   // [[p]]
 }
   )";
@@ -2242,6 +2244,9 @@
 const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
 ASSERT_THAT(BazDecl, NotNull());
 
+const ValueDecl *NullDecl = findValueDecl(ASTCtx, "Null");
+ASSERT_THAT(NullDecl, NotNull());
+
 const auto *FooXVal =
 cast(Env.getValue(*FooXDecl, SkipPast::None));
 const auto *FooYVal =
@@ -2250,6 +2255,8 @@
 cast(Env.getValue(*BarDecl, SkipPast::None));
 const auto *BazVal =
 cast(Env.getValue(*BazDecl, SkipPast::None));
+const auto *NullVal =
+cast(Env.getValue(*NullDecl, SkipPast::None));
 
 EXPECT_EQ(FooXVal, FooYVal);
 EXPECT_NE(FooXVal, BarVal);
@@ -2267,6 +2274,11 @@
 const StorageLocation &BazPointeeLoc = BazVal->getPointeeLoc();
 EXPECT_TRUE(isa(BazPointeeLoc));
 EXPECT_THAT(Env.getValue(BazPointeeLoc), IsNull());
+
+const StorageLocation &NullPointeeLoc =
+NullVal->getPointeeLoc();
+EXPECT_TRUE(isa(NullPointeeLoc));
+EXPECT_THAT(Env.getValue(NullPointeeLoc), IsNull());
   });
 }
 
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -24,8 +24,8 @@
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(QualType Type) {
-  assert(!Type.isNull());
-  if (Type->isStructureOrClassType() || Type->isUnionType()) {
+  if (!Type.isNull() &&
+  (Type->isStructureOrClassType() || Type->isUnionType())) {
 // FIXME: Explore options to avoid eager initialization of fields as some of
 // them might not be needed for a particular analysis.
 llvm::DenseMap FieldLocs;
@@ -57,8 +57,8 @@
 
 PointerValue &
 DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) {
-  assert(!PointeeType.isNull());
-  auto CanonicalPointeeType = PointeeType.getCanonicalType();
+  auto CanonicalPointeeType =
+  PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType();
   auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr);
   if (Res.second) {
 auto &PointeeLoc = getStableStorageLocation(CanonicalPointeeType);
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -155,6 +155,7 @@
 
   /// Returns a pointer value that represents a null pointer. Calls with
   /// `PointeeType` that are canonically equivalent will return the same result.
+  /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.
   PointerValue &getOrCreateNullPointerValue(QualType PointeeType);
 
   /// Returns a symbolic boolean value that models a boolean literal equal to
@@ -251,6 +252,17 @@
   bool equivalentBoolValues(BoolValue &Val1, BoolValue &Val2);
 
 private:
+  struct NullableQualTypeDenseMapInfo : private llvm::DenseMapInfo {
+static QualType getEmptyKey() {
+  // Allow a NULL `QualType` by using a different value as the empty key.
+  return QualType::getFromOpaquePtr(reinterpret_cast(1));
+}
+
+using DenseMapInfo::getHashValue;
+using DenseMapInfo::getTombstoneKey;
+using DenseMapInfo::isEqual;
+  };
+
   /// Adds all constraints of the flow condition identified by `Token` and all
   /// of its transitive dependencies to `Constraints`. `VisitedTokens` is used
   /// to track tokens of flow conditions that were already visited by recursi

[clang] f10d271 - [clang][dataflow] Handle null pointers of type std::nullptr_t

2022-07-05 Thread Eric Li via cfe-commits

Author: Eric Li
Date: 2022-07-05T13:49:26Z
New Revision: f10d271ae27f35cd56535ff7e832a358732c8fcd

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

LOG: [clang][dataflow] Handle null pointers of type std::nullptr_t

Treat `std::nullptr_t` as a regular scalar type to avoid tripping
assertions when analyzing code that uses `std::nullptr_t`.

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index c1100d8474aa4..d87b9cc37b996 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -155,6 +155,7 @@ class DataflowAnalysisContext {
 
   /// Returns a pointer value that represents a null pointer. Calls with
   /// `PointeeType` that are canonically equivalent will return the same 
result.
+  /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.
   PointerValue &getOrCreateNullPointerValue(QualType PointeeType);
 
   /// Returns a symbolic boolean value that models a boolean literal equal to
@@ -251,6 +252,17 @@ class DataflowAnalysisContext {
   bool equivalentBoolValues(BoolValue &Val1, BoolValue &Val2);
 
 private:
+  struct NullableQualTypeDenseMapInfo : private llvm::DenseMapInfo {
+static QualType getEmptyKey() {
+  // Allow a NULL `QualType` by using a 
diff erent value as the empty key.
+  return QualType::getFromOpaquePtr(reinterpret_cast(1));
+}
+
+using DenseMapInfo::getHashValue;
+using DenseMapInfo::getTombstoneKey;
+using DenseMapInfo::isEqual;
+  };
+
   /// Adds all constraints of the flow condition identified by `Token` and all
   /// of its transitive dependencies to `Constraints`. `VisitedTokens` is used
   /// to track tokens of flow conditions that were already visited by recursive
@@ -311,7 +323,8 @@ class DataflowAnalysisContext {
   // required to initialize the `PointeeLoc` field in `PointerValue`. Consider
   // creating a type-independent `NullPointerValue` without a `PointeeLoc`
   // field.
-  llvm::DenseMap NullPointerVals;
+  llvm::DenseMap
+  NullPointerVals;
 
   AtomicBoolValue &TrueVal;
   AtomicBoolValue &FalseVal;

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index e08fc71c51dc7..cd87e87a6acab 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -24,8 +24,8 @@ namespace dataflow {
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(QualType Type) {
-  assert(!Type.isNull());
-  if (Type->isStructureOrClassType() || Type->isUnionType()) {
+  if (!Type.isNull() &&
+  (Type->isStructureOrClassType() || Type->isUnionType())) {
 // FIXME: Explore options to avoid eager initialization of fields as some 
of
 // them might not be needed for a particular analysis.
 llvm::DenseMap FieldLocs;
@@ -57,8 +57,8 @@ DataflowAnalysisContext::getStableStorageLocation(const Expr 
&E) {
 
 PointerValue &
 DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) {
-  assert(!PointeeType.isNull());
-  auto CanonicalPointeeType = PointeeType.getCanonicalType();
+  auto CanonicalPointeeType =
+  PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType();
   auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr);
   if (Res.second) {
 auto &PointeeLoc = getStableStorageLocation(CanonicalPointeeType);

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 04710b1795ef4..c4a42061edd90 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2213,12 +2213,14 @@ TEST(TransferTest, IntegralToBooleanCastFromBool) {
 
 TEST(TransferTest, NullToPointerCast) {
   std::string Code = R"(
+using my_nullptr_t = decltype(nullptr);
 struct Baz {};
 void target() {
   int *FooX = nullptr;
   int *FooY = nullptr;
   bool **Bar = nullptr;
   Baz *Baz = nullptr;
+  my_nullptr_t Null = 0;
   // [[p]]
 }
   )";
@@ -2242,6 +2244,9 @@ TEST(TransferTest, NullToPointerCast) {
 const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
 ASSERT_THAT(BazDecl, NotNull());
 

[PATCH] D129097: [clang][dataflow] Handle null pointers of type std::nullptr_t

2022-07-05 Thread Eric Li 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 rGf10d271ae27f: [clang][dataflow] Handle null pointers of type 
std::nullptr_t (authored by li.zhe.hua).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129097

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2213,12 +2213,14 @@
 
 TEST(TransferTest, NullToPointerCast) {
   std::string Code = R"(
+using my_nullptr_t = decltype(nullptr);
 struct Baz {};
 void target() {
   int *FooX = nullptr;
   int *FooY = nullptr;
   bool **Bar = nullptr;
   Baz *Baz = nullptr;
+  my_nullptr_t Null = 0;
   // [[p]]
 }
   )";
@@ -2242,6 +2244,9 @@
 const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
 ASSERT_THAT(BazDecl, NotNull());
 
+const ValueDecl *NullDecl = findValueDecl(ASTCtx, "Null");
+ASSERT_THAT(NullDecl, NotNull());
+
 const auto *FooXVal =
 cast(Env.getValue(*FooXDecl, SkipPast::None));
 const auto *FooYVal =
@@ -2250,6 +2255,8 @@
 cast(Env.getValue(*BarDecl, SkipPast::None));
 const auto *BazVal =
 cast(Env.getValue(*BazDecl, SkipPast::None));
+const auto *NullVal =
+cast(Env.getValue(*NullDecl, SkipPast::None));
 
 EXPECT_EQ(FooXVal, FooYVal);
 EXPECT_NE(FooXVal, BarVal);
@@ -2267,6 +2274,11 @@
 const StorageLocation &BazPointeeLoc = BazVal->getPointeeLoc();
 EXPECT_TRUE(isa(BazPointeeLoc));
 EXPECT_THAT(Env.getValue(BazPointeeLoc), IsNull());
+
+const StorageLocation &NullPointeeLoc =
+NullVal->getPointeeLoc();
+EXPECT_TRUE(isa(NullPointeeLoc));
+EXPECT_THAT(Env.getValue(NullPointeeLoc), IsNull());
   });
 }
 
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -24,8 +24,8 @@
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(QualType Type) {
-  assert(!Type.isNull());
-  if (Type->isStructureOrClassType() || Type->isUnionType()) {
+  if (!Type.isNull() &&
+  (Type->isStructureOrClassType() || Type->isUnionType())) {
 // FIXME: Explore options to avoid eager initialization of fields as some of
 // them might not be needed for a particular analysis.
 llvm::DenseMap FieldLocs;
@@ -57,8 +57,8 @@
 
 PointerValue &
 DataflowAnalysisContext::getOrCreateNullPointerValue(QualType PointeeType) {
-  assert(!PointeeType.isNull());
-  auto CanonicalPointeeType = PointeeType.getCanonicalType();
+  auto CanonicalPointeeType =
+  PointeeType.isNull() ? PointeeType : PointeeType.getCanonicalType();
   auto Res = NullPointerVals.try_emplace(CanonicalPointeeType, nullptr);
   if (Res.second) {
 auto &PointeeLoc = getStableStorageLocation(CanonicalPointeeType);
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -155,6 +155,7 @@
 
   /// Returns a pointer value that represents a null pointer. Calls with
   /// `PointeeType` that are canonically equivalent will return the same result.
+  /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.
   PointerValue &getOrCreateNullPointerValue(QualType PointeeType);
 
   /// Returns a symbolic boolean value that models a boolean literal equal to
@@ -251,6 +252,17 @@
   bool equivalentBoolValues(BoolValue &Val1, BoolValue &Val2);
 
 private:
+  struct NullableQualTypeDenseMapInfo : private llvm::DenseMapInfo {
+static QualType getEmptyKey() {
+  // Allow a NULL `QualType` by using a different value as the empty key.
+  return QualType::getFromOpaquePtr(reinterpret_cast(1));
+}
+
+using DenseMapInfo::getHashValue;
+using DenseMapInfo::getTombstoneKey;
+using DenseMapInfo::isEqual;
+  };
+
   /// Adds all constraints of the flow condition identified by `Token` and all
   /// of its transitive dependencies to `Constr

[clang] 935570b - [ConstExpr] Don't create div/rem expressions

2022-07-05 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-07-05T15:54:53+02:00
New Revision: 935570b2ad808035a1fd9bf6fa894657babc8694

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

LOG: [ConstExpr] Don't create div/rem expressions

This removes creation of udiv/sdiv/urem/srem constant expressions,
in preparation for their removal. I've added a
ConstantExpr::isDesirableBinOp() predicate to determine whether
an expression should be created for a certain operator.

With this patch, div/rem expressions can still be created through
explicit IR/bitcode, forbidding them entirely will be the next step.

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

Added: 


Modified: 
clang/test/CodeGenCUDA/managed-var.cu
clang/test/OpenMP/target_data_codegen.cpp
clang/test/OpenMP/target_enter_data_codegen.cpp
clang/test/OpenMP/target_enter_data_depend_codegen.cpp
clang/test/OpenMP/target_exit_data_codegen.cpp
clang/test/OpenMP/target_exit_data_depend_codegen.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_depend_codegen.cpp
llvm/include/llvm/Analysis/TargetFolder.h
llvm/include/llvm/IR/ConstantFolder.h
llvm/include/llvm/IR/Constants.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
llvm/test/Transforms/InstCombine/not-add.ll

Removed: 




diff  --git a/clang/test/CodeGenCUDA/managed-var.cu 
b/clang/test/CodeGenCUDA/managed-var.cu
index 7b5f6bb4771a5..6915582e12127 100644
--- a/clang/test/CodeGenCUDA/managed-var.cu
+++ b/clang/test/CodeGenCUDA/managed-var.cu
@@ -144,9 +144,9 @@ float load3() {
 // HOST:  %3 = getelementptr inbounds [100 x %struct.vec], [100 x 
%struct.vec]* %2, i64 0, i64 1, i32 1
 // HOST:  %4 = ptrtoint float* %3 to i64
 // HOST:  %5 = sub i64 %4, %1
-// HOST:  %6 = sdiv exact i64 %5, 4
-// HOST:  %7 = sitofp i64 %6 to float
-// HOST:  ret float %7
+// HOST:  %sub.ptr.div = sdiv exact i64 %5, 4
+// HOST:  %conv = sitofp i64 %sub.ptr.div to float
+// HOST:  ret float %conv
 float addr_taken2() {
   return (float)reinterpret_cast(&(v2[1].y)-&(v[1].x));
 }

diff  --git a/clang/test/OpenMP/target_data_codegen.cpp 
b/clang/test/OpenMP/target_data_codegen.cpp
index 2e9bd8d9cafbd..73a3bac1fc60e 100644
--- a/clang/test/OpenMP/target_data_codegen.cpp
+++ b/clang/test/OpenMP/target_data_codegen.cpp
@@ -152,7 +152,8 @@ void foo(int arg) {
   // CK1-DAG: [[CP0:%.+]] = bitcast i8** [[P0]] to double***
   // CK1-DAG: store [[ST]]* @gb, [[ST]]** [[CBP0]]
   // CK1-DAG: store double** getelementptr inbounds ([[ST]], [[ST]]* @gb, i32 
0, i32 1), double*** [[CP0]]
-  // CK1-DAG: store i64 sdiv exact (i64 sub (i64 ptrtoint (double** 
getelementptr (double*, double** getelementptr inbounds (%struct.ST, 
%struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** 
getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), 
i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)), i64* [[PS0]],
+  // CK1-DAG: [[DIV:%.+]] = sdiv exact i64 sub (i64 ptrtoint (double** 
getelementptr (double*, double** getelementptr inbounds (%struct.ST, 
%struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** 
getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), 
ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
+  // CK1-DAG: store i64 [[DIV]], i64* [[PS0]],
 
   // CK1-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, 
i{{.+}} 1
   // CK1-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, 
i{{.+}} 1

diff  --git a/clang/test/OpenMP/target_enter_data_codegen.cpp 
b/clang/test/OpenMP/target_enter_data_codegen.cpp
index 7e359cfab679d..81455cd02e588 100644
--- a/clang/test/OpenMP/target_enter_data_codegen.cpp
+++ b/clang/test/OpenMP/target_enter_data_codegen.cpp
@@ -158,7 +158,8 @@ void foo(int arg) {
   // CK1-DAG: [[CP0:%.+]] = bitcast i8** [[P0]] to double***
   // CK1-DAG: store [[ST]]* @gb, [[ST]]** [[CBP0]]
   // CK1-DAG: store double** getelementptr inbounds ([[ST]], [[ST]]* @gb, i32 
0, i32 1), double*** [[CP0]]
-  // CK1-DAG: store i64 sdiv exact (i64 sub (i64 ptrtoint (double** 
getelementptr (double*, double** getelementptr inbounds (%struct.ST, 
%struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** 
getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), 
i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)), i64* [[S0]],
+  // CK1-DAG: [[DIV:%.+]] = sdiv exact i64 sub (i64 ptrtoint (double** 
getelementptr (double*, double** getelementptr inbounds (%struct.ST, 
%struct.ST

[PATCH] D128820: [ConstExpr] Don't create div/rem expressions

2022-07-05 Thread Nikita Popov 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 rG935570b2ad80: [ConstExpr] Don't create div/rem 
expressions (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D128820?vs=442100&id=442295#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128820

Files:
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
  llvm/test/Transforms/InstCombine/not-add.ll

Index: llvm/test/Transforms/InstCombine/not-add.ll
===
--- llvm/test/Transforms/InstCombine/not-add.ll
+++ llvm/test/Transforms/InstCombine/not-add.ll
@@ -172,12 +172,8 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[X:%.*]], 1
 ; CHECK-NEXT:[[B15:%.*]] = srem i32 ashr (i32 65536, i32 or (i32 zext (i1 icmp eq (i32* @g, i32* null) to i32), i32 65537)), [[XOR]]
-; CHECK-NEXT:[[B22:%.*]] = add nsw i32 [[B15]], sdiv (i32 or (i32 zext (i1 icmp eq (i32* @g, i32* null) to i32), i32 65537), i32 2147483647)
-; CHECK-NEXT:[[B14:%.*]] = srem i32 ashr (i32 65536, i32 or (i32 zext (i1 icmp eq (i32* @g, i32* null) to i32), i32 65537)), [[B22]]
 ; CHECK-NEXT:[[B12:%.*]] = add nuw nsw i32 [[B15]], ashr (i32 65536, i32 or (i32 zext (i1 icmp eq (i32* @g, i32* null) to i32), i32 65537))
-; CHECK-NEXT:[[B8:%.*]] = shl i32 sdiv (i32 or (i32 zext (i1 icmp eq (i32* @g, i32* null) to i32), i32 65537), i32 2147483647), [[B14]]
-; CHECK-NEXT:[[B2:%.*]] = xor i32 [[B12]], [[B8]]
-; CHECK-NEXT:[[B:%.*]] = xor i32 [[B2]], -1
+; CHECK-NEXT:[[B:%.*]] = xor i32 [[B12]], -1
 ; CHECK-NEXT:store i32 [[B]], i32* undef, align 4
 ; CHECK-NEXT:ret void
 ;
Index: llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
===
--- llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
+++ llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
@@ -394,7 +394,7 @@
 ; PTR64_IDX64-NEXT:%ii = sext i32 %i to i64
 ; PTR64_IDX64-NEXT:--> (sext i32 {1,+,1}<%for.body> to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) --> (sext i32 (-1 + (trunc i64 (ptrtoint i64 (i32)* @sext_like_noop to i64) to i32)) to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
 ; PTR64_IDX64-NEXT:%div = sdiv i64 5, %ii
-; PTR64_IDX64-NEXT:--> %div U: full-set S: full-set --> sdiv (i64 5, i64 sext (i32 add (i32 ptrtoint (i64 (i32)* @sext_like_noop to i32), i32 -1) to i64)) U: full-set S: full-set
+; PTR64_IDX64-NEXT:--> %div U: full-set S: full-set
 ; PTR64_IDX64-NEXT:%i = phi i32 [ %inc, %for.body ], [ 1, %entry ]
 ; PTR64_IDX64-NEXT:--> {1,+,1}<%for.body> U: [1,0) S: [1,0) Exits: (-1 + (trunc i64 (ptrtoint i64 (i32)* @sext_like_noop to i64) to i32)) LoopDispositions: { %for.body: Computable }
 ; PTR64_IDX64-NEXT:%inc = add nuw i32 %i, 1
@@ -411,7 +411,7 @@
 ; PTR64_IDX32-NEXT:%ii = sext i32 %i to i64
 ; PTR64_IDX32-NEXT:--> (sext i32 {1,+,1}<%for.body> to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) --> (sext i32 (-1 + ptrtoint (i64 (i32)* @sext_like_noop to i32)) to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
 ; PTR64_IDX32-NEXT:%div = sdiv i64 5, %ii
-; PTR64_IDX32-NEXT:--> %div U: full-set S: full-set --> sdiv (i64 5, i64 sext (i32 add (i32 ptrtoint (i64 (i32)* @sext_like_noop to i32), i32 -1) to i64)) U: full-set S: full-set
+; PTR64_IDX32-NEXT:--> %div U: full-set S: full-set
 ; PTR64_IDX32-NEXT:%i = phi i32 [ %inc, %for.body ], [ 1, %entry ]
 ; PTR64_IDX32-NEXT:--> {1,+,1}<%for.body> U: [1,0) S: [1,0) Exits: (-1 + ptrtoint (i64 (i32)* @sext_like_noop to i32)) LoopDispositions: { %for.body: Computable }
 ; PTR64_IDX32-NEXT:%inc = add nuw i32 %i, 1
@@ -428,7 +428,7 @@
 ; PTR16_IDX16-NEXT:%ii = sext i32 %i to i64
 ; PTR16_IDX16-NEXT:--> (sext i32 {1,+,1}<%for.body> to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) --> (-1 + (zext i16 (ptrtoint i64 (i32)* @sext_like_noop to i16) to 

[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-05 Thread Kai Nacke via Phabricator via cfe-commits
Kai added a comment.

Did you consider to make this more generalized? From skimming through the 
change, I see only 2 ppc-specific things:

- Loading of the canary word
- Value of `XORWord`

The first bullet is solved by the the other inline comment I made.
The second bullet can be solved by using all 64 bits. If a 32 bit value is 
used, the upper bits are ignored because the `VT` should be `MVT::i32` in this 
case.




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11154-11156
+GlobalValue *GV = (Subtarget.isAIXABI())
+  ? M->getGlobalVariable(AIXSSPCanaryWordName)
+  : M->getNamedValue("__stack_chk_guard");

I think this can be simplified using `getSDagStackGuard()`.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11157
+  : M->getNamedValue("__stack_chk_guard");
+if (GV == nullptr) { // linux uses LOAD_STACK_GUARD node instead of having 
a
+ // canary word global value

pscoro wrote:
> Addressing a comment from the previous review, GV != nullptr can not be an 
> assert because linux implements stack guard loading differently than aix. 
> This review now also supports linux as well
You can simplify the code by reordering the conditions:


```
if (useLoadStackGuardNode()) {
  // LOAD_STACK_GUARD
} else if (Value *GV = getSDagStackGuard(M)) {
  // AIX implementation
} else
  llvm_unreachable("Unhandled stack guard case");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

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


[clang-tools-extra] 9ab67cc - [pseudo] Implement guard extension.

2022-07-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-05T15:55:15+02:00
New Revision: 9ab67cc8bfe7181b7d775bab4d7a908dc8774889

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

LOG: [pseudo] Implement guard extension.

- Extend the GLR parser to allow conditional reduction based on the
  guard functions;
- Implement two simple guards (contextual-override/final) for cxx.bnf;
- layering: clangPseudoCXX depends on clangPseudo (as the guard function need
  to access the TokenStream);

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

Added: 
clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp

Modified: 
clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
clang-tools-extra/pseudo/gen/Main.cpp
clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
clang-tools-extra/pseudo/include/clang-pseudo/Language.h
clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
clang-tools-extra/pseudo/lib/GLR.cpp
clang-tools-extra/pseudo/lib/cli/CLI.cpp
clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
clang-tools-extra/pseudo/lib/cxx/CXX.cpp
clang-tools-extra/pseudo/lib/cxx/cxx.bnf
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp 
b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
index 02f4a40fae7c7..087ab6c250e39 100644
--- a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
+++ b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
@@ -122,8 +122,7 @@ static void glrParse(benchmark::State &State) {
   for (auto _ : State) {
 pseudo::ForestArena Forest;
 pseudo::GSS GSS;
-pseudo::glrParse(Stream, ParseParams{Lang->G, Lang->Table, Forest, GSS},
- StartSymbol);
+pseudo::glrParse(ParseParams{Stream, Forest, GSS}, StartSymbol, *Lang);
   }
   State.SetBytesProcessed(static_cast(State.iterations()) *
   SourceText->size());
@@ -136,9 +135,7 @@ static void full(benchmark::State &State) {
 TokenStream Stream = lexAndPreprocess();
 pseudo::ForestArena Forest;
 pseudo::GSS GSS;
-pseudo::glrParse(lexAndPreprocess(),
- ParseParams{Lang->G, Lang->Table, Forest, GSS},
- StartSymbol);
+pseudo::glrParse(ParseParams{Stream, Forest, GSS}, StartSymbol, *Lang);
   }
   State.SetBytesProcessed(static_cast(State.iterations()) *
   SourceText->size());

diff  --git a/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp 
b/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
index ea1606b330be3..87b9d15480cc3 100644
--- a/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
+++ b/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
@@ -43,9 +43,8 @@ class Fuzzer {
 clang::pseudo::GSS GSS;
 const Language &Lang = getLanguageFromFlags();
 auto &Root =
-glrParse(ParseableStream,
- clang::pseudo::ParseParams{Lang.G, Lang.Table, Arena, GSS},
- *Lang.G.findNonterminal("translation-unit"));
+glrParse(clang::pseudo::ParseParams{ParseableStream, Arena, GSS},
+ *Lang.G.findNonterminal("translation-unit"), Lang);
 if (Print)
   llvm::outs() << Root.dumpRecursive(Lang.G);
   }

diff  --git a/clang-tools-extra/pseudo/gen/Main.cpp 
b/clang-tools-extra/pseudo/gen/Main.cpp
index 5964cc8143f05..b74f3d46c3560 100644
--- a/clang-tools-extra/pseudo/gen/Main.cpp
+++ b/clang-tools-extra/pseudo/gen/Main.cpp
@@ -79,6 +79,14 @@ int main(int argc, char *argv[]) {
 
   switch (Emit) {
   case EmitSymbolList:
+Out.os() << R"cpp(
+#ifndef NONTERMINAL
+#define NONTERMINAL(X, Y)
+#endif
+#ifndef EXTENSION
+#define EXTENSION(X, Y)
+#endif
+)cpp";
 for (clang::pseudo::SymbolID ID = 0; ID < G.table().Nonterminals.size();
  ++ID) {
   std::string Name = G.symbolName(ID).str();
@@ -86,6 +94,16 @@ int main(int argc, char *argv[]) {
   std::replace(Name.begin(), Name.end(), '-', '_');
   Out.os() << llvm::formatv("NONTERMINAL({0}, {1})\n", Name, ID);
 }
+for (clang::pseudo::ExtensionID EID = 1 /*skip the sentinel 0 value*/;
+ EID < G.table().AttributeValues.size(); ++EID) {
+  llvm::StringRef Name = G.table().AttributeValues[EID];
+  assert(!Name.empty());
+  Out.os() << llvm::formatv("EXTENSION({0}, {1})\n", Name, EID);
+}
+Out.os() << R"cpp(
+#undef NONTERMINAL
+#undef EXTENSION
+)cpp";
 break;
   case EmitGrammarContent:
 for (llvm::StringRef Line : llvm::split(GrammarText, '\n')) {

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
index 51fb233bf9962..ebf54685b01b2 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.

[PATCH] D127448: [pseudo] Implement guard extension.

2022-07-05 Thread Haojian Wu 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 rG9ab67cc8bfe7: [pseudo] Implement guard extension. (authored 
by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127448

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cli/CLI.cpp
  clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -81,6 +81,14 @@
 ADD_FAILURE() << "No such symbol found: " << Name;
 return 0;
   }
+  ExtensionID extensionID(llvm::StringRef AttrValueName) const {
+for (ExtensionID EID = 0; EID < TestLang.G.table().AttributeValues.size();
+ ++EID)
+  if (TestLang.G.table().AttributeValues[EID] == AttrValueName)
+return EID;
+ADD_FAILURE() << "No such attribute value found: " << AttrValueName;
+return 0;
+  }
 
   RuleID ruleFor(llvm::StringRef NonterminalName) const {
 auto RuleRange =
@@ -131,7 +139,7 @@
   ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
   glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal,
-   {TestLang.G, TestLang.Table, Arena, GSStack}, NewHeads);
+   {emptyTokenStream(), Arena, GSStack}, TestLang, NewHeads);
 
   EXPECT_THAT(NewHeads,
   UnorderedElementsAre(AllOf(state(4), parsedSymbol(&SemiTerminal),
@@ -164,7 +172,7 @@
 
   std::vector Heads = {GSSNode1};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode1,
  AllOf(state(2), parsedSymbolID(id("class-name")),
@@ -202,7 +210,8 @@
   TestLang.Table = std::move(B).build();
 
   std::vector Heads = {GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode4,
@@ -254,7 +263,8 @@
   TestLang.Table = std::move(B).build();
 
   std::vector Heads = {GSSNode3, GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   // Verify that the stack heads are joint at state 5 after reduces.
   EXPECT_THAT(Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -309,7 +319,7 @@
 
   std::vector Heads = {GSSNode3, GSSNode4};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
 
   EXPECT_THAT(
   Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -343,14 +353,16 @@
 
   // When the lookahead is +, reduce is performed.
   std::vector Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::plus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::plus), {emptyTokenStream(), Arena, GSStack},
+TestLang);
   EXPECT_THAT(Heads,
   ElementsAre(GSSNode1, AllOf(state(2), parsedSymbolID(id("term")),
   parents(Root;
 
   // When the lookahead is -, reduce is not performed.
   Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::minus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::minus),
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, ElementsAre(GSSNode1));
 }
 
@@ -376,7 +388,7 @@
   const TokenStream &Tokens = cook(lex("{ abc", LOptions), LOptions);
 
   const ForestNode &Parsed =
-  glrParse(Tokens, {TestLang.G, TestLang.Table, Arena, GSStack}, id("test"));
+  glrParse({Tokens, Arena, GSStack}, id("test"), TestLang);
   // Verify that there is no duplicated sequence node of `expr := IDENTIFIER`
   // in the forest, see the `#1` and `=#1` in the dump string.
   EXPECT_EQ(Parsed.dumpRecursive(TestLang.G),
@@ -413,7 +425,7 

[PATCH] D128820: [ConstExpr] Don't create div/rem expressions

2022-07-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/lib/IR/Constants.cpp:2368-2379
+bool ConstantExpr::isDesirableBinOp(unsigned Opcode) {
+  assert(Instruction::isBinaryOp(Opcode) && "Argument must be binop opcode");
+  switch (Opcode) {
+  case Instruction::UDiv:
+  case Instruction::SDiv:
+  case Instruction::URem:
+  case Instruction::SRem:

nhaehnle wrote:
> Is the plan to successively make more ops undesirable? Perhaps this should be 
> a whitelist instead of a blacklist.
I went with the "Why don't we have both?" approach here and explicitly listed 
both the desirable and undesirable binops. And yes, I plan to successively move 
these until only add and sub are left in the bottom list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128820

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


[PATCH] D128486: [pseudo] Add error-recovery framework & brace-based recovery

2022-07-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Looks great, let's ship it! feel free to land it in any form you think it is 
suitable.




Comment at: clang-tools-extra/pseudo/include/clang-pseudo/GLR.h:150
+// OldHeads is the parse state at TokenIndex.
+// This function consumes consumes zero or more tokens by advancing TokenIndex,
+// and places any recovery states created in NewHeads.

nit: remove the duplicated `consumes`.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h:148
+RecoveryStrategy Strategy; // Heuristic choosing the tokens to match.
+SymbolID Result;   // The symbol that is produced.
+  };

nit: mention the `Result` must be a nonterminal.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h:131
+  // Expected to be called by LR parsers.
+  llvm::ArrayRef getActions(StateID State, SymbolID Terminal) const;
   // Returns the state after we reduce a nonterminal.

nit: unrelated method?



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h:248
+  // A given state has [RecoveryOffset[S], RecoveryOffset[S+1]).
+  std::vector RecoveryOffset;
+  std::vector Recoveries;

sammccall wrote:
> hokein wrote:
> > I see the motivation of the `OffsetTable` structure now, this would come as 
> > a follow-up to simplify the `ReduceOffset` and `RecoveryOffset`, right?
> Yes. Though I'm on the fence about whether it's worth it with one case (it's 
> a bit awkward to generalize the building IIRC).
A motivating bit is that it is tricky to implement a correct `get` method (we 
both made the same out-of-bound issue). I'm fine with the current form, we can 
revisit it afterwards.



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:178
+const ForestNode &Placeholder =
+Params.Forest.createOpaque(Option->Symbol, Option->Position);
+const GSS::Node *NewHead = Params.GSStack.addNode(

should we worry about the case where we create a duplicated forest node? e.g. 
we have two best options and both recover to the same nonterminal.



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:44
+
+void glrRecover(llvm::ArrayRef OldHeads,
+unsigned &TokenIndex, const TokenStream &Tokens,

sammccall wrote:
> hokein wrote:
> > The `GLR.cpp` file is growing significantly, I think the recovery part is 
> > large enough to be lived in a separate file `GLRRecovery.cpp`, but the 
> > declaration can still be in the `GLR.h`.
> This is interesting, recover/shift/reduce/parse are (vertically) 
> self-contained enough that it didn't seem like a big problem yet...
> 
> If the concern is file length, maybe we'd thather start with `reduce`; if 
> it's relatedness, `GSS`?
> 
> My line count is:
>  - recover: 156
>  - shift: 47
>  - reduce: 319
>  - parse: 87
>  - GSS: 66
Yeah, indeed these pieces can be split, my main concern is not file length -- I 
would prefer keeping shift/reduce/parse into a single file, as they form a 
complete GLR algorithm (splitting them would make it harder to read and follow).

Recovery seems like a different thing, I would image this part of code will 
grow more in the future
- the GLR algorithm has the core recovery mechanism framework with some 
fallback recovery strategies (eof, brackets)
- we have different recovery strategies implemented (some of them might be 
cxx-specific, probably be part of pseudoCXX library);





Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:68
+// one arbitrarily.
+std::vector Path;
+  };

sammccall wrote:
> hokein wrote:
> > nit: maybe name it `Parses` or `PartialParses`. Path make me think this is 
> > a patch of GSS nodes.
> Renamed to DiscardedParse, does that work for you?
It is better than the original name. The `DiscardedParse` is a bit weird when 
we start to put it under the opaque node, in that sense, they are not 
discarded, IMO



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:83
+  //expr := type ( . expr )   - (up) we should recover this outer expr
+  //expr := . type ( expr )   - (up+left) we should not recover this type!
+  //

sammccall wrote:
> hokein wrote:
> > I think you're right -- I thought the first GSS node with a recovery state 
> > we encounter during the Walkup  state is the node we want. 
> > 
> > This example is a little confusing (it still matches our previous mental 
> > model), I didn't get it until we discussed offline. I think the following 
> > example is clearer 
> > 
> > ```
> > parsing the text `if (true) else ?`
> > 
> > IfStmt := if (stmt) else . stmt - which we're currently parsing
> > IfStmt := if (.stmt) else stmt  - (left) the first recovery GSS node, 
> > should not recover from this
> > IfS

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

2022-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 442298.
aaron.ballman added a comment.
Herald added projects: LLVM, clang-tools-extra.
Herald added a subscriber: llvm-commits.

Rebased and made the same changes for the LLVM and clang-tools-extra tests.


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] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-07-05 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj added a comment.

@nridge @sammccall if you don't have any further comments, I will commit this 
tomorrow, and maybe think about how to extend it to signature help/code 
completion :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 442299.
Codesbyusman added a comment.

updating the test files for the last update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/Parser/objc-static-assert.m
  clang/test/Parser/objc-static-assert.mm
  clang/test/Sema/builtin-align.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/access-base-class.cpp
  clang/test/SemaCXX/alias-template.cpp
  clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/complex-folding.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx2a-template-lambdas.cpp
  clang/test/SemaCXX/delete-and-function-templates.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/static-assert-cxx17.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/test/SemaCXX/using-decl-templates.cpp
  clang/test/SemaCXX/weak-init.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/pr52909.cpp
  clang/test/SemaTemplate/pr52970.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -184,7 +184,7 @@
 
 namespace Diags {
   struct A { int n, m; };
-  template struct X { static_assert(a.n == a.m); }; // expected-error {{static_assert failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
+  template struct X { static_assert(a.n == a.m); }; // expected-error {{static assertion failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
   template struct X; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}}
 }
 
Index: clang/test/SemaTemplate/pr52970.cpp
===
--- clang/test/SemaTemplate/pr52970.cpp
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -32,7 +32,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingFunctionName
@@ -57,7 +57,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingPointer
Index: clang/test/SemaTemplate/pr52909.cpp
===
--- clang/test/SemaTemplate/pr52909.cpp
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -15,7 +15,7 @@
   // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
 };
 
-static_assert(Beginable); // expected-error {{static_assert failed}}
+static_assert(Beginable); // expected-error {{static assertion failed}}
  // expected-note@-1 {{does not satisfy 'Beginable'}}
 } // namespace PR52905
 
@@ -48,7 +48,7 @@
 static void begin(double);
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
 
 } // namespace PR52909b
@@ -65,7 +65,7 @@
 int *f() const;
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
 
 } // namespace PR53075
Index: clang/test/SemaTemplate/instantiate-var-template.cpp
===
--- clang/test/SemaTemplate/instantiate-var-template.cpp
+++ clang/test/SemaTemplate/instantiate-var-template.cpp
@@ -31,7 +31,7 @@
   static_assert(b == 1, ""); // expected-note {{in instantiation of}} expected-error {{no

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

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

we've already discussed most of these so no action needed, but here are some of 
them before they become completely irrelevant :P




Comment at: clang-tools-extra/clangd/TUScheduler.cpp:457
+// Give up on this request, releasing resources if any.
+void abandon() {
+  std::lock_guard Lock(Mu);

in the scenario of a shutdown (or destruction of a preamble thread, because 
file is closed), i think we also want to call cancellation of the acquire 
release here. as things stand unless we're destroying the throttler itself i 
think these requests might stick around.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:483
 // Wait until stop is called or there is a request.
-ReqCV.wait(Lock, [this] { return NextReq || Done; });
+ReqCV.wait(Lock, [&] { return NextReq || Done; });
 if (Done)

any reason for capturing locals here now ?



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:500
+
+  ReqCV.wait(Lock, [&] { return TState->ready() || Done; });
+  if (Done) {

we can move the wait into the `if block` above, i think.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:500
+
+  ReqCV.wait(Lock, [&] { return TState->ready() || Done; });
+  if (Done) {

kadircet wrote:
> we can move the wait into the `if block` above, i think.
so this implies preamblerequest we issued an acquire for, and the preamble 
request we'll be building below might be different. this is not a concern 
initially but i think it would be nice to not get cornered when we want to 
notify the throttler about such changes.

i guess `PreambleThread::update` would be the natural place to communicate such 
changes, if we're overwriting a preamblerequest and there's a pending acquire 
we can either cancel and make preamblethread re-issue acquire, or we can have a 
new API on throttler to update the request signals. i think, both of these 
require having throttlestate as a member. maybe we should do that directly to 
remind ourselves of this in the future?



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1573
+  case PreambleAction::Queued:
+Result.push_back("headers are queued");
+break;

let's use "includes" here, similar to above.



Comment at: clang-tools-extra/clangd/TUScheduler.h:114
+  // If it fails (e.g. races), resources are acquired and must be released.
+  virtual CancelFn acquire(llvm::StringRef Filename, AcquireCallback) = 0;
+

can we make the first parameter a struct instead? i feel like we might end up 
adding more parameters describing the reason for the request here.


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] D129100: [clangd] Support external throttler for preamble builds

2022-07-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 442308.
sammccall added a comment.

Simplify, leaning more on the throttler's lifetime and expecting it to manage
state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129100

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1372,6 +1372,141 @@
 CheckNoFileActionsSeesLastActiveFile(LastActive);
   }
 }
+
+TEST_F(TUSchedulerTests, PreambleThrottle) {
+  const int NumRequests = 4;
+  // Silly throttler that waits for 4 requests, and services them in reverse.
+  // Doesn't honor cancellation but records it.
+  struct : public PreambleThrottler {
+std::mutex Mu;
+std::vector Acquires;
+std::vector Releases;
+llvm::DenseMap Callbacks;
+// If set, the notification is signalled after acquiring the specified ID.
+llvm::Optional> Notify;
+
+RequestID acquire(llvm::StringRef Filename, Callback CB) override {
+  RequestID ID;
+  Callback Invoke;
+  {
+std::lock_guard Lock(Mu);
+ID = Acquires.size();
+Acquires.emplace_back(Filename);
+// If we're full, satisfy this request immediately.
+if (Acquires.size() == NumRequests) {
+  Invoke = std::move(CB);
+} else {
+  Callbacks.try_emplace(ID, std::move(CB));
+}
+  }
+  if (Invoke)
+Invoke();
+  if (Notify && ID == Notify->first) {
+Notify->second->notify();
+Notify.reset();
+  }
+  return ID;
+}
+
+void release(RequestID ID) override {
+  Releases.push_back(ID);
+  Callback SatisfyNext;
+  {
+std::lock_guard Lock(Mu);
+if (ID > 0)
+  SatisfyNext = std::move(Callbacks[ID - 1]);
+  }
+  if (SatisfyNext)
+SatisfyNext();
+}
+
+void reset() {
+  Acquires.clear();
+  Releases.clear();
+  Callbacks.clear();
+}
+  } Throttler;
+
+  struct CaptureBuiltFilenames : public ParsingCallbacks {
+std::vector &Filenames;
+CaptureBuiltFilenames(std::vector &Filenames)
+: Filenames(Filenames) {}
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &CI, ASTContext &Ctx,
+   Preprocessor &PP, const CanonicalIncludes &) override {
+  // Deliberately no synchronization.
+  // The PreambleThrottler should serialize these calls, if not then tsan
+  // will find a bug here.
+  Filenames.emplace_back(Path);
+}
+  };
+
+  auto Opts = optsForTest();
+  Opts.AsyncThreadsCount = 2 * NumRequests; // throttler is the bottleneck
+  Opts.PreambleThrottler = &Throttler;
+
+  std::vector Filenames;
+
+  {
+std::vector BuiltFilenames;
+TUScheduler S(CDB, Opts,
+  std::make_unique(BuiltFilenames));
+for (unsigned I = 0; I < NumRequests; ++I) {
+  auto Path = testPath(std::to_string(I) + ".cc");
+  Filenames.push_back(Path);
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
+}
+ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+
+// The throttler saw all files, and we built them.
+EXPECT_THAT(Throttler.Acquires,
+testing::UnorderedElementsAreArray(Filenames));
+EXPECT_THAT(BuiltFilenames,
+testing::UnorderedElementsAreArray(Filenames));
+// We built the files in reverse order that the throttler saw them.
+EXPECT_THAT(BuiltFilenames,
+testing::ElementsAreArray(Throttler.Acquires.rbegin(),
+  Throttler.Acquires.rend()));
+// Resources for each file were correctly released.
+EXPECT_THAT(Throttler.Releases, ElementsAre(3, 2, 1, 0));
+  }
+
+  Throttler.reset();
+  Filenames.clear();
+
+  // This time, enqueue 2 files, then cancel one of them while still waiting.
+  // Finally shut down the server. Observe that everything gets cleaned up.
+  Notification After2;
+  Throttler.Notify = {1, &After2};
+  std::vector BuiltFilenames;
+  {
+TUScheduler S(CDB, Opts,
+  std::make_unique(BuiltFilenames));
+for (unsigned I = 0; I < NumRequests / 2; ++I) {
+  auto Path = testPath(std::to_string(I) + ".cc");
+  Filenames.push_back(Path);
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
+}
+After2.wait();
+
+// The throttler saw all files, but we built none.
+EXPECT_THAT(Throttler.Acquires,
+testing::UnorderedElementsAreArray(Filenames));
+EXPECT_THAT(BuiltFilena

[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

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



Comment at: clang/include/clang/Sema/HLSLExternalSemaSource.h:22
+class HLSLExternalSemaSource : public ExternalSemaSource {
+  static char ID;
+

It looks like you're missing the `classof` and `isA` support that actually uses 
this.



Comment at: clang/lib/Headers/hlsl/hlsl_basic_types.h:30
 #ifdef __HLSL_ENABLE_16_BIT
-typedef int16_t int16_t2 __attribute__((ext_vector_type(2)));
-typedef int16_t int16_t3 __attribute__((ext_vector_type(3)));
-typedef int16_t int16_t4 __attribute__((ext_vector_type(4)));
-typedef uint16_t uint16_t2 __attribute__((ext_vector_type(2)));
-typedef uint16_t uint16_t3 __attribute__((ext_vector_type(3)));
-typedef uint16_t uint16_t4 __attribute__((ext_vector_type(4)));
+typedef vector int16_t2;
+typedef vector int16_t3;

Can you explain these changes in light of:

> The problem is that templates aren't supported before HLSL 2021, and type 
> aliases still aren't supported in HLSL.

This still looks like it's using template and type aliases.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:41-44
+  auto *UsingDecl = UsingDirectiveDecl::Create(
+  AST, AST.getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
+  NestedNameSpecifierLoc(), SourceLocation(), HLSLNamespace,
+  AST.getTranslationUnitDecl());

And users won't find this behavior surprising? I would be worried that the user 
has their own globally declared type that this hidden using directive will then 
cause to be ambiguous: https://godbolt.org/z/jMsW54vWe -- when users hit this 
themselves, the location of the conflict is going to point into nowhere-land, 
which is also rather unfortunate.

Actually, the more I think about this, the less comfortable I am with it. This 
also means you have to be *very* careful about conflicts with STL names, and it 
means that any new declarations added to the `hlsl` namespace automatically 
risk breaking code.

Aside: any particular reason the namespace declaration is implicit but the 
using directive declaration is not?



Comment at: clang/test/AST/HLSL/vector-alias.hlsl:20
+// CHECK: UsingDirectiveDecl 0x{{[0-9a-fA-F]+}} <>  Namespace 0x{{[0-9a-fA-F]+}} 'hlsl'
+
+[numthreads(1,1,1)]

It's good that there are tests to verify the AST behavior, but there should 
also be tests showing the behavior in failure cases (like instantiating the 
vector incorrectly, ambiguous names as described above, etc) to see if we can 
live with the behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

___
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-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 442309.
sammccall added a comment.

remove dead code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129100

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1372,6 +1372,141 @@
 CheckNoFileActionsSeesLastActiveFile(LastActive);
   }
 }
+
+TEST_F(TUSchedulerTests, PreambleThrottle) {
+  const int NumRequests = 4;
+  // Silly throttler that waits for 4 requests, and services them in reverse.
+  // Doesn't honor cancellation but records it.
+  struct : public PreambleThrottler {
+std::mutex Mu;
+std::vector Acquires;
+std::vector Releases;
+llvm::DenseMap Callbacks;
+// If set, the notification is signalled after acquiring the specified ID.
+llvm::Optional> Notify;
+
+RequestID acquire(llvm::StringRef Filename, Callback CB) override {
+  RequestID ID;
+  Callback Invoke;
+  {
+std::lock_guard Lock(Mu);
+ID = Acquires.size();
+Acquires.emplace_back(Filename);
+// If we're full, satisfy this request immediately.
+if (Acquires.size() == NumRequests) {
+  Invoke = std::move(CB);
+} else {
+  Callbacks.try_emplace(ID, std::move(CB));
+}
+  }
+  if (Invoke)
+Invoke();
+  if (Notify && ID == Notify->first) {
+Notify->second->notify();
+Notify.reset();
+  }
+  return ID;
+}
+
+void release(RequestID ID) override {
+  Releases.push_back(ID);
+  Callback SatisfyNext;
+  {
+std::lock_guard Lock(Mu);
+if (ID > 0)
+  SatisfyNext = std::move(Callbacks[ID - 1]);
+  }
+  if (SatisfyNext)
+SatisfyNext();
+}
+
+void reset() {
+  Acquires.clear();
+  Releases.clear();
+  Callbacks.clear();
+}
+  } Throttler;
+
+  struct CaptureBuiltFilenames : public ParsingCallbacks {
+std::vector &Filenames;
+CaptureBuiltFilenames(std::vector &Filenames)
+: Filenames(Filenames) {}
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &CI, ASTContext &Ctx,
+   Preprocessor &PP, const CanonicalIncludes &) override {
+  // Deliberately no synchronization.
+  // The PreambleThrottler should serialize these calls, if not then tsan
+  // will find a bug here.
+  Filenames.emplace_back(Path);
+}
+  };
+
+  auto Opts = optsForTest();
+  Opts.AsyncThreadsCount = 2 * NumRequests; // throttler is the bottleneck
+  Opts.PreambleThrottler = &Throttler;
+
+  std::vector Filenames;
+
+  {
+std::vector BuiltFilenames;
+TUScheduler S(CDB, Opts,
+  std::make_unique(BuiltFilenames));
+for (unsigned I = 0; I < NumRequests; ++I) {
+  auto Path = testPath(std::to_string(I) + ".cc");
+  Filenames.push_back(Path);
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
+}
+ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+
+// The throttler saw all files, and we built them.
+EXPECT_THAT(Throttler.Acquires,
+testing::UnorderedElementsAreArray(Filenames));
+EXPECT_THAT(BuiltFilenames,
+testing::UnorderedElementsAreArray(Filenames));
+// We built the files in reverse order that the throttler saw them.
+EXPECT_THAT(BuiltFilenames,
+testing::ElementsAreArray(Throttler.Acquires.rbegin(),
+  Throttler.Acquires.rend()));
+// Resources for each file were correctly released.
+EXPECT_THAT(Throttler.Releases, ElementsAre(3, 2, 1, 0));
+  }
+
+  Throttler.reset();
+  Filenames.clear();
+
+  // This time, enqueue 2 files, then cancel one of them while still waiting.
+  // Finally shut down the server. Observe that everything gets cleaned up.
+  Notification After2;
+  Throttler.Notify = {1, &After2};
+  std::vector BuiltFilenames;
+  {
+TUScheduler S(CDB, Opts,
+  std::make_unique(BuiltFilenames));
+for (unsigned I = 0; I < NumRequests / 2; ++I) {
+  auto Path = testPath(std::to_string(I) + ".cc");
+  Filenames.push_back(Path);
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
+}
+After2.wait();
+
+// The throttler saw all files, but we built none.
+EXPECT_THAT(Throttler.Acquires,
+testing::UnorderedElementsAreArray(Filenames));
+EXPECT_THAT(BuiltFilenames, testing::IsEmpty());
+// We haven't released anything yet, 

[clang] a4772cb - Revert "[SimplifyCFG] Thread branches on same condition in more cases (PR54980)"

2022-07-05 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-07-05T16:57:46+02:00
New Revision: a4772cbaf0dc717ab6b4639272ca2910897613f0

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

LOG: Revert "[SimplifyCFG] Thread branches on same condition in more cases 
(PR54980)"

This reverts commit 4e545bdb355a470d601e9bb7f7b2693c99e61a3e.

The newly added test is the third infinite combine loop caused by
this change. In this case, it's a combination of the branch to
common dest and jump threading folds that keeps peeling off loop
iterations.

The core problem here is that we ideally would not thread over
loop backedges, both because it is potentially non-profitable
(it may break canonical loop structure) and because it may result
in these kinds of loops. Unfortunately, due to the lack of a
dominator tree in SimplifyCFG, there is no good way to prevent
this. While we have LoopHeaders, this is an optional structure and
we don't do a good job of keeping it up to date. It would be fine
for a profitability check, but is not suitable for a correctness
check.

So for now I'm just giving up here, as I don't see a good way to
robustly prevent infinite combine loops.

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

Added: 


Modified: 
clang/test/CodeGenObjC/exceptions.m
clang/test/CodeGenObjCXX/exceptions-legacy.mm
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/CodeGen/AArch64/arm64-andCmpBrToTBZ.ll
llvm/test/Transforms/GVNSink/sink-common-code.ll
llvm/test/Transforms/SimplifyCFG/X86/sink-common-code.ll
llvm/test/Transforms/SimplifyCFG/jump-threading.ll
llvm/test/Transforms/SimplifyCFG/pr55765.ll
llvm/test/Transforms/SimplifyCFG/wc-widen-block.ll

Removed: 




diff  --git a/clang/test/CodeGenObjC/exceptions.m 
b/clang/test/CodeGenObjC/exceptions.m
index 302e8af51ed8e..e01965edd73f2 100644
--- a/clang/test/CodeGenObjC/exceptions.m
+++ b/clang/test/CodeGenObjC/exceptions.m
@@ -25,12 +25,11 @@ void f1(void) {
 // CHECK-NEXT: icmp
 // CHECK-NEXT: br i1
 @try {
+// CHECK:  call void asm sideeffect "", "=*m"
 // CHECK:  call void asm sideeffect "", "*m"
 // CHECK-NEXT: call void @foo()
   foo();
 // CHECK:  call void @objc_exception_try_exit
-// CHECK:  try.handler:
-// CHECK:  call void asm sideeffect "", "=*m"
 
 } @finally {
   break;
@@ -54,6 +53,12 @@ int f2(void) {
   // CHECK-NEXT:   [[CAUGHT:%.*]] = icmp eq i32 [[SETJMP]], 0
   // CHECK-NEXT:   br i1 [[CAUGHT]]
   @try {
+// Landing pad.  Note that we elide the re-enter.
+// CHECK:  call void asm sideeffect "", "=*m,=*m"(i32* nonnull 
elementtype(i32) [[X]]
+// CHECK-NEXT: call i8* @objc_exception_extract
+// CHECK-NEXT: [[T1:%.*]] = load i32, i32* [[X]]
+// CHECK-NEXT: [[T2:%.*]] = add nsw i32 [[T1]], -1
+
 // CHECK: store i32 6, i32* [[X]]
 x++;
 // CHECK-NEXT: call void asm sideeffect "", "*m,*m"(i32* nonnull 
elementtype(i32) [[X]]
@@ -62,12 +67,6 @@ int f2(void) {
 // CHECK-NEXT: [[T:%.*]] = load i32, i32* [[X]]
 foo();
   } @catch (id) {
-// Landing pad.  Note that we elide the re-enter.
-// CHECK:  call void asm sideeffect "", "=*m,=*m"(i32* nonnull 
elementtype(i32) [[X]]
-// CHECK-NEXT: call i8* @objc_exception_extract
-// CHECK-NEXT: [[T1:%.*]] = load i32, i32* [[X]]
-// CHECK-NEXT: [[T2:%.*]] = add nsw i32 [[T1]], -1
-
 x--;
   }
 

diff  --git a/clang/test/CodeGenObjCXX/exceptions-legacy.mm 
b/clang/test/CodeGenObjCXX/exceptions-legacy.mm
index 4166f635deecf..9d9e4e4b86df6 100644
--- a/clang/test/CodeGenObjCXX/exceptions-legacy.mm
+++ b/clang/test/CodeGenObjCXX/exceptions-legacy.mm
@@ -63,19 +63,20 @@ void test1(id obj, bool *failed) {
 //   Body.
 // CHECK:  invoke void @_Z3foov()
 
+//   Catch handler.  Reload of 'failed' address is unnecessary.
+// CHECK:  [[T0:%.*]] = load i8*, i8**
+// CHECK-NEXT: store i8 1, i8* [[T0]],
+// CHECK-NEXT: br label
+
 //   Leave the @try.
 // CHECK:  call void @objc_exception_try_exit([[BUF_T]]* nonnull [[BUF]])
 // CHECK-NEXT: br label
 // CHECK:  ret void
 
+
 //   Real EH cleanup.
 // CHECK:  [[T0:%.*]] = landingpad
 // CHECK-NEXT:cleanup
 // CHECK-NEXT: call void @objc_exception_try_exit([[BUF_T]]* nonnull [[BUF]])
 // CHECK-NEXT: resume
 
-//   Catch handler.  Reload of 'failed' address is unnecessary.
-// CHECK:  [[T0:%.*]] = load i8*, i8**
-// CHECK-NEXT: store i8 1, i8* [[T0]],
-// CHECK-NEXT: br label
-

diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index bbf596e1a1405..6b0f1e3760960 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2976,10 +2976,8 @@ static bool 
BlockIsSimpleEnoughToThre

[PATCH] D124159: [SimplifyCFG] Thread branches on same condition in more cases (PR54980)

2022-07-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

I ended up reverting this patch in 
https://github.com/llvm/llvm-project/commit/a4772cbaf0dc717ab6b4639272ca2910897613f0,
 because I reduced another infinite loop 
(https://github.com/llvm/llvm-project/issues/56203) to it as well, which makes 
it the third one. It's probably not possible to reliably prevent infinite 
combine loops in this area with a dominator tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124159

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Welp, fixed THIS problem but lead to another issue in libc++ that I'm still 
running down.  Stand by all :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

___
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-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:457
+// Give up on this request, releasing resources if any.
+void abandon() {
+  std::lock_guard Lock(Mu);

kadircet wrote:
> in the scenario of a shutdown (or destruction of a preamble thread, because 
> file is closed), i think we also want to call cancellation of the acquire 
> release here. as things stand unless we're destroying the throttler itself i 
> think these requests might stick around.
(this is obsolete, but...)

I don't think this leak is possible, after we get Cancel (from 
Throttler->acquire) then we wait until either:
 - request is satisfied (TState->ready() on line 500) in which case no cancel 
is needed, or
 - we call Cancel immediately on line 501.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:483
 // Wait until stop is called or there is a request.
-ReqCV.wait(Lock, [this] { return NextReq || Done; });
+ReqCV.wait(Lock, [&] { return NextReq || Done; });
 if (Done)

kadircet wrote:
> any reason for capturing locals here now ?
Just for consistency with the second `wait` below - I usually don't think it's 
interesting to list captures when no lifetimes are involved (because the lambda 
is invoked synchronously)



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:500
+
+  ReqCV.wait(Lock, [&] { return TState->ready() || Done; });
+  if (Done) {

kadircet wrote:
> kadircet wrote:
> > we can move the wait into the `if block` above, i think.
> so this implies preamblerequest we issued an acquire for, and the preamble 
> request we'll be building below might be different. this is not a concern 
> initially but i think it would be nice to not get cornered when we want to 
> notify the throttler about such changes.
> 
> i guess `PreambleThread::update` would be the natural place to communicate 
> such changes, if we're overwriting a preamblerequest and there's a pending 
> acquire we can either cancel and make preamblethread re-issue acquire, or we 
> can have a new API on throttler to update the request signals. i think, both 
> of these require having throttlestate as a member. maybe we should do that 
> directly to remind ourselves of this in the future?
> we can move the wait into the if block

that works, but it doesn't really seem clearer to me

`wait (..., cond)` is just `while (!cond) { ... }`, so the outer if is 
redundant.
On the other hand the if is important to the code it currently guards (for 
reasons explained in the comment), so it seems confusing to split its purpose 
in this way.

The only way it makes sense to me is as a microoptimization, but it doesn't 
seem like a useful one.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:500
+
+  ReqCV.wait(Lock, [&] { return TState->ready() || Done; });
+  if (Done) {

sammccall wrote:
> kadircet wrote:
> > kadircet wrote:
> > > we can move the wait into the `if block` above, i think.
> > so this implies preamblerequest we issued an acquire for, and the preamble 
> > request we'll be building below might be different. this is not a concern 
> > initially but i think it would be nice to not get cornered when we want to 
> > notify the throttler about such changes.
> > 
> > i guess `PreambleThread::update` would be the natural place to communicate 
> > such changes, if we're overwriting a preamblerequest and there's a pending 
> > acquire we can either cancel and make preamblethread re-issue acquire, or 
> > we can have a new API on throttler to update the request signals. i think, 
> > both of these require having throttlestate as a member. maybe we should do 
> > that directly to remind ourselves of this in the future?
> > we can move the wait into the if block
> 
> that works, but it doesn't really seem clearer to me
> 
> `wait (..., cond)` is just `while (!cond) { ... }`, so the outer if is 
> redundant.
> On the other hand the if is important to the code it currently guards (for 
> reasons explained in the comment), so it seems confusing to split its purpose 
> in this way.
> 
> The only way it makes sense to me is as a microoptimization, but it doesn't 
> seem like a useful one.
> the preamble request we'll be building below might be different

The request in general is (filename, signals). Filename clearly can't change. 
Signals can, but...

> i guess PreambleThread::update would be the natural place to communicate such 
> changes

I don't think so, I think signals naturally come from elsewhere in the system 
as `(filename, signal)` pairs and are best thought of as "sticky", where events 
affect both current and future throttling requests.

As such I think we might have an API like `Throttler->updateSignals(Filename, 
...)` and let the throttler join on filename, rather than req

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

2022-07-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 442319.
sammccall marked an inline comment as done.
sammccall added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129100

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1372,6 +1372,141 @@
 CheckNoFileActionsSeesLastActiveFile(LastActive);
   }
 }
+
+TEST_F(TUSchedulerTests, PreambleThrottle) {
+  const int NumRequests = 4;
+  // Silly throttler that waits for 4 requests, and services them in reverse.
+  // Doesn't honor cancellation but records it.
+  struct : public PreambleThrottler {
+std::mutex Mu;
+std::vector Acquires;
+std::vector Releases;
+llvm::DenseMap Callbacks;
+// If set, the notification is signalled after acquiring the specified ID.
+llvm::Optional> Notify;
+
+RequestID acquire(llvm::StringRef Filename, Callback CB) override {
+  RequestID ID;
+  Callback Invoke;
+  {
+std::lock_guard Lock(Mu);
+ID = Acquires.size();
+Acquires.emplace_back(Filename);
+// If we're full, satisfy this request immediately.
+if (Acquires.size() == NumRequests) {
+  Invoke = std::move(CB);
+} else {
+  Callbacks.try_emplace(ID, std::move(CB));
+}
+  }
+  if (Invoke)
+Invoke();
+  if (Notify && ID == Notify->first) {
+Notify->second->notify();
+Notify.reset();
+  }
+  return ID;
+}
+
+void release(RequestID ID) override {
+  Releases.push_back(ID);
+  Callback SatisfyNext;
+  {
+std::lock_guard Lock(Mu);
+if (ID > 0)
+  SatisfyNext = std::move(Callbacks[ID - 1]);
+  }
+  if (SatisfyNext)
+SatisfyNext();
+}
+
+void reset() {
+  Acquires.clear();
+  Releases.clear();
+  Callbacks.clear();
+}
+  } Throttler;
+
+  struct CaptureBuiltFilenames : public ParsingCallbacks {
+std::vector &Filenames;
+CaptureBuiltFilenames(std::vector &Filenames)
+: Filenames(Filenames) {}
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &CI, ASTContext &Ctx,
+   Preprocessor &PP, const CanonicalIncludes &) override {
+  // Deliberately no synchronization.
+  // The PreambleThrottler should serialize these calls, if not then tsan
+  // will find a bug here.
+  Filenames.emplace_back(Path);
+}
+  };
+
+  auto Opts = optsForTest();
+  Opts.AsyncThreadsCount = 2 * NumRequests; // throttler is the bottleneck
+  Opts.PreambleThrottler = &Throttler;
+
+  std::vector Filenames;
+
+  {
+std::vector BuiltFilenames;
+TUScheduler S(CDB, Opts,
+  std::make_unique(BuiltFilenames));
+for (unsigned I = 0; I < NumRequests; ++I) {
+  auto Path = testPath(std::to_string(I) + ".cc");
+  Filenames.push_back(Path);
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
+}
+ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+
+// The throttler saw all files, and we built them.
+EXPECT_THAT(Throttler.Acquires,
+testing::UnorderedElementsAreArray(Filenames));
+EXPECT_THAT(BuiltFilenames,
+testing::UnorderedElementsAreArray(Filenames));
+// We built the files in reverse order that the throttler saw them.
+EXPECT_THAT(BuiltFilenames,
+testing::ElementsAreArray(Throttler.Acquires.rbegin(),
+  Throttler.Acquires.rend()));
+// Resources for each file were correctly released.
+EXPECT_THAT(Throttler.Releases, ElementsAre(3, 2, 1, 0));
+  }
+
+  Throttler.reset();
+  Filenames.clear();
+
+  // This time, enqueue 2 files, then cancel one of them while still waiting.
+  // Finally shut down the server. Observe that everything gets cleaned up.
+  Notification After2;
+  Throttler.Notify = {1, &After2};
+  std::vector BuiltFilenames;
+  {
+TUScheduler S(CDB, Opts,
+  std::make_unique(BuiltFilenames));
+for (unsigned I = 0; I < NumRequests / 2; ++I) {
+  auto Path = testPath(std::to_string(I) + ".cc");
+  Filenames.push_back(Path);
+  S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
+}
+After2.wait();
+
+// The throttler saw all files, but we built none.
+EXPECT_THAT(Throttler.Acquires,
+testing::UnorderedElementsAreArray(Filenames));
+EXPECT_THAT(BuiltFilenames, testing::IsE

[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-05 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442320.
pscoro added a comment.

small revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11127,6 +11127,81 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction &MF = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+EVT MemVT =
+DAG.getTargetLoweringInfo().getPointerMemTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord = 0x; // XORing with 0b111...111 will never
+ // result in the original word
+
+// try getting canary word as global value if it exists
+/*GlobalValue *GV = (Subtarget.isAIXABI())
+  ? M->getGlobalVariable(AIXSSPCanaryWordName)
+  : M->getNamedValue("__stack_chk_guard");
+			  */
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead of having a
+   // canary word global value
+MachineSDNode *LSG = DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT,
+Op->getOperand(0));
+if (VT != MemVT) {
+  Load = DAG.getPtrExtOrTrunc(SDValue(LSG, 0), DL, MemVT);
+} else {
+ 

[PATCH] D112579: Allow non-variadic functions to be attributed with `__attribute__((format))`

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

In D112579#3625195 , @fcloutier wrote:

> Thanks, Aaron. I wasn't sure how to follow up given how long it had been 
> since the review started. I understand that we're all busy (which explains 
> the week delay on my part here as well).

No worries, pinging the review like you did is a good way to try to get it more 
attention, though it sometimes takes a few tries depending on the review.

> I've addressed all of your comments except the one on this bit 
> :
>
>   if (const FunctionType *FnTy = D->getFunctionType())
> IsVariadic = cast(FnTy)->isVariadic();
>
> The proposed change isn't identical because `D->getFunctionType()` can return 
> nullptr (for instance, if `D` is a `BlockDecl`). However, in the case `FnTy` 
> isn't nullptr, then it is guaranteed to be a `FunctionProtoType` as the 
> attribute is rejected on functions without a prototype.

The suggestion I had was slightly different:

  if (const auto *FnTy = D->getType()->getAs())
IsVariadic = FnTy->isVariadic();

It's getting as a prototyped function, and only if that succeeds do we check 
whether it's variadic. I think that is equivalent to what you have now, but is 
more clearly expressed. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112579

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-07-05 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 442321.
abidmalikwaterloo marked 11 inline comments as done.
abidmalikwaterloo added a comment.
Herald added a subscriber: anlunx.

Updated DistributeOp::verify as per reviewer's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

Files:
  clang/lib/Testing/CMakeLists.txt
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -121,6 +121,19 @@
   return
 }
 
+// CHECK-LABEL: omp_DistributeOp
+func.func @omp_DistributeOp(%lb : index, %ub : index, %step : index, %data_var : memref, %chunk_var : i32) -> () {
+  // CHECK: omp.distribute collapse(2)
+  // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
+  "omp.distribute" (%lb, %ub, %step) ({
+^bb0(%iv: index):
+ omp.yield 
+  }) {operand_segment_sizes = dense<[1,1,1,0,0,0]> : vector<6xi32>, collapse_val = 2} :
+(index, index, index) -> ()
+ 
+ return
+ }
+
 // CHECK-LABEL: omp_wsloop
 func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref, %linear_var : i32, %chunk_var : i32) -> () {
 
Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -207,6 +207,20 @@
   return success();
 }
 
+//===-===//
+// Verifier for Dristribute Op
+//===-===//
+
+LogicalResult DistributeOp::verify(){
+  if (this->lowerBound().empty()) 
+return emitOpError() << "empty lowerbound for distribute loop operation";
+  
+  if (this->upperBound().empty()) 
+return emitOpError() << "empty upperbound for distribute loop operation";
+  
+  return success();	
+}
+
 /// schedule ::= `schedule` `(` sched-list `)`
 /// sched-list ::= sched-val | sched-val sched-list |
 ///sched-val `,` sched-modifier
@@ -510,14 +524,14 @@
 }
 
 //===--===//
-// WsLoopOp
+// LoopControl
 //===--===//
 
 /// loop-control ::= `(` ssa-id-list `)` `:` type `=`  loop-bounds
 /// loop-bounds := `(` ssa-id-list `)` to `(` ssa-id-list `)` inclusive? steps
 /// steps := `step` `(`ssa-id-list`)`
 ParseResult
-parseWsLoopControl(OpAsmParser &parser, Region ®ion,
+parseLoopControl(OpAsmParser &parser, Region ®ion,
SmallVectorImpl &lowerBound,
SmallVectorImpl &upperBound,
SmallVectorImpl &steps,
@@ -560,7 +574,7 @@
   return success();
 }
 
-void printWsLoopControl(OpAsmPrinter &p, Operation *op, Region ®ion,
+void printLoopControl(OpAsmPrinter &p, Operation *op, Region ®ion,
 ValueRange lowerBound, ValueRange upperBound,
 ValueRange steps, TypeRange loopVarTypes,
 UnitAttr inclusive) {
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -394,7 +394,7 @@
   custom(
 $reduction_vars, type($reduction_vars), $reductions
   ) `)`
-) `for` custom($region, $lowerBound, $upperBound, $step,
+) `for` custom($region, $lowerBound, $upperBound, $step,
   type($step), $inclusive) attr-dict
   }];
   let hasVerifier = 1;
@@ -446,7 +446,7 @@
 def YieldOp : OpenMP_Op<"yield",
 [NoSideEffect, ReturnLike, Terminator,
  ParentOneOf<["WsLoopOp", "ReductionDeclareOp", 
- "AtomicUpdateOp", "SimdLoopOp"]>]> {
+ "AtomicUpdateOp", "SimdLoopOp","DistributeOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
 "omp.yield" yields SSA values from the OpenMP dialect op region and
@@ -463,6 +463,68 @@
   let assemblyFormat = [{ ( `(` $results^ `:` type($results) `)` )? attr-dict}];
 }
 
+//===--===//
+// 2.9.4.1 distribute Construct
+//===--===//
+
+def DistributeOp : OpenMP_Op<"distribute", [AttrSizedOperandSegments,
+AllTypesMatch<["lowerBound", "upperBound", "step"]>]> {
+  let summary = "distribute loop construct";
+  let description = [{ 
+The distribute construct specifies that the iterations of one or more loop
+will be executed by

[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-07-05 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo marked an inline comment as done.
abidmalikwaterloo added a comment.

update the changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

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

Precommit CI failures currently look to be unrelated. I think the only thing 
remaining is this bit:

> I think we should also update DiagnosticParseKinds.td at the same time...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-07-05 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: clang/lib/Testing/CMakeLists.txt:30
+  clangBasic
+  clangFrontend
   )

You still have these changes that are unrelated. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment.

Yes I am looking into the DiagnosticParseKinds.td


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-05 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman added a comment.

Yes I am looking into the DiagnosticParseKinds.td. Kindly also look another 
error encountered in testing while updating the test. Although not having in my 
system but this  is giving .
Look here 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

___
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-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: tahonermann, clang-language-wg.
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:271
+- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
+  comments.
 

Should we mention `P2295R5` now that it's at least core approved? Something 
like:
%%%
...unit sequences in comments; in support of `P2295R5 
`_.
%%%


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] D129048: Rewording the "static_assert" to static assertion

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

In D129048#3630584 , @Codesbyusman 
wrote:

> Yes I am looking into the DiagnosticParseKinds.td

Excellent, thank you!

In D129048#3630589 , @Codesbyusman 
wrote:

> Yes I am looking into the DiagnosticParseKinds.td. Kindly also look another 
> error encountered in testing while updating the test. Although not having in 
> my system but this  is giving .
> Look here 
> 

I noticed that one earlier -- I think it's unrelated to your changes. (I've 
seen that test spuriously fail before and there's nothing in the test files 
that uses a static assertion, so it seems highly unlikely that changes to the 
diagnostic message caused that issue; I expect it will go away on its own when 
you push up another patch in the future.) I think it's safe for you to ignore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D127114: new clang-tidy checker for assignments within condition clause of if statement

2022-07-05 Thread dodohand via Phabricator via cfe-commits
dodohand added a comment.

Hi @alexfh , @aaron.ballman, Could one of you have a look at this? I'd like to 
get it moving toward resolution and don't know who else ought to do a review...


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

https://reviews.llvm.org/D127114

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


[PATCH] D127114: new clang-tidy checker for assignments within condition clause of if statement

2022-07-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

LGTM with a few minor edits.

Do you have commit access?




Comment at: 
clang-tools-extra/clang-tidy/bugprone/AssignmentInIfConditionCheck.cpp:19-21
+void AssignmentInIfConditionCheck::registerMatchers(MatchFinder *Finder) {
+  // Scott Added this one
+  Finder->addMatcher(ifStmt(hasCondition(forEachDescendant(





Comment at: 
clang-tools-extra/clang-tidy/bugprone/AssignmentInIfConditionCheck.cpp:32-34
+const MatchFinder::MatchResult &Result) {
+  // Add callback implementation.
+  const auto *MatchedDecl =

No need to repeat the code in comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-assignment-in-if-condition.cpp:1-4
+// RUN: %check_clang_tidy %s bugprone-assignment-in-if-condition %t
+
+// Add something that triggers the check here.
+void f(int arg) {




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

https://reviews.llvm.org/D127114

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


[clang] b8dbc6f - [HLSL] Add ExternalSemaSource & vector alias

2022-07-05 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-07-05T11:30:29-05:00
New Revision: b8dbc6ffea93976dc0d8569c9d23e9c21e33e317

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

LOG: [HLSL] Add ExternalSemaSource & vector alias

HLSL vector types are ext_vector types, but they are also exposed via a
template syntax `vector`. This is morally equavalent to the code:

```c++
template 
using vector = T __attribute__((ext_vector_type(Size)))
```

The problem is that templates aren't supported before HLSL 2021, and
type aliases still aren't supported in HLSL.

To resolve this (and other issues where HLSL can't represent its own
types), we rely on an external AST & Sema source being registered for
HLSL code.

This patch adds the HLSLExternalSemaSource and registers the vector
type alias.

Depends on D127802

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

Added: 
clang/include/clang/Sema/HLSLExternalSemaSource.h
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/test/AST/HLSL/vector-alias.hlsl

Modified: 
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Headers/hlsl/hlsl_basic_types.h
clang/lib/Sema/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Sema/HLSLExternalSemaSource.h 
b/clang/include/clang/Sema/HLSLExternalSemaSource.h
new file mode 100644
index 0..92154427a3e72
--- /dev/null
+++ b/clang/include/clang/Sema/HLSLExternalSemaSource.h
@@ -0,0 +1,43 @@
+//===--- HLSLExternalSemaSource.h - HLSL Sema Source *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the HLSLExternalSemaSource interface.
+//
+//===--===//
+#ifndef CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H
+#define CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H
+
+#include "clang/Sema/ExternalSemaSource.h"
+
+namespace clang {
+class NamespaceDecl;
+class Sema;
+
+class HLSLExternalSemaSource : public ExternalSemaSource {
+  static char ID;
+
+  Sema *SemaPtr = nullptr;
+  NamespaceDecl *HLSLNamespace;
+
+  void defineHLSLVectorAlias();
+
+public:
+  ~HLSLExternalSemaSource() override;
+
+  /// Initialize the semantic source with the Sema instance
+  /// being used to perform semantic analysis on the abstract syntax
+  /// tree.
+  void InitializeSema(Sema &S) override;
+
+  /// Inform the semantic consumer that Sema is no longer available.
+  void ForgetSema() override { SemaPtr = nullptr; }
+};
+
+} // namespace clang
+
+#endif // CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 65160dd7e0b18..81915e6330b03 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -24,6 +24,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Parse/ParseAST.h"
+#include "clang/Sema/HLSLExternalSemaSource.h"
 #include "clang/Serialization/ASTDeserializationListener.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
@@ -1014,6 +1015,13 @@ bool FrontendAction::BeginSourceFile(CompilerInstance 
&CI,
 CI.getASTContext().setExternalSource(Override);
   }
 
+  // Setup HLSL External Sema Source
+  if (CI.getLangOpts().HLSL && CI.hasASTContext()) {
+IntrusiveRefCntPtr HLSLSema(
+new HLSLExternalSemaSource());
+CI.getASTContext().setExternalSource(HLSLSema);
+  }
+
   FailureCleanup.release();
   return true;
 }

diff  --git a/clang/lib/Headers/hlsl/hlsl_basic_types.h 
b/clang/lib/Headers/hlsl/hlsl_basic_types.h
index 2069990f5c06c..e68715f1a6a45 100644
--- a/clang/lib/Headers/hlsl/hlsl_basic_types.h
+++ b/clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -27,38 +27,38 @@ typedef long int64_t;
 // built-in vector data types:
 
 #ifdef __HLSL_ENABLE_16_BIT
-typedef int16_t int16_t2 __attribute__((ext_vector_type(2)));
-typedef int16_t int16_t3 __attribute__((ext_vector_type(3)));
-typedef int16_t int16_t4 __attribute__((ext_vector_type(4)));
-typedef uint16_t uint16_t2 __attribute__((ext_vector_type(2)));
-typedef uint16_t uint16_t3 __attribute__((ext_vector_type(3)));
-typedef uint16_t uint16_t4 __attribute__((ext_vector_type(4)));
+typedef vector int16_t2;
+typedef vector int16_t3;
+typedef vector int16_t4;
+typedef vector uint16_t2;
+typedef vector uint16_t3;
+typedef vector uint16_t4;
 #endif
 
-typedef int int2 __attribute__((ext_vector_type(2)));
-typedef int int3 __attribute__((ext_vector_type(3)));
-typedef int int4 __attribute__((ex

  1   2   >