[PATCH] D72824: [X86] Add combination for fma and fneg on X86 under strict FP.

2020-01-16 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

FMA4 tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72824



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


[PATCH] D72824: [X86] Add combination for fma and fneg on X86 under strict FP.

2020-01-16 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 238425.
pengfei added a comment.

Add FMA4 tests. Thanks @RKSimon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72824

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrFMA.td
  llvm/lib/Target/X86/X86InstrFragmentsSIMD.td
  llvm/test/CodeGen/X86/fp-intrinsics-fma.ll

Index: llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
===
--- llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
+++ llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
@@ -1,7 +1,326 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -O3 -mtriple=x86_64-pc-linux < %s | FileCheck %s --check-prefixes=COMMON,NOFMA
-; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma < %s | FileCheck %s --check-prefixes=COMMON,FMA
-; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+avx512f < %s | FileCheck %s --check-prefixes=COMMON,FMA
+; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma < %s | FileCheck %s --check-prefixes=COMMON,FMA,FMA-AVX1
+; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma4 < %s | FileCheck %s --check-prefixes=COMMON,FMA4
+; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+avx512f < %s | FileCheck %s --check-prefixes=COMMON,FMA,FMA-AVX512
+
+define float @f1(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f1:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm0
+; NOFMA-NEXT:callq fmaf
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f1:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfnmadd213ss {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f1:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfnmaddss %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg float %0
+  %result = call float @llvm.experimental.constrained.fma.f32(float %3, float %1, float %2,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %result
+}
+
+define double @f2(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f2:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm0
+; NOFMA-NEXT:callq fma
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f2:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfnmadd213sd {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f2:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfnmaddsd %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg double %0
+  %result = call double @llvm.experimental.constrained.fma.f64(double %3, double %1, double %2,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  ret double %result
+}
+
+define float @f3(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f3:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm2
+; NOFMA-NEXT:callq fmaf
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f3:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfmsub213ss {{.*#+}} xmm0 = (xmm1 * xmm0) - xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f3:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfmsubss %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg float %2
+  %result = call float @llvm.experimental.constrained.fma.f32(float %0, float %1, float %3,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %result
+}
+
+define double @f4(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f4:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm2
+; NOFMA-NEXT:callq fma
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f4:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfmsub213sd {{.*#+}} xmm0 = (xmm1 * xmm0) - xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f4:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfmsubsd %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg double %2
+  %result = call double @llvm.experimental.constrained.fma.f64(d

[PATCH] D72825: [NFC] Fix options name typo

2020-01-16 Thread Jim Lin via Phabricator via cfe-commits
Jim created this revision.
Jim added reviewers: efriedma, MaskRay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Jim edited the summary of this revision.

1. -ftree_loop_im -> -ftree-loop-im
2. -ftree_loop_ivcanon -> -ftree-loop-ivcanon
3. -ftree_loop_linear -> -ftree-loop-linear


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72825

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -292,9 +292,9 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
+// RUN: -ftree-loop-im\
+// RUN: -ftree-loop-ivcanon   \
+// RUN: -ftree-loop-linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -432,9 +432,9 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not 
supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree-loop-im' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree-loop-ivcanon' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree-loop-linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not 
supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3297,9 +3297,9 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, 
Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, 
Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  
Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  
Group;
-defm tree_loop_linear : BooleanFFlag<"tree_loop_linear">,  
Group;
+defm tree_loop_im : BooleanFFlag<"tree-loop-im">,  
Group;
+defm tree_loop_ivcanon : BooleanFFlag<"tree-loop-ivcanon">,  
Group;
+defm tree_loop_linear : BooleanFFlag<"tree-loop-linear">,  
Group;
 defm tree_salias : BooleanFFlag<"tree-salias">, Group;
 defm tree_ter : BooleanFFlag<"tree-ter">, 
Group;
 defm tree_vectorizer_verbose : BooleanFFlag<"tree-vectorizer-verbose">, 
Group;


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -292,9 +292,9 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
+// RUN: -ftree-loop-im\
+// RUN: -ftree-loop-ivcanon   \
+// RUN: -ftree-loop-linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -432,9 +432,9 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is 

[PATCH] D72769: Replace CLANG_SPAWN_CC1 env var with a driver mode flag

2020-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for fixing this.

As I understand, the original patch made the new behaviour on-by-default and 
will make the release, so we want this flag on the release branch too, right?

(Happy to file a bug, just want to check first)


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

https://reviews.llvm.org/D72769



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


[PATCH] D72304: [OpenMP]{OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-01-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM with some minor things you should address before the merge.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:90
+// extern ArrayType *KmpCriticalNameTy;
+// extern PointerType *KmpCriticalNamePtrTy;
+

Leftover comment.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:272
+  /// \param CriticalName name of the lock used by the critical directive
+  /// \param hasHint whether there is ahint clause associated with critical
+  ///

Nit: typos in parameter name and comment, comments seems outdated.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:305
+  /// should be
+  ///   called.
+  ///

Nit: Comment is not in sync with the Entry one.
Nit: spelling in the parameter name and format.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:326
+  /// be
+  ///   called.
+  ///

Nit: spelling param name and format.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:45
 ///{
-
 #define OMP_TYPE(VarName, InitValue) Type *llvm::omp::types::VarName = nullptr;

Leftover



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:695
+
+  FinalizationStack.push_back({FiniCB, OMPD, /*IsCancellable*/ false});
+

This needs to be guarded by `HasFinalize` if the corresponding pop is.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:749
+BasicBlock *ExitPredBB = SplitPos->getParent();
+auto InsertBB = merged ? ExitPredBB : ExitBB;
+if (!isa_and_nonnull(SplitPos))

I have the feeling the merging makes it harder without providing a benefit but 
I'm OK with it for now



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:759
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitCommonDirectiveEntry(
+Directive omp, Value *EntryCall, BasicBlock *ExitBB, bool Conditional) {
+

`omp` is not a good name here.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:791
+omp::Directive OMPD, InsertPointTy FinIP, Instruction *ExitCall,
+bool hasFinalize) {
+

 `HasFinalize`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304



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


[PATCH] D72769: Replace CLANG_SPAWN_CC1 env var with a driver mode flag

2020-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D72769#1823473 , @sammccall wrote:

> As I understand, the original patch made the new behaviour on-by-default and 
> will make the release, so we want this flag on the release branch too, right?


Yes, this is on my list. Thanks for keeping the release branch in mind :-)


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

https://reviews.llvm.org/D72769



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D71082#1822925 , @akhuang wrote:

> This caused a linker error in chromium:
>
>   ld.lld: error: undefined symbol: __warn_memset_zero_len
>
>
> Apparently now that the glibc memset is being used, __warn_memset_zero_len 
> gets called from libc++ code 
> (https://github.com/llvm/llvm-project/blob/b72a8c65e4e34779b6bc9e466203f553f5294486/libcxx/include/__bit_reference#L371).


I can reproduce the behavior locally, but without the linker error. On my 
system, (RHEL7.5) libc_nonshared.a provides that symbol. I've checked on other 
systems and it's available in that library on Ubuntu 14.04.

On other systems, this symbol is not available, neither in the lib nor in the 
header, because the associated gcc version is high enough. Can you try to 
reproduce with:

  clang -S -O2 -fgnuc-version=5.0 t.cpp  -o - -stdlib=libc++ 
-D_FORTIFY_SOURCE=1 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71911: [ThinLTO] Summarize vcall_visibility metadata

2020-01-16 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

I think this has to be rebased - I see multiple failures when trying to apply


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71911



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


[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-16 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM marked an inline comment as done.
MarkMurrayARM added inline comments.



Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:3658
+// Unpredicated v(max|min)nma
+def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec 
MQPR:$Qm,
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;

dmgreen wrote:
> If I'm reading the ARMARM correctly, the fp case seems to preform the abs on 
> both operands.
My bad. Fix coming under separate cover.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72761



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


[clang] ed181ef - [HIP][AMDGPU] expand printf when compiling HIP to AMDGPU

2020-01-16 Thread Sameer Sahasrabuddhe via cfe-commits

Author: Sameer Sahasrabuddhe
Date: 2020-01-16T15:15:38+05:30
New Revision: ed181efa175d3e0acc134e6cd161914e64c7195e

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

LOG: [HIP][AMDGPU] expand printf when compiling HIP to AMDGPU

Summary:
This change implements the expansion in two parts:
- Add a utility function emitAMDGPUPrintfCall() in LLVM.
- Invoke the above function from Clang CodeGen, when processing a HIP
  program for the AMDGPU target.

The printf expansion has undefined behaviour if the format string is
not a compile-time constant. As a sufficient condition, the HIP
ToolChain now emits -Werror=format-nonliteral.

Reviewed By: arsenm

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

Added: 
clang/test/CodeGenHIP/printf-aggregate.cpp
clang/test/CodeGenHIP/printf.cpp
clang/test/Driver/hip-printf.hip
llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/ToolChains/HIP.cpp
llvm/lib/Transforms/Utils/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 09fd3087b494..4decaa593a59 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4115,6 +4115,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BIprintf:
 if (getTarget().getTriple().isNVPTX())
   return EmitNVPTXDevicePrintfCallExpr(E, ReturnValue);
+if (getTarget().getTriple().getArch() == Triple::amdgcn &&
+getLangOpts().HIP)
+  return EmitAMDGPUDevicePrintfCallExpr(E, ReturnValue);
 break;
   case Builtin::BI__builtin_canonicalize:
   case Builtin::BI__builtin_canonicalizef:

diff  --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp 
b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index d7e267630762..bccce7dd7ff4 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -16,6 +16,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Transforms/Utils/AMDGPUEmitPrintf.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -120,3 +121,36 @@ CodeGenFunction::EmitNVPTXDevicePrintfCallExpr(const 
CallExpr *E,
   return RValue::get(Builder.CreateCall(
   VprintfFunc, {Args[0].getRValue(*this).getScalarVal(), BufferPtr}));
 }
+
+RValue
+CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E,
+ReturnValueSlot ReturnValue) {
+  assert(getTarget().getTriple().getArch() == llvm::Triple::amdgcn);
+  assert(E->getBuiltinCallee() == Builtin::BIprintf ||
+ E->getBuiltinCallee() == Builtin::BI__builtin_printf);
+  assert(E->getNumArgs() >= 1); // printf always has at least one arg.
+
+  CallArgList CallArgs;
+  EmitCallArgs(CallArgs,
+   E->getDirectCallee()->getType()->getAs(),
+   E->arguments(), E->getDirectCallee(),
+   /* ParamsToSkip = */ 0);
+
+  SmallVector Args;
+  for (auto A : CallArgs) {
+// We don't know how to emit non-scalar varargs.
+if (!A.getRValue(*this).isScalar()) {
+  CGM.ErrorUnsupported(E, "non-scalar arg to printf");
+  return RValue::get(llvm::ConstantInt::get(IntTy, -1));
+}
+
+llvm::Value *Arg = A.getRValue(*this).getScalarVal();
+Args.push_back(Arg);
+  }
+
+  llvm::IRBuilder<> IRB(Builder.GetInsertBlock(), Builder.GetInsertPoint());
+  IRB.SetCurrentDebugLocation(Builder.getCurrentDebugLocation());
+  auto Printf = llvm::emitAMDGPUPrintfCall(IRB, Args);
+  Builder.SetInsertPoint(IRB.GetInsertBlock(), IRB.GetInsertPoint());
+  return RValue::get(Printf);
+}

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 3d8bc93eb965..5ab15bf74a23 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3722,6 +3722,8 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   RValue EmitNVPTXDevicePrintfCallExpr(const CallExpr *E,
ReturnValueSlot ReturnValue);
+  RValue EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E,
+ReturnValueSlot ReturnValue);
 
   RValue EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
  const CallExpr *E, ReturnValueSlot ReturnValue);

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index f89e648948ab..d4b015a7e873 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -436,6 +436,7 @@ Tool *HIPToolChain::buildLinker() cons

[PATCH] D72786: [clang] Set function attributes on SEH filter functions correctly.

2020-01-16 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 updated this revision to Diff 238431.
sanwou01 added a comment.

Fix tests, thanks rnk


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72786

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGen/exceptions-seh-finally.c
  clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp


Index: clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 "-triple" "arm64-windows" "-munwind-tables" 
"-fms-compatibility" -emit-llvm -O1 -disable-llvm-passes %s -o - | FileCheck %s
+
+# 0 "" 3
+#define a(b, c) d() & b
+#define f(c) a(e(0, 0, #c).b(), )
+
+struct e {
+  e(int, int, char *);
+  int b();
+};
+
+struct d {
+  void operator&(int);
+};
+
+struct h;
+
+struct i {
+  h *operator->();
+  h &operator*() { f(); }
+};
+
+typedef int g;
+
+struct h {
+  void ad();
+};
+
+g aq(h j, g k, int, int) {
+  if (k)
+return;
+  j.ad();
+}
+
+// CHECK: define internal i32 @"?filt$0@0@at@@"(i8* %exception_pointers, i8* 
%frame_pointer) #[[MD:[0-9]+]]
+// CHECK: attributes #[[MD]] = { nounwind uwtable
+
+void at() {
+  i ar;
+
+  __try {
+ar->ad();
+  } __except (aq(*ar, _exception_code(), 0, 0)) {
+  }
+
+}
Index: clang/test/CodeGen/exceptions-seh-finally.c
===
--- clang/test/CodeGen/exceptions-seh-finally.c
+++ clang/test/CodeGen/exceptions-seh-finally.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
-// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -O1 
-disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -O1 
-disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -O1 
-disable-llvm-passes -o - | FileCheck %s
 
 void abort(void) __attribute__((noreturn));
 void might_crash(void);
@@ -281,7 +281,5 @@
 // CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
 // CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i{{32|64}} 0, 
i{{32|64}} 0))
 
-// Look for the absence of noinline. Enum attributes come first, so check that
-// a string attribute is the first to verify that no enum attributes are
-// present.
-// CHECK: attributes [[finally_attrs]] = { "{{.*}}" }
+// only nounwind; noinline is suppressed by -O1 -disable-llvm-passes
+// CHECK: attributes [[finally_attrs]] = { nounwind "{{.*}}" }
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1885,7 +1885,7 @@
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
 
-  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FnInfo, CurFn);
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);
 }
 


Index: clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 "-triple" "arm64-windows" "-munwind-tables" "-fms-compatibility" -emit-llvm -O1 -disable-llvm-passes %s -o - | FileCheck %s
+
+# 0 "" 3
+#define a(b, c) d() & b
+#define f(c) a(e(0, 0, #c).b(), )
+
+struct e {
+  e(int, int, char *);
+  int b();
+};
+
+struct d {
+  void operator&(int);
+};
+
+struct h;
+
+struct i {
+  h *operator->();
+  h &operator*() { f(); }
+};
+
+typedef int g;
+
+struct h {
+  void ad();
+};
+
+g aq(h j, g k, int, int) {
+  if (k)
+return;
+  j.ad();
+}
+
+// CHECK: define internal i32 @"?filt$0@0@at@@"(i8* %exception_pointers, i8* %frame_pointer) #[[MD:[0-9]+]]
+// CHECK: attributes #[[MD]] = { nounwind uwtable
+
+void at() {
+  i ar;
+
+  __try {
+ar->ad();
+  } __except (aq(*ar, _exception_code(), 0, 0)) {
+  }
+
+}
Index: clang/test/CodeGen/exceptions-seh-finally.c
===
--- clang/test/CodeGen/exceptions-seh-finally.c
+++ clang/test/CodeGen/exceptions-seh-finally.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - | FileCheck %s
+

[PATCH] D71365: expand printf when compiling HIP to AMDGPU

2020-01-16 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed181efa175d: [HIP][AMDGPU] expand printf when compiling HIP 
to AMDGPU (authored by sameerds).
Herald added a subscriber: kerbowa.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71365

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenHIP/printf-aggregate.cpp
  clang/test/CodeGenHIP/printf.cpp
  clang/test/Driver/hip-printf.hip
  llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt

Index: llvm/lib/Transforms/Utils/CMakeLists.txt
===
--- llvm/lib/Transforms/Utils/CMakeLists.txt
+++ llvm/lib/Transforms/Utils/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_llvm_component_library(LLVMTransformUtils
+  AMDGPUEmitPrintf.cpp
   ASanStackFrameLayout.cpp
   AddDiscriminators.cpp
   BasicBlockUtils.cpp
Index: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
===
--- /dev/null
+++ llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
@@ -0,0 +1,246 @@
+//===- AMDGPUEmitPrintf.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
+//
+//===--===//
+//
+// Utility function to lower a printf call into a series of device
+// library calls on the AMDGPU target.
+//
+// WARNING: This file knows about certain library functions. It recognizes them
+// by name, and hardwires knowledge of their semantics.
+//
+//===--===//
+
+#include "llvm/Transforms/Utils/AMDGPUEmitPrintf.h"
+#include "llvm/ADT/SparseBitVector.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/IRBuilder.h"
+
+#include 
+
+using namespace llvm;
+
+#define DEBUG_TYPE "amdgpu-emit-printf"
+
+static bool isCString(const Value *Arg) {
+  auto Ty = Arg->getType();
+  auto PtrTy = dyn_cast(Ty);
+  if (!PtrTy)
+return false;
+
+  auto IntTy = dyn_cast(PtrTy->getElementType());
+  if (!IntTy)
+return false;
+
+  return IntTy->getBitWidth() == 8;
+}
+
+static Value *fitArgInto64Bits(IRBuilder<> &Builder, Value *Arg) {
+  auto Int64Ty = Builder.getInt64Ty();
+  auto Ty = Arg->getType();
+
+  if (auto IntTy = dyn_cast(Ty)) {
+switch (IntTy->getBitWidth()) {
+case 32:
+  return Builder.CreateZExt(Arg, Int64Ty);
+case 64:
+  return Arg;
+}
+  }
+
+  if (Ty->getTypeID() == Type::DoubleTyID) {
+return Builder.CreateBitCast(Arg, Int64Ty);
+  }
+
+  if (auto PtrTy = dyn_cast(Ty)) {
+return Builder.CreatePtrToInt(Arg, Int64Ty);
+  }
+
+  llvm_unreachable("unexpected type");
+}
+
+static Value *callPrintfBegin(IRBuilder<> &Builder, Value *Version) {
+  auto Int64Ty = Builder.getInt64Ty();
+  auto M = Builder.GetInsertBlock()->getModule();
+  auto Fn = M->getOrInsertFunction("__ockl_printf_begin", Int64Ty, Int64Ty);
+  return Builder.CreateCall(Fn, Version);
+}
+
+static Value *callAppendArgs(IRBuilder<> &Builder, Value *Desc, int NumArgs,
+ Value *Arg0, Value *Arg1, Value *Arg2, Value *Arg3,
+ Value *Arg4, Value *Arg5, Value *Arg6,
+ bool IsLast) {
+  auto Int64Ty = Builder.getInt64Ty();
+  auto Int32Ty = Builder.getInt32Ty();
+  auto M = Builder.GetInsertBlock()->getModule();
+  auto Fn = M->getOrInsertFunction("__ockl_printf_append_args", Int64Ty,
+   Int64Ty, Int32Ty, Int64Ty, Int64Ty, Int64Ty,
+   Int64Ty, Int64Ty, Int64Ty, Int64Ty, Int32Ty);
+  auto IsLastValue = Builder.getInt32(IsLast);
+  auto NumArgsValue = Builder.getInt32(NumArgs);
+  return Builder.CreateCall(Fn, {Desc, NumArgsValue, Arg0, Arg1, Arg2, Arg3,
+ Arg4, Arg5, Arg6, IsLastValue});
+}
+
+static Value *appendArg(IRBuilder<> &Builder, Value *Desc, Value *Arg,
+bool IsLast) {
+  auto Arg0 = fitArgInto64Bits(Builder, Arg);
+  auto Zero = Builder.getInt64(0);
+  return callAppendArgs(Builder, Desc, 1, Arg0, Zero, Zero, Zero, Zero, Zero,
+Zero, IsLast);
+}
+
+// The device library does not provide strlen, so we build our own loop
+// here. While we are at it, we also include the terminating null in the length.
+static Value *getStrlenWithNull(IRBuilder<> &Builder, Value *Str) {
+  auto *Prev = Builder.GetInsertBlock();
+  Module *M = Prev->getModule();
+
+  auto CharZero = Builder.getInt8(0);
+  auto On

[PATCH] D72630: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

2020-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

It seems that while this commit got pushed to GitHub, it's not actually part of 
master or any other branches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72630



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


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-01-16 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

Thanks, I'm still in process of testing (now fixing issue which however is most 
likely related to devirtualization itself, not to this patch). Meanwhile some 
of my comments below.




Comment at: llvm/test/Transforms/WholeProgramDevirt/import-indir.ll:2
 ; Test that we correctly import an indir resolution for type identifier 
"typeid1".
-; RUN: opt -S -wholeprogramdevirt -wholeprogramdevirt-summary-action=import 
-wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml 
-wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
+; RUN: opt -S -wholeprogramdevirt -whole-program-visibility 
-wholeprogramdevirt-summary-action=import 
-wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml 
-wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
 ; RUN: FileCheck --check-prefix=SUMMARY %s < %t

Why do you need `-whole-program-visibility` here? Correct me if I'm wrong, but 
AFAIK module scanning doesn't happen during import and GV visibility should be 
taken from imported summary.



Comment at: llvm/tools/opt/opt.cpp:634
+  // not performed via opt.
+  updateVCallVisibilityInModule(*M,
+/* WholeProgramVisibilityEnabledInLTO */ 
false);

Hm, looks like I don't fully understand this. I have following concerns:

1) According to your changes every time I use `opt -wholeprogramdevirt` I also 
have to pass `-whole-program-visibility`. Has `-wholeprogramdevirt` flag become 
no-op without this additional flag? If so this looks counter intuitive to me.

2) When I use `opt -wholeprogramdevirt` default constructor of 
`WholeProgramDevirt` class is called and `UseCommandLine` flag is set to true. 
Can't I use this flag to effectively lower visibility in module instead of 
playing with metadata?

```
if (VS->vCallVisibility() == GlobalObject::VCallVisibilityPublic && 
!UseCommandLine)
 return false;
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71913



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


[clang] 736a380 - clang-format: [JS] tests for async wrapping.

2020-01-16 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-01-16T11:23:11+01:00
New Revision: 736a3802124b57490fa1e67538415a2a77fa731c

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

LOG: clang-format: [JS] tests for async wrapping.

Summary:
Adds tests to ensure that `async method() ...` does not wrap between async and
the method name, which would cause automatic semicolon insertion.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 619a19f1a22d..f5be0d7a4ab1 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -737,6 +737,22 @@ TEST_F(FormatTestJS, AsyncFunctions) {
"   function a() {\n"
"  return   1;\n"
"}  \n");
+  // clang-format must not insert breaks between async and function, otherwise
+  // automatic semicolon insertion may trigger (in particular in a class body).
+  verifyFormat("async function\n"
+   "hello(\n"
+   "myparamnameiswaytoolng) {\n"
+   "}",
+   "async function hello(myparamnameiswaytoolng) {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("class C {\n"
+   "  async hello(\n"
+   "  myparamnameiswaytoolng) {\n"
+   "  }\n"
+   "}",
+   "class C {\n"
+   "  async hello(myparamnameiswaytoolng) {} }",
+   getGoogleJSStyleWithColumns(10));
   verifyFormat("async function* f() {\n"
"  yield fetch(x);\n"
"}");



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


[PATCH] D70377: clang-format: [JS] tests for async wrapping.

2020-01-16 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG736a3802124b: clang-format: [JS] tests for async wrapping. 
(authored by mprobst).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70377

Files:
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -737,6 +737,22 @@
"   function a() {\n"
"  return   1;\n"
"}  \n");
+  // clang-format must not insert breaks between async and function, otherwise
+  // automatic semicolon insertion may trigger (in particular in a class body).
+  verifyFormat("async function\n"
+   "hello(\n"
+   "myparamnameiswaytoolng) {\n"
+   "}",
+   "async function hello(myparamnameiswaytoolng) {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("class C {\n"
+   "  async hello(\n"
+   "  myparamnameiswaytoolng) {\n"
+   "  }\n"
+   "}",
+   "class C {\n"
+   "  async hello(myparamnameiswaytoolng) {} }",
+   getGoogleJSStyleWithColumns(10));
   verifyFormat("async function* f() {\n"
"  yield fetch(x);\n"
"}");


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -737,6 +737,22 @@
"   function a() {\n"
"  return   1;\n"
"}  \n");
+  // clang-format must not insert breaks between async and function, otherwise
+  // automatic semicolon insertion may trigger (in particular in a class body).
+  verifyFormat("async function\n"
+   "hello(\n"
+   "myparamnameiswaytoolng) {\n"
+   "}",
+   "async function hello(myparamnameiswaytoolng) {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("class C {\n"
+   "  async hello(\n"
+   "  myparamnameiswaytoolng) {\n"
+   "  }\n"
+   "}",
+   "class C {\n"
+   "  async hello(myparamnameiswaytoolng) {} }",
+   getGoogleJSStyleWithColumns(10));
   verifyFormat("async function* f() {\n"
"  yield fetch(x);\n"
"}");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71469: [AArch64] Add sq(r)dmulh_lane(q) LLVM IR intrinsics

2020-01-16 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71469



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgrang, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Makes use of insertion order to stabilize output for multiple decls.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72826

Files:
  clang-tools-extra/clangd/FindTarget.cpp

Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -134,6 +135,35 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+const NamedDecl *getTemplatePattern(const NamedDecl *D) {
+  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+return CRD->getTemplateInstantiationPattern();
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
+return FD->getTemplateInstantiationPattern();
+  } else if (auto *VD = dyn_cast(D)) {
+// Hmm: getTIP returns its arg if it's not an instantiation?!
+VarDecl *T = VD->getTemplateInstantiationPattern();
+return (T == D) ? nullptr : T;
+  } else if (const auto *ED = dyn_cast(D)) {
+return ED->getInstantiatedFromMemberEnum();
+  } else if (isa(D) || isa(D)) {
+if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
+  if (const DeclContext *ParentPat =
+  dyn_cast_or_null(getTemplatePattern(Parent)))
+for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
+  if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
+return BaseND;
+  } else if (const auto *ECD = dyn_cast(D)) {
+if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
+  if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
+for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
+  return BaseECD;
+  }
+}
+  }
+  return nullptr;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -167,38 +197,12 @@
 struct TargetFinder {
   using RelSet = DeclRelationSet;
   using Rel = DeclRelation;
+
+private:
+  llvm::SmallDenseMap InsertionOrder;
   llvm::SmallDenseMap Decls;
   RelSet Flags;
 
-  static const NamedDecl *getTemplatePattern(const NamedDecl *D) {
-if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-  return CRD->getTemplateInstantiationPattern();
-} else if (const FunctionDecl *FD = dyn_cast(D)) {
-  return FD->getTemplateInstantiationPattern();
-} else if (auto *VD = dyn_cast(D)) {
-  // Hmm: getTIP returns its arg if it's not an instantiation?!
-  VarDecl *T = VD->getTemplateInstantiationPattern();
-  return (T == D) ? nullptr : T;
-} else if (const auto *ED = dyn_cast(D)) {
-  return ED->getInstantiatedFromMemberEnum();
-} else if (isa(D) || isa(D)) {
-  if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
-if (const DeclContext *ParentPat =
-dyn_cast_or_null(getTemplatePattern(Parent)))
-  for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
-if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
-  return BaseND;
-} else if (const auto *ECD = dyn_cast(D)) {
-  if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
-if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
-  for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
-return BaseECD;
-}
-  }
-}
-return nullptr;
-  }
-
   template  void debug(T &Node, RelSet Flags) {
 dlog("visit [{0}] {1}", Flags,
  nodeToString(ast_type_traits::DynTypedNode::create(Node)));
@@ -207,10 +211,24 @@
   void report(const NamedDecl *D, RelSet Flags) {
 dlog("--> [{0}] {1}", Flags,
  nodeToString(ast_type_traits::DynTypedNode::create(*D)));
-Decls[D] |= Flags;
+auto It = Decls.try_emplace(D, Flags);
+if (It.second)
+  InsertionOrder[D] = InsertionOrder.size();
+else
+  It.first->second |= Flags;
   }
 
 public:
+  llvm::SmallVector, 1> takeDecls() const {
+using ValTy = std::pair;
+llvm::SmallVector Result{Decls.begin(), Decls.end()};
+llvm::sort(Result, [this](const ValTy &LHS, const ValTy &RHS) {
+  return InsertionOrder.lookup(LHS.first) <
+ InsertionOrder.lookup(RHS.first);
+});
+return Result;
+  }
+
   void add(const Decl *Dcl, RelSet Flags) {
 const NamedDecl *D = llvm::dyn_cast(Dcl);
 if (!D)
@@ -485,7 +503,7 @@
   else if (const CXXCtorInitializer *CCI = N.get())
 Finder.add(CCI, Flags);
 
-  return {Finder.Decls.begin(), Finder.Decls.end()};
+  return Fi

[PATCH] D72777: [clangd] Dont display `` kinds in hover board

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb08e8353a89f: [clangd] Dont display `` kinds 
in hover board (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72777

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1655,7 +1655,7 @@
 HI.Kind = index::SymbolKind::Unknown;
 HI.Name = "X";
   },
-  R"( X)",
+  R"(X)",
   },
   {
   [](HoverInfo &HI) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -522,7 +522,8 @@
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph &Header = Output.addHeading(3);
-  Header.appendText(index::getSymbolKindString(Kind));
+  if (Kind != index::SymbolKind::Unknown)
+Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1655,7 +1655,7 @@
 HI.Kind = index::SymbolKind::Unknown;
 HI.Name = "X";
   },
-  R"( X)",
+  R"(X)",
   },
   {
   [](HoverInfo &HI) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -522,7 +522,8 @@
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph &Header = Output.addHeading(3);
-  Header.appendText(index::getSymbolKindString(Kind));
+  if (Kind != index::SymbolKind::Unknown)
+Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@akhuang : I've reported https://sourceware.org/bugzilla/show_bug.cgi?id=25399 
to glibc. According to me this is more of a glibc problem than this patch, and 
as we have a workaround with `-fgnuc-version=5.0` I think we could apply the 
patch back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[clang-tools-extra] b08e835 - [clangd] Dont display `` kinds in hover board

2020-01-16 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-16T11:47:00+01:00
New Revision: b08e8353a89f682861ef947fdb6e229b3de2e37d

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

LOG: [clangd] Dont display `` kinds in hover board

Summary:
Currently when hovering over an `auto` or `decltype` that resolve to a
builtin-type, clangd would display `` as the kind of the symbol.

Drop that to make rendering nicer.

Reviewers: usaxena95

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 118d58591d2d..0833a46f088e 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -522,7 +522,8 @@ markup::Document HoverInfo::present() const {
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph &Header = Output.addHeading(3);
-  Header.appendText(index::getSymbolKindString(Kind));
+  if (Kind != index::SymbolKind::Unknown)
+Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 385c064a9dce..65d5e4a6c216 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1655,7 +1655,7 @@ TEST(Hover, Present) {
 HI.Kind = index::SymbolKind::Unknown;
 HI.Name = "X";
   },
-  R"( X)",
+  R"(X)",
   },
   {
   [](HoverInfo &HI) {



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


[PATCH] D72827: clang-format: [JS] Handle keyword-named methods.

2020-01-16 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
Herald added a project: clang.

Including `do`, `for`, and `while`, in addition to the previously
handled fields. The unit test explicitly uses methods, but this code
path handles both fields and methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72827

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -343,6 +343,14 @@
"  x: 'x'\n"
"};",
"const Axis = {for: 'for', x:   'x'};");
+  verifyFormat("class KeywordNamedMethods {\n"
+   "  do() {\n"
+   "  }\n"
+   "  for() {\n"
+   "  }\n"
+   "  while() {\n"
+   "  }\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsMethods) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1015,9 +1015,15 @@
 return;
   case tok::kw_for:
   case tok::kw_while:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseForOrWhileLoop();
 return;
   case tok::kw_do:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseDoWhile();
 return;
   case tok::kw_switch:


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -343,6 +343,14 @@
"  x: 'x'\n"
"};",
"const Axis = {for: 'for', x:   'x'};");
+  verifyFormat("class KeywordNamedMethods {\n"
+   "  do() {\n"
+   "  }\n"
+   "  for() {\n"
+   "  }\n"
+   "  while() {\n"
+   "  }\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsMethods) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1015,9 +1015,15 @@
 return;
   case tok::kw_for:
   case tok::kw_while:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseForOrWhileLoop();
 return;
   case tok::kw_do:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseDoWhile();
 return;
   case tok::kw_switch:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61895 tests passed, 0 failed 
and 782 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: MaskRay, hfinkel.
Herald added subscribers: llvm-commits, cfe-commits, haicheng, hiraditya, 
eraman.
Herald added projects: clang, LLVM.
serge-sans-paille added a comment.

@MaskRay no example yet, I'd like your opinion on the approach first. It has 
the advantage of being non intrusive to the code base...


First attempt at implementing -fsemantic-interposition.

Rely on `GlobalValue::isInterposable` that already captures most of the 
expected behavior.

Rely on a `ModuleFlag` to state whether we should respect SemanticInterposition 
or not. The default remains no.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72829

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp

Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -559,6 +559,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  auto *Val =
+  cast_or_null(getModuleFlag("SemanticInterposition"));
+
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (getParent() && getParent()->getSemanticInterposition() &&
+  isDSOPreemptable())
+return true;
+  return isInterposableLinkage(getLinkage());
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/lib/Analysis/InlineCost.cpp
===
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -1842,7 +1842,7 @@
 } else if (Operator::getOpcode(V) == Instruction::BitCast) {
   V = cast(V)->getOperand(0);
 } else if (GlobalAlias *GA = dyn_cast(V)) {
-  if (GA->isInterposable())
+  if (GA->isInterposable() || GA->isDSOPreemptable())
 break;
   V = GA->getAliasee();
 } else {
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -846,6 +846,17 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// @name Utility functions for querying and setting semantic interposition
+  /// @{
+
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
+  /// @}
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ -284,6 +284,8 @@
 return IsDSOLocal;
   }
 
+  bool isDSOPreemptable() const { return !IsDSOLocal; }
+
   bool hasPartition() const {
 return HasPartition;
   }
@@ -426,7 +428,7 @@
   /// *arbitrary* definition at link time.  We cannot do any IPO or inlinining
   /// across interposable call edges, since the callee can be replaced with
   /// something arbitrary at link time.
-  bool isInterposable() const { return isInterposableLinkage(getLinkage()); }
+  bool isInterposable() const;
 
   bool hasExternalLinkage() const { return isExternalLinkage(getLinkage()); }
   bool hasAvailableExternallyLinkage() const {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2679,6 +2679,13 @@
 Opts.setValueVisibilityMode(DefaultVisibility);
   }
 
+  // Semantic interposition mode defaults to "false".
+  if (Arg *siOpt = Args.getLastArg(OPT_fsemantic_interposition,
+   OPT_fno_semantic_interposition)) {
+Opts.SemanticInterposition =
+unsigned(siOpt->getOption().getID() == OPT_fsemantic_interposition);
+  }
+
   // The type-visibility mode defaults to the value-visibility mode.
   if 

[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@craig.topper up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@MaskRay no example yet, I'd like your opinion on the approach first. It has 
the advantage of being non intrusive to the code base...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D71566: New checks for fortified sprintf

2020-01-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@erik.pilkington up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:202
+private:
+  llvm::SmallDenseMap InsertionOrder;
   llvm::SmallDenseMap Decls;

why two maps vs map to pair here? Seems a little 
inefficient/untidy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826



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


[PATCH] D72612: [AArch64][SVE] Add ImmArg property to intrinsics with immediates

2020-01-16 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 238445.
kmclaughlin added a comment.

- Replace PatLeaf with ImmLeaf & TImmLeaf in the VectorIndex multiclass


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

https://reviews.llvm.org/D72612

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td

Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -1646,12 +1646,12 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b:$idx))),
-(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b:$idx)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b:$idx)>;
-  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b:$idx))),
-(!cast(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b:$idx)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))),
+(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))),
+(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>;
+  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))),
+(!cast(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>;
 }
 
 
@@ -1694,12 +1694,12 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b:$idx))),
-(!cast(NAME # _H) $Op1, $Op2, VectorIndexH32b:$idx)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # _S) $Op1, $Op2, VectorIndexS32b:$idx)>;
-  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b:$idx))),
-(!cast(NAME # _D) $Op1, $Op2, VectorIndexD32b:$idx)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
+(!cast(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))),
+(!cast(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>;
+  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))),
+(!cast(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>;
 }
 
 //===--===//
@@ -1785,10 +1785,10 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b:$idx), (i32 complexrotateop:$imm))),
-(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b:$idx, complexrotateop:$imm)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b:$idx), (i32 complexrotateop:$imm))),
-(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
 }
 
 //===--===//
@@ -1949,7 +1949,7 @@
 multiclass sve2_fp_mla_long_by_indexed_elem opc, string asm,
 SDPatternOperator op> {
   def NAME : sve2_fp_mla_long_by_indexed_elem;
-  def : SVE_4_Op_Imm_Pat(NAME)>;
+  def : SVE_4_Op_Imm_Pat(NAME)>;
 }
 
 //===--===//
@@ -2479,23 +2479,23 @@
 
 multiclass sve_intx_dot_by_indexed_elem {
-  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
+  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> {
 bits<2> iop;
 bits<3> Zm;
 let Inst{20-19} = iop;
 let Inst{18-16} = Zm;
   }
-  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
+  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> {
 bits<1> iop;
 bits<4> Zm;
 let Inst{20} = iop;
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv4i32 (op nxv4i32:$Op1, nxv16i8:$Op2, nxv16i8:$Op3, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # 

[PATCH] D72830: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-16 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM created this revision.
MarkMurrayARM added reviewers: dmgreen, simon_tatham.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

Fix VMINNMAQ, VMAXNMAQ intrinsics; BOTH arguments have the absolute values 
taken.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72830

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vminnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vminnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vmaxnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vmaxnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3655,7 +3655,8 @@
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated v(max|min)nma
-def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec MQPR:$Qm,
+def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
+  (fabs (VTI.Vec MQPR:$Qm,
   (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
 
 // Predicated v(max|min)nma
Index: clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v

[PATCH] D72612: [AArch64][SVE] Add ImmArg property to intrinsics with immediates

2020-01-16 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked an inline comment as done.
kmclaughlin added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1108
+  def "" : AsmVectorIndexOpnd, PatLeaf<(ty imm), pred>;
+  def _timm : AsmVectorIndexOpnd, PatLeaf<(ty timm), pred>;
+}

efriedma wrote:
> Using ImmLeaf/TImmLeaf doesn't work here?
Thanks for the suggestion, it looks like I can use ImmLeaf & TImmLeaf here (and 
use //Imm// again instead of //N->getZExtValue()// in VectorIndex1, etc below)


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

https://reviews.llvm.org/D72612



___
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-initialization-list

2020-01-16 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238449.
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added a comment.

Rebased.


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

https://reviews.llvm.org/D71199

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -0,0 +1,407 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+
+class Simple1 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple1() {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple1(int nn, double xx) {
+// CHECK-FIXES: Simple1(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple1() = default;
+};
+
+class Simple2 {
+  int n;
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple2() : n (0) {
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple2(int nn, double xx) : n(nn) {
+// CHECK-FIXES: Simple2(int nn, double xx) : n(nn), x(xx) {
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple2() = default;
+};
+
+class Simple3 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+
+public:
+  Simple3() : x (0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple3(int nn, double xx) : x(xx) {
+// CHECK-FIXES: Simple3(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple3() = default;
+};
+
+int something_int();
+double something_double();
+
+class Simple4 {
+  int n;
+
+public:
+  Simple4() {
+// CHECK-FIXES: Simple4() : n(something_int()) {
+n = something_int();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple4() = default;
+};
+
+static bool dice();
+
+class Complex1 {
+  int n;
+  int m;
+
+public:
+  Complex1() : n(0) {
+if (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional expression
+  }
+
+  ~Complex1() = default;
+};
+
+class Complex2 {
+  int n;
+  int m;
+
+public:
+  Complex2() : n(0) {
+if (!dice())
+  return;
+m = 1;
+// NO-MESSAGES: initialization of 'm' follows a conditional expression
+  }
+
+  ~Complex2() = default;
+};
+
+class Complex3 {
+  int n;
+  int m;
+
+public:
+  Complex3() : n(0) {
+while (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional loop
+  }
+
+  ~Complex3() = default;
+};
+
+class Complex4 {
+  int n;
+  int m;
+
+public:
+  Complex4() : n(0) {
+while (!dice())
+  return;
+

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61912 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D67160: [clang, ARM] Default to -fno-lax-vector-conversions in ARM v8.1-M.

2020-01-16 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham abandoned this revision.
simon_tatham added a comment.

I ended up solving this problem a completely different way, in D72518 
. Instead of controlling the behavior I need 
based on the target architecture, I made it depend on a type attribute on the 
vector types, so that the MVE header file adds that attribute but nobody else 
does. And doing it like that I was also able to make the behavior more subtle, 
so that it makes the polymorphic MVE intrinsics work without also turning 
//every// case of lax vector checking into strict – so users still get to make 
a choice about how strict they want their vectors to be, and the intrinsics 
work either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67160



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-16 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238451.
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

Rebased.


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

https://reviews.llvm.org/D71001

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+class C {
+  int num;
+public:
+  explicit C(int n) : num(n) {}
+};
+
+void bad_new(int n, int m) {
+  C *p = new C(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  C \*p = new C\(n}} + 10{{\);$}}
+
+  p = new C(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - 10{{\);$}}
+
+  p = new C(n) + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} + m{{\);$}}
+
+  p = new C(n) - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - (m + 10){{\);$}}
+
+  p = new C(n) - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - m{{\) \+ 10;$}}
+  // FIXME: Should be {{^  p = new C\(n}} - m + 10{{\);$}}
+}
+
+void bad_new_array(int n, int m) {
+  char *p = new char[n] + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = new char\[n}} + 10{{\];$}}
+
+  p = new char[n] - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - 10{{\];$}}
+
+  p = new char[n] + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} + m{{\];$}}
+
+  p = new char[n] - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - (m + 10){{\];$}}
+
+  p = new char[n] - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - m{{\] \+ 10;$}}
+  // FIXME: should be {{^  p = new char\[n}} - m + 10{{\];$}}
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void bad_malloc(int n) {
+  char *p = (char *)malloc(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = \(char \*\)malloc\(n}} + 10{{\);$}}
+
+  p = (char *)malloc(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = \(char \*\)malloc\(n}} - 10{{\);$}}
+
+  p = (char *)malloc(n) + n;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: a

[clang] 8a34467 - [Concepts] Fix ConceptSpecializationExpr profiling crash

2020-01-16 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-01-16T13:39:30+02:00
New Revision: 8a3446746098ba29348bb8f85357dd0b466a6d6e

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

LOG: [Concepts] Fix ConceptSpecializationExpr profiling crash

ConceptSpecializationExprs (CSEs) were being created with nullptr
TemplateArgsAsWritten during TemplateTemplateParmDecl canonicalization, and
we were relying on them during profiling which caused sporadic crashes
in test/CXX/.../temp.arg.template/p3-2a.cpp introduced in D44352.

Change profiling of CSEs to instead rely on the actual converted template
arguments and concept named.

Added: 


Modified: 
clang/lib/AST/StmtProfile.cpp

Removed: 




diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 2aa5106e90fa..c0b0f3b0b064 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1335,9 +1335,9 @@ void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
 void StmtProfiler::VisitConceptSpecializationExpr(
const ConceptSpecializationExpr *S) 
{
   VisitExpr(S);
-  VisitDecl(S->getFoundDecl());
-  VisitTemplateArguments(S->getTemplateArgsAsWritten()->getTemplateArgs(),
- S->getTemplateArgsAsWritten()->NumTemplateArgs);
+  VisitDecl(S->getNamedConcept());
+  for (const TemplateArgument &Arg : S->getTemplateArguments())
+VisitTemplateArgument(Arg);
 }
 
 static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,



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


[PATCH] D72830: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-16 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

Hmm. Somewhere in the back of my head is a worry that we may miss an 
optimization opportunity in cases such as `max(a, abs(b))` where value-range 
analysis tells us that `a` is known to be positive already.

But better a missed optimization than a correctness bug, of course! This patch 
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72830



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238456.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826

Files:
  clang-tools-extra/clangd/FindTarget.cpp

Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -134,6 +135,35 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+const NamedDecl *getTemplatePattern(const NamedDecl *D) {
+  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+return CRD->getTemplateInstantiationPattern();
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
+return FD->getTemplateInstantiationPattern();
+  } else if (auto *VD = dyn_cast(D)) {
+// Hmm: getTIP returns its arg if it's not an instantiation?!
+VarDecl *T = VD->getTemplateInstantiationPattern();
+return (T == D) ? nullptr : T;
+  } else if (const auto *ED = dyn_cast(D)) {
+return ED->getInstantiatedFromMemberEnum();
+  } else if (isa(D) || isa(D)) {
+if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
+  if (const DeclContext *ParentPat =
+  dyn_cast_or_null(getTemplatePattern(Parent)))
+for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
+  if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
+return BaseND;
+  } else if (const auto *ECD = dyn_cast(D)) {
+if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
+  if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
+for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
+  return BaseECD;
+  }
+}
+  }
+  return nullptr;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -167,37 +197,12 @@
 struct TargetFinder {
   using RelSet = DeclRelationSet;
   using Rel = DeclRelation;
-  llvm::SmallDenseMap Decls;
-  RelSet Flags;
 
-  static const NamedDecl *getTemplatePattern(const NamedDecl *D) {
-if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-  return CRD->getTemplateInstantiationPattern();
-} else if (const FunctionDecl *FD = dyn_cast(D)) {
-  return FD->getTemplateInstantiationPattern();
-} else if (auto *VD = dyn_cast(D)) {
-  // Hmm: getTIP returns its arg if it's not an instantiation?!
-  VarDecl *T = VD->getTemplateInstantiationPattern();
-  return (T == D) ? nullptr : T;
-} else if (const auto *ED = dyn_cast(D)) {
-  return ED->getInstantiatedFromMemberEnum();
-} else if (isa(D) || isa(D)) {
-  if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
-if (const DeclContext *ParentPat =
-dyn_cast_or_null(getTemplatePattern(Parent)))
-  for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
-if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
-  return BaseND;
-} else if (const auto *ECD = dyn_cast(D)) {
-  if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
-if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
-  for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
-return BaseECD;
-}
-  }
-}
-return nullptr;
-  }
+private:
+  llvm::SmallDenseMap>
+  Decls;
+  RelSet Flags;
 
   template  void debug(T &Node, RelSet Flags) {
 dlog("visit [{0}] {1}", Flags,
@@ -207,10 +212,24 @@
   void report(const NamedDecl *D, RelSet Flags) {
 dlog("--> [{0}] {1}", Flags,
  nodeToString(ast_type_traits::DynTypedNode::create(*D)));
-Decls[D] |= Flags;
+auto It = Decls.try_emplace(D, std::make_pair(Flags, Decls.size()));
+// If already exists, update the flags.
+if (!It.second)
+  It.first->second.first |= Flags;
   }
 
 public:
+  llvm::SmallVector, 1> takeDecls() const {
+using ValTy = std::pair;
+llvm::SmallVector Result;
+for (const auto &Elem : Decls)
+  Result.push_back({Elem.getFirst(), Elem.getSecond().first});
+llvm::sort(Result, [this](const ValTy &LHS, const ValTy &RHS) {
+  return Decls.lookup(LHS.first).second < Decls.lookup(RHS.first).second;
+});
+return Result;
+  }
+
   void add(const Decl *Dcl, RelSet Flags) {
 const NamedDecl *D = llvm::dyn_cast(Dcl);
 if (!D)
@@ -485,7 +504,7 @@
   else if (const CXXCtorInitializer *CCI = N.get())
 Finder.add(CCI, Flags);
 
-  return {Finder.Decls.begin(), Finder.Decls.end()};
+  return Finder.takeDecls();
 }
 
 llvm::SmallVector
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] 00c74d0 - Remove release note about in-process-cc1

2020-01-16 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-01-16T13:24:22+01:00
New Revision: 00c74d0b644b9ad31b377d0a07012c090af834e2

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

LOG: Remove release note about in-process-cc1

This feature landed before the 10.x branch, so it will be covered in the
clang 10 release notes instead.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d081c885a0b3..35132cecee57 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -46,11 +46,6 @@ sections with improvements to Clang's support for those 
languages.
 Major New Features
 --
 
-- clang used to run the actual compilation in a subprocess ("clang -cc1").
-  Now compilations are done in-process by default. ``-fno-integrated-cc1``
-  restores the former behavior. The ``-v`` and ``-###`` flags will print
-  "(in-process)" when compilations are done in-process.
-
 - ...
 
 Improvements to Clang's diagnostics



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


[PATCH] D72769: Replace CLANG_SPAWN_CC1 env var with a driver mode flag

2020-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Oh, and removed the release note from trunk in 00c74d0b644 



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

https://reviews.llvm.org/D72769



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


[PATCH] D72769: Replace CLANG_SPAWN_CC1 env var with a driver mode flag

2020-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D72769#1823488 , @hans wrote:

> In D72769#1823473 , @sammccall wrote:
>
> > As I understand, the original patch made the new behaviour on-by-default 
> > and will make the release, so we want this flag on the release branch too, 
> > right?
>
>
> Yes, this is on my list. Thanks for keeping the release branch in mind :-)


Cherry-picked to 10.x in c4a134a 



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

https://reviews.llvm.org/D72769



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61912 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826



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


[PATCH] D72072: [AST] Respect shouldTraversePostOrder when traversing type locs

2020-01-16 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

A test would be nice, but we don't have infrastructure for checking call 
ordering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72072



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:224
+using ValTy = std::pair;
+llvm::SmallVector Result;
+for (const auto &Elem : Decls)

no need for lookups I think
```
Result.resize(Decls.size());
for (auto& Elem : Decls)
  Result[Elem.second.second] = {Elem.first, Elem.second.first};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61894 tests passed, 0 failed 
and 782 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2020-01-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

There are some interesting failures that need to be investigated.
https://reviews.llvm.org/rG647c3f4e47de8a850ffcaa897db68702d8d2459a


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[clang] 19c5057 - Fix "pointer is null" static analyzer warnings. NFCI.

2020-01-16 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-16T13:02:40Z
New Revision: 19c5057e8df62e75b26e881dfc8f8f32686fe75c

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

LOG: Fix "pointer is null" static analyzer warnings. NFCI.

Use castAs<> instead of getAs<> since the pointer is dereferenced immediately 
in all cases and castAs will perform the null assertion for us.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 038078bbe88d..feb8d000eca3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1357,7 +1357,7 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function 
*Fn,
 std::string typeName;
 if (isPipe)
   typeName = ty.getCanonicalType()
- ->getAs()
+ ->castAs()
  ->getElementType()
  .getAsString(Policy);
 else
@@ -1371,7 +1371,7 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function 
*Fn,
 std::string baseTypeName;
 if (isPipe)
   baseTypeName = ty.getCanonicalType()
- ->getAs()
+ ->castAs()
  ->getElementType()
  .getCanonicalType()
  .getAsString(Policy);



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


[PATCH] D72675: Fix -ffast-math/-ffp-contract interaction

2020-01-16 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D72675#1823227 , @mcberg2017 wrote:

> We crossed that bridge internally at Apple a while ago, meaning I have some 
> code debt for cleaning up open source for fma formation that uses contract 
> and reassoc differently than we do today, both together and separately, case 
> by case.


Ah, great. I don't have a preference about the order of patches (ie, is it 
better to make this change first or do the backend cleanup first), so whatever 
works better.

But it would be better to have all of the baseline tests in place, so we know 
where we stand currently. So I'd prefer to have the PPC and x86 tests 
pre-committed to master (change test comments as needed to match current/future 
reality).

We could also decouple the clang part of this patch from the backend change 
IIUC. But do we need another change (or at least tests) to show how the driver 
difference translates in the clang front-end to LLVM FMF and/or function 
attributes?




Comment at: clang/test/Driver/fast-math.c:183-184
 //
+// -ffp-contract=off must disable the fast-math umbrella, and the 
unsafe-fp-math
+// umbrella.
+// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \

Do we need another pair of tests for -ffp-contract=on?


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

https://reviews.llvm.org/D72675



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238469.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Get rid of redundant sorting step


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826

Files:
  clang-tools-extra/clangd/FindTarget.cpp

Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -134,6 +135,35 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+const NamedDecl *getTemplatePattern(const NamedDecl *D) {
+  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+return CRD->getTemplateInstantiationPattern();
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
+return FD->getTemplateInstantiationPattern();
+  } else if (auto *VD = dyn_cast(D)) {
+// Hmm: getTIP returns its arg if it's not an instantiation?!
+VarDecl *T = VD->getTemplateInstantiationPattern();
+return (T == D) ? nullptr : T;
+  } else if (const auto *ED = dyn_cast(D)) {
+return ED->getInstantiatedFromMemberEnum();
+  } else if (isa(D) || isa(D)) {
+if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
+  if (const DeclContext *ParentPat =
+  dyn_cast_or_null(getTemplatePattern(Parent)))
+for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
+  if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
+return BaseND;
+  } else if (const auto *ECD = dyn_cast(D)) {
+if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
+  if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
+for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
+  return BaseECD;
+  }
+}
+  }
+  return nullptr;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -167,37 +197,12 @@
 struct TargetFinder {
   using RelSet = DeclRelationSet;
   using Rel = DeclRelation;
-  llvm::SmallDenseMap Decls;
-  RelSet Flags;
 
-  static const NamedDecl *getTemplatePattern(const NamedDecl *D) {
-if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-  return CRD->getTemplateInstantiationPattern();
-} else if (const FunctionDecl *FD = dyn_cast(D)) {
-  return FD->getTemplateInstantiationPattern();
-} else if (auto *VD = dyn_cast(D)) {
-  // Hmm: getTIP returns its arg if it's not an instantiation?!
-  VarDecl *T = VD->getTemplateInstantiationPattern();
-  return (T == D) ? nullptr : T;
-} else if (const auto *ED = dyn_cast(D)) {
-  return ED->getInstantiatedFromMemberEnum();
-} else if (isa(D) || isa(D)) {
-  if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
-if (const DeclContext *ParentPat =
-dyn_cast_or_null(getTemplatePattern(Parent)))
-  for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
-if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
-  return BaseND;
-} else if (const auto *ECD = dyn_cast(D)) {
-  if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
-if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
-  for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
-return BaseECD;
-}
-  }
-}
-return nullptr;
-  }
+private:
+  llvm::SmallDenseMap>
+  Decls;
+  RelSet Flags;
 
   template  void debug(T &Node, RelSet Flags) {
 dlog("visit [{0}] {1}", Flags,
@@ -207,10 +212,22 @@
   void report(const NamedDecl *D, RelSet Flags) {
 dlog("--> [{0}] {1}", Flags,
  nodeToString(ast_type_traits::DynTypedNode::create(*D)));
-Decls[D] |= Flags;
+auto It = Decls.try_emplace(D, std::make_pair(Flags, Decls.size()));
+// If already exists, update the flags.
+if (!It.second)
+  It.first->second.first |= Flags;
   }
 
 public:
+  llvm::SmallVector, 1> takeDecls() const {
+using ValTy = std::pair;
+llvm::SmallVector Result;
+Result.resize(Decls.size());
+for (const auto &Elem : Decls)
+  Result[Elem.second.second] = {Elem.first, Elem.second.first};
+return Result;
+  }
+
   void add(const Decl *Dcl, RelSet Flags) {
 const NamedDecl *D = llvm::dyn_cast(Dcl);
 if (!D)
@@ -485,7 +502,7 @@
   else if (const CXXCtorInitializer *CCI = N.get())
 Finder.add(CCI, Flags);
 
-  return {Finder.Decls.begin(), Finder.Decls.end()};
+  return Finder.takeDecls();
 }
 
 llvm::SmallVector
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d54d71b - [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-16T14:47:28+01:00
New Revision: d54d71b67e602674a255e299a22fe31dee1f3619

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

LOG: [clangd] Make output order of allTargetDecls deterministic

Summary:
Makes use of insertion order to stabilize output for multiple decls.

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

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, usaxena95, 
cfe-commits, aemerson

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index d8ce0b69283f..82a2e8c27d56 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -134,6 +135,35 @@ const Type *getPointeeType(const Type *T) {
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+const NamedDecl *getTemplatePattern(const NamedDecl *D) {
+  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+return CRD->getTemplateInstantiationPattern();
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
+return FD->getTemplateInstantiationPattern();
+  } else if (auto *VD = dyn_cast(D)) {
+// Hmm: getTIP returns its arg if it's not an instantiation?!
+VarDecl *T = VD->getTemplateInstantiationPattern();
+return (T == D) ? nullptr : T;
+  } else if (const auto *ED = dyn_cast(D)) {
+return ED->getInstantiatedFromMemberEnum();
+  } else if (isa(D) || isa(D)) {
+if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
+  if (const DeclContext *ParentPat =
+  dyn_cast_or_null(getTemplatePattern(Parent)))
+for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
+  if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
+return BaseND;
+  } else if (const auto *ECD = dyn_cast(D)) {
+if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
+  if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
+for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
+  return BaseECD;
+  }
+}
+  }
+  return nullptr;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -167,37 +197,12 @@ const Type *getPointeeType(const Type *T) {
 struct TargetFinder {
   using RelSet = DeclRelationSet;
   using Rel = DeclRelation;
-  llvm::SmallDenseMap Decls;
-  RelSet Flags;
 
-  static const NamedDecl *getTemplatePattern(const NamedDecl *D) {
-if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-  return CRD->getTemplateInstantiationPattern();
-} else if (const FunctionDecl *FD = dyn_cast(D)) {
-  return FD->getTemplateInstantiationPattern();
-} else if (auto *VD = dyn_cast(D)) {
-  // Hmm: getTIP returns its arg if it's not an instantiation?!
-  VarDecl *T = VD->getTemplateInstantiationPattern();
-  return (T == D) ? nullptr : T;
-} else if (const auto *ED = dyn_cast(D)) {
-  return ED->getInstantiatedFromMemberEnum();
-} else if (isa(D) || isa(D)) {
-  if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
-if (const DeclContext *ParentPat =
-dyn_cast_or_null(getTemplatePattern(Parent)))
-  for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
-if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
-  return BaseND;
-} else if (const auto *ECD = dyn_cast(D)) {
-  if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
-if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
-  for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
-return BaseECD;
-}
-  }
-}
-return nullptr;
-  }
+private:
+  llvm::SmallDenseMap>
+  Decls;
+  RelSet Flags;
 
   template  void debug(T &Node, RelSet Flags) {
 dlog("visit [{0}] {1}", Flags,
@@ -207,10 +212,22 @@ struct TargetFinder {
   void report(const NamedDecl *D, RelSet Flags) {
 dlog("--> [{0}] {1}", Flags,
  nodeToString(ast_type_traits::DynTypedNode::create(*D)));
-Decls[D] |= Flags;
+auto It = Decls.try_emplace(D, std::make_pair(Flags, Decls.size()));
+// If already exists, update the flags.
+if (!It.second)
+  It.first->second.first |= Flags;
   }
 
 public:
+  llvm::SmallVector, 1> takeDecls() const 
{
+using ValTy = std::pair;
+llvm::SmallVector Re

[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:224
+using ValTy = std::pair;
+llvm::SmallVector Result;
+for (const auto &Elem : Decls)

sammccall wrote:
> no need for lookups I think
> ```
> Result.resize(Decls.size());
> for (auto& Elem : Decls)
>   Result[Elem.second.second] = {Elem.first, Elem.second.first};
> ```
ah right, sorry I was in a rush :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826



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


[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd54d71b67e60: [clangd] Make output order of allTargetDecls 
deterministic (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826

Files:
  clang-tools-extra/clangd/FindTarget.cpp

Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -134,6 +135,35 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+const NamedDecl *getTemplatePattern(const NamedDecl *D) {
+  if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+return CRD->getTemplateInstantiationPattern();
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
+return FD->getTemplateInstantiationPattern();
+  } else if (auto *VD = dyn_cast(D)) {
+// Hmm: getTIP returns its arg if it's not an instantiation?!
+VarDecl *T = VD->getTemplateInstantiationPattern();
+return (T == D) ? nullptr : T;
+  } else if (const auto *ED = dyn_cast(D)) {
+return ED->getInstantiatedFromMemberEnum();
+  } else if (isa(D) || isa(D)) {
+if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
+  if (const DeclContext *ParentPat =
+  dyn_cast_or_null(getTemplatePattern(Parent)))
+for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
+  if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
+return BaseND;
+  } else if (const auto *ECD = dyn_cast(D)) {
+if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
+  if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
+for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
+  return BaseECD;
+  }
+}
+  }
+  return nullptr;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -167,37 +197,12 @@
 struct TargetFinder {
   using RelSet = DeclRelationSet;
   using Rel = DeclRelation;
-  llvm::SmallDenseMap Decls;
-  RelSet Flags;
 
-  static const NamedDecl *getTemplatePattern(const NamedDecl *D) {
-if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-  return CRD->getTemplateInstantiationPattern();
-} else if (const FunctionDecl *FD = dyn_cast(D)) {
-  return FD->getTemplateInstantiationPattern();
-} else if (auto *VD = dyn_cast(D)) {
-  // Hmm: getTIP returns its arg if it's not an instantiation?!
-  VarDecl *T = VD->getTemplateInstantiationPattern();
-  return (T == D) ? nullptr : T;
-} else if (const auto *ED = dyn_cast(D)) {
-  return ED->getInstantiatedFromMemberEnum();
-} else if (isa(D) || isa(D)) {
-  if (const auto *Parent = llvm::dyn_cast(D->getDeclContext()))
-if (const DeclContext *ParentPat =
-dyn_cast_or_null(getTemplatePattern(Parent)))
-  for (const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
-if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
-  return BaseND;
-} else if (const auto *ECD = dyn_cast(D)) {
-  if (const auto *ED = dyn_cast(ECD->getDeclContext())) {
-if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
-  for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
-return BaseECD;
-}
-  }
-}
-return nullptr;
-  }
+private:
+  llvm::SmallDenseMap>
+  Decls;
+  RelSet Flags;
 
   template  void debug(T &Node, RelSet Flags) {
 dlog("visit [{0}] {1}", Flags,
@@ -207,10 +212,22 @@
   void report(const NamedDecl *D, RelSet Flags) {
 dlog("--> [{0}] {1}", Flags,
  nodeToString(ast_type_traits::DynTypedNode::create(*D)));
-Decls[D] |= Flags;
+auto It = Decls.try_emplace(D, std::make_pair(Flags, Decls.size()));
+// If already exists, update the flags.
+if (!It.second)
+  It.first->second.first |= Flags;
   }
 
 public:
+  llvm::SmallVector, 1> takeDecls() const {
+using ValTy = std::pair;
+llvm::SmallVector Result;
+Result.resize(Decls.size());
+for (const auto &Elem : Decls)
+  Result[Elem.second.second] = {Elem.first, Elem.second.first};
+return Result;
+  }
+
   void add(const Decl *Dcl, RelSet Flags) {
 const NamedDecl *D = llvm::dyn_cast(Dcl);
 if (!D)
@@ -485,7 +502,7 @@
   else if (const CXXCtorInitializer *CCI = N.get())
 Finder.add(CCI, Flags);
 
-  return {Finder.Decls.begin(), Finder.Decls.end()};
+  return Finder.takeDecls();
 }
 
 llvm::SmallVector
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/c

[PATCH] D72826: [clangd] Make output order of allTargetDecls deterministic

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61912 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72826



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


[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2020-01-16 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.
Herald added a reviewer: nicolasvasilache.
Herald added a subscriber: liufengdb.

Ping! Any further comments?


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

https://reviews.llvm.org/D71775



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst:15
+
+void bad_malloc(int n) {
+  char *p = (char*) malloc(n) + 10;

Identification. I think 2 character should be enough.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst:25
+
+  char *p = (char*) malloc(n + 10);

Identification. I think 2 character should be enough.


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

https://reviews.llvm.org/D71001



___
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-initialization-list

2020-01-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst:72
+
+C(int nn, int mm) : n(nn) {
+  if (dice())

Please make indentation 2 characters, same as in above code snippets.


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] D71911: [ThinLTO] Summarize vcall_visibility metadata

2020-01-16 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D71911#1823497 , @evgeny777 wrote:

> I think this has to be rebased - I see multiple failures when trying to apply


I'll rebase it today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71911



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


[PATCH] D72827: clang-format: [JS] Handle keyword-named methods.

2020-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

How about `if` and `try`? Is there a list somewhere for all such valid 
identifiers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72827



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


[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

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

LGTM!

In D72373#1809080 , @AlexanderLanin 
wrote:

> FIX-IT isn't quite that obvious. Some options:
>
> - look for other typedef which contains the same as const
> - create new typedef/using
> - remove "*" from typedef and adjust all usage accordingly. Implies removing 
> "Ptr" suffix.


I think we can punt on the fixit for now as this is a good incremental 
improvement. Another possible option is to remove the `const` from the 
declaration using the typedef (there may be situations where you cannot add a 
new typedef or modify the existing one because the typedef is in a system 
header).




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp:2
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DUSING
+// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -DTYPEDEF
+

AlexanderLanin wrote:
> is this good practice? I didn't want to duplicate everything here.
Yes, this is a good way to reduce duplication.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-misplaced-const.cpp:32
+  // Potentially quite unexpectedly the int can be modified here
+  // CHECK-MESSAGES: :[[@LINE+1]]:23: warning: 'i' declared with a 
const-qualified {{.*}}; results in the type being 'int *const' instead of 
'const int *'
+  if (const ptr_to_int i = 0) {

AlexanderLanin wrote:
> not sure how to remove the regex here without duplicating everything
I think the regex is reasonable enough.


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

https://reviews.llvm.org/D72373



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


[PATCH] D72827: clang-format: [JS] Handle keyword-named methods.

2020-01-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM thanks for the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72827



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


[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238474.
kadircet added a comment.

- Handle return and parameter types as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72498

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1514,6 +1514,56 @@
 HI.Name = "cls > >";
 HI.Documentation = "type of nested templates.";
   }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  decltype(a) [[b^]] = a;)cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "decltype(a) b = a";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.Name = "b";
+HI.Type = "int";
+  }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  decltype(a) c;
+  decltype(c) [[b^]] = a;)cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "decltype(c) b = a";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.Name = "b";
+HI.Type = "int";
+  }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  const decltype(a) [[b^]] = a;)cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "const decltype(a) b = a";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.Name = "b";
+HI.Type = "int";
+  }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  auto [[f^oo]](decltype(a) x) -> decltype(a) { return 0; })cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "auto foo(decltype(a) x) -> decltype(a)";
+HI.Kind = index::SymbolKind::Function;
+HI.NamespaceScope = "";
+HI.Name = "foo";
+// FIXME: Handle composite types with decltype with a printing
+// policy.
+HI.Type = "auto (decltype(a)) -> decltype(a)";
+HI.ReturnType = "int";
+HI.Parameters = {
+{std::string("int"), std::string("x"), llvm::None}};
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1542,6 +1592,7 @@
 Expected.SymRange = T.range();
 Case.ExpectedBuilder(Expected);
 
+SCOPED_TRACE(H->present().asPlainText());
 EXPECT_EQ(H->NamespaceScope, Expected.NamespaceScope);
 EXPECT_EQ(H->LocalScope, Expected.LocalScope);
 EXPECT_EQ(H->Name, Expected.Name);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -123,6 +123,15 @@
   }
 }
 
+std::string printType(QualType QT, const PrintingPolicy &Policy) {
+  // TypePrinter doesn't resolve decltypes, so resolve them here.
+  // FIXME: This doesn't handle composite types that contain a decltype in them.
+  // We should rather have a printing policy for that.
+  while (const auto *DT = QT->getAs())
+QT = DT->getUnderlyingType();
+  return QT.getAsString(Policy);
+}
+
 std::vector
 fetchTemplateParameters(const TemplateParameterList *Params,
 const PrintingPolicy &PP) {
@@ -131,8 +140,7 @@
 
   for (const Decl *Param : *Params) {
 HoverInfo::Param P;
-P.Type.emplace();
-if (const auto TTP = dyn_cast(Param)) {
+if (const auto *TTP = dyn_cast(Param)) {
   P.Type = TTP->wasDeclaredWithTypename() ? "typename" : "class";
   if (TTP->isParameterPack())
 *P.Type += "...";
@@ -141,21 +149,21 @@
 P.Name = TTP->getNameAsString();
   if (TTP->hasDefaultArgument())
 P.Default = TTP->getDefaultArgument().getAsString(PP);
-} else if (const auto NTTP = dyn_cast(Param)) {
+} else if (const auto *NTTP = dyn_cast(Param)) {
   if (IdentifierInfo *II = NTTP->getIdentifier())
 P.Name = II->getName().str();
 
-  llvm::raw_string_ostream Out(*P.Type);
-  NTTP->getType().print(Out, PP);
+  P.Type = printType(NTTP->getType(), PP);
   if (NTTP->isParameterPack())
-Out << "...";
+*P.Type += "...";
 
   if (NTTP->hasDefaultArgument()) {
 P.Default.emplace();
 llvm::raw_string_ostream Out(*P.Default);
 NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP);
   }
-} else if (const auto TTPD = dyn_cast(Param)) {
+} else if (const auto *TTPD = dyn_cast(Param)) {
+  P.Type.emplace();
   llvm::raw_string_ostream OS(*P.Type);
   OS << "template <";
   printParams(OS,
@@ -241,7 +249,7 @@
 HI.Parameters->emplace_ba

[PATCH] D72373: [clang-tidy] extend misc-misplaced-const to detect using besides typedef

2020-01-16 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

Thanks for the review!

Could someone commit this? As I can not.
Alexander Lanin 


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

https://reviews.llvm.org/D72373



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


[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61913 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72498



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


[PATCH] D65042: [Concept] Placeholder constraints and abbreviated templates

2020-01-16 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 238478.
saar.raz marked 21 inline comments as done.
saar.raz added a comment.

Address CR comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65042

Files:
  .gitignore
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/SemaTemplate/ms-delayed-default-template-args.cpp

Index: clang/test/SemaTemplate/ms-delayed-default-template-args.cpp
===
--- clang/test/SemaTemplate/ms-delayed-default-template-args.cpp
+++ clang/test/SemaTemplate/ms-delayed-default-template-args.cpp
@@ -94,6 +94,7 @@
 template  struct Bar { T x; };
 
 template  *P> // expected-error {{use of undeclared identifier 'Xylophone'}}
+// expected-note@-1{{template parameter is declared here}}
 struct Foo { };
 
 typedef int Xylophone;
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -501,7 +501,7 @@
 
 /// Determine whether the parser is at the start of a template
 /// type parameter.
-/// \param ScopeError will receive true if there was a parsing error.
+/// \param Error will receive true if there was a parsing error.
 bool Parser::isStartOfTemplateTypeParameter(bool &Error) {
   Error = false;
   if (Tok.is(tok::kw_class)) {
@@ -611,8 +611,8 @@
   // type-constraint is in fact part of a placeholder-type-specifier of a
   // non-type template parameter.
 
-  bool ScopeError;
-  if (isStartOfTemplateTypeParameter(ScopeError)) {
+  bool Error;
+  if (isStartOfTemplateTypeParameter(Error)) {
 // Is there just a typo in the input code? ('typedef' instead of
 // 'typename')
 if (Tok.is(tok::kw_typedef)) {
@@ -629,7 +629,7 @@
 
 return ParseTypeParameter(Depth, Position);
   }
-  if (ScopeError) {
+  if (Error) {
 // We return an invalid parameter as opposed to null to avoid having bogus
 // diagnostics about an empty template parameter list.
 // FIXME: Fix ParseTemplateParameterList to better handle nullptr results
@@ -679,7 +679,7 @@
 /// \returns true if an error occurred, and false otherwise.
 bool Parser::TryAnnotateTypeConstraint(CXXScopeSpec &SS) {
   if (!getLangOpts().ConceptsTS)
-return true;
+return false;
   if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
  /*EnteringContext=*/false,
  /*MayBePseudoDestructor=*/nullptr,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3472,13 +3472,12 @@
 ConsumeAnnotationToken();
 SourceLocation AutoLoc = Tok.getLocation();
 if (TryConsumeToken(tok::kw_decltype)) {
-  if (!Tok.is(tok::l_paren)) {
+  BalancedDelimiterTracker Tracker(*this, tok::l_paren);
+  if (Tracker.consumeOpen()) {
 // Something like `void foo(Iterator decltype i)`
 Diag(Tok, diag::err_expected) << tok::l_paren;
   } else {
-BalancedDelimiterTracker Tracker(*this, tok::l_paren);
-Tracker.consumeOpen();
-if (!ExpectAndConsume(tok::kw_auto)) {
+if (!TryConsumeToken(tok::kw_auto)) {
   // Something like `void foo(Iterator decltype(int) i)`
   Tracker.skipToEnd();
   Diag(Tok, diag::err_placeholder_decltype_non_auto)
@@ -3489,6 +3488,7 @@
   Tracker.consumeClose();
 }
   }
+  ConsumedEnd = Tok.getLocation();
   // Even if something went wrong above, continue as if we've seen
   // `decltype(auto)`.
   isInvalid = DS.SetTypeSpecType(TST_decltype_auto, Loc, PrevSpec,
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -3079,7 +3079,7 @@
SourceLocation &RAngleLoc);
   bool ParseTemplateParameterList(unsigned Depth,
   SmallVectorImpl &TemplateParams);
-  bool isStartOfTemplateTypeParameter(bool &ScopeError);
+  bool isStartOfTemplateTypeParameter(bool &Error);
   NamedDecl *ParseTemplateParameter(unsigned Depth, unsigned Position);
   NamedDecl *ParseTypeParameter(unsigned Depth, unsigned Position);
   NamedDecl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
Index: .gitignore
===
--- .gitignore
+++ .gitignore
@@ -54,7 +54,3 @@
 .vs
 # clangd index
 .clangd
-<<< Updated upstream
-===
-clang/\.idea/
->>> Stashed changes
___
cfe-commits mailing list
cfe-

[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-01-16 Thread Luboš Luňák via Phabricator via cfe-commits
llunak updated this revision to Diff 238477.
llunak added a comment.

In D69585#1821831 , @aganea wrote:

> What is the error?


I take that part back, actually. I don't quite remember anymore what exactly I 
did in October, but if I now revert the PCH tweaks in LibreOffice I did to 
avoid the error, the compilation fails even without the patch or with GCC. So I 
assume what really happened was that code changes triggered the error and I 
incorrectly assumed it was because of my patch. So, unless proven otherwise, I 
take it that my patch is actually technically correct without causing any code 
regressions (the OpenMP problem has just been fixed).

What remains is those 22 tests which fail because moving the instantiations 
reorders the code that is expected by FileCheck. This patch handles 2 of them, 
and it's already rather tedious (the OpenMP tests are large). Is this really 
the way to handle them, or does somebody have a better idea?


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

https://reviews.llvm.org/D69585

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCXX/vla-lambda-capturing.cpp
  clang/test/OpenMP/single_codegen.cpp

Index: clang/test/OpenMP/single_codegen.cpp
===
--- clang/test/OpenMP/single_codegen.cpp
+++ clang/test/OpenMP/single_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefixes=CHECK,NOPCH %s
 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefixes=CHECK,PCH %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -std=c++11 -fopenmp -fnoopenmp-use-tls -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
 // RUN: %clang_cc1 -verify -fopenmp -fnoopenmp-use-tls -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=ARRAY %s
 
@@ -230,6 +230,58 @@
 // ARRAY: store %struct.St* %{{.+}}, %struct.St** %{{.+}},
 #endif
 
+// PCH-LABEL: @_ZN3SSTIdEC2Ev
+// PCH: getelementptr inbounds [[SST_TY]], [[SST_TY]]* %{{.+}}, i32 0, i32 0
+// PCH-NEXT: store double 0.00e+00, double* %
+// PCH-NEXT: getelementptr inbounds [[SST_TY]], [[SST_TY]]* %{{.+}}, i32 0, i32 0
+// PCH-NEXT: store double* %{{.+}}, double** %
+// PCH-NEXT: load double*, double** %
+// PCH-NEXT: load double, double* %
+// PCH-NEXT: bitcast i64* %{{.+}} to double*
+// PCH-NEXT: store double %{{.+}}, double* %
+// PCH-NEXT: load i64, i64* %
+// PCH-NEXT: call void ([[IDENT_T_TY]]*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call([[IDENT_T_TY]]* @{{.+}}, i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, [[SST_TY]]*, i64)* [[SST_MICROTASK:@.+]] to void
+// PCH-NEXT: ret void
+
+// PCH: define internal void [[SST_MICROTASK]](i32* {{[^,]+}}, i32* {{[^,]+}}, [[SST_TY]]* {{.+}}, i64 {{.+}})
+// PCH: [[RES:%.+]] = call i32 @__kmpc_single([[IDENT_T_TY]]* @{{.+}}, i32 %{{.+}})
+// PCH-NEXT: icmp ne i32 [[RES]], 0
+// PCH-NEXT: br i1
+
+// PCH: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 1
+// PCH-NEXT: load double*, double** %
+// PCH-NEXT: store double* %
+// PCH-LABEL: invoke void @_ZZN3SSTIdEC1EvENKUlvE_clEv(
+
+// PCH: call void @__kmpc_end_single([[IDENT_T_TY]]* @{{.+}}, i32 %{{.+}})
+// PCH-NEXT: store i32 1, i32* [[DID_IT]],
+// PCH-NEXT: br label
+
+// PCH: call void @__kmpc_end_single([[IDENT_T_TY]]* @{{.+}}, i32 %{{.+}})
+// PCH-NEXT: br label
+
+// PCH: getelementptr inbounds [1 x i8*], [1 x i8*]* [[LIST:%.+]], i64 0, i64 0
+// PCH: load double*, double** %
+// PCH-NEXT: bitcast double* %
+// PCH-NEXT: store i8* %
+// PCH-NEXT: bitcast [1 x i8*]* [[LIST]] to i8*
+// PCH-NEXT: load i32, i32* [[DID_IT]],
+// PCH-NEXT: call void @__kmpc_copyprivate([[IDENT_T_TY]]* @{{.+}}, i32 %{{.+}}, i64 8, i8* %{{.+}}, void (i8*, i8*)* [[COPY_FUNC:@[^,]+]], i32 %{{.+}})
+// PCH-NEXT:  ret void
+
+// PCH-LABEL: @_ZZN3SSTIdEC1EvENKUlvE_clEv(
+// PCH: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 1
+// PCH-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 1
+// PCH-NEXT: load double*, double** %
+// P

[PATCH] D72840: [clangd] Make define outline code action visible

2020-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, usaxena95.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This got forgotten during the process.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72840

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp


Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -299,7 +299,7 @@
 public:
   const char *id() const override;
 
-  bool hidden() const override { return true; }
+  bool hidden() const override { return false; }
   Intent intent() const override { return Intent::Refactor; }
   std::string title() const override {
 return "Move function body to out-of-line.";


Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -299,7 +299,7 @@
 public:
   const char *id() const override;
 
-  bool hidden() const override { return true; }
+  bool hidden() const override { return false; }
   Intent intent() const override { return Intent::Refactor; }
   std::string title() const override {
 return "Move function body to out-of-line.";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72484: [clang-tidy] Fix check for Abseil internal namespace access

2020-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp:43-44
+
+  if (!LocAtFault.isValid())
+return;
+

rogeeff wrote:
> lebedev.ri wrote:
> > Is there test coverage for this? When does/can this happen?
> At the time when I wrote this internally the test cases in 
> abseil-no-internal-dependencies.cpp were reproducing this failure. I'm not 
> sure this is still the case. It is possible compiler was fixed since then.
I am not certain I'm following along (sorry if I'm just being dense). Are you 
saying that the existing test coverage in abseil-no-internal-dependencies.cpp 
was failing for you internally, and that's the reason for this fix? Or are you 
saying that the newly-added test cases in this patch were triggering this 
failure?


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

https://reviews.llvm.org/D72484



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-01-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: andrew.w.kaylor, kpn, rjmccall, sepavloff.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Intel would like to support #pragma float_control which allows control over 
precision and exception behavior at the source level. This pragma is supported 
by both the Microsoft compiler and the Intel compiler, and our customers have 
found it useful.  This message is to describe the pragma, provide the patch for 
review, and request feedback from the community.

As the pragma was originally defined in the Microsoft compiler, the pragma 
supports a stack of settings, so that you can use push and pop to save and 
restore the state. That functionality is already in clang and this patch 
piggy-backs on that support (reference PragmaStack and PragmaMsStackAction). 
The Microsoft compiler supports it only at file scope, but the Intel compiler, 
and this patch, supports the pragma at either file scope or at the beginning of 
a compound statement.  Clang currently provides support for pragma fp_contract 
which enables floating point contraction--also at file scope and compound 
statement, and uses FPFeatures on certain expression nodes to hold the pragma 
settings. This patch piggy-backs FPFeatures, adding fields to show the setting 
of "float_control(precise)" and "float_control(except)"

This patch includes an update to the pragma documentation, to summarize, using 
pragma float_control(precise) is like enabling ffp-model=precise for a region 
of the program. pragma float_control(except) is like enabling 
ffp-exception-behavior=strict/ignore for a region of the program.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72841

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/fp-floatcontrol-class.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  llvm/include/llvm/IR/IRBuilder.h

Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -299,10 +299,16 @@
 IRBuilderBase &Builder;
 FastMathFlags FMF;
 MDNode *FPMathTag;
+bool IsFPConstrained;
+fp::ExceptionBehavior DefaultConstrainedExcept;
+fp::RoundingMode DefaultConstrainedRounding;
 
   public:
 FastMathFlagGuard(IRBuilderBase &B)
-: Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
+: Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag),
+  IsFPConstrained(B.IsFPConstrained),
+  DefaultConstrainedExcept(B.DefaultConstrainedExcept),
+  DefaultConstrainedRounding(B.DefaultConstrainedRounding) {}
 
 FastMathFlagGuard(const FastMathFlagGuard &) = delete;
 FastMathFlagGuard &operator=(const FastMathFlagGuard &) = delete;
@@ -310,6 +316,9 @@
 ~FastMathFlagGuard() {
   Builder.FMF = FMF;
   Builder.DefaultFPMathTag = FPMathTag;
+  Builder.IsFPConstrained = IsFPConstrained;
+  Builder.DefaultConstrainedExcept = DefaultConstrainedExcept;
+  Builder.DefaultConstrainedRounding = DefaultConstrainedRounding;
 }
   };
 
Index: clang/test/CodeGen/fp-floatcontrol-pragma.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCHECK_ERROR %s
+
+float fff(float x, float y) {
+// CHECK-LABEL: define float @_Z3f{{.*}}
+// CHECK: entry
+#pragma float_control(except, on)
+  float z;
+  z = z*z;
+//CHECK: llvm.experimental.constrained.fmul{{.*}}
+  {
+z = x*y;
+//CHECK: llvm.experimental.constrained.fmul{{.*}}
+  }
+  {
+// This pragma has no effect since if there are any fp intrin in the
+// function then all the operations need to be fp intrin
+#pragma float_control(except, off)
+ z = z + x*y;
+//CHECK: llvm.experimental.constrained.fmul{{.*}}
+  }
+  z = z*z;
+//CHECK: llvm.experimental.constrained.fmul{{.*}}
+  return z;
+}
+float check_precise(float x, float y) {
+// CHECK-LABEL: define float @_Z13check_preciseff{{.*}}
+  float z;
+  {
+#pragma float_control(precise, on)
+z = x*y + z;
+//CHECK: llvm.fmuladd{{.*}}
+  }
+  {
+#pragma float_control(precise, off)
+z = x*y + z;
+//CHECK: fmul float
+//CHECK: fadd float
+  }
+  return z;
+}
+float fma_test1(

[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2020-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Given that the compiler already has `-Wsign-conversion`, I'm not certain what 
value is added by this check. Can you explain a bit about why this is the 
correct approach for diagnosing the issue? When you ignore the false positives 
from the test, the only cases not pointed out by `-Wsign-compare` are the macro 
cases (which is reasonable behavior to not diagnose on -- the fix for one macro 
may make other macros invalid).




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unsigned-subtraction.cpp:36-37
+  if (x - 2 > 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: signed value subtracted from
+// CHECK-FIXES: if (x - 2u > 0) {
+return;

I consider this to be a false positive diagnostic -- the `2` is converted from 
a signed value into an unsigned value and there cannot possibly be a conversion 
error on that implicit cast.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unsigned-subtraction.cpp:100
+  if (y.size() - 1 > 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: signed value subtracted from
+// CHECK-FIXES: if (y.size() - 1u > 0) {

Similarly, I consider this to be a false positive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[PATCH] D72840: [clangd] Make define outline code action visible

2020-01-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61913 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72840



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


[clang] cbaa326 - Removed an unused include from TypeLocVisitor.h

2020-01-16 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-01-16T15:57:44+01:00
New Revision: cbaa32650a0b5b17b42fc123de068de69b290bf5

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

LOG: Removed an unused include from TypeLocVisitor.h

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang/include/clang/AST/TypeLocVisitor.h

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 82a2e8c27d56..2bab9d4f67b7 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeLocVisitor.h"
+#include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"

diff  --git a/clang/include/clang/AST/TypeLocVisitor.h 
b/clang/include/clang/AST/TypeLocVisitor.h
index ec780884e96c..168e9ac532ee 100644
--- a/clang/include/clang/AST/TypeLocVisitor.h
+++ b/clang/include/clang/AST/TypeLocVisitor.h
@@ -13,7 +13,6 @@
 #define LLVM_CLANG_AST_TYPELOCVISITOR_H
 
 #include "clang/AST/TypeLoc.h"
-#include "clang/AST/TypeVisitor.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace clang {



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


[PATCH] D72378: [clang-tidy] Add `bugprone-reserved-identifier`

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

LGTM!




Comment at: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp:27-34
+static const char NonReservedMessage[] =
+"declaration uses identifier '%0', which is not a reserved "
+"identifier";
+static const char GlobalUnderscoreMessage[] =
+"declaration uses identifier '%0', which is reserved in the global "
+"namespace; this causes undefined behavior";
+static const char DefaultMessage[] = "declaration uses reserved identifier "

logan-5 wrote:
> aaron.ballman wrote:
> > I think you can reasonably combine these into a single diagnostic using 
> > `%select`. e.g.,
> > `"declaration uses identifier %0, which is %select{a reserved 
> > identifier|not a reserved identifier|reserved in the global namespace}1"`
> > 
> > I took out the bits about causing undefined behavior because that doesn't 
> > really add much to the diagnostic (the "is a reserved identifier" bit 
> > should be sufficient). Also, I removed the manual quoting around the `%0` 
> > because it shouldn't be needed if you pass in a `NamedDecl*` as opposed to 
> > a string (which you should prefer doing because it automatically formats 
> > the identifier properly).
> I don't have access to a `NamedDecl*` for a couple reasons, one being that 
> the same diagnostic is used for both declarations and macro definitions. The 
> %select change sounds like a good one--I'll do that (or I already did it, 
> depending when this comment shows up).
Ah, okay, that's a good point about macros.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72378



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


[PATCH] D72089: [Syntax] Build declarator nodes

2020-01-16 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:395
   }
+  /// FIXME: use custom iterator instead of 'vector'.
+  std::vector declarators();

s/iterator/container/ ?

Also unclear why a custom one should be used.

I also think it should be an implementation comment (in the .cc file).



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:491
+/// Array size specified inside a declarator.
+/// E.g. `[10]` in `int a[10]`.
+class ArraySubscript final : public Tree {

Also `[static 10]` in `void f(int xs[static 10]);`



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:500
+  syntax::Expression *sizeExpression();
+  syntax::Leaf *rbracket();
+};

+ TODO: add an accessor for the "static" keyword.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:503
+
+/// Trailing return type inside parameter list, starting from the arrow token.
+/// E.g. `-> int***`.

s/inside parameter list/after the parameter list/ ?

s/starting from/starting with/ or "including the arrow token" to emphasize that 
the arrow is included.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:512
+  syntax::Leaf *arrow();
+  syntax::SimpleDeclarator *declarator();
+};

+ TODO: add accessors for specifiers.

Or we could add a syntax node for the "type-id" construct -- it seems like it 
will be useful in other places that require exactly one type, like the argument 
of sizeof, type argument of static_cast etc. (Also could be a TODO, this patch 
is pretty long.)



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:515
+
+/// Parameter list for a function type.
+class ParametersAndQualifiers final : public Tree {

Would be great to show an example of what sort of qualifiers we're talking 
about here (trailing "const", "volatile", "&", "&&", right?) What about 
"noexcept"? Would be also good to say that "override" does not belong here.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:524
+  /// FIXME: use custom iterator instead of 'vector'.
+  std::vector parameters();
+  syntax::Leaf *rparen();

Similarly, I think it should be an implementation comment.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:53
+namespace {
+struct GetStartLoc : TypeLocVisitor {
+  SourceLocation VisitParenTypeLoc(ParenTypeLoc T) {

A brief comment about why this is necessary (and why it works) would be 
appreciated. Just remind the reader that type locs are stored inside-out, and 
that the start location in the source order would be on the innermost node.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:119
+  SourceLocation Start = GetStartLoc().Visit(T);
+  SourceLocation End = T.getSourceRange().getEnd();
+  assert(End.isValid());

Why don't we need a similar visitor to get the end location? I think we have a 
similar inside-out problem with `int x[10][20]`.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:306
   auto BeginExecuted = DelayedFolds.lower_bound(Tokens.begin());
-  auto It = BeginExecuted;
-  for (; It != DelayedFolds.end() && It->second.End <= Tokens.end(); ++It)
+  auto EndExecuted = BeginExecuted;
+  for (; EndExecuted != DelayedFolds.end() &&

The past tense in Executed threw me off -- I thought that we already executed 
these folds, and now doing them again for some reason.

Consider `BeginFolds` / `EndFolds`?



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:483
+  Builder.foldNode(Tokens, new (allocator()) syntax::SimpleDeclarator);
+  Builder.markChild(Tokens, 
syntax::NodeRole::SimpleDeclaration_declarator);
+}

Looks like this patch was not updated for https://reviews.llvm.org/D72446 
(because we're not passing the AST node to markChild)?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:908
+  {R"cpp(
+static_assert(true, "message");
+static_assert(true);

I think we already have one of these tests for static_assert.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:931
+   )txt"},
+  // Array subscripts in declarators.
+  {R"cpp(

Now that this test is going over 1000 lines, I'd really appreciate splitting it 
into multiple files, each focusing on one aspect (e.g., one file for testing 
declarators). Could be a follow-up change.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1210
+  `-;
+   )txt"},
   };

A few complex tests that combine multiple declarators would be nice (especially 
to test that the delayed fold logic composes correctly).

```
char (*(*x[10])(short a, int b))[20];
char (*(*x[10][20])(short a, int b))[30][4

[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Still LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72498



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

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

LGTM with a few nits.




Comment at: 
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp:71-74
+  if (!getLangOpts().CPlusPlus)
+return;
+  if (getLangOpts().ObjC)
+return;

I'd combine these into a single `if`.



Comment at: 
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h:25
+public:
+  NonTrivialTypesLibcMemoryCallsCheck(StringRef Name, ClangTidyContext 
*Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;

You should do this formatting change, the per-merge check is actually correct 
for once. Don't bother with the ones in the test files though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

2020-01-16 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13384
   case Stmt::MemberExprClass: {
 expr = cast(expr)->getBase();
 break;

ilya wrote:
> rsmith wrote:
> > ilya wrote:
> > > rsmith wrote:
> > > > Hmm, don't we need to do different things for dot and arrow in this 
> > > > case?
> > > There are several test cases for an out of bounds access on an array 
> > > member using dot and arrow operators in array-bounds.cpp. Do you have a 
> > > specific test case for which you think the code is broken?
> > > There are several test cases for an out of bounds access on an array 
> > > member using dot and arrow operators in array-bounds.cpp. Do you have a 
> > > specific test case for which you think the code is broken?
> > 
> > Sure. There's a false negative for this:
> > 
> > ```
> > struct A { int n; };
> > A *a[4];
> > int *n = &a[4]->n;
> > ```
> > 
> > ... because we incorrectly visit the left-hand side of the `->` with 
> > `AllowOnePastEnd == 1`. The left-hand side of `->` is subject to 
> > lvalue-to-rvalue conversion, so can't be one-past-the-end regardless of the 
> > context in which the `->` appears.
> > ... because we incorrectly visit the left-hand side of the -> with 
> > AllowOnePastEnd == 1. The left-hand side of -> is subject to 
> > lvalue-to-rvalue conversion, so can't be one-past-the-end regardless of the 
> > context in which the -> appears.
> 
> Thanks for clarifying. So basically we don't want to allow one-past-end for 
> MemberExpr?
> Thanks for clarifying. So basically we don't want to allow one-past-end for 
> MemberExpr?

I think the point is rather that when the MemberExpr isArrow, we want to think 
of it as performing an implicit dereference first, and thus we should do 
`AllowOnePastEnd--` before recursing if that is the case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71714



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


[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2020-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71707#1821903 , @jankratochvil 
wrote:

> In D71707#1796671 , @aaron.ballman 
> wrote:
>
> > Have you considered language extensions like `__ptr32`, `__ptr64`, 
> > `__sptr`, and `__uptr` 
> > (https://docs.microsoft.com/en-us/cpp/cpp/ptr32-ptr64?view=vs-2019) which 
> > we also support?
>
>
> I think only `__uptr` support would matter to prevent some false positives. I 
> am not sure it is used anywhere. Should I really implement it?


It's not super common so if it's a problem, you can punt on it. It is used 
within the Win32 SDK though (I found at least a few uses of it). If you don't 
want to add support for them right now, you can just throw a FIXME into the 
code so we remember to add support for it at some point.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:32
+  for (;;) {
+std::string str = CheckType.getAsString();
+if (strset.count(str))

`str` should be `Str`.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:46
+
+  static const auto intptrs = llvm::StringSet<>{"uintptr_t", "intptr_t"};
+  if (find_type(intptrs, DestType, Context))

`static llvm::StringSet<> IntPtrs{"uintptr_t", "intptr_t"};`



Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:67
+
+  static const auto intptr = llvm::StringSet<>{"intptr_t"};
+  if (!find_type(intptr, SourceType, Context))

Similar here as above.



Comment at: clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h:28
+private:
+  bool find_type(const llvm::StringSet<> &strset, QualType CheckType,
+ const ASTContext &Context) const;

aaron.ballman wrote:
> These should be `findType`, `checkPointer`, and `checkIntegral` by our usual 
> naming conventions. Also, `strset` should be `StrSet` per conventions (same 
> in the definition).
This function doesn't need to be a member function, it doesn't rely on the 
class state whatsoever. I think the function should not take the container but 
instead be a templated function accepting iterators.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h:28-31
+  bool find_type(const llvm::StringSet<> &strset, QualType CheckType,
+ const ASTContext &Context) const;
+  void check_pointer(const CastExpr *MatchedCast, const ASTContext &Context);
+  void check_integral(const CastExpr *MatchedCast, const ASTContext &Context);

These should be `findType`, `checkPointer`, and `checkIntegral` by our usual 
naming conventions. Also, `strset` should be `StrSet` per conventions (same in 
the definition).



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst:24
+
+The only supported cast from a pointer to integer is ``uintptr_t``.
+

This seems outdated?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:17
+  t2 t = (t2)p;
+}

jankratochvil wrote:
> aaron.ballman wrote:
> > I'd also like to see tests for implicit casts as well as pointer width and 
> > sign extension language extensions.
> Done implicit cases.  But I do not understand what you mean by the rest - 
> could you provide an example? Thanks.
I was talking about test cases involving `__ptr32` or `__uptr`, if we wanted to 
support them.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:21
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not use cast of a pointer 
'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may 
sign-extend [bugprone-pointer-cast-widening]
+  // uint64_t u64implicit = p; // error: cannot initialize a variable of type 
'uint64_t' (aka 'unsigned long') with an lvalue of type 'void *' 
[clang-diagnostic-error]
+  uint64_t u64reinterpret = reinterpret_cast(p);

Remove commented out code.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:24
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: do not use cast of a pointer 
'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may 
sign-extend [bugprone-pointer-cast-widening]
+  // uint64_t u64static = static_cast(p); // error: static_cast from 
'void *' to 'uint64_t' (aka 'unsigned long') is not allowed
+  uintptr_t up = (uintptr_t)p;

Remove commented out code.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:32
+  t2 t = (t2)p;
+  intptr_t ip = reinterpret_cast(p);
+  __uint128_t u64ipimplicit = ip;

Can you also show that C-style casts to `intptr_t` are not diagnosed? e.g

[PATCH] D72848: Remove some SVN-specific code.

2020-01-16 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.

$URL$ is an SVN keyword substitution enabled via
`svn propset svn:keywords "URL" tools/clang/lib/Basic/Version.cpp`.
Now that we no longer use SVN, it's no longer being replaced by
anything, and we no longer offer svn exports. So remove the
$URL$-specific logic.

The "cfe" path prefix removal also no longer makes sense now that
we're on git: Both CLANG_REPOSITORY and LLVM_REPOSITORY are usually
set to https://github.com/llvm/llvm-project.git

So remove that too, and remove the "llvm" prefix removal for symmetry.
With the github url, "llvm" _is_ found in the string, but not in
the place the function expected. Nobody noticed since the llvm
repository path is only used if CLANG_REVISION and LLVM_REVISION are
different, which in the git monorepo world they never should be.
(I might remove the "// Support LLVM in a separate repository"
block in a separate commit.)


https://reviews.llvm.org/D72848

Files:
  clang/lib/Basic/Version.cpp


Index: clang/lib/Basic/Version.cpp
===
--- clang/lib/Basic/Version.cpp
+++ clang/lib/Basic/Version.cpp
@@ -28,46 +28,19 @@
   return CLANG_REPOSITORY_STRING;
 #else
 #ifdef CLANG_REPOSITORY
-  StringRef URL(CLANG_REPOSITORY);
+  return CLANG_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // If the CLANG_REPOSITORY is empty, try to use the SVN keyword. This helps 
us
-  // pick up a tag in an SVN export, for example.
-  StringRef SVNRepository("$URL$");
-  if (URL.empty()) {
-URL = SVNRepository.slice(SVNRepository.find(':'),
-  SVNRepository.find("/lib/Basic"));
-  }
-
-  // Strip off version from a build from an integration branch.
-  URL = URL.slice(0, URL.find("/src/tools/clang"));
-
-  // Trim path prefix off, assuming path came from standard cfe path.
-  size_t Start = URL.find("cfe/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start + 4);
-
-  return URL;
 #endif
 }
 
 std::string getLLVMRepositoryPath() {
 #ifdef LLVM_REPOSITORY
-  StringRef URL(LLVM_REPOSITORY);
+  return LLVM_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // Trim path prefix off, assuming path came from standard llvm path.
-  // Leave "llvm/" prefix to distinguish the following llvm revision from the
-  // clang revision.
-  size_t Start = URL.find("llvm/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start);
-
-  return URL;
 }
 
 std::string getClangRevision() {


Index: clang/lib/Basic/Version.cpp
===
--- clang/lib/Basic/Version.cpp
+++ clang/lib/Basic/Version.cpp
@@ -28,46 +28,19 @@
   return CLANG_REPOSITORY_STRING;
 #else
 #ifdef CLANG_REPOSITORY
-  StringRef URL(CLANG_REPOSITORY);
+  return CLANG_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // If the CLANG_REPOSITORY is empty, try to use the SVN keyword. This helps us
-  // pick up a tag in an SVN export, for example.
-  StringRef SVNRepository("$URL$");
-  if (URL.empty()) {
-URL = SVNRepository.slice(SVNRepository.find(':'),
-  SVNRepository.find("/lib/Basic"));
-  }
-
-  // Strip off version from a build from an integration branch.
-  URL = URL.slice(0, URL.find("/src/tools/clang"));
-
-  // Trim path prefix off, assuming path came from standard cfe path.
-  size_t Start = URL.find("cfe/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start + 4);
-
-  return URL;
 #endif
 }
 
 std::string getLLVMRepositoryPath() {
 #ifdef LLVM_REPOSITORY
-  StringRef URL(LLVM_REPOSITORY);
+  return LLVM_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // Trim path prefix off, assuming path came from standard llvm path.
-  // Leave "llvm/" prefix to distinguish the following llvm revision from the
-  // clang revision.
-  size_t Start = URL.find("llvm/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start);
-
-  return URL;
 }
 
 std::string getClangRevision() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72850: [CMake] Use LinuxRemoteTI instead of LinuxLocalTI in CrossWinToARMLinux cmake cache

2020-01-16 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb created this revision.
broadwaylamb added reviewers: vvereschaka, aorlov, andreil99.
Herald added subscribers: cfe-commits, kristof.beyls, mgorny.
Herald added a project: clang.

Depends on D72847 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72850

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -99,7 +99,7 @@
 # Remote test configuration.
 if(DEFINED REMOTE_TEST_HOST)
   set(DEFAULT_TEST_EXECUTOR 
"SSHExecutor('${REMOTE_TEST_HOST}', '${REMOTE_TEST_USER}')")
-  set(DEFAULT_TEST_TARGET_INFO  
"libcxx.test.target_info.LinuxLocalTI")
+  set(DEFAULT_TEST_TARGET_INFO  
"libcxx.test.target_info.LinuxRemoteTI")
 
   # Allow override with the custom values.
   if(NOT DEFINED LIBUNWIND_TARGET_INFO)


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -99,7 +99,7 @@
 # Remote test configuration.
 if(DEFINED REMOTE_TEST_HOST)
   set(DEFAULT_TEST_EXECUTOR "SSHExecutor('${REMOTE_TEST_HOST}', '${REMOTE_TEST_USER}')")
-  set(DEFAULT_TEST_TARGET_INFO  "libcxx.test.target_info.LinuxLocalTI")
+  set(DEFAULT_TEST_TARGET_INFO  "libcxx.test.target_info.LinuxRemoteTI")
 
   # Allow override with the custom values.
   if(NOT DEFINED LIBUNWIND_TARGET_INFO)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 237fd94 - [Hexagon] Remove unnecessary case in StringSwitch, NFC

2020-01-16 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2020-01-16T10:00:57-06:00
New Revision: 237fd94312526c7aef55f929b51696bba451dab8

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

LOG: [Hexagon] Remove unnecessary case in StringSwitch, NFC

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index e4d9ea8a70f9..d2400472c63e 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -31,7 +31,6 @@ static StringRef getDefaultHvxLength(StringRef Cpu) {
   .Case("v60", "64b")
   .Case("v62", "64b")
   .Case("v65", "64b")
-  .Case("v66", "128b")
   .Default("128b");
 }
 



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


[clang] fb9413c - Remove some SVN-specific code.

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

Author: Nico Weber
Date: 2020-01-16T11:02:52-05:00
New Revision: fb9413cb84cc422426c81f6464083795e781566b

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

LOG: Remove some SVN-specific code.

$URL$ is an SVN keyword substitution enabled via
`svn propset svn:keywords "URL" tools/clang/lib/Basic/Version.cpp`.
Now that we no longer use SVN, it's no longer being replaced by
anything, and we no longer offer svn exports. So remove the
$URL$-specific logic.

The "cfe" path prefix removal also no longer makes sense now that
we're on git: Both CLANG_REPOSITORY and LLVM_REPOSITORY are usually
set to https://github.com/llvm/llvm-project.git

So remove that too, and remove the "llvm" prefix removal for symmetry.
With the github url, "llvm" _is_ found in the string, but not in
the place the function expected. Nobody noticed since the llvm
repository path is only used if CLANG_REVISION and LLVM_REVISION are
different, which in the git monorepo world they never should be.
(I might remove the "// Support LLVM in a separate repository"
block in a separate commit.)

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

Added: 


Modified: 
clang/lib/Basic/Version.cpp

Removed: 




diff  --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index c69d13b2f689..c4b7d34ed168 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -28,46 +28,19 @@ std::string getClangRepositoryPath() {
   return CLANG_REPOSITORY_STRING;
 #else
 #ifdef CLANG_REPOSITORY
-  StringRef URL(CLANG_REPOSITORY);
+  return CLANG_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // If the CLANG_REPOSITORY is empty, try to use the SVN keyword. This helps 
us
-  // pick up a tag in an SVN export, for example.
-  StringRef SVNRepository("$URL$");
-  if (URL.empty()) {
-URL = SVNRepository.slice(SVNRepository.find(':'),
-  SVNRepository.find("/lib/Basic"));
-  }
-
-  // Strip off version from a build from an integration branch.
-  URL = URL.slice(0, URL.find("/src/tools/clang"));
-
-  // Trim path prefix off, assuming path came from standard cfe path.
-  size_t Start = URL.find("cfe/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start + 4);
-
-  return URL;
 #endif
 }
 
 std::string getLLVMRepositoryPath() {
 #ifdef LLVM_REPOSITORY
-  StringRef URL(LLVM_REPOSITORY);
+  return LLVM_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // Trim path prefix off, assuming path came from standard llvm path.
-  // Leave "llvm/" prefix to distinguish the following llvm revision from the
-  // clang revision.
-  size_t Start = URL.find("llvm/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start);
-
-  return URL;
 }
 
 std::string getClangRevision() {



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


[PATCH] D72848: Remove some SVN-specific code.

2020-01-16 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb9413cb84cc: Remove some SVN-specific code. (authored by 
thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72848

Files:
  clang/lib/Basic/Version.cpp


Index: clang/lib/Basic/Version.cpp
===
--- clang/lib/Basic/Version.cpp
+++ clang/lib/Basic/Version.cpp
@@ -28,46 +28,19 @@
   return CLANG_REPOSITORY_STRING;
 #else
 #ifdef CLANG_REPOSITORY
-  StringRef URL(CLANG_REPOSITORY);
+  return CLANG_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // If the CLANG_REPOSITORY is empty, try to use the SVN keyword. This helps 
us
-  // pick up a tag in an SVN export, for example.
-  StringRef SVNRepository("$URL$");
-  if (URL.empty()) {
-URL = SVNRepository.slice(SVNRepository.find(':'),
-  SVNRepository.find("/lib/Basic"));
-  }
-
-  // Strip off version from a build from an integration branch.
-  URL = URL.slice(0, URL.find("/src/tools/clang"));
-
-  // Trim path prefix off, assuming path came from standard cfe path.
-  size_t Start = URL.find("cfe/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start + 4);
-
-  return URL;
 #endif
 }
 
 std::string getLLVMRepositoryPath() {
 #ifdef LLVM_REPOSITORY
-  StringRef URL(LLVM_REPOSITORY);
+  return LLVM_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // Trim path prefix off, assuming path came from standard llvm path.
-  // Leave "llvm/" prefix to distinguish the following llvm revision from the
-  // clang revision.
-  size_t Start = URL.find("llvm/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start);
-
-  return URL;
 }
 
 std::string getClangRevision() {


Index: clang/lib/Basic/Version.cpp
===
--- clang/lib/Basic/Version.cpp
+++ clang/lib/Basic/Version.cpp
@@ -28,46 +28,19 @@
   return CLANG_REPOSITORY_STRING;
 #else
 #ifdef CLANG_REPOSITORY
-  StringRef URL(CLANG_REPOSITORY);
+  return CLANG_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // If the CLANG_REPOSITORY is empty, try to use the SVN keyword. This helps us
-  // pick up a tag in an SVN export, for example.
-  StringRef SVNRepository("$URL$");
-  if (URL.empty()) {
-URL = SVNRepository.slice(SVNRepository.find(':'),
-  SVNRepository.find("/lib/Basic"));
-  }
-
-  // Strip off version from a build from an integration branch.
-  URL = URL.slice(0, URL.find("/src/tools/clang"));
-
-  // Trim path prefix off, assuming path came from standard cfe path.
-  size_t Start = URL.find("cfe/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start + 4);
-
-  return URL;
 #endif
 }
 
 std::string getLLVMRepositoryPath() {
 #ifdef LLVM_REPOSITORY
-  StringRef URL(LLVM_REPOSITORY);
+  return LLVM_REPOSITORY;
 #else
-  StringRef URL("");
+  return "";
 #endif
-
-  // Trim path prefix off, assuming path came from standard llvm path.
-  // Leave "llvm/" prefix to distinguish the following llvm revision from the
-  // clang revision.
-  size_t Start = URL.find("llvm/");
-  if (Start != StringRef::npos)
-URL = URL.substr(Start);
-
-  return URL;
 }
 
 std::string getClangRevision() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7f5f6ff - [Hexagon] Add preprocessor test for hexagonv66

2020-01-16 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2020-01-16T10:18:58-06:00
New Revision: 7f5f6ff5476b6dafb5be2f9c102d9b324a313717

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

LOG: [Hexagon] Add preprocessor test for hexagonv66

Added: 


Modified: 
clang/test/Preprocessor/hexagon-predefines.c

Removed: 




diff  --git a/clang/test/Preprocessor/hexagon-predefines.c 
b/clang/test/Preprocessor/hexagon-predefines.c
index 1d122c0e8275..e833bf862116 100644
--- a/clang/test/Preprocessor/hexagon-predefines.c
+++ b/clang/test/Preprocessor/hexagon-predefines.c
@@ -33,6 +33,13 @@
 // CHECK-V65-NOT: #define __HVX__ 1
 // CHECK-V65: #define __hexagon__ 1
 
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv66 
%s | FileCheck %s -check-prefix CHECK-V66
+// CHECK-V66: #define __HEXAGON_ARCH__ 66
+// CHECK-V66: #define __HEXAGON_V66__ 1
+// CHECK-V66-NOT: #define __HVX_LENGTH__
+// CHECK-V66-NOT: #define __HVX__ 1
+// CHECK-V66: #define __hexagon__ 1
+
 // The HVX flags are explicitly defined by the driver.
 // For v60,v62,v65 - 64B mode is default
 // For v66 and future archs - 128B is default



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


[PATCH] D72855: Make LLVM_APPEND_VC_REV=OFF affect clang, lld, and lldb as well.

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

A very late follow-up to my question in D37272 
 :)


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

https://reviews.llvm.org/D72855



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


[PATCH] D72855: Make LLVM_APPEND_VC_REV=OFF affect clang, lld, and lldb as well.

2020-01-16 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.
thakis added a comment.

A very late follow-up to my question in D37272 
 :)


When LLVM_APPEND_VC_REV=OFF is set, the current git hash is no
longer embedded into binaries (mostly for --version output).
Without it, most binaries need to relink after every single
commit, even if they didn't change otherwise (due to, say,
a documentation-only commit).

LLVM_APPEND_VC_REV is ON by default, so this doesn't change the
default behavior of anything.

With this, all clients of GenerateVersionFromVCS.cmake honor
LLVM_APPEND_VC_REV.


https://reviews.llvm.org/D72855

Files:
  clang/lib/Basic/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lldb/source/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/CMake.rst


Index: llvm/docs/CMake.rst
===
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -272,7 +272,7 @@
   Generate build targets for the LLVM benchmarks. Defaults to ON.
 
 **LLVM_APPEND_VC_REV**:BOOL
-  Embed version control revision info (svn revision number or Git revision id).
+  Embed version control revision info (Git revision id).
   The version info is provided by the ``LLVM_REVISION`` macro in
   ``llvm/include/llvm/Support/VCSRevision.h``. Developers using git who don't
   need revision info can disable this option to avoid re-linking most binaries
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -78,6 +78,8 @@
 set(LLVM_INCLUDE_DIRS "@LLVM_CONFIG_INCLUDE_DIRS@")
 set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
 
+set(LLVM_APPEND_VC_REV "@LLVM_APPEND_VC_REV@")
+
 # These variables are duplicated for install tree but they have different
 # values for build tree.  LLVM_INCLUDE_DIRS contains both source
 # and generated include directories while the following variables have
Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -18,14 +18,14 @@
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
 set(generate_vcs_version_script 
"${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
 
-if(lldb_vc)
+if(lldb_vc AND LLVM_APPEND_VC_REV)
   set(lldb_source_dir ${LLDB_SOURCE_DIR})
 endif()
 
 add_custom_command(OUTPUT "${version_inc}"
   DEPENDS "${lldb_vc}" "${generate_vcs_version_script}"
   COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB"
-   "-DLLDB_SOURCE_DIR=${LLDB_SOURCE_DIR}"
+   "-DLLDB_SOURCE_DIR=${lldb_source_dir}"
"-DHEADER_FILE=${version_inc}"
-P "${generate_vcs_version_script}")
 
Index: lld/Common/CMakeLists.txt
===
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -8,14 +8,14 @@
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
 set(generate_vcs_version_script 
"${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
 
-if(lld_vc)
+if(lld_vc AND LLVM_APPEND_VC_REV)
   set(lld_source_dir ${LLD_SOURCE_DIR})
 endif()
 
 add_custom_command(OUTPUT "${version_inc}"
   DEPENDS "${lld_vc}" "${generate_vcs_version_script}"
   COMMAND ${CMAKE_COMMAND} "-DNAMES=LLD"
-  "-DLLD_SOURCE_DIR=${LLD_SOURCE_DIR}"
+  "-DLLD_SOURCE_DIR=${lld_source_dir}"
   "-DHEADER_FILE=${version_inc}"
   -P "${generate_vcs_version_script}")
 
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -12,10 +12,10 @@
 
 set(generate_vcs_version_script 
"${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
 
-if(llvm_vc)
+if(llvm_vc AND LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
 endif()
-if(clang_vc)
+if(clang_vc AND LLVM_APPEND_VC_REV)
   set(clang_source_dir ${CLANG_SOURCE_DIR})
 endif()
 


Index: llvm/docs/CMake.rst
===
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -272,7 +272,7 @@
   Generate build targets for the LLVM benchmarks. Defaults to ON.
 
 **LLVM_APPEND_VC_REV**:BOOL
-  Embed version control revision info (svn revision number or Git revision id).
+  Embed version control revision info (Git revision id).
   The version info is provided by the ``LLVM_REVISION`` macro in
   ``llvm/include/llvm/Support/VCSRevision.h``. Developers using git who don't
   need revision info can disable this option to avoid re-linking most binaries
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -78,6 +78

[PATCH] D72705: [clang][checkers] Added new checker 'alpha.unix.ErrorReturn'.

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

I am experimenting with somewhat other check algorithm for this problem, the 
review of this code can be suspended for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-16 Thread Thibault North via Phabricator via cfe-commits
tnorth updated this revision to Diff 238513.
tnorth added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Thanks for your time and feedback.

- Update diff with context,
- remove public declaration of LoadConfigFile,
- change prototype of LoadConfigFile and simplify it,
- avoid string copy to ConfigFile, use StringRef directly,
- don't stat the file before attempting to read it.

Regarding the tests, I am unsure how to do this currenlty (I'd need to read 
some docs/other examples).
I didn't have in mind the use case of BasedOnStyle: file:some/path.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14350,6 +14350,35 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9: explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style8 = getStyle("file:/e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(*Style8, getGoogleStyle());
+
+  // Test 10: relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style9 = getStyle("file:../../e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style9);
+  ASSERT_EQ(*Style9, getGoogleStyle());
+
+  // Test 11: missing explicit format file
+  auto Style10 = getStyle("file:/e/missing.clang-format",
+  "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style10);
+  llvm::consumeError(Style10.takeError());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2519,6 +2519,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2568,6 +2570,22 @@
 
 const char *DefaultFallbackStyle = "LLVM";
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS) {
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  std::error_code ReadFileError = Text.getError();
+  if (ReadFileError) {
+return make_string_error("Error reading config file " + ReadFileError.message());
+  }
+  FormatStyle Style = getLLVMStyle();
+  std::error_code ParseFileError = parseConfiguration(Text.get()->getBuffer(), &Style);
+  if (ParseFileError != ParseError::Success) {
+return make_string_error("Error parsing config file " + ParseFileError.message());
+  }
+  return Style;
+}
+
 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyleName,
  StringRef Code,
@@ -2588,6 +2606,12 @@
 return Style;
   }
 
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_lower("file:")) {
+return LoadConfigFile(StyleName.substr(5), FS);
+  }
+
   if (!StyleName.equals_lower("file")) {
 if (!getPredefinedStyle(StyleName, Style.Language, &Style))
   return make_string_error("Invalid value for -style");
@@ -2628,24 +2652,7 @@
 }
 
 if (FoundConfigFile) {
-  llvm::ErrorOr> Text =
-  FS->getBufferForFile(ConfigFile.str());
-  if (std::error_code EC = Text.getError())
-return make_string_error(EC.message());
-  if (std::error_code ec =
-  parseConfiguration(Text.get()->getBuffer(), &Style)) {
-if (ec == ParseError::Unsuitable) {
-  if (!UnsuitableConfigFiles.empty())
-UnsuitableConfigFiles.append(", ");
-  UnsuitableConfigFiles.append(ConfigFile);
-  continue;
-}
-

[clang] bc413da - [Hexagon] Fix alignment info for __builtin_circ_lduh

2020-01-16 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2020-01-16T10:54:45-06:00
New Revision: bc413da0865d6c0dba1c39f185298806c60890e3

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

LOG: [Hexagon] Fix alignment info for __builtin_circ_lduh

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 74742023d1b3..00eb5332a746 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2916,7 +2916,7 @@ bool Sema::CheckHexagonBuiltinArgument(unsigned 
BuiltinID, CallExpr *TheCall) {
 { Hexagon::BI__builtin_circ_ldd,  {{ 3, true,  4,  3 }} },
 { Hexagon::BI__builtin_circ_ldw,  {{ 3, true,  4,  2 }} },
 { Hexagon::BI__builtin_circ_ldh,  {{ 3, true,  4,  1 }} },
-{ Hexagon::BI__builtin_circ_lduh, {{ 3, true,  4,  0 }} },
+{ Hexagon::BI__builtin_circ_lduh, {{ 3, true,  4,  1 }} },
 { Hexagon::BI__builtin_circ_ldb,  {{ 3, true,  4,  0 }} },
 { Hexagon::BI__builtin_circ_ldub, {{ 3, true,  4,  0 }} },
 { Hexagon::BI__builtin_circ_std,  {{ 3, true,  4,  3 }} },



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


[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked 2 inline comments as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7709-7712
 isa(Next->getAssociatedExpression()) ||
 isa(Next->getAssociatedExpression()) ||
-isa(Next->getAssociatedExpression())) &&
+isa(Next->getAssociatedExpression()) ||
+isa(Next->getAssociatedExpression())) &&

ABataev wrote:
> This assertion must check that the expression is just an lvalue, no?
Yes.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15442-15443
+  CurComponents.emplace_back(CurE, nullptr);
+} else if (auto *CurE = dyn_cast(E)) {
+  E = CurE->getLHS()->IgnoreParenImpCasts();
 } else {

ABataev wrote:
> Why just the LHS is analyzed? Also, what about support for other expressions, 
> like casting, call, choose etc., which may result in lvalue?
1. LHS: I'll fix that
2. I'll add support for casting, call, etc
3. For "choose" are you referring to something like (a < b ? b : a)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[clang] 7acfda6 - [llvm] Make new pass manager's OptimizationLevel a class

2020-01-16 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2020-01-16T09:00:56-08:00
New Revision: 7acfda633f1378344efde22bfed242dd56c26cdd

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

LOG: [llvm] Make new pass manager's OptimizationLevel a class

Summary:
The old pass manager separated speed optimization and size optimization
levels into two unsigned values. Coallescing both in an enum in the new
pass manager may lead to unintentional casts and comparisons.

In particular, taking a look at how the loop unroll passes were constructed
previously, the Os/Oz are now (==new pass manager) treated just like O3,
likely unintentionally.

This change disallows raw comparisons between optimization levels, to
avoid such unintended effects. As an effect, the O{s|z} behavior changes
for loop unrolling and loop unroll and jam, matching O2 rather than O3.

The change also parameterizes the threshold values used for loop
unrolling, primarily to aid testing.

Reviewers: tejohnson, davidxl

Reviewed By: tejohnson

Subscribers: zzheng, ychen, mehdi_amini, hiraditya, steven_wu, dexonsmith, 
dang, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
llvm/test/Transforms/LoopUnroll/opt-levels.ll
llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 0bfcab88a3a9..f379c103b694 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -924,7 +924,7 @@ static PassBuilder::OptimizationLevel mapToLevel(const 
CodeGenOptions &Opts) {
 llvm_unreachable("Invalid optimization level!");
 
   case 1:
-return PassBuilder::O1;
+return PassBuilder::OptimizationLevel::O1;
 
   case 2:
 switch (Opts.OptimizeSize) {
@@ -932,17 +932,17 @@ static PassBuilder::OptimizationLevel mapToLevel(const 
CodeGenOptions &Opts) {
   llvm_unreachable("Invalid optimization level for size!");
 
 case 0:
-  return PassBuilder::O2;
+  return PassBuilder::OptimizationLevel::O2;
 
 case 1:
-  return PassBuilder::Os;
+  return PassBuilder::OptimizationLevel::Os;
 
 case 2:
-  return PassBuilder::Oz;
+  return PassBuilder::OptimizationLevel::Oz;
 }
 
   case 3:
-return PassBuilder::O3;
+return PassBuilder::OptimizationLevel::O3;
   }
 }
 

diff  --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index e7db8fd421fe..828ac004117e 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -143,11 +143,26 @@ class PassBuilder {
   ///
   /// This enumerates the LLVM-provided high-level optimization levels. Each
   /// level has a specific goal and rationale.
-  enum OptimizationLevel {
+  class OptimizationLevel final {
+unsigned SpeedLevel = 2;
+unsigned SizeLevel = 0;
+OptimizationLevel(unsigned SpeedLevel, unsigned SizeLevel)
+: SpeedLevel(SpeedLevel), SizeLevel(SizeLevel) {
+  // Check that only valid combinations are passed.
+  assert(SpeedLevel <= 3 &&
+ "Optimization level for speed should be 0, 1, 2, or 3");
+  assert(SizeLevel <= 2 &&
+ "Optimization level for size should be 0, 1, or 2");
+  assert((SizeLevel == 0 || SpeedLevel == 2) &&
+ "Optimize for size should be encoded with speedup level == 2");
+}
+
+  public:
+OptimizationLevel() = default;
 /// Disable as many optimizations as possible. This doesn't completely
 /// disable the optimizer in all cases, for example always_inline functions
 /// can be required to be inlined for correctness.
-O0,
+static const OptimizationLevel O0;
 
 /// Optimize quickly without destroying debuggability.
 ///
@@ -161,10 +176,9 @@ class PassBuilder {
 ///
 /// As an example, complex loop transformations such as versioning,
 /// vectorization, or fusion don't make sense here due to the degree to
-/// which the executed code 
diff ers from the source code, and the compile time
-/// cost.
-O1,
-
+/// which the executed code 
diff ers from the source code, and the compile
+/// time cost.
+static const OptimizationLevel O1;
 /// Optimize for fast execution as much as possible without triggering
 /// significant incremental compile time or code size growth.
 ///
@@ -181,8 +195,7 @@ class PassBuilder {
 ///
 /// This is expected to be a good default optimization level for the vast
 /// majority of users.
-O2,
-
+st

[PATCH] D72547: [llvm] Make new pass manager's OptimizationLevel a class

2020-01-16 Thread Mircea Trofin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7acfda633f13: [llvm] Make new pass manager's 
OptimizationLevel a class (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72547

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/test/Transforms/LoopUnroll/opt-levels.ll
  llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll

Index: llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll
===
--- /dev/null
+++ llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll
@@ -0,0 +1,61 @@
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O2
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O3
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Os
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -enable-npm-unroll-and-jam -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Oz
+
+; Check that Os and Oz are optimized like O2, not like O3. To easily highlight
+; the behavior, we artificially disable unrolling for anything but O3 by setting
+; the default threshold to 0.
+
+; O3: for.inner.1
+; O2-NOT: for.inner.1
+; Os-NOT: for.inner.1
+; Oz-NOT: for.inner.1
+
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+
+define void @test1(i32 %I, i32 %J, i32* noalias nocapture %A, i32* noalias nocapture readonly %B) #0 {
+entry:
+  %cmp = icmp ne i32 %J, 0
+  %cmpJ = icmp ne i32 %I, 0
+  %or.cond = and i1 %cmp, %cmpJ
+  br i1 %or.cond, label %for.outer.preheader, label %for.end
+
+for.outer.preheader:
+  br label %for.outer
+
+for.outer:
+  %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ]
+  br label %for.inner
+
+for.inner:
+  %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ]
+  %sum = phi i32 [ 0, %for.outer ], [ %add, %for.inner ]
+  %arrayidx = getelementptr inbounds i32, i32* %B, i32 %j
+  %0 = load i32, i32* %arrayidx, align 4, !tbaa !5
+  %add = add i32 %0, %sum
+  %inc = add nuw i32 %j, 1
+  %exitcond = icmp eq i32 %inc, %J
+  br i1 %exitcond, label %for.latch, label %for.inner
+
+for.latch:
+  %add.lcssa = phi i32 [ %add, %for.inner ]
+  %arrayidx6 = getelementptr inbounds i32, i32* %A, i32 %i
+  store i32 %add.lcssa, i32* %arrayidx6, align 4, !tbaa !5
+  %add8 = add nuw i32 %i, 1
+  %exitcond25 = icmp eq i32 %add8, %I
+  br i1 %exitcond25, label %for.end.loopexit, label %for.outer
+
+for.end.loopexit:
+  br label %for.end
+
+for.end:
+  ret void
+}
+
+
+
+!5 = !{!6, !6, i64 0}
+!6 = !{!"int", !7, i64 0}
+!7 = !{!"omnipotent char", !8, i64 0}
+!8 = !{!"Simple C/C++ TBAA"}
Index: llvm/test/Transforms/LoopUnroll/opt-levels.ll
===
--- /dev/null
+++ llvm/test/Transforms/LoopUnroll/opt-levels.ll
@@ -0,0 +1,47 @@
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O2
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=O3
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Os
+; RUN: opt < %s -S -passes="default" -unroll-runtime=true -unroll-threshold-default=0 -unroll-threshold-aggressive=300 | FileCheck %s -check-prefix=Oz
+
+; Check that Os and Oz are optimized like O2, not like O3. To easily highlight
+; the behavior, we artificially disable unrolling for anything but O3 by setting
+; the default threshold to 0.
+
+; O3: loop2.preheader
+; O2-NOT: loop2.preheader
+; Os-NOT: loop2.preheader
+; Oz-NOT: loop2.preheader
+
+define void @unroll(i32 %iter, i32* %addr1, i32* %addr2) nounwind {
+entry:
+  br label %loop1
+
+loop1:
+  %iv1 = phi i32 [ 0, %entry ], [ %inc1, %loop1.latch ]
+  %offset1 = getelementptr i32, i32* %addr1, i32 %iv1
+  store i32 %iv1, i32* %offset1, align 4
+  br label %loop2.header
+
+loop2.header:
+  %e = icmp uge i32 %iter, 1
+  br i1 %e, label %loop2, label %exit2
+
+loop2:
+  %iv2 = phi i32 [ 0, %loop2.header ], [ %inc2, %loop2 ]
+  %offset2 = getelementptr i32, i32* %addr2, i32 %iv2
+  store i32 %iv2, i32* %offset2, align 4
+  %inc2 = add i32 %iv2, 1
+  %exitcnd2 = icmp uge i32 %inc2, %iter
+  br i1 %exitcnd2, label %exit2, label %loop2
+
+e

[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Not sure that we need to dig that deep. Maybe just keep thw original analysis 
for the known expressions and map all other lvalues without some extra 
analysis, just like DeclRefExpr nodes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-01-16 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked 2 inline comments as done.
tejohnson added inline comments.



Comment at: llvm/test/Transforms/WholeProgramDevirt/import-indir.ll:2
 ; Test that we correctly import an indir resolution for type identifier 
"typeid1".
-; RUN: opt -S -wholeprogramdevirt -wholeprogramdevirt-summary-action=import 
-wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml 
-wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
+; RUN: opt -S -wholeprogramdevirt -whole-program-visibility 
-wholeprogramdevirt-summary-action=import 
-wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml 
-wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
 ; RUN: FileCheck --check-prefix=SUMMARY %s < %t

evgeny777 wrote:
> Why do you need `-whole-program-visibility` here? Correct me if I'm wrong, 
> but AFAIK module scanning doesn't happen during import and GV visibility 
> should be taken from imported summary.
Before my patch, type tests were only inserted for vtables with hidden LTO 
visibility. Therefore, the very presence of type tests communicated the hidden 
visibility and enabled the WPD.

With this patch, to support enabling WPD aggressively at LTO time, we now 
insert type tests unconditionally under -fwhole-program-vtables. The 
vcall_visibility metadata tells LTO how to interpret them. And the new options 
allow changing those to hidden visibility to get the more aggressive WPD.

Because these legacy tests have type tests but no vcall_visibility metadata, we 
now will conservatively treat them as having public LTO visibility. This option 
is therefore required to convert the summarized (default public) vcall 
visibility into hidden to get the prior more aggressive behavior they are 
trying to test.

Note I could have instead changed the assembly here to add hidden 
vcall_visibility metadata everywhere. That seemed a little onerous so that's 
why I just added the option. I could add a comment to that effect if it would 
help?



Comment at: llvm/tools/opt/opt.cpp:634
+  // not performed via opt.
+  updateVCallVisibilityInModule(*M,
+/* WholeProgramVisibilityEnabledInLTO */ 
false);

evgeny777 wrote:
> Hm, looks like I don't fully understand this. I have following concerns:
> 
> 1) According to your changes every time I use `opt -wholeprogramdevirt` I 
> also have to pass `-whole-program-visibility`. Has `-wholeprogramdevirt` flag 
> become no-op without this additional flag? If so this looks counter intuitive 
> to me.
> 
> 2) When I use `opt -wholeprogramdevirt` default constructor of 
> `WholeProgramDevirt` class is called and `UseCommandLine` flag is set to 
> true. Can't I use this flag to effectively lower visibility in module instead 
> of playing with metadata?
> 
> ```
> if (VS->vCallVisibility() == GlobalObject::VCallVisibilityPublic && 
> !UseCommandLine)
>  return false;
> ```
> 
> According to your changes every time I use opt -wholeprogramdevirt I also 
> have to pass -whole-program-visibility. Has -wholeprogramdevirt flag become 
> no-op without this additional flag? If so this looks counter intuitive to me.

No, it wouldn't be needed if the tests contained !vcall_visibility metadata 
indicating hidden LTO visibility (see my earlier comment response).

> When I use opt -wholeprogramdevirt default constructor of WholeProgramDevirt 
> class is called and UseCommandLine flag is set to true. Can't I use this flag 
> to effectively lower visibility in module instead of playing with metadata?

I could do that. What it would mean though is that we would be unable to use 
opt for any future testing of vtables intended to have public vcall visibility 
(either through a lack of that metadata, or explicit vcall_vsibility metadata 
indicating public). Which might be ok - in fact all my new testing of this 
behavior is via llvm-lto2 or the linkers. I suppose that would obviate this 
change as well as all the opt based test changes to pass the flag. Do you think 
that is better?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71913



___
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-01-16 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238527.
baloghadamsoftware retitled this revision from "[clang-tidy] New check 
cppcoreguidelines-prefer-initialization-list" to "[clang-tidy] New check 
cppcoreguidelines-prefer-initializer".
baloghadamsoftware added a comment.

Indentation of the code fixed in the documentation.


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

https://reviews.llvm.org/D71199

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -0,0 +1,407 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+
+class Simple1 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple1() {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple1(int nn, double xx) {
+// CHECK-FIXES: Simple1(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple1() = default;
+};
+
+class Simple2 {
+  int n;
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple2() : n (0) {
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple2(int nn, double xx) : n(nn) {
+// CHECK-FIXES: Simple2(int nn, double xx) : n(nn), x(xx) {
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple2() = default;
+};
+
+class Simple3 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+
+public:
+  Simple3() : x (0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple3(int nn, double xx) : x(xx) {
+// CHECK-FIXES: Simple3(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple3() = default;
+};
+
+int something_int();
+double something_double();
+
+class Simple4 {
+  int n;
+
+public:
+  Simple4() {
+// CHECK-FIXES: Simple4() : n(something_int()) {
+n = something_int();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple4() = default;
+};
+
+static bool dice();
+
+class Complex1 {
+  int n;
+  int m;
+
+public:
+  Complex1() : n(0) {
+if (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional expression
+  }
+
+  ~Complex1() = default;
+};
+
+class Complex2 {
+  int n;
+  int m;
+
+public:
+  Complex2() : n(0) {
+if (!dice())
+  return;
+m = 1;
+// NO-MESSAGES: initialization of 'm' follows a conditional expression
+  }
+
+  ~Complex2() = default;
+};
+
+class Complex3 {
+  int n;
+  int m;
+
+public:
+  Complex3() : n(0) {
+while (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Going to investigate few interesting cases of `findExplicitReferences` not 
working as intended and opting out for a clean approach that prevents 
duplicates from getting into the reference set.




Comment at: clang-tools-extra/clangd/FindTarget.cpp:620
+  if (llvm::dyn_cast(E->getMemberDecl()))
+NameLocation = E->getEndLoc();
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),

kadircet wrote:
> instead of patching the source location for destructors. we should probably 
> not report anything for them in here, as they will be reported correctly as 
> typelocs.
> 
> So you can check for `E->getMemberNameInfo().getNamedTypoInfo()` and bail out 
> if its non-null, which means this is a constructor/destructor/operator with a 
> typeloc that will be visited separately and result in the same ref. That way 
> we would also get rid of duplicate refs being reported by 
> `findExplicitReferences`, API doesn't mention anything about those but most 
> of the callers would fail in the presence of duplicates, therefore I think we 
> shouldn't be reporting duplicates. (for example the main visitor actually 
> makes sure typelocs are not visited twice).
> 
> also could you add unittests for constructor and operator cases as well to 
> make sure we get exactly one reference for those as well.
> instead of patching the source location for destructors. we should probably 
> not report anything for them in here, as they will be reported correctly as 
> typelocs.

Yes, I thought about that, but I decided against it because IIUC this would 
prevent destructors/ctors from appearing in x-refs which might be a regression. 
Also, this might be incorrect for cases like this one:

```
class Bar {};

class Foo {
public:
  operator Bar() const { return Bar(); }
};

int main() {
  Foo foo;
  Bar bar = foo.operator Bar();
}
```

Here, if we bail out on `foo.operator Bar()` we would miss the reference to the 
`operator Bar()` which we might want to preserve.

Actually, looking at the `FindTargets` unittests, there is something 
interesting happening: references to constructor have the constructor as the 
target, but destructor references target typename itself.

Another thing that is happening is that the following code has two references 
of bar at the same location:

```
class Foo {
public:
  operator $0^$1^Bar() const { return Bar(); }
};
```

I'm on it right now.

> also could you add unittests for constructor and operator cases as well to 
> make sure we get exactly one reference for those as well.

Sure!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-16 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238528.
baloghadamsoftware added a comment.

Indentation of the code fixed in the documentation.


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

https://reviews.llvm.org/D71001

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+class C {
+  int num;
+public:
+  explicit C(int n) : num(n) {}
+};
+
+void bad_new(int n, int m) {
+  C *p = new C(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  C \*p = new C\(n}} + 10{{\);$}}
+
+  p = new C(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - 10{{\);$}}
+
+  p = new C(n) + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} + m{{\);$}}
+
+  p = new C(n) - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - (m + 10){{\);$}}
+
+  p = new C(n) - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new C\(n}} - m{{\) \+ 10;$}}
+  // FIXME: Should be {{^  p = new C\(n}} - m + 10{{\);$}}
+}
+
+void bad_new_array(int n, int m) {
+  char *p = new char[n] + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = new char\[n}} + 10{{\];$}}
+
+  p = new char[n] - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - 10{{\];$}}
+
+  p = new char[n] + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} + m{{\];$}}
+
+  p = new char[n] - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - (m + 10){{\];$}}
+
+  p = new char[n] - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = new char\[n}} - m{{\] \+ 10;$}}
+  // FIXME: should be {{^  p = new char\[n}} - m + 10{{\];$}}
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void bad_malloc(int n) {
+  char *p = (char *)malloc(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = \(char \*\)malloc\(n}} + 10{{\);$}}
+
+  p = (char *)malloc(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  p = \(char \*\)malloc\(n}} - 10{{\);$}}
+
+  p = (char *)malloc(n) + n;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic 

[PATCH] D72635: Add "context" capability to Thread Safety Analysis

2020-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: aaronpuchert, delesley.
aaron.ballman added a comment.

In D72635#1822686 , @eti-p-doray wrote:

> I added an example in the description.
>
> From doc https://clang.llvm.org/docs/ThreadSafetyAnalysis.html, 
>  it sounds like we should be allowed to declare our class with 
> CAPABILITY("context"), but it turns out that only "mutex" and "role" are 
> allowed.
>  I could otherwise update this CL to allow any string (single word 
> lowercase?) as CAPABILITY?


I had to hop in a time machine to figure out what we were thinking with 
restricting the names to just `role` and `mutex` and did not see any reasonable 
rationale for the restriction and I'm in favor of lifting it now. I think the 
correct way forward here is to remove the diagnostic (allowing arbitrary 
capability names), remove the `isRole()` and `isMutex()` accessors from the 
attribute definition in Attr.td (they're unused), and then update the 
documentation to make it more clear that we allow arbitrary names for 
capabilities.

Adding a few more people who use these attributes to see if there are concerns 
with this approach.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72635



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


[PATCH] D72848: Remove some SVN-specific code.

2020-01-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang/lib/Basic/Version.cpp:33
 #else
-  StringRef URL("");
+  return "";
 #endif

return {} should be better.



Comment at: clang/lib/Basic/Version.cpp:42
 #else
-  StringRef URL("");
+  return "";
 #endif

return {} should be better.



Comment at: clang/lib/Basic/Version.cpp:50
 #else
   return "";
 #endif

return {} should be better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72848



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


[clang] cebba7c - [SystemZ] Avoid unnecessary conversions in vecintrin.h

2020-01-16 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-01-16T18:58:14+01:00
New Revision: cebba7ce3952c8f37a923fa3a10360fd4c463775

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

LOG: [SystemZ] Avoid unnecessary conversions in vecintrin.h

Use floating-point instead of integer zero constants to avoid
creating implicit conversions, which currently cause suboptimal
code to be generated with -ffp-exception-behavior=strict.

NFC otherwise.

Added: 


Modified: 
clang/lib/Headers/vecintrin.h

Removed: 




diff  --git a/clang/lib/Headers/vecintrin.h b/clang/lib/Headers/vecintrin.h
index c71b76a3ee39..6f9b609f2dfe 100644
--- a/clang/lib/Headers/vecintrin.h
+++ b/clang/lib/Headers/vecintrin.h
@@ -290,7 +290,7 @@ vec_promote(unsigned long long __scalar, int __index) {
 #if __ARCH__ >= 12
 static inline __ATTRS_o_ai vector float
 vec_promote(float __scalar, int __index) {
-  const vector float __zero = (vector float)0;
+  const vector float __zero = (vector float)0.0f;
   vector float __vec = __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1);
   __vec[__index & 3] = __scalar;
   return __vec;
@@ -299,7 +299,7 @@ vec_promote(float __scalar, int __index) {
 
 static inline __ATTRS_o_ai vector double
 vec_promote(double __scalar, int __index) {
-  const vector double __zero = (vector double)0;
+  const vector double __zero = (vector double)0.0;
   vector double __vec = __builtin_shufflevector(__zero, __zero, -1, -1);
   __vec[__index & 1] = __scalar;
   return __vec;
@@ -366,7 +366,7 @@ vec_insert_and_zero(const unsigned long long *__ptr) {
 #if __ARCH__ >= 12
 static inline __ATTRS_o_ai vector float
 vec_insert_and_zero(const float *__ptr) {
-  vector float __vec = (vector float)0;
+  vector float __vec = (vector float)0.0f;
   __vec[1] = *__ptr;
   return __vec;
 }
@@ -374,7 +374,7 @@ vec_insert_and_zero(const float *__ptr) {
 
 static inline __ATTRS_o_ai vector double
 vec_insert_and_zero(const double *__ptr) {
-  vector double __vec = (vector double)0;
+  vector double __vec = (vector double)0.0;
   __vec[0] = *__ptr;
   return __vec;
 }



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


[PATCH] D72722: [FPEnv] [SystemZ] Platform-specific builtin constrained FP enablement

2020-01-16 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

A few comments (see inline) -- otherwise this looks good to me, thanks!




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13354
+  return Builder.CreateFNeg(Builder.CreateConstrainedFPCall(F, {X, Y,  
Z}), "neg");
+
+} else {

Spurious empty line.



Comment at: clang/test/CodeGen/builtins-systemz-vector2-constrained.c:25
+  // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> {{.*}}
+  // CHECK:  [[RES:%[^ ]+]] = call <2 x double> 
@llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, <2 x double> [[NEG]], metadata !{{.*}}, metadata !{{.*}})
+  // CHECK: fneg <2 x double> [[RES]]

Why is it that this one has metadata nodes and all the others do not?   Do they 
really not have metadata (why?) or are you just not checking for them?



Comment at: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c:12
+// FIXME: The lack of constant folding for strict fp breaks this test.
+// See label FIXME-CHECK-ASM.
+

This was caused by unnecessary implicit conversions in the vecintrin.h code, 
I've now checked in cebba7c to remove those.   Can you rebase?  This FIXME 
should no longer be necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72722



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


  1   2   3   >