[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-01 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 275005.
jfb added a comment.

Add memmove and memset (but still missing the codegen tests)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
  clang/test/SemaOpenCL/to_addr_builtin.cl

Index: clang/test/SemaOpenCL/to_addr_builtin.cl
===
--- clang/test/SemaOpenCL/to_addr_builtin.cl
+++ clang/test/SemaOpenCL/to_addr_builtin.cl
@@ -15,7 +15,7 @@
   // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
   // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
-  // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
+  // expected-error@-5{{too many arguments to function call, expected 1, have 2}}
 #endif
 
   int x;
Index: clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -10,7 +10,7 @@
   read_pipe(p, );
   read_pipe(p, ptr);
   read_pipe(tmp, p);// expected-error {{first argument to 'read_pipe' must be a pipe type}}
-  read_pipe(p);   // expected-error {{invalid number of arguments to function: 'read_pipe'}}
+  read_pipe(p); // expected-error {{too few arguments to function call, expected 2 or 4, have 1}}
   read_pipe(p, rid, tmp, ptr);
   read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t' having '__private int')}}
   read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int' having '__private reserve_id_t')}}
@@ -39,7 +39,7 @@
   write_pipe(p, );
   write_pipe(p, ptr);
   write_pipe(tmp, p);// expected-error {{first argument to 'write_pipe' must be a pipe type}}
-  write_pipe(p);   // expected-error {{invalid number of arguments to function: 'write_pipe'}}
+  write_pipe(p); // expected-error {{too few arguments to function call, expected 2 or 4, have 1}}
   write_pipe(p, rid, tmp, ptr);
   write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t' having '__private int')}}
   write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int' having '__private reserve_id_t')}}
Index: clang/test/Sema/builtin-overloaded-memfns.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-overloaded-memfns.cpp
@@ -0,0 +1,158 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=1
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=0
+
+// Test memcpy and memmove with the same code, since they're basically the same constraints.
+#if CPY
+#define MEM(...) __builtin_overloaded_memcpy(__VA_ARGS__)
+#else
+#define MEM(...) __builtin_overloaded_memmove(__VA_ARGS__)
+#endif
+
+#define NULL (void *)0
+#define nullptr __nullptr
+using size_t = __SIZE_TYPE__;
+struct Intish {
+  int i;
+};
+struct TrivialCpy {
+  char buf[8];
+  TrivialCpy();
+  TrivialCpy(const TrivialCpy &) = default;
+};
+struct NotTrivialCpy {
+  char buf[8];
+  NotTrivialCpy();
+  NotTrivialCpy(const NotTrivialCpy &);
+};
+
+void arg_count() {
+  MEM();   // expected-error {{too few arguments to function call, expected 3, have 0}}
+  MEM(0);  // expected-error {{too few arguments to function call, expected 3, have 1}}
+  MEM(0, 0);   // expected-error {{too few arguments to function call, expected 3, have 2}}
+  MEM(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+  __builtin_overloaded_memset();   // expected-error {{too few arguments to function call, expected 3, have 0}}
+  __builtin_overloaded_memset(0);  // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __builtin_overloaded_memset(0, 0);   // expected-error {{too few arguments to function call, expected 3, have 2}}
+  __builtin_overloaded_memset(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+}
+
+void null(char *dst, 

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2416
 
-  // Double and long long should be naturally aligned if possible.
+  // Double, long double (only when the target supports AIX power alignment) 
and
+  // long long should be naturally aligned if possible.

I suggest to clarify the binding of the parenthetical and also to make the 
context that the required alignment is lower than the natural alignment more 
explicit:
```
  // Double (and, for targets supporting AIX `power` alignment, long double) and
  // long long should be naturally aligned (despite requiring less alignment) if
  // possible.
```



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1210
 
+  auto getBaseOrPreferredAlign = [&](CharUnits UnpackedAlign) {
+return (Packed && ((Context.getLangOpts().getClangABICompat() <=

The lambda is currently being named for what is produced based on the identity 
of what gets passed to it and not named for what it does.

This should be named `getPackedBaseAlignFromUnpacked` or similar.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1212
+return (Packed && ((Context.getLangOpts().getClangABICompat() <=
+LangOptions::ClangABI::Ver6) ||
+   Context.getTargetInfo().getTriple().isPS4()))

I suggest not applying "ABI compat" with Clang <= 6 on AIX. There was is no 
Clang <= 6 with AIX support.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1218
+
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
   // Per GCC's documentation, it only applies to non-static data members.

This comment belongs inside the lambda.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1235
 
+  // Do not use AIX special alignment if current base is not the first member 
or
+  // the struct is not a union.

Suggestion:
```
  // AIX `power` alignment does not apply the preferred alignment for non-union
  // classes if the source of the alignment (the current base in this context)
  // follows introduction of the first member with allocated space.
```



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1769
+
+  bool FoundNonOverlappingEmptyField = false;
+  bool SupportsAIXPowerAlignment =

The name is wrong for the value (the value corresponding to this name is 
`!IsOverlappingEmptyField`). I would suggest something like 
`FoundNonOverlappingEmptyFieldToHandle`.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1772
+  Context.getTargetInfo().defaultsToAIXPowerAlignment();
+  if (SupportsAIXPowerAlignment && !HandledFirstNonOverlappingEmptyField &&
+  !IsOverlappingEmptyField)

Move the definition of the variable here and just use the `if` condition as the 
initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-07-01 Thread Johel Ernesto Guerrero Peña via Phabricator via cfe-commits
JohelEGP added a comment.

Using parameter packs within non-parenthesized requires-clauses results in 
weird formatting:

  template 
  requires std::invocable < F, std::invoke_result_t
  ... > struct constant;

vs

  template 
  requires(std::invocable...>)
  struct constant;


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

https://reviews.llvm.org/D79773



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


[PATCH] D83009: [clang][Serialization] Don't duplicate the body of LambdaExpr during deserialization

2020-07-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I cherry picked this change and retried the case that was failing. This change 
addresses the issue I was seeing. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83009



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


[PATCH] D82440: [Power10] Implement Vector Shift Double Bit Immediate Builtins in LLVM/Clang

2020-07-01 Thread Lei Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88874f074644: [PowerPC]Implement Vector Shift Double Bit 
Immediate Builtins (authored by biplmish, committed by lei).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82440

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -mcpu=pwr10 \
+; RUN:   -ppc-vsr-nums-as-vr -mtriple=powerpc64le-unknown-unknown < %s | FileCheck %s
+
+; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -mcpu=pwr10 \
+; RUN:   -ppc-vsr-nums-as-vr -mtriple=powerpc64-unknown-unknown < %s | FileCheck %s
+
+define <16 x i8> @testVSLDBI(<16 x i8> %a, <16 x i8> %b) {
+; CHECK-LABEL: testVSLDBI:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsldbi v2, v2, v3, 1
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vsldbi(<16 x i8> %a, <16 x i8> %b, i32 1)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.altivec.vsldbi(<16 x i8>, <16 x i8>, i32 immarg)
+
+define <16 x i8> @testVSRDBI(<16 x i8> %a, <16 x i8> %b) {
+; CHECK-LABEL: testVSRDBI:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsrdbi v2, v2, v3, 1
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vsrdbi(<16 x i8> %a, <16 x i8> %b, i32 1)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.altivec.vsrdbi(<16 x i8>, <16 x i8>, i32 immarg)
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -738,11 +738,19 @@
   def VSLDBI : VNForm_VTAB5_SD3<22, 0, (outs vrrc:$VRT),
 (ins vrrc:$VRA, vrrc:$VRB, u3imm:$SH),
 "vsldbi $VRT, $VRA, $VRB, $SH",
-IIC_VecGeneral, []>;
+IIC_VecGeneral, 
+[(set v16i8:$VRT,
+  (int_ppc_altivec_vsldbi v16i8:$VRA,
+  v16i8:$VRB,
+  i32:$SH))]>;
   def VSRDBI : VNForm_VTAB5_SD3<22, 1, (outs vrrc:$VRT),
 (ins vrrc:$VRA, vrrc:$VRB, u3imm:$SH),
 "vsrdbi $VRT, $VRA, $VRB, $SH",
-IIC_VecGeneral, []>;
+IIC_VecGeneral,
+[(set v16i8:$VRT,
+  (int_ppc_altivec_vsrdbi v16i8:$VRA,
+  v16i8:$VRB, 
+  i32:$SH))]>;
def VPDEPD : VXForm_1<1485, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  "vpdepd $vD, $vA, $vB", IIC_VecGeneral,
  [(set v2i64:$vD,
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -454,6 +454,16 @@
def int_ppc_altivec_vclrrb :  GCCBuiltin<"__builtin_altivec_vclrrb">,
Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty],
  [IntrNoMem]>;
+
+  // P10 Vector Shift Double Bit Immediate.
+  def int_ppc_altivec_vsldbi : GCCBuiltin<"__builtin_altivec_vsldbi">,
+  Intrinsic<[llvm_v16i8_ty],
+[llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty],
+[IntrNoMem, ImmArg>]>;
+  def int_ppc_altivec_vsrdbi : GCCBuiltin<"__builtin_altivec_vsrdbi">,
+  Intrinsic<[llvm_v16i8_ty],
+[llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty],
+[IntrNoMem, ImmArg>]>;
 }
 
 // Vector average.
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -5,10 +5,13 @@
 
 #include 
 
-vector signed char vsca;
+vector signed char vsca, vscb;
 vector unsigned char vuca, vucb, vucc;
+vector signed short vssa, 

[clang] 88874f0 - [PowerPC]Implement Vector Shift Double Bit Immediate Builtins

2020-07-01 Thread Lei Huang via cfe-commits

Author: Biplob Mishra
Date: 2020-07-01T20:34:53-05:00
New Revision: 88874f07464467f3852dd662d180f7738756649b

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

LOG: [PowerPC]Implement Vector Shift Double Bit Immediate Builtins

Implement Vector Shift Double Bit Immediate Builtins in LLVM/Clang.
  * vec_sldb ();
  * vec_srdb ();

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

Added: 
llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index fa5b0b9d0920..2a5ae08ea7b2 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -316,6 +316,10 @@ BUILTIN(__builtin_altivec_vclrrb, "V16cV16cUi", "")
 BUILTIN(__builtin_altivec_vclzdm, "V2ULLiV2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_vctzdm, "V2ULLiV2ULLiV2ULLi", "")
 
+// P10 Vector Shift built-ins.
+BUILTIN(__builtin_altivec_vsldbi, "V16UcV16UcV16UcIi", "")
+BUILTIN(__builtin_altivec_vsrdbi, "V16UcV16UcV16UcIi", "")
+
 // VSX built-ins.
 
 BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 91279119630d..85f712f18ef3 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16881,6 +16881,14 @@ vec_cnttzm(vector unsigned long long __a, vector 
unsigned long long __b) {
   return __builtin_altivec_vctzdm(__a, __b);
 }
 
+/* vec_sldbi */
+
+#define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))
+
+/* vec_srdbi */
+
+#define vec_srdb(__a, __b, __c) __builtin_altivec_vsrdbi(__a, __b, (__c & 0x7))
+
 #endif /* __POWER10_VECTOR__ */
 
 #undef __ATTRS_o_ai

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index b4554c9fd55a..a8d25bd7e240 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3128,6 +3128,10 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo 
, unsigned BuiltinID,
  return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7);
   case PPC::BI__builtin_vsx_xxeval:
  return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255);
+  case PPC::BI__builtin_altivec_vsldbi:
+ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
+  case PPC::BI__builtin_altivec_vsrdbi:
+ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
   }
   return SemaBuiltinConstantArgRange(TheCall, i, l, u);
 }

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index f7930667af79..efb63ce808cb 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -5,10 +5,13 @@
 
 #include 
 
-vector signed char vsca;
+vector signed char vsca, vscb;
 vector unsigned char vuca, vucb, vucc;
+vector signed short vssa, vssb;
 vector unsigned short vusa, vusb, vusc;
+vector signed int vsia, vsib;
 vector unsigned int vuia, vuib, vuic;
+vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
 vector unsigned __int128 vui128a, vui128b, vui128c;
 unsigned int uia;
@@ -146,3 +149,111 @@ vector unsigned long long test_vctzdm(void) {
   // CHECK-NEXT: ret <2 x i64>
   return vec_cnttzm(vulla, vullb);
 }
+
+vector signed char test_vec_sldb_sc(void) {
+  // CHECK: @llvm.ppc.altivec.vsldbi(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32 0
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_sldb(vsca, vscb, 0);
+  }
+
+vector unsigned char test_vec_sldb_uc(void) {
+  // CHECK: @llvm.ppc.altivec.vsldbi(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32 
1
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_sldb(vuca, vucb, 1);
+}
+
+vector signed short test_vec_sldb_ss(void) {
+  // CHECK: @llvm.ppc.altivec.vsldbi(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32 
2
+  // CHECK-NEXT: bitcast <16 x i8> %{{.*}} to <8 x i16>
+  // CHECK-NEXT: ret <8 x i16>
+  return vec_sldb(vssa, vssb, 2);
+}
+
+vector unsigned short test_vec_sldb_us(void) {
+  // CHECK: @llvm.ppc.altivec.vsldbi(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32 
3
+  // CHECK-NEXT: bitcast <16 x i8> %{{.*}} to <8 x i16>
+  // CHECK-NEXT: ret <8 x i16>
+  return vec_sldb(vusa, vusb, 3);
+}
+
+vector signed int test_vec_sldb_si(void) {
+  // CHECK: @llvm.ppc.altivec.vsldbi(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32 
4
+  // CHECK-NEXT: bitcast <16 x i8> %{{.*}} to <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_sldb(vsia, vsib, 4);
+}
+
+vector unsigned int test_vec_sldb_ui(void) {
+  // CHECK: 

[PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-01 Thread Keith Smiley via Phabricator via cfe-commits
keith accepted this revision.
keith added a comment.

Awesome!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015



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


[PATCH] D82906: [flang][openmp] Use common Directive and Clause enum from llvm/Frontend

2020-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D82906#2127047 , @clementval wrote:

> Fix for warning


I find clang better at -Wswitch related warnings than GCC. Might be nice 
building llvm-project with clang and testing with `check-clang`.
If you don't mind `curl | sh`, `curl -s 
https://raw.githubusercontent.com/chromium/chromium/master/tools/clang/scripts/update.py
 | python - --output-dir=path/to/bin` gives you a stable and newer 
clang+lld+other utilities.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82906



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


[PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-01 Thread whitequark via Phabricator via cfe-commits
whitequark added a comment.

Thank you for making this change. IIRC I introduced `-fuse-ld=` out of 
frustration with the inability to change the linker path in any way other than 
with a shell script on `PATH`. It was not a good design.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015



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


[PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I got pinged for my GCC -fuse-ld=path patch today. On GCC side, Martin Liška is 
fine with clang's choice if we can reach a reasonable consensus: 
https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549236.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015



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


[PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: echristo, jyknight, martell, theraven, whitequark.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Supersedes D80225 . Add -fld-path= to avoid 
strange target specific
prefixes and make -fuse-ld= focus on its intended job: "linker flavor".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83015

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/fld-path.c
  clang/test/Driver/fuse-ld.c

Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -2,6 +2,7 @@
 // RUN: -fuse-ld=/usr/local/bin/or1k-linux-ld 2>&1 \
 // RUN: -target x86_64-unknown-linux \
 // RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
+// CHECK-ABSOLUTE-LD: warning: '-fuse-ld=' taking a path is deprecated. Use '-fld-path=' instead
 // CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
 
 
Index: clang/test/Driver/fld-path.c
===
--- /dev/null
+++ clang/test/Driver/fld-path.c
@@ -0,0 +1,39 @@
+/// This tests uses the PATH environment variable.
+// UNSUPPORTED: system-windows
+
+/// If -fld-path specifies a word (without /), PATH is consulted to locate the linker.
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### -fld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// BFD: Inputs/basic_freebsd_tree/usr/bin/ld.bfd
+
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### -fld-path=ld.gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=GOLD
+
+// GOLD: Inputs/basic_freebsd_tree/usr/bin/ld.gold
+
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### -fld-path=not_exist \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NOT_EXIST
+
+// NOT_EXIST: error: invalid linker name in argument '-fld-path=not_exist'
+
+/// -fld-path's argument is searched in PATH. --sysroot and -B have no effect.
+// RUN: env PATH= %clang %s -### -fld-path=ld.bfd -B %S/Inputs/basic_freebsd_tree/usr/bin \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NOT_EXIST2
+
+// NOT_EXIST2: error: invalid linker name in argument '-fld-path=ld.bfd'
+
+/// -fld-path can specify a path
+// RUN: %clang %s -### -fld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+/// -fld-path= and -fuse-ld= can be used together. -fld-path= takes precedence.
+/// -fuse-ld= can be used to specify the linker flavor.
+// RUN: %clang %s -### -Werror -fld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd -fuse-ld=gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD --implicit-check-not=error:
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -547,18 +547,39 @@
 }
 
 std::string ToolChain::GetLinkerPath() const {
+  // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is
+  // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
   StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
 
+  // -fld-path= takes precedence over -fuse-ld= and specifies the executable
+  // name. PATH is consulted if the value does not contain /. -B is
+  // intentionally ignored.
+  if (const Arg *A = Args.getLastArg(options::OPT_fld_path_EQ)) {
+ErrorOr Path = llvm::sys::findProgramByName(A->getValue());
+if (Path)
+  return *Path;
+getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
+return GetProgramPath(getDefaultLinker());
+  }
+  if (UseLinker.empty() || UseLinker == "ld") {
+// If we're passed -fuse-ld= with no argument, or with the argument ld,
+// then use whatever the default system linker is.
+return GetProgramPath(getDefaultLinker());
+  }
+
+  // Extending -fuse-ld= to an absolute or relative path is unexpected. Checking
+  // for the linker flavor is brittle. In addition, prepending "ld." or "ld64."
+  // to a relative path is surprising. This is more complex due to priorities
+  // among -B, COMPILER_PATH and PATH. -fld-path= should be used instead.
+  if (UseLinker.find('/') != StringRef::npos)
+

[PATCH] D82930: [HIP] Fix rocm detection

2020-07-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(BinPath + "/.hipVersion");
+if (!VersionFile)

arsenm wrote:
> yaxunl wrote:
> > arsenm wrote:
> > > I don't think the detection should fail if this is missing
> > why? this file is unique to HIP installation. If it is missing, the 
> > installation is broken.
> Because I should be able to use this without a complete hip installation. 
> Without a specified version, it should assume the most modern layout. This 
> will for example break pointing --rocm-path at the device library build 
> directory for library tests
I also don't see what value checking the version really provides; it may be 
informative to print it, but I don't think it's useful to derive information 
from it


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

https://reviews.llvm.org/D82930



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


[PATCH] D82930: [HIP] Fix rocm detection

2020-07-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(BinPath + "/.hipVersion");
+if (!VersionFile)

yaxunl wrote:
> arsenm wrote:
> > I don't think the detection should fail if this is missing
> why? this file is unique to HIP installation. If it is missing, the 
> installation is broken.
Because I should be able to use this without a complete hip installation. 
Without a specified version, it should assume the most modern layout. This will 
for example break pointing --rocm-path at the device library build directory 
for library tests


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

https://reviews.llvm.org/D82930



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


[PATCH] D83006: [ASTImporter] Add unittest case for friend decl import

2020-07-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 274961.
vabridgers added a comment.

update for pre-merge lint checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83006

Files:
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3416,6 +3416,26 @@
   EXPECT_TRUE(ToCtor->hasBody());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateFriendDecl) {
+  const auto *Code =
+  R"(
+  template  class X {  friend T; };
+  struct Y {};
+  template class X;
+)";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec = FirstDeclMatcher().match(
+  ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter().match(
+ToTU, classTemplateSpecializationDecl()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3416,6 +3416,26 @@
   EXPECT_TRUE(ToCtor->hasBody());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateFriendDecl) {
+  const auto *Code =
+  R"(
+  template  class X {  friend T; };
+  struct Y {};
+  template class X;
+)";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec = FirstDeclMatcher().match(
+  ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter().match(
+ToTU, classTemplateSpecializationDecl()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83006: [ASTImporter] Add unittest case for friend decl import

2020-07-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I confirmed that a crash was seen when the change for 
https://reviews.llvm.org/D82882 was reverted, then the unittests pass with the 
change associated with https://reviews.llvm.org/D82882.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83006



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


[PATCH] D82992: clang CoverageMapping tests bot cleanup

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82992#2126898 , @MaskRay wrote:

> Hi, your git commit contains extra Phabricator tags. You can drop 
> `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git 
> commit with the following script:
>
>   arcfilter () {
>   arc amend
>   git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
> /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ 
> {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
>   }
>   
>
> `Reviewed By: ` is considered important by some people. Please keep the tag. 
> (`--date=now` is my personal preference (author dates are usually not useful. 
> Using committer dates can make log almost monotonic in time))
>
> `llvm/utils/git/pre-push.py` can validate the message does not include 
> unneeded tags.


Ah good to know. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82992



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


[PATCH] D82992: clang CoverageMapping tests bot cleanup

2020-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` 
`Subscribers:` `Tags:` and the text `Summary:` from the git commit with the 
following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. 
(`--date=now` is my personal preference (author dates are usually not useful. 
Using committer dates can make log almost monotonic in time))

`llvm/utils/git/pre-push.py` can validate the message does not include unneeded 
tags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82992



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


[clang] ac8d059 - typo fixes to cycle bots

2020-07-01 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-07-01T19:20:05-04:00
New Revision: ac8d059c8e80fc84d16ad79d08e25010ffa114c2

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

LOG: typo fixes to cycle bots

Added: 


Modified: 
clang/docs/MatrixTypes.rst

Removed: 




diff  --git a/clang/docs/MatrixTypes.rst b/clang/docs/MatrixTypes.rst
index 54099e5aae93..5d022af44121 100644
--- a/clang/docs/MatrixTypes.rst
+++ b/clang/docs/MatrixTypes.rst
@@ -245,8 +245,8 @@ and if omitted ``row`` is used as ``columnStride``.
 **Preconditions**: ``columnStride`` is greater than or equal to the number of 
rows in ``M``.
 
 **Remarks**: The type ``T`` is the const-unqualified version of the matrix
-argument’s element type. The paramter ``columnStride`` is optional and if
-ommitted, the number of rows of ``M`` is used as ``columnStride``.
+argument’s element type. The parameter ``columnStride`` is optional and if
+omitted, the number of rows of ``M`` is used as ``columnStride``.
 
 **Effects**: Equivalent to:
 



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


[PATCH] D82992: clang CoverageMapping tests bot cleanup

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9fc877213e07: clang CoverageMapping tests bot cleanup 
(authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82992

Files:
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,3 +1,5 @@
+// fixme: the following line is added to cleanup bots, will be removed in 
weeks.
+// RUN: rm -f %S/coroutine.ll
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s -o - | FileCheck %s
 
 namespace std::experimental {


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,3 +1,5 @@
+// fixme: the following line is added to cleanup bots, will be removed in weeks.
+// RUN: rm -f %S/coroutine.ll
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
 
 namespace std::experimental {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-01 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik marked an inline comment as done.
shafik added a subscriber: rsmith.
shafik added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1190
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)

@rsmith you were correct, this was indeed reversed.


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

https://reviews.llvm.org/D83008



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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-01 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 274948.
jfb added a comment.

This builtin doesn't return anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/include/clang/Basic/Builtins.def


Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -486,7 +486,7 @@
 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memcpy_inline, "vv*vC*Iz", "nt")
-BUILTIN(__builtin_overloaded_memcpy, "v*v*vC*z", "nt")
+BUILTIN(__builtin_overloaded_memcpy, "vv*vC*z", "nt")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memset, "v*v*iz", "nF")


Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -486,7 +486,7 @@
 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memcpy_inline, "vv*vC*Iz", "nt")
-BUILTIN(__builtin_overloaded_memcpy, "v*v*vC*z", "nt")
+BUILTIN(__builtin_overloaded_memcpy, "vv*vC*z", "nt")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memset, "v*v*iz", "nF")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-01 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 274949.
jfb added a comment.

Arcanist ate the rest of my commit and I am confused.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
  clang/test/SemaOpenCL/to_addr_builtin.cl

Index: clang/test/SemaOpenCL/to_addr_builtin.cl
===
--- clang/test/SemaOpenCL/to_addr_builtin.cl
+++ clang/test/SemaOpenCL/to_addr_builtin.cl
@@ -15,7 +15,7 @@
   // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
   // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
-  // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
+  // expected-error@-5{{too many arguments to function call, expected 1, have 2}}
 #endif
 
   int x;
Index: clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -10,7 +10,7 @@
   read_pipe(p, );
   read_pipe(p, ptr);
   read_pipe(tmp, p);// expected-error {{first argument to 'read_pipe' must be a pipe type}}
-  read_pipe(p);   // expected-error {{invalid number of arguments to function: 'read_pipe'}}
+  read_pipe(p); // expected-error {{too few arguments to function call, expected 2 or 4, have 1}}
   read_pipe(p, rid, tmp, ptr);
   read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t' having '__private int')}}
   read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int' having '__private reserve_id_t')}}
@@ -39,7 +39,7 @@
   write_pipe(p, );
   write_pipe(p, ptr);
   write_pipe(tmp, p);// expected-error {{first argument to 'write_pipe' must be a pipe type}}
-  write_pipe(p);   // expected-error {{invalid number of arguments to function: 'write_pipe'}}
+  write_pipe(p); // expected-error {{too few arguments to function call, expected 2 or 4, have 1}}
   write_pipe(p, rid, tmp, ptr);
   write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t' having '__private int')}}
   write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int' having '__private reserve_id_t')}}
Index: clang/test/Sema/builtin-overloaded-memfns.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-overloaded-memfns.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions
+
+#define NULL (void *)0
+#define nullptr __nullptr
+using size_t = __SIZE_TYPE__;
+struct Intish {
+  int i;
+};
+struct TrivialCpy {
+  char buf[8];
+  TrivialCpy();
+  TrivialCpy(const TrivialCpy &) = default;
+};
+struct NotTrivialCpy {
+  char buf[8];
+  NotTrivialCpy();
+  NotTrivialCpy(const NotTrivialCpy &);
+};
+
+void memcpy_arg_count() {
+  __builtin_overloaded_memcpy();   // expected-error {{too few arguments to function call, expected 3, have 0}}
+  __builtin_overloaded_memcpy(0);  // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __builtin_overloaded_memcpy(0, 0);   // expected-error {{too few arguments to function call, expected 3, have 2}}
+  __builtin_overloaded_memcpy(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+}
+
+void memcpy_null(char *dst, const char *src, size_t size) {
+  __builtin_overloaded_memcpy(0, 0, 0);
+  __builtin_overloaded_memcpy(0, 0, size);
+  __builtin_overloaded_memcpy(dst, 0, 42);   // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(dst, 0, 42);   // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(dst, NULL, 42);// expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(dst, nullptr, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(0, src, 42);   // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(NULL, src, 42);// expected-warning {{null passed to a 

[PATCH] D83009: [clang][Serialization] Don't duplicate the body of LambdaExpr during deserialization

2020-07-01 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: vabridgers, martong, aaron.ballman.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, rnkovacs.

05843dc6ab97a00cbde7aa4f08bf3692eb83109d 
 changed 
the serialization of the body
of `LambdaExpr` to avoid a mutation in `LambdaExpr::getBody` and to avoid a 
missing
body in `LambdaExpr::children`.

Unfortunately this replaced one bug by another: we are now duplicating the body 
during
deserialization; that is after deserialization the identity:

`E->getBody() == E->getCallOperator()->getBody()` does not hold.

Fix that by instead lazily loading the body from the call operator when needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83009

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-lambda-body-not-duplicated.cpp

Index: clang/test/AST/ast-dump-lambda-body-not-duplicated.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-lambda-body-not-duplicated.cpp
@@ -0,0 +1,26 @@
+// Test without serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -ast-dump %s \
+// RUN: | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value \
+// RUN: -include-pch %t -ast-dump-all /dev/null \
+// RUN: | FileCheck %s
+
+// Make sure that the Stmt * for the body of the LambdaExpr is
+// equal to the Stmt * for the body of the call operator.
+void Test() {
+  []() {
+return 42;
+  };
+}
+
+// CHECK: FunctionDecl {{.*}} Test
+//
+// CHECK: CXXMethodDecl {{.*}} operator() 'int () const' inline
+// CHECK-NEXT: CompoundStmt 0x[[TMP:.*]]
+// CHECK: IntegerLiteral {{.*}} 'int' 42
+//
+// CHECK: CompoundStmt 0x[[TMP]]
+// Check: IntegerLiteral {{.*}} 'int' 42
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1615,7 +1615,8 @@
 Record.AddStmt(*C);
   }
 
-  Record.AddStmt(E->getBody());
+  // Don't serialize the body. It belongs to the call operator declaration.
+  // LambdaExpr only stores a copy of the Stmt *.
 
   Code = serialization::EXPR_LAMBDA;
 }
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1715,12 +1715,12 @@
 
   // Read capture initializers.
   for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
-  CEnd = E->capture_init_end();
+ CEnd = E->capture_init_end();
C != CEnd; ++C)
 *C = Record.readSubExpr();
 
-  // Ok, not one past the end.
-  E->getStoredStmts()[NumCaptures] = Record.readSubStmt();
+  // The body will be lazily deserialized when needed from the call operator
+  // declaration.
 }
 
 void
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -1118,6 +1118,10 @@
 LambdaExpr::LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
 : Expr(LambdaExprClass, Empty) {
   LambdaExprBits.NumCaptures = NumCaptures;
+
+  // Initially don't initialize the body of the LambdaExpr. The body will
+  // be lazily deserialized when needed.
+  getStoredStmts()[NumCaptures] = nullptr; // Not one past the end.
 }
 
 LambdaExpr *LambdaExpr::Create(const ASTContext , CXXRecordDecl *Class,
@@ -1147,6 +1151,25 @@
   return new (Mem) LambdaExpr(EmptyShell(), NumCaptures);
 }
 
+void LambdaExpr::initBodyIfNeeded() const {
+  if (!getStoredStmts()[capture_size()]) {
+auto *This = const_cast(this);
+This->getStoredStmts()[capture_size()] = getCallOperator()->getBody();
+  }
+}
+
+Stmt *LambdaExpr::getBody() const {
+  initBodyIfNeeded();
+  return getStoredStmts()[capture_size()];
+}
+
+const CompoundStmt *LambdaExpr::getCompoundStmtBody() const {
+  Stmt *Body = getBody();
+  if (const auto *CoroBody = dyn_cast(Body))
+return cast(CoroBody->getBody());
+  return cast(Body);
+}
+
 bool LambdaExpr::isInitCapture(const LambdaCapture *C) const {
   return (C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
   (getCallOperator() == C->getCapturedVar()->getDeclContext()));
@@ -1216,6 +1239,17 @@
 
 bool LambdaExpr::isMutable() const { return !getCallOperator()->isConst(); }
 
+LambdaExpr::child_range LambdaExpr::children() {
+  initBodyIfNeeded();
+  return child_range(getStoredStmts(), getStoredStmts() + capture_size() + 

[PATCH] D83006: [ASTImporter] Add unittest case for friend decl import

2020-07-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 274945.
vabridgers added a comment.

Updated commit header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83006

Files:
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3417,6 +3417,29 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
+   ClassTemplateFriendDecl) {
+  auto Code =
+  R"(
+  template  class X {  friend T; };
+  struct Y {};
+  template class X;
+)";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec =
+  FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec =
+  FirstDeclMatcher().match(
+  ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter().match(
+ToTU, classTemplateSpecializationDecl()));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =
   R"(


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3417,6 +3417,29 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
+   ClassTemplateFriendDecl) {
+  auto Code =
+  R"(
+  template  class X {  friend T; };
+  struct Y {};
+  template class X;
+)";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec =
+  FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec =
+  FirstDeclMatcher().match(
+  ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter().match(
+ToTU, classTemplateSpecializationDecl()));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =
   R"(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-01 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: teemperor, jingham, jasonmolenda, friss.
Herald added a subscriber: kristof.beyls.
shafik marked an inline comment as done.
shafik added a subscriber: rsmith.
shafik added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1190
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)

@rsmith you were correct, this was indeed reversed.


Currently the `ItaniumRecordLayoutBuilder` when laying out base classes has the 
virtual and non-virtual bases mixed up when pulling the base class layouts from 
the external source.

This came up in an LLDB bug where on arm64 because of differences in how it 
deals with tail padding would layout the bases differently without the correct 
layout from the external source (LLDB). This would result in some fields being 
off by 4 bytes.


https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/Shell/Expr/Inputs/layout.cpp
  lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test


Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
@@ -0,0 +1,7 @@
+# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t
+
+# RUN: %lldb %t -b -s %s | FileCheck %s
+
+expr (intptr_t) - (intptr_t)
+# CHECK: (lldb) expr (intptr_t) - (intptr_t)
+# CHECK: (long) $0 = 12
Index: lldb/test/Shell/Expr/Inputs/layout.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/layout.cpp
@@ -0,0 +1,30 @@
+#include 
+
+struct B1 {
+  uint8_t a;
+};
+
+struct D1 : public B1 {
+  uint8_t a;
+  uint32_t ID;
+  uint8_t b;
+};
+
+struct Mixin : public D1 {
+  uint8_t a;
+  uint32_t *arr[3];
+};
+
+struct B2 {
+  uint32_t a;
+};
+
+class D2 : public B2, public Mixin {};
+
+D2 sg;
+
+int main() {
+  D2 s;
+
+  return s.ID;
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
@@ -0,0 +1,7 @@
+# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t
+
+# RUN: %lldb %t -b -s %s | FileCheck %s
+
+expr (intptr_t) - (intptr_t)
+# CHECK: (lldb) expr (intptr_t) - (intptr_t)
+# CHECK: (long) $0 = 12
Index: lldb/test/Shell/Expr/Inputs/layout.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/layout.cpp
@@ -0,0 +1,30 @@
+#include 
+
+struct B1 {
+  uint8_t a;
+};
+
+struct D1 : public B1 {
+  uint8_t a;
+  uint32_t ID;
+  uint8_t b;
+};
+
+struct Mixin : public D1 {
+  uint8_t a;
+  uint32_t *arr[3];
+};
+
+struct B2 {
+  uint32_t a;
+};
+
+class D2 : public B2, public Mixin {};
+
+D2 sg;
+
+int main() {
+  D2 s;
+
+  return s.ID;
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82940: [ASTReader][ASTWriter][PCH][Modules] Fix (de)serialization of SwitchCases

2020-07-01 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

> Yes, I think that my patch just traded-off a bug for another bug. What about 
> the following instead:
> 
> Initially zero the `Stmt *` for the body, then when the body is needed 
> (either with `getBody` or with `children`)
>  populate it if needed from the call operator. This is what was done before 
> with `getBody`.
> 
> This preserve the benefit of having a lazily deserialized body while being a 
> simple fix.
> 
> Thoughts? Am I missing something?
> 
> If not I can cook-up a patch either tonight or tomorrow.

D83009 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82940



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


[PATCH] D83006: [ASTImporter] Add unittest case for friend decl import

2020-07-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added a reviewer: martong.
Herald added subscribers: cfe-commits, teemperor, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.
vabridgers updated this revision to Diff 274945.
vabridgers added a comment.

Updated commit header.


This change adds a matching test case for the recent bug fix to
VisitFriendDecl in ASTImporterLookup.cpp.

See https://reviews.llvm.org/D82882 for details.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83006

Files:
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3417,6 +3417,29 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
+   ClassTemplateFriendDecl) {
+  auto Code =
+  R"(
+  template  class X {  friend T; };
+  struct Y {};
+  template class X;
+)";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec =
+  FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec =
+  FirstDeclMatcher().match(
+  ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter().match(
+ToTU, classTemplateSpecializationDecl()));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =
   R"(


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3417,6 +3417,29 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
+   ClassTemplateFriendDecl) {
+  auto Code =
+  R"(
+  template  class X {  friend T; };
+  struct Y {};
+  template class X;
+)";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec =
+  FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec =
+  FirstDeclMatcher().match(
+  ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter().match(
+ToTU, classTemplateSpecializationDecl()));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =
   R"(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9fc8772 - clang CoverageMapping tests bot cleanup

2020-07-01 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2020-07-01T16:06:56-07:00
New Revision: 9fc877213e075a76831fe71291d7c072c64c27e3

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

LOG: clang CoverageMapping tests bot cleanup

Summary:
D82928 generated unexpected tmp files in the CoverageMapping test directory. 
This patch cleans it up and remove the file in the test bots.
It will be revered after a week.

Reviewers: thakis

Reviewed By: thakis

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/CoverageMapping/coroutine.cpp

Removed: 




diff  --git a/clang/test/CoverageMapping/coroutine.cpp 
b/clang/test/CoverageMapping/coroutine.cpp
index c149eefd1f01..dc9473348fc9 100644
--- a/clang/test/CoverageMapping/coroutine.cpp
+++ b/clang/test/CoverageMapping/coroutine.cpp
@@ -1,3 +1,5 @@
+// fixme: the following line is added to cleanup bots, will be removed in 
weeks.
+// RUN: rm -f %S/coroutine.ll
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s -o - | FileCheck %s
 
 namespace std::experimental {



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


[PATCH] D50229: [ARM][AArch64] Add feature +fp16fml

2020-07-01 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.
Herald added a subscriber: danielkiss.



Comment at: test/Driver/aarch64-cpus.c:518
+// RUN: %clang -target aarch64 -march=armv8.4-a -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERICV84A-NO-FP16FML %s
+// GENERICV84A-NO-FP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// GENERICV84A-NO-FP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"

Hi @SjoerdMeijer , I have noticed that this test does something different from 
what gcc does (well, claims to do, I haven't checked the actual behavior on 
gcc).

From the table in [1], it seems that `armv8.4-a` implies `fp16fml`... who got 
it right? GCC or clang? Or am I missing something?

Francesco


[1] https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#AArch64-Options 
(see the description of `-march=name`)


Repository:
  rC Clang

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

https://reviews.llvm.org/D50229



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


[PATCH] D82807: [clang-tidy] Allows the prevailing include header guard in Flang ...

2020-07-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Would you be able to add some unit tests for this in a follow up.
`clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp` is where they live.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82807



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


[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments

2020-07-01 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 5 inline comments as done.
njames93 added inline comments.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp:124
+llvm::Optional getRegexFlag(llvm::StringRef Flag) {
+  for (auto  : RegexMap) {
+if (Flag == StringFlag.first)

aaron.ballman wrote:
> `const auto &` (same below)
Foiled by my own check ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82706



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


[PATCH] D82999: [CodeGen] Check the cleanup flag before destructing temporaries created in conditional expressions

2020-07-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, rjmccall.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.

The temporary of the true operand shouldn't be destructed when the false 
operand is evaluated and throws.

rdar://problem/64829372


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82999

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/temporaries.cpp

Index: clang/test/CodeGenCXX/temporaries.cpp
===
--- clang/test/CodeGenCXX/temporaries.cpp
+++ clang/test/CodeGenCXX/temporaries.cpp
@@ -817,15 +817,19 @@
 
   // CHECK-LABEL: define {{.*}} @_ZN11Conditional1fEb(
   void f(bool b) {
+// CHECK: store i1 false, i1* %{{.*}},
 // CHECK: store i1 false, i1* %[[CLEANUP_B:.*]],
+// CHECK: store i1 false, i1* %{{.*}},
 // CHECK: store i1 false, i1* %[[CLEANUP_C:.*]],
 // CHECK: br i1
 //
 // CHECK: call {{.*}} @_ZN11Conditional1BC1Ev(
+// CHECK: store i1 true, i1* %{{.*}},
 // CHECK: store i1 true, i1* %[[CLEANUP_B]],
 // CHECK: br label
 //
 // CHECK: call {{.*}} @_ZN11Conditional1CC1Ev(
+// CHECK: store i1 true, i1* %{{.*}},
 // CHECK: store i1 true, i1* %[[CLEANUP_C]],
 // CHECK: br label
 A & = b ? static_cast(B()) : static_cast(C());
@@ -847,15 +851,19 @@
   struct D { A & };
   // CHECK-LABEL: define {{.*}} @_ZN11Conditional10f_indirectEb(
   void f_indirect(bool b) {
+// CHECK-CXX17: store i1 false, i1* %{{.*}},
 // CHECK: store i1 false, i1* %[[CLEANUP_B:.*]],
+// CHECK-CXX17: store i1 false, i1* %{{.*}},
 // CHECK: store i1 false, i1* %[[CLEANUP_C:.*]],
 // CHECK: br i1
 //
 // CHECK: call {{.*}} @_ZN11Conditional1BC1Ev(
+// CHECK-CXX17: store i1 true, i1* %{{.*}},
 // CHECK: store i1 true, i1* %[[CLEANUP_B]],
 // CHECK: br label
 //
 // CHECK: call {{.*}} @_ZN11Conditional1CC1Ev(
+// CHECK-CXX17: store i1 true, i1* %{{.*}},
 // CHECK: store i1 true, i1* %[[CLEANUP_C]],
 // CHECK: br label
 D d = b ? D{B()} : D{C()};
Index: clang/test/CodeGenCXX/exceptions.cpp
===
--- clang/test/CodeGenCXX/exceptions.cpp
+++ clang/test/CodeGenCXX/exceptions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++98 -o - -fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++11 -o - -fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
+// CHECK: %[[STRUCT_TEST13_A:.*]] = type { i32, i32 }
+
 typedef __typeof(sizeof(0)) size_t;
 
 // Declare the reserved global placement new.
@@ -594,4 +596,45 @@
   // CHECK11:   call void @_ZN6test121AdlEPvS1_(i8* [[PTR]], i8* [[PTR]])
 }
 
+namespace test13 {
+
+struct A {
+  A();
+  ~A();
+  int a, b;
+};
+
+// CHECK: define void @_ZN6test134testEi(
+// CHECK: %[[REF_TMP:.*]] = alloca %[[STRUCT_TEST13_A]], align 4
+// CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1
+// CHECK: %[[CLEANUP_COND1:.*]] = alloca i1, align 1
+// CHECK: %[[REF_TMP2:.*]] = alloca %[[STRUCT_TEST13_A]], align 4
+// CHECK: %[[CLEANUP_COND3:.*]] = alloca i1, align 1
+// CHECK: %[[CLEANUP_COND4:.*]] = alloca i1, align 1
+
+// CHECK: call void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]])
+// CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1
+// CHECK: store i1 true, i1* %[[CLEANUP_COND1]], align 1
+// CHECK: br
+
+// CHECK: invoke void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP2]])
+
+// CHECK: store i1 true, i1* %[[CLEANUP_COND3]], align 1
+// CHECK: store i1 true, i1* %[[CLEANUP_COND4]], align 1
+// CHECK: br
+
+//   Check the flag before destructing the temporary.
+
+// CHECK: landingpad { i8*, i32 }
+// CHECK: %[[CLEANUP_IS_ACTIVE:.*]] = load i1, i1* %[[CLEANUP_COND]], align 1
+// CHECK: br i1 %[[CLEANUP_IS_ACTIVE]],
+
+// CHECK: void @_ZN6test131AD1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]])
+
+void test(int c) {
+  const A  = c ? static_cast(A()) : static_cast(A());
+}
+
+}
+
 // CHECK98: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2095,7 +2095,7 @@
   // FIXME: When popping normal cleanups, we need to keep this EH cleanup
   // around in case a temporary's destructor throws an exception.
   if (cleanupKind & EHCleanup)
-EHStack.pushCleanup(
+pushFullExprCleanup(
 static_cast(cleanupKind & ~NormalCleanup), addr, type,
 destroyer, useEHCleanupForArray);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82994: [RFC] Instrumenting Clang/LLVM with Perfetto

2020-07-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

New files are missing standard license header blurb.
Also probably missing some tests.




Comment at: clang/lib/Driver/Driver.cpp:3754
 
+  // We don't need to count the assembler as a job since it doesn't
+  // cause the memory issue that requires disabling integrated-cc1.

This appears unrelated to the patch.



Comment at: clang/tools/clang-shlib/CMakeLists.txt:40
+if (PERFETTO)
+# Avoid issues with PRIVATE library
+# There's probably a better fix for this

Could use more words. What issues?



Comment at: llvm/cmake/modules/AddPerfetto.cmake:9
+  ExternalProject_Add(perfetto_git
+  GIT_REPOSITORY https://github.com/google/perfetto.git
+  GIT_TAG releases/v4.x

I have concerns about this.
It really should use system-provided version via `find_package()`
At worst, the sources should be bundled into the tree like it's already done in 
some rare cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82994



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


[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

2020-07-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:969
+  // Do not warn for non-closed stream at program exit.
+  if (Pred && Pred->getCFGBlock() && Pred->getCFGBlock()->hasNoReturnElement())
+return Pred;

balazske wrote:
> Szelethus wrote:
> > It is a realistic worry that either the predecessor exploded node or the 
> > CFGBlock is null? Could we assert this instead?
> It may be simply more safe to check for it. I do not know if exactly if these 
> can be null at this place.
Please use `SuppressOnSink` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845



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


[PATCH] D82967: [analyzer][tests] Measure peak memory consumption for every project

2020-07-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/utils/analyzer/SATestUtils.py:113
+peak_mem = max(peak_mem, get_memory(process))
+time.sleep(.5)
+

Do i understand correctly that this basically adds roughly 0.25 second delay to 
every invocation of the analyzer? If so, that may add up to a lot of seconds 
for a project with many small translation units which can potentially screw our 
wall clock measurements. I guess the ideal solution would be some sort of 
"select" that waits on process termination with timeout, or we could simply 
decrease the sleep interval and hope it won't consume too much cpu time.



Comment at: clang/utils/analyzer/requirements.txt:1-2
+humanize
+psutil

Dunno, should we bother putting every utility into its own directory with its 
own requirements? Like, `exploded-graph-rewriter.py` certainly has different 
requirements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82967



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


[PATCH] D82986: [Coroutines] Fix test breakage in D82928

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82986#2126479 , @thakis wrote:

> That's not enough, you also need to add an rm to remove the stale .LL file 
> still on disk, see my comment on your original change.


It's in https://reviews.llvm.org/D82992 if you could help accept it. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82986



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


[PATCH] D82901: [libTooling] Fix `maybeExtendRange` to support `CharRange`s.

2020-07-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecfa0b24189a: [libTooling] Fix `maybeExtendRange` to support 
`CharRange`s. (authored by gmatute, committed by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82901

Files:
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "TestVisitor.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
@@ -21,9 +23,11 @@
 using llvm::Succeeded;
 using llvm::ValueIs;
 using tooling::getAssociatedRange;
+using tooling::getExtendedRange;
 using tooling::getExtendedText;
 using tooling::getRangeForEdit;
 using tooling::getText;
+using tooling::maybeExtendRange;
 using tooling::validateEditRange;
 
 namespace {
@@ -52,7 +56,7 @@
  arg.getBegin() == R.getBegin() && arg.getEnd() == R.getEnd();
 }
 
-MATCHER_P2(EqualsAnnotatedRange, SM, R, "") {
+MATCHER_P2(EqualsAnnotatedRange, Context, R, "") {
   if (arg.getBegin().isMacroID()) {
 *result_listener << "which starts in a macro";
 return false;
@@ -62,15 +66,13 @@
 return false;
   }
 
-  unsigned Begin = SM->getFileOffset(arg.getBegin());
-  unsigned End = SM->getFileOffset(arg.getEnd());
+  CharSourceRange Range = Lexer::getAsCharRange(
+  arg, Context->getSourceManager(), Context->getLangOpts());
+  unsigned Begin = Context->getSourceManager().getFileOffset(Range.getBegin());
+  unsigned End = Context->getSourceManager().getFileOffset(Range.getEnd());
 
-  *result_listener << "which is [" << Begin << ",";
-  if (arg.isTokenRange()) {
-*result_listener << End << "]";
-return Begin == R.Begin && End + 1 == R.End;
-  }
-  *result_listener << End << ")";
+  *result_listener << "which is a " << (arg.isTokenRange() ? "Token" : "Char")
+   << " range [" << Begin << "," << End << ")";
   return Begin == R.Begin && End == R.End;
 }
 
@@ -84,11 +86,13 @@
 // Base class for visitors that expect a single match corresponding to a
 // specific annotated range.
 template  class AnnotatedCodeVisitor : public TestVisitor {
-  llvm::Annotations Code;
+protected:
   int MatchCount = 0;
+  llvm::Annotations Code;
 
 public:
   AnnotatedCodeVisitor() : Code("$r[[]]") {}
+  // Helper for tests of `getAssociatedRange`.
   bool VisitDeclHelper(Decl *Decl) {
 // Only consider explicit declarations.
 if (Decl->isImplicit())
@@ -96,8 +100,7 @@
 
 ++MatchCount;
 EXPECT_THAT(getAssociatedRange(*Decl, *this->Context),
-EqualsAnnotatedRange(>Context->getSourceManager(),
- Code.range("r")))
+EqualsAnnotatedRange(this->Context, Code.range("r")))
 << Code.code();
 return true;
   }
@@ -183,6 +186,45 @@
   Visitor.runOver("int foo() { return foo() + 3; }");
 }
 
+TEST(SourceCodeTest, maybeExtendRange_TokenRange) {
+  struct ExtendTokenRangeVisitor
+  : AnnotatedCodeVisitor {
+bool VisitCallExpr(CallExpr *CE) {
+  ++MatchCount;
+  EXPECT_THAT(getExtendedRange(*CE, tok::TokenKind::semi, *Context),
+  EqualsAnnotatedRange(Context, Code.range("r")));
+  return true;
+}
+  };
+
+  ExtendTokenRangeVisitor Visitor;
+  // Extends to include semicolon.
+  Visitor.runOverAnnotated("void f(int x, int y) { $r[[f(x, y);]] }");
+  // Does not extend to include semicolon.
+  Visitor.runOverAnnotated(
+  "int f(int x, int y) { if (0) return $r[[f(x, y)]] + 3; }");
+}
+
+TEST(SourceCodeTest, maybeExtendRange_CharRange) {
+  struct ExtendCharRangeVisitor : AnnotatedCodeVisitor {
+bool VisitCallExpr(CallExpr *CE) {
+  ++MatchCount;
+  CharSourceRange Call = Lexer::getAsCharRange(CE->getSourceRange(),
+   Context->getSourceManager(),
+   Context->getLangOpts());
+  EXPECT_THAT(maybeExtendRange(Call, tok::TokenKind::semi, *Context),
+  EqualsAnnotatedRange(Context, Code.range("r")));
+  return true;
+}
+  };
+  ExtendCharRangeVisitor Visitor;
+  // Extends to include semicolon.
+  Visitor.runOverAnnotated("void f(int x, int y) { $r[[f(x, y);]] }");
+  // Does not extend to include semicolon.
+  Visitor.runOverAnnotated(
+  "int f(int x, int y) { if (0) return $r[[f(x, y)]] + 3; }");
+}
+
 TEST(SourceCodeTest, getAssociatedRange) {
   struct VarDeclsVisitor : AnnotatedCodeVisitor {
 bool 

[PATCH] D82986: [Coroutines] Fix test breakage in D82928

2020-07-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

That's not enough, you also need to add an rm to remove the stale .LL file 
still on disk, see my comment on your original change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82986



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


[PATCH] D82994: [RFC] Instrumenting Clang/LLVM with Perfetto

2020-07-01 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry created this revision.
Herald added subscribers: llvm-commits, cfe-commits, arphaman, hiraditya, 
mgorny.
Herald added projects: clang, LLVM.
Nathan-Huckleberry edited the summary of this revision.
Nathan-Huckleberry edited the summary of this revision.
Nathan-Huckleberry edited the summary of this revision.
Nathan-Huckleberry edited the summary of this revision.
Nathan-Huckleberry edited the summary of this revision.
Nathan-Huckleberry edited the summary of this revision.
Nathan-Huckleberry edited the summary of this revision.

Instrumenting Clang/LLVM with Perfetto

Overview

Perfetto is an event based tracer designed to replace chrome://tracing. It
allows for fine-grained control over trace data and is currently in use by
Chrome and Android.

Instrumentation of Clang with Perfetto would give nicely formatted traces
that are easily shareable by link. Compile time regression bugs could be
filed with Perfetto links that clearly show the regression.

Perfetto exposes a C++ library that allows arbitrary applications to record
app-specific events. Trace events can be added to Clang by calling macros
exposed by Perfetto.

The trace events are sent to an in-process tracing service and are kept in
memory until the trace is written to disk. The trace is written as a protobuf
and can be opened by the Perfetto trace processor (https://ui.perfetto.dev/).

The Perfetto trace processor allows you to vizualize traces as flamegraphs.
The view can be scrolled with "WASD" keys. There is also a query engine
built into the processor that can run queries by pressing CTRL+ENTER.

The benefits of Perfetto:

- Shareable Perfetto links
  - Traces can be easily shared without sending the trace file
- Traces can be easily aggregated with UNIX cat
- Fine-grained Tracing Control
  - Trace events can span across function boundaries  (Start a trace in one 
function, end it in another)
  - Finer granularity than function level that you would see with Linux perf
- Less tracing overhead
  - Trace events are buffered in memory, not sent directly to disk
  - Perfetto macros are optimized to prevent overhead
- Smaller trace sizes
  - Strings and other reused data is interned
  - Traces are stored as protobufs instead of JSON
  - 3x smaller than -ftrace-time traces
- SQL queries for traces
  - The Perfetto UI has a query language built in for data aggregation
- Works on Linux/MacOS/Windows

Example Trace

This is an example trace on a Linux kernel source file.
https://ui.perfetto.dev/#!/?s=c7942d5118f3ccfe16f46d166b05a66d077eb61ef8e22184a7d7dfe87ba8ea

This is an example trace on the entire Linux kernel.
https://ui.perfetto.dev/#!/?s=10556b46b46aba46188a51478102a6ce21a9c767c218afa5b8429eac4cb9d4
Recorded with:

  make CC="clang-9" KCFLAGS="-perfetto" -j72
  find /tmp -name "*pftrace" -exec cat {} \; > trace.pftrace

Current Implementation

These changes are behind a CMake flag (-DPERFETTO). When building Clang with
the CMake flag enabled, the Perfetto GitHub is cloned into the build folder and
linked against any code that uses Perfetto macros.

The -ftime-trace and Perfetto trace events have been combined into one
macro that expands to trace events for both. The behavior of -ftime-trace
is unchanged.

To run a Perfetto trace, pass the flag -perfetto to Clang (built with
-DPERFETTO). The trace output file follows the convention set by
-ftime-trace and uses the filename passed to -o to determine the trace
filename.

For example:
`clang -perfetto -c foo.c -o foo.o`
would generate foo.pftrace.

Tracing documentation

`LLVM_TRACE_BEGIN(name, detail)`
Begins a tracing slice if Perfetto or -ftime-trace is enabled.
`name` : constexpr String
This is what will be displayed on the tracing UI.
`detail` : StringRef
Additional detail to add to the trace slice. This expands to a lambda
and will be evaluated lazily only if Perfetto or -ftime-trace are
enabled.

`LLVM_TRACE_END()`
Ends the most recently started slice.

`LLVM_TRACE_SCOPE(name, detail)`
Begins a tracing slice and initializes an anonymous struct if Perfetto or
-ftime-trace is enabled. When the struct goes out of scope, the tracing
slice will end.
`name` : constexpr String
 This is what will be displayed on the tracing UI.
 `detail` : StringRef
Additional detail to add to the trace slice. This expands to a lambda
and will be evaluated lazily only if Perfetto or -ftime-trace are
enabled.

Perfetto Documentation: https://perfetto.dev/

FAQs

Why not use Linux Perf?
Perfetto's event based model allows for much finer grained control over
the trace.

- Linux Perf is only available on Linux.
- Visualization requires post processing with separate tools.
- Requires kernel version specific dependencies.

Why not use -ftime-trace?
Perfetto has almost the same functionality as -ftime-trace, but with a
few added benefits.

- Shareable links.
- Traces can be aggregated easily with UNIX cat.
- The query engine for trace analysis.
- The Perfetto UI is browser agnostic and could be used the 

[clang] ecfa0b2 - [libTooling] Fix `maybeExtendRange` to support `CharRange`s.

2020-07-01 Thread Yitzhak Mandelbaum via cfe-commits

Author: Gabriel Matute
Date: 2020-07-01T20:40:48Z
New Revision: ecfa0b24189abf4bb172a8860048af05fa17daee

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

LOG: [libTooling] Fix `maybeExtendRange` to support `CharRange`s.

Currently, `maybeExtendRange` takes a `CharSourceRange`, but only works
correctly for the `TokenRange` case. This change adds proper support for the
`CharRange` case.

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/lib/Tooling/Transformer/SourceCode.cpp
clang/unittests/Tooling/SourceCodeTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Transformer/SourceCode.cpp 
b/clang/lib/Tooling/Transformer/SourceCode.cpp
index a29d2e796d94..26b204851f05 100644
--- a/clang/lib/Tooling/Transformer/SourceCode.cpp
+++ b/clang/lib/Tooling/Transformer/SourceCode.cpp
@@ -37,11 +37,17 @@ StringRef clang::tooling::getText(CharSourceRange Range,
 CharSourceRange clang::tooling::maybeExtendRange(CharSourceRange Range,
  tok::TokenKind Next,
  ASTContext ) {
-  Optional Tok = Lexer::findNextToken(
-  Range.getEnd(), Context.getSourceManager(), Context.getLangOpts());
-  if (!Tok || !Tok->is(Next))
+  CharSourceRange R = Lexer::getAsCharRange(Range, Context.getSourceManager(),
+Context.getLangOpts());
+  if (R.isInvalid())
 return Range;
-  return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation());
+  Token Tok;
+  bool Err =
+  Lexer::getRawToken(R.getEnd(), Tok, Context.getSourceManager(),
+ Context.getLangOpts(), /*IgnoreWhiteSpace=*/true);
+  if (Err || !Tok.is(Next))
+return Range;
+  return CharSourceRange::getTokenRange(Range.getBegin(), Tok.getLocation());
 }
 
 llvm::Error clang::tooling::validateEditRange(const CharSourceRange ,

diff  --git a/clang/unittests/Tooling/SourceCodeTest.cpp 
b/clang/unittests/Tooling/SourceCodeTest.cpp
index aeb0ca36582b..eb652cf03064 100644
--- a/clang/unittests/Tooling/SourceCodeTest.cpp
+++ b/clang/unittests/Tooling/SourceCodeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "TestVisitor.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
@@ -21,9 +23,11 @@ using llvm::Failed;
 using llvm::Succeeded;
 using llvm::ValueIs;
 using tooling::getAssociatedRange;
+using tooling::getExtendedRange;
 using tooling::getExtendedText;
 using tooling::getRangeForEdit;
 using tooling::getText;
+using tooling::maybeExtendRange;
 using tooling::validateEditRange;
 
 namespace {
@@ -52,7 +56,7 @@ MATCHER_P(EqualsRange, R, "") {
  arg.getBegin() == R.getBegin() && arg.getEnd() == R.getEnd();
 }
 
-MATCHER_P2(EqualsAnnotatedRange, SM, R, "") {
+MATCHER_P2(EqualsAnnotatedRange, Context, R, "") {
   if (arg.getBegin().isMacroID()) {
 *result_listener << "which starts in a macro";
 return false;
@@ -62,15 +66,13 @@ MATCHER_P2(EqualsAnnotatedRange, SM, R, "") {
 return false;
   }
 
-  unsigned Begin = SM->getFileOffset(arg.getBegin());
-  unsigned End = SM->getFileOffset(arg.getEnd());
+  CharSourceRange Range = Lexer::getAsCharRange(
+  arg, Context->getSourceManager(), Context->getLangOpts());
+  unsigned Begin = Context->getSourceManager().getFileOffset(Range.getBegin());
+  unsigned End = Context->getSourceManager().getFileOffset(Range.getEnd());
 
-  *result_listener << "which is [" << Begin << ",";
-  if (arg.isTokenRange()) {
-*result_listener << End << "]";
-return Begin == R.Begin && End + 1 == R.End;
-  }
-  *result_listener << End << ")";
+  *result_listener << "which is a " << (arg.isTokenRange() ? "Token" : "Char")
+   << " range [" << Begin << "," << End << ")";
   return Begin == R.Begin && End == R.End;
 }
 
@@ -84,11 +86,13 @@ static ::testing::Matcher AsRange(const 
SourceManager ,
 // Base class for visitors that expect a single match corresponding to a
 // specific annotated range.
 template  class AnnotatedCodeVisitor : public TestVisitor {
-  llvm::Annotations Code;
+protected:
   int MatchCount = 0;
+  llvm::Annotations Code;
 
 public:
   AnnotatedCodeVisitor() : Code("$r[[]]") {}
+  // Helper for tests of `getAssociatedRange`.
   bool VisitDeclHelper(Decl *Decl) {
 // Only consider explicit declarations.
 if (Decl->isImplicit())
@@ -96,8 +100,7 @@ template  class AnnotatedCodeVisitor : public 
TestVisitor {
 
 ++MatchCount;
 EXPECT_THAT(getAssociatedRange(*Decl, *this->Context),
- 

[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

2020-07-01 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a subscriber: majnemer.
riccibruno added inline comments.



Comment at: clang/lib/AST/StmtPrinter.cpp:1159
+  case BuiltinType::UInt128:
+OS << "Ui128";
+break;

riccibruno wrote:
> davidstone wrote:
> > riccibruno wrote:
> > > `i128` and `Ui128` are not valid integer literal suffix. The output of 
> > > `StmtPrinter` is intended to be valid C++. Unfortunately here I think 
> > > that your only choice is to print the high and low parts separately. 
> > I'm confused. i8, Ui8, i16, and Ui16 are also not valid C++ suffixes, but 
> > just a few lines up we use those. What am I missing here?
> The literal suffixes `[u]i8, [u]i16, [u]i32, and [u]i64` are an MSVC 
> extension (see `NumericLiteralParser::NumericLiteralParser` in 
> `Lex/LiteralSupport.cpp`).
> 
> This does not explain why they are used even in non-ms compatibility mode
> but at least there is some reason for their existence.
> 
> However I don't think that MSVC supports 128-bits integers (?), and clang 
> certainly
> does not support `[u]i128` so there is no reason to use them.
> 
> @aaron.ballman Do you know why are these suffixes used outside of 
> ms-compatibility mode?
> This does not explain why they are used even in non-ms compatibility mode
> but at least there is some reason for their existence.

Let's just ask the author @majnemer 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82880



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


[PATCH] D82992: clang CoverageMapping tests bot cleanup

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
lxfind added a reviewer: thakis.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

D82928  generated unexpected tmp files in the 
CoverageMapping test directory. This patch cleans it up and remove the file in 
the test bots.
It will be revered after a week.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82992

Files:
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,3 +1,5 @@
+// fixme: the following line is added to cleanup bots, will be removed in 
weeks.
+// RUN: rm -f %S/coroutine.ll
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s -o - | FileCheck %s
 
 namespace std::experimental {


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,3 +1,5 @@
+// fixme: the following line is added to cleanup bots, will be removed in weeks.
+// RUN: rm -f %S/coroutine.ll
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
 
 namespace std::experimental {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82807: [clang-tidy] Allows the prevailing include header guard in Flang ...

2020-07-01 Thread Eric Schweitz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1581540876f: [clang-tidy] Allows the prevailing include 
header guard in Flang to be… (authored by schweitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82807

Files:
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp


Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang") - 1);
+
   return StringRef(Guard).upper();
 }
 


Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang") - 1);
+
   return StringRef(Guard).upper();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/test/CoverageMapping/coroutine.cpp:1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+

Since this line is missing an -o /dev/null, it writes a .ll file into the test 
directory, which lit tries to run as test next time, causing check-clang to 
fail: http://45.33.8.238/linux/21841/step_7.txt

Please add `-o /dev/null`, and please also add a `RUN: rm -f %S/coroutine.ll` 
to clean up bots (with a fixme to remove that rm line once it's been in the 
tree for a week or so)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928



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


[PATCH] D82908: [SVE] ACLE: Fix builtins for svdup_lane_bf16 and svcvtnt_bf16_f32_x

2020-07-01 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli accepted this revision.
fpetrogalli added a comment.
This revision is now accepted and ready to land.

LGTM, thank you.




Comment at: clang/utils/TableGen/SveEmitter.cpp:1265-1279
+  OS << "#if defined(__ARM_FEATURE_SVE_BF16)\n";
+  OS << "#define svcvtnt_bf16_x  svcvtnt_bf16_m\n";
+  OS << "#define svcvtnt_bf16_f32_x  svcvtnt_bf16_f32_m\n";
+  OS << "#endif /*__ARM_FEATURE_SVE_BF16 */\n\n";
+
   OS << "#if defined(__ARM_FEATURE_SVE2)\n";
   OS << "#define svcvtnt_f16_x  svcvtnt_f16_m\n";

nit: worth adding a comment in the emitter  explaining why these redirections 
are needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82908



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


[clang-tools-extra] e158154 - [clang-tidy] Allows the prevailing include header guard in Flang to be recognized rather than flagged as a violation in phabricator.

2020-07-01 Thread Eric Schweitz via cfe-commits

Author: Eric Schweitz
Date: 2020-07-01T12:47:36-07:00
New Revision: e1581540876f51af1aa1389bdb21388ae88c1b90

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

LOG: [clang-tidy] Allows the prevailing include header guard in Flang to be 
recognized rather than flagged as a violation in phabricator.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp 
b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
index 56156ff2fb38..3e4c39d94193 100644
--- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -54,6 +54,10 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef 
Filename,
   if (StringRef(Guard).startswith("clang"))
 Guard = "LLVM_" + Guard;
 
+  // The prevalent style in flang is FORTRAN_FOO_BAR_H
+  if (StringRef(Guard).startswith("flang"))
+Guard = "FORTRAN" + Guard.substr(sizeof("flang") - 1);
+
   return StringRef(Guard).upper();
 }
 



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


[PATCH] D82948: [Driver][ARM] Disable unsupported features when nofp arch extension is used

2020-07-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

Needs a regression test. This patch and the dependent patch clash, better with 
a single patch.




Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:288
 
+static void appendNoFPUnsupportedFeatures(const arm::FloatABI ABI,
+  const unsigned FPUID,

That's kinda mouthful name.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:292-297
+  auto checkFPDisabledInArchName = [](const StringRef ) {
+SmallVector Split;
+ArchName.split(Split, '+', -1, false);
+return llvm::any_of(
+Split, [](const StringRef ) { return Extension == "nofp"; });
+  };

Wouldn't just looking for the substring do the job?

Also need to handle `-mcpu=...+nofp`.

We already "parse" the arguments to `-march=` and `-mcpu=` (and `-mfpu=`) 
earlier, it seems to me we
could note the `+nofp` and `+nofp.dp` earlier. (TBH, it isn't immediately 
obvious to me how to untangle this mess).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82948



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


[PATCH] D82940: [ASTReader][ASTWriter][PCH][Modules] Fix (de)serialization of SwitchCases

2020-07-01 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D82940#2125939 , @martong wrote:

> In D82940#2125183 , @riccibruno 
> wrote:
>
> > > I'm not certain I understand, but I'm removing my LG while we figure it 
> > > out. Can you expound a bit further?
> >
> > Take a look at the AST dump of a small modification of the reduced test 
> > case which doesn't trigger the assertion:
> >
> >   void should_not_crash_with_switch_in_lambda() {
> > switch (1)
> > default:;
> > auto f = [] {
> >   switch (1)
> >   default:;
> > };
> >   }
> >
> >
> > Before the serialization of `LambdaExpr` for the `LambdaExpr *E`, we have 
> > `E->getBody() == E->getCallOperator()->getBody()`.
> >  After serialization this is not true anymore because we are writing and 
> > reading the body directly when visiting the `LambdaExpr`
> >  (the captures have the same problem).
>
>
> The same is true in case of the simplest lambda example:
>
>   void foo() {   // line 11
>   []{};
>   }
>
>
> The AST that we got from the Parser has only one CompoundStmt node, but 
> referenced in the CXXMethodDecl and added as a direct child to LambdaExpr:
>
>   `-LambdaExpr 0x5643235372c8 
> |-CXXRecordDecl 0x564323536c98  col:5 implicit class definition
> | |-CXXMethodDecl 0x564323536dd8  col:5 constexpr 
> operator() 'auto () const -> void' inline
> | | `-CompoundStmt 0x564323536e88 
> `-CompoundStmt 0x564323536e88 
>   
>
> After serialization and deserialization, the CompoundStmt is just copied, 
> notice the different pointer values:
>
>   `-LambdaExpr 0x55a49f35f830 
> |-CXXRecordDecl 0x55a49f35f860  col:5 imported implicit 
>  class definition
> | |-CXXMethodDecl 0x55a49f35fac8  col:5 imported constexpr 
> operator() 'auto () const -> void' inline
> | | `-CompoundStmt 0x55a49f360110 
> `-CompoundStmt 0x55a49f35f820 
>   
>
> This suggests that we should prepare the ASTReader/ASTWriter to be able to 
> handle references to Stmts similarly as it can already handle references to 
> Decls (see `ASTWriter::DeclIDs`).
>  Does this sound as a good direction, should I move forward this way?


Yes, I think that my patch just traded-off a bug for another bug. What about 
the following instead:

Initially zero the `Stmt *` for the body, then when the body is needed (either 
with `getBody` or with `children`)
populate it if needed from the call operator. This is what was done before with 
`getBody`.

This preserve the benefit of having a lazily deserialized body while being a 
simple fix.

Thoughts? Am I missing something?

If not I can cook-up a patch either tonight or tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82940



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-07-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Thank you I see now... super subtle but I'll take a look.


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

https://reviews.llvm.org/D79773



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


[PATCH] D77982: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally

2020-07-01 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Thanks for all the helpful feedback. Before we commit this just want to double 
check there are no final comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77982



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


[PATCH] D82921: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods

2020-07-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

This introduces a non-uniformity between `RecursiveASTVisitor` and 
`StmtVisitor`. `StmtVisitor` contains matching logic to treat the various kinds 
of unary and binary operators as if they were distinct AST node kinds, and that 
functionality is used much more heavily throughout Clang. Given that, I don't 
think this change necessarily improves big-picture uniformity, but the 
reduction in complexity and binary size still seem sufficiently compelling to 
me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82921



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-07-01 Thread Johel Ernesto Guerrero Peña via Phabricator via cfe-commits
JohelEGP added a comment.

In D79773#2125040 , @MyDeveloperDay 
wrote:

> Just so I'm clear for this and your Allman coment would you show me what you 
> are seeing and what you expect to see? just so I understand.


Sure, thank you.

This is what I have, as shown above. Actually fixed to show surrounding 
context, which is relevant to formatting. Note the `//` comment:

  namespace jge
  {
  template 
  struct [[nodiscard]] size2d
  {
  template 
  friend constexpr auto
  operator*(const size2d& l, const units::quantity& r) noexcept(
  noexcept(l.w* r)) requires(requires { l.w* r; }) //
  {
  return size2d{l.w * r, l.h * r};
  }
  };
  
  } // namespace jge

I added `//` to make the formatting look like what I want. If I remove it, this 
is what I get:

  namespace jge
  {
  template 
  struct [[nodiscard]] size2d
  {
  template 
  friend constexpr auto
  operator*(const size2d& l, const units::quantity& r) noexcept(
  noexcept(l.w* r)) requires(requires { l.w* r; }) {
  return size2d{l.w * r, l.h * r};
  }
  };
  
  } // namespace jge

So this is what I want, without the `//` comment:

  namespace jge
  {
  template 
  struct [[nodiscard]] size2d
  {
  template 
  friend constexpr auto
  operator*(const size2d& l, const units::quantity& r) noexcept(
  noexcept(l.w* r)) requires(requires { l.w* r; }) 
  {
  return size2d{l.w * r, l.h * r};
  }
  };
  
  } // namespace jge

For the constructor initializer list, this is what I have. Note the parentheses 
in the first requires-clause:

  namespace jge
  {
  template 
  class [[nodiscard]] plane
  {
  constexpr plane(const plane& other) noexcept(
  (detail::default_allocator_is_nothrow &&
   std::is_nothrow_copy_constructible_v)) requires(std::copyable)
: plane{to1d(other), other.sz.w}
  {
  }
  
  constexpr plane& operator=(const plane& other) noexcept(
  (std::is_nothrow_copy_constructible_v &&
   std::is_nothrow_copy_assignable_v)) requires std::copyable //
  {
  assign(to1d(other), other.sz.w);
  return *this;
  }
  };
  
  } // namespace jge

This is what I get without the parentheses. Note that all code after the 
constructor initializer list is further indented:

  namespace jge
  {
  template 
  class [[nodiscard]] plane
  {
  constexpr plane(const plane& other) noexcept(
  (detail::default_allocator_is_nothrow &&
   std::is_nothrow_copy_constructible_v)) requires std::copyable
: plane{to1d(other), other.sz.w}
{
}
  
constexpr plane& operator=(const plane& other) noexcept(
(std::is_nothrow_copy_constructible_v &&
 std::is_nothrow_copy_assignable_v)) requires std::copyable //
{
assign(to1d(other), other.sz.w);
return *this;
}
  };
  
  } // namespace jge

So this is what I want. Without extra parentheses, nor extra indentation:

  namespace jge
  {
  template 
  class [[nodiscard]] plane
  {
  constexpr plane(const plane& other) noexcept(
  (detail::default_allocator_is_nothrow &&
   std::is_nothrow_copy_constructible_v)) requires std::copyable
: plane{to1d(other), other.sz.w}
  {
  }
  
  constexpr plane& operator=(const plane& other) noexcept(
  (std::is_nothrow_copy_constructible_v &&
   std::is_nothrow_copy_assignable_v)) requires std::copyable //
  {
  assign(to1d(other), other.sz.w);
  return *this;
  }
  };
  
  } // namespace jge

All with the config file 
 linked 
above.


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

https://reviews.llvm.org/D79773



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


[PATCH] D82986: [Coroutines] Fix test breakage in D82928

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGddcf063dd52f: [Coroutines] Fix test breakage in D82928 
(authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82986

Files:
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s -o - | FileCheck %s
 
 namespace std::experimental {
 template 


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
 
 namespace std::experimental {
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82986: [Coroutines] Fix test breakage in D82928

2020-07-01 Thread Brian Gesiak via Phabricator via cfe-commits
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82986



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


[PATCH] D82984: Revert "[Coroutines] Fix code coverage for coroutine"

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind abandoned this revision.
lxfind added a comment.

Fix up in https://reviews.llvm.org/D82986


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82984



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


[PATCH] D82986: [Coroutines] Fix test breakage in D82928

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
lxfind added reviewers: modocache, fhahn.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

Thanks for the fix!


The test file in D82928  generated temp files 
within the test directory, causing test failures. Fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82986

Files:
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s -o - | FileCheck %s
 
 namespace std::experimental {
 template 


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
 
 namespace std::experimental {
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82928#2126018 , @fhahn wrote:

> Looks like this causes a bunch of build bot failures, e.g 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b
>
> It would be great if you could take a look.


Fix patch in https://reviews.llvm.org/D82986


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928



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


[PATCH] D82392: [CodeGen] Add public function to emit C++ destructor call.

2020-07-01 Thread Zoe Carver via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7c5da57a5f3: [CodeGen] Add public function to emit C++ 
destructor call. (authored by zoecarver).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82392

Files:
  clang/include/clang/CodeGen/CodeGenABITypes.h
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CodeGenABITypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -259,6 +259,12 @@
bool ForVirtualBase,
bool Delegating) override;
 
+  llvm::Value *getCXXDestructorImplicitParam(CodeGenFunction ,
+ const CXXDestructorDecl *DD,
+ CXXDtorType Type,
+ bool ForVirtualBase,
+ bool Delegating) override;
+
   void EmitDestructorCall(CodeGenFunction , const CXXDestructorDecl *DD,
   CXXDtorType Type, bool ForVirtualBase,
   bool Delegating, Address This,
@@ -1577,6 +1583,12 @@
   return AddedStructorArgs::suffix({{MostDerivedArg, getContext().IntTy}});
 }
 
+llvm::Value *MicrosoftCXXABI::getCXXDestructorImplicitParam(
+CodeGenFunction , const CXXDestructorDecl *DD, CXXDtorType Type,
+bool ForVirtualBase, bool Delegating) {
+  return nullptr;
+}
+
 void MicrosoftCXXABI::EmitDestructorCall(CodeGenFunction ,
  const CXXDestructorDecl *DD,
  CXXDtorType Type, bool ForVirtualBase,
@@ -1603,8 +1615,11 @@
 BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
   }
 
+  llvm::Value *Implicit =
+  getCXXDestructorImplicitParam(CGF, DD, Type, ForVirtualBase,
+Delegating); // = nullptr
   CGF.EmitCXXDestructorCall(GD, Callee, This.getPointer(), ThisTy,
-/*ImplicitParam=*/nullptr,
+/*ImplicitParam=*/Implicit,
 /*ImplicitParamTy=*/QualType(), nullptr);
   if (BaseDtorEndBB) {
 // Complete object handler should continue to be the remaining
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -228,6 +228,12 @@
bool ForVirtualBase,
bool Delegating) override;
 
+  llvm::Value *getCXXDestructorImplicitParam(CodeGenFunction ,
+ const CXXDestructorDecl *DD,
+ CXXDtorType Type,
+ bool ForVirtualBase,
+ bool Delegating) override;
+
   void EmitDestructorCall(CodeGenFunction , const CXXDestructorDecl *DD,
   CXXDtorType Type, bool ForVirtualBase,
   bool Delegating, Address This,
@@ -1693,13 +1699,21 @@
   return AddedStructorArgs::prefix({{VTT, VTTTy}});
 }
 
+llvm::Value *ItaniumCXXABI::getCXXDestructorImplicitParam(
+CodeGenFunction , const CXXDestructorDecl *DD, CXXDtorType Type,
+bool ForVirtualBase, bool Delegating) {
+  GlobalDecl GD(DD, Type);
+  return CGF.GetVTTParameter(GD, ForVirtualBase, Delegating);
+}
+
 void ItaniumCXXABI::EmitDestructorCall(CodeGenFunction ,
const CXXDestructorDecl *DD,
CXXDtorType Type, bool ForVirtualBase,
bool Delegating, Address This,
QualType ThisTy) {
   GlobalDecl GD(DD, Type);
-  llvm::Value *VTT = CGF.GetVTTParameter(GD, ForVirtualBase, Delegating);
+  llvm::Value *VTT =
+  getCXXDestructorImplicitParam(CGF, DD, Type, ForVirtualBase, Delegating);
   QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
 
   CGCallee Callee;
Index: clang/lib/CodeGen/CodeGenABITypes.cpp
===
--- clang/lib/CodeGen/CodeGenABITypes.cpp
+++ clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -115,3 +115,16 @@
  const FieldDecl *FD) {
   return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
 }
+
+llvm::Value *CodeGen::getCXXDestructorImplicitParam(
+CodeGenModule , llvm::BasicBlock *InsertBlock,
+llvm::BasicBlock::iterator InsertPoint, const CXXDestructorDecl 

[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82928#2126018 , @fhahn wrote:

> Looks like this causes a bunch of build bot failures, e.g 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b
>
> It would be great if you could take a look.


Let me revert it for now while fixing it. If you could accept: 
https://reviews.llvm.org/D82984


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928



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


[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can the missing bit just be added?  It seems to me that frontends ought to be 
able to emit the obvious intrinsic for the semantic operation here rather than 
having to second-guess the backend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663



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


[PATCH] D82781: [OpenCL] Fix missing address space deduction in template variables

2020-07-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Seems like you shouldn't do it earlier if the type is dependent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82781



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


[PATCH] D82984: Revert "[Coroutines] Fix code coverage for coroutine"

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
lxfind added reviewers: fhahn, modocache.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
lxfind abandoned this revision.
lxfind added a comment.

Fix up in https://reviews.llvm.org/D82986


This reverts commit 565e37c7702d181804c12d36b6010c513c9b3417 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82984

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
-
-namespace std::experimental {
-template 
-struct coroutine_traits;
-
-template 
-struct coroutine_handle {
-  coroutine_handle() = default;
-  static coroutine_handle from_address(void *) noexcept { return {}; }
-};
-template <>
-struct coroutine_handle {
-  static coroutine_handle from_address(void *) { return {}; }
-  coroutine_handle() = default;
-  template 
-  coroutine_handle(coroutine_handle) noexcept {}
-};
-} // namespace std::experimental
-
-struct suspend_always {
-  bool await_ready() noexcept;
-  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
-  void await_resume() noexcept;
-};
-
-template <>
-struct std::experimental::coroutine_traits {
-  struct promise_type {
-int get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend() noexcept;
-void return_value(int);
-  };
-};
-
-// CHECK-LABEL: _Z2f1i:
-int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
-  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
-++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
-  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
-co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
-  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
-  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
-} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,18 +908,6 @@
 terminateRegion(S);
   }
 
-  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
-extendRegion(S);
-Visit(S->getBody());
-  }
-
-  void VisitCoreturnStmt(const CoreturnStmt *S) {
-extendRegion(S);
-if (S->getOperand())
-  Visit(S->getOperand());
-terminateRegion(S);
-  }
-
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- clang/test/CoverageMapping/coroutine.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
-
-namespace std::experimental {
-template 
-struct coroutine_traits;
-
-template 
-struct coroutine_handle {
-  coroutine_handle() = default;
-  static coroutine_handle from_address(void *) noexcept { return {}; }
-};
-template <>
-struct coroutine_handle {
-  static coroutine_handle from_address(void *) { return {}; }
-  coroutine_handle() = default;
-  template 
-  coroutine_handle(coroutine_handle) noexcept {}
-};
-} // namespace std::experimental
-
-struct suspend_always {
-  bool await_ready() noexcept;
-  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
-  void await_resume() noexcept;
-};
-
-template <>
-struct std::experimental::coroutine_traits {
-  struct promise_type {
-int get_return_object();
-suspend_always initial_suspend();
-suspend_always final_suspend() noexcept;
-void return_value(int);
-  };
-};
-
-// CHECK-LABEL: _Z2f1i:
-int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
-  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
-++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
-  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
-co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)
-  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
-  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
-} // CHECK-NEXT: File 0, 

[clang] ddcf063 - [Coroutines] Fix test breakage in D82928

2020-07-01 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2020-07-01T11:17:21-07:00
New Revision: ddcf063dd52ff1f30ac27d6f9abce6a45685a2b2

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

LOG: [Coroutines] Fix test breakage in D82928

Summary: The test file in D82928 generated temp files within the test 
directory, causing test failures. Fix it.

Reviewers: modocache, fhahn

Reviewed By: modocache

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/CoverageMapping/coroutine.cpp

Removed: 




diff  --git a/clang/test/CoverageMapping/coroutine.cpp 
b/clang/test/CoverageMapping/coroutine.cpp
index ec1d64e0f970..c149eefd1f01 100644
--- a/clang/test/CoverageMapping/coroutine.cpp
+++ b/clang/test/CoverageMapping/coroutine.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s -o - | FileCheck %s
 
 namespace std::experimental {
 template 



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


[clang] e7c5da5 - [CodeGen] Add public function to emit C++ destructor call.

2020-07-01 Thread via cfe-commits

Author: zoecarver
Date: 2020-07-01T11:01:23-07:00
New Revision: e7c5da57a5f3fdb6649ff92cb8ba0ce3c4978668

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

LOG: [CodeGen] Add public function to emit C++ destructor call.

Adds `CodeGen::getCXXDestructorImplicitParam`, to retrieve a C++ destructor's 
implicit parameter (after the "this" pointer) based on the ABI in the given 
CodeGenModule.

This will allow other frontends (Swift, for example) to easily emit calls to 
object destructors with correct ABI semantics and calling convetions.

This is needed for Swift C++ interop. Here's the corresponding Swift change: 
https://github.com/apple/swift/pull/32291

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

Added: 


Modified: 
clang/include/clang/CodeGen/CodeGenABITypes.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/CodeGen/CGCXXABI.h
clang/lib/CodeGen/CodeGenABITypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 0201f92074ec..3c745fadbe78 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -25,7 +25,9 @@
 
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/ABI.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "llvm/IR/BasicBlock.h"
 
 namespace llvm {
 class AttrBuilder;
@@ -40,6 +42,7 @@ class Type;
 namespace clang {
 class ASTContext;
 class CXXConstructorDecl;
+class CXXDestructorDecl;
 class CXXRecordDecl;
 class CXXMethodDecl;
 class CodeGenOptions;
@@ -90,6 +93,12 @@ const CGFunctionInfo (CodeGenModule 
,
 ImplicitCXXConstructorArgs
 getImplicitCXXConstructorArgs(CodeGenModule , const CXXConstructorDecl *D);
 
+llvm::Value *
+getCXXDestructorImplicitParam(CodeGenModule , llvm::BasicBlock 
*InsertBlock,
+  llvm::BasicBlock::iterator InsertPoint,
+  const CXXDestructorDecl *D, CXXDtorType Type,
+  bool ForVirtualBase, bool Delegating);
+
 /// Returns null if the function type is incomplete and can't be lowered.
 llvm::FunctionType *convertFreeFunctionType(CodeGenModule ,
 const FunctionDecl *FD);

diff  --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index bb40dace8a84..474e5c1e4c6a 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -28,7 +28,6 @@ namespace clang {
 
 namespace CodeGen {
   class ABIArgInfo;
-  class Address;
   class CGCXXABI;
   class CGFunctionInfo;
   class CodeGenFunction;

diff  --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 2b7f45fcab98..f5b3fc13bbbd 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -402,6 +402,13 @@ class CGCXXABI {
  CXXCtorType Type, bool ForVirtualBase,
  bool Delegating, CallArgList );
 
+  /// Get the implicit (second) parameter that comes after the "this" pointer,
+  /// or nullptr if there is isn't one.
+  virtual llvm::Value *
+  getCXXDestructorImplicitParam(CodeGenFunction ,
+const CXXDestructorDecl *DD, CXXDtorType Type,
+bool ForVirtualBase, bool Delegating) = 0;
+
   /// Emit the destructor call.
   virtual void EmitDestructorCall(CodeGenFunction ,
   const CXXDestructorDecl *DD, CXXDtorType 
Type,

diff  --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index 322cf45c47af..d3a16a1d5acc 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -115,3 +115,16 @@ unsigned CodeGen::getLLVMFieldNumber(CodeGenModule ,
  const FieldDecl *FD) {
   return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
 }
+
+llvm::Value *CodeGen::getCXXDestructorImplicitParam(
+CodeGenModule , llvm::BasicBlock *InsertBlock,
+llvm::BasicBlock::iterator InsertPoint, const CXXDestructorDecl *D,
+CXXDtorType Type, bool ForVirtualBase, bool Delegating) {
+  CodeGenFunction CGF(CGM, /*suppressNewContext=*/true);
+  CGF.CurCodeDecl = D;
+  CGF.CurFuncDecl = D;
+  CGF.CurFn = InsertBlock->getParent();
+  CGF.Builder.SetInsertPoint(InsertBlock, InsertPoint);
+  return CGM.getCXXABI().getCXXDestructorImplicitParam(
+  CGF, D, Type, ForVirtualBase, Delegating);
+}

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 2829877cfe5d..80de2a6e3950 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ 

[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82928#2126018 , @fhahn wrote:

> Looks like this causes a bunch of build bot failures, e.g 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b
>
> It would be great if you could take a look.


Looks like it's creating a tmp file within the test dir. Let me take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928



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


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Looks like this causes a bunch of build bot failures, e.g 
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b

It would be great if you could take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928



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


[PATCH] D82392: [CodeGen] Add public function to emit C++ destructor call.

2020-07-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall 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/D82392/new/

https://reviews.llvm.org/D82392



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


[PATCH] D82791: [lit] Improve lit's output with default settings and --verbose.

2020-07-01 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 274865.
varungandhi-apple added a comment.

Rebase after changes in D82808 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82791

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/utils/lit/lit/LitConfig.py
  llvm/utils/lit/lit/OutputSettings.py
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/cl_arguments.py
  llvm/utils/lit/lit/display.py
  llvm/utils/lit/lit/main.py
  llvm/utils/lit/tests/shtest-format.py
  llvm/utils/lit/tests/shtest-run-at-line.py
  llvm/utils/lit/tests/unittest-failing-locator.py

Index: llvm/utils/lit/tests/unittest-failing-locator.py
===
--- /dev/null
+++ llvm/utils/lit/tests/unittest-failing-locator.py
@@ -0,0 +1,122 @@
+# Check that the locate_last_failing_run_line function works as expected.
+
+# RUN: %{python} %s
+# END.
+
+import unittest
+
+from lit.TestRunner import locate_last_run_line
+
+class TestRunLineLocatorHeuristics(unittest.TestCase):
+
+def test_basic(self):
+# from a script like
+# RUN: echo Hello 1>&2
+basic = (
+"+ : 'RUN: at line 1'\n"
+"+ echo Hello 1>&2\n"
+"+ Hello\n"
+)
+line_start, substr = locate_last_run_line(basic)
+self.assertEqual(line_start, 0)
+self.assertEqual(substr, "RUN: at line 1")
+
+def test_multiple(self):
+# from a script like
+# RUN: echo Hello 1>&2
+# RUN: false
+multiple = (
+"+ : 'RUN: at line 1'\n"
+"+ echo Hello 1>&2\n"
+"+ Hello\n"
+"+ : 'RUN: at line 2'\n"
+"+ false\n"
+)
+line_start, substr = locate_last_run_line(multiple)
+self.assertEqual(line_start, multiple.rfind("+ :"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_varying_prefix(self):
+# from a script like
+# RUN: echo Hello 1>&2
+# RUN: false
+#
+# in a hypothetical shell which prints line-numbers on 'set +x'
+# (as an example of something that varies)
+varying_prefix = (
+"+ 1 : 'RUN: at line 1'\n"
+"+ 2 echo Hello 1>&2\n"
+"+ Hello\n"
+"+ 3 : 'RUN: at line 2'\n"
+"+ 4 false\n"
+)
+line_start, substr = locate_last_run_line(varying_prefix)
+self.assertEqual(line_start, varying_prefix.rfind("+ 3"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_confusing_basic(self):
+# from a script like
+# RUN: echo 'RUN: at line 10' 1>&2
+confusing_basic = (
+"+ : 'RUN: at line 1'\n"
+"+ echo 'RUN: at line 10'\n"
+"RUN: at line 10\n"
+)
+line_start, substr = locate_last_run_line(confusing_basic)
+# FIXME: These should both be equal ideally.
+self.assertNotEqual(line_start, 0)
+self.assertNotEqual(substr, "RUN: at line 1")
+
+def test_confusing_multiple(self):
+# from a script like
+# RUN: echo 'RUN: at line 10' 1>&2
+# RUN: false
+confusing_multiple = (
+"+ : 'RUN: at line 1'\n"
+"+ echo 'RUN: at line 10'\n"
+"RUN: at line 10\n"
+"+ : 'RUN: at line 2'\n"
+"+ false\n"
+)
+line_start, substr = locate_last_run_line(confusing_multiple)
+self.assertEqual(line_start, confusing_multiple.rfind("+ :"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_confusing_varying_prefix_1(self):
+# from a script like
+# RUN: echo 'RUN: at line 10' 1>&2
+# RUN: false
+#
+# in a hypothetical shell which prints line-numbers on 'set +x'
+# (as an example of something that varies)
+confusing_varying_prefix = (
+"+ 1 : 'RUN: at line 1'\n"
+"+ 2 echo 'RUN: at line 10'\n"
+"RUN: at line 10\n"
+"+ 3 : 'RUN: at line 2'\n"
+"+ 4 false\n"
+)
+line_start, substr = locate_last_run_line(confusing_varying_prefix)
+self.assertEqual(line_start, confusing_varying_prefix.rfind("+ 3"))
+self.assertEqual(substr, "RUN: at line 2")
+
+def test_confusing_varying_prefix_2(self):
+# from a script like
+# RUN: true
+# RUN: not echo 'RUN: at line 100'
+#
+# in a hypothetical shell which prints line-numbers on 'set +x'
+# (as an example of something that varies)
+confusing_varying_prefix = (
+"+ 1 : 'RUN: at line 1'\n"
+"+ 2 true\n"
+"+ 3 : 'RUN: at line 2'\n"
+"+ 4 not echo 'RUN: at line 100'\n"
+"+ RUN: at line 100\n"
+)
+line_start, substr = locate_last_run_line(confusing_varying_prefix)
+# 

[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-07-01 Thread Max Moroz via Phabricator via cfe-commits
Dor1s added a comment.

If we still decide to proceed with this, would it make sense to expand it to 
`sanitizer_coverage` based on any sancov instrumentation being enabled? As you 
mentioned in the description, there might be users who manually enable certain 
sancov flags. I think it's good to be able to support those usecases too   
(e.g. other fuzzing engines).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82926



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


[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-07-01 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

In D82926#2125950 , @hctim wrote:

> So - the `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` flag is a property of the 
> build system and not that of the compiler. There are some places (android) 
> where enabling `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` globally changes 
> the behaviour of large amounts of libraries in ways that break the build 
> system.
>
> Having this flag allows us to make targeted compile-time changes to libc 
> based on sancov that don't require enabling 
> `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` across the entire build system.


Shouldn't we be fixing the fuzzing build for Android then?  
`FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is what we use everywhere else, so I 
don't like the idea of making a new flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82926



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


[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-07-01 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

So - the `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` flag is a property of the 
build system and not that of the compiler. There are some places (android) 
where enabling `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` globally changes the 
behaviour of large amounts of libraries in ways that break the build system.

Having this flag allows us to make targeted compile-time changes to libc based 
on sancov that don't require enabling 
`FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` across the entire build system.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82926



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


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG565e37c7702d: [Coroutines] Fix code coverage for coroutine 
(authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===

[PATCH] D82940: [ASTReader][ASTWriter][PCH][Modules] Fix (de)serialization of SwitchCases

2020-07-01 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D82940#2125183 , @riccibruno wrote:

> > I'm not certain I understand, but I'm removing my LG while we figure it 
> > out. Can you expound a bit further?
>
> Take a look at the AST dump of a small modification of the reduced test case 
> which doesn't trigger the assertion:
>
>   void should_not_crash_with_switch_in_lambda() {
> switch (1)
> default:;
> auto f = [] {
>   switch (1)
>   default:;
> };
>   }
>
>
> Before the serialization of `LambdaExpr` for the `LambdaExpr *E`, we have 
> `E->getBody() == E->getCallOperator()->getBody()`.
>  After serialization this is not true anymore because we are writing and 
> reading the body directly when visiting the `LambdaExpr`
>  (the captures have the same problem).


The same is true in case of the simplest lambda example:

  void foo() {   // line 11
  []{};
  }

The AST that we got from the Parser has only one CompoundStmt node, but 
referenced in the CXXMethodDecl and added as a direct child to LambdaExpr:

  `-LambdaExpr 0x5643235372c8 
|-CXXRecordDecl 0x564323536c98  col:5 implicit class definition
| |-CXXMethodDecl 0x564323536dd8  col:5 constexpr operator() 
'auto () const -> void' inline
| | `-CompoundStmt 0x564323536e88 
`-CompoundStmt 0x564323536e88 

After serialization and deserialization, the CompoundStmt is just copied, 
notice the different pointer values:

  `-LambdaExpr 0x55a49f35f830 
|-CXXRecordDecl 0x55a49f35f860  col:5 imported implicit 
 class definition
| |-CXXMethodDecl 0x55a49f35fac8  col:5 imported constexpr 
operator() 'auto () const -> void' inline
| | `-CompoundStmt 0x55a49f360110 
`-CompoundStmt 0x55a49f35f820 

This suggests that we should prepare the ASTReader/ASTWriter to be able to 
handle references to Stmts similarly as it can already handle references to 
Decls (see `ASTWriter::DeclIDs`).
Does this sound as a good direction, should I move forward this way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82940



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


[clang] 565e37c - [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2020-07-01T10:11:40-07:00
New Revision: 565e37c7702d181804c12d36b6010c513c9b3417

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

LOG: [Coroutines] Fix code coverage for coroutine

Summary:
Previously, source-based coverage analysis does not work properly for coroutine.
This patch adds processing of coroutine body and co_return in the coverage 
analysis, so that we can handle them properly.
For coroutine body, we should only look at the actual function body and ignore 
the compiler-generated things; for co_return, we need to terminate the region 
similar to return statement.
Added a test, and confirms that it now works properly. (without this patch, the 
statement after the if statement will be treated wrongly)

Reviewers: lewissbaker, modocache, junparser

Reviewed By: modocache

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/CoverageMapping/coroutine.cpp

Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index cdbfc88e7b70..78b268f423cb 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@ struct CounterCoverageMappingBuilder
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())

diff  --git a/clang/test/CoverageMapping/coroutine.cpp 
b/clang/test/CoverageMapping/coroutine.cpp
new file mode 100644
index ..ec1d64e0f970
--- /dev/null
+++ b/clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-01 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 274855.
ellis added a comment.

Add `isLanguageVersionSupported` for Objective-C


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s bugprone-no-escape %t
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_time_s *dispatch_time_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
+
+extern dispatch_queue_t queue;
+
+void test_noescape_attribute(__attribute__((noescape)) int *p, int *q) {
+  dispatch_async(queue, ^{
+*p = 123;
+// CHECK-MESSAGES: :[[@LINE-2]]:25: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+// CHECK-MESSAGES: :[[@LINE-4]]:30: note: the 'noescape' attribute is declared here.
+  });
+
+  dispatch_after(456, queue, ^{
+*p = 789;
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+  });
+
+  dispatch_async(queue, ^{
+*q = 0;
+// CHECK-MESSAGES-NOT: :[[@LINE-2]]:25: warning: pointer 'q' with attribute 'noescape' is captured by an asynchronously-executed block
+  });
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
`bugprone-multiple-statement-macro `_,
+   `bugprone-no-escape `_, "Yes"
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - bugprone-no-escape
+
+bugprone-no-escape
+==
+
+Finds pointers with the ``noescape`` attribute that are captured by an
+asynchronously-executed block. The block arguments in ``dispatch_async()`` and
+``dispatch_after()`` are guaranteed to escape, so it is an error if a pointer with the
+``noescape`` attribute is captured by one of these blocks.
+
+The following is an example of an invalid use of the ``noescape`` attribute.
+
+  .. code-block:: objc
+void foo(__attribute__((noescape)) int *p) {
+  dispatch_async(queue, ^{
+*p = 123;
+  });
+});
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@
   result of a memory allocation function (``malloc()``, ``calloc()``,
   ``realloc()``, ``alloca()``) instead of its argument.
 
+- New :doc:`bugprone-no-escape
+  ` check.
+
+  Finds pointers with the ``noescape`` attribute that are captured by an
+  asynchronously-executed block.
+
 - New :doc:`bugprone-spuriously-wake-up-functions
   ` check.
 
@@ -201,14 +207,14 @@
   Now checks ``std::basic_string_view`` by default.
 
 - Improved :doc:`readability-else-after-return
-  ` check now supports a 
+  ` check now supports a
   `WarnOnConditionVariables` option to control whether to refactor condition
   variables where possible.
 
 - Improved :doc:`readability-identifier-naming
   ` check.
 
-  Now able to rename member references in class template definitions with 
+  Now able to rename member references in class template definitions with
   explicit access.
 
 - Improved :doc:`readability-qualified-auto
Index: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
@@ -0,0 +1,39 @@
+//===--- NoEscapeCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the 

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-01 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 274847.
jfb edited the summary of this revision.
jfb added a comment.

Overload a new builtin instead. For now I only did memcpy, to get feedback on 
the approach. I'll add other mem* functions if this makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
  clang/test/SemaOpenCL/to_addr_builtin.cl

Index: clang/test/SemaOpenCL/to_addr_builtin.cl
===
--- clang/test/SemaOpenCL/to_addr_builtin.cl
+++ clang/test/SemaOpenCL/to_addr_builtin.cl
@@ -15,7 +15,7 @@
   // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
   // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
-  // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
+  // expected-error@-5{{too many arguments to function call, expected 1, have 2}}
 #endif
 
   int x;
Index: clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -10,7 +10,7 @@
   read_pipe(p, );
   read_pipe(p, ptr);
   read_pipe(tmp, p);// expected-error {{first argument to 'read_pipe' must be a pipe type}}
-  read_pipe(p);   // expected-error {{invalid number of arguments to function: 'read_pipe'}}
+  read_pipe(p); // expected-error {{too few arguments to function call, expected 2 or 4, have 1}}
   read_pipe(p, rid, tmp, ptr);
   read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t' having '__private int')}}
   read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int' having '__private reserve_id_t')}}
@@ -39,7 +39,7 @@
   write_pipe(p, );
   write_pipe(p, ptr);
   write_pipe(tmp, p);// expected-error {{first argument to 'write_pipe' must be a pipe type}}
-  write_pipe(p);   // expected-error {{invalid number of arguments to function: 'write_pipe'}}
+  write_pipe(p); // expected-error {{too few arguments to function call, expected 2 or 4, have 1}}
   write_pipe(p, rid, tmp, ptr);
   write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t' having '__private int')}}
   write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int' having '__private reserve_id_t')}}
Index: clang/test/Sema/builtin-overloaded-memfns.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-overloaded-memfns.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions
+
+#define NULL (void *)0
+#define nullptr __nullptr
+using size_t = __SIZE_TYPE__;
+struct Intish {
+  int i;
+};
+struct TrivialCpy {
+  char buf[8];
+  TrivialCpy();
+  TrivialCpy(const TrivialCpy &) = default;
+};
+struct NotTrivialCpy {
+  char buf[8];
+  NotTrivialCpy();
+  NotTrivialCpy(const NotTrivialCpy &);
+};
+
+void memcpy_arg_count() {
+  __builtin_overloaded_memcpy();   // expected-error {{too few arguments to function call, expected 3, have 0}}
+  __builtin_overloaded_memcpy(0);  // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __builtin_overloaded_memcpy(0, 0);   // expected-error {{too few arguments to function call, expected 3, have 2}}
+  __builtin_overloaded_memcpy(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+}
+
+void memcpy_null(char *dst, const char *src, size_t size) {
+  __builtin_overloaded_memcpy(0, 0, 0);
+  __builtin_overloaded_memcpy(0, 0, size);
+  __builtin_overloaded_memcpy(dst, 0, 42);   // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(dst, 0, 42);   // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(dst, NULL, 42);// expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(dst, nullptr, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __builtin_overloaded_memcpy(0, src, 42);   // expected-warning {{null passed to a 

[PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods

2020-07-01 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder added a comment.

So the risk with that one is that if someone had say the `-didSomething` direct 
selector and that some UIKit/Apple SDK API now adds this as a thing that you 
use with CFNotification center for example, where you _need_ dynamism, then the 
uses of the API would warn all the time when the internal to the client project 
`-didSomething` is in scope.

So we ideally need a way to silence this warning, so at the very least this 
needs to be a new `-W` flag (on by default (?)) so that callers that have an 
issue can use a `_Pragma` at the call site to ignore the error for when it's 
legal.

I would suggest something like `-Wstrict-direct-dispatch` or something.


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

https://reviews.llvm.org/D82611



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


[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

2020-07-01 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a subscriber: aaron.ballman.
riccibruno added inline comments.



Comment at: clang/lib/AST/StmtPrinter.cpp:1159
+  case BuiltinType::UInt128:
+OS << "Ui128";
+break;

davidstone wrote:
> riccibruno wrote:
> > `i128` and `Ui128` are not valid integer literal suffix. The output of 
> > `StmtPrinter` is intended to be valid C++. Unfortunately here I think that 
> > your only choice is to print the high and low parts separately. 
> I'm confused. i8, Ui8, i16, and Ui16 are also not valid C++ suffixes, but 
> just a few lines up we use those. What am I missing here?
The literal suffixes `[u]i8, [u]i16, [u]i32, and [u]i64` are an MSVC extension 
(see `NumericLiteralParser::NumericLiteralParser` in `Lex/LiteralSupport.cpp`).

This does not explain why they are used even in non-ms compatibility mode
but at least there is some reason for their existence.

However I don't think that MSVC supports 128-bits integers (?), and clang 
certainly
does not support `[u]i128` so there is no reason to use them.

@aaron.ballman Do you know why are these suffixes used outside of 
ms-compatibility mode?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82880



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


[PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods

2020-07-01 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder added inline comments.



Comment at: clang/lib/Sema/SemaExprObjC.cpp:1230
 }
-
-static void HelperToDiagnoseDirectSelectorsExpr(Sema , SourceLocation AtLoc,
-Selector Sel,
+static void HelperToDiagnoseDirectSelectorsExpr(Sema , Selector Sel,
 ObjCMethodList ,

missing line between the functions?


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

https://reviews.llvm.org/D82611



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


[PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods

2020-07-01 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder added inline comments.



Comment at: clang/test/SemaObjC/potentially-direct-selector.m:84
+  (void)@selector(inBaseCat);
+  (void)@selector(inBaseCatImpl);
+  (void)@selector(inDerived);

I think this might be too weak, if we add a warning then maybe what we want is 
a tri-state:

`-Wstrict-direct-dispatch=none|self|all`

because I can see cases where the heuristic here would be too weak


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

https://reviews.llvm.org/D82611



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


[PATCH] D82930: [HIP] Fix rocm detection

2020-07-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(BinPath + "/.hipVersion");
+if (!VersionFile)

arsenm wrote:
> I don't think the detection should fail if this is missing
why? this file is unique to HIP installation. If it is missing, the 
installation is broken.


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

https://reviews.llvm.org/D82930



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


[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-07-01 Thread Max Moroz via Phabricator via cfe-commits
Dor1s added a comment.

What usecase(s) do you have for this in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82926



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


[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments

2020-07-01 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 274846.
njames93 added a comment.

Small refactor based on comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82706

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/ASTMatchers/ASTMatchersMacros.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  llvm/include/llvm/Support/Regex.h
  llvm/lib/Support/Regex.cpp

Index: llvm/lib/Support/Regex.cpp
===
--- llvm/lib/Support/Regex.cpp
+++ llvm/lib/Support/Regex.cpp
@@ -26,7 +26,7 @@
 
 Regex::Regex() : preg(nullptr), error(REG_BADPAT) {}
 
-Regex::Regex(StringRef regex, unsigned Flags) {
+Regex::Regex(StringRef regex, RegexFlags Flags) {
   unsigned flags = 0;
   preg = new llvm_regex();
   preg->re_endp = regex.end();
@@ -39,6 +39,9 @@
   error = llvm_regcomp(preg, regex.data(), flags|REG_PEND);
 }
 
+Regex::Regex(StringRef regex, unsigned Flags)
+: Regex(regex, static_cast(Flags)) {}
+
 Regex::Regex(Regex &) {
   preg = regex.preg;
   error = regex.error;
Index: llvm/include/llvm/Support/Regex.h
===
--- llvm/include/llvm/Support/Regex.h
+++ llvm/include/llvm/Support/Regex.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_SUPPORT_REGEX_H
 #define LLVM_SUPPORT_REGEX_H
 
+#include "llvm/ADT/BitmaskEnum.h"
 #include 
 
 struct llvm_regex;
@@ -26,20 +27,22 @@
 
   class Regex {
   public:
-enum {
-  NoFlags=0,
+enum RegexFlags : unsigned {
+  NoFlags = 0,
   /// Compile for matching that ignores upper/lower case distinctions.
-  IgnoreCase=1,
+  IgnoreCase = 1,
   /// Compile for newline-sensitive matching. With this flag '[^' bracket
   /// expressions and '.' never match newline. A ^ anchor matches the
   /// null string after any newline in the string in addition to its normal
   /// function, and the $ anchor matches the null string before any
   /// newline in the string in addition to its normal function.
-  Newline=2,
+  Newline = 2,
   /// By default, the POSIX extended regular expression (ERE) syntax is
   /// assumed. Pass this flag to turn on basic regular expressions (BRE)
   /// instead.
-  BasicRegex=4
+  BasicRegex = 4,
+
+  LLVM_MARK_AS_BITMASK_ENUM(BasicRegex)
 };
 
 Regex();
@@ -47,7 +50,8 @@
 ///
 /// \param Regex - referenced string is no longer needed after this
 /// constructor does finish.  Only its compiled form is kept stored.
-Regex(StringRef Regex, unsigned Flags = NoFlags);
+Regex(StringRef Regex, RegexFlags Flags = NoFlags);
+Regex(StringRef Regex, unsigned Flags);
 Regex(const Regex &) = delete;
 Regex =(Regex regex) {
   std::swap(preg, regex.preg);
Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -259,6 +259,15 @@
   EXPECT_TRUE(matches("unsigned X = sizeof(int);", MStmt));
   EXPECT_FALSE(matches("unsigned X = alignof(int);", MStmt));
 
+  Code =
+  R"query(namedDecl(matchesName("^::[ABC]*$", "IgnoreCase | BasicRegex")))query";
+  llvm::Optional MatchesName(
+  Parser::parseMatcherExpression(Code, nullptr, nullptr, ));
+  EXPECT_EQ("", Error.toStringFull());
+  M = MatchesName->unconditionalConvertTo();
+  EXPECT_TRUE(matches("unsigned AAACCBB;", M));
+  EXPECT_TRUE(matches("unsigned aaaccbb;", M));
+
   Code = "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))";
   EXPECT_TRUE(!Parser::parseMatcherExpression(Code, ).hasValue());
   EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
@@ -348,6 +357,26 @@
 "1:14: Incorrect type for arg 1. (Expected = string) != (Actual = "
 "String)",
 ParseMatcherWithError(R"query(decl(hasAttr("unrelated")))query"));
+  EXPECT_EQ(
+  "1:1: Error parsing argument 1 for matcher namedDecl.\n"
+  "1:11: Error building matcher matchesName.\n"
+  "1:33: Unknown value 'Ignorecase' for arg 2; did you mean 'IgnoreCase'",
+  ParseMatcherWithError(
+  R"query(namedDecl(matchesName("[ABC]*", "Ignorecase")))query"));
+  EXPECT_EQ(
+  "1:1: Error parsing argument 1 for matcher namedDecl.\n"
+  "1:11: Error building matcher matchesName.\n"
+  "1:33: Incorrect type for arg 2. (Expected = string) != (Actual = "
+  "String)",
+  ParseMatcherWithError(
+

[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

2020-07-01 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The problem is that `PathDiagnostic::Profile` does not use the uniqueing 
locations. Two `PathDiagnostic` objects with different uniqueing location but 
otherwise same data are counted as "same" and only one is kept 
(`BugReporter::FlushReport`). How to fix this?

- Add uniqueing locations to the profile. May have unexpected effects to other 
checkers.
- Change something in the leak bug reports to make these different. Probably 
the location can be set to the allocation site (but the full path should be 
reported). Or include name of the leaked symbol in the report, but it may not 
exists always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845



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


[PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid sloc

2020-07-01 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas marked an inline comment as done.
eduucaldas added inline comments.



Comment at: clang/lib/AST/ExprCXX.cpp:82
+  default:
+return getNumArgs() == 1;
+  }

riccibruno wrote:
> This will be true for `operator->`.
Thank you ! I had missed that! I'll propose a more robust solution. I'll 
probably split this patch. But I'll take care to subscribe you to anything 
related


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82954



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


[PATCH] D82388: move "basic" builtins to TableGen

2020-07-01 Thread Nathan Froyd via Phabricator via cfe-commits
froydnj added a comment.

FWIW, an in-progress tree for the proposed move for all the 
architecture-specific builtins is:

https://github.com/froydnj/llvm-project/tree/move-builtins-to-tablegen

I don't know if the ARM/NEON/SVE builtins will be easily movable.  It looks 
like they are separately generated from existing `.td` files; while you could 
generate `.td` files containing all the appropriate `Builtin` etc. definitions, 
you cannot have tablegen input depend on tablegen'd output in the general case 
due to:

https://github.com/llvm/llvm-project/blob/c83ec0a633583e5b12e0aeb70627eb35f7cd4847/llvm/cmake/modules/TableGen.cmake#L11-L35

in the non-Ninja case.  If you try, you get circular dependencies.  One could 
maybe hack around this by giving certain files different suffixes, but that 
feels gross.

I'm not sure how to address that issue.


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

https://reviews.llvm.org/D82388



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


[PATCH] D82314: [Coroutines] Optimize the lifespan of temporary co_await object

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82314#2124662 , @junparser wrote:

> In D82314#2124661 , @junparser wrote:
>
> > @lxfind This patch causes some mismatch when variable is used in both 
> > resume and destroy function. Besides, we should move this patch and the 
> > check in buildCoroutineFrame.
>
>
> @lxfind, Would you try to fix this? If you do not have time, then I'll try do 
> this. Thanks


Could you please help take a look, if you have a local repro? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314



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


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 274836.
lxfind added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ 

[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-01 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

[facepalm] Thank you. I carefully //wrote// a revised description, but forgot 
to upload it to this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-01 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D82659#2125618 , @clementval wrote:

> LGTM. So later the DEPENDS omp_gen that are in clang subdirectories could be 
> removed right?


That seems likely. I'm thinking what I should probably do is to polish up my 
checking script and try to get it into `llvm/utils` somewhere, and then it 
would be possible to make that kind of change and be //confident// that it 
wasn't removing a necessary dependency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Brian Gesiak via Phabricator via cfe-commits
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

Excellent, thanks for this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82928



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


[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-01 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

@simon_tatham Can you just update the description so it is consistent with your 
fix when it lands?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

2020-07-01 Thread David Stone via Phabricator via cfe-commits
davidstone marked an inline comment as done.
davidstone added inline comments.



Comment at: clang/lib/AST/StmtPrinter.cpp:1159
+  case BuiltinType::UInt128:
+OS << "Ui128";
+break;

riccibruno wrote:
> `i128` and `Ui128` are not valid integer literal suffix. The output of 
> `StmtPrinter` is intended to be valid C++. Unfortunately here I think that 
> your only choice is to print the high and low parts separately. 
I'm confused. i8, Ui8, i16, and Ui16 are also not valid C++ suffixes, but just 
a few lines up we use those. What am I missing here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82880



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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-07-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Just my 2 cents, but would it not be wise to introduce a test case that runs 
the 2 aforementioned checks together demonstrating how they interact with each 
other. This will also force compliance if either check is updated down the line.


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

https://reviews.llvm.org/D71199



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:125
+CheckFactories.registerCheck(
+"bugprone-no-escape");
 CheckFactories.registerCheck(

ellis wrote:
> Not sure if we want to lint this line because it was generated by 
> `clang-tidy/add_new_check.py` and every other `registerCheck` line is 
> formatted in the same way.
They should be formatted, but we don't pipe the changes through clang-format in 
the `add_new_check.py` script. only 8/21 clang-tidy module files are 
incorrectly formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-01 Thread Valentin Clement via Phabricator via cfe-commits
clementval accepted this revision.
clementval added a comment.

LGTM. So later the DEPENDS omp_gen that are in clang subdirectories could be 
removed right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D82891: [clangd] Fix race in FileIndex that sometimes temporarily lost updates.

2020-07-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked 2 inline comments as done.
Closed by commit rGc5263a4e84cc: [clangd] Fix race in FileIndex that sometimes 
temporarily lost updates. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D82891?vs=274532=274818#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82891

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -22,6 +22,7 @@
 #include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
+#include "support/Threading.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexSymbol.h"
@@ -509,6 +510,31 @@
   EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("b")));
 }
 
+// Verifies that concurrent calls to updateMain don't "lose" any updates.
+TEST(FileIndexTest, Threadsafety) {
+  FileIndex M;
+  Notification Go;
+
+  constexpr int Count = 10;
+  {
+// Set up workers to concurrently call updateMain() with separate files.
+AsyncTaskRunner Pool;
+for (unsigned I = 0; I < Count; ++I) {
+  auto TU = TestTU::withCode(llvm::formatv("int xxx{0};", I).str());
+  TU.Filename = llvm::formatv("x{0}.c", I).str();
+  Pool.runAsync(TU.Filename, [&, Filename(testPath(TU.Filename)),
+  AST(TU.build())]() mutable {
+Go.wait();
+M.updateMain(Filename, AST);
+  });
+}
+// On your marks, get set...
+Go.notify();
+  }
+
+  EXPECT_THAT(runFuzzyFind(M, "xxx"), ::testing::SizeIs(Count));
+}
+
 TEST(FileShardedIndexTest, Sharding) {
   auto AHeaderUri = URI::create(testPath("a.h")).toString();
   auto BHeaderUri = URI::create(testPath("b.h")).toString();
Index: clang-tools-extra/clangd/index/Symbol.h
===
--- clang-tools-extra/clangd/index/Symbol.h
+++ clang-tools-extra/clangd/index/Symbol.h
@@ -186,7 +186,8 @@
   const_iterator end() const { return Symbols.end(); }
   const_iterator find(const SymbolID ) const;
 
-  size_t size() const { return Symbols.size(); }
+  using size_type = size_t;
+  size_type size() const { return Symbols.size(); }
   bool empty() const { return Symbols.empty(); }
   // Estimates the total memory usage.
   size_t bytes() const {
Index: clang-tools-extra/clangd/index/FileIndex.h
===
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -81,9 +81,11 @@
   /// The index keeps the slabs alive.
   /// Will count Symbol::References based on number of references in the main
   /// files, while building the index with DuplicateHandling::Merge option.
+  /// Version is populated with an increasing sequence counter.
   std::unique_ptr
   buildIndex(IndexType,
- DuplicateHandling DuplicateHandle = DuplicateHandling::PickOne);
+ DuplicateHandling DuplicateHandle = DuplicateHandling::PickOne,
+ size_t *Version = nullptr);
 
 private:
   struct RefSlabAndCountReferences {
@@ -92,6 +94,7 @@
   };
   mutable std::mutex Mutex;
 
+  size_t Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
   llvm::StringMap> RelatiosSnapshot;
@@ -136,6 +139,12 @@
   // (Note that symbols *only* in the main file are not indexed).
   FileSymbols MainFileSymbols;
   SwapIndex MainFileIndex;
+
+  // While both the FileIndex and SwapIndex are threadsafe, we need to track
+  // versions to ensure that we don't overwrite newer indexes with older ones.
+  std::mutex UpdateIndexMu;
+  unsigned MainIndexVersion = 0;
+  unsigned PreambleIndexVersion = 0;
 };
 
 using SlabTuple = std::tuple;
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -229,6 +229,7 @@
  std::unique_ptr Relations,
  bool CountReferences) {
   std::lock_guard Lock(Mutex);
+  ++Version;
   if (!Symbols)
 SymbolsSnapshot.erase(Key);
   else
@@ -248,7 +249,8 @@
 }
 
 std::unique_ptr
-FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle) {
+FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
+size_t *Version) {
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> 

[PATCH] D82967: [analyzer][tests] Measure peak memory consumption for every project

2020-07-01 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82967

Files:
  clang/utils/analyzer/Dockerfile
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/SATestUtils.py
  clang/utils/analyzer/requirements.txt

Index: clang/utils/analyzer/requirements.txt
===
--- /dev/null
+++ clang/utils/analyzer/requirements.txt
@@ -0,0 +1,2 @@
+humanize
+psutil
Index: clang/utils/analyzer/SATestUtils.py
===
--- clang/utils/analyzer/SATestUtils.py
+++ clang/utils/analyzer/SATestUtils.py
@@ -1,8 +1,9 @@
 import os
 import sys
+import time
 
 from subprocess import CalledProcessError, check_call
-from typing import List, IO, Optional
+from typing import List, IO, Optional, Tuple
 
 
 def which(command: str, paths: Optional[str] = None) -> Optional[str]:
@@ -47,6 +48,87 @@
 return ext in (".i", ".ii", ".c", ".cpp", ".m", "")
 
 
+def time_to_str(time: float) -> str:
+"""
+Convert given time in seconds into a human-readable string.
+"""
+return f"{time:.2f}s"
+
+
+def memory_to_str(memory: int) -> str:
+"""
+Convert given number of bytes into a human-readable string.
+"""
+if memory:
+try:
+import humanize
+return humanize.naturalsize(memory, gnu=True)
+except ImportError:
+# no formatter installed, let's keep it in bytes
+return f"{memory}B"
+
+# If memory is 0, we didn't succeed measuring it.
+return "N/A"
+
+
+def check_and_measure_call(*popenargs, **kwargs) -> Tuple[float, int]:
+"""
+Run command with arguments.  Wait for command to complete and measure
+execution time and peak memory consumption.
+If the exit code was zero then return, otherwise raise
+CalledProcessError.  The CalledProcessError object will have the
+return code in the returncode attribute.
+
+The arguments are the same as for the call and check_call functions.
+
+Return a tuple of execution time and peak memory.
+"""
+peak_mem = 0
+start_time = time.time()
+
+try:
+import psutil as ps
+
+def get_memory(process: ps.Process) -> int:
+mem = 0
+
+# we want to gather memory usage from all of the child processes
+descendants = list(process.children(recursive=True))
+descendants.append(process)
+
+for subprocess in descendants:
+try:
+mem += subprocess.memory_info().rss
+except (ps.NoSuchProcess, ps.AccessDenied):
+continue
+
+return mem
+
+with ps.Popen(*popenargs, **kwargs) as process:
+# while the process is running calculate resource utilization.
+while (process.is_running() and
+   process.status() != ps.STATUS_ZOMBIE):
+# track the peak utilization of the process
+peak_mem = max(peak_mem, get_memory(process))
+time.sleep(.5)
+
+if process.is_running():
+process.kill()
+
+if process.returncode != 0:
+cmd = kwargs.get("args")
+if cmd is None:
+cmd = popenargs[0]
+raise CalledProcessError(process.returncode, cmd)
+
+except ImportError:
+# back off to subprocess if we don't have psutil installed
+peak_mem = 0
+check_call(*popenargs, **kwargs)
+
+return time.time() - start_time, peak_mem
+
+
 def run_script(script_path: str, build_log_file: IO, cwd: str,
out=sys.stdout, err=sys.stderr, verbose: int = 0):
 """
Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -43,7 +43,7 @@
 variable. It should contain a comma separated list.
 """
 import CmpRuns
-import SATestUtils
+import SATestUtils as utils
 from ProjectMap import DownloadType, ProjectInfo
 
 import glob
@@ -63,7 +63,7 @@
 # and this is we can shush that false positive
 from plistlib import InvalidFileException  # type:ignore
 from subprocess import CalledProcessError, check_call
-from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING
+from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING, Tuple
 
 
 ###
@@ -115,7 +115,7 @@
 if 'CC' in os.environ:
 cc_candidate: Optional[str] = os.environ['CC']
 else:
-cc_candidate = SATestUtils.which("clang", os.environ['PATH'])
+cc_candidate = 

[PATCH] D82968: [VE] Rename VE toolchain source files

2020-07-01 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: LLVM, VE.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Rename VE.cpp and VE.h to VEToolchain.cpp and VEToolchain.h respectively
in order to avoid link warning message.  Linker warns that VE.cpp.o and
Arch/VE.cpp.o have the same name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82968

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/VE.cpp
  clang/lib/Driver/ToolChains/VE.h
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/lib/Driver/ToolChains/VEToolchain.h

Index: clang/lib/Driver/ToolChains/VE.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/VE.h
@@ -1,66 +0,0 @@
-//===--- VE.h - VE ToolChain Implementations *- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
-#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
-
-#include "Linux.h"
-#include "clang/Driver/ToolChain.h"
-
-namespace clang {
-namespace driver {
-namespace toolchains {
-
-class LLVM_LIBRARY_VISIBILITY VEToolChain : public Linux {
-public:
-  VEToolChain(const Driver , const llvm::Triple ,
-  const llvm::opt::ArgList );
-
-protected:
-  Tool *buildAssembler() const override;
-  Tool *buildLinker() const override;
-
-public:
-  bool isPICDefault() const override;
-  bool isPIEDefault() const override;
-  bool isPICDefaultForced() const override;
-  bool SupportsProfiling() const override;
-  bool hasBlocksRuntime() const override;
-  void
-  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
-llvm::opt::ArgStringList ) const override;
-  void
-  addClangTargetOptions(const llvm::opt::ArgList ,
-llvm::opt::ArgStringList ,
-Action::OffloadKind DeviceOffloadKind) const override;
-  void AddClangCXXStdlibIncludeArgs(
-  const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const override;
-  void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const override;
-
-  llvm::ExceptionHandling
-  GetExceptionModel(const llvm::opt::ArgList ) const override;
-
-  CXXStdlibType
-  GetCXXStdlibType(const llvm::opt::ArgList ) const override {
-return ToolChain::CST_Libcxx;
-  }
-
-  RuntimeLibType GetDefaultRuntimeLibType() const override {
-return ToolChain::RLT_CompilerRT;
-  }
-
-  const char *getDefaultLinker() const override { return "nld"; }
-};
-
-} // end namespace toolchains
-} // end namespace driver
-} // end namespace clang
-
-#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
Index: clang/lib/Driver/ToolChains/VEToolchain.cpp
===
--- clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#include "VE.h"
+#include "VEToolchain.h"
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -43,7 +43,7 @@
 #include "ToolChains/RISCVToolchain.h"
 #include "ToolChains/Solaris.h"
 #include "ToolChains/TCE.h"
-#include "ToolChains/VE.h"
+#include "ToolChains/VEToolchain.h"
 #include "ToolChains/WebAssembly.h"
 #include "ToolChains/XCore.h"
 #include "clang/Basic/Version.h"
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -68,7 +68,7 @@
   ToolChains/RISCVToolchain.cpp
   ToolChains/Solaris.cpp
   ToolChains/TCE.cpp
-  ToolChains/VE.cpp
+  ToolChains/VEToolchain.cpp
   ToolChains/WebAssembly.cpp
   ToolChains/XCore.cpp
   ToolChains/PPCLinux.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82964: [clangd] Config: loading and caching config from disk.

2020-07-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, jfb, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.

The Provider extension point is designed to also be implemented by
ClangdLSPServer (to inject config-over-lsp) and likely by embedders.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82964

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigProvider.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -0,0 +1,154 @@
+//===-- ConfigProviderTests.cpp ---===//
+//
+// 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 "Config.h"
+#include "ConfigProvider.h"
+#include "ConfigTesting.h"
+#include "TestFS.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace config {
+namespace {
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+
+// Provider that appends an arg to compile flags.
+// The arg is prefix, where N is the times getFragments() was called.
+// It also yields a diagnostic each time it's called.
+class FakeProvider : public Provider {
+  std::string Prefix;
+  mutable std::atomic Index = {0};
+
+  std::vector
+  getFragments(const Params &, DiagnosticCallback DC) const override {
+DC(llvm::SMDiagnostic("", llvm::SourceMgr::DK_Error, Prefix));
+CompiledFragment F =
+[Arg(Prefix + std::to_string(++Index))](const Params , Config ) {
+  C.CompileFlags.Edits.push_back(
+  [Arg](std::vector ) { Argv.push_back(Arg); });
+  return true;
+};
+return {F};
+  }
+
+public:
+  FakeProvider(llvm::StringRef Prefix) : Prefix(Prefix) {}
+};
+
+std::vector getAddedArgs(Config ) {
+  std::vector Argv;
+  for (auto  : C.CompileFlags.Edits)
+Edit(Argv);
+  return Argv;
+}
+
+// The provider from combine() should invoke its providers in order, and not
+// cache their results.
+TEST(ProviderTest, Combine) {
+  CapturedDiags Diags;
+  std::vector> Providers;
+  Providers.push_back(std::make_unique("foo"));
+  Providers.push_back(std::make_unique("bar"));
+  auto Combined = Provider::combine(std::move(Providers));
+  Config Cfg = Combined->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("foo"), DiagMessage("bar")));
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo1", "bar1"));
+  Diags.Diagnostics.clear();
+
+  Cfg = Combined->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("foo"), DiagMessage("bar")));
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo2", "bar2"));
+}
+
+const char *AddFooWithErr = R"yaml(
+CompileFlags:
+  Add: foo
+  Unknown: 42
+)yaml";
+
+const char *AddBarBaz = R"yaml(
+CompileFlags:
+  Add: bar
+---
+CompileFlags:
+  Add: baz
+)yaml";
+
+TEST(ProviderTest, FromYAMLFile) {
+  MockFS FS;
+  FS.Files["foo.yaml"] = AddFooWithErr;
+
+  CapturedDiags Diags;
+  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), FS);
+  auto Cfg = P->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("Unknown CompileFlags key Unknown")));
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
+  Diags.Diagnostics.clear();
+
+  Cfg = P->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "Cached, not re-parsed";
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
+
+  FS.Files["foo.yaml"] = AddBarBaz;
+  Cfg = P->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "New config, no errors";
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
+
+  FS.Files.erase("foo.yaml");
+  Cfg = P->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "Missing file is not an error";
+  EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
+}
+
+TEST(ProviderTest, FromAncestorRelativeYAMLFiles) {
+  MockFS FS;
+  FS.Files["a/b/c/foo.yaml"] = AddBarBaz;
+  FS.Files["a/foo.yaml"] = AddFooWithErr;
+
+  std::string ABCPath = testPath("a/b/c/d/test.cc");
+  Params ABCParams;
+  ABCParams.Path = ABCPath;
+  std::string APath = testPath("a/b/e/f/test.cc");
+  Params AParams;
+  AParams.Path = APath;
+
+  CapturedDiags Diags;
+  auto P = 

  1   2   3   >