[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/Expr.cpp:1387
+
+  auto CreateDependentType = [&Ctx]() {
+ASTContext::GetBuiltinTypeError Error;

hokein wrote:
> this can be removed, dependent type is a builtin type, so you could just use 
> `Ctx.DependentTy`.
useful, I did not observe that



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:630
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}

hokein wrote:
> CalleeType is not a specific term in `getCallReturnType`, just `CalleeType is 
> overload and dependent`, I think we can also verify this in the 
> Visitor.OnCall callback. 
> 
> IIUC, the patch fixes three different crashes
> - calling getCallReturntype on the `f(t)` expr 
> - calling getCallReturntype on the `f_overload()` expr 
> - calling getCallReturntype on the `a.f_overload(p);` expr
> 
> I think it would be much clear to express them in the `OnCall` callback 
> (rather than calling `getCallReturnType` on every Expr). One option is to use 
> the annotation, and identify the expression by location like below. An other 
> benefit is that we can unify the test code (instead of duplicating them) 
> without hurting the code readability.
> 
> ```
> template
> void templ(const T& t, F f) {
>   $crash1[[f]](t);
>   // CalleeType in getCallReturntype is Overload and dependent
> }
> 
> struct A {
>   void f_overload(int);
>   void f_overload(double);
> };
> 
> void f() {
>   int i = 0;
>   templ(i, [](const auto &p) {
> $crash2[[f_overload]](p); // UnresolvedLookupExpr
> // CalleeType in getCallReturntype is Overload and not dependent
>   });
> 
>   templ(i, [](const auto &p) {
> A a;
> a.$crash3[[f_overload]](p); // UnresolvedMemberExpr
> // CalleeType in getCallReturntype is BoundMember and has overloads
>   });
>   
> }
> ```
>  
The current test finds every `CallExpr` and calls the `getCallReturnType` on 
it. The test should verify that this function works, so at least calling it is 
needed. An additional check could be to verify that the "Callee" is really of 
the specific kind (`UnresolvedLookupExpr` and the others), this can be added. I 
do not get it how the annotations can be used here, it is possible only to get 
the position of the code in the string but how to use this value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D97358: [X86] Support amx-bf16 intrinsic.

2021-03-16 Thread Bing Yu via Phabricator via cfe-commits
yubing added inline comments.



Comment at: clang/lib/Headers/amxintrin.h:326
+__DEFAULT_FN_ATTRS_BF16
+static void __tile_tdpbf16ps(__tile1024i *dst, __tile1024i src1,
+ __tile1024i src2) {

Should we align this with "tile_dpbssd" by renaming it wth "tile_dpbf16ps"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97358

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


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added reviewers: NoQ, ASDenysPetrov.
balazske added a comment.
Herald added a subscriber: Charusso.

This patch makes one TODO less and it is possible to debug cases like in the 
next (in stack) change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

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


[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added reviewers: MyDeveloperDay, HazardyKnusperkeks.
HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added inline comments.
This revision now requires changes to proceed.



Comment at: clang/docs/ReleaseNotes.rst:168
 
+- Option ``SpaceBeforeForLoopSemiColon`` has been added to control whether
+  spaces will be added before the semi-colons in for loops.

No need for change, but in the future I would prefer to add changes to the end 
of the list. :)



Comment at: clang/include/clang/Format/Format.h:2841
+  ///true:  false:
+  ///for (i = 0 ; i < 1 ; ++i) {}   vs. for (i = 0; i < 1; ++i) {}
+  /// \endcode

Please also show the range based for here. Otherwise it may be surprising, it 
would be for me.



Comment at: clang/unittests/Format/FormatTest.cpp:12712
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+  verifyFormat("for (int i = 0 ; auto a : b) {\n}", Space);
+}

Okay that was unexpected for me, I thought the space would only apply to the 
old `for`s.

In that case please add `while` and maybe `if` with initializer. What should be 
discussed is if `for` and the other control statements with initializer should 
behave differently with regard to their initializer semicolon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98429

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


[PATCH] D98504: [clang][Checkers] Fix PthreadLockChecker state cleanup at dead symbol.

2021-03-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Exactly the case is (I think) that the mutex goes out of scope and we have not 
checked if it was really destroyed. Still the program can check later if it was 
destroyed (like the `if` in the test case). A resource leak may be the problem 
(if destroy failed) so a warning like "possible resource leak if destroy call 
fails" can be added to the `pthread_mutex_destroy` call.




Comment at: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp:290-304
   // Existence in DestroyRetVal ensures existence in LockMap.
   // Existence in Destroyed also ensures that the lock state for lockR is 
either
   // UntouchedAndPossiblyDestroyed or UnlockedAndPossiblyDestroyed.
   assert(lstate->isUntouchedAndPossiblyDestroyed() ||
  lstate->isUnlockedAndPossiblyDestroyed());
 
   ConstraintManager &CMgr = state->getConstraintManager();

NoQ wrote:
> ASDenysPetrov wrote:
> > I'm just wondering, did you think about such way of fixing?
> This involves keeping dead regions in the program state. I'd be pretty 
> worried about it.
This was my first idea but did not like it because state is not cleaned up 
correctly. (And `LockMap` contains data about unaccessible mutex.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98504

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


[PATCH] D98685: [X86][AMX] Rename amx-bf16 intrinsic according to correct naming convention __tile_tdpbf16ps should be renamed with __tile_dpbf16ps

2021-03-16 Thread Bing Yu via Phabricator via cfe-commits
yubing created this revision.
Herald added a subscriber: pengfei.
yubing requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98685

Files:
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c


Index: clang/test/CodeGen/X86/amx_api.c
===
--- clang/test/CodeGen/X86/amx_api.c
+++ clang/test/CodeGen/X86/amx_api.c
@@ -81,9 +81,9 @@
   __tile_zero(&c);
 }
 
-void test_tile_tdpbf16ps(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_tdpbf16ps
+void test_tile_dpbf16ps(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbf16ps
   //CHECK: call x86_amx @llvm.x86.tdpbf16ps.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_tdpbf16ps(&a, b, c);
+  __tile_dpbf16ps(&a, b, c);
 }
Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -267,8 +267,8 @@
 }
 
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_BF16
-_tile_tdpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k,
- _tile1024i dst, _tile1024i src1, _tile1024i src2) {
+_tile_dpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k,
+_tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbf16ps_internal(m, n, k, dst, src1, src2);
 }
 
@@ -323,10 +323,10 @@
 }
 
 __DEFAULT_FN_ATTRS_BF16
-static void __tile_tdpbf16ps(__tile1024i *dst, __tile1024i src1,
- __tile1024i src2) {
-  dst->tile = _tile_tdpbf16ps_internal(src1.row, src2.col, src1.col, dst->tile,
-   src1.tile, src2.tile);
+static void __tile_dpbf16ps(__tile1024i *dst, __tile1024i src1,
+__tile1024i src2) {
+  dst->tile = _tile_dpbf16ps_internal(src1.row, src2.col, src1.col, dst->tile,
+  src1.tile, src2.tile);
 }
 
 #undef __DEFAULT_FN_ATTRS_TILE


Index: clang/test/CodeGen/X86/amx_api.c
===
--- clang/test/CodeGen/X86/amx_api.c
+++ clang/test/CodeGen/X86/amx_api.c
@@ -81,9 +81,9 @@
   __tile_zero(&c);
 }
 
-void test_tile_tdpbf16ps(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_tdpbf16ps
+void test_tile_dpbf16ps(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbf16ps
   //CHECK: call x86_amx @llvm.x86.tdpbf16ps.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_tdpbf16ps(&a, b, c);
+  __tile_dpbf16ps(&a, b, c);
 }
Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -267,8 +267,8 @@
 }
 
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_BF16
-_tile_tdpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k,
- _tile1024i dst, _tile1024i src1, _tile1024i src2) {
+_tile_dpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k,
+_tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbf16ps_internal(m, n, k, dst, src1, src2);
 }
 
@@ -323,10 +323,10 @@
 }
 
 __DEFAULT_FN_ATTRS_BF16
-static void __tile_tdpbf16ps(__tile1024i *dst, __tile1024i src1,
- __tile1024i src2) {
-  dst->tile = _tile_tdpbf16ps_internal(src1.row, src2.col, src1.col, dst->tile,
-   src1.tile, src2.tile);
+static void __tile_dpbf16ps(__tile1024i *dst, __tile1024i src1,
+__tile1024i src2) {
+  dst->tile = _tile_dpbf16ps_internal(src1.row, src2.col, src1.col, dst->tile,
+  src1.tile, src2.tile);
 }
 
 #undef __DEFAULT_FN_ATTRS_TILE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96110: [X86] Pass to transform tdpbf16ps intrinsics to scalar operation.

2021-03-16 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 330898.
yubing added a comment.

just do a rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96110

Files:
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll

Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -97,8 +97,8 @@
   ret void
 }
 
-define dso_local void @test_amx_dp(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
-; CHECK-LABEL: @test_amx_dp(
+define dso_local void @test_amx_dpbssd(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbssd(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
 ; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
@@ -172,6 +172,84 @@
   ret void
 }
 
+define dso_local void @test_amx_dpbf16ps(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbf16ps(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
+; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
+; CHECK-NEXT:[[C_AMX:%.*]] = bitcast <256 x i32> [[C:%.*]] to x86_amx
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i16 [[K:%.*]], 2
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.rows.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TDPBF16PS_SCALARIZE_ROWS_STEP:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_ROW:%.*]] = phi <256 x i32> [ [[C]], [[ENTRY]] ], [ [[TMP21:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP23:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.rows.body:
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.cols.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TDPBF16PS_SCALARIZE_COLS_STEP:%.*]], [[TDPBF16PS_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_ROW]], [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TMP21]], [[TDPBF16PS_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_ROW]], [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TMP23]], [[TDPBF16PS_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:[[TMP2:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP3:%.*]] = add i16 [[TMP2]], [[TDPBF16PS_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_COLS_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.cols.body:
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_INNER_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.inner.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_INNER_IV:%.*]] = phi i16 [ 0, [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TDPBF16PS_SCALARIZE_INNER_STEP:%.*]], [[TDPBF16PS_SCALARIZE_INNER_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_COL]], [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TMP21]], [[TDPBF16PS_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_INNER_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.inner.body:
+; CHECK-NEXT:[[TMP4:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP5:%.*]] = add i16 [[TMP4]], [[TDPBF16PS_SCALARIZE_INNER_IV]]
+; CHECK-NEXT:[[TMP6:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_INNER_IV]], 16
+; CHECK-NEXT:[[TMP7:%.*]] = add i16 [[TMP6]], [[TDPBF16PS_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP8:%.*]] = extractelement <256 x i32> [[VEC_C_INNER_PHI]], i16 [[TMP3]]
+; CHECK-NEXT:[[TMP9:%.*]] = bitcast i32 [[TMP8]] to float
+; CHECK-NEXT:[[TMP10:%.*]] = extractelement <256 x i32> [[A]], i16 [[TMP5]]
+; CHECK-NEXT:[[TMP11:%.*]] = bitcast i32 [[TMP10]] to <2 x i16>
+; CHECK-NEXT:[[TMP12:%.*]] = extractelement <256 x i32> [[B]], i16 [[TMP7]]
+; CHECK-NEXT:[[TMP13:%.*]] = bitcast i32 [[TMP12]] to <2 x i16>
+; CHECK-NEXT:[[TMP14:%.*]] = shufflevector <2 x i16> [[TMP11]], <2 x i16> zeroinitializer, <4 x i32> 
+; CHECK-NEXT:[[TMP15:%.*]] = bitcast <4 x i16> [[TMP14]] to <2 x float>
+; CHECK-NEXT:[[TMP16:%.*]] = shufflevector <2 x i16> [[TMP13]], <2 x i16> zeroinitializer, <4 x i3

[PATCH] D98685: [X86][AMX] Rename amx-bf16 intrinsic according to correct naming convention

2021-03-16 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei 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/D98685/new/

https://reviews.llvm.org/D98685

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


[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-16 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 330901.
curdeius marked 4 inline comments as done.
curdeius added a comment.

- Add test.
- Remove unnecessary PrototypeScope.exit().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
+auto XL3 = []( constexpr mutable constexpr {}; // expected-error{{invalid storage class specifier}} \
+   // expected-error{{function parameter cannot be constexpr}} \
+   // expected-error{{C++ requires}} \
+   // expected-error{{expected ')'}} \
+   // expected-note{{to match this '('}} \
+   // expected-error{{expected body}} \
+   // expected-warning{{duplicate 'constexpr'}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -688,9 +688,9 @@
 /// ParseLambdaExpression - Parse a C++11 lambda expression.
 ///
 ///   lambda-expression:
-/// lambda-introducer lambda-declarator[opt] compound-statement
+/// lambda-introducer lambda-declarator compound-statement
 /// lambda-introducer '<' template-parameter-list '>'
-/// lambda-declarator[opt] compound-statement
+/// lambda-declarator compound-statement
 ///
 ///   lambda-introducer:
 /// '[' lambda-capture[opt] ']'
@@ -722,9 +722,13 @@
 /// '&' identifier initializer
 ///
 ///   lambda-declarator:
-/// '(' parameter-declaration-clause ')' attribute-specifier[opt]
-///   'mutable'[opt] exception-specification[opt]
-///   trailing-return-type[opt]
+/// lambda-specifiers [C++2b]
+/// '(' parameter-declaration-clause ')' lambda-specifiers
+/// requires-clause[opt]
+///
+///   lambda-specifiers:
+/// decl-specifier-seq[opt] noexcept-specifier[opt]
+/// attribute-specifier-seq[opt] trailing-return-type[opt]
 ///
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
@@ -1315,11 +1319,92 @@
 
   TypeResult TrailingReturnType;
   SourceLocation TrailingReturnTypeLoc;
+
+  auto ParseLambdaSpecifiers =
+  [&](SourceLocation LParenLoc, SourceLocation RParenLoc,
+  MutableArrayRef ParamInfo,
+  SourceLocation EllipsisLoc) {
+SourceLocation DeclEndLoc = RParenLoc;
+
+// GNU-style attributes must be parsed before the mutable specifier to
+// be compatible with GCC. MSVC-style attributes must be parsed before
+// the mutable specifier to be compatible with MSVC.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attr);
+
+// Parse mutable-opt and/or constexpr-opt or consteval-opt, and update
+// the DeclEndLoc.
+SourceLocation MutableLoc;
+SourceLocation ConstexprLoc;
+SourceLocation ConstevalLoc;
+tryConsumeLambdaSpecifierToken(*this, MutableLoc, ConstexprLoc,
+   ConstevalLoc, DeclEndLoc);
+
+addConstexprToLambdaDeclSpecifier(*this, ConstexprLoc, DS);
+addConstevalToLambdaDeclSpecifier(*this, ConstevalLoc, DS);
+

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-16 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Thank you for the review Aaron. I hope having addressed your comments so far.
I'm not sure for the prototype scope though.




Comment at: clang/lib/Parse/ParseExprCXX.cpp:1440
+  } else if (getLangOpts().CPlusPlus2b) {
+ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope |
+Scope::FunctionDeclarationScope |

aaron.ballman wrote:
> I don't know the answer to this, but... do we need a prototype scope at all 
> when there's no parameter list? The old code was doing this, so I don't think 
> this is an issue with your patch per se, more just curiosity whether this is 
> necessary in this case.
I'm not really familiar with clang (I usually work with other parts of LLVM), 
but at least in the current implementation (before this patch) the prototype 
scope englobes the parsing of lambda-specifiers, so I found it logical to keep 
it the same way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-16 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/include/llvm/Target/TargetSelectionDAG.td:158
 ]>;
+def SDTFPRoundEvenOp  : SDTypeProfile<1, 1, [   // froundeven
+  SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>, 
SDTCisSameNumEltsAs<0, 1>

bsmith wrote:
> dmgreen wrote:
> > Is this used? The one above should maybe say `// fpround`?
> No it's not, I added it for consistency, but perhaps I shouldn't? I think 
> fround is correct for the one above, or at least is consistent with the 
> others in this file, for example fextend below.
It's used below in `def fpround: SDNode<"ISD::FP_ROUND"   , 
SDTFPRoundOp>;`, so it looks like its used with the fptrunc instruction, not 
the fround intrinsic.

I see your point about fextend... I would say they should both be changed to 
fpextend/fpround, for consistency with the nodes they act upon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D98688: [-Wcalled-once-parameter] Harden analysis in terms of block use

2021-03-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added a subscriber: Charusso.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch introduces a very simple inter-procedural analysis
between blocks and enclosing functions.

We always analyze blocks first (analysis is done as part of semantic
analysis that goes side-by-side with the parsing process), and at the
moment of reporting we don't know how that block will be actually
used.

This patch introduces new logic delaying reports of the "never called"
warnings on blocks.  If we are not sure that the block will be called
exactly once, we shouldn't warn our users about that.  Double calls,
however, don't require such delays.  While analyzing the enclosing
function, we can actually decide what we should do with those
warnings.

Additionally, as a side effect, we can be more confident about blocks
in such context and can treat them not as escapes, but as direct
calls.

rdar://74090107


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98688

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -31,6 +31,16 @@
 @class NSString, Protocol;
 extern void NSLog(NSString *format, ...);
 
+typedef int group_t;
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef void (^dispatch_block_t)(void);
+extern dispatch_queue_t queue;
+
+void dispatch_group_async(dispatch_queue_t queue,
+  group_t group,
+  dispatch_block_t block);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+
 void escape(void (^callback)(void));
 void escape_void(void *);
 void indirect_call(void (^callback)(void) CALLED_ONCE);
@@ -225,11 +235,11 @@
 }
 
 void block_call_1(void (^callback)(void) CALLED_ONCE) {
-  indirect_call(^{
-callback();
-  });
-  callback();
-  // no-warning
+  indirect_call( // expected-note{{previous call is here}}
+  ^{
+callback();
+  });
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
 }
 
 void block_call_2(void (^callback)(void) CALLED_ONCE) {
@@ -255,7 +265,7 @@
   // expected-warning@-1{{'callback' parameter marked 'called_once' is never used when taking false branch}}
   escape(callback);
 }
-  }();
+  }(); // no-warning
 }
 
 void block_call_5(void (^outer)(void) CALLED_ONCE) {
@@ -273,6 +283,32 @@
   outer(); // expected-warning{{'outer' parameter marked 'called_once' is called twice}}
 }
 
+void block_dispatch_call(int cond, void (^callback)(void) CALLED_ONCE) {
+  dispatch_async(queue, ^{
+if (cond) // expected-warning{{'callback' parameter marked 'called_once' is never called when taking false branch}}
+  callback();
+  });
+}
+
+void block_escape_call_1(int cond, void (^callback)(void) CALLED_ONCE) {
+  escape_void((__bridge void *)^{
+if (cond) {
+  // no-warning
+  callback();
+}
+  });
+}
+
+void block_escape_call_2(int cond, void (^callback)(void) CALLED_ONCE) {
+  escape_void((__bridge void *)^{
+if (cond) {
+  callback(); // expected-note{{previous call is here}}
+}
+// Double call can still be reported.
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  });
+}
+
 void never_called_one_exit(int cond, void (^callback)(void) CALLED_ONCE) {
   if (!cond) // expected-warning{{'callback' parameter marked 'called_once' is never called when taking true branch}}
 return;
@@ -822,11 +858,10 @@
 
 - (void)block_call_1:(void (^)(void))CALLED_ONCE callback {
   // We consider captures by blocks as escapes
-  [self indirect_call:(^{
+  [self indirect_call:(^{ // expected-note{{previous call is here}}
   callback();
 })];
-  callback();
-  // no-warning
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
 }
 
 - (void)block_call_2:(int)cond callback:(void (^)(void))CALLED_ONCE callback {
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1506,6 +1506,25 @@
   }
 }
 
+namespace clang {
+namespace {
+typedef SmallVector OptionalNotes;
+typedef std::pair DelayedDiag;
+typedef std::list DiagList;
+
+struct SortDiagBySourceLocation {
+  SourceManager &SM;
+  SortDiagBySourceLocation(SourceManager &SM) : SM(SM) {}
+
+  bool operator()(const DelayedDiag &left, const DelayedDiag &right) {
+// Although this call will 

[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

Thanks for working on this. A couple of post-commit comments to look at, 
otherwise looks good. Thanks for figuring out how to do this in a portable 
manner!




Comment at: llvm/cmake/modules/GetErrcMessages.cmake:1
+
+# This function returns the messages of various POSIX error codes as they are 
returned by std::error_code.

Delete this blank line?



Comment at: llvm/cmake/modules/GetErrcMessages.cmake:3-6
+# The purpose of this function is to supply those error messages to llvm-lit 
using the errc_messages config
+# Currently supplied and needed error codes: ENOENT, EISDIR, EINVAL and EACCES
+# Messages are semi colon separated
+# Keep amount, order and tested error codes in sync with 
llvm/utils/lit/lit/llvm/config.py

Each of these lines look like they need a trailing full stop added.



Comment at: llvm/utils/lit/lit/llvm/config.py:14
 lit_path_displayed = False
+python_errc_displayed = False
 

Seems like this variable is unused and got leftover from an experiment at some 
point?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread Markus Böck via Phabricator via cfe-commits
zero9178 marked an inline comment as done.
zero9178 added inline comments.



Comment at: llvm/cmake/modules/GetErrcMessages.cmake:3-6
+# The purpose of this function is to supply those error messages to llvm-lit 
using the errc_messages config
+# Currently supplied and needed error codes: ENOENT, EISDIR, EINVAL and EACCES
+# Messages are semi colon separated
+# Keep amount, order and tested error codes in sync with 
llvm/utils/lit/lit/llvm/config.py

jhenderson wrote:
> Each of these lines look like they need a trailing full stop added.
Just to double check, that means adding a `.` at the end of the lines right?



Comment at: llvm/utils/lit/lit/llvm/config.py:14
 lit_path_displayed = False
+python_errc_displayed = False
 

jhenderson wrote:
> Seems like this variable is unused and got leftover from an experiment at 
> some point?
Correct, that was accidently left in. I immediately followed up with a commit 
removing it here: 
https://reviews.llvm.org/rG68e4084bf68ae7517491a6a0cbfd6d3b6f93cef7


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D96110: [X86] Pass to transform tdpbf16ps intrinsics to scalar operation.

2021-03-16 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:318-319
+// calculate idxa, idxb, idxc
+// %eltc = extractelement <256 x i32> %vec.c.inner.phi, i16 %idxc
+// %eltcf32 = bitcast i32 %eltc to float
+// %elta = extractelement <256 x i32> %veca, i16 %idxa

Can we create vecC with <256 x float>?



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:341
+Value *EltC = B.CreateExtractElement(VecCPhi, IdxC);
+Value *C_F32 = B.CreateBitCast(EltC, B.getFloatTy());
+Value *EltA = B.CreateExtractElement(VecA, IdxA);

better to use EltCF32 or CF32



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:348
+int ShuffleMask[4] = {2, 0, 3, 1};
+Value *A_V2F32 = B.CreateBitCast(
+B.CreateShuffleVector(SubVecA, ZeroV2I16, makeArrayRef(ShuffleMask)),

ditto



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:349
+Value *A_V2F32 = B.CreateBitCast(
+B.CreateShuffleVector(SubVecA, ZeroV2I16, makeArrayRef(ShuffleMask)),
+V2F32Ty);

Better to define a variable for it and reuse.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:390-394
+  template ::type>
+  bool lowerTileDP(Instruction *TileDP);

Is it concise to use below?
```
template 
typename std::enable_if_t<
IntrID == Intrinsic::x86_tdpbssd_internal ||
IntrID == Intrinsic::x86_tdpbf16ps_internal, bool>
lowerTileDP(Instruction *TileDP);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96110

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: llvm/cmake/modules/GetErrcMessages.cmake:3-6
+# The purpose of this function is to supply those error messages to llvm-lit 
using the errc_messages config
+# Currently supplied and needed error codes: ENOENT, EISDIR, EINVAL and EACCES
+# Messages are semi colon separated
+# Keep amount, order and tested error codes in sync with 
llvm/utils/lit/lit/llvm/config.py

zero9178 wrote:
> jhenderson wrote:
> > Each of these lines look like they need a trailing full stop added.
> Just to double check, that means adding a `.` at the end of the lines right?
Yes, that's right. Full stop (British English) == period (American English) == 
`.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread Markus Böck via Phabricator via cfe-commits
zero9178 marked 4 inline comments as done.
zero9178 added a comment.

I addressed your comments in 
https://reviews.llvm.org/rG4a17ac0387f078529da02e355a24df99f645d364. Hope it 
should be alright now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D98278#2628433 , @zero9178 wrote:

> I addressed your comments in 
> https://reviews.llvm.org/rG4a17ac0387f078529da02e355a24df99f645d364. Hope it 
> should be alright now

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-16 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

That looks really good. Please add tests as indicated in the inline comments 
and fix the formatting (see clang-format warnings).




Comment at: clang/include/clang/Format/Format.h:1912
+/// Keep existing empty lines after access modifiers.
+/// MaxEmptyLinesToKeep is applied instead.
+ELAAMS_Leave,

Shouldn't we put the same comment in `ELBAMS_Leave`?
That goes outside the scope of this patch if it ELBAMS doesn't behave this way.



Comment at: clang/include/clang/Format/Format.h:1957
+  /// Defines how many lines are put after access modifiers.
+  unsigned EmptyLinesAfterAccessModifier;
+

Max_S wrote:
> curdeius wrote:
> > This option seems to be very different from 
> > `EmptyLineBeforeAccessModifier`. I don't mean in what it does, because this 
> > is analogical, but in the possible options.
> > Wouldn't it be less surprising to have (at least some) similar options here 
> > and there?
> > Is there any value in having more than one line after access modifiers? 
> > Couldn't that be achieved with Leave option?
> > How do the two options work together?
> > 
> > Also, the difference in singular vs. plural form of "Line(s)" in these two 
> > options is disconcerting.
> > From the user perspective, it's error-prone to have two options that are at 
> > the same time so similar and so different.
> I agree with you and changed it accordingly. I left out the option 
> `LogicalBlock`.
> 
> The interaction between the two options is quite minimal. I can add extra 
> tests, that would demonstrate this but I do not think that this is necessary.
> 
> The leave option would now applies MaxEmptyLinesToKeep in a correct way. See 
> also my remarks in >>! In D98237#2616621.
I like the new version. Thank you for the update.
I'd still love to see the tests with both Before/After options (and we probably 
want `MaxEmptyLinesToKeep > 1` for these tests in order to check whether e.g. 
Always/Always keeps precisely one new line).

I mean something along these lines (amongst other tests):
```
  Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
  Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
  Style.MaxEmptyLinesToKeep = 3;
  EXPECT_EQ(R"(
struct S {
private:

public:
};
)",
format(R"(
struct S {
private:



public:
};
)", Style));
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:308
+  .count());
+// FIXME(kirillbobyrev): This is not really "freshness", this is just the
+// time since last index reload.

kbobyrev wrote:
> kadircet wrote:
> > what's the issue to be fixed here exactly? do we want to display the index 
> > build time instead of age? (if so what's the blocker)
> The point here is that is the index load freshness but it's not the index 
> load, not the index age itself. The index age is e.g. the time of the last 
> commit being indexed. Hence, we don't actually have this information _right 
> now_ - it should be provided separately (probably in a way of adjacent 
> `index.metadata` file or something similar). E.g. when we download from 
> GitHub release, we do know the time an index was uploaded, that's a better 
> estimate of the index "age" probably. But what the comment in Proto file says 
> is actually more like the commit time, e.g. when did the last change that 
> made it into the index happen.
ah i see, yes you are totally right.

maybe rephrase as `We are currently making use of the last modification time of 
the index artifact to deduce its age. This is wrong as it doesn't account for 
the indexing delay. Propagate some metadata with the index artifacts to 
indicate time of the commit we indexed.`



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:457
 
-  std::thread HotReloadThread([&Index, &Status, &FS]() {
+  Monitor Monitor(std::chrono::system_clock::now());
+

kbobyrev wrote:
> kadircet wrote:
> > unless we call updateIndex here too, monitoring service won't know about 
> > the one being served until the first reload right?
> > 
> > (another option would be to just not load the index at startup immediately, 
> > and handle the initial load in HotReloadThread, but that can be a separate 
> > change.)
> I think using `Status.getLastModificationTime()` should be correct, right? 
> This is the index we actually loaded (checked above).
right that would do, but now we are lying about the server's uptime :D

so we should explicitly call 
`Monitor.updateIndex(Status->getLastModificationTime());` and still initialize 
monitoring service with `system_clock::now`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

I'm seeing a problem with this. Compiling with gcc 9.3.0 the compilation of the 
test program works, but then when I run it I get

  
/repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188:
 /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by 
/repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188)

and this causes everything to fail with

  llvm-lit: 
/repo/uabelho/master-github/llvm/utils/lit/lit/TestingConfig.py:100: fatal: 
unable to parse config file 
'/repo/uabelho/master-github/llvm/build-all-bbigcc/tools/clang/test/lit.site.cfg.py',
 traceback: Traceback (most recent call last):
File 
"/repo/uabelho/master-github/llvm/build-all-bbigcc/bin/../../utils/lit/lit/TestingConfig.py",
 line 89, in load_from_path
  exec(compile(data, path, 'exec'), cfg_globals, None)
File 
"/repo/uabelho/master-github/llvm/build-all-bbigcc/tools/clang/test/lit.site.cfg.py",
 line 19
  config.errc_messages = 
"/repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188:
 /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by 
/repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188)

so perhaps there should be some additional error handling when running the 
compiled program doesn't work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D98278#2628477 , @uabelho wrote:

> Hi,
>
> I'm seeing a problem with this. Compiling with gcc 9.3.0 the compilation of 
> the test program works, but then when I run it I get
>
>   
> /repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188:
>  /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by 
> /repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188)
>
> and this causes everything to fail with
>
>   llvm-lit: 
> /repo/uabelho/master-github/llvm/utils/lit/lit/TestingConfig.py:100: fatal: 
> unable to parse config file 
> '/repo/uabelho/master-github/llvm/build-all-bbigcc/tools/clang/test/lit.site.cfg.py',
>  traceback: Traceback (most recent call last):
> File 
> "/repo/uabelho/master-github/llvm/build-all-bbigcc/bin/../../utils/lit/lit/TestingConfig.py",
>  line 89, in load_from_path
>   exec(compile(data, path, 'exec'), cfg_globals, None)
> File 
> "/repo/uabelho/master-github/llvm/build-all-bbigcc/tools/clang/test/lit.site.cfg.py",
>  line 19
>   config.errc_messages = 
> "/repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188:
>  /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by 
> /repo/uabelho/master-github/llvm/build-all-bbigcc/CMakeFiles/CMakeTmp/cmTC_00188)
>
> so perhaps there should be some additional error handling when running the 
> compiled program doesn't work?

Could you try changing line 32 of llvm/cmake/modules/GetErrcMessages.cmake from 
`if (errc_compiled)` to `if (errc_compiled AND "${errc_test_code}" STREQUAL 
"0")` and report back if it changes anything? I think that should fix your 
issue, although it'll fall back to using python's strerror messages. Indeed an 
oversight of mine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-16 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3683
+Style.BraceWrapping.AfterEnum;
+bool isLineTooBig = (strlen(Right.TokenText.data()) +
+ Right.OriginalColumn) > Style.ColumnLimit;

atirit wrote:
> curdeius wrote:
> > strlen? Please use `StringRef::size()`.
> For `FormatToken.TokenText`, `StringRef::size()` is set to the length of the 
> token, not of the stored text. Please see 
> `clang/lib/Format/FormatTokenLexer.cpp:1047`. Changing that line breaks 
> nearly every format test so I'm assuming that it is correct. A `strlen` or 
> equivalent is necessary here.
Then it should be something like the line's length, no? Using `strlen` will be 
very expensive on non-snippets, as it `strlen` will traverse the string until 
its end (so possibly until the end of file) for each invocation of 
`mustBreakBefore` (if it goes into this condition of course).

I only see one failing check in the test `FormatTest.FormatsTypedefEnum` when 
using `TokenText.size()`:
```
  verifyFormat("typedef enum\n"
   "{\n"
   "  ZERO = 0,\n"
   "  ONE = 1,\n"
   "  TWO = 2,\n"
   "  THREE = 3\n"
   "} LongEnum;",
   Style);
```

You might need to add more tests in `AfterEnum` to test the behaviour of this 
part if the line is just below/above the limit.

Also, that's just a hack, but I made all tests pass with:
```
assert(Line.Last);
assert(Line.Last->TokenText.data() >= Right.TokenText.data());
auto isAllowedByShortEnums = [&]() {
  if (!Style.AllowShortEnumsOnASingleLine ||
  (Line.Last->TokenText.data() - Right.TokenText.data() +
   Right.TokenText.size() + Right.OriginalColumn) >
  Style.ColumnLimit)
```
I haven't given it too much thought though and am unsure whether there are 
cases where the above assertions will fail.



Comment at: clang/unittests/Format/FormatTest.cpp:13426-13435
   verifyFormat("enum X\n"
"{\n"
"  Y = 0,\n"
"}\n",
AllmanBraceStyle);
   verifyFormat("enum X\n"
"{\n"

I would then put `AllmanBraceStyle.AllowShortEnumsOnASingleLine = ...;` just 
before these enum tests and put the old value back afterwards.
Also, as @HazardyKnusperkeks suggested test both false and true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-16 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

It looks like this has caused a compile-time regression at `O0`: 
https://llvm-compile-time-tracker.com/compare.php?from=9341bcbdc93a251b632ffaa51a84452a7a4a5e4e&to=4f198b0c27b04e830a3069aaf4b39cf203eaae4a&stat=instructions

The cause is probably the computation of DomTree and LoopInfo, even if no AMX 
intrinsics are present. I think you should be able to easily fix this by not 
fetching DT/LI from the pass manager, and computing them in the pass instead 
(only if intrinsics are present).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D98694: [-Wcalled-once-parameter] Fix false positives for cleanup attr

2021-03-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added a subscriber: Charusso.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Cleanup attribute allows users to attach a destructor-like functions
to variable declarations to be called whenever they leave the scope.
The logic of such functions is not supported by the Clang's CFG and
is too hard to be reasoned about.  In order to avoid false positives
in this situation, we assume that we didn't see ALL of the executtion
paths of the function and, thus, can warn only about multiple call
violation.

rdar://74441906


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98694

Files:
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/test/SemaObjC/warn-called-once.m


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1193,4 +1193,46 @@
   escape(handler);
 }
 
+// rdar://74441906
+typedef void (^DeferredBlock)(void);
+static inline void DefferedCallback(DeferredBlock *inBlock) { (*inBlock)(); }
+#define _DEFERCONCAT(a, b) a##b
+#define _DEFERNAME(a) _DEFERCONCAT(__DeferredVar_, a)
+#define DEFER __extension__ __attribute__((cleanup(DefferedCallback), unused)) 
\
+  DeferredBlock _DEFERNAME(__COUNTER__) = ^
+
+- (void)test_cleanup_1:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+// no-warning
+handler();
+  }
+}
+
+- (void)test_cleanup_2:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+handler(); // expected-note{{previous call is here}}
+  }
+
+  // We still can warn about double call even in this case.
+  handler(); // expected-warning{{completion handler is called twice}}
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -812,8 +812,12 @@
   }
 }
 
-// Early exit if we don't have parameters for extra analysis.
-if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none())
+// Early exit if we don't have parameters for extra analysis...
+if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none() &&
+// ... or if we've seen variables with cleanup functions.
+// We can't reason that we've seen every path in this case,
+// and thus abandon reporting any warnings that imply that.
+!FunctionHasCleanupVars)
   return;
 
 // We are looking for a pair of blocks A, B so that the following is true:
@@ -1601,6 +1605,10 @@
 if (Var->getInit()) {
   checkEscapee(Var->getInit());
 }
+
+if (Var->hasAttr()) {
+  FunctionHasCleanupVars = true;
+}
   }
 }
   }
@@ -1669,6 +1677,13 @@
   // around.
   bool SuppressOnConventionalErrorPaths = false;
 
+  // The user can annotate variable declarations with cleanup functions, which
+  // essentially imposes a custom destructor logic on that variable.
+  // It is possible to use it, however, to call tracked parameters on all exits
+  // from the function.  For this reason, we track the fact that the function
+  // actually has these.
+  bool FunctionHasCleanupVars = false;
+
   State CurrentState;
   ParamSizedVector TrackedParams;
   CFGSizedVector States;


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1193,4 +1193,46 @@
   escape(handler);
 }
 
+// rdar://74441906
+typedef void (^DeferredBlock)(void);
+static inline void DefferedCallback(DeferredBlock *inBlock) { (*inBlock)(); }
+#define _DEFERCONCAT(a, b) a##b
+#define _DEFERNAME(a) _DEFERCONCAT(__DeferredVar_, a)
+#define DEFER __extension__ __attribute__((cleanup(DefferedCallback), unused)) \
+  DeferredBlock _DEFERNAME(__COUNTER__) = ^
+
+- (void)test_cleanup_1:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+// no-warning
+handler();
+  }
+}
+
+- (void)test_cleanup_2:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+handler(); // expected-note{{previous call is here}}
+  }
+
+  // We still can warn about double call even in this case.
+  handler(); // expected-warning{{completion handler is called twice}}
+}
+
 @end
Index: clang/lib/Anal

[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D98278#2628482 , @zero9178 wrote:

> In D98278#2628477 , @uabelho wrote:
>
>> so perhaps there should be some additional error handling when running the 
>> compiled program doesn't work?
>
> Could you try changing line 32 of llvm/cmake/modules/GetErrcMessages.cmake 
> from `if (errc_compiled)` to `if (errc_compiled AND "${errc_exit_code}" 
> STREQUAL "0")` and report back if it changes anything? I think that should 
> fix your issue, although it'll fall back to using python's strerror messages. 
> Indeed an oversight of mine.

Yes that helps, please submit. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[clang] a92693d - [CodeCompletion] Don't track preferred types if code completion is disabled.

2021-03-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-16T12:16:10+01:00
New Revision: a92693dac4592e7bfbd9caf09939d46756de3821

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

LOG: [CodeCompletion] Don't track preferred types if code completion is 
disabled.

Some of this work isn't quite trivial.

(As requested in D96058)

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

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 09a0dd2cf233..e1bd3531be8e 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -941,8 +941,8 @@ class Parser : public CodeCompletionHandler {
 bool isActive;
 
   public:
-explicit TentativeParsingAction(Parser& p) : P(p) {
-  PrevPreferredType = P.PreferredType;
+explicit TentativeParsingAction(Parser &p)
+: P(p), PrevPreferredType(P.PreferredType) {
   PrevTok = P.Tok;
   PrevTentativelyDeclaredIdentifierCount =
   P.TentativelyDeclaredIdentifiers.size();

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a919740aa662..9e3eb4f07472 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -286,14 +286,13 @@ class FileNullabilityMap {
   }
 };
 
-/// Keeps track of expected type during expression parsing. The type is tied to
-/// a particular token, all functions that update or consume the type take a
-/// start location of the token they are looking at as a parameter. This allows
-/// to avoid updating the type on hot paths in the parser.
+/// Tracks expected type during expression parsing, for use in code completion.
+/// The type is tied to a particular token, all functions that update or 
consume
+/// the type take a start location of the token they are looking at as a
+/// parameter. This avoids updating the type on hot paths in the parser.
 class PreferredTypeBuilder {
 public:
-  PreferredTypeBuilder() = default;
-  explicit PreferredTypeBuilder(QualType Type) : Type(Type) {}
+  PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
 
   void enterCondition(Sema &S, SourceLocation Tok);
   void enterReturn(Sema &S, SourceLocation Tok);
@@ -320,7 +319,7 @@ class PreferredTypeBuilder {
   void enterTypeCast(SourceLocation Tok, QualType CastType);
 
   QualType get(SourceLocation Tok) const {
-if (Tok != ExpectedLoc)
+if (!Enabled || Tok != ExpectedLoc)
   return QualType();
 if (!Type.isNull())
   return Type;
@@ -330,6 +329,7 @@ class PreferredTypeBuilder {
   }
 
 private:
+  bool Enabled;
   /// Start position of a token for which we store expected type.
   SourceLocation ExpectedLoc;
   /// Expected type for a token starting at ExpectedLoc.

diff  --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 50e1f1eaba4d..97bd7d8fc51a 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -160,9 +160,6 @@ static void CheckArrayDesignatorSyntax(Parser &P, 
SourceLocation Loc,
 /// \p CodeCompleteCB is called with Designation parsed so far.
 ExprResult Parser::ParseInitializerWithPotentialDesignator(
 DesignatorCompletionInfo DesignatorCompletion) {
-  if (!getPreprocessor().isCodeCompletionEnabled())
-DesignatorCompletion.PreferredBaseType = QualType(); // skip field lookup
-
   // If this is the old-style GNU extension:
   //   designation ::= identifier ':'
   // Handle it as a field designator.  Otherwise, this must be the start of a

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 9b0f921b4269..fb182883b88a 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -49,10 +49,10 @@ IdentifierInfo *Parser::getSEHExceptKeyword() {
 }
 
 Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
-  : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
-GreaterThanIsOperator(true), ColonIsSacred(false),
-InMessageExpression(false), TemplateParameterDepth(0),
-ParsingInObjCContainer(false) {
+: PP(pp), PreferredType(pp.isCodeCompletionEnabled()), Actions(actions),
+  Diags(PP.getDiagnostics()), GreaterThanIsOperator(true),
+  ColonIsSacred(false), InMessageExpression(false),
+  TemplateParameterDepth(0), ParsingInObjCContainer(false) {
   SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
   Tok.startToken();
   Tok.setKind(tok::eof);

diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 2feb02bbe4ed..18605b321c70 100644
--- a/clang/lib/Sema/SemaCodeCompl

[PATCH] D98459: [CodeCompletion] Don't track preferred types if code completion is disabled.

2021-03-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa92693dac459: [CodeCompletion] Don't track preferred 
types if code completion is disabled. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98459

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp

Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -381,6 +381,8 @@
 } // namespace
 
 void PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) {
+  if (!Enabled)
+return;
   if (isa(S.CurContext)) {
 if (sema::BlockScopeInfo *BSI = S.getCurBlock()) {
   ComputeType = nullptr;
@@ -399,6 +401,8 @@
 }
 
 void PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) {
+  if (!Enabled)
+return;
   auto *VD = llvm::dyn_cast_or_null(D);
   ComputeType = nullptr;
   Type = VD ? VD->getType() : QualType();
@@ -410,6 +414,8 @@
 void PreferredTypeBuilder::enterDesignatedInitializer(SourceLocation Tok,
   QualType BaseType,
   const Designation &D) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getDesignatedType(BaseType, D);
   ExpectedLoc = Tok;
@@ -417,6 +423,8 @@
 
 void PreferredTypeBuilder::enterFunctionArgument(
 SourceLocation Tok, llvm::function_ref ComputeType) {
+  if (!Enabled)
+return;
   this->ComputeType = ComputeType;
   Type = QualType();
   ExpectedLoc = Tok;
@@ -424,6 +432,8 @@
 
 void PreferredTypeBuilder::enterParenExpr(SourceLocation Tok,
   SourceLocation LParLoc) {
+  if (!Enabled)
+return;
   // expected type for parenthesized expression does not change.
   if (ExpectedLoc == LParLoc)
 ExpectedLoc = Tok;
@@ -541,6 +551,8 @@
 
 void PreferredTypeBuilder::enterBinary(Sema &S, SourceLocation Tok, Expr *LHS,
tok::TokenKind Op) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getPreferredTypeOfBinaryRHS(S, LHS, Op);
   ExpectedLoc = Tok;
@@ -548,7 +560,7 @@
 
 void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok,
   Expr *Base) {
-  if (!Base)
+  if (!Enabled || !Base)
 return;
   // Do we have expected type for Base?
   if (ExpectedLoc != Base->getBeginLoc())
@@ -561,6 +573,8 @@
 void PreferredTypeBuilder::enterUnary(Sema &S, SourceLocation Tok,
   tok::TokenKind OpKind,
   SourceLocation OpLoc) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getPreferredTypeOfUnaryArg(S, this->get(OpLoc), OpKind);
   ExpectedLoc = Tok;
@@ -568,6 +582,8 @@
 
 void PreferredTypeBuilder::enterSubscript(Sema &S, SourceLocation Tok,
   Expr *LHS) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = S.getASTContext().IntTy;
   ExpectedLoc = Tok;
@@ -575,12 +591,16 @@
 
 void PreferredTypeBuilder::enterTypeCast(SourceLocation Tok,
  QualType CastType) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = !CastType.isNull() ? CastType.getCanonicalType() : QualType();
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterCondition(Sema &S, SourceLocation Tok) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = S.getASTContext().BoolTy;
   ExpectedLoc = Tok;
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -49,10 +49,10 @@
 }
 
 Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
-  : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
-GreaterThanIsOperator(true), ColonIsSacred(false),
-InMessageExpression(false), TemplateParameterDepth(0),
-ParsingInObjCContainer(false) {
+: PP(pp), PreferredType(pp.isCodeCompletionEnabled()), Actions(actions),
+  Diags(PP.getDiagnostics()), GreaterThanIsOperator(true),
+  ColonIsSacred(false), InMessageExpression(false),
+  TemplateParameterDepth(0), ParsingInObjCContainer(false) {
   SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
   Tok.startToken();
   Tok.setKind(tok::eof);
Index: clang/lib/Parse/ParseInit.cpp
===
--- clang/lib/Parse/ParseInit.cpp
+++ clang/lib/Parse/ParseInit.cpp
@@ -160,9 +160,6 @@
 /// \p CodeCompleteCB is called with Designation parsed so far.
 ExprResult Parser::ParseInitializerWithPotentialDesigna

[clang-tools-extra] 43d0b1c - [clangd] Reject renames to non-identifier characters

2021-03-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-16T12:18:29+01:00
New Revision: 43d0b1c9c16c7b435ae301d0a856fc48123e08c7

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

LOG: [clangd] Reject renames to non-identifier characters

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 853fc57bb906..5431046836ca 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -22,14 +22,17 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/Stmt.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace clang {
@@ -178,8 +181,7 @@ enum class ReasonToReject {
   UnsupportedSymbol,
   AmbiguousSymbol,
 
-  // name validation.
-  RenameToKeywords,
+  // name validation. FIXME: reconcile with InvalidName
   SameName,
 };
 
@@ -241,8 +243,6 @@ llvm::Error makeError(ReasonToReject Reason) {
   return "symbol is not a supported kind (e.g. namespace, macro)";
 case ReasonToReject::AmbiguousSymbol:
   return "there are multiple symbols at the given location";
-case ReasonToReject::RenameToKeywords:
-  return "the chosen name is a keyword";
 case ReasonToReject::SameName:
   return "new name is the same as the old name";
 }
@@ -437,6 +437,7 @@ struct InvalidName {
   enum Kind {
 Keywords,
 Conflict,
+BadIdentifier,
   };
   Kind K;
   std::string Details;
@@ -447,6 +448,8 @@ std::string toString(InvalidName::Kind K) {
 return "Keywords";
   case InvalidName::Conflict:
 return "Conflict";
+  case InvalidName::BadIdentifier:
+return "BadIdentifier";
   }
   llvm_unreachable("unhandled InvalidName kind");
 }
@@ -459,12 +462,31 @@ llvm::Error makeError(InvalidName Reason) {
Reason.Details);
 case InvalidName::Conflict:
   return llvm::formatv("conflict with the symbol in {0}", Reason.Details);
+case InvalidName::BadIdentifier:
+  return llvm::formatv("the chosen name \"{0}\" is not a valid identifier",
+   Reason.Details);
 }
 llvm_unreachable("unhandled InvalidName kind");
   };
   return error("invalid name: {0}", Message(Reason));
 }
 
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&
+  !isIdentifierHead(Ident.front(), AllowDollar))
+return false;
+  for (char C : Ident) {
+if (llvm::isASCII(C) && !isIdentifierBody(C, AllowDollar))
+  return false;
+  }
+  return true;
+}
+
 // Check if we can rename the given RenameDecl into NewName.
 // Return details if the rename would produce a conflict.
 llvm::Optional checkName(const NamedDecl &RenameDecl,
@@ -476,6 +498,8 @@ llvm::Optional checkName(const NamedDecl 
&RenameDecl,
   llvm::Optional Result;
   if (isKeyword(NewName, ASTCtx.getLangOpts()))
 Result = InvalidName{InvalidName::Keywords, NewName.str()};
+  else if (!mayBeValidIdentifier(NewName))
+Result = InvalidName{InvalidName::BadIdentifier, NewName.str()};
   else {
 // Name conflict detection.
 // Function conflicts are subtle (overloading), so ignore them.

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index ca0e7ff24306..5b35ac00d888 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1240,6 +1240,21 @@ TEST(RenameTest, PrepareRename) {
   testing::HasSubstr("keyword"));
   EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "Keywords"),
   ElementsAre(1));
+
+  for (std::string BadIdent : {"foo!bar", "123foo", "😀@"}) {
+Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
+   /*NewName=*/BadIdent, {});
+EXPECT_FALSE(Results);
+EXPECT_THAT(llvm::toString(Results.takeError()),
+testing::HasSubstr("identifier"));
+EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "BadI

[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-16 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 rG43d0b1c9c16c: [clangd] Reject renames to non-identifier 
characters (authored by sammccall).
Herald added a project: clang-tools-extra.

Changed prior to commit:
  https://reviews.llvm.org/D98424?vs=329955&id=330933#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1240,6 +1240,21 @@
   testing::HasSubstr("keyword"));
   EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "Keywords"),
   ElementsAre(1));
+
+  for (std::string BadIdent : {"foo!bar", "123foo", "😀@"}) {
+Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
+   /*NewName=*/BadIdent, {});
+EXPECT_FALSE(Results);
+EXPECT_THAT(llvm::toString(Results.takeError()),
+testing::HasSubstr("identifier"));
+EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "BadIdentifier"),
+ElementsAre(1));
+  }
+  for (std::string GoodIdent : {"fooBar", "__foo$", "😀"}) {
+Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
+   /*NewName=*/GoodIdent, {});
+EXPECT_TRUE(bool(Results));
+  }
 }
 
 TEST(CrossFileRenameTests, DirtyBuffer) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -22,14 +22,17 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/Stmt.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace clang {
@@ -178,8 +181,7 @@
   UnsupportedSymbol,
   AmbiguousSymbol,
 
-  // name validation.
-  RenameToKeywords,
+  // name validation. FIXME: reconcile with InvalidName
   SameName,
 };
 
@@ -241,8 +243,6 @@
   return "symbol is not a supported kind (e.g. namespace, macro)";
 case ReasonToReject::AmbiguousSymbol:
   return "there are multiple symbols at the given location";
-case ReasonToReject::RenameToKeywords:
-  return "the chosen name is a keyword";
 case ReasonToReject::SameName:
   return "new name is the same as the old name";
 }
@@ -437,6 +437,7 @@
   enum Kind {
 Keywords,
 Conflict,
+BadIdentifier,
   };
   Kind K;
   std::string Details;
@@ -447,6 +448,8 @@
 return "Keywords";
   case InvalidName::Conflict:
 return "Conflict";
+  case InvalidName::BadIdentifier:
+return "BadIdentifier";
   }
   llvm_unreachable("unhandled InvalidName kind");
 }
@@ -459,12 +462,31 @@
Reason.Details);
 case InvalidName::Conflict:
   return llvm::formatv("conflict with the symbol in {0}", Reason.Details);
+case InvalidName::BadIdentifier:
+  return llvm::formatv("the chosen name \"{0}\" is not a valid identifier",
+   Reason.Details);
 }
 llvm_unreachable("unhandled InvalidName kind");
   };
   return error("invalid name: {0}", Message(Reason));
 }
 
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&
+  !isIdentifierHead(Ident.front(), AllowDollar))
+return false;
+  for (char C : Ident) {
+if (llvm::isASCII(C) && !isIdentifierBody(C, AllowDollar))
+  return false;
+  }
+  return true;
+}
+
 // Check if we can rename the given RenameDecl into NewName.
 // Return details if the rename would produce a conflict.
 llvm::Optional checkName(const NamedDecl &RenameDecl,
@@ -476,6 +498,8 @@
   llvm::Optional Result;
   if (isKeyword(NewName, ASTCtx.getLangOpts()))
 Result = InvalidName{InvalidName::Keywords, NewName.str()};
+  else if (!mayBeValidIdentifier(NewName))
+Result = InvalidName{InvalidName::BadIdentifier, NewName.str()};
   else {
 // Name conflict detection.
 // Function conflicts are subtle (overloading), so ignore them.
___

[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-16 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D98278#2628527 , @uabelho wrote:

> In D98278#2628482 , @zero9178 wrote:
>
>> In D98278#2628477 , @uabelho wrote:
>>
>>> so perhaps there should be some additional error handling when running the 
>>> compiled program doesn't work?
>>
>> Could you try changing line 32 of llvm/cmake/modules/GetErrcMessages.cmake 
>> from `if (errc_compiled)` to `if (errc_compiled AND "${errc_exit_code}" 
>> STREQUAL "0")` and report back if it changes anything? I think that should 
>> fix your issue, although it'll fall back to using python's strerror 
>> messages. Indeed an oversight of mine.
>
> Yes that helps, please submit. Thanks!

Pushed in https://reviews.llvm.org/rG953bb5e5c8f60dc769942a3615d800fe166ffd1d


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[clang-tools-extra] 3b99731 - [clangd] Turn off implicit cancellation based on client capabilities

2021-03-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-16T12:27:40+01:00
New Revision: 3b99731c4e7bb844699eda6640bd99344f800c79

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

LOG: [clangd] Turn off implicit cancellation based on client capabilities

Capability is in upcoming 3.17: 
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/

(This is also useful for C++ embedders)

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index cd13e013aa50..b4a5cf337296 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -518,6 +518,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
   if (Params.capabilities.WorkDoneProgress)
 BackgroundIndexProgressState = BackgroundIndexProgress::Empty;
   BackgroundIndexSkipCreate = Params.capabilities.ImplicitProgressCreation;
+  Opts.ImplicitCancellation = !Params.capabilities.CancelsStaleRequests;
 
   llvm::json::Object ServerCaps{
   {"textDocumentSync",

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 164e387bd454..e9724e7516aa 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -150,6 +150,8 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),
+  Transient(Opts.ImplicitCancellation ? TUScheduler::InvalidateOnUpdate
+  : TUScheduler::NoInvalidation),
   DirtyFS(std::make_unique(TFS, DraftMgr)) {
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
@@ -593,7 +595,7 @@ void ClangdServer::enumerateTweaks(
   };
 
   WorkScheduler->runWithAST("EnumerateTweaks", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+Transient);
 }
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
@@ -683,8 +685,7 @@ void ClangdServer::findDocumentHighlights(
 CB(clangd::findDocumentHighlights(InpAST->AST, Pos));
   };
 
-  WorkScheduler->runWithAST("Highlights", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+  WorkScheduler->runWithAST("Highlights", File, std::move(Action), Transient);
 }
 
 void ClangdServer::findHover(PathRef File, Position Pos,
@@ -698,8 +699,7 @@ void ClangdServer::findHover(PathRef File, Position Pos,
 CB(clangd::getHover(InpAST->AST, Pos, std::move(Style), Index));
   };
 
-  WorkScheduler->runWithAST("Hover", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+  WorkScheduler->runWithAST("Hover", File, std::move(Action), Transient);
 }
 
 void ClangdServer::typeHierarchy(PathRef File, Position Pos, int Resolve,
@@ -771,7 +771,7 @@ void ClangdServer::documentSymbols(llvm::StringRef File,
 CB(clangd::getDocumentSymbols(InpAST->AST));
   };
   WorkScheduler->runWithAST("DocumentSymbols", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+Transient);
 }
 
 void ClangdServer::foldingRanges(llvm::StringRef File,
@@ -783,7 +783,7 @@ void ClangdServer::foldingRanges(llvm::StringRef File,
 CB(clangd::getFoldingRanges(InpAST->AST));
   };
   WorkScheduler->runWithAST("FoldingRanges", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+Transient);
 }
 
 void ClangdServer::findImplementations(
@@ -850,7 +850,7 @@ void ClangdServer::documentLinks(PathRef File,
 CB(clangd::getDocumentLinks(InpAST->AST));
   };
   WorkScheduler->runWithAST("DocumentLinks", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+Transient);
 }
 
 void ClangdServer::semanticHighlights(
@@ -862,7 +862,7 @@ void ClangdServer::semanticHighlights(
 CB(clangd::getSemanticHighlightings(InpAST->AST));
   };
   WorkScheduler->runWithAST("SemanticHighlights", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+

[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-16 Thread Sam McCall 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 rG3b99731c4e7b: [clangd] Turn off implicit cancellation based 
on client capabilities (authored by sammccall).
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h

Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -475,6 +475,10 @@
   /// window.implicitWorkDoneProgressCreate
   bool ImplicitProgressCreation = false;
 
+  /// Whether the client claims to cancel stale requests.
+  /// general.staleRequestSupport.cancel
+  bool CancelsStaleRequests = false;
+
   /// Whether the client implementation supports a refresh request sent from the
   /// server to the client.
   bool SemanticTokenRefreshSupport = false;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -414,6 +414,12 @@
 if (auto Implicit = Window->getBoolean("implicitWorkDoneProgressCreate"))
   R.ImplicitProgressCreation = *Implicit;
   }
+  if (auto *General = O->getObject("general")) {
+if (auto *StaleRequestSupport = General->getObject("staleRequestSupport")) {
+  if (auto Cancel = StaleRequestSupport->getBoolean("cancel"))
+R.CancelsStaleRequests = *Cancel;
+}
+  }
   if (auto *OffsetEncoding = O->get("offsetEncoding")) {
 R.offsetEncoding.emplace();
 if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -146,6 +146,12 @@
 /*RebuildRatio=*/1,
 };
 
+/// Cancel certain requests if the file changes before they begin running.
+/// This is useful for "transient" actions like enumerateTweaks that were
+/// likely implicitly generated, and avoids redundant work if clients forget
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+
 /// Clangd will execute compiler drivers matching one of these globs to
 /// fetch system include path.
 std::vector QueryDriverGlobs;
@@ -391,6 +397,8 @@
 
   llvm::Optional WorkspaceRoot;
   llvm::Optional WorkScheduler;
+  // Invalidation policy used for actions that we assume are "transient".
+  TUScheduler::ASTActionInvalidation Transient;
 
   // Store of the current versions of the open documents.
   // Only written from the main thread (despite being threadsafe).
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -150,6 +150,8 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),
+  Transient(Opts.ImplicitCancellation ? TUScheduler::InvalidateOnUpdate
+  : TUScheduler::NoInvalidation),
   DirtyFS(std::make_unique(TFS, DraftMgr)) {
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
@@ -593,7 +595,7 @@
   };
 
   WorkScheduler->runWithAST("EnumerateTweaks", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+Transient);
 }
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
@@ -683,8 +685,7 @@
 CB(clangd::findDocumentHighlights(InpAST->AST, Pos));
   };
 
-  WorkScheduler->runWithAST("Highlights", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+  WorkScheduler->runWithAST("Highlights", File, std::move(Action), Transient);
 }
 
 void ClangdServer::findHover(PathRef File, Position Pos,
@@ -698,8 +699,7 @@
 CB(clangd::getHover(InpAST->AST, Pos, std::move(Style), Index));
   };
 
-  WorkScheduler->runWithAST("Hover", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+  WorkScheduler->runWithAST("Hover", File, std::move(Action), Transient);
 }
 
 void ClangdServer::typeHierarchy(PathRef File, Position Pos, int Resolve,
@@ -771,7 +771,7 @@
 CB(clangd::getDocumentSymbols(InpAST->AST));
   };
   WorkSc

[clang-tools-extra] ca13f55 - [clangd] Add `limit` extension on completion and workspace-symbols

2021-03-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-16T12:28:01+01:00
New Revision: ca13f5595ae8dc7326f29c8658de70bbc1854db0

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

LOG: [clangd] Add `limit` extension on completion and workspace-symbols

This overrides the --limit-results command-line flag, and is not constrained
by it.
See https://github.com/clangd/clangd/issues/707

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index b4a5cf337296..aef849d8d8d9 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -780,7 +780,7 @@ void ClangdLSPServer::onWorkspaceSymbol(
 const WorkspaceSymbolParams &Params,
 Callback> Reply) {
   Server->workspaceSymbols(
-  Params.query, Opts.CodeComplete.Limit,
+  Params.query, Params.limit.getValueOr(Opts.CodeComplete.Limit),
   [Reply = std::move(Reply),
this](llvm::Expected> Items) mutable {
 if (!Items)
@@ -1031,21 +1031,24 @@ void ClangdLSPServer::onCompletion(const 
CompletionParams &Params,
 vlog("ignored auto-triggered completion, preceding char did not match");
 return Reply(CompletionList());
   }
-  Server->codeComplete(
-  Params.textDocument.uri.file(), Params.position, Opts.CodeComplete,
-  [Reply = std::move(Reply),
-   this](llvm::Expected List) mutable {
-if (!List)
-  return Reply(List.takeError());
-CompletionList LSPList;
-LSPList.isIncomplete = List->HasMore;
-for (const auto &R : List->Completions) {
-  CompletionItem C = R.render(Opts.CodeComplete);
-  C.kind = adjustKindToCapability(C.kind, 
SupportedCompletionItemKinds);
-  LSPList.items.push_back(std::move(C));
-}
-return Reply(std::move(LSPList));
-  });
+  auto Opts = this->Opts.CodeComplete;
+  if (Params.limit && *Params.limit >= 0)
+Opts.Limit = *Params.limit;
+  Server->codeComplete(Params.textDocument.uri.file(), Params.position, Opts,
+   [Reply = std::move(Reply), Opts,
+this](llvm::Expected List) mutable 
{
+ if (!List)
+   return Reply(List.takeError());
+ CompletionList LSPList;
+ LSPList.isIncomplete = List->HasMore;
+ for (const auto &R : List->Completions) {
+   CompletionItem C = R.render(Opts);
+   C.kind = adjustKindToCapability(
+   C.kind, SupportedCompletionItemKinds);
+   LSPList.items.push_back(std::move(C));
+ }
+ return Reply(std::move(LSPList));
+   });
 }
 
 void ClangdLSPServer::onSignatureHelp(const TextDocumentPositionParams &Params,

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 42ca721ebcbb..099c8531d341 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -750,7 +750,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const 
SymbolDetails &S) {
 bool fromJSON(const llvm::json::Value &Params, WorkspaceSymbolParams &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.map("query", R.query);
+  return O && O.map("query", R.query) &&
+ mapOptOrNull(Params, "limit", R.limit, P);
 }
 
 llvm::json::Value toJSON(const Command &C) {
@@ -851,7 +852,8 @@ bool fromJSON(const llvm::json::Value &Params, 
CompletionContext &R,
 
 bool fromJSON(const llvm::json::Value &Params, CompletionParams &R,
   llvm::json::Path P) {
-  if (!fromJSON(Params, static_cast(R), P))
+  if (!fromJSON(Params, static_cast(R), P) ||
+  !mapOptOrNull(Params, "limit", R.limit, P))
 return false;
   if (auto *Context = Params.getAsObject()->get("context"))
 return fromJSON(*Context, R.context, P.field("context"));

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 1334ddf4b5ce..8e90f1f47831 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1056,8 +1056,13 @@ bool operator==(const SymbolDetails &, const 
SymbolDetails &);
 
 /// The parameters of a Workspace Symbol Request.
 struct WorkspaceSymbolParams {
-  /// A non-empty query string
+  /// A query string to filter symbols by.
+  /// Clients may send an empty string here to request

[PATCH] D97801: [clangd] Add `limit` extension on completion and workspace-symbols

2021-03-16 Thread Sam McCall 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 rGca13f5595ae8: [clangd] Add `limit` extension on completion 
and workspace-symbols (authored by sammccall).
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97801

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h

Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1056,8 +1056,13 @@
 
 /// The parameters of a Workspace Symbol Request.
 struct WorkspaceSymbolParams {
-  /// A non-empty query string
+  /// A query string to filter symbols by.
+  /// Clients may send an empty string here to request all the symbols.
   std::string query;
+
+  /// Max results to return, overriding global default. 0 means no limit.
+  /// Clangd extension.
+  llvm::Optional limit;
 };
 bool fromJSON(const llvm::json::Value &, WorkspaceSymbolParams &,
   llvm::json::Path);
@@ -1106,6 +,10 @@
 
 struct CompletionParams : TextDocumentPositionParams {
   CompletionContext context;
+
+  /// Max results to return, overriding global default. 0 means no limit.
+  /// Clangd extension.
+  llvm::Optional limit;
 };
 bool fromJSON(const llvm::json::Value &, CompletionParams &, llvm::json::Path);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -750,7 +750,8 @@
 bool fromJSON(const llvm::json::Value &Params, WorkspaceSymbolParams &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.map("query", R.query);
+  return O && O.map("query", R.query) &&
+ mapOptOrNull(Params, "limit", R.limit, P);
 }
 
 llvm::json::Value toJSON(const Command &C) {
@@ -851,7 +852,8 @@
 
 bool fromJSON(const llvm::json::Value &Params, CompletionParams &R,
   llvm::json::Path P) {
-  if (!fromJSON(Params, static_cast(R), P))
+  if (!fromJSON(Params, static_cast(R), P) ||
+  !mapOptOrNull(Params, "limit", R.limit, P))
 return false;
   if (auto *Context = Params.getAsObject()->get("context"))
 return fromJSON(*Context, R.context, P.field("context"));
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -780,7 +780,7 @@
 const WorkspaceSymbolParams &Params,
 Callback> Reply) {
   Server->workspaceSymbols(
-  Params.query, Opts.CodeComplete.Limit,
+  Params.query, Params.limit.getValueOr(Opts.CodeComplete.Limit),
   [Reply = std::move(Reply),
this](llvm::Expected> Items) mutable {
 if (!Items)
@@ -1031,21 +1031,24 @@
 vlog("ignored auto-triggered completion, preceding char did not match");
 return Reply(CompletionList());
   }
-  Server->codeComplete(
-  Params.textDocument.uri.file(), Params.position, Opts.CodeComplete,
-  [Reply = std::move(Reply),
-   this](llvm::Expected List) mutable {
-if (!List)
-  return Reply(List.takeError());
-CompletionList LSPList;
-LSPList.isIncomplete = List->HasMore;
-for (const auto &R : List->Completions) {
-  CompletionItem C = R.render(Opts.CodeComplete);
-  C.kind = adjustKindToCapability(C.kind, SupportedCompletionItemKinds);
-  LSPList.items.push_back(std::move(C));
-}
-return Reply(std::move(LSPList));
-  });
+  auto Opts = this->Opts.CodeComplete;
+  if (Params.limit && *Params.limit >= 0)
+Opts.Limit = *Params.limit;
+  Server->codeComplete(Params.textDocument.uri.file(), Params.position, Opts,
+   [Reply = std::move(Reply), Opts,
+this](llvm::Expected List) mutable {
+ if (!List)
+   return Reply(List.takeError());
+ CompletionList LSPList;
+ LSPList.isIncomplete = List->HasMore;
+ for (const auto &R : List->Completions) {
+   CompletionItem C = R.render(Opts);
+   C.kind = adjustKindToCapability(
+   C.kind, SupportedCompletionItemKinds);
+   LSPList.items.push_back(std::move(C));
+ }
+ return Reply(std::move(LSPList));
+   });
 }
 
 void ClangdLSPServer::onSignatureHelp(const TextDocumentPositionParams &Params,
___
c

[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330937.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Resolve review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/MonitoringService.proto
  clang-tools-extra/clangd/index/remote/Service.proto
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,7 +8,10 @@
 
 #include "Features.inc"
 #include "Index.pb.h"
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
 #include "Service.grpc.pb.h"
+#include "Service.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
@@ -288,11 +291,46 @@
   clangd::SymbolIndex &Index;
 };
 
+class Monitor final : public v1::Monitor::Service {
+public:
+  Monitor(llvm::sys::TimePoint<> IndexAge)
+  : StartTime(std::chrono::system_clock::now()), IndexBuildTime(IndexAge) {}
+
+  void updateIndex(llvm::sys::TimePoint<> UpdateTime) {
+IndexBuildTime.exchange(UpdateTime);
+  }
+
+private:
+  // FIXME(kirillbobyrev): Most fields should be populated when the index
+  // reloads (probably in adjacent metadata.txt file next to loaded .idx) but
+  // they aren't right now.
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const v1::MonitoringInfoRequest *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_uptime_seconds(std::chrono::duration_cast(
+  std::chrono::system_clock::now() - StartTime)
+  .count());
+// FIXME(kirillbobyrev): We are currently making use of the last
+// modification time of the index artifact to deduce its age. This is wrong
+// as it doesn't account for the indexing delay. Propagate some metadata
+// with the index artifacts to indicate time of the commit we indexed.
+Reply->set_index_age_seconds(
+std::chrono::duration_cast(
+std::chrono::system_clock::now() - IndexBuildTime.load())
+.count());
+return grpc::Status::OK;
+  }
+
+  const llvm::sys::TimePoint<> StartTime;
+  std::atomic> IndexBuildTime;
+};
+
 // Detect changes in \p IndexPath file and load new versions of the index
 // whenever they become available.
 void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
llvm::vfs::Status &LastStatus,
-   llvm::IntrusiveRefCntPtr &FS) {
+   llvm::IntrusiveRefCntPtr &FS,
+   Monitor &Monitor) {
   auto Status = FS->status(IndexPath);
   // Requested file is same as loaded index: no reload is needed.
   if (!Status || (Status->getLastModificationTime() ==
@@ -309,12 +347,13 @@
 return;
   }
   Index.reset(std::move(NewIndex));
+  Monitor.updateIndex(Status->getLastModificationTime());
   log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
   Status->getLastModificationTime(), Status->getSize());
 }
 
 void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
-  llvm::StringRef IndexPath) {
+  llvm::StringRef IndexPath, Monitor &Monitor) {
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
@@ -327,6 +366,7 @@
   Builder.AddChannelArgument(GRPC_ARG_MAX_CONNECTION_IDLE_MS,
  IdleTimeoutSeconds * 1000);
   Builder.RegisterService(&Service);
+  Builder.RegisterService(&Monitor);
   std::unique_ptr Server(Builder.BuildAndStart());
   log("Server listening on {0}", ServerAddress);
 
@@ -425,16 +465,18 @@
   }
   clang::clangd::SwapIndex Index(std::move(SymIndex));
 
-  std::thread HotReloadThread([&Index, &Status, &FS]() {
+  Monitor Monitor(Status->getLastModificationTime());
+
+  std::thread HotReloadThread([&Index, &Status, &FS, &Monitor]() {
 llvm::vfs::Status LastStatus = *Status;
 static constexpr auto RefreshFrequency = std::chrono::seconds(30);
 while (!clang::clangd::shutdownRequested()) {
-  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS);
+  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS, Monitor);
   std::this_thread::sleep_for(RefreshFrequency);
 }
   });
 
-  runServerAndWait(Index, ServerAddress, IndexPath);
+  runServerAndWait(Index, ServerAddress, IndexPath, Monitor);
 
   HotReloadThread.join();
 }
Index: clang-tools-extra/clangd/index/remote/Service.proto
===
--- clang-tools-extra/clangd/index/remote/Service.prot

[PATCH] D98664: Fix crash on dumping AST containing constant initializer with ParenListExpr

2021-03-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

As far as the changes go, these seem reasonable to me, though I find it a bit 
odd that these are expressions without a type whereas a `ParenExpr` has a type 
of the underlying parenthesized expression. e.g.,

  int x(0); // (0) has void type
  int y = (0); // (0) has int type

I think my natural assumption is that the init expression would have the type 
of the thing that's being initialized.

Despite that, I think the changes LG, but I'd like to hear from @rsmith.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98664

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


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D98411#2626613 , @ldrumm wrote:

> Given this fixes a runtime crash bug, should it be backported to the relevant 
> release branch?

Sure, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-16 Thread Bing Yu via Phabricator via cfe-commits
yubing added a comment.

In D93594#2628497 , @nikic wrote:

> It looks like this has caused a compile-time regression at `O0`: 
> https://llvm-compile-time-tracker.com/compare.php?from=9341bcbdc93a251b632ffaa51a84452a7a4a5e4e&to=4f198b0c27b04e830a3069aaf4b39cf203eaae4a&stat=instructions
>
> The cause is probably the computation of DomTree and LoopInfo, even if no AMX 
> intrinsics are present. I think you should be able to easily fix this by not 
> fetching DT/LI from the pass manager, and computing them in the pass instead 
> (only if intrinsics are present).

Thanks, @nikic, I will fix it ASAP. Besides, How could I reproduce the 
regression?
Eh, I am asking these question because I think I should see if the repression 
can't be reproduced with my future bugfix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:1914
+ELAAMS_Leave,
+/// Always add empty line after access modifiers.
+/// \code

It does not always add, it does enforces one empty line, or am I mistaken?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[clang-tools-extra] 128ce70 - [CodeCompletion] Avoid spurious signature help for init-list args

2021-03-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-16T12:46:40+01:00
New Revision: 128ce70eef9948b81e725fd0e2ed46a7c004a118

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

LOG: [CodeCompletion] Avoid spurious signature help for init-list args

Somewhat surprisingly, signature help is emitted as a side-effect of
computing the expected type of a function argument.
The reason is that both actions require enumerating the possible
function signatures and running partial overload resolution, and doing
this twice would be wasteful and complicated.

Change #1: document this, it's subtle :-)

However, sometimes we need to compute the expected type without having
reached the code completion cursor yet - in particular to allow
completion of designators.
eb4ab3358cd4dc834a761191b5531b38114f7b13 did this but introduced a
regression - it emits signature help in the wrong location as a side-effect.

Change #2: only emit signature help if the code completion cursor was reached.

Currently there is PP.isCodeCompletionReached(), but we can't use it
because it's set *after* running code completion.
It'd be nice to set this implicitly when the completion token is lexed,
but ConsumeCodeCompletionToken() makes this complicated.

Change #3: call cutOffParsing() *first* when seeing a completion token.

After this, the fact that the Sema::Produce*SignatureHelp() functions
are even more confusing, as they only sometimes do that.
I don't want to rename them in this patch as it's another large
mechanical change, but we should soon.

Change #4: prepare to rename ProduceSignatureHelp() to GuessArgumentType() etc.

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/Sema/Sema.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/desig-init.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 0ff1e83b7613..a57ae49f9159 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1253,6 +1253,19 @@ TEST(SignatureHelpTest, Overloads) {
   EXPECT_EQ(0, Results.activeParameter);
 }
 
+TEST(SignatureHelpTest, OverloadInitListRegression) {
+  auto Results = signatures(R"cpp(
+struct A {int x;};
+struct B {B(A);};
+void f();
+int main() {
+  B b({1});
+  f(^);
+}
+  )cpp");
+  EXPECT_THAT(Results.signatures, UnorderedElementsAre(Sig("f() -> void")));
+}
+
 TEST(SignatureHelpTest, DefaultArgs) {
   auto Results = signatures(R"cpp(
 void bar(int x, int y = 0);

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9e3eb4f07472..79e2471fdabe 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -306,6 +306,9 @@ class PreferredTypeBuilder {
   /// Clients should be very careful when using this funciton, as it stores a
   /// function_ref, clients should make sure all calls to get() with the same
   /// location happen while function_ref is alive.
+  ///
+  /// The callback should also emit signature help as a side-effect, but only
+  /// if the completion point has been reached.
   void enterFunctionArgument(SourceLocation Tok,
  llvm::function_ref ComputeType);
 
@@ -318,6 +321,12 @@ class PreferredTypeBuilder {
   /// Handles all type casts, including C-style cast, C++ casts, etc.
   void enterTypeCast(SourceLocation Tok, QualType CastType);
 
+  /// Get the expected type associated with this location, if any.
+  ///
+  /// If the location is a function argument, determining the expected type
+  /// involves considering all function overloads and the arguments so far.
+  /// In this case, signature help for these function overloads will be 
reported
+  /// as a side-effect (only if the completion point has been reached).
   QualType get(SourceLocation Tok) const {
 if (!Enabled || Tok != ExpectedLoc)
   return QualType();
@@ -12216,8 +12225,14 @@ class Sema final {
   const VirtSpecifiers *VS = nullptr);
   void CodeCompleteBracketDeclarator(Scope *S);
   void CodeCompleteCase(Scope *S);
-  /// Reports signatures for a call to CodeCompleteConsumer and returns the
-  /// preferred type for the curre

[PATCH] D98488: [CodeCompletion] Avoid spurious signature help for init-list args

2021-03-16 Thread Sam McCall 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 rG128ce70eef99: [CodeCompletion] Avoid spurious signature help 
for init-list args (authored by sammccall).
Herald added a project: clang-tools-extra.

Changed prior to commit:
  https://reviews.llvm.org/D98488?vs=330218&id=330945#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98488

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/Sema.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/desig-init.cpp

Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -62,3 +62,18 @@
   Test X{.x = T(2)};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:62:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
 }
+
+namespace signature_regression {
+  // Verify that an old bug is gone: passing an init-list as a constructor arg
+  // would emit overloads as a side-effect.
+  struct S{int x;};
+  int wrongFunction(S);
+  int rightFunction();
+  int dummy = wrongFunction({1});
+  int x = rightFunction();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:73:25 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-SIGNATURE-REGRESSION %s
+  // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
+  // CHECK-SIGNATURE-REGRESSION: OVERLOAD: [#int#]rightFunction
+  // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
+}
+
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5711,8 +5711,9 @@
  unsigned CurrentArg, SourceLocation OpenParLoc) {
   if (Candidates.empty())
 return QualType();
-  SemaRef.CodeCompleter->ProcessOverloadCandidates(
-  SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
+  if (SemaRef.getPreprocessor().isCodeCompletionReached())
+SemaRef.CodeCompleter->ProcessOverloadCandidates(
+SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
   return getParamType(SemaRef, Candidates, CurrentArg);
 }
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -870,6 +870,7 @@
 SingleDecl = ParseObjCMethodDefinition();
 break;
   case tok::code_completion:
+cutOffParsing();
 if (CurParsedObjCImpl) {
   // Code-complete Objective-C methods even without leading '-'/'+' prefix.
   Actions.CodeCompleteObjCMethodDecl(getCurScope(),
@@ -879,7 +880,6 @@
 Actions.CodeCompleteOrdinaryName(
 getCurScope(),
 CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace);
-cutOffParsing();
 return nullptr;
   case tok::kw_import:
 SingleDecl = ParseModuleImport(SourceLocation());
@@ -2114,21 +2114,21 @@
 
   for (Scope *S = getCurScope(); S; S = S->getParent()) {
 if (S->getFlags() & Scope::FnScope) {
+  cutOffParsing();
   Actions.CodeCompleteOrdinaryName(getCurScope(),
Sema::PCC_RecoveryInFunction);
-  cutOffParsing();
   return PrevTokLocation;
 }
 
 if (S->getFlags() & Scope::ClassScope) {
-  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class);
   cutOffParsing();
+  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class);
   return PrevTokLocation;
 }
   }
 
-  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
   cutOffParsing();
+  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
   return PrevTokLocation;
 }
 
@@ -2452,8 +2452,8 @@
   while (true) {
 if (!Tok.is(tok::identifier)) {
   if (Tok.is(tok::code_completion)) {
-Actions.CodeCompleteModuleImport(UseLoc, Path);
 cutOffParsing();
+Actions.CodeCompleteModuleImport(UseLoc, Path);
 return true;
   }
 
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -178,8 +178,8 @@
 }
 
   case tok::code_completion:
-Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement);
 cutOffPars

[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks! let's ship it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

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


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-16 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm added a comment.

In D98411#2628592 , @Anastasia wrote:

> In D98411#2626613 , @ldrumm wrote:
>
>> Given this fixes a runtime crash bug, should it be backported to the 
>> relevant release branch?
>
> Sure, thanks!

https://bugs.llvm.org/show_bug.cgi?id=49605


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[clang-tools-extra] 2772c3a - [clangd] Introduce pullDiags endpoint

2021-03-16 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-16T12:52:15+01:00
New Revision: 2772c3a9752289ffec473b62f84855262a22de0b

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

LOG: [clangd] Introduce pullDiags endpoint

Implement initial support for pull-based diagnostics in ClangdServer.
This is planned for LSP 3.17, and initial proposal is in
https://github.com/microsoft/vscode-languageserver-node/blob/d15eb0671e0947d14e3548d13754104ee13aa56d/protocol/src/common/proposed.diagnostic.ts#L111.

We chose to serve the requests only when clangd has a fresh preamble
available. In case of a stale preamble we just drop the request on the
floor.

This patch doesn't plumb this to LSP layer yet, as pullDiags is still a
proposal with only an implementation in vscode.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/ParsedAST.h
clang-tools-extra/clangd/Preamble.h
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang-tools-extra/clangd/unittests/ModulesTests.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang-tools-extra/clangd/unittests/PreambleTests.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/TestTU.h
clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index e9724e7516aa..f9516a1537a0 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -9,6 +9,7 @@
 #include "ClangdServer.h"
 #include "CodeComplete.h"
 #include "Config.h"
+#include "Diagnostics.h"
 #include "DumpAST.h"
 #include "FindSymbols.h"
 #include "Format.h"
@@ -81,7 +82,9 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
 if (FIndex)
   FIndex->updateMain(Path, AST);
 
-std::vector Diagnostics = AST.getDiagnostics();
+assert(AST.getDiagnostics().hasValue() &&
+   "We issue callback only with fresh preambles");
+std::vector Diagnostics = *AST.getDiagnostics();
 if (ServerCallbacks)
   Publish([&]() {
 ServerCallbacks->onDiagnosticsReady(Path, AST.version(),
@@ -902,6 +905,21 @@ void ClangdServer::customAction(PathRef File, 
llvm::StringRef Name,
   WorkScheduler->runWithAST(Name, File, std::move(Action));
 }
 
+void ClangdServer::diagnostics(PathRef File, Callback> CB) {
+  auto Action =
+  [CB = std::move(CB)](llvm::Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+if (auto Diags = InpAST->AST.getDiagnostics())
+  return CB(*Diags);
+// FIXME: Use ServerCancelled error once it is settled in LSP-3.17.
+return CB(llvm::make_error("server is busy parsing includes",
+ ErrorCode::InternalError));
+  };
+
+  WorkScheduler->runWithAST("Diagnostics", File, std::move(Action));
+}
+
 llvm::StringMap ClangdServer::fileStats() const {
   return WorkScheduler->fileStats();
 }

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index b633d3139683..37ac30f70cb4 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -12,6 +12,7 @@
 #include "../clang-tidy/ClangTidyOptions.h"
 #include "CodeComplete.h"
 #include "ConfigProvider.h"
+#include "Diagnostics.h"
 #include "DraftStore.h"
 #include "FeatureModule.h"
 #include "GlobalCompilationDatabase.h"
@@ -40,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -64,6 +66,8 @@ class ClangdServer {
 virtual ~Callbacks() = default;
 
 /// Called by ClangdServer when \p Diagnostics for \p File are ready.
+/// These pushed diagnostics might correspond to an older version of the
+/// file, they do not interfere with "pull-based" 
ClangdServer::diagnostics.
 /// May be called concurrently for separate files, not for a single file.
 virtual void onDiagnosticsReady(PathRef File, llvm::StringRef Version,
 std::vector Diagnostics) {}
@@ -345,6 +349,14 @@ class ClangdServer {
   void customAction(PathRef File, llvm::StringRef Name,
 Callback Action);
 
+  /// Fetches diagnostics for current version of the \p File. This might fail 
if
+  /// server is busy (building a preamble) and would require a long time to
+  /// prepare diagnost

[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6268
+  auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
+  auto *Call = CGF.Builder.CreateCall(
+  CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});

Btw I think we should be using `CodeGenFunction::EmitRuntimeCall` here instead 
because it sets the CC correctly through `SPIRABIInfo`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-16 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

I have one more though.

I like the idea of turning `opencl-c.h` into the test: as it is already in the 
repo and is already being used for quite a while we can assume it as a mainline 
for now. I think the first step should be to test that 
`-fdeclare-oprencl-builtins` generates the same built-ins which are declared in 
`opencl-c.h`. If we can't do this //programmable way// we can use AST 
pretty-printing for tablegen header and `opencl-c.h` and compare these with 
//diff //(we can also do a clean-up of AST files with //rm// while running that 
tests).

Once this is done we can incrementally modify either `opencl-c.h` header and 
tablegen header. Testing changes to either of them can combine sanity check as 
@svenvh suggested in **builtins-opencl2.0.check** and diff for AST pretty 
printing.

Advantages:

- Time of testing. Locally I get nice results: 

  $ time ./build_release/bin/clang-check -extra-arg=-cl-std=CL2.0 --ast-print  
llvm-project/clang/lib/Headers/opencl-c.h &> header.h
  real    0m0.182s
  user    0m0.162s
  sys     0m0.020s

  But not yet clear how much time such printing will take for tablegen header. 
I assume it won't take a lot longer.

- This will keep changes to `opencl-h` header and tablegen header consistent 
(until `opencl-c.h` will be deprecated)

 
Disadvantages:

- Still doesn't eliminate subtle errors, need to carefully collect information 
from the spec about amount of the built-ins


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

https://reviews.llvm.org/D97869

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-16 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D96771#2626507 , @Anastasia wrote:

> I had a second thought about the extension name and I realized that the 
> reason why I initially wanted to use `clcpp` is that it aligns better with 
> `clc++` which is used in `-cl-std`. Even though from the RFC the preference 
> was towards `cppcl` it felt like there was no objection to `clcpp` either. So 
> I just want to check one last time whether it would make sense to align with 
> `clc++` and use `clcpp`. Perhaps, it make clang interface a bit more 
> inconsistent?

That is a good point, in my opinion aligning with the `-cl-std` flag is a good 
reason to go for `.clcpp`.  I would recommend mentioning this on the RfC thread 
too, to ensure that people who suggested a slight preference for the other 
extension are okay with `.clcpp` too.


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

https://reviews.llvm.org/D96771

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


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-16 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6268
+  auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
+  auto *Call = CGF.Builder.CreateCall(
+  CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});

Anastasia wrote:
> Btw I think we should be using `CodeGenFunction::EmitRuntimeCall` here 
> instead because it sets the CC correctly through `SPIRABIInfo`.
> 
Thanks. I'll prepare a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-16 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 330951.
bsmith added a comment.

- Remove `SDTFPRoundEvenOp` as it's not a correct mirror of `SDTFPRoundOp` 
since that is not for `ISD::FROUND`.
- Fix comments in `include/llvm/Target/TargetSelectionDAG.td` for 
`SDTFPRoundOp` and `SDTFPExtendOp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm64-vrnd.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/Target/TargetSelectionDAG.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/arm64-vcvt.ll
  llvm/test/CodeGen/AArch64/arm64-vfloatintrinsics.ll
  llvm/test/CodeGen/AArch64/f16-instructions.ll
  llvm/test/CodeGen/AArch64/fp-intrinsics.ll
  llvm/test/CodeGen/AArch64/frintn.ll
  llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
  llvm/test/CodeGen/AArch64/vec-libcalls.ll

Index: llvm/test/CodeGen/AArch64/vec-libcalls.ll
===
--- llvm/test/CodeGen/AArch64/vec-libcalls.ll
+++ llvm/test/CodeGen/AArch64/vec-libcalls.ll
@@ -29,6 +29,7 @@
 declare <3 x float> @llvm.nearbyint.v3f32(<3 x float>)
 declare <3 x float> @llvm.rint.v3f32(<3 x float>)
 declare <3 x float> @llvm.round.v3f32(<3 x float>)
+declare <3 x float> @llvm.roundeven.v3f32(<3 x float>)
 declare <3 x float> @llvm.sqrt.v3f32(<3 x float>)
 declare <3 x float> @llvm.trunc.v3f32(<3 x float>)
 
@@ -478,6 +479,15 @@
   ret <3 x float> %r
 }
 
+define <3 x float> @roundeven_v3f32(<3 x float> %x) nounwind {
+; CHECK-LABEL: roundeven_v3f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:frintn v0.4s, v0.4s
+; CHECK-NEXT:ret
+  %r = call <3 x float> @llvm.roundeven.v3f32(<3 x float> %x)
+  ret <3 x float> %r
+}
+
 define <3 x float> @sqrt_v3f32(<3 x float> %x) nounwind {
 ; CHECK-LABEL: sqrt_v3f32:
 ; CHECK:   // %bb.0:
Index: llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
===
--- llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
+++ llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
@@ -1255,6 +1255,253 @@
   ret void
 }
 
+;
+; ROUNDEVEN -> FRINTN
+;
+
+; Don't use SVE for 64-bit vectors.
+define <4 x half> @frintn_v4f16(<4 x half> %op) #0 {
+; CHECK-LABEL: frintn_v4f16:
+; CHECK: frintn v0.4h, v0.4h
+; CHECK-NEXT: ret
+  %res = call <4 x half> @llvm.roundeven.v4f16(<4 x half> %op)
+  ret <4 x half> %res
+}
+
+; Don't use SVE for 128-bit vectors.
+define <8 x half> @frintn_v8f16(<8 x half> %op) #0 {
+; CHECK-LABEL: frintn_v8f16:
+; CHECK: frintn v0.8h, v0.8h
+; CHECK-NEXT: ret
+  %res = call <8 x half> @llvm.roundeven.v8f16(<8 x half> %op)
+  ret <8 x half> %res
+}
+
+define void @frintn_v16f16(<16 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v16f16:
+; CHECK: ptrue [[PG:p[0-9]+]].h, vl16
+; CHECK-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; CHECK-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; CHECK-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; CHECK-NEXT: ret
+  %op = load <16 x half>, <16 x half>* %a
+  %res = call <16 x half> @llvm.roundeven.v16f16(<16 x half> %op)
+  store <16 x half> %res, <16 x half>* %a
+  ret void
+}
+
+define void @frintn_v32f16(<32 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v32f16:
+; VBITS_GE_512: ptrue [[PG:p[0-9]+]].h, vl32
+; VBITS_GE_512-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_GE_512-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; VBITS_GE_512-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; VBITS_GE_512-NEXT: ret
+
+; Ensure sensible type legalisation.
+; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].h, vl16
+; VBITS_EQ_256-DAG: add x[[A_HI:[0-9]+]], x0, #32
+; VBITS_EQ_256-DAG: ld1h { [[OP_LO:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_EQ_256-DAG: ld1h { [[OP_HI:z[0-9]+]].h }, [[PG]]/z, [x[[A_HI]]]
+; VBITS_EQ_256-DAG: frintn [[RES_LO:z[0-9]+]].h, [[PG]]/m, [[OP_LO]].h
+; VBITS_EQ_256-DAG: frintn [[RES_HI:z[0-9]+]].h, [[PG]]/m, [[OP_HI]].h
+; VBITS_EQ_256-DAG: st1h { [[RES_LO]].h }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1h { [[RES_HI]].h }, [[PG]], [x[[A_HI]]
+; VBITS_EQ_256-NEXT: ret
+  %op = load <32 x half>, <32 x half>* %a
+  %res = call <32 x half> @llvm.roundeven.v32f16(<32 x half> %op)
+  store <32 x half> %res, <32 x half>* %a
+  ret void
+}
+
+define void @frintn_v64f16(<64 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v64f16:
+; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].h, vl64
+; VBITS_GE_1024-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_GE_1024-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; VBITS_GE_1024-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+

[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

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

LGTM, though I think we should consider changing the diagnostic text (for all 
of the VLA folding cases) as a follow-up.




Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

rsmith wrote:
> efriedma wrote:
> > aaron.ballman wrote:
> > > efriedma wrote:
> > > > aaron.ballman wrote:
> > > > > efriedma wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type 
> > > > > > > name shall specify a complete object type or an array of unknown 
> > > > > > > size, but not a variable-length array type"?
> > > > > > Yes, this is a constraint violation.  This patch downgrades the 
> > > > > > error to a warning, for compatibility with older versions of clang.
> > > > > It was an error in older versions of Clang, so downgrading it to a 
> > > > > warning can't make code *more* compatible with older versions. This 
> > > > > also makes it harder to port C code to other compilers because Clang 
> > > > > happily accepts code that the C standard says should be rejected.
> > > > > 
> > > > > I'm not strongly opposed to the change, but I also don't like 
> > > > > ignoring constraint violations in the standard as that comes awfully 
> > > > > close to what `-fpermissive` does (and at least with that awful flag 
> > > > > you have to opt *into* the less strictly conforming behavior instead 
> > > > > of getting it by default as with extensions).
> > > > > 
> > > > > I'm curious if @rsmith has thoughts here?
> > > > > It was an error in older versions of Clang
> > > > 
> > > > https://godbolt.org/z/rvbffY
> > > Oh, I hadn't realized this changed *that* recently! Is this breaking some 
> > > significant amounts of code now that we err on it (or regressing 
> > > performance by not folding the VLA)?
> > > 
> > > My point still stands about disliking when we ignore constraint 
> > > violations. To expound a bit, in this particular case, I think the 
> > > standard is being over-constraining because we reasonably *can* fold this 
> > > to a more efficient form. Normally, I'd suggest filing a DR with WG14 
> > > over this and treating the constraint as UB we can extend. However, I 
> > > think the "solution" that comes out of WG14 would (likely) be to make 
> > > compound literal expressions of VLA types be undefined behavior rather 
> > > than a constraint violation (because I don't see many other options in 
> > > the standard wording for a more targeted fix to allow *just* this safe 
> > > usage). Given the security concerns around misuse of VLAs already, I 
> > > think that would be a worse world to live in even if it gets us what we 
> > > want with this specific case in mind. This is where my caution is coming 
> > > from. Knowing a bit more about the experience in the proprietary code 
> > > bases would be helpful, if it's something you can share more details 
> > > about.
> > The pattern I saw looked something like the following, at global scope, 
> > where it couldn't really be confused for a VLA:
> > 
> > ```
> > const int x = 2;
> > int *p = (int[x]){0};
> > ```
> > 
> > As for the frequency of it showing up, I think I got confused.  Looking 
> > again, there were multiple codebases with new -Wgnu-folding-constant 
> > warnings, but only one codebase with this specific construct.  So that 
> > makes the argument a bit weaker.
> > 
> > That said, we're doing this folding for variables already, so extending it 
> > to compound literals doesn't seem like a big deal.  And the warning is on 
> > by default.
> > Is this breaking some significant amounts of code now that we err on it (or 
> > regressing performance by not folding the VLA)?
> 
> We only ever constant-fold VLAs to constant-length arrays in cases where a 
> VLA would be invalid, so there's no regressing-performance concern. (We used 
> to do such folding, but it resulted in our miscompiling certain testcases, 
> which is why Clang's behavior changed recently.) As a result, there's no risk 
> of someone seeing a surprise VLA here, that should have been a constraint 
> violation.
> 
> Given the above, I don't think that changing this from a constraint violation 
> to UB in the C standard would make a difference. Either way, I think a 
> strictly conforming program cannot contain such a construct, and a conforming 
> implementation can, as an extension, define the meaning of programs 
> containing such a construct.
> 
> It's common for us to have conforming extensions that permit us to accept 
> more real-world code. Accepting with an on-by-default warning is often the 
> best tradeoff between accepting real-world code and diagnosing non-portable 
> constructs, especially in cases where past versions of GCC (<= 4.4) a

[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 330952.
abhina.sreeskantharajan added a comment.

Sorry Zibi, I misunderstood your comment. I updated the patch to switch around 
the Flag and Mode defaults in createUniqueFile because the flags was set 
explicitly more often than mode.  I also had to reorder the args in 
createUniqueEntity to match the ordering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr =
+MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(
+  Filename, EC,
+  llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // If open fails, no cleanup is needed.
   if (EC)
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -167,8 +167,8 @@
 stat

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I think this seems reasonable, but one question I have is: do we want to accept 
lambdas without parens in older C++ modes as an extension (with suitable 
compatibility warnings)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Frontend/CompilerInstance.cpp:771
+TempPath, fd, TempPath,
+llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);

zibi wrote:
> The ` llvm::sys::fs::all_read | llvm::sys::fs::all_write` seems to be a 
> default so if we make that parameter last we won't need to pass it and worry 
> about the mode parameter which would be the second last default parameter.  
> Switch parameters only when you determine that indeed `tag` is more frequent 
> parameter which need to be set comparing to `mode` parameter.
Thanks, I've reordered the args as you suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD

2021-03-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 330954.
tbaeder added a comment.

Dropped the `FORCE` stuff since we can just set the variable directly and that 
shouldn't make a difference as far was I know. And the warning now only appears 
if either LTO or LLD are enabled.


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

https://reviews.llvm.org/D89942

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/3-stage-base.cmake


Index: clang/cmake/caches/3-stage-base.cmake
===
--- clang/cmake/caches/3-stage-base.cmake
+++ clang/cmake/caches/3-stage-base.cmake
@@ -3,15 +3,6 @@
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
-# Use LLD do have less requirements on system linker, unless we're on an apple
-# platform where the system compiler is to be prefered.
-if(APPLE)
-set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
-set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
-
 set(CLANG_BOOTSTRAP_TARGETS
   clang
   check-all
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -635,7 +635,31 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
+  # We want LLD for LTO, but LLD does not support SystemZ, so disable
+  # LTO here and use the installed system linker
+  if ("${LLVM_NATIVE_ARCH}" MATCHES "SystemZ")
+if (BOOTSTRAP_LLVM_ENABLE_LLD OR BOOTSTRAP_LLVM_ENABLE_LTO)
+  message(STATUS "Disabling LTO and LLD for stage3 builds since LLD does 
not support ${LLVM_NATIVE_ARCH}")
+endif()
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF)
+set(BOOTSTRAP_LLVM_ENABLE_LTO OFF)
+  elseif(APPLE)
+# Use LLD to have fewer requirements on system linker, unless we're on an 
apple
+# platform where the system compiler is to be preferred
+message(STATUS "Using system linker for stage3 builds on Apple")
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF)
+  else()
+set(BOOTSTRAP_LLVM_ENABLE_LLD ON)
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON)
+  endif()
+  message(STATUS "Stage3 builds: LLD: ${BOOTSTRAP_LLVM_ENABLE_LLD}. LTO: 
${BOOTSTRAP_LLVM_ENABLE_LTO}")
+
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
+# adding lld to clang-bootstrap-deps without having it enabled in
+# LLVM_ENABLE_PROJECTS just generates a cryptic error message.
+if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
+  message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is 
not in LLVM_ENABLE_PROJECTS")
+endif()
 add_dependencies(clang-bootstrap-deps lld)
   endif()
 


Index: clang/cmake/caches/3-stage-base.cmake
===
--- clang/cmake/caches/3-stage-base.cmake
+++ clang/cmake/caches/3-stage-base.cmake
@@ -3,15 +3,6 @@
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
-# Use LLD do have less requirements on system linker, unless we're on an apple
-# platform where the system compiler is to be prefered.
-if(APPLE)
-set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
-set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
-
 set(CLANG_BOOTSTRAP_TARGETS
   clang
   check-all
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -635,7 +635,31 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
+  # We want LLD for LTO, but LLD does not support SystemZ, so disable
+  # LTO here and use the installed system linker
+  if ("${LLVM_NATIVE_ARCH}" MATCHES "SystemZ")
+if (BOOTSTRAP_LLVM_ENABLE_LLD OR BOOTSTRAP_LLVM_ENABLE_LTO)
+  message(STATUS "Disabling LTO and LLD for stage3 builds since LLD does not support ${LLVM_NATIVE_ARCH}")
+endif()
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF)
+set(BOOTSTRAP_LLVM_ENABLE_LTO OFF)
+  elseif(APPLE)
+# Use LLD to have fewer requirements on system linker, unless we're on an apple
+# platform where the system compiler is to be preferred
+message(STATUS "Using system linker for stage3 builds on Apple")
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF)
+  else()
+set(BOOTSTRAP_LLVM_ENABLE_LLD ON)
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON)
+  endif()
+  message(STATUS "Stage3 builds: LLD: ${BOOTSTRAP_LLVM_ENABLE_LLD}. LTO: ${BOOTSTRAP_LLVM_ENABLE_LTO}")
+
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
+# adding lld to clang-bootstrap-deps without having it enabled in
+# LLVM_ENABLE_PROJECTS just generates a cryptic error message.
+if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
+  message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is not in LLVM_ENABLE_PROJECTS")
+endif()
 add_dependencies(clang-bootstrap-deps lld)

[clang-tools-extra] 524fe51 - [clangd] Add basic monitoring info request for remote index server

2021-03-16 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-03-16T13:37:58+01:00
New Revision: 524fe515091d31e1c054fc521113a3bf2088d159

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

LOG: [clangd] Add basic monitoring info request for remote index server

This allows requesting information about the server uptime and start time. This 
is the first patch in a series of monitoring changes, hence it's not 
immediately useful. Next step is propagating the index freshness information 
and then probably loading metadata into the index server.

The way to test new behaviour through command line:

```
$ grpc_cli call localhost:50051 Monitor/MonitoringInfo ''
connecting to localhost:50051
uptime_seconds: 42
index_age_seconds: 609568
Rpc succeeded with OK status
```

Reviewed By: kadircet

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

Added: 
clang-tools-extra/clangd/index/remote/MonitoringService.proto

Modified: 
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/index/remote/Service.proto
clang-tools-extra/clangd/index/remote/server/Server.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index eaa000b745e5..ded3f9274f86 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -1,5 +1,7 @@
 if (CLANGD_ENABLE_REMOTE)
   generate_protos(RemoteIndexProto "Index.proto")
+  generate_protos(MonitoringServiceProto "MonitoringService.proto"
+GRPC)
   generate_protos(RemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
@@ -8,6 +10,7 @@ if (CLANGD_ENABLE_REMOTE)
   target_link_libraries(RemoteIndexServiceProto
 PRIVATE
 RemoteIndexProto
+MonitoringServiceProto
 )
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)

diff  --git a/clang-tools-extra/clangd/index/remote/MonitoringService.proto 
b/clang-tools-extra/clangd/index/remote/MonitoringService.proto
new file mode 100644
index ..75d807c19005
--- /dev/null
+++ b/clang-tools-extra/clangd/index/remote/MonitoringService.proto
@@ -0,0 +1,27 @@
+//===--- MonitoringService.proto - CLangd Remote index monitoring service 
-===//
+//
+// 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
+//
+//===--===//
+
+syntax = "proto2";
+
+package clang.clangd.remote.v1;
+
+message MonitoringInfoRequest {}
+message MonitoringInfoReply {
+  // Time since the server started (in seconds).
+  optional uint64 uptime_seconds = 1;
+  // Time since the index was built on the indexing machine.
+  optional uint64 index_age_seconds = 2;
+  // ID of the indexed commit in Version Control System.
+  optional string index_commit_hash = 3;
+  // URL to the index file.
+  optional string index_link = 4;
+}
+
+service Monitor {
+  rpc MonitoringInfo(MonitoringInfoRequest) returns (MonitoringInfoReply) {}
+}

diff  --git a/clang-tools-extra/clangd/index/remote/Service.proto 
b/clang-tools-extra/clangd/index/remote/Service.proto
index 4e39ff9ec666..7c7efa530200 100644
--- a/clang-tools-extra/clangd/index/remote/Service.proto
+++ b/clang-tools-extra/clangd/index/remote/Service.proto
@@ -23,4 +23,3 @@ service SymbolIndex {
 
   rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
 }
-

diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index be0e844a1f80..f3cf131bb8a5 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,7 +8,10 @@
 
 #include "Features.inc"
 #include "Index.pb.h"
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
 #include "Service.grpc.pb.h"
+#include "Service.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
@@ -288,11 +291,46 @@ class RemoteIndexServer final : public 
v1::SymbolIndex::Service {
   clangd::SymbolIndex &Index;
 };
 
+class Monitor final : public v1::Monitor::Service {
+public:
+  Monitor(llvm::sys::TimePoint<> IndexAge)
+  : StartTime(std::chrono::system_clock::now()), IndexBuildTime(IndexAge) 
{}
+
+  void updateIndex(llvm::sys::TimePoint<> UpdateTime) {
+IndexBuildTime.exchange(UpdateTime);
+  }
+
+private:
+  // FIXME(kirillbobyrev): Most fields should be populated when the index
+  // reloads (probably in adjacent metadata.txt file next to loaded .idx) but
+  // they aren't right now.
+  g

[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-16 Thread Kirill Bobyrev 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 rG524fe515091d: [clangd] Add basic monitoring info request for 
remote index server (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/MonitoringService.proto
  clang-tools-extra/clangd/index/remote/Service.proto
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,7 +8,10 @@
 
 #include "Features.inc"
 #include "Index.pb.h"
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
 #include "Service.grpc.pb.h"
+#include "Service.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
@@ -288,11 +291,46 @@
   clangd::SymbolIndex &Index;
 };
 
+class Monitor final : public v1::Monitor::Service {
+public:
+  Monitor(llvm::sys::TimePoint<> IndexAge)
+  : StartTime(std::chrono::system_clock::now()), IndexBuildTime(IndexAge) {}
+
+  void updateIndex(llvm::sys::TimePoint<> UpdateTime) {
+IndexBuildTime.exchange(UpdateTime);
+  }
+
+private:
+  // FIXME(kirillbobyrev): Most fields should be populated when the index
+  // reloads (probably in adjacent metadata.txt file next to loaded .idx) but
+  // they aren't right now.
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const v1::MonitoringInfoRequest *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_uptime_seconds(std::chrono::duration_cast(
+  std::chrono::system_clock::now() - StartTime)
+  .count());
+// FIXME(kirillbobyrev): We are currently making use of the last
+// modification time of the index artifact to deduce its age. This is wrong
+// as it doesn't account for the indexing delay. Propagate some metadata
+// with the index artifacts to indicate time of the commit we indexed.
+Reply->set_index_age_seconds(
+std::chrono::duration_cast(
+std::chrono::system_clock::now() - IndexBuildTime.load())
+.count());
+return grpc::Status::OK;
+  }
+
+  const llvm::sys::TimePoint<> StartTime;
+  std::atomic> IndexBuildTime;
+};
+
 // Detect changes in \p IndexPath file and load new versions of the index
 // whenever they become available.
 void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
llvm::vfs::Status &LastStatus,
-   llvm::IntrusiveRefCntPtr &FS) {
+   llvm::IntrusiveRefCntPtr &FS,
+   Monitor &Monitor) {
   auto Status = FS->status(IndexPath);
   // Requested file is same as loaded index: no reload is needed.
   if (!Status || (Status->getLastModificationTime() ==
@@ -309,12 +347,13 @@
 return;
   }
   Index.reset(std::move(NewIndex));
+  Monitor.updateIndex(Status->getLastModificationTime());
   log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
   Status->getLastModificationTime(), Status->getSize());
 }
 
 void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
-  llvm::StringRef IndexPath) {
+  llvm::StringRef IndexPath, Monitor &Monitor) {
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
@@ -327,6 +366,7 @@
   Builder.AddChannelArgument(GRPC_ARG_MAX_CONNECTION_IDLE_MS,
  IdleTimeoutSeconds * 1000);
   Builder.RegisterService(&Service);
+  Builder.RegisterService(&Monitor);
   std::unique_ptr Server(Builder.BuildAndStart());
   log("Server listening on {0}", ServerAddress);
 
@@ -425,16 +465,18 @@
   }
   clang::clangd::SwapIndex Index(std::move(SymIndex));
 
-  std::thread HotReloadThread([&Index, &Status, &FS]() {
+  Monitor Monitor(Status->getLastModificationTime());
+
+  std::thread HotReloadThread([&Index, &Status, &FS, &Monitor]() {
 llvm::vfs::Status LastStatus = *Status;
 static constexpr auto RefreshFrequency = std::chrono::seconds(30);
 while (!clang::clangd::shutdownRequested()) {
-  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS);
+  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS, Monitor);
   std::this_thread::sleep_for(RefreshFrequency);
 }
   });
 
-  runServerAndWait(Index, ServerAddress, IndexPath);
+  runServerAndWait(Index, ServerAddress, IndexPath, Monitor);
 
   HotReloadThread.join();
 }
Index: clang-tools-extra/clangd/index/remote/Service.proto
==

[PATCH] D98664: Fix crash on dumping AST containing constant initializer with ParenListExpr

2021-03-16 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D98664#2628591 , @aaron.ballman 
wrote:

> As far as the changes go, these seem reasonable to me, though I find it a bit 
> odd that these are expressions without a type whereas a `ParenExpr` has a 
> type of the underlying parenthesized expression. e.g.,
>
>   int x(0); // (0) has void type
>   int y = (0); // (0) has int type
>
> I think my natural assumption is that the init expression would have the type 
> of the thing that's being initialized.

In this case the `int` type will be assigned when the initialization is carried 
out in Sema. The `void` will only remain if we are in a template and the 
variable being initialized has a dependent type, so we can't carry out the 
initialization. Also if there are errors. It's similar to `int y{0};` in that 
regard.

If we don't know the type this syntax could be a constructor call, conversion 
operator call, but also regular value initialization. So we can't use 
`CXXUnresolvedConstructExpr` or something like that. That's my understanding.

> Despite that, I think the changes LG, but I'd like to hear from @rsmith.

So would I, also about whether to use the dependent type instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98664

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


[PATCH] D97361: [clang-tidy] Add readability-redundant-using check

2021-03-16 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.
Herald added a project: clang-tools-extra.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97361

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


[PATCH] D98664: Fix crash on dumping AST containing constant initializer with ParenListExpr

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

In D98664#2628742 , @aaronpuchert 
wrote:

> In D98664#2628591 , @aaron.ballman 
> wrote:
>
>> As far as the changes go, these seem reasonable to me, though I find it a 
>> bit odd that these are expressions without a type whereas a `ParenExpr` has 
>> a type of the underlying parenthesized expression. e.g.,
>>
>>   int x(0); // (0) has void type
>>   int y = (0); // (0) has int type
>>
>> I think my natural assumption is that the init expression would have the 
>> type of the thing that's being initialized.
>
> In this case the `int` type will be assigned when the initialization is 
> carried out in Sema. The `void` will only remain if we are in a template and 
> the variable being initialized has a dependent type, so we can't carry out 
> the initialization. Also if there are errors. It's similar to `int y{0};` in 
> that regard.
>
> If we don't know the type this syntax could be a constructor call, conversion 
> operator call, but also regular value initialization. So we can't use 
> `CXXUnresolvedConstructExpr` or something like that. That's my understanding.

Ah, thank you for the explanation, that makes sense.

>> Despite that, I think the changes LG, but I'd like to hear from @rsmith.
>
> So would I, also about whether to use the dependent type instead.

I'm giving my LG, but you should wait for a few days before landing to see if 
@rsmith has concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98664

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D96771#2628691 , @svenvh wrote:

> In D96771#2626507 , @Anastasia wrote:
>
>> I had a second thought about the extension name and I realized that the 
>> reason why I initially wanted to use `clcpp` is that it aligns better with 
>> `clc++` which is used in `-cl-std`. Even though from the RFC the preference 
>> was towards `cppcl` it felt like there was no objection to `clcpp` either. 
>> So I just want to check one last time whether it would make sense to align 
>> with `clc++` and use `clcpp`. Perhaps, it make clang interface a bit more 
>> inconsistent?
>
> That is a good point, in my opinion aligning with the `-cl-std` flag is a 
> good reason to go for `.clcpp`.  I would recommend mentioning this on the RfC 
> thread too, to ensure that people who suggested a slight preference for the 
> other extension are okay with `.clcpp` too.

+1 for consistency.


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

https://reviews.llvm.org/D96771

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


[PATCH] D98665: Correct Doxygen syntax for inline code

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

LGTM! I wonder if this is something our `-Wdocumentation` should warn about?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98665

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


[PATCH] D98705: [OpenCL] Prefer CodeGenFunction::EmitRuntimeCall

2021-03-16 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm created this revision.
ldrumm added reviewers: Anastasia, bader.
ldrumm added a project: clang.
Herald added a subscriber: yaxunl.
ldrumm requested review of this revision.
Herald added a subscriber: cfe-commits.

CodeGenFunction::EmitRuntimeCall automatically sets the right calling  │
convention for the callee so we can avoid setting it ourselves


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98705

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6265,9 +6265,8 @@
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
   auto *SamplerT = 
getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
   auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  auto *Call = CGF.Builder.CreateCall(
+  auto *Call = CGF.EmitRuntimeCall(
   CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
-  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
   return Call;
 }
 


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6265,9 +6265,8 @@
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
   auto *SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
   auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  auto *Call = CGF.Builder.CreateCall(
+  auto *Call = CGF.EmitRuntimeCall(
   CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
-  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
   return Call;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-16 Thread Zibi Sarbino via Phabricator via cfe-commits
zibi accepted this revision.
zibi added a comment.
This revision is now accepted and ready to land.

LTGM, thx for an extra mile, Abhina.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-16 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330968.
arnamoy10 added a comment.

Adding the test file


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/iso_fortran_env.mod
@@ -0,0 +1,7 @@
+! DUMMY module
+! Added for testing p

[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-16 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330973.
arnamoy10 added a comment.

Moving -std to non-dialect option


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/std2018.f90

Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,35 @@
+! REQUIRES: new-flang-driver
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,6 +45,8 @@
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -std=   Language standard to compile for
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
@@ -91,6 +93,8 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -pedantic  Warn on language extensions
+! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -45,6 +45,8 @@
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -o  Write output to 
+! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -std=   Language standard to compile for
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -368,6 +368,26 @@
 res.frontendOpts().features_.Enable(
 Fortran::common::LanguageFeature::OpenMP);
   }
+
+  //-fpedantic
+  if (args.hasArg(clang::driver::options::OPT_pedantic)) {
+res.set_EnableConformanceChecks();
+  }
+  // -std=f2018.  Current behaviour is same as -fpedantic
+  // TODO: Set proper options when more fortran standards
+  // are supported.
+  if (args.hasArg(clang::driver::options::OPT_std_EQ)) {
+auto standard = args.getLastArgValue(clang::driver::options::OPT_std_EQ);
+// We only allow f2018 as the given standard
+if (standard.equals("f2018")) {
+  res.set_EnableConformanceChecks();
+} else {
+  const unsigned diagID =
+  diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+  "Only -std=f2018 is allowed currently.");
+  diags.Report(diagID);
+}
+  }
   return;
 }
 
@@ -508,6 +528,11 @@
 
   if

[clang-tools-extra] 9a5af54 - [clang-tidy] Remove readability-deleted-default

2021-03-16 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-16T14:03:33Z
New Revision: 9a5af541ee058b85a92113ecf9d38a06ef2b313d

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

LOG: [clang-tidy] Remove readability-deleted-default

The deprecation notice was cherrypicked to the release branch in 
https://github.com/llvm/llvm-project/commit/f8b32989241cca87a8690c8cc404f06ce1f90e4c
 so its safe to remove this for the 13.X release cycle.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp
clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.h
clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
clang-tools-extra/test/clang-tidy/checkers/readability-deleted-default.cpp



diff  --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index ecf37b5b9157..78a3851f66be 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -10,7 +10,6 @@ add_clang_library(clangTidyReadabilityModule
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp
-  DeletedDefaultCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionCognitiveComplexityCheck.cpp
   FunctionSizeCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp
deleted file mode 100644
index ff2f00b94e36..
--- a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-//===--- DeletedDefaultCheck.cpp - 
clang-tidy--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "DeletedDefaultCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace readability {
-
-void DeletedDefaultCheck::registerMatchers(MatchFinder *Finder) {
-  // We match constructors/assignment operators that are:
-  //   - explicitly marked '= default'
-  //   - actually deleted
-  //   - not in template instantiation.
-  // We bind the declaration to "method-decl" and also to "constructor" when
-  // it is a constructor.
-
-  Finder->addMatcher(
-  cxxMethodDecl(anyOf(cxxConstructorDecl().bind("constructor"),
-  isCopyAssignmentOperator(),
-  isMoveAssignmentOperator()),
-isDefaulted(), unless(isImplicit()), isDeleted(),
-unless(isInstantiated()))
-  .bind("method-decl"),
-  this);
-}
-
-void DeletedDefaultCheck::check(const MatchFinder::MatchResult &Result) {
-  const StringRef Message = "%0 is explicitly defaulted but implicitly "
-"deleted, probably because %1; definition can "
-"either be removed or explicitly deleted";
-  if (const auto *Constructor =
-  Result.Nodes.getNodeAs("constructor")) {
-auto Diag = diag(Constructor->getBeginLoc(), Message);
-if (Constructor->isDefaultConstructor()) {
-  Diag << "default constructor"
-   << "a non-static data member or a base class is lacking a default "
-  "constructor";
-} else if (Constructor->isCopyConstructor()) {
-  Diag << "copy constructor"
-   << "a non-static data member or a base class is not copyable";
-} else if (Constructor->isMoveConstructor()) {
-  Diag << "move constructor"
-   << "a non-static data member or a base class is neither copyable "
-  "nor movable";
-}
-  } else if (const auto *Assignment =
- Result.Nodes.getNodeAs("method-decl")) {
-diag(Assignment->getBeginLoc(), Message)
-<< (Assignment->isCopyAssignmentOperator() ? "copy assignment operator"
-   : "move assignment 
operator")
-<< "a base class or a non-static data member is not assignable, e.g. "
-   "because the latter is marked 'const'";
-  }
-}
-
-} // namespace readability
-} // namespace tidy
-} // namespace clan

[PATCH] D98707: [clang][ASTImporter] Fix import of VarDecl regarding thread local storage spec

2021-03-16 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: a.sidorin, shafik, martong, balazske.
Herald added subscribers: teemperor, rnkovacs.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After the import, we did not copy the `TSCSpec`.
This commit resolves that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98707

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -814,6 +814,12 @@
  functionDecl(hasDescendant(usingDecl(;
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+ Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 /// \brief Matches shadow declarations introduced into a scope by a
 ///(resolved) using declaration.
 ///
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4018,6 +4018,7 @@
   D->getStorageClass()))
 return ToVar;
 
+  ToVar->setTSCSpec(D->getTSCSpec());
   ToVar->setQualifierInfo(ToQualifierLoc);
   ToVar->setAccess(D->getAccess());
   ToVar->setLexicalDeclContext(LexicalDC);


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -814,6 +814,12 @@
  functionDecl(hasDescendant(usingDecl(;
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+ Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 /// \brief Matches shadow declarations introduced into a scope by a
 ///(resolved) using declaration.
 ///
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4018,6 +4018,7 @@
   D->getStorageClass()))
 return ToVar;
 
+  ToVar->setTSCSpec(D->getTSCSpec());
   ToVar->setQualifierInfo(ToQualifierLoc);
   ToVar->setAccess(D->getAccess());
   ToVar->setLexicalDeclContext(LexicalDC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97653: [clang-tidy] Fix RenamerClangTidy checks breaking lambda captures.

2021-03-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.
Herald added a project: clang-tools-extra.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97653

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


[PATCH] D98665: Correct Doxygen syntax for inline code

2021-03-16 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D98665#2628851 , @aaron.ballman 
wrote:

> LGTM! I wonder if this is something our `-Wdocumentation` should warn about?

Interestingly we warn about the opposite problem:

  /// @endcode
  int x;

produces "warning: '@endcode' command does not terminate a verbatim text block 
[-Wdocumentation]".

Maybe we're deliberately not doing this because it would be too annoying, not 
sure. Maybe @gribozavr2 knows that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98665

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


[clang] 1cb15b1 - Correct Doxygen syntax for inline code

2021-03-16 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-03-16T15:17:45+01:00
New Revision: 1cb15b10ea370178871769929ff9690f461191fc

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

LOG: Correct Doxygen syntax for inline code

There is no syntax like {@code ...} in Doxygen, @code is a block command
that ends with @endcode, and generally these are not enclosed in braces.
The correct syntax for inline code snippets is @c .

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Analysis/AnyCall.h
clang/include/clang/Analysis/RetainSummaryManager.h
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
llvm/include/llvm/Support/GraphWriter.h

Removed: 




diff  --git a/clang/include/clang/Analysis/AnyCall.h 
b/clang/include/clang/Analysis/AnyCall.h
index 16371eb1da18..846ff7719ce1 100644
--- a/clang/include/clang/Analysis/AnyCall.h
+++ b/clang/include/clang/Analysis/AnyCall.h
@@ -107,8 +107,8 @@ class AnyCall {
 
   }
 
-  /// If {@code E} is a generic call (to ObjC method /function/block/etc),
-  /// return a constructed {@code AnyCall} object. Return None otherwise.
+  /// If @c E is a generic call (to ObjC method /function/block/etc),
+  /// return a constructed @c AnyCall object. Return None otherwise.
   static Optional forExpr(const Expr *E) {
 if (const auto *ME = dyn_cast(E)) {
   return AnyCall(ME);
@@ -127,8 +127,8 @@ class AnyCall {
 }
   }
 
-  /// If {@code D} is a callable (Objective-C method or a function), return
-  /// a constructed {@code AnyCall} object. Return None otherwise.
+  /// If @c D is a callable (Objective-C method or a function), return
+  /// a constructed @c AnyCall object. Return None otherwise.
   // FIXME: block support.
   static Optional forDecl(const Decl *D) {
 if (const auto *FD = dyn_cast(D)) {
@@ -186,7 +186,7 @@ class AnyCall {
   }
 
   /// \returns Function identifier if it is a named declaration,
-  /// {@code nullptr} otherwise.
+  /// @c nullptr otherwise.
   const IdentifierInfo *getIdentifier() const {
 if (const auto *ND = dyn_cast_or_null(D))
   return ND->getIdentifier();

diff  --git a/clang/include/clang/Analysis/RetainSummaryManager.h 
b/clang/include/clang/Analysis/RetainSummaryManager.h
index 6acefb563d8c..b7ccb0317830 100644
--- a/clang/include/clang/Analysis/RetainSummaryManager.h
+++ b/clang/include/clang/Analysis/RetainSummaryManager.h
@@ -613,8 +613,8 @@ class RetainSummaryManager {
 const FunctionType *FT,
 bool &AllowAnnotations);
 
-  /// Apply the annotation of {@code pd} in function {@code FD}
-  /// to the resulting summary stored in out-parameter {@code Template}.
+  /// Apply the annotation of @c pd in function @c FD
+  /// to the resulting summary stored in out-parameter @c Template.
   /// \return whether an annotation was applied.
   bool applyParamAnnotationEffect(const ParmVarDecl *pd, unsigned parm_idx,
   const NamedDecl *FD,
@@ -715,8 +715,8 @@ class RetainSummaryManager {
   /// Set argument types for arguments which are not doing anything.
   void updateSummaryForArgumentTypes(const AnyCall &C, const RetainSummary 
*&RS);
 
-  /// Determine whether a declaration {@code D} of correspondent type (return
-  /// type for functions/methods) {@code QT} has any of the given attributes,
+  /// Determine whether a declaration @c D of correspondent type (return
+  /// type for functions/methods) @c QT has any of the given attributes,
   /// provided they pass necessary validation checks AND tracking the given
   /// attribute is enabled.
   /// Returns the object kind corresponding to the present attribute, or None,

diff  --git a/clang/lib/Analysis/RetainSummaryManager.cpp 
b/clang/lib/Analysis/RetainSummaryManager.cpp
index 00bc854a8804..ecda47a67c1d 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -881,8 +881,8 @@ RetainSummaryManager::getRetEffectFromAnnotations(QualType 
RetTy,
   return None;
 }
 
-/// \return Whether the chain of typedefs starting from {@code QT}
-/// has a typedef with a given name {@code Name}.
+/// \return Whether the chain of typedefs starting from @c QT
+/// has a typedef wit

[PATCH] D98665: Correct Doxygen syntax for inline code

2021-03-16 Thread Aaron Puchert 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 rG1cb15b10ea37: Correct Doxygen syntax for inline code 
(authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98665

Files:
  clang/include/clang/Analysis/AnyCall.h
  clang/include/clang/Analysis/RetainSummaryManager.h
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  llvm/include/llvm/Support/GraphWriter.h

Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -318,8 +318,8 @@
 
 std::string createGraphFilename(const Twine &Name, int &FD);
 
-/// Writes graph into a provided {@code Filename}.
-/// If {@code Filename} is empty, generates a random one.
+/// Writes graph into a provided @c Filename.
+/// If @c Filename is empty, generates a random one.
 /// \return The resulting filename, or an empty string if writing
 /// failed.
 template 
Index: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -157,8 +157,8 @@
 
 } // end of anonymous namespace
 
-/// Print coverage information to output stream {@code o}.
-/// May modify the used list of files {@code Fids} by inserting new ones.
+/// Print coverage information to output stream @c o.
+/// May modify the used list of files @c Fids by inserting new ones.
 static void printCoverage(const PathDiagnostic *D,
   unsigned InputIndentLevel,
   SmallVectorImpl &Fids,
@@ -484,8 +484,8 @@
 // Static function definitions.
 //===--===//
 
-/// Print coverage information to output stream {@code o}.
-/// May modify the used list of files {@code Fids} by inserting new ones.
+/// Print coverage information to output stream @c o.
+/// May modify the used list of files @c Fids by inserting new ones.
 static void printCoverage(const PathDiagnostic *D,
   unsigned InputIndentLevel,
   SmallVectorImpl &Fids,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3139,8 +3139,8 @@
 
   /// \p PreCallback: callback before break.
   /// \p PostCallback: callback after break.
-  /// \p Stop: stop iteration if returns {@code true}
-  /// \return Whether {@code Stop} ever returned {@code true}.
+  /// \p Stop: stop iteration if returns @c true
+  /// \return Whether @c Stop ever returned @c true.
   static bool traverseHiddenNodes(
   const ExplodedNode *N,
   llvm::function_ref PreCallback,
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1846,7 +1846,7 @@
   return nullptr;
 }
 
-/// \return A subexpression of {@code Ex} which represents the
+/// \return A subexpression of @c Ex which represents the
 /// expression-of-interest.
 static const Expr *peelOffOuterExpr(const Expr *Ex,
 const ExplodedNode *N) {
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2738,8 +2738,8 @@
 }
 
 /// Generate notes from all visitors.
-/// Notes associated with {@code ErrorNode} are generated using
-/// {@code getEndPath}, and the rest are generated with {@code VisitNode}.
+/// Notes associated with @c ErrorNode are generated using
+/// @c getEndPath, and the rest are generated with @c VisitNode.
 static std::unique_ptr
 generateVisitorsDiagnostics(PathSensitiveBugReport *R,
 const ExplodedNode *ErrorNode,
@@ -2749,7 +2749,7 @@
   PathSensitiveBugReport::VisitorList visitors;
 
   // Run visitors on all nodes starting from the node *before* the 

[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 330978.
awarzynski added a comment.

Switch back from `-fdebug-dump-symbols-sources` to `-fget-symbols-sources`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98191

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/getsymbols01.f90
  flang/test/Semantics/getsymbols02.f90
  flang/test/Semantics/getsymbols03-a.f90
  flang/test/Semantics/getsymbols04.f90
  flang/test/Semantics/getsymbols05.f90

Index: flang/test/Semantics/getsymbols05.f90
===
--- flang/test/Semantics/getsymbols05.f90
+++ flang/test/Semantics/getsymbols05.f90
@@ -9,7 +9,7 @@
   x = y
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:x:{{.*}}getsymbols05.f90, 3, 14-15
 ! CHECK:x:{{.*}}getsymbols05.f90, 6, 16-17
 ! CHECK:y:{{.*}}getsymbols05.f90, 4, 14-15
Index: flang/test/Semantics/getsymbols04.f90
===
--- flang/test/Semantics/getsymbols04.f90
+++ flang/test/Semantics/getsymbols04.f90
@@ -6,7 +6,7 @@
   x = y
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:x:{{.*}}getsymbols04.f90, 3, 14-15
 ! CHECK:x:{{.*}}getsymbols04.f90, 5, 11-12
 ! CHECK:y:{{.*}}getsymbols04.f90, 4, 14-15
Index: flang/test/Semantics/getsymbols03-a.f90
===
--- flang/test/Semantics/getsymbols03-a.f90
+++ flang/test/Semantics/getsymbols03-a.f90
@@ -7,7 +7,7 @@
  x = f
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:f:{{.*}}getsymbols03-b.f90, 2, 12-13
 ! CHECK:main:{{.*}}getsymbols03-a.f90, 4, 9-13
 ! CHECK:mm3:{{.*}}getsymbols03-a.f90, 5, 6-9
Index: flang/test/Semantics/getsymbols02.f90
===
--- flang/test/Semantics/getsymbols02.f90
+++ flang/test/Semantics/getsymbols02.f90
@@ -7,8 +7,8 @@
 i = callget5()
 ENDPROGRAM
 
-! RUN: %f18 -fsyntax-only %S/Inputs/getsymbols02-a.f90
-! RUN: %f18 -fsyntax-only %S/Inputs/getsymbols02-b.f90
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only %S/Inputs/getsymbols02-a.f90
+! RUN: %flang_fc1 -fsyntax-only %S/Inputs/getsymbols02-b.f90
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK: callget5: .{{[/\\]}}mm2b.mod,
 ! CHECK: get5: .{{[/\\]}}mm2a.mod,
Index: flang/test/Semantics/getsymbols01.f90
===
--- flang/test/Semantics/getsymbols01.f90
+++ flang/test/Semantics/getsymbols01.f90
@@ -15,7 +15,7 @@
  end function
 end module
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK-COUNT-1:f:{{.*}}getsymbols01.f90, 12, 26-27
 ! CHECK-COUNT-1:mm1:{{.*}}getsymbols01.f90, 2, 8-11
 ! CHECK-COUNT-1:s:{{.*}}getsymbols01.f90, 5, 18-19
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -77,6 +77,7 @@
 ! HELP-FC1-NEXT: -ffixed-line-length=
 ! HELP-FC1-NEXT: Use  as character line width in fixed mode
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
+! HELP-FC1-NEXT: -fget-symbols-sources   Dump symbols and their source code locations
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -58,6 +58,9 @@
   case DebugPreFIRTree:
 return std::make_unique();
 break;
+  case GetSymbolsSources:
+return std::make_unique();
+break;
   default:
 break;
 // TODO:
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- fla

[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D98191#2611694 , @tskeith wrote:

> `-fget-symbols-sources` is not a debug option, it's intended for integrating 
> with IDEs like vscode. So I think the original name is better. Unlike the 
> "dump" options it actually is an action and not something that is intended to 
> produce debug output on the way to doing something else.

Makes sense, updated. Would this option be used to extract 
debug/code-navigation info? Is there an equivalent in `clang` or `gfortran`? 
Just curious.

On a separate note, all these debug options 

 are _actions_. We may want to fine-tune it at some point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98191

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


[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not respecting and highlighting fed SourceRanges

2021-03-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:78
+- libToolingCore and Clang-Tidy was refactored and now checks can produce
+  highlights (``^`` under fragments of the source code) in diagnostics.
+  Existing and new checks in the future can be expected to start implementing

Please use sing back-ticks for non-language constructs.


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

https://reviews.llvm.org/D98635

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 330989.
abhina.sreeskantharajan added a comment.

NFC edit: Fix formatting/lint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr =
+MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(
+  Filename, EC,
+  llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // If open fails, no cleanup is needed.
   if (EC)
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -167,8 +167,8 @@
 static std::error_code
 createUniqueEntity(const Twine &Model, int &ResultFD,
SmallVectorImpl &ResultPath, bool MakeAbsolute,
-   unsigned Mode, FSEntity Type,
-   sys::fs::OpenFlags Flag

[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-16 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM, if no one else has comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D98707: [clang][ASTImporter] Fix import of VarDecl regarding thread local storage spec

2021-03-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Looks good, just find a better place for the test.




Comment at: clang/unittests/AST/ASTImporterTest.cpp:817
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier Verifier;

The test can be moved to better place, probably after line 3481 and use 
`ImportVariables`. At least I want it not between two related tests, here 
between `ImportUsingDecl` and `ImportUsingShadowDecl`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98707

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


[PATCH] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD

2021-03-16 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I'm super sorry to be popping in so late on this. Is this really the direction 
we should take?

If we know SystemZ + LLD + LTO is a bad configuration, "fixing" the 
configuration and logging a message seems like the wrong move when the only way 
to get into that state is to specifically request options.

The CMake cache files are morally equivalent to a user specifying the config 
they want, and this patch accepts an invalid configuration and mutates it. Our 
CMake output is so noisy, that a user who actually wants LTO on SystemZ might 
never notice that they aren't getting it.

It seems to me, your intent is to make the stage3 build work for SystemZ, and 
that seems like something we should accomplish entirely inside the stage3 CMake 
caches.


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

https://reviews.llvm.org/D89942

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


[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-16 Thread Nathan Hjelm via Phabricator via cfe-commits
hjelmn added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:168
 
+- Option ``SpaceBeforeForLoopSemiColon`` has been added to control whether
+  spaces will be added before the semi-colons in for loops.

HazardyKnusperkeks wrote:
> No need for change, but in the future I would prefer to add changes to the 
> end of the list. :)
Opps. Should have asked the convention before putting it at the top. I will go 
ahead and move it to be consistent with LLVM practice.



Comment at: clang/unittests/Format/FormatTest.cpp:12712
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+  verifyFormat("for (int i = 0 ; auto a : b) {\n}", Space);
+}

HazardyKnusperkeks wrote:
> Okay that was unexpected for me, I thought the space would only apply to the 
> old `for`s.
> 
> In that case please add `while` and maybe `if` with initializer. What should 
> be discussed is if `for` and the other control statements with initializer 
> should behave differently with regard to their initializer semicolon.
hmm, I think then I could rename this one to: SpaceBeforeCForLoopSemiColon 
which would then only add spaces in for(init;cond;increment)
then maybe SpaceAfterControlStatementInitializer or 
SpaceBeforeControlStatementSemiColon that controls the behavior for control 
statements with initializers.

How does that sound?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98429

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-03-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:54
+   "reverse_iterator",
+   "reverse_const_iterator"});
+

`const_reverse_iterator` seems plausible here for the same reason as 
`const_iterator`.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:56
+
+#ifndef NDEBUG
+

Are you planning to remove the debugging code now that the check is approaching 
its final form?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:363
+/// Returns the diagnostic-friendly name of the node, or empty string.
+static SmallString<64> getName(const NamedDecl *ND) {
+  SmallString<64> Name;

Is this still needed in light of the comments from @riccibruno?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[PATCH] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD

2021-03-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

In D89942#2629146 , @beanz wrote:

> If we know SystemZ + LLD + LTO is a bad configuration, "fixing" the 
> configuration and logging a message seems like the wrong move when the only 
> way to get into that state is to specifically request options.

But that's not true. The `3-stage-base.cmake` sets `BOOTSTRAP_LLVM_ENABLE_LTO` 
to `ON`, which doesn't work on SystemZ. This is the initial problem I had. I 
was not interested in having LTO enabled or not, but the cache enables it and 
that breaks on SystemZ.

> It seems to me, your intent is to make the stage3 build work for SystemZ, and 
> that seems like something we should accomplish entirely inside the stage3 
> CMake caches.

I vaguely remember trying to do all this in the `3-stage-base.cmake` but things 
like `LLVM_NATIVE_ARCH` etc. are not available in there, I am not sure if the 
previous `if(APPLE)` check was working either.


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

https://reviews.llvm.org/D89942

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


[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-03-16 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96418

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


[PATCH] D97297: [clang-tidy] Suppress reports to patternedly named parameters in 'bugprone-easily-swappable-parameters'

2021-03-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:364-365
+StringRef S2) {
+  StringRef S1Prefix = S1.take_front(S1.size() - N),
+S2Prefix = S2.take_front(S2.size() - N);
+  return S1Prefix == S2Prefix && !S1Prefix.empty();

Should we be checking that `.size() - N` doesn't cause wraparound?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:371
+StringRef S2) {
+  StringRef S1Suffix = S1.take_back(S1.size() - N),
+S2Suffix = S2.take_back(S2.size() - N);

Same question here as above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97297

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 331005.
vsavchenko marked 16 inline comments as done.
vsavchenko added a comment.

Rebase and address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -11,120 +11,339 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest-typed-test.h"
 #include "gtest/gtest.h"
 
+using namespace clang;
+using namespace ento;
+
 namespace clang {
 namespace ento {
-namespace {
 
-// TestCase contains to lists of ranges.
-// Original one has to be negated.
-// Expected one has to be compared to negated original range.
-template  struct TestCase {
-  RangeSet original;
-  RangeSet expected;
-
-  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
-   const std::initializer_list &originalList,
-   const std::initializer_list &expectedList)
-  : original(createRangeSetFromList(BVF, F, originalList)),
-expected(createRangeSetFromList(BVF, F, expectedList)) {}
-
-private:
-  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
-  const std::initializer_list rangeList) {
-llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
-llvm::APSInt to = from;
-RangeSet rangeSet = F.getEmptySet();
-for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
-  from = *it;
-  to = *(it + 1);
-  rangeSet = rangeSet.addRange(
-  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
-}
-return rangeSet;
-  }
+template  static std::string toString(const RangeOrSet &Obj) {
+  std::string ObjRepresentation;
+  llvm::raw_string_ostream SS(ObjRepresentation);
+  Obj.dump(SS);
+  return SS.str();
+}
+LLVM_ATTRIBUTE_UNUSED static std::string toString(const llvm::APSInt &Point) {
+  return Point.toString(10);
+}
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
+  const RangeSet &Set) {
+  return OS << toString(Set);
+}
 
-  void printNegate(const TestCase &TestCase) {
-TestCase.original.print(llvm::dbgs());
-llvm::dbgs() << " => ";
-TestCase.expected.print(llvm::dbgs());
-  }
-};
+} // namespace ento
+} // namespace clang
 
-class RangeSetTest : public testing::Test {
-protected:
+namespace {
+
+template  class RangeSetTest : public testing::Test {
+public:
   // Init block
   std::unique_ptr AST = tooling::buildASTFromCode("struct foo;");
-  ASTContext &context = AST->getASTContext();
-  llvm::BumpPtrAllocator alloc;
-  BasicValueFactory BVF{context, alloc};
-  RangeSet::Factory F;
+  ASTContext &Context = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  BasicValueFactory BVF{Context, Arena};
+  RangeSet::Factory F{BVF};
   // End init block
 
-  template  void checkNegate() {
-using type = T;
-
-// Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-// MID is a value in the middle of the range
-// which unary minus does not affect on,
-// e.g. int8/int32(0), uint8(128), uint32(2147483648).
-
-constexpr type MIN = std::numeric_limits::min();
-constexpr type MAX = std::numeric_limits::max();
-constexpr type MID = std::is_signed::value
- ? 0
- : ~(static_cast(-1) / static_cast(2));
-constexpr type A = MID - static_cast(42 + 42);
-constexpr type B = MID - static_cast(42);
-constexpr type C = -B;
-constexpr type D = -A;
-
-static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
-  "Values shall be in an ascending order");
-
-// Left {[x, y], [x, y]} is what shall be negated.
-// Right {[x, y], [x, y]} is what shall be compared to a negation result.
-TestCase cases[] = {
-{BVF, F, {MIN, A}, {MIN, MIN, D, MAX}},
-{BVF, F, {MIN, C}, {MIN, MIN, B, MAX}},
-{BVF, F, {MIN, MID}, {MIN, MIN, MID, MAX}},
-{BVF, F, {MIN, MAX}, {MIN, MAX}},
-{BVF, F, {A, D}, {A, D}},
-{BVF, F, {A, B}, {C, D}},
-{BVF, F, {MIN, A, D, MAX}, {MIN, A, D, MAX}},
-{BVF, F, {MIN, B, MID, D}, {MIN, MIN, A, MID, C, MAX}},
-{BVF, F, {MIN, MID, C, D}, 

[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Oof, it took me quite some time to come back to this.
I don't think that I'll be able to gather more performance-related data than I 
already did, so if it's OK with y'all, we can land it.
@NoQ @steakhal @ASDenysPetrov ?




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:77-78
+  //
+  //   * Range sets are usually very simple, 1 or 2 ranges.
+  // That's why llvm::ImmutableSet is not perfect.
+  //

ASDenysPetrov wrote:
> That's very usefull description for reviewers, but I think is redundant for 
> newcomers, when you're reading this you can't understand why it compares to 
> `ImmutableSet` at all. I think this preamble only relates to the Summary of 
> this patch as the core reason of this change.
> You can just mention the fact that formerly it was an `ImmutableSet`. See 
> //http// for details.
I don't want to fully remove this comment because this is a comment explaining 
implementation detail, which I believe newcomers can skip altogether.
However, I will change it to say that it was formerly an immutable set.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:209
+  private:
+/// Return a persistent version of the given container.
+RangeSet makePersistent(ContainerType &&From);

steakhal wrote:
> 
That's a bit too verbose for the header IMO.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:211
+RangeSet makePersistent(ContainerType &&From);
+/// Construct a new persistent version of the given container.
+ContainerType *construct(ContainerType &&From);

steakhal wrote:
> 
The same as above.  I don't want to mention caches or arenas for the sake of 
hiding those as implementation detail.  One might rightfully argue that having 
these methods here also leaks implementation detail into the header file, but 
without a pImpl, which I believe is not very widespread in the LLVM codebase, 
it's not possible to hide these.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:462-470
   // Negate all other ranges.
-  for (iterator e = end(); i != e; ++i) {
+  for (; It != End; ++It) {
 // Negate int values.
-const llvm::APSInt &newFrom = BV.getValue(-i->To());
-const llvm::APSInt &newTo = BV.getValue(-i->From());
-// Add a negated range.
-newRanges = F.add(newRanges, Range(newFrom, newTo));
-  }
-
-  if (newRanges.isSingleton())
-return newRanges;
+const llvm::APSInt &NewFrom = ValueFactory.getValue(-It->To());
+const llvm::APSInt &NewTo = ValueFactory.getValue(-It->From());
 
+// Add a negated range.

steakhal wrote:
> It might be overkill, but we can do this using transform.
Yeah, I'd say that it is wordier.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:495-507
+void RangeSet::dump(raw_ostream &OS) const {
   bool isFirst = true;
-  os << "{ ";
-  for (iterator i = begin(), e = end(); i != e; ++i) {
+  OS << "{ ";
+  for (const Range &R : *this) {
 if (isFirst)
   isFirst = false;
 else

steakhal wrote:
> Hmm, we could simplify this further, assuming `Range::operator<<` is defined.
I think it looks a bit clearer with `llvm::interleaveComma`



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:105
+  void checkNegate(RawRangeSet RawOriginal, RawRangeSet RawExpected) {
+wrap(&Self::checkNegateImpl, RawOriginal, RawExpected);
+  }

ASDenysPetrov wrote:
> Explain, please, what's the matter to use `wrap` everywhere, not just call 
> `checkNegateImpl` explicitly?
> Won't the call works and looks the same? Like:
> ```
> this->checkNegateImpl({{MIN, A}}, {{MIN, MIN}, {D, MAX}});
> ```
Sure, we want to use a "raw" version of ranges and range sets everywhere in the 
tests for the simplicity of the test.  Here I got bored writing `from(Arg0), 
from(Arg1), ...` and went with this.



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:185
+
+using IntTypes = ::testing::Types;

ASDenysPetrov wrote:
> Thank you for making it in a proper way, instead of a list with different 
> type instantiations.
Oh yes, it would've been a true nightmare repeating every test for every type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD

2021-03-16 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D89942#2629184 , @tbaeder wrote:

> But that's not true. The `3-stage-base.cmake` sets 
> `BOOTSTRAP_LLVM_ENABLE_LTO` to `ON`, which doesn't work on SystemZ. This is 
> the initial problem I had. I was not interested in having LTO enabled or not, 
> but the cache enables it and that breaks on SystemZ.

Right, and my point is that the problem is `3-stage-base` setting that value. 
The caches are effectively user presets for build configurations. If the preset 
is broken, we shouldn't work around that in the build system.

> I vaguely remember trying to do all this in the `3-stage-base.cmake` but 
> things like `LLVM_NATIVE_ARCH` etc. are not available in there, I am not sure 
> if the previous `if(APPLE)` check was working either.

The `APPLE` check definitely works. That value is set by CMake before loading 
cache values, and that should not be removed from the cache file.

You can dump this blurb at the top of the CMake cache to see what variables are 
defined:

  get_cmake_property(_variableNames VARIABLES)  
  
  list (SORT _variableNames)
  
  foreach (_variableName ${_variableNames}) 
  
  message(STATUS "${_variableName}=${${_variableName}}")
  
  endforeach() 

Between the variables CMake sets there and possibly shelling out to uname, is 
there really nothing you can key off?


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

https://reviews.llvm.org/D89942

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-16 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 331008.
vsavchenko added a comment.

Add minor fix in tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -11,120 +11,340 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest-typed-test.h"
 #include "gtest/gtest.h"
 
+using namespace clang;
+using namespace ento;
+
 namespace clang {
 namespace ento {
-namespace {
 
-// TestCase contains to lists of ranges.
-// Original one has to be negated.
-// Expected one has to be compared to negated original range.
-template  struct TestCase {
-  RangeSet original;
-  RangeSet expected;
-
-  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
-   const std::initializer_list &originalList,
-   const std::initializer_list &expectedList)
-  : original(createRangeSetFromList(BVF, F, originalList)),
-expected(createRangeSetFromList(BVF, F, expectedList)) {}
-
-private:
-  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
-  const std::initializer_list rangeList) {
-llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
-llvm::APSInt to = from;
-RangeSet rangeSet = F.getEmptySet();
-for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
-  from = *it;
-  to = *(it + 1);
-  rangeSet = rangeSet.addRange(
-  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
-}
-return rangeSet;
-  }
+template  static std::string toString(const RangeOrSet &Obj) {
+  std::string ObjRepresentation;
+  llvm::raw_string_ostream SS(ObjRepresentation);
+  Obj.dump(SS);
+  return SS.str();
+}
+LLVM_ATTRIBUTE_UNUSED static std::string toString(const llvm::APSInt &Point) {
+  return Point.toString(10);
+}
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
+  const RangeSet &Set) {
+  return OS << toString(Set);
+}
 
-  void printNegate(const TestCase &TestCase) {
-TestCase.original.print(llvm::dbgs());
-llvm::dbgs() << " => ";
-TestCase.expected.print(llvm::dbgs());
-  }
-};
+} // namespace ento
+} // namespace clang
 
-class RangeSetTest : public testing::Test {
-protected:
+namespace {
+
+template  class RangeSetTest : public testing::Test {
+public:
   // Init block
   std::unique_ptr AST = tooling::buildASTFromCode("struct foo;");
-  ASTContext &context = AST->getASTContext();
-  llvm::BumpPtrAllocator alloc;
-  BasicValueFactory BVF{context, alloc};
-  RangeSet::Factory F;
+  ASTContext &Context = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  BasicValueFactory BVF{Context, Arena};
+  RangeSet::Factory F{BVF};
   // End init block
 
-  template  void checkNegate() {
-using type = T;
-
-// Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-// MID is a value in the middle of the range
-// which unary minus does not affect on,
-// e.g. int8/int32(0), uint8(128), uint32(2147483648).
-
-constexpr type MIN = std::numeric_limits::min();
-constexpr type MAX = std::numeric_limits::max();
-constexpr type MID = std::is_signed::value
- ? 0
- : ~(static_cast(-1) / static_cast(2));
-constexpr type A = MID - static_cast(42 + 42);
-constexpr type B = MID - static_cast(42);
-constexpr type C = -B;
-constexpr type D = -A;
-
-static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
-  "Values shall be in an ascending order");
-
-// Left {[x, y], [x, y]} is what shall be negated.
-// Right {[x, y], [x, y]} is what shall be compared to a negation result.
-TestCase cases[] = {
-{BVF, F, {MIN, A}, {MIN, MIN, D, MAX}},
-{BVF, F, {MIN, C}, {MIN, MIN, B, MAX}},
-{BVF, F, {MIN, MID}, {MIN, MIN, MID, MAX}},
-{BVF, F, {MIN, MAX}, {MIN, MAX}},
-{BVF, F, {A, D}, {A, D}},
-{BVF, F, {A, B}, {C, D}},
-{BVF, F, {MIN, A, D, MAX}, {MIN, A, D, MAX}},
-{BVF, F, {MIN, B, MID, D}, {MIN, MIN, A, MID, C, MAX}},
-{BVF, F, {MIN, MID, C, D}, {MIN, MIN, A, B, MID, MAX}},
-{BVF, F, {MIN, MID, 

[PATCH] D98705: [OpenCL] Prefer CodeGenFunction::EmitRuntimeCall

2021-03-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98705

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


[PATCH] D98717: [AMDGPU] Split dot2-insts feature

2021-03-16 Thread Jay Foad via Phabricator via cfe-commits
foad created this revision.
foad added reviewers: rampitec, kzhuravl, b-sumner.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, 
nhaehnle, jvesely, arsenm.
foad requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

Split out some of the instructions predicated on the dot2-insts target
feature into a new dot7-insts, in preparation for subtargets that have
some but not all of these instructions. NFCI.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98717

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
  llvm/lib/Target/AMDGPU/GCNSubtarget.h
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/VOP3PInstructions.td

Index: llvm/lib/Target/AMDGPU/VOP3PInstructions.td
===
--- llvm/lib/Target/AMDGPU/VOP3PInstructions.td
+++ llvm/lib/Target/AMDGPU/VOP3PInstructions.td
@@ -287,19 +287,24 @@
 let IsDOT = 1 in {
 let SubtargetPredicate = HasDot2Insts in {
 
-def V_DOT2_F32_F16 : VOP3PInst<"v_dot2_f32_f16",
-  VOP3_Profile,
-  AMDGPUfdot2, 1/*ExplicitClamp*/>;
 def V_DOT2_I32_I16 : VOP3PInst<"v_dot2_i32_i16",
   VOP3_Profile, int_amdgcn_sdot2, 1>;
 def V_DOT2_U32_U16 : VOP3PInst<"v_dot2_u32_u16",
   VOP3_Profile, int_amdgcn_udot2, 1>;
+
+} // End SubtargetPredicate = HasDot2Insts
+
+let SubtargetPredicate = HasDot7Insts in {
+
+def V_DOT2_F32_F16 : VOP3PInst<"v_dot2_f32_f16",
+  VOP3_Profile,
+  AMDGPUfdot2, 1/*ExplicitClamp*/>;
 def V_DOT4_U32_U8  : VOP3PInst<"v_dot4_u32_u8",
   VOP3_Profile, int_amdgcn_udot4, 1>;
 def V_DOT8_U32_U4  : VOP3PInst<"v_dot8_u32_u4",
   VOP3_Profile, int_amdgcn_udot8, 1>;
 
-} // End SubtargetPredicate = HasDot2Insts
+} // End SubtargetPredicate = HasDot7Insts
 
 let SubtargetPredicate = HasDot1Insts in {
 
@@ -564,13 +569,18 @@
 
 let SubtargetPredicate = HasDot2Insts in {
 
-defm V_DOT2_F32_F16 : VOP3P_Real_vi <0x23>;
 defm V_DOT2_I32_I16 : VOP3P_Real_vi <0x26>;
 defm V_DOT2_U32_U16 : VOP3P_Real_vi <0x27>;
+
+} // End SubtargetPredicate = HasDot2Insts
+
+let SubtargetPredicate = HasDot7Insts in {
+
+defm V_DOT2_F32_F16 : VOP3P_Real_vi <0x23>;
 defm V_DOT4_U32_U8  : VOP3P_Real_vi <0x29>;
 defm V_DOT8_U32_U4  : VOP3P_Real_vi <0x2b>;
 
-} // End SubtargetPredicate = HasDot2Insts
+} // End SubtargetPredicate = HasDot7Insts
 
 let SubtargetPredicate = HasDot1Insts in {
 
@@ -657,13 +667,18 @@
 
 let SubtargetPredicate = HasDot2Insts in {
 
-defm V_DOT2_F32_F16 : VOP3P_Real_gfx10 <0x13>;
 defm V_DOT2_I32_I16 : VOP3P_Real_gfx10 <0x14>;
 defm V_DOT2_U32_U16 : VOP3P_Real_gfx10 <0x15>;
+
+} // End SubtargetPredicate = HasDot2Insts
+
+let SubtargetPredicate = HasDot7Insts in {
+
+defm V_DOT2_F32_F16 : VOP3P_Real_gfx10 <0x13>;
 defm V_DOT4_U32_U8  : VOP3P_Real_gfx10 <0x17>;
 defm V_DOT8_U32_U4  : VOP3P_Real_gfx10 <0x19>;
 
-} // End SubtargetPredicate = HasDot2Insts
+} // End SubtargetPredicate = HasDot7Insts
 
 let SubtargetPredicate = HasDot1Insts in {
 
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -10486,7 +10486,7 @@
   EVT VT = N->getValueType(0);
   SDLoc SL(N);
 
-  if (!Subtarget->hasDot2Insts() || VT != MVT::f32)
+  if (!Subtarget->hasDot7Insts() || VT != MVT::f32)
 return SDValue();
 
   // FMA((F32)S0.x, (F32)S1. x, FMA((F32)S0.y, (F32)S1.y, (F32)z)) ->
Index: llvm/lib/Target/AMDGPU/GCNSubtarget.h
===
--- llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -150,6 +150,7 @@
   bool HasDot4Insts;
   bool HasDot5Insts;
   bool HasDot6Insts;
+  bool HasDot7Insts;
   bool HasMAIInsts;
   bool HasPkFmacF16Inst;
   bool HasAtomicFaddInsts;
@@ -687,6 +688,10 @@
 return HasDot6Insts;
   }
 
+  bool hasDot7Insts() const {
+return HasDot7Insts;
+  }
+
   bool hasMAIInsts() const {
 return HasMAIInsts;
   }
Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -267,6 +267,7 @@
 HasDot4Insts(false),
 HasDot5Insts(false),
 HasDot6Insts(false),
+HasDot7Insts(false),
 HasMAIInsts(false),
 HasPkFmacF16Inst(false),
 HasAtomicFaddInsts(false),
Index: llvm/lib/Target/AMDGPU/AMDGPU.td
===
--- llvm/lib/Target/AMDGPU/AMDGPU.td
+++ llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -480,7 +480,7 @@
 def FeatureDot2Insts : SubtargetFeature<"dot2-insts",
   "HasDot2Insts",
   "true

[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-16 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 331009.
arnamoy10 added a comment.

Updating to use available option from `Options.td` instead of creating a new 
option for `-Werror`


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

https://reviews.llvm.org/D98657

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Semantics/dosemantics03.f90

Index: flang/test/Semantics/dosemantics03.f90
===
--- flang/test/Semantics/dosemantics03.f90
+++ flang/test/Semantics/dosemantics03.f90
@@ -1,4 +1,5 @@
 ! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
+! RUN: %S/test_errors.sh %s %t %flang_fc1 -Werror
 
 ! Issue 458 -- semantic checks for a normal DO loop.  The DO variable
 ! and the initial, final, and step expressions must be INTEGER if the
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -47,6 +47,7 @@
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
+! HELP-NEXT: -WEnable the specified warning
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
@@ -94,6 +95,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---
 ! EXPECTED ERROR
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -47,6 +47,7 @@
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
+! CHECK-NEXT: -WEnable the specified warning
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -327,6 +327,11 @@
   if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
 res.SetDebugModuleDir(true);
   }
+
+  // -Werror option
+  if (args.hasArg(clang::driver::options::OPT_W_Joined)) {
+res.SetWarnAsErr(true);
+  }
 }
 
 /// Parses all Dialect related arguments and populates the variables
@@ -518,5 +523,6 @@
   defaultKinds(), fortranOptions.features, allCookedSources);
 
   semanticsContext_->set_moduleDirectory(moduleDir())
-  .set_searchDirectories(fortranOptions.searchDirectories);
+  .set_searchDirectories(fortranOptions.searchDirectories)
+  .set_warningsAreErrors(warnAsErr());
 }
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -71,6 +71,8 @@
 
   bool debugModuleDir_ = false;
 
+  bool warnAsErr_ = false;
+
   // Fortran Dialect options
   Fortran::common::IntrinsicTypeDefaultKinds defaultKinds_;
 
@@ -96,6 +98,9 @@
   bool &debugModuleDir() { return debugModuleDir_; }
   const bool &debugModuleDir() const { return debugModuleDir_; }
 
+  bool &warnAsErr() { return warnAsErr_; }
+  const bool &warnAsErr() const { return warnAsErr_; }
+
   Fortran::common::IntrinsicTypeDefaultKinds &defaultKinds() {
 return defaultKinds_;
   }
@@ -116,6 +121,8 @@
 
   void SetDebugModuleDir(bool flag) { debugModuleDir_ = flag; }
 
+  void SetWarnAsErr(bool flag) { warnAsErr_ = flag; }
+
   /// Set the Fortran options to predifined defaults. These defaults are
   /// consistend with f18/f18.cpp.
   // TODO: We should map frontendOpts_ to parserOpts_ instead. For that, we
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,7 +42,8 @@
 
 void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
   Args.AddAllArgs(CmdArgs,
-  {options::OPT_module_dir, options::OPT_fdebug_module_writer});
+  {options::OPT_module_dir, options::OPT_fdebug_module_writer,
+   options::OPT_W_Joined});
 }
 
 void Flang::ConstructJob(Compilation &C, const 

[PATCH] D78652: [clang-tidy] Suppress reports to similarly used parameters in 'bugprone-easily-swappable-parameters'

2021-03-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:481
+
+  assert(TargetIdx.hasValue() && "Matched, but didn't find index?");
+  TargetParams[PassedParamOfThisFn].insert(

I *think* you could run into this assert with K&R C function where there is a 
`FunctionDecl` to get back to but the decl claims it has no params because it 
has no prototype (while the call expression actually has the arguments). 
However, there may be other code that protects us from this case.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:532-536
+  if (find(FD->parameters(), ReturnedParam) == FD->param_end())
+// Returning an Expr to a ParmVarDecl that **isn't** parameter of the
+// function should not be possible. Make sure a mistake of the matcher
+// does **not** interfere with the heuristic's result.
+continue;

Is this a FIXME because there's a matcher issue this works around or should it 
be an assertion?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h:43
+  /// If enabled, diagnostics for parameters that are used together in a
+  /// similar way will not be presented.
+  const bool SuppressParametersUsedTogether;





Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst:90
+
+Currently, the following heuristics are implemented, either of which
+will suppress the warning about the parameter pair involved:




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78652

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


[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-16 Thread Tim Keith via Phabricator via cfe-commits
tskeith added a comment.

> Would this option be used to extract debug/code-navigation info?

Yes, it's something related to mapping between symbols and source locations.

> Is there an equivalent in `clang` or `gfortran`?

Not that I know of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98191

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


[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-03-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Some thoughts




Comment at: clang/lib/CodeGen/CGStmt.cpp:796
+  bool EmitBoolCondBranch = !C || !C->isOne();
+  bool CondIsConst = C;
   const SourceRange &R = S.getSourceRange();

I think, if we really want to give this a name, perhaps we want something even 
more specific,
perhaps `CondIsConstImm`/`CondIsConstInt`?



Comment at: clang/lib/CodeGen/CGStmt.cpp:801
+ SourceLocToDebugLoc(R.getEnd()),
+ loopMustProgress(CondIsConst));
 

Now this doesn't make sense. Why must loop progress if it's condition is a 
constant?
I think this should be renamed?



Comment at: clang/lib/CodeGen/CodeGenFunction.h:508-521
 if (CGM.getCodeGenOpts().getFiniteLoops() ==
 CodeGenOptions::FiniteLoopsKind::Never)
   return false;
 
+// C++11 and later guarantees that a thread eventually will do one of the
+// following (6.9.2.3.1 in C++11):
+// - terminate,

What happens for C++11+ when `-fno-finite-loops` is specified?
I.e., shouldn't this be similar to `loopMustProgress()`?



Comment at: clang/lib/CodeGen/CodeGenFunction.h:508-521
 if (CGM.getCodeGenOpts().getFiniteLoops() ==
 CodeGenOptions::FiniteLoopsKind::Never)
   return false;
 
+// C++11 and later guarantees that a thread eventually will do one of the
+// following (6.9.2.3.1 in C++11):
+// - terminate,

lebedev.ri wrote:
> What happens for C++11+ when `-fno-finite-loops` is specified?
> I.e., shouldn't this be similar to `loopMustProgress()`?
I may be unaware, but to me this looks wrong.
`getFiniteLoops()` should know the right answer always, we shouldn't need to do 
checks for standard versions here.



Comment at: clang/test/CodeGen/attr-mustprogress.c:8
 // RUN: %clang_cc1 -std=c11 -fno-finite-loops -triple=x86_64-unknown-linux-gnu 
-S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
 
 int a = 0;

Here and for C++, i would suggest to have bullet-proof RUN line coverage:
* -std=c99/-std=c11/-std=c18/-std=c2x
* -std=c99/-std=c11/-std=c18/-std=c2x + -ffinite-loops
* -std=c99/-std=c11/-std=c18/-std=c2x + -fno-finite-loops

 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96418

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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-03-16 Thread Felix Benning via Phabricator via cfe-commits
FelixBenning added a comment.

If I understood it correctly there is a `BraceWrapping` group where 
`BraceWrappingAfterControlStatementStyle AfterControlStatement` is quite 
similar. It has a `Never`, `MultiLine`, and `Always` options. There is also a 
`bool AfterFunction` option which is currently only a bool. If it were changed 
to an enum it could provide this option as the `MultiLine` option. I do not 
really understand why there is a different option for control statements and 
functions though...


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

https://reviews.llvm.org/D33029

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


[clang] 440f6bd - [OpenCL][NFCI] Prefer CodeGenFunction::EmitRuntimeCall

2021-03-16 Thread Luke Drummond via cfe-commits

Author: Luke Drummond
Date: 2021-03-16T16:22:19Z
New Revision: 440f6bdf34f4ce3ac3435d650f5296dcc0102488

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

LOG: [OpenCL][NFCI] Prefer CodeGenFunction::EmitRuntimeCall

`CodeGenFunction::EmitRuntimeCall` automatically sets the right calling
convention for the callee so we can avoid setting it ourselves.

As requested in https://reviews.llvm.org/D98411

Reviewed by: anastasia
Differential Revision: https://reviews.llvm.org/D98705

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 75854f69b110..f3a73f8783dc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6265,9 +6265,8 @@ CodeGenModule::createOpenCLIntToSamplerConversion(const 
Expr *E,
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
   auto *SamplerT = 
getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
   auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  auto *Call = CGF.Builder.CreateCall(
+  auto *Call = CGF.EmitRuntimeCall(
   CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
-  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
   return Call;
 }
 



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


[PATCH] D98705: [OpenCL] Prefer CodeGenFunction::EmitRuntimeCall

2021-03-16 Thread Luke Drummond 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 rG440f6bdf34f4: [OpenCL][NFCI] Prefer 
CodeGenFunction::EmitRuntimeCall (authored by ldrumm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98705

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6265,9 +6265,8 @@
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
   auto *SamplerT = 
getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
   auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  auto *Call = CGF.Builder.CreateCall(
+  auto *Call = CGF.EmitRuntimeCall(
   CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
-  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
   return Call;
 }
 


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6265,9 +6265,8 @@
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
   auto *SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
   auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  auto *Call = CGF.Builder.CreateCall(
+  auto *Call = CGF.EmitRuntimeCall(
   CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
-  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
   return Call;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98110: [NFC][clangd] Use table to collect option aliases

2021-03-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.
Herald added a project: clang-tools-extra.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98110

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


[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type

2021-03-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97831

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


[PATCH] D95736: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const &` diagnostics

2021-03-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:707-708
+  // FIXME: Don't emit multiple combinations here either.
+  StringRef DiagText = "a call site binds an expression to '%0' and "
+   "'%1' with the same force";
+  diag(M.Second->getOuterLocStart(), DiagText, DiagnosticIDs::Note)

I think "with the same force" is going to be hard for users to make sense of. 
I'm at a bit of a loss for how to word it though. The issue is that `T` and 
`const T&` parameters *might* be easily swapped, so maybe it's best to call it 
out that way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95736

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


  1   2   3   >