[PATCH] D88526: [clang][Sema] Fix PR47676: Handle dependent AltiVec C-style cast

2020-09-29 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: pkubaj, nemanjai, jasonliu, 
aaron.ballman.
Herald added a project: clang.
hubert.reinterpretcast requested review of this revision.

Fix premature decision in the presence of type-dependent expression operands on 
whether AltiVec vector initializations from single expressions are "splat" 
operations.

Verify that the instantiation is able to determine the correct cast semantics 
for both the scalar type and the vector type case.

Note that, because the change only affects the single-expression case (and the 
target type is an AltiVec-style vector type), the replacement of a 
parenthesized list with a parenthesized expression does not change the 
semantics of the program in a program-observable manner.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88526

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaTemplate/pr47676.cpp


Index: clang/test/SemaTemplate/pr47676.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/pr47676.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -ast-dump \
+// RUN:-xc++ < %s 2>&1 \
+// RUN:   | FileCheck %s
+
+// Ensures that casts to AltiVec type with a dependent expression operand does
+// not hit the assertion failure reported in PR47676. Further checks that casts
+// to AltiVec type with a dependent expression operand is, on instantiation,
+// able to correctly differentiate between a splat case and a bitcast case.
+template  void f(T *tp) {
+  extern void g(int, ...);
+  g(0, (__vector int)(*tp));
+  g(0, (__vector int)*tp);
+}
+
+void g(void) {
+  f<__vector float>(nullptr);
+//  CHECK: | |-FunctionDecl {{.*}} f 'void (__vector float *)'
+
+//  CHECK: |   | `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: |   |   `-ImplicitCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: |   | `-ImplicitCastExpr {{.*}}'__vector float' 

+
+//  CHECK: | `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: |   `-ImplicitCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: | `-ImplicitCastExpr {{.*}}'__vector float' 

+
+  f(nullptr);
+//  CHECK: | `-FunctionDecl {{.*}} f 'void (double *)'
+
+//  CHECK: | | `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} 'int' 
+// CHECK-NEXT: | | `-ImplicitCastExpr {{.*}}'double' 
+
+//  CHECK: |   `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'int' 
+// CHECK-NEXT: |   `-ImplicitCastExpr {{.*}}:'double' 
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7408,7 +7408,7 @@
 }
 if (PE || PLE->getNumExprs() == 1) {
   Expr *E = (PE ? PE->getSubExpr() : PLE->getExpr(0));
-  if (!E->getType()->isVectorType())
+  if (!E->isTypeDependent() && !E->getType()->isVectorType())
 isVectorLiteral = true;
 }
 else


Index: clang/test/SemaTemplate/pr47676.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/pr47676.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -ast-dump \
+// RUN:-xc++ < %s 2>&1 \
+// RUN:   | FileCheck %s
+
+// Ensures that casts to AltiVec type with a dependent expression operand does
+// not hit the assertion failure reported in PR47676. Further checks that casts
+// to AltiVec type with a dependent expression operand is, on instantiation,
+// able to correctly differentiate between a splat case and a bitcast case.
+template  void f(T *tp) {
+  extern void g(int, ...);
+  g(0, (__vector int)(*tp));
+  g(0, (__vector int)*tp);
+}
+
+void g(void) {
+  f<__vector float>(nullptr);
+//  CHECK: | |-FunctionDecl {{.*}} f 'void (__vector float *)'
+
+//  CHECK: |   | `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: |   |   `-ImplicitCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: |   | `-ImplicitCastExpr {{.*}}'__vector float' 
+
+//  CHECK: | `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: |   `-ImplicitCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: | `-ImplicitCastExpr {{.*}}'__vector float' 
+
+  f(nullptr);
+//  CHECK: | `-FunctionDecl {{.*}} f 'void (double *)'
+
+//  CHECK: | | `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} 'int' 
+// CHECK-NEXT: | | `-ImplicitCastExpr {{.*}}'double' 
+
+//  CHECK: |   `-CStyleCastExpr {{.*}} '__vector int' 
+// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'int' 
+// CHECK-NEXT: |   `-ImplicitCastExpr {{.*}}:'double' 
+}
Index: 

[PATCH] D88518: Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

2020-09-29 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88518

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


Re: [PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-29 Thread Serge Pavlov via cfe-commits
The change https://reviews.llvm.org/rG4e4f926e83cf removes the problematic
test.
Sorry for troubles.

Thanks,
--Serge


On Wed, Sep 30, 2020 at 2:55 AM Petr Hosek via Phabricator <
revi...@reviews.llvm.org> wrote:

> phosek added a comment.
>
> In D87822#2301293 , @sepavloff
> wrote:
>
> > In D87822#2301194 ,
> @leonardchan wrote:
> >
> >> Thanks for looking into it. We have that commit but it still seems to be
> >> failing for us with the same error.
> >
> > In D88498  this test is removed
> because use of rounding mode changed. So you could just remove this test to
> fix the bot.
>
> Can we revert this change and reland it later with the fix? It's been 3
> days now and our bots are still red.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D87822/new/
>
> https://reviews.llvm.org/D87822
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4e4f926 - Remove test AST/const-fpfeatures-diag.c

2020-09-29 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2020-09-30T11:07:55+07:00
New Revision: 4e4f926e83cf77f0d36b821a3d2aa1de78338a82

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

LOG: Remove test AST/const-fpfeatures-diag.c

This test is going to be removed because using dynamic rounding mode
in initializers is changing. It also causes build failures in some
cases, so remove it now.

Added: 


Modified: 


Removed: 
clang/test/AST/const-fpfeatures-diag.c



diff  --git a/clang/test/AST/const-fpfeatures-diag.c 
b/clang/test/AST/const-fpfeatures-diag.c
deleted file mode 100644
index d0408dae3663..
--- a/clang/test/AST/const-fpfeatures-diag.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas 
%s
-
-// REQUIRES: x86-registered-target
-
-#pragma STDC FENV_ROUND FE_DYNAMIC
-
-// nextUp(1.F) == 0x1.02p0F
-
-float F1 = 0x1.00p0F + 0x0.02p0F;
-float F2 = 0x1.00p0F + 0x0.01p0F; // expected-error{{initializer 
element is not a compile-time constant}}



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


[PATCH] D87956: [WIP][IR] add fn attr for no_stack_protector; prevent inlining ssp into no-ssp

2020-09-29 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

bumping for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87956

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


[PATCH] D88469: [clangd] Heuristic resolution for dependent type and template names

2020-09-29 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:128
 const auto ValueFilter = [](const NamedDecl *D) { return isa(D); };
+const auto TypeFilter = [](const NamedDecl *D) { return !isa(D); };
 

hokein wrote:
> why not using `isa(D)`?
Heh. When I wrote this, I searched for `TypeDecl` via `workspaceSymbols`, did 
not see it in the first few results, and concluded that there is no such type.

Now I see it is there, just further down (and below **partial** matches like 
`CFConstantStringTypeDecl`). Maybe I should file a `workspaceSymbols` bug about 
this :)



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:743
+template 
+void foo(typename A::[[B]]);
+  )cpp";

hokein wrote:
> can you try to add a nested struct C in B, and verify `typename 
> A::B::[[C]])` still works?
Thank you for the example; this does not currently work.

Also, `typename A::[[B]]::C` does not work either, because only the leaf 
type gets a `DependentNameType`.

I will try to get these to work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88469

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


[PATCH] D54943: WIP [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-09-29 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- added a comment.

In D54943#2292377 , @0x8000- wrote:

> In D54943#2291969 , @JonasToth wrote:
>
>> @AlexanderLanin @0x8000- i created the branch `release-11-const` 
>> (https://github.com/JonasToth/llvm-project/tree/release-11-const) in my fork.
>>
>> This branch is based on 11-rc3 and cherry picks the commits that correspond 
>> to this revision.
>> I hope this is of any use for you! I will probably forget to update this 
>> branch all the time, but if I feel like there has been actual progress made, 
>> i will update!
>
> Thank you Jonas - will add this to our CI tool for the new project and try to 
> find some time to run it on the legacy project.

Just a quick update; in clang-tidy mode it works great, with no false positive 
and no crashes. I haven't tried the 'apply-replacements' mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[clang] 6f01c53 - Remove further OpenBSD/sparc bits

2020-09-29 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-09-29T22:17:12-04:00
New Revision: 6f01c53f26af7fb0393464079ec5e839a497d4da

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

LOG: Remove further OpenBSD/sparc bits

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d545bb551474..e3723e213c52 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1057,8 +1057,6 @@ tools::ParsePICArgs(const ToolChain , const 
ArgList ) {
   break;
 
 case llvm::Triple::ppc:
-case llvm::Triple::sparc:
-case llvm::Triple::sparcel:
 case llvm::Triple::sparcv9:
   IsPICLevelTwo = true; // "-fPIE"
   break;



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


[PATCH] D88377: Diagnose invalid target ID for AMDGPU toolchain for assembler

2020-09-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 295163.
yaxunl marked an inline comment as done.
yaxunl added a comment.

fix bug


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

https://reviews.llvm.org/D88377

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/amdgpu-invalid-target-id.s

Index: clang/test/Driver/amdgpu-invalid-target-id.s
===
--- /dev/null
+++ clang/test/Driver/amdgpu-invalid-target-id.s
@@ -0,0 +1,45 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: not %clang -target amdgcn-amd-amdhsa \
+// RUN:   -mcpu=gfx908xnack -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=NOPLUS %s
+
+// NOPLUS: error: Invalid target ID: gfx908xnack
+
+// RUN: not %clang -target amdgcn-amd-amdpal \
+// RUN:   -mcpu=gfx908:xnack+:xnack+ -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=ORDER %s
+
+// ORDER: error: Invalid target ID: gfx908:xnack+:xnack+
+
+// RUN: not %clang -target amdgcn--mesa3d \
+// RUN:   -mcpu=gfx908:unknown+ -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=UNK %s
+
+// UNK: error: Invalid target ID: gfx908:unknown+
+
+// RUN: not %clang -target amdgcn-amd-amdhsa \
+// RUN:   -mcpu=gfx908:sram-ecc+:unknown+ -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=MIXED %s
+
+// MIXED: error: Invalid target ID: gfx908:sram-ecc+:unknown+
+
+// RUN: not %clang -target amdgcn-amd-amdhsa \
+// RUN:   -mcpu=gfx900:sram-ecc+ -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=UNSUP %s
+
+// UNSUP: error: Invalid target ID: gfx900:sram-ecc+
+
+// RUN: not %clang -target amdgcn-amd-amdhsa \
+// RUN:   -mcpu=gfx900:xnack -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=NOSIGN %s
+
+// NOSIGN: error: Invalid target ID: gfx900:xnack
+
+// RUN: not %clang -target amdgcn-amd-amdhsa \
+// RUN:   -mcpu=gfx900+xnack -nostdlib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=NOCOLON %s
+
+// NOCOLON: error: Invalid target ID: gfx900+xnack
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -235,8 +235,7 @@
 Action::OffloadKind DeviceOffloadingKind) const {
   HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);
 
-  // Allow using target ID in --offload-arch.
-  StringRef GpuArch = translateTargetID(DriverArgs, CC1Args);
+  StringRef GpuArch = getGPUArch(DriverArgs);
   assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
   (void) GpuArch;
   assert(DeviceOffloadingKind == Action::OFK_HIP &&
@@ -348,6 +347,7 @@
   if (!BoundArch.empty()) {
 DAL->eraseArg(options::OPT_mcpu_EQ);
 DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_mcpu_EQ), BoundArch);
+checkTargetID(*DAL);
   }
 
   return DAL;
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -94,11 +94,10 @@
   bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
 
 protected:
-  /// Translate -mcpu option containing target ID to cc1 options.
-  /// Returns the GPU name.
-  StringRef translateTargetID(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const;
+  /// Check and diagnose invalid target ID specified by -mcpu.
+  void checkTargetID(const llvm::opt::ArgList ) const;
 
+  /// Get GPU arch from -mcpu without checking.
   StringRef getGPUArch(const llvm::opt::ArgList ) const;
 };
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -433,6 +433,8 @@
   DAL->append(A);
   }
 
+  checkTargetID(*DAL);
+
   if (!Args.getLastArgValue(options::OPT_x).equals("cl"))
 return DAL;
 
@@ -525,8 +527,6 @@
 const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ,
 Action::OffloadKind DeviceOffloadingKind) const {
-  // Allow using target ID in -mcpu.
-  translateTargetID(DriverArgs, CC1Args);
   // Default to "hidden" visibility, as object level linking will not be
   // supported for the foreseeable future.
   if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
@@ -543,21 +543,17 @@
   getTriple(), DriverArgs.getLastArgValue(options::OPT_mcpu_EQ));
 }
 
-StringRef
-AMDGPUToolChain::translateTargetID(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const {
+void AMDGPUToolChain::checkTargetID(
+const llvm::opt::ArgList ) const {
   StringRef TargetID = DriverArgs.getLastArgValue(options::OPT_mcpu_EQ);
   if (TargetID.empty())
-return StringRef();
+return;
 
   llvm::StringMap FeatureMap;
   auto 

[PATCH] D88524: [CUDA][HIP] Fix bound arch for offload action for fat binary

2020-09-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Currently CUDA/HIP toolchain uses "unknown" as bound arch
for offload action for fat binary. This causes -mcpu or -march
with "unknown" added in HIPToolChain::TranslateArgs or
CUDAToolChain::TranslateArgs.

This causes issue for https://reviews.llvm.org/D88377 since
HIP toolchain needs to check -mcpu in HIPToolChain::TranslateArgs.

The bound arch of offload action for fat binary is not really
used, therefore set it to nullptr to make things simpler.


https://reviews.llvm.org/D88524

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-toolchain-device-only.hip

Index: clang/test/Driver/hip-toolchain-device-only.hip
===
--- /dev/null
+++ clang/test/Driver/hip-toolchain-device-only.hip
@@ -0,0 +1,29 @@
+// REQUIRES: clang-driver, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --offload-arch=gfx803 --offload-arch=gfx900 \
+// RUN:   --cuda-device-only -nogpuinc -nogpulib -c \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=CHECK,LINK %s
+
+// CHECK-NOT: error:
+
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-fcuda-is-device"
+// CHECK-SAME: "-target-cpu" "gfx803"
+// CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_803:".*o"]] "-x" "hip"
+
+// CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
+
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: "-fcuda-is-device"
+// CHECK-SAME: "-target-cpu" "gfx900"
+// CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_900:".*o"]] "-x" "hip"
+
+// CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
+
+// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
+// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
+// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV_A_803]],[[IMG_DEV_A_900]]" "-outputs=[[BUNDLE_A:.*hipfb]]"
Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -219,6 +219,12 @@
 // DBIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // DBIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // DBIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// DBIN-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// DBIN-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// DBIN-DAG: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], [[ARCH]])
+// DBIN-DAG: [[P6:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P5]]}, image
+// DBIN-DAG: [[P7:[0-9]+]]: linker, {[[P6]]}, hip-fatbin, (device-hip)
+// DBIN-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa)" {[[P7]]}, hip-fatbin
 // DBIN-NOT: host
 //
 // Test single gpu architecture up to the assemble phase in device-only
@@ -230,6 +236,8 @@
 // DASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // DASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // DASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// DASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// DASM-DAG: [[P4:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P3]]}, assembler
 // DASM-NOT: host
 
 //
@@ -242,9 +250,19 @@
 // DBIN2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // DBIN2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // DBIN2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
-// DBIN2-DAG: [[P6:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T]], (device-[[T]], [[ARCH2:gfx900]])
-// DBIN2-DAG: [[P7:[0-9]+]]: preprocessor, {[[P6]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH2]])
-// DBIN2-DAG: [[P8:[0-9]+]]: compiler, {[[P7]]}, ir, (device-[[T]], [[ARCH2]])
+// DBIN2-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// DBIN2-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// DBIN2-DAG: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], [[ARCH]])
+// DBIN2-DAG: [[P6:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P5]]}, image
+// DBIN2-DAG: [[P7:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T]], (device-[[T]], [[ARCH2:gfx900]])
+// DBIN2-DAG: [[P8:[0-9]+]]: preprocessor, {[[P7]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH2]])
+// DBIN2-DAG: [[P9:[0-9]+]]: compiler, {[[P8]]}, ir, (device-[[T]], [[ARCH2]])
+// 

[clang] d04775e - Add remquo, frexp and modf overload functions to HIP header

2020-09-29 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-09-29T20:57:56-04:00
New Revision: d04775e16bba456f0be0aaa7478959c5bfa22c41

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

LOG: Add remquo, frexp and modf overload functions to HIP header

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 0c27ef60a064..b72bb40ccdb6 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -1221,6 +1221,27 @@ __DEVICE__
 inline _Float16 pow(_Float16 __base, int __iexp) {
   return __ocml_pown_f16(__base, __iexp);
 }
+
+__DEVICE__
+inline float remquo(float __x, float __y, int *__quo) {
+  return remquof(__x, __y, __quo);
+}
+
+template 
+__DEVICE__
+typename __hip_enable_if::is_specialized &&
+ std::numeric_limits<__T2>::is_specialized,
+ double>::type
+remquo(__T1 __x, __T2 __y, int *__quo) {
+  return remquo((double)__x, (double)__y, __quo);
+}
+
+__DEVICE__
+inline float frexp(float __x, int *__nptr) { return frexpf(__x, __nptr); }
+
+__DEVICE__
+inline float modf(float __x, float *__iptr) { return modff(__x, __iptr); }
+
 #endif
 
 #pragma pop_macro("__DEF_FUN1")



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


[PATCH] D88522: [DebugInfo] Add types from constructor homing to the retained types list.

2020-09-29 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c4fc581d5fe: [DebugInfo] Add types from constructor homing 
to the retained types list. (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88522

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -9,7 +9,7 @@
   B();
 } TestB;
 
-// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"C"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
 struct C {
   C() {}
 } TestC;
@@ -73,3 +73,7 @@
 void L() {
   auto func = [&]() {};
 }
+
+// Check that types are being added to retained types list.
+// CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+// CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1726,7 +1726,7 @@
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -9,7 +9,7 @@
   B();
 } TestB;
 
-// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
 struct C {
   C() {}
 } TestC;
@@ -73,3 +73,7 @@
 void L() {
   auto func = [&]() {};
 }
+
+// Check that types are being added to retained types list.
+// CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+// CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1726,7 +1726,7 @@
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5c4fc58 - [DebugInfo] Add types from constructor homing to the retained types list.

2020-09-29 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2020-09-29T17:00:45-07:00
New Revision: 5c4fc581d5fe8427f03ec90b0d745453398aa3ad

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

LOG: [DebugInfo] Add types from constructor homing to the retained types list.

Add class types to the retained types list to make sure they
don't get dropped if the constructor is optimized out later.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 27c584ff0795..88aace8b85dd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1726,7 +1726,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(

diff  --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp 
b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
index cf2e89e35522..cf7adad6b449 100644
--- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -9,7 +9,7 @@ struct B {
   B();
 } TestB;
 
-// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"C"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
 struct C {
   C() {}
 } TestC;
@@ -73,3 +73,7 @@ void f(K k) {}
 void L() {
   auto func = [&]() {};
 }
+
+// Check that types are being added to retained types list.
+// CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+// CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]



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


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Committed (with substantial changes) as 
984744a1314ce165378e7945bc45995302a8cb80 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88497

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


[clang] 984744a - Fix a variety of minor issues with ObjC method mangling:

2020-09-29 Thread John McCall via cfe-commits

Author: John McCall
Date: 2020-09-29T19:51:53-04:00
New Revision: 984744a1314ce165378e7945bc45995302a8cb80

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

LOG: Fix a variety of minor issues with ObjC method mangling:

- Fix a memory leak accidentally introduced yesterday by using CodeGen's
  existing mangling context instead of creating a new context afresh.

- Move GNU-runtime ObjC method mangling into the AST mangler; this will
  eventually be necessary to support direct methods there, but is also
  just the right architecture.

- Make the Apple-runtime method mangling work properly when given an
  interface declaration, fixing a bug (which had solidified into a test)
  where mangling a category method from the interface could cause it to
  be mangled as if the category name was a class name.  (Category names
  are namespaced within their class and have no global meaning.)

- Fix a code cross-reference in dsymutil.

Based on a patch by Ellis Hoag.

Added: 


Modified: 
clang/include/clang/AST/DeclObjC.h
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/Mangle.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp
clang/lib/CodeGen/CGObjCRuntime.h
clang/test/AST/ast-dump-decl-json.m
llvm/tools/dsymutil/SymbolMap.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index 5613ed8370c0..32e69d7fe1ed 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -320,6 +320,13 @@ class ObjCMethodDecl : public NamedDecl, public 
DeclContext {
 return const_cast(this)->getClassInterface();
   }
 
+  /// If this method is declared or implemented in a category, return
+  /// that category.
+  ObjCCategoryDecl *getCategory();
+  const ObjCCategoryDecl *getCategory() const {
+return const_cast(this)->getCategory();
+  }
+
   Selector getSelector() const { return getDeclName().getObjCSelector(); }
 
   QualType getReturnType() const { return MethodDeclType; }

diff  --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 5c8b34731f36..78ef9a1c67c9 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -1165,6 +1165,14 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
   llvm_unreachable("unknown method context");
 }
 
+ObjCCategoryDecl *ObjCMethodDecl::getCategory() {
+  if (auto *CD = dyn_cast(getDeclContext()))
+return CD;
+  if (auto *IMD = dyn_cast(getDeclContext()))
+return IMD->getCategoryDecl();
+  return nullptr;
+}
+
 SourceRange ObjCMethodDecl::getReturnTypeSourceRange() const {
   const auto *TSI = getReturnTypeSourceInfo();
   if (TSI)

diff  --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index a67f57688e30..3282fcbd584f 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -308,12 +308,44 @@ void MangleContext::mangleObjCMethodName(const 
ObjCMethodDecl *MD,
  raw_ostream ,
  bool includePrefixByte,
  bool includeCategoryNamespace) {
+  if (getASTContext().getLangOpts().ObjCRuntime.isGNUFamily()) {
+// This is the mangling we've always used on the GNU runtimes, but it
+// has obvious collisions in the face of underscores within class
+// names, category names, and selectors; maybe we should improve it.
+
+OS << (MD->isClassMethod() ? "_c_" : "_i_")
+   << MD->getClassInterface()->getName() << '_';
+
+if (includeCategoryNamespace) {
+  if (auto category = MD->getCategory())
+OS << category->getName();
+}
+OS << '_';
+
+auto selector = MD->getSelector();
+for (unsigned slotIndex = 0,
+  numArgs = selector.getNumArgs(),
+  slotEnd = std::max(numArgs, 1U);
+   slotIndex != slotEnd; ++slotIndex) {
+  if (auto name = selector.getIdentifierInfoForSlot(slotIndex))
+OS << name->getName();
+
+  // Replace all the positions that would've been ':' with '_'.
+  // That's after each slot except that a unary selector doesn't
+  // end in ':'.
+  if (numArgs)
+OS << '_';
+}
+
+return;
+  }
+
   // \01+[ContainerName(CategoryName) SelectorName]
   if (includePrefixByte) {
 OS << '\01';
   }
   OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
-  if (const auto *CID = dyn_cast(MD->getDeclContext())) {
+  if (const auto *CID = MD->getCategory()) {
 OS << CID->getClassInterface()->getName();
 if (includeCategoryNamespace) {
   OS << '(' << *CID << ')';

diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index bb9c494ae68e..ed36e4a5cbc1 100644
--- 

[PATCH] D88522: [DebugInfo] Add types from constructor homing to the retained types list.

2020-09-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good - thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88522

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


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-29 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 295149.
atmnpatel added a comment.

Fixing buildkite build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/attr-mustprogress-0.c
  clang/test/CodeGen/attr-mustprogress-0.cpp
  clang/test/CodeGen/attr-mustprogress-1.c
  clang/test/CodeGen/attr-mustprogress-1.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGen/pragma-do-while.cpp
  clang/test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
  clang/test/CodeGenCXX/debug-info-line-if.cpp
  clang/test/CodeGenCXX/debug-info-loops.cpp
  clang/test/CodeGenCXX/fno-unroll-loops-metadata.cpp
  clang/test/CodeGenCXX/pragma-followup_inner.cpp
  clang/test/CodeGenCXX/pragma-followup_outer.cpp
  clang/test/CodeGenCXX/pragma-loop-distribute.cpp
  clang/test/CodeGenCXX/pragma-loop-pr27643.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-imperfectly_nested.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-nested.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-outer.cpp
  clang/test/CodeGenCXX/pragma-loop-safety.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/CodeGenCXX/pragma-pipeline.cpp
  clang/test/CodeGenCXX/pragma-unroll-and-jam.cpp
  clang/test/CodeGenCXX/pragma-unroll.cpp
  clang/test/CodeGenCXX/thunks-ehspec.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/Profile/c-unprofiled-blocks.c
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
@@ -41,7 +41,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -86,7 +86,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
@@ -197,7 +197,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -223,7 +223,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -11,7 +11,7 @@
   struct RT Z;
 };
 
-// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK: Function Attrs: noinline nounwind optnone mustprogress
 // CHECK-LABEL: @_Z3fooP2ST(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
Index: 

[PATCH] D88522: [DebugInfo] Add types from constructor homing to the retained types list.

2020-09-29 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: dblaikie.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
akhuang requested review of this revision.

Add class types to the retained types list to make sure they
don't get dropped if the constructor is optimized out later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88522

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -9,7 +9,7 @@
   B();
 } TestB;
 
-// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"C"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
 struct C {
   C() {}
 } TestC;
@@ -73,3 +73,7 @@
 void L() {
   auto func = [&]() {};
 }
+
+// Check that types are being added to retained types list.
+// CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+// CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1726,7 +1726,7 @@
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -9,7 +9,7 @@
   B();
 } TestB;
 
-// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
 struct C {
   C() {}
 } TestC;
@@ -73,3 +73,7 @@
 void L() {
   auto func = [&]() {};
 }
+
+// Check that types are being added to retained types list.
+// CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+// CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1726,7 +1726,7 @@
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-29 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel marked 3 inline comments as done.
atmnpatel added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:801
+ getLangOpts().CPlusPlus11 || getLangOpts().CPlusPlus14 ||
+ getLangOpts().CPlusPlus17 || getLangOpts().C2x) {
+MustProgress = true;

jdoerfert wrote:
> Also in C? And C2x in the end is probably CPLusPlus2x?
> Also in C?
Not quite sure what you mean here.

But LangOptions.def seems to say that C2x is the upcoming C standard, not any 
upcoming C++ standard.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

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


[clang] 1c604a9 - Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

2020-09-29 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-09-29T15:53:17-07:00
New Revision: 1c604a9f5fd65c91f097c856fa6643373fc869e1

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

LOG: Recognize setjmp and friends as builtins even if jmp_buf is not declared 
yet.

This happens in glibc's headers. It's important that we recognize these
functions so that we can mark them as returns_twice.

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

Added: 
clang/test/CodeGen/setjmp.c

Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/builtin-setjmp.c
clang/test/Sema/implicit-builtin-decl.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index efefe62c4a2c..d001b0bea9e6 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -75,6 +75,9 @@
 //  U -> pure
 //  c -> const
 //  t -> signature is meaningless, use custom typechecking
+//  T -> type is not important to semantic analysis and codegen; recognize as
+//   builtin even if type doesn't match signature, and don't warn if we
+//   can't be sure the type is right
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
 //  f -> this is a libc/libm function without the '__builtin_' prefix. It can
 //   be followed by ':headername:' to state which header this function
@@ -896,7 +899,7 @@ LANGBUILTIN(__va_start,   "vc**.", "nt", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(__fastfail, "vUi","nr", ALL_MS_LANGUAGES)
 
 // Microsoft library builtins.
-LIBBUILTIN(_setjmpex, "iJ", "fj",   "setjmpex.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_setjmpex, "iJ", "fjT", "setjmpex.h", ALL_MS_LANGUAGES)
 
 // C99 library functions
 // C99 stdarg.h
@@ -990,8 +993,8 @@ LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", 
ALL_LANGUAGES)
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.
 #undef setjmp
-LIBBUILTIN(setjmp, "iJ",  "fj","setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(longjmp, "vJi","fr","setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(setjmp, "iJ",  "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(longjmp, "vJi","frT",   "setjmp.h", ALL_LANGUAGES)
 
 // Non-C library functions, active in GNU mode only.
 // Functions with (returns_twice) attribute (marked as "j") are still active in
@@ -1018,21 +1021,21 @@ LIBBUILTIN(strcasecmp, "icC*cC*", "f", "strings.h", 
ALL_GNU_LANGUAGES)
 LIBBUILTIN(strncasecmp, "icC*cC*z", "f",   "strings.h", ALL_GNU_LANGUAGES)
 // POSIX unistd.h
 LIBBUILTIN(_exit, "vi",   "fr","unistd.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(vfork, "p","fj","unistd.h", ALL_LANGUAGES)
+LIBBUILTIN(vfork, "p","fjT",   "unistd.h", ALL_LANGUAGES)
 // POSIX pthread.h
 // FIXME: Should specify argument types.
 LIBBUILTIN(pthread_create, "",  "fC<2,3>", "pthread.h", ALL_GNU_LANGUAGES)
 
 // POSIX setjmp.h
 
-LIBBUILTIN(_setjmp, "iJ", "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(__sigsetjmp, "iSJi",   "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(sigsetjmp, "iSJi", "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(savectx, "iJ", "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(getcontext, "iK*", "fj",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(_setjmp, "iJ", "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(__sigsetjmp, "iSJi",   "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(sigsetjmp, "iSJi", "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(savectx, "iJ", "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(getcontext, "iK*", "fjT",   "setjmp.h", ALL_LANGUAGES)
 
-LIBBUILTIN(_longjmp, "vJi",   "fr","setjmp.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(siglongjmp, "vSJi","fr","setjmp.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(_longjmp, "vJi",   "frT",   "setjmp.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(siglongjmp, "vSJi","frT",   "setjmp.h", ALL_GNU_LANGUAGES)
 // non-standard but very common
 LIBBUILTIN(strlcpy, "zc*cC*z","f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(strlcat, "zc*cC*z","f", "string.h", ALL_GNU_LANGUAGES)

diff  --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index e4ed482d9068..15bfcf797917 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -158,6 +158,13 @@ class Context {
 return strchr(getRecord(ID).Attributes, 't') != nullptr;
   }
 
+  /// Determines whether a declaration of this builtin should be recognized
+  /// even if the type doesn't match the specified signature.
+  bool allowTypeMismatch(unsigned ID) const {
+return 

[PATCH] D88518: Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c604a9f5fd6: Recognize setjmp and friends as builtins even 
if jmp_buf is not declared yet. (authored by rsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88518

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/setjmp.c
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/implicit-builtin-decl.c

Index: clang/test/Sema/implicit-builtin-decl.c
===
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -54,13 +54,12 @@
 
 void snprintf() { }
 
-// PR8316 & PR40692
-void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
+void longjmp();
 
 extern float fmaxf(float, float);
 
 struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
+void sigsetjmp(struct __jmp_buf_tag[1], int);
 
 // PR40692
 void pthread_create(); // no warning expected
Index: clang/test/Sema/builtin-setjmp.c
===
--- clang/test/Sema/builtin-setjmp.c
+++ clang/test/Sema/builtin-setjmp.c
@@ -1,10 +1,42 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DONLY_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s
 
 #ifdef NO_JMP_BUF
-extern long setjmp(long *);   // expected-warning {{declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
-#else
+// This happens in some versions of glibc: the declaration of __sigsetjmp
+// precedes the declaration of sigjmp_buf.
+extern long setjmp(long *); // Can't check, so we trust that this is the right type
+// FIXME: We could still diagnose the missing `jmp_buf` at the point of the call.
+// expected-no-diagnostics
+#elif WRONG_JMP_BUF
 typedef long jmp_buf;
-extern int setjmp(char);  // expected-warning@8 {{incompatible redeclaration of library function 'setjmp'}}
-  // expected-note@8{{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+extern int setjmp(char); // expected-warning {{incompatible redeclaration of library function 'setjmp'}}
+ // expected-note@-1 {{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+#elif RIGHT_JMP_BUF
+typedef long jmp_buf;
+extern int setjmp(long); // OK, right type.
+// expected-no-diagnostics
+#elif ONLY_JMP_BUF
+typedef int *jmp_buf;
 #endif
+
+void use() {
+  setjmp(0);
+  #ifdef NO_SETJMP
+  // expected-warning@-2 {{implicit declaration of function 'setjmp' is invalid in C99}}
+  #elif ONLY_JMP_BUF
+  // expected-warning@-4 {{implicitly declaring library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)')}}
+  // expected-note@-5 {{include the header  or explicitly provide a declaration for 'setjmp'}}
+  #endif
+
+  #ifdef NO_SETJMP
+  // In this case, the regular AST dump doesn't dump the implicit declaration of 'setjmp'.
+  #pragma clang __debug dump setjmp
+  #endif
+}
+
+// CHECK: FunctionDecl {{.*}} used setjmp
+// CHECK: BuiltinAttr {{.*}} Implicit
+// CHECK: ReturnsTwiceAttr {{.*}} Implicit
Index: clang/test/CodeGen/setjmp.c
===
--- /dev/null
+++ clang/test/CodeGen/setjmp.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct __jmp_buf_tag { int n; };
+int setjmp(struct __jmp_buf_tag*);
+int sigsetjmp(struct __jmp_buf_tag*, int);
+int _setjmp(struct __jmp_buf_tag*);
+int __sigsetjmp(struct __jmp_buf_tag*, int);
+
+typedef struct __jmp_buf_tag jmp_buf[1];
+typedef struct __jmp_buf_tag sigjmp_buf[1];
+
+#ifdef __cplusplus
+}
+#endif
+
+void f() {
+  jmp_buf jb;
+  // CHECK: call {{.*}}@setjmp(
+  setjmp(jb);
+  

[PATCH] D67678: PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D67678#1856229 , @rsmith wrote:

> In D67678#1836953 , @dexonsmith 
> wrote:
>
>> In D67678#1836922 , @rsmith wrote:
>>
>>> If there's no timeline to update the macOS SDK, then perhaps we could add a 
>>> hack to Clang to allow these conversions only in limited contexts (the 
>>> specific parts of the macOS SDK that are relying on them). Do you know how 
>>> many such places there might be? If it's just a few functions, we could 
>>> match against the function names, or depending on what `SIMD_CFUNC` expands 
>>> to, perhaps we could match that. Failing that, we could set a 
>>> platform-specific default or similar.
>>
>> A hack like this sounds pragmatic to me.  An initial look suggests it's a 
>> small number of frameworks; I suspect many functions, but we could 
>> potentially match on partial file path or `SIMD_CFUNC`.  We need a deeper 
>> audit across our internal stack to be sure, though.  I don't think we'll 
>> have bandwidth for that until ~late February.
>
> OK, that seems fine to me. I don't want this to miss another release if we 
> can avoid it, but that should give plenty of time to iterate on something 
> that keeps your SDK building :)

@dexonsmith Ping, I'd like to get this done for the Clang 12 release; what do 
we need to do to make sure we're not causing problems for the macOS SDK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67678

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


[PATCH] D88518: Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.  I like this better as a fix for PR40692 anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88518

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


[PATCH] D88500: [AIX][Clang][Driver] Link libm in c++ mode

2020-09-29 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM with minor comments.




Comment at: clang/test/Driver/aix-ld.c:406
 // CHECK-LD32-NOSTDLIBXX-LCXX: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-NOSTDLIBXX-LCXX-:"-lm"
 // CHECK-LD32-NOSTDLIBXX-LCXX: "-lc"

Typo.



Comment at: clang/test/Driver/aix-ld.c:446
 // CHECK-LD32-NOSTARTFILES-LCXX: "-L[[SYSROOT]]/usr/lib"
-// CHECK-LD32-NOSTARTFILES-LCXX  "-lc++"
+// CHECK-LD32-NOSTARTFILES-LCXX:  "-lc++"
 // CHECK-LD32-NOSTARTFILES-LCXX: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"

Formatting.



Comment at: clang/test/Driver/aix-ld.c:448
 // CHECK-LD32-NOSTARTFILES-LCXX: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-NOSTARTFILES-LCXX:  "-lm"
 // CHECK-LD32-NOSTARTFILES-LCXX: "-lc"

Same comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88500

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


[PATCH] D77491: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D77491#2300013 , @rjmccall wrote:

> Being permissive about recognizing builtins when the expected signature 
> requires a type that lookup can't find seems completely reasonable.  We don't 
> really want to force library functions to take the custom-typechecking path 
> just because we want to infer an attribute for them.

Proposed fix in https://reviews.llvm.org/D88518.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77491

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


[PATCH] D88518: Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added reviewers: tambre, rjmccall.
Herald added a project: clang.
rsmith requested review of this revision.

This happens in glibc's headers. It's important that we recognize these
functions so that we can mark them as returns_twice.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88518

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/setjmp.c
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/implicit-builtin-decl.c

Index: clang/test/Sema/implicit-builtin-decl.c
===
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -54,13 +54,12 @@
 
 void snprintf() { }
 
-// PR8316 & PR40692
-void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
+void longjmp();
 
 extern float fmaxf(float, float);
 
 struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
+void sigsetjmp(struct __jmp_buf_tag[1], int);
 
 // PR40692
 void pthread_create(); // no warning expected
Index: clang/test/Sema/builtin-setjmp.c
===
--- clang/test/Sema/builtin-setjmp.c
+++ clang/test/Sema/builtin-setjmp.c
@@ -1,10 +1,42 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DONLY_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s
 
 #ifdef NO_JMP_BUF
-extern long setjmp(long *);   // expected-warning {{declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
-#else
+// This happens in some versions of glibc: the declaration of __sigsetjmp
+// precedes the declaration of sigjmp_buf.
+extern long setjmp(long *); // Can't check, so we trust that this is the right type
+// FIXME: We could still diagnose the missing `jmp_buf` at the point of the call.
+// expected-no-diagnostics
+#elif WRONG_JMP_BUF
 typedef long jmp_buf;
-extern int setjmp(char);  // expected-warning@8 {{incompatible redeclaration of library function 'setjmp'}}
-  // expected-note@8{{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+extern int setjmp(char); // expected-warning {{incompatible redeclaration of library function 'setjmp'}}
+ // expected-note@-1 {{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+#elif RIGHT_JMP_BUF
+typedef long jmp_buf;
+extern int setjmp(long); // OK, right type.
+// expected-no-diagnostics
+#elif ONLY_JMP_BUF
+typedef int *jmp_buf;
 #endif
+
+void use() {
+  setjmp(0);
+  #ifdef NO_SETJMP
+  // expected-warning@-2 {{implicit declaration of function 'setjmp' is invalid in C99}}
+  #elif ONLY_JMP_BUF
+  // expected-warning@-4 {{implicitly declaring library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)')}}
+  // expected-note@-5 {{include the header  or explicitly provide a declaration for 'setjmp'}}
+  #endif
+
+  #ifdef NO_SETJMP
+  // In this case, the regular AST dump doesn't dump the implicit declaration of 'setjmp'.
+  #pragma clang __debug dump setjmp
+  #endif
+}
+
+// CHECK: FunctionDecl {{.*}} used setjmp
+// CHECK: BuiltinAttr {{.*}} Implicit
+// CHECK: ReturnsTwiceAttr {{.*}} Implicit
Index: clang/test/CodeGen/setjmp.c
===
--- /dev/null
+++ clang/test/CodeGen/setjmp.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct __jmp_buf_tag { int n; };
+int setjmp(struct __jmp_buf_tag*);
+int sigsetjmp(struct __jmp_buf_tag*, int);
+int _setjmp(struct __jmp_buf_tag*);
+int __sigsetjmp(struct __jmp_buf_tag*, int);
+
+typedef struct __jmp_buf_tag jmp_buf[1];
+typedef struct __jmp_buf_tag sigjmp_buf[1];
+
+#ifdef __cplusplus
+}
+#endif
+
+void f() {
+  jmp_buf jb;
+  // CHECK: call {{.*}}@setjmp(
+  setjmp(jb);
+  // 

[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-09-29 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

In D84467#2264205 , @vsk wrote:

> @alanphipps thanks for bearing with me. I think this is about ready to land. 
> I do ask that you back out any punctuation/whitespace changes in code/tests 
> that aren't directly modified in your diff (the clang-format-diff script can 
> help with this). It looks like some libCoverage and test changes are no 
> longer in the current version of this patch, as compared to the previous 
> version (https://reviews.llvm.org/D84467?id=287269). Was that intentional?

I apologize for the long delay myself -- I think I discovered a bug in the code 
that I'm trying to work out.  In answer to your question about the patches, no 
it wasn't intentional; I believe I produced the patch incorrectly, only 
capturing the most recent changes.  I'll update this soon.


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

https://reviews.llvm.org/D84467

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


[PATCH] D88265: Fix comma with half vectors.

2020-09-29 Thread Alexandre Rames via Phabricator via cfe-commits
arames added a comment.

I do not have commit rights, so it would be great if you can land it.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88265

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


[PATCH] D88446: docs: add documentation describing API Notes

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Broadly, it seems reasonable to me for Clang to support this. I have no major 
concerns with the overall approach here, and it seems like you already have 
sufficient implementation experience with this approach to know that it's going 
to work out well in practice. I'm happy that all of the points in 
http://clang.llvm.org/get_involved.html for Clang extensions are covered -- or 
will be covered by the work to implement this.




Comment at: clang/docs/APINotes.rst:5-12
+**The Problem:** You have headers you want to use, but you also want to add
+extra information to some of the APIs. You don't want to put that information
+in the headers themselves --- perhaps because you want to keep them clean for
+other clients, or perhaps because they're from some open source project and you
+don't want to modify them at all.
+
+**Incomplete solution:** Redeclare all the interesting APIs in your own header

"API" should generally be used only as an uncountable noun. If you mean 
something more concrete here, such as "a function, method, type, ...", then 
saying that would be better, since "API" can be interpreted as meaning an 
individual such entity or a collection of such entities, depending on the 
reader.



Comment at: clang/docs/APINotes.rst:45
+Clang will search for API notes files next to module maps only when passed the
+``-fapinotes-modules`` option.
+

Can we add a hyphen between `api` and `notes` here? `-fapinotes` is a little 
hard to read.



Comment at: clang/docs/APINotes.rst:187-190
+  - "N"onnull (``_Nonnull``)
+  - "O"ptional (``_Nullable``)
+  - "U"nspecified (``_Null_unspecified``)
+  - "S"calar (deprecated)

Is it important that these are single letters? Spelling out the name in full 
(as you do for other enumerated values like `MethodKind` and `PropertyKind`) 
would seem a little more readable. (We could accept the single-letter forms as 
aliases.)



Comment at: clang/docs/APINotes.rst:233-235
+  Note that the type is *not* parsed in the context where it will be used,
+  which means that macros are not available and nullability must be applied
+  explicitly (even in an ``NS_ASSUME_NONNULL_BEGIN`` section).

So what context is it parsed in? Below you have an `NSArray *` example; how do 
we do the lookup for `NSArray`?



Comment at: clang/docs/APINotes.rst:273
+  Used for ``NSError`` code enums. The value is the name of the associated 
domain
+  ``NSString`` constant; an empty string ("") means the enum is a normal enum
+  rather than an error code.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88446

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


[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-09-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 295120.
jhuber6 added a comment.

Adding check for Windows file path. Updating some files after rebasing.


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

https://reviews.llvm.org/D87946

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_06.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_08.cpp
  clang/test/OpenMP/target_map_codegen_09.cpp
  clang/test/OpenMP/target_map_codegen_10.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_16.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_19.cpp
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_21.cpp
  clang/test/OpenMP/target_map_codegen_22.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_24.cpp
  clang/test/OpenMP/target_map_codegen_25.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_30.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_33.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  

[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-29 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 295119.
atmnpatel added a comment.

NFC fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/attr-mustprogress-0.c
  clang/test/CodeGen/attr-mustprogress-0.cpp
  clang/test/CodeGen/attr-mustprogress-1.c
  clang/test/CodeGen/attr-mustprogress-1.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGen/pragma-do-while.cpp
  clang/test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
  clang/test/CodeGenCXX/debug-info-line-if.cpp
  clang/test/CodeGenCXX/debug-info-loops.cpp
  clang/test/CodeGenCXX/fno-unroll-loops-metadata.cpp
  clang/test/CodeGenCXX/pragma-followup_inner.cpp
  clang/test/CodeGenCXX/pragma-followup_outer.cpp
  clang/test/CodeGenCXX/pragma-loop-distribute.cpp
  clang/test/CodeGenCXX/pragma-loop-pr27643.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-imperfectly_nested.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-nested.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-outer.cpp
  clang/test/CodeGenCXX/pragma-loop-safety.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/CodeGenCXX/pragma-pipeline.cpp
  clang/test/CodeGenCXX/pragma-unroll-and-jam.cpp
  clang/test/CodeGenCXX/pragma-unroll.cpp
  clang/test/CodeGenCXX/thunks-ehspec.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/Profile/c-unprofiled-blocks.c
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
@@ -41,7 +41,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -86,7 +86,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
@@ -197,7 +197,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -223,7 +223,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -11,7 +11,7 @@
   struct RT Z;
 };
 
-// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK: Function Attrs: noinline nounwind optnone mustprogress
 // CHECK-LABEL: @_Z3fooP2ST(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
Index: 

[PATCH] D88265: Fix comma with half vectors.

2020-09-29 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 295116.
arames added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88265

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/fp16vec-sema.c


Index: clang/test/Sema/fp16vec-sema.c
===
--- clang/test/Sema/fp16vec-sema.c
+++ clang/test/Sema/fp16vec-sema.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
 
 typedef __fp16 half4 __attribute__ ((vector_size (8)));
 typedef float float4 __attribute__ ((vector_size (16)));
@@ -28,6 +28,8 @@
   sv0 = hv0 >= hv1;
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
   sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
+  hv0, 1;
+  1, hv0;
 
   // Implicit conversion between half vectors and float vectors are not 
allowed.
   hv0 = fv0; // expected-error{{assigning to}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13933,9 +13933,10 @@
   // float vectors and truncating the result back to half vector. For now, we 
do
   // this only when HalfArgsAndReturn is set (that is, when the target is arm 
or
   // arm64).
-  assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
- isVector(LHS.get()->getType(), Context.HalfTy) &&
- "both sides are half vectors or neither sides are");
+  assert(
+  (Opc == BO_Comma || isVector(RHS.get()->getType(), Context.HalfTy) ==
+  isVector(LHS.get()->getType(), Context.HalfTy)) 
&&
+  "both sides are half vectors or neither sides are");
   ConvertHalfVec =
   needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 


Index: clang/test/Sema/fp16vec-sema.c
===
--- clang/test/Sema/fp16vec-sema.c
+++ clang/test/Sema/fp16vec-sema.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
 
 typedef __fp16 half4 __attribute__ ((vector_size (8)));
 typedef float float4 __attribute__ ((vector_size (16)));
@@ -28,6 +28,8 @@
   sv0 = hv0 >= hv1;
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
   sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
+  hv0, 1;
+  1, hv0;
 
   // Implicit conversion between half vectors and float vectors are not allowed.
   hv0 = fv0; // expected-error{{assigning to}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13933,9 +13933,10 @@
   // float vectors and truncating the result back to half vector. For now, we do
   // this only when HalfArgsAndReturn is set (that is, when the target is arm or
   // arm64).
-  assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
- isVector(LHS.get()->getType(), Context.HalfTy) &&
- "both sides are half vectors or neither sides are");
+  assert(
+  (Opc == BO_Comma || isVector(RHS.get()->getType(), Context.HalfTy) ==
+  isVector(LHS.get()->getType(), Context.HalfTy)) &&
+  "both sides are half vectors or neither sides are");
   ConvertHalfVec =
   needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88500: [AIX][Clang][Driver] Link libm in c++ mode

2020-09-29 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 295111.
daltenty marked an inline comment as done.
daltenty added a comment.

- Make dependant on just c++ mode
- Add missing colons


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88500

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -20,6 +20,7 @@
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-NOT: "-lm"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
@@ -41,6 +42,7 @@
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-NOT: "-lm"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
@@ -64,6 +66,7 @@
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD-NOT: "-lm"
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
@@ -87,6 +90,7 @@
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD-NOT: "-lm"
 // CHECK-LD64-PTHREAD: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
@@ -109,6 +113,7 @@
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
@@ -131,6 +136,7 @@
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
@@ -153,6 +159,7 @@
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-STATIC-NOT: "-lm"
 // CHECK-LD32-STATIC: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Library search path.
@@ -176,6 +183,7 @@
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
 // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-LIBP-NOT: "-lm"
 // CHECK-LD32-LIBP: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. nostdlib.
@@ -200,6 +208,7 @@
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
+// CHECK-LD32-NO-STD-LIB-NOT: "-lm"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. nodefaultlibs.
@@ -224,6 +233,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
+// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lm"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
@@ -247,6 +257,7 @@
 // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc++"
 // CHECK-LD32-CXX-ARG-ORDER: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-ORDER: "-lm"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. lc++ and lc order.
@@ -266,6 +277,7 @@
 // CHECK-LD32-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD32-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-LCXX: "-lm"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. lc++ and lc order.
@@ -285,6 +297,7 @@
 // CHECK-LD64-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD64-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-CXX-ARG-LCXX: "-lm"
 // 

[PATCH] D88297: [clangd] Trivial setter support when moving items to fields

2020-09-29 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01a30fa6787d: [clangd] Trivial setter support when moving 
items to fields (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88297

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
@@ -698,6 +698,26 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Setter (move)
+   R"cpp(
+  namespace std { template T&& move(T&& t); }
+  struct X { int Y; void [[^setY]](float v) { Y = std::move(v); } };
+  )cpp",
+   [](HoverInfo ) {
+ HI.Name = "setY";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.NamespaceScope = "";
+ HI.Definition = "void setY(float v)";
+ HI.LocalScope = "X::";
+ HI.Documentation = "Trivial setter for `Y`.";
+ HI.Type = "void (float)";
+ HI.ReturnType = "void";
+ HI.Parameters.emplace();
+ HI.Parameters->emplace_back();
+ HI.Parameters->back().Type = "float";
+ HI.Parameters->back().Name = "v";
+ HI.AccessSpecifier = "public";
+   }},
   {// Field type initializer.
R"cpp(
   struct X { int x = 2; };
@@ -802,8 +822,8 @@
  HI.Type = "int";
  HI.AccessSpecifier = "public";
}},
-   {// No crash on InitListExpr.
-R"cpp(
+  {// No crash on InitListExpr.
+   R"cpp(
   struct Foo {
 int a[10];
   };
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -413,6 +413,8 @@
 // If CMD is one of the forms:
 //   void foo(T arg) { FieldName = arg; }
 //   R foo(T arg) { FieldName = arg; return *this; }
+//   void foo(T arg) { FieldName = std::move(arg); }
+//   R foo(T arg) { FieldName = std::move(arg); return *this; }
 // then returns "FieldName"
 llvm::Optional setterVariableName(const CXXMethodDecl *CMD) {
   assert(CMD->hasBody());
@@ -455,6 +457,18 @@
   } else {
 return llvm::None;
   }
+
+  // Detect the case when the item is moved into the field.
+  if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
+if (CE->getNumArgs() != 1)
+  return llvm::None;
+auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
+!ND->isInStdNamespace())
+  return llvm::None;
+RHS = CE->getArg(0);
+  }
+
   auto *DRE = llvm::dyn_cast(RHS->IgnoreCasts());
   if (!DRE || DRE->getDecl() != Arg)
 return llvm::None;


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -698,6 +698,26 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Setter (move)
+   R"cpp(
+  namespace std { template T&& move(T&& t); }
+  struct X { int Y; void [[^setY]](float v) { Y = std::move(v); } };
+  )cpp",
+   [](HoverInfo ) {
+ HI.Name = "setY";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.NamespaceScope = "";
+ HI.Definition = "void setY(float v)";
+ HI.LocalScope = "X::";
+ HI.Documentation = "Trivial setter for `Y`.";
+ HI.Type = "void (float)";
+ HI.ReturnType = "void";
+ HI.Parameters.emplace();
+ HI.Parameters->emplace_back();
+ HI.Parameters->back().Type = "float";
+ HI.Parameters->back().Name = "v";
+ HI.AccessSpecifier = "public";
+   }},
   {// Field type initializer.
R"cpp(
   struct X { int x = 2; };
@@ -802,8 +822,8 @@
  HI.Type = "int";
  HI.AccessSpecifier = "public";
}},
-   {// No crash on InitListExpr.
-R"cpp(
+  {// No crash on InitListExpr.
+   R"cpp(
   struct Foo {
 int a[10];
   };
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -413,6 +413,8 @@
 // If CMD is one of the forms:
 //   void foo(T arg) { FieldName = arg; }
 //   R foo(T arg) { FieldName = arg; return *this; }
+//   void foo(T arg) { FieldName = std::move(arg); }
+//   R foo(T arg) { FieldName = std::move(arg); 

[clang-tools-extra] 01a30fa - [clangd] Trivial setter support when moving items to fields

2020-09-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-09-29T21:51:15+01:00
New Revision: 01a30fa6787d8375e1df573150f9927561b0a0f1

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

LOG: [clangd] Trivial setter support when moving items to fields

Extend the Trivial setter documentation to support cases where the value is 
moved into a field using `std::move`.

Reviewed By: sammccall, kadircet

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

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 ef9bb536005f..9da8a9c9af57 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -413,6 +413,8 @@ llvm::Optional getterVariableName(const 
CXXMethodDecl *CMD) {
 // If CMD is one of the forms:
 //   void foo(T arg) { FieldName = arg; }
 //   R foo(T arg) { FieldName = arg; return *this; }
+//   void foo(T arg) { FieldName = std::move(arg); }
+//   R foo(T arg) { FieldName = std::move(arg); return *this; }
 // then returns "FieldName"
 llvm::Optional setterVariableName(const CXXMethodDecl *CMD) {
   assert(CMD->hasBody());
@@ -455,6 +457,18 @@ llvm::Optional setterVariableName(const 
CXXMethodDecl *CMD) {
   } else {
 return llvm::None;
   }
+
+  // Detect the case when the item is moved into the field.
+  if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
+if (CE->getNumArgs() != 1)
+  return llvm::None;
+auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
+!ND->isInStdNamespace())
+  return llvm::None;
+RHS = CE->getArg(0);
+  }
+
   auto *DRE = llvm::dyn_cast(RHS->IgnoreCasts());
   if (!DRE || DRE->getDecl() != Arg)
 return llvm::None;

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 636e5d99be52..48c0fef45ab8 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -698,6 +698,26 @@ class Foo {})cpp";
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Setter (move)
+   R"cpp(
+  namespace std { template T&& move(T&& t); }
+  struct X { int Y; void [[^setY]](float v) { Y = std::move(v); } };
+  )cpp",
+   [](HoverInfo ) {
+ HI.Name = "setY";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.NamespaceScope = "";
+ HI.Definition = "void setY(float v)";
+ HI.LocalScope = "X::";
+ HI.Documentation = "Trivial setter for `Y`.";
+ HI.Type = "void (float)";
+ HI.ReturnType = "void";
+ HI.Parameters.emplace();
+ HI.Parameters->emplace_back();
+ HI.Parameters->back().Type = "float";
+ HI.Parameters->back().Name = "v";
+ HI.AccessSpecifier = "public";
+   }},
   {// Field type initializer.
R"cpp(
   struct X { int x = 2; };
@@ -802,8 +822,8 @@ class Foo {})cpp";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
}},
-   {// No crash on InitListExpr.
-R"cpp(
+  {// No crash on InitListExpr.
+   R"cpp(
   struct Foo {
 int a[10];
   };



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


[PATCH] D88500: [AIX][Clang][Driver] Link libm when we would libc++

2020-09-29 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 295107.
daltenty added a comment.

- Add blank line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88500

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -20,6 +20,7 @@
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-NOT: "-lm"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
@@ -41,6 +42,7 @@
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-NOT: "-lm"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
@@ -64,6 +66,7 @@
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD-NOT: "-lm"
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
@@ -87,6 +90,7 @@
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD-NOT: "-lm"
 // CHECK-LD64-PTHREAD: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
@@ -109,6 +113,7 @@
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
@@ -131,6 +136,7 @@
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
@@ -153,6 +159,7 @@
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-STATIC-NOT: "-lm"
 // CHECK-LD32-STATIC: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Library search path.
@@ -176,6 +183,7 @@
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
 // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-LIBP-NOT: "-lm"
 // CHECK-LD32-LIBP: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. nostdlib.
@@ -200,6 +208,7 @@
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
+// CHECK-LD32-NO-STD-LIB-NOT: "-lm"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. nodefaultlibs.
@@ -224,6 +233,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
+// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lm"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
@@ -247,6 +257,7 @@
 // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc++"
 // CHECK-LD32-CXX-ARG-ORDER: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-ORDER: "-lm"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. lc++ and lc order.
@@ -266,6 +277,7 @@
 // CHECK-LD32-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD32-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-LCXX: "-lm"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. lc++ and lc order.
@@ -285,6 +297,7 @@
 // CHECK-LD64-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD64-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-CXX-ARG-LCXX: "-lm"
 // CHECK-LD64-CXX-ARG-LCXX: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. 

[PATCH] D88500: [AIX][Clang][Driver] Link libm when we would libc++

2020-09-29 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 295105.
daltenty added a comment.

- Remove deps comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88500

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -20,6 +20,7 @@
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-NOT: "-lm"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
@@ -41,6 +42,7 @@
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-NOT: "-lm"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
@@ -64,6 +66,7 @@
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD-NOT: "-lm"
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
@@ -87,6 +90,7 @@
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD-NOT: "-lm"
 // CHECK-LD64-PTHREAD: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
@@ -109,6 +113,7 @@
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
@@ -131,6 +136,7 @@
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
@@ -153,6 +159,7 @@
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-STATIC-NOT: "-lm"
 // CHECK-LD32-STATIC: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Library search path.
@@ -176,6 +183,7 @@
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
 // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-LIBP-NOT: "-lm"
 // CHECK-LD32-LIBP: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. nostdlib.
@@ -200,6 +208,7 @@
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
+// CHECK-LD32-NO-STD-LIB-NOT: "-lm"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. nodefaultlibs.
@@ -224,6 +233,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
+// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lm"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
@@ -247,6 +257,7 @@
 // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc++"
 // CHECK-LD32-CXX-ARG-ORDER: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-ORDER: "-lm"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. lc++ and lc order.
@@ -266,6 +277,7 @@
 // CHECK-LD32-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD32-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-LCXX: "-lm"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. lc++ and lc order.
@@ -285,6 +297,7 @@
 // CHECK-LD64-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD64-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-CXX-ARG-LCXX: "-lm"
 // CHECK-LD64-CXX-ARG-LCXX: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. 

[PATCH] D88174: [Sema] Address-space sensitive check for unbounded arrays (v2)

2020-09-29 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx reopened this revision.
chrish_ericsson_atx added a comment.
This revision is now accepted and ready to land.

Reverted due to another obscure test failure.  Working to diagnose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88174

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


[PATCH] D88507: [clangd][remote] Make sure relative paths are absolute with respect to posix style

2020-09-29 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Ahh, good catch! Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88507

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


[clang] 155d2d5 - Revert "[Sema] Address-space sensitive check for unbounded arrays (v2)"

2020-09-29 Thread Chris Hamilton via cfe-commits

Author: Chris Hamilton
Date: 2020-09-29T22:46:14+02:00
New Revision: 155d2d5300551c6ac26eaeef259d73d62f939d0b

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

LOG: Revert "[Sema] Address-space sensitive check for unbounded arrays (v2)"

This reverts commit d9ee935679e7164d1c47e351bbbcf5c25742b59c.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/const-eval.c
clang/test/SemaCXX/constant-expression-cxx1y.cpp

Removed: 
clang/test/Sema/unbounded-array-bounds.c



diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4562d1114694..f29eec316971 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8915,14 +8915,6 @@ def warn_array_index_precedes_bounds : Warning<
 def warn_array_index_exceeds_bounds : Warning<
   "array index %0 is past the end of the array (which contains %1 "
   "element%s2)">, InGroup;
-def warn_ptr_arith_exceeds_max_addressable_bounds : Warning<
-  "the pointer incremented by %0 refers past the last possible element for an 
array in %1-bit "
-  "address space containing %2-bit (%3-byte) elements (max possible %4 
element%s5)">,
-  InGroup;
-def warn_array_index_exceeds_max_addressable_bounds : Warning<
-  "array index %0 refers past the last possible element for an array in %1-bit 
"
-  "address space containing %2-bit (%3-byte) elements (max possible %4 
element%s5)">,
-  InGroup;
 def note_array_declared_here : Note<
   "array %0 declared here">;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a5de6a5c88db..eeb322262400 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14057,11 +14057,11 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, 
const Expr *IndexExpr,
   const ConstantArrayType *ArrayTy =
   Context.getAsConstantArrayType(BaseExpr->getType());
 
-  const Type *BaseType =
-  ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
-  bool IsUnboundedArray = (BaseType == nullptr);
-  if (EffectiveType->isDependentType() ||
-  (!IsUnboundedArray && BaseType->isDependentType()))
+  if (!ArrayTy)
+return;
+
+  const Type *BaseType = ArrayTy->getElementType().getTypePtr();
+  if (EffectiveType->isDependentType() || BaseType->isDependentType())
 return;
 
   Expr::EvalResult Result;
@@ -14069,10 +14069,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, 
const Expr *IndexExpr,
 return;
 
   llvm::APSInt index = Result.Val.getInt();
-  if (IndexNegated) {
-index.setIsUnsigned(false);
+  if (IndexNegated)
 index = -index;
-  }
 
   const NamedDecl *ND = nullptr;
   if (const DeclRefExpr *DRE = dyn_cast(BaseExpr))
@@ -14080,69 +14078,6 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, 
const Expr *IndexExpr,
   if (const MemberExpr *ME = dyn_cast(BaseExpr))
 ND = ME->getMemberDecl();
 
-  if (IsUnboundedArray) {
-if (index.isUnsigned() || !index.isNegative()) {
-  const auto  = getASTContext();
-  unsigned AddrBits =
-  ASTC.getTargetInfo().getPointerWidth(ASTC.getTargetAddressSpace(
-  EffectiveType->getCanonicalTypeInternal()));
-  if (index.getBitWidth() < AddrBits)
-index = index.zext(AddrBits);
-  CharUnits ElemCharUnits = ASTC.getTypeSizeInChars(EffectiveType);
-  llvm::APInt ElemBytes(index.getBitWidth(), ElemCharUnits.getQuantity());
-  // If index has more active bits than address space, we already know
-  // we have a bounds violation to warn about.  Otherwise, compute
-  // address of (index + 1)th element, and warn about bounds violation
-  // only if that address exceeds address space.
-  if (index.getActiveBits() <= AddrBits) {
-bool Overflow;
-llvm::APInt Product(index);
-Product += 1;
-Product = Product.umul_ov(ElemBytes, Overflow);
-if (!Overflow && Product.getActiveBits() <= AddrBits)
-  return;
-  }
-
-  // Need to compute max possible elements in address space, since that
-  // is included in diag message.
-  llvm::APInt MaxElems = llvm::APInt::getMaxValue(AddrBits);
-  MaxElems = MaxElems.zext(std::max(AddrBits + 1, 
ElemBytes.getBitWidth()));
-  MaxElems += 1;
-  ElemBytes = ElemBytes.zextOrTrunc(MaxElems.getBitWidth());
-  MaxElems = MaxElems.udiv(ElemBytes);
-
-  unsigned DiagID =
-  ASE ? diag::warn_array_index_exceeds_max_addressable_bounds
-  : diag::warn_ptr_arith_exceeds_max_addressable_bounds;
-
-  // Diag message shows element size in bits and in "bytes" (platform-
-  // dependent CharUnits)
-  

[PATCH] D88265: Fix comma with half vectors.

2020-09-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Sema/fp16vec-sema.c:33
+  1, hv0; // expected-warning 2 {{expression result unused}}
 
   // Implicit conversion between half vectors and float vectors are not 
allowed.

Since these diagnostics aren't relevant to the test, can you silence them by 
passing `-Wno-unused-value` or assigning the expressions to variables?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88265

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


[PATCH] D88333: Better diagnostics for anonymous bit-fields with attributes or an initializer

2020-09-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman marked 2 inline comments as done.
aaron.ballman added a comment.

Thank you for the reviews, I've committed in 
538762fef0b662048be2a261ebc12da249efa977 





Comment at: clang/lib/Parse/ParseDecl.cpp:4126
 /// struct-declarator: declarator[opt] ':' constant-expression
-if (Tok.isNot(tok::colon)) {
+if (Tok.isNot(tok::colon) && !isCXX11AttributeSpecifier()) {
   // Don't parse FOO:BAR as if it were a typo for FOO::BAR.

rsmith wrote:
> I think this change is redundant now.
Ah, good catch! I've corrected this (and the other one).


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

https://reviews.llvm.org/D88333

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


[clang] 538762f - Better diagnostics for anonymous bit-fields with attributes or an initializer.

2020-09-29 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-09-29T16:32:20-04:00
New Revision: 538762fef0b662048be2a261ebc12da249efa977

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

LOG: Better diagnostics for anonymous bit-fields with attributes or an 
initializer.

The current C++ grammar allows an anonymous bit-field with an attribute,
but this is ambiguous (the attribute in that case could appertain to the
type instead of the bit-field). The current thinking in the Core Working
Group is that it's better to disallow attributes in that position at the
grammar level so that the ambiguity resolves in favor of applying to the
type.

During discussions about the behavior of the attribute, the Core Working
Group also felt it was better to disallow anonymous bit-fields from
specifying a default member initializer.

This implements both sets of related grammar changes.

Added: 
clang/test/CXX/class/class.bit/p1.cpp

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/Parser/MicrosoftExtensions.cpp
clang/test/Parser/c2x-attributes.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index da4e1725269f..78d3a08b3028 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -872,6 +872,8 @@ def ext_bitfield_member_init: ExtWarn<
 def warn_cxx17_compat_bitfield_member_init: Warning<
   "default member initializer for bit-field is incompatible with "
   "C++ standards before C++20">, InGroup, DefaultIgnore;
+def err_anon_bitfield_member_init : Error<
+  "anonymous bit-field cannot have a default member initializer">;
 def err_incomplete_array_member_init: Error<
   "array bound cannot be deduced from a default member initializer">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ed11e0d1ce3c..4562d1114694 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5619,8 +5619,6 @@ def err_bitfield_width_exceeds_type_width : Error<
 def err_anon_bitfield_width_exceeds_type_width : Error<
   "width of anonymous bit-field (%0 bits) exceeds %select{width|size}1 "
   "of its type (%2 bit%s2)">;
-def err_anon_bitfield_init : Error<
-  "anonymous bit-field cannot have a default member initializer">;
 def err_incorrect_number_of_vector_initializers : Error<
   "number of elements must be either one or match the size of the vector">;
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index adec7c607682..3f314c59ade6 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4113,8 +4113,13 @@ void Parser::ParseStructDeclaration(
 DeclaratorInfo.D.setCommaLoc(CommaLoc);
 
 // Attributes are only allowed here on successive declarators.
-if (!FirstDeclarator)
+if (!FirstDeclarator) {
+  // However, this does not apply for [[]] attributes (which could show up
+  // before or after the __attribute__ attributes).
+  DiagnoseAndSkipCXX11Attributes();
   MaybeParseGNUAttributes(DeclaratorInfo.D);
+  DiagnoseAndSkipCXX11Attributes();
+}
 
 /// struct-declarator: declarator
 /// struct-declarator: declarator[opt] ':' constant-expression

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 059d875d683d..a903896f172c 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2305,10 +2305,15 @@ bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
 Declarator , VirtSpecifiers , ExprResult ,
 LateParsedAttrList ) {
   // member-declarator:
-  //   declarator pure-specifier[opt]
+  //   declarator virt-specifier-seq[opt] pure-specifier[opt]
   //   declarator requires-clause
   //   declarator brace-or-equal-initializer[opt]
-  //   identifier[opt] ':' constant-expression
+  //   identifier attribute-specifier-seq[opt] ':' constant-expression
+  //   brace-or-equal-initializer[opt]
+  //   ':' constant-expression
+  //
+  // NOTE: the latter two productions are a proposed bugfix rather than the
+  // current grammar rules as of C++20.
   if (Tok.isNot(tok::colon))
 ParseDeclarator(DeclaratorInfo);
   else
@@ -2342,7 +2347,11 @@ bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
   }
 
   // If attributes exist after the declarator, but before an '{', parse them.
+  // However, this does not apply for [[]] attributes (which could show up
+  // before or after the __attribute__ 

[PATCH] D88498: [FPEnv] Evaluate initializers in constant rounding mode

2020-09-29 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/test/AST/const-fpfeatures-strict.c:39
+
+// CHECK: @var_04 = {{.*}} %struct.S { float 0x3FF02000 }
+// CHECK: @var_05 = {{.*}} %struct.S { float 0x3FF02000 }

I think the initializer for var_04 is evaluated at translation time, therefore 
the initialization expression would look the same as var_01 above, using 
default rounding mode.  Same for var_05 and var_06. They have "static duration"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88498

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


[PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D87822#2301293 , @sepavloff wrote:

> In D87822#2301194 , @leonardchan 
> wrote:
>
>> Thanks for looking into it. We have that commit but it still seems to be
>> failing for us with the same error.
>
> In D88498  this test is removed because use 
> of rounding mode changed. So you could just remove this test to fix the bot.

Can we revert this change and reland it later with the fix? It's been 3 days 
now and our bots are still red.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87822

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


[PATCH] D88297: [clangd] Trivial setter support when moving items to fields

2020-09-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:466
+auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+if (!ND)
+  return llvm::None;

njames93 wrote:
> kadircet wrote:
> > nit: combine with the next condition, and perform the string comparison 
> > last, i.e.:
> > 
> > `if(!ND || !ND->isInStd || ND->getName() != "move")`
> Can you explain the reasoning for moving the comparison to the end?
it was to skip a potentialyl expensive string comparison, but now that I look 
into `isInStdNamespace` it is also performing a string comparison in the end. 
so nvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88297

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


[PATCH] D88477: [analyzer] Overwrite cast type in getBinding only if that was null originally

2020-09-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

A load from a region of type `T` should always yield a value of type `T` 
because that's what a load is.

I'd rather have it as an assertion: if the region is typed, the type shouldn't 
be specified. If such assertion is hard to satisfy, we could allow the same 
canonical type to be specified. But having a conflict between two sources of 
type information and resolving it by arbitrarily choosing one of them sounds 
scary and unreliable. This patch doesn't eliminate the source of the conflict, 
it simply changes the way we flip the coin to resolve it.

Normally then loading through a casted pointer the conflict is resolved by 
representing the casted pointer differently, so that the pointer appeared to be 
a `TypedValueRegion` of the correct type. Namely, it is achieved by wrapping it 
into an `ElementRegion` with index 0 and the correct type. Why didn't the same 
occur in this case? Do I understand correctly that `L` is just ``, not 
`{b, 0 S32b, unsigned char **}`?

---

This is the current status quo and how the patch should probably go within it. 
In the long term I'd prefer to undo this entire concept of "region having a 
type". Most of the time memory regions in C are "kinda" typed and type punning 
is indeed largely problematic due to the Strict Aliasing rule (and object 
lifetime rules in C++) but there are always ways to bypass those rules and our 
idea of regions having types fails us every single time this happens. Types are 
at best a mutable property attached to a region (i.e., like a dynamic type 
map), definitely not part of its identity. Every access should be typed 
separately and explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88477

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


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the review! I've commit in 
15fbae8ac303d8601ea95418d4818cb50d0765e1 



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

https://reviews.llvm.org/D88445

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


[clang] 15fbae8 - Use "default member initializer" instead of "in-class initializer" for diagnostics.

2020-09-29 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-09-29T15:04:23-04:00
New Revision: 15fbae8ac303d8601ea95418d4818cb50d0765e1

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

LOG: Use "default member initializer" instead of "in-class initializer" for 
diagnostics.

This changes some diagnostics to use terminology from the standard
rather than invented terminology, which improves consistency with other
diagnostics as well. There are no functional changes intended other
than wording and naming.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/Parser/MicrosoftExtensions.cpp
clang/test/Parser/cxx-class.cpp
clang/test/SemaCXX/PR9572.cpp
clang/test/SemaCXX/class.cpp
clang/test/SemaCXX/cxx98-compat.cpp
clang/test/SemaCXX/member-init.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 1ac1e9d10a7a..da4e1725269f 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -709,7 +709,7 @@ def err_ms_property_expected_accessor_name : Error<
 def err_ms_property_expected_comma_or_rparen : Error<
   "expected ',' or ')' at end of property accessor list">;
 def err_ms_property_initializer : Error<
-  "property declaration cannot have an in-class initializer">;
+  "property declaration cannot have a default member initializer">;
 
 def warn_cxx20_compat_explicit_bool : Warning<
   "this expression will be parsed as explicit(bool) in C++20">,
@@ -859,13 +859,13 @@ def warn_cxx98_compat_defaulted_deleted_function : 
Warning<
   "%select{defaulted|deleted}0 function definitions are incompatible with 
C++98">,
   InGroup, DefaultIgnore;
 
-// C++11 in-class member initialization
+// C++11 default member initialization
 def ext_nonstatic_member_init : ExtWarn<
-  "in-class initialization of non-static data member is a C++11 extension">,
-  InGroup;
+  "default member initializer for non-static data member is a C++11 "
+  "extension">, InGroup;
 def warn_cxx98_compat_nonstatic_member_init : Warning<
-  "in-class initialization of non-static data members is incompatible with 
C++98">,
-  InGroup, DefaultIgnore;
+  "default member initializer for non-static data members is incompatible with 
"
+  "C++98">, InGroup, DefaultIgnore;
 def ext_bitfield_member_init: ExtWarn<
   "default member initializer for bit-field is a C++20 extension">,
   InGroup;
@@ -873,7 +873,7 @@ def warn_cxx17_compat_bitfield_member_init: Warning<
   "default member initializer for bit-field is incompatible with "
   "C++ standards before C++20">, InGroup, DefaultIgnore;
 def err_incomplete_array_member_init: Error<
-  "array bound cannot be deduced from an in-class initializer">;
+  "array bound cannot be deduced from a default member initializer">;
 
 // C++11 alias-declaration
 def ext_alias_declaration : ExtWarn<

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8f6c7b9400fa..ed11e0d1ce3c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1842,7 +1842,7 @@ def note_nontrivial_no_copy : Note<
 def note_nontrivial_user_provided : Note<
   "because %select{base class of |field of |}0type %1 has a user-provided "
   "%sub{select_special_member_kind}2">;
-def note_nontrivial_in_class_init : Note<
+def note_nontrivial_default_member_init : Note<
   "because field %0 has an initializer">;
 def note_nontrivial_param_type : Note<
   "because its parameter is %
diff {of type $, not $|of the wrong type}2,3">;
@@ -8521,12 +8521,12 @@ def err_in_class_initializer_literal_type : Error<
   "'constexpr' specifier">;
 def err_in_class_initializer_non_constant : Error<
   "in-class initializer for static data member is not a constant expression">;
-def err_in_class_initializer_not_yet_parsed : Error<
+def err_default_member_initializer_not_yet_parsed : Error<
   "default member initializer for %1 needed within definition of enclosing "
   "class %0 outside of member functions">;
-def note_in_class_initializer_not_yet_parsed : Note<
+def note_default_member_initializer_not_yet_parsed : Note<
   "default member initializer declared here">;
-def err_in_class_initializer_cycle
+def err_default_member_initializer_cycle
 : Error<"default member initializer for %0 uses itself">;
 
 def ext_in_class_initializer_non_constant : Extension<

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 6558a4f6d8b2..2d2b80573a69 100644
--- 

[PATCH] D88500: [AIX][Clang][Driver] Link libm along with libc++

2020-09-29 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:165
 
+// Since libc++ has dependencies on libm, if we have one then add the 
other.
+if (getToolChain().ShouldLinkCXXStdlib(Args))

Is that right?

My check of the libc++ from XL C/C++ for AIX 16.1.0 shows a dependency on 
`libC.a`, but not `libm.a`:
```
[183]   0xundef  IMP DS EXTref libC.a(shrcore.o) 
uncaught_exception__3stdFv
```

It seems `-lm` is just linked for C++ invocations. Other targets also pick up 
`-lm` for C++ invocations as a stdlib (not specifically a C++ stdlib).



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:168
+  CmdArgs.push_back("-lm");
 CmdArgs.push_back("-lc");
   }

Minor nit: Given the spacing in this block, I think a blank line would be 
appropriate to have before this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88500

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


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Thanks for updating the comment in dsymutil!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88497

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


[clang-tools-extra] 962a247 - [clangd] Fix assertion in remote-index marshalling

2020-09-29 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-09-29T20:40:19+02:00
New Revision: 962a247aebba39bc8f2d6aa901ed512f5c09dc72

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

LOG: [clangd] Fix assertion in remote-index marshalling

convert_to_slash is a no-op on posix style.

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 839250982a03..31ce4a44ea55 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -296,8 +296,7 @@ llvm::Expected Marshaller::toProtobuf(const 
clangd::SymbolID ,
 llvm::Expected
 Marshaller::relativePathToURI(llvm::StringRef RelativePath) {
   assert(LocalIndexRoot);
-  assert(RelativePath == llvm::sys::path::convert_to_slash(
- RelativePath, llvm::sys::path::Style::posix));
+  assert(RelativePath == llvm::sys::path::convert_to_slash(RelativePath));
   if (RelativePath.empty())
 return error("Empty relative path.");
   if (llvm::sys::path::is_absolute(RelativePath))



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


[PATCH] D88507: [clangd][remote] Make sure relative paths are absolute with respect to posix style

2020-09-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Relative paths received from the server are always in posix style. So
we need to ensure they are relative using that style, and not the native one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88507

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp


Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -299,7 +299,7 @@
   assert(RelativePath == llvm::sys::path::convert_to_slash(RelativePath));
   if (RelativePath.empty())
 return error("Empty relative path.");
-  if (llvm::sys::path::is_absolute(RelativePath))
+  if (llvm::sys::path::is_absolute(RelativePath, 
llvm::sys::path::Style::posix))
 return error("RelativePath '{0}' is absolute.", RelativePath);
   llvm::SmallString<256> FullPath = llvm::StringRef(*LocalIndexRoot);
   llvm::sys::path::append(FullPath, RelativePath);


Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -299,7 +299,7 @@
   assert(RelativePath == llvm::sys::path::convert_to_slash(RelativePath));
   if (RelativePath.empty())
 return error("Empty relative path.");
-  if (llvm::sys::path::is_absolute(RelativePath))
+  if (llvm::sys::path::is_absolute(RelativePath, llvm::sys::path::Style::posix))
 return error("RelativePath '{0}' is absolute.", RelativePath);
   llvm::SmallString<256> FullPath = llvm::StringRef(*LocalIndexRoot);
   llvm::sys::path::append(FullPath, RelativePath);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77598: Integral template argument suffix and cast printing

2020-09-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/AST/TemplateBase.cpp:71-72
 
   if (T->isBooleanType() && !Policy.MSVCFormatting) {
 Out << (Val.getBoolValue() ? "true" : "false");
   } else if (T->isCharType()) {

rsmith wrote:
> reikdas wrote:
> > rsmith wrote:
> > > rsmith wrote:
> > > > It looks like `MSVCFormatting` wants `bool` values to be printed as `0` 
> > > > and `1`, and this patch presumably changes that (along with the 
> > > > printing of other builtin types). I wonder if this is a problem in 
> > > > practice (eg, if such things are used as keys for debug info or 
> > > > similar)...
> > > Do we need to suppress printing the suffixes below in `MSVCFormatting` 
> > > mode too?
> > @rsmith The tests pass, so that is reassuring at least. Is there any other 
> > way to find out whether we need to suppress printing the suffixes for other 
> > types in MSVCFormatting mode?
> @rnk Can you take a look at this? Per 
> rG60103383f097b6580ecb4519eeb87defdb7c05c9 and PR21528 it seems like there 
> might be specific requirements for how template arguments are formatted for 
> CodeView support; we presumably need to make sure we still satisfy those 
> requirements.
Probably. This change looks like it preserves behavior from before when 
`MSVCFormatting` is set, so I think this is OK. I checked, my version of MSVC 
still uses 1/0 in debug info for boolean template args.


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

https://reviews.llvm.org/D77598

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


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!


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

https://reviews.llvm.org/D88445

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


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 295055.
ellis added a subscriber: vsapsai.
ellis added a comment.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fix a comment to reference the correct method.

Thanks to @vsapsai for pointing this out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88497

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  llvm/tools/dsymutil/SymbolMap.cpp


Index: llvm/tools/dsymutil/SymbolMap.cpp
===
--- llvm/tools/dsymutil/SymbolMap.cpp
+++ llvm/tools/dsymutil/SymbolMap.cpp
@@ -47,7 +47,7 @@
 return Translation;
 
   // Objective-C symbols for the MachO symbol table start with a \1. Please see
-  // `CGObjCCommonMac::GetNameForMethod` in clang.
+  // `MangleContext::mangleObjCMethodName` in clang.
   if (Translation[0] == 1)
 return StringRef(Translation).drop_front();
 
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1079,8 +1079,9 @@
   void EmitImageInfo();
 
 public:
-  CGObjCCommonMac(CodeGen::CodeGenModule ) :
-CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) { }
+  CGObjCCommonMac(CodeGen::CodeGenModule )
+  : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()),
+Mangler(cgm.getContext().createMangleContext()) {}
 
   bool isNonFragileABI() const {
 return ObjCABI == 2;
@@ -1121,6 +1122,7 @@
 
 private:
   void fillRunSkipBlockVars(CodeGenModule , const CGBlockInfo );
+  std::unique_ptr Mangler;
 };
 
 namespace {
@@ -4003,9 +4005,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/true);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/true);
 
 CodeGenTypes  = CGM.getTypes();
 llvm::FunctionType *MethodTy =
@@ -4059,9 +4060,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/false);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/false);
 
 Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
 Name.str(), ());


Index: llvm/tools/dsymutil/SymbolMap.cpp
===
--- llvm/tools/dsymutil/SymbolMap.cpp
+++ llvm/tools/dsymutil/SymbolMap.cpp
@@ -47,7 +47,7 @@
 return Translation;
 
   // Objective-C symbols for the MachO symbol table start with a \1. Please see
-  // `CGObjCCommonMac::GetNameForMethod` in clang.
+  // `MangleContext::mangleObjCMethodName` in clang.
   if (Translation[0] == 1)
 return StringRef(Translation).drop_front();
 
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1079,8 +1079,9 @@
   void EmitImageInfo();
 
 public:
-  CGObjCCommonMac(CodeGen::CodeGenModule ) :
-CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) { }
+  CGObjCCommonMac(CodeGen::CodeGenModule )
+  : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()),
+Mangler(cgm.getContext().createMangleContext()) {}
 
   bool isNonFragileABI() const {
 return ObjCABI == 2;
@@ -1121,6 +1122,7 @@
 
 private:
   void fillRunSkipBlockVars(CodeGenModule , const CGBlockInfo );
+  std::unique_ptr Mangler;
 };
 
 namespace {
@@ -4003,9 +4005,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/true);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/true);
 
 CodeGenTypes  = CGM.getTypes();
 llvm::FunctionType *MethodTy =
@@ -4059,9 +4060,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/false);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/false);
 
 

[PATCH] D88403: Migrate Declarators to use the List API

2020-09-29 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 295053.
eduucaldas added a comment.

Update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88403

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp

Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -188,8 +188,9 @@
 TranslationUnit Detached synthesized
 `-SimpleDeclaration synthesized
   |-'int' synthesized
-  |-SimpleDeclarator Declarator synthesized
-  | `-'a' synthesized
+  |-DeclaratorList Declarators synthesized
+  | `-SimpleDeclarator ListElement synthesized
+  |   `-'a' synthesized
   `-';' synthesized
   )txt"));
 }
@@ -201,8 +202,9 @@
   EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
 SimpleDeclaration Detached synthesized
 |-'int' synthesized
-|-SimpleDeclarator Declarator synthesized
-| `-'a' synthesized
+|-DeclaratorList Declarators synthesized
+| `-SimpleDeclarator ListElement synthesized
+|   `-'a' synthesized
 `-';' synthesized
   )txt"));
 }
@@ -225,11 +227,12 @@
 TranslationUnit Detached synthesized
 `-SimpleDeclaration synthesized
   |-'void' synthesized
-  |-SimpleDeclarator Declarator synthesized
-  | |-'test' synthesized
-  | `-ParametersAndQualifiers synthesized
-  |   |-'(' OpenParen synthesized
-  |   `-')' CloseParen synthesized
+  |-DeclaratorList Declarators synthesized
+  | `-SimpleDeclarator ListElement synthesized
+  |   |-'test' synthesized
+  |   `-ParametersAndQualifiers synthesized
+  | |-'(' OpenParen synthesized
+  | `-')' CloseParen synthesized
   `-CompoundStatement synthesized
 |-'{' OpenParen synthesized
 |-IfStatement Statement synthesized
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -92,21 +92,23 @@
 TranslationUnit Detached
 |-SimpleDeclaration
 | |-'int'
-| |-SimpleDeclarator Declarator
-| | |-'main'
-| | `-ParametersAndQualifiers
-| |   |-'(' OpenParen
-| |   `-')' CloseParen
+| |-DeclaratorList Declarators
+| | `-SimpleDeclarator ListElement
+| |   |-'main'
+| |   `-ParametersAndQualifiers
+| | |-'(' OpenParen
+| | `-')' CloseParen
 | `-CompoundStatement
 |   |-'{' OpenParen
 |   `-'}' CloseParen
 `-SimpleDeclaration
   |-'void'
-  |-SimpleDeclarator Declarator
-  | |-'foo'
-  | `-ParametersAndQualifiers
-  |   |-'(' OpenParen
-  |   `-')' CloseParen
+  |-DeclaratorList Declarators
+  | `-SimpleDeclarator ListElement
+  |   |-'foo'
+  |   `-ParametersAndQualifiers
+  | |-'(' OpenParen
+  | `-')' CloseParen
   `-CompoundStatement
 |-'{' OpenParen
 `-'}' CloseParen
@@ -123,16 +125,18 @@
 TranslationUnit Detached
 |-SimpleDeclaration
 | |-'int'
-| |-SimpleDeclarator Declarator
-| | `-'a'
+| |-DeclaratorList Declarators
+| | `-SimpleDeclarator ListElement
+| |   `-'a'
 | `-';'
 `-SimpleDeclaration
   |-'int'
-  |-SimpleDeclarator Declarator
-  | |-'b'
-  | |-'='
-  | `-IntegerLiteralExpression
-  |   `-'42' LiteralToken
+  |-DeclaratorList Declarators
+  | `-SimpleDeclarator ListElement
+  |   |-'b'
+  |   |-'='
+  |   `-IntegerLiteralExpression
+  | `-'42' LiteralToken
   `-';'
 )txt"));
 }
@@ -146,21 +150,24 @@
 TranslationUnit Detached
 `-SimpleDeclaration
   |-'void'
-  |-SimpleDeclarator Declarator
-  | |-'foo'
-  | `-ParametersAndQualifiers
-  |   |-'(' OpenParen
-  |   |-ParameterDeclarationList Parameters
-  |   | |-SimpleDeclaration ListElement
-  |   | | |-'int'
-  |   | | `-SimpleDeclarator Declarator
-  |   | |   `-'a'
-  |   | |-',' ListDelimiter
-  |   | `-SimpleDeclaration ListElement
-  |   |   |-'int'
-  |   |   `-SimpleDeclarator Declarator
-  |   | `-'b'
-  |   `-')' CloseParen
+  |-DeclaratorList Declarators
+  | `-SimpleDeclarator ListElement
+  |   |-'foo'
+  |   `-ParametersAndQualifiers
+  | |-'(' OpenParen
+  | |-ParameterDeclarationList Parameters
+  | | |-SimpleDeclaration ListElement
+  | | | |-'int'
+  | | | `-DeclaratorList Declarators
+  | | |   `-SimpleDeclarator ListElement
+  | | | `-'a'
+  | | |-',' ListDelimiter
+  | | `-SimpleDeclaration ListElement
+  | |   |-'int'
+  | |   `-DeclaratorList Declarators
+  | | `-SimpleDeclarator ListElement
+  | |   `-'b'
+  | `-')' CloseParen
   `-CompoundStatement
 |-'{' OpenParen
 `-'}' CloseParen
@@ -178,8 +185,9 @@
 `-SimpleDeclaration
   |-'in\
 t'
-  |-SimpleDeclarator Declarator
-  | `-'a'
+  |-DeclaratorList Declarators
+  | `-SimpleDeclarator ListElement
+  

[PATCH] D88329: [objc] Consolidate ObjC name mangle code to AST

2020-09-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:929
-  /// \param[out] NameOut - The return value.
-  void GetNameForMethod(const ObjCMethodDecl *OMD,
-const ObjCContainerDecl *CD,

Note that the removed method is mentioned in comment docs at 
https://github.com/llvm/llvm-project/blob/3681be876fea9b270c7a1d2dc41679a399610e06/llvm/tools/dsymutil/SymbolMap.cpp#L50


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88329

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


[PATCH] D87737: Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3681be876fea: Add 
-fprofile-update={atomic,prefer-atomic,single} (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D87737?vs=294781=295042#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87737

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/code-coverage-tsan.c
  clang/test/CodeGen/tsan-instrprof-atomic.c
  clang/test/Driver/fprofile-update.c

Index: clang/test/Driver/fprofile-update.c
===
--- /dev/null
+++ clang/test/Driver/fprofile-update.c
@@ -0,0 +1,15 @@
+/// For -fprofile-instr-generate and -fprofile-arcs, increment counters atomically
+/// if -fprofile-update={atomic,prefer-atomic} or -fsanitize=thread is specified.
+// RUN: %clang -### %s -c -target x86_64-linux -fsanitize=thread %s 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=atomic 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=prefer-atomic 2>&1 | FileCheck %s
+
+// CHECK: "-fprofile-update=atomic"
+
+// RUN: %clang -### %s -c -fprofile-update=atomic -fprofile-update=single 2>&1 | FileCheck %s --check-prefix=SINGLE
+
+// SINGLE-NOT: "-fprofile-update=atomic"
+
+// RUN: not %clang %s -c -fprofile-update=unknown 2>&1 | FileCheck %s --check-prefix=ERROR
+
+// ERROR: error: unsupported argument 'unknown' to option 'fprofile-update='
Index: clang/test/CodeGen/tsan-instrprof-atomic.c
===
--- clang/test/CodeGen/tsan-instrprof-atomic.c
+++ clang/test/CodeGen/tsan-instrprof-atomic.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fsanitize=thread -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fprofile-update=atomic -o - | FileCheck %s
 
 // CHECK: define {{.*}}@foo
 // CHECK-NOT: load {{.*}}foo
Index: clang/test/CodeGen/code-coverage-tsan.c
===
--- clang/test/CodeGen/code-coverage-tsan.c
+++ clang/test/CodeGen/code-coverage-tsan.c
@@ -1,11 +1,12 @@
-/// -fsanitize=thread requires the (potentially concurrent) counter updates to be atomic.
-// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fsanitize=thread -femit-coverage-notes -femit-coverage-data \
+/// -fprofile-update=atomic (implied by -fsanitize=thread) requires the
+/// (potentially concurrent) counter updates to be atomic.
+// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic -femit-coverage-notes -femit-coverage-data \
 // RUN:   -coverage-notes-file /dev/null -coverage-data-file /dev/null -o - | FileCheck %s
 
 // CHECK-LABEL: void @foo()
 /// Two counters are incremented by __tsan_atomic64_fetch_add.
-// CHECK: call i64 @__tsan_atomic64_fetch_add
-// CHECK-NEXT:call i32 @__tsan_atomic32_fetch_sub
+// CHECK: atomicrmw add i64* {{.*}} @__llvm_gcov_ctr
+// CHECK-NEXT:atomicrmw sub i32*
 
 _Atomic(int) cnt;
 void foo() { cnt--; }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -884,6 +884,7 @@
   Opts.DebugRangesBaseAddress = Args.hasArg(OPT_fdebug_ranges_base_address);
 
   setPGOInstrumentor(Opts, Args, Diags);
+  Opts.AtomicProfileUpdate = Args.hasArg(OPT_fprofile_update_EQ);
   Opts.InstrProfileOutput =
   std::string(Args.getLastArgValue(OPT_fprofile_instrument_path_EQ));
   Opts.ProfileInstrumentUsePath =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -868,6 +868,17 @@
 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-filter-files=" + v)));
   }
 
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_update_EQ)) {
+StringRef Val = A->getValue();
+if (Val == "atomic" || Val == "prefer-atomic")
+  CmdArgs.push_back("-fprofile-update=atomic");
+else if (Val != "single")
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getOption().getName() << Val;
+  } else if (TC.getSanitizerArgs().needsTsanRt()) {
+CmdArgs.push_back("-fprofile-update=atomic");
+  }
+
   // Leave -fprofile-dir= an unused argument unless .gcda emission is
   // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' consider
   // the flag used. There is no -fno-profile-dir, so the user has no
Index: clang/lib/CodeGen/BackendUtil.cpp
===

[clang] 3681be8 - Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-29 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-09-29T10:43:23-07:00
New Revision: 3681be876fea9b270c7a1d2dc41679a399610e06

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

LOG: Add -fprofile-update={atomic,prefer-atomic,single}

GCC 7 introduced -fprofile-update={atomic,prefer-atomic} (prefer-atomic is for
best efforts (some targets do not support atomics)) to increment counters
atomically, which is exactly what we have done with -fprofile-instr-generate
(D50867) and -fprofile-arcs (b5ef137c11b1cc6ae839ee75b49233825772bdd0).
This patch adds the option to clang to surface the internal options at driver 
level.

GCC 7 also turned on -fprofile-update=prefer-atomic when -pthread is specified,
but it has performance regression
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89307). So we don't follow suit.

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

Added: 
clang/test/Driver/fprofile-update.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/code-coverage-tsan.c
clang/test/CodeGen/tsan-instrprof-atomic.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 2d0d71443dfd..ed6c9e3bc341 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2172,6 +2172,17 @@ programs using the same instrumentation method as 
``-fprofile-generate``.
   profile file, it reads from that file. If ``pathname`` is a directory name,
   it reads from ``pathname/default.profdata``.
 
+.. option:: -fprofile-update[=]
+
+  Unless ``-fsanitize=thread`` is specified, the default is ``single``, which
+  uses non-atomic increments. The counters can be inaccurate under thread
+  contention. ``atomic`` uses atomic increments which is accurate but has
+  overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
+  by the target, or ``single`` otherwise.
+
+  This option currently works with ``-fprofile-arcs`` and 
``-fprofile-instr-generate``,
+  but not with ``-fprofile-generate``.
+
 Disabling Instrumentation
 ^
 

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index a259218b29c6..062a8c3fe64a 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -185,6 +185,7 @@ CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1)
 VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is 
specified.
 
+CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a1f3d7a4316f..09fdf50b1cb8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -853,6 +853,9 @@ def fprofile_filter_files_EQ : Joined<["-"], 
"fprofile-filter-files=">,
 def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Instrument only functions from files where names don't match all 
the regexes separated by a semi-colon">;
+def fprofile_update_EQ : Joined<["-"], "fprofile-update=">,
+Group, Flags<[CC1Option, CoreOption]>, 
Values<"atomic,prefer-atomic,single">,
+MetaVarName<"">, HelpText<"Set update method of profile counters 
(atomic,prefer-atomic,single)">;
 def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Generate instrumented code to collect order file into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index f83ec2479652..d77590cc2adf 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -570,7 +570,7 @@ static Optional getGCOVOptions(const 
CodeGenOptions ,
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
   Options.Filter = CodeGenOpts.ProfileFilterFiles;
   Options.Exclude = CodeGenOpts.ProfileExcludeFiles;
-  Options.Atomic = LangOpts.Sanitize.has(SanitizerKind::Thread);
+  Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
 
@@ -582,10 +582,7 @@ getInstrProfOptions(const CodeGenOptions ,
   InstrProfOptions Options;
   Options.NoRedZone = 

[PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-29 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D87822#2301194 , @leonardchan wrote:

> Thanks for looking into it. We have that commit but it still seems to be
> failing for us with the same error.

In D88498  this test is removed because use of 
rounding mode changed. So you could just remove this test to fix the bot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87822

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


[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane resigned from this revision.
erichkeane added a comment.

I'm not really a good person to review this, OMP isn't nearly my expertise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

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


[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 295032.
jhuber6 added a reviewer: erichkeane.
jhuber6 added a comment.

Adding test cases for incompatible architecture messages. Checking the 
architecture is done by checking all combinations of architectures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/target_incompatible_architecture_messages.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll

Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -888,313 +888,313 @@
 ; CHECK: declare dso_local i32 @omp_pause_resource_all(i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
+; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels()
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void 

[PATCH] D87891: [clangd] findNearbyIdentifier(): guaranteed to give up after 2^N lines

2020-09-29 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX closed this revision.
ArcsinX added a comment.

Don't know why this didn't close automatically
Commit: https://reviews.llvm.org/rGd8ba6b4ab3eceb6bbcdf4371d4ffaab9d1a5cebe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87891

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


[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Richard and I had a long conversation about this further up-thread, if you 
missed it.


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

https://reviews.llvm.org/D87528

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


[PATCH] D88498: [FPEnv] Evaluate initializers in constant rounding mode

2020-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Parse/ParseDecl.cpp:2290
+  // rounding mode.
+  if (VD->isFileVarDecl() || VD->isConstexpr() ||
+  (!getLangOpts().CPlusPlus && VD->isStaticLocal())) {

It's far from clear to me that this is correct in C++. In principle, for a 
dynamic initializer, the rounding mode could have been set by an earlier 
initializer.

Perhaps we can make an argument that, due to the permission to interleave 
initializers from different TUs, every dynamic initializer must leave the 
program in the default rounding mode, but I don't think even that makes this 
approach correct, because an initializer could do this:

```
double d;
double e = (fesetround(...), d = some calculation, fesetround(...default...), 
d);
```

I think we can only do this in C and will need something different for C++.

(I think this also has problems in C++ due to constexpr functions: it's not the 
case that all floating point operations that will be evaluated as part of the 
initializer lexically appear within it.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88498

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


[PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Commented in that review, but that patch has the wrong fix: it's based on the 
targets LLVM is configured with rather than the current test target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87822

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


Re: [PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-29 Thread Leonard Chan via cfe-commits
Thanks for looking into it. We have that commit but it still seems to be
failing for us with the same error.

On Tue, Sep 29, 2020 at 12:58 AM Serge Pavlov  wrote:

> Hi!
>
> This issue must be fixed by: https://reviews.llvm.org/rGf91b9c0f9858
> Do you have recent changes from the trunk?
>
> Thanks,
> --Serge
>
>
> On Tue, Sep 29, 2020 at 4:22 AM Leonard Chan via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> leonardchan added a comment.
>>
>> Hi! It looks like this is causing a test failure on our aach64 builders (
>> https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-arm64/b8868095822628984976?
>> ):
>>
>>   [1113/1114] Running the Clang regression tests
>>   llvm-lit:
>> /b/s/w/ir/k/staging/llvm_build/bin/../../../llvm-project/llvm/utils/lit/lit/llvm/config.py:379:
>> note: using clang: /b/s/w/ir/k/staging/llvm_build/bin/clang
>>   -- Testing: 26708 tests, 256 workers --
>>   Testing:
>>   FAIL: Clang :: AST/const-fpfeatures-diag.c (269 of 26708)
>>    TEST 'Clang :: AST/const-fpfeatures-diag.c' FAILED
>> 
>>   Script:
>>   --
>>   : 'RUN: at line 1';   /b/s/w/ir/k/staging/llvm_build/bin/clang -cc1
>> -internal-isystem /b/s/w/ir/k/staging/llvm_build/lib/clang/12.0.0/include
>> -nostdsysteminc -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas
>> /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c
>>   --
>>   Exit Code: 1
>>
>>   Command Output (stderr):
>>   --
>>   error: 'error' diagnostics expected but not seen:
>> File /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c
>> Line 8: initializer element is not a compile-time constant
>>   error: 'warning' diagnostics seen but not expected:
>> (frontend): overriding currently unsupported use of floating point
>> exceptions on this target
>>   2 errors generated.
>>
>>   --
>>
>>   
>>   Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
>>   
>>   Failed Tests (1):
>> Clang :: AST/const-fpfeatures-diag.c
>>
>> Would you mind taking a look and sending out a fix? Thanks.
>>
>>
>> Repository:
>>   rG LLVM Github Monorepo
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D87822/new/
>>
>> https://reviews.llvm.org/D87822
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88265: Fix comma with half vectors.

2020-09-29 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 295025.
arames marked an inline comment as done.
arames added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88265

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/fp16vec-sema.c


Index: clang/test/Sema/fp16vec-sema.c
===
--- clang/test/Sema/fp16vec-sema.c
+++ clang/test/Sema/fp16vec-sema.c
@@ -28,6 +28,8 @@
   sv0 = hv0 >= hv1;
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
   sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
+  hv0, 1; // expected-warning 2 {{expression result unused}}
+  1, hv0; // expected-warning 2 {{expression result unused}}
 
   // Implicit conversion between half vectors and float vectors are not 
allowed.
   hv0 = fv0; // expected-error{{assigning to}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13933,9 +13933,10 @@
   // float vectors and truncating the result back to half vector. For now, we 
do
   // this only when HalfArgsAndReturn is set (that is, when the target is arm 
or
   // arm64).
-  assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
- isVector(LHS.get()->getType(), Context.HalfTy) &&
- "both sides are half vectors or neither sides are");
+  assert(
+  (Opc == BO_Comma || isVector(RHS.get()->getType(), Context.HalfTy) ==
+  isVector(LHS.get()->getType(), Context.HalfTy)) 
&&
+  "both sides are half vectors or neither sides are");
   ConvertHalfVec =
   needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 


Index: clang/test/Sema/fp16vec-sema.c
===
--- clang/test/Sema/fp16vec-sema.c
+++ clang/test/Sema/fp16vec-sema.c
@@ -28,6 +28,8 @@
   sv0 = hv0 >= hv1;
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
   sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
+  hv0, 1; // expected-warning 2 {{expression result unused}}
+  1, hv0; // expected-warning 2 {{expression result unused}}
 
   // Implicit conversion between half vectors and float vectors are not allowed.
   hv0 = fv0; // expected-error{{assigning to}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13933,9 +13933,10 @@
   // float vectors and truncating the result back to half vector. For now, we do
   // this only when HalfArgsAndReturn is set (that is, when the target is arm or
   // arm64).
-  assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
- isVector(LHS.get()->getType(), Context.HalfTy) &&
- "both sides are half vectors or neither sides are");
+  assert(
+  (Opc == BO_Comma || isVector(RHS.get()->getType(), Context.HalfTy) ==
+  isVector(LHS.get()->getType(), Context.HalfTy)) &&
+  "both sides are half vectors or neither sides are");
   ConvertHalfVec =
   needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d8ba6b4 - [clangd] findNearbyIdentifier(): guaranteed to give up after 2^N lines

2020-09-29 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2020-09-29T19:54:55+03:00
New Revision: d8ba6b4ab3eceb6bbcdf4371d4ffaab9d1a5cebe

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

LOG: [clangd] findNearbyIdentifier(): guaranteed to give up after 2^N lines

As @kadircet mentions in D84912#2184144, `findNearbyIdentifier()` traverses the 
whole file if there is no identifier for the word.
This patch ensures give up after 2^N lines in any case.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 9e8791c2a765..9532e1418cca 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -562,19 +562,34 @@ const syntax::Token *findNearbyIdentifier(const 
SpelledWord ,
   auto Cost = [&](SourceLocation Loc) -> unsigned {
 assert(SM.getFileID(Loc) == File && "spelled token in wrong file?");
 unsigned Line = SM.getSpellingLineNumber(Loc);
-if (Line > WordLine)
-  return 1 + llvm::Log2_64(Line - WordLine);
-if (Line < WordLine)
-  return 2 + llvm::Log2_64(WordLine - Line);
-return 0;
+return Line >= WordLine ? Line - WordLine : 2 * (WordLine - Line);
   };
   const syntax::Token *BestTok = nullptr;
-  // Search bounds are based on word length: 2^N lines forward.
-  unsigned BestCost = Word.Text.size() + 1;
+  unsigned BestCost = -1;
+  // Search bounds are based on word length:
+  // - forward: 2^N lines
+  // - backward: 2^(N-1) lines.
+  unsigned MaxDistance =
+  1U << std::min(Word.Text.size(),
+   std::numeric_limits::digits - 1);
+  // Line number for SM.translateLineCol() should be one-based, also
+  // SM.translateLineCol() can handle line number greater than
+  // number of lines in the file.
+  // - LineMin = max(1, WordLine + 1 - 2^(N-1))
+  // - LineMax = WordLine + 1 + 2^N
+  unsigned LineMin =
+  WordLine + 1 <= MaxDistance / 2 ? 1 : WordLine + 1 - MaxDistance / 2;
+  unsigned LineMax = WordLine + 1 + MaxDistance;
+  SourceLocation LocMin = SM.translateLineCol(File, LineMin, 1);
+  assert(LocMin.isValid());
+  SourceLocation LocMax = SM.translateLineCol(File, LineMax, 1);
+  assert(LocMax.isValid());
 
   // Updates BestTok and BestCost if Tok is a good candidate.
   // May return true if the cost is too high for this token.
   auto Consider = [&](const syntax::Token ) {
+if (Tok.location() < LocMin || Tok.location() > LocMax)
+  return true; // we are too far from the word, break the outer loop.
 if (!(Tok.kind() == tok::identifier && Tok.text(SM) == Word.Text))
   return false;
 // No point guessing the same location we started with.

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index a48bb9c8c182..40637b5fa758 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1428,6 +1428,11 @@ TEST(LocateSymbol, NearbyIdentifier) {
 
 
   // h^i
+
+
+
+
+  int x = hi;
 )cpp",
   R"cpp(
   // prefer nearest occurrence even if several matched tokens



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


[PATCH] D88265: Fix comma with half vectors.

2020-09-29 Thread Alexandre Rames via Phabricator via cfe-commits
arames marked 2 inline comments as done.
arames added inline comments.



Comment at: clang/test/Sema/fp16vec-sema.c:29
   sv0 = hv0 >= hv1;
+  hv0, 1; // expected-warning 2 {{expression result unused}}
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}

fhahn wrote:
> nit: it might be slightly better to move it 2 lines further down, so all 
> operators that assign the result are grouped together. Also, should we add 
> `1, hv0` as well?
Moved.
I added `1, hv0` for completeness. It would hit the same path as the reverse.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88265

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


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

2020-09-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D72705#2274568 , @balazske wrote:

> I am not sure if this checker is worth to further development. A part of the 
> found bugs can be detected with other checkers too, specially if the 
> preconditions of many standard functions are checked (more than what is done 
> now) and by modeling the function calls with assumed error return value.

We shouldn't throw all the knowledge away, once its in our hands. What you're 
suggesting as an alternative is using state splits, something that is obviously 
expensive, and we can't know whether that state split is always just / 
constructive.

---

Since we had private meetings about this, it would be great to share the 
overall vision going forward. While we shouldn't burden @NoQ with having to 
review this checker line-by-line, he might have valuable input on what we're 
going for.

I'd like to ask you to write a mail on cfe-dev, and bring forward a formal 
proposal:

- Explain ERR33-C, and your interpretation of it. Highlight how you want to see 
very explicit error checking against the concrete return value in some cases, 
and not in others. Provide a list of functions where you think, and why you 
think that vigorous checking is appropriate, and a list for those where a more 
lenient one could be used.
- Explain why you picked symbolic execution to solve this problem.
- Explain how this problem could be solved, and the pros/cons of them:
  - Making state splits in StdLibraryFunctionChecker
  - Expanding on taint analysis
  - Check constraints on a return value in a new checker (this is impossible, 
sure, but why?)
  - GDM tracking of values to be checked in a new checker
- You picked no4 -- justify it.

Since you made considerable progress already, it would be great to have talk 
about how you are implementing this, and why. For instance, "I recognize 
appropriate function in checkPostCall, and mark their return value as unchecked 
in the GDM. Later, in checkLocation, if I find that such a value is read from, 
I'll analyze the surrounding code to find out whether its a rule-compliant 
comparison of it, if it is not, I emit a warning. This is done by ascending the 
AST with a ParentMap, and running a statement visitor on the parent statement". 
Code examples are always amazing, demonstrate on a piece of code how 
`if(someReturnValue != 0)`, or something similar would be analyzed.

---

I hope I didn't sounds condescending or demanding, it was definitely not my 
intent. Its a joy to see your works come to life, there are a lot of smarts to 
marvel in! With that said, the reviewing process has shown some significant 
problems.

D71510  was submitted 10 months ago -- you 
obviously didn't work on it non-stop, but the fact that some pivotal aspects of 
your solution was realized by me only a month ago despite doing my best to 
follow the development is very unfortunate indeed. I'm not sure anyone else 
realized the extent of it either. Changes on StreamChecker followed a very 
similar trend, I felt like I had to understand, explain, and prove the 
correctness of the change for myself. As I made progress on it, sometimes the 
patches were split up, reuploaded and abandoned, like a multi-headed hydra. We 
ought to draw some lessons from this.

As an author, you can make the reviewers job a lot easier by:

- If the change is big enough, have a round on the mailing list //before// 
writing too much code. Scouting ahead is fine, but its not worth going too far.
- Provide a thorough summary with examples, drawings (D70411#1754356 
), whatever that helps to convey the 
message. If the code you're changing took considerable time to understand, it 
will probably take considerable time for reviewers as well. D86874 
, D55566 , 
D86135  and D86736 
 are great examples. D63954 
 keeps it short, but provides a link to more 
discussions.
- For a new checker, upload a very slimmed down version of your prototype. Its 
okay if it has FP/FN problems, or crashes on some weird input, its alpha for a 
reason. Its rare that for demonstration purposes you really need 500+ LOC. This 
allows everyone to discuss followup steps as well (though I don't think you 
ever left me in the dark regarding that).
- If a high level objection/question rose, its not worth adding new features, 
or even updating it much, unless it directly clarifies some trivial 
misunderstanding.
- When you publish results, give your input on them. Are you satisfied with the 
findings? Are there notable false positives? Could they be fixed easily?
- Laugh at how I used to do none of these, again, because its funny 
(D45532#1083670 ).

There are a lot of lessons to be taken on 

[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

Yes please commit for me :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88497

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


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Oh, oops, I should've caught this in review.  I assume you still need a commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88497

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


[PATCH] D88500: [AIX][Clang][Driver] Link libm along with libc++

2020-09-29 Thread David Tenty via Phabricator via cfe-commits
daltenty created this revision.
daltenty added reviewers: hubert.reinterpretcast, DiggerLin.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
daltenty requested review of this revision.

since libc++ has dependencies on libm.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88500

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -20,6 +20,7 @@
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-NOT: "-lm"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
@@ -41,6 +42,7 @@
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-NOT: "-lm"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
@@ -64,6 +66,7 @@
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD-NOT: "-lm"
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
@@ -87,6 +90,7 @@
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD-NOT: "-lm"
 // CHECK-LD64-PTHREAD: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
@@ -109,6 +113,7 @@
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
@@ -131,6 +136,7 @@
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
@@ -153,6 +159,7 @@
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-STATIC-NOT: "-lm"
 // CHECK-LD32-STATIC: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Library search path.
@@ -176,6 +183,7 @@
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
 // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-LIBP-NOT: "-lm"
 // CHECK-LD32-LIBP: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. nostdlib.
@@ -200,6 +208,7 @@
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc++"
 // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads"
+// CHECK-LD32-NO-STD-LIB-NOT: "-lm"
 // CHECK-LD32-NO-STD-LIB-NOT: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. nodefaultlibs.
@@ -224,6 +233,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
+// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lm"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
@@ -247,6 +257,7 @@
 // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc++"
 // CHECK-LD32-CXX-ARG-ORDER: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-ORDER: "-lm"
 // CHECK-LD32-CXX-ARG-ORDER: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. lc++ and lc order.
@@ -266,6 +277,7 @@
 // CHECK-LD32-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD32-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-LD32-CXX-ARG-LCXX: "-lm"
 // CHECK-LD32-CXX-ARG-LCXX: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. lc++ and lc order.
@@ -285,6 +297,7 @@
 // CHECK-LD64-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-CXX-ARG-LCXX: "-lc++"
 // CHECK-LD64-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
+// CHECK-LD64-CXX-ARG-LCXX: "-lm"
 

[PATCH] D88462: FP math settings for static duration initialization - work in progress

2020-09-29 Thread Melanie Blower via Phabricator via cfe-commits
mibintc abandoned this revision.
mibintc added a comment.

refer to https://reviews.llvm.org/D88498


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88462

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


[PATCH] D88498: [FPEnv] Evaluate initializers in constant rounding mode

2020-09-29 Thread Melanie Blower via Phabricator via cfe-commits
mibintc accepted this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

thanks for this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88498

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


[PATCH] D88359: [analyzer][RFC] Complete rewrite of ArrayBoundCheckerV2

2020-09-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Thank you for your time @balazske!
Your catches were really valuable.




Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:61
+
+  return NeedsExtraBitToPreserveSigness ? Signed : ExtendedSigned;
+}

balazske wrote:
> Should not the `ExtendedSigned` be in the true branch?
You are right. Thanks.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:87
+/// stored value.
+static APSInt absWithoutWrapping(const llvm::APSInt ) {
+  // If unsigned, we might need a sign bit.

balazske wrote:
> I do not like these function names. `getCommonSignedTypeToFit`, 
> `isRepresentableBySigned`, `getAbsWithoutWrapping` is better to have the 
> common "start verbs" in the names.
You are probably right about that.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:241
+  const APSInt )
+  : LastValidState(std::move(State)), SVB(SVB), RootSymbol(RootSymbol) {
+assert(LastValidState);

balazske wrote:
> std::move is not needed here
But definitely not hurt :D
I quite like to use `move` on by-value parameters.
This way the implementation could omit the increment decrement even if the 
implementation currently doesn't exploit this.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:269
+  /// Starts the simplification process.
+  SimplificationResult Simplify() {
+LLVM_DEBUG(llvm::dbgs() << __func__ << ": initially: '";

balazske wrote:
> Function name should start with lower case.
Thanks.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:285
+   LastValidState->printJson(llvm::dbgs()); llvm::dbgs() << '\n';);
+return {std::move(LastValidState), std::move(LowerBound),
+std::move(UpperBound), SymbolVal(RootSymbol), 
SimplificationFailed};

balazske wrote:
> The moves here are not needed.
I'm not convinced about that.
I think without move we would do a copy there - which could be expensive in the 
case of `APSInt`s.
Here is an example demonstrating this: https://godbolt.org/z/E5dqWb
I know that currently APSInt does not support move operations, but I already 
plan adding that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88359

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


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:801
+ getLangOpts().CPlusPlus11 || getLangOpts().CPlusPlus14 ||
+ getLangOpts().CPlusPlus17 || getLangOpts().C2x) {
+MustProgress = true;

Also in C? And C2x in the end is probably CPLusPlus2x?



Comment at: clang/lib/CodeGen/CGStmt.cpp:894
+else if (C->isOne())
+  IsMustProgress = false;
+  } else if (getLangOpts().C11 || getLangOpts().C17 || getLangOpts().C2x ||

Maybe call this FnIsMustProgress or the other one LoopMustProgress.



Comment at: clang/lib/CodeGen/CGStmt.cpp:898
+ getLangOpts().CPlusPlus17 || getLangOpts().C2x)
+MustProgress = true;
+

same as above



Comment at: clang/lib/CodeGen/CGStmt.cpp:946
+   getLangOpts().CPlusPlus17 || getLangOpts().C2x) &&
+  (!S.getCond() || !S.getCond()->EvaluateAsInt(Result, getContext(
+MustProgress = true;

same as above.

Don't we have to update IsMustProgress here too?




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:1165
+IsMustProgress = true;
+  }
+

no braces. why the mustprogress check?



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:1172
+
+  if (IsMustProgress)
+CurFn->addFnAttr(llvm::Attribute::MustProgress);

Say that we do this late because we need to see the body.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

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


[PATCH] D88477: [analyzer] Overwrite cast type in getBinding only if that was null originally

2020-09-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D88477#2300687 , @martong wrote:

>> In this example, it cast to the `unsigned char` (which is the type of the 
>> stored value of `**b`, stored at `#1`) instead of the static type of the 
>> access (the type of `**b` is  `char`at `#2`).
>
> Possible typo in the summary. At `#2` the type should be `char *` shouldn't 
> it?

Yup, thanks. Updated revision summary accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88477

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


[PATCH] D88462: FP math settings for static duration initialization - work in progress

2020-09-29 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Please look at D88498 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88462

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


[PATCH] D88498: [FPEnv] Evaluate initializers in constant rounding mode

2020-09-29 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, mibintc.
Herald added a project: clang.
sepavloff requested review of this revision.

Previously initializers were evaluated using rounding mode currently
specified by Sema. If at the same time FP exception behavior was set
to `strict`, compiler failed to compile the following C code:

  struct S { float f; };
  static struct S x = {0.63};

This happened because setting strict behavior set rounding mode to
`dymanic`. In this case the value of initializer depends on the current
rounding mode and it cannot be evaluated in compile time.

Initializers for some objects must be constants. On the other hand using
`dynamic` as rounding mode make no sense. Even in C++ if the initializer
is evaluated dynamically, it happens before execution of `main`, so
there is no possibility to set rounding mode for such initializers. So
if rounding mode is `dynamic` when an initializer is evaluated in some
cases, compiler replaces it with default `tonearest` rounding.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88498

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/test/AST/const-fpfeatures-diag.c
  clang/test/AST/const-fpfeatures-strict.c

Index: clang/test/AST/const-fpfeatures-strict.c
===
--- /dev/null
+++ clang/test/AST/const-fpfeatures-strict.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -S -emit-llvm -ffp-exception-behavior=strict -Wno-unknown-pragmas %s -o - | FileCheck %s
+
+// nextUp(1.F) == 0x1.02p0F
+
+struct S {
+  float f;
+};
+
+static struct S var_01 = {0x1.01p0};
+struct S *func_01() {
+  return _01;
+}
+
+struct S var_02 = {0x1.01p0};
+
+struct S *func_03() {
+  static struct S var_03 = {0x1.01p0};
+  return _03;
+}
+
+// CHECK: @var_01 = {{.*}} %struct.S { float 1.00e+00 }
+// CHECK: @var_02 = {{.*}} %struct.S { float 1.00e+00 }
+// CHECK: @func_03.var_03 = {{.*}} %struct.S { float 1.00e+00 }
+
+#pragma STDC FENV_ROUND FE_UPWARD
+
+static struct S var_04 = {0x1.01p0};
+struct S *func_04() {
+  return _04;
+}
+
+struct S var_05 = {0x1.01p0};
+
+struct S *func_06() {
+  static struct S var_06 = {0x1.01p0};
+  return _06;
+}
+
+// CHECK: @var_04 = {{.*}} %struct.S { float 0x3FF02000 }
+// CHECK: @var_05 = {{.*}} %struct.S { float 0x3FF02000 }
+// CHECK: @func_06.var_06 = {{.*}} %struct.S { float 0x3FF02000 }
Index: clang/test/AST/const-fpfeatures-diag.c
===
--- clang/test/AST/const-fpfeatures-diag.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas %s
-
-// REQUIRES: x86-registered-target
-
-#pragma STDC FENV_ROUND FE_DYNAMIC
-
-// nextUp(1.F) == 0x1.02p0F
-
-float F1 = 0x1.00p0F + 0x0.02p0F;
-float F2 = 0x1.00p0F + 0x0.01p0F; // expected-error{{initializer element is not a compile-time constant}}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2281,6 +2281,26 @@
   }
 
   PreferredType.enterVariableInit(Tok.getLocation(), ThisDecl);
+
+  Sema::FPFeaturesStateRAII FPO(Actions);
+  if (auto VD = dyn_cast_or_null(ThisDecl))
+if (!VD->isInvalidDecl()) {
+  // If variable requires constant initialization, set constant
+  // rounding mode.
+  if (VD->isFileVarDecl() || VD->isConstexpr() ||
+  (!getLangOpts().CPlusPlus && VD->isStaticLocal())) {
+if (Actions.getCurFPFeatures().getRoundingMode() ==
+llvm::RoundingMode::Dynamic) {
+  // If constant rounding mode is 'dynamic', it means that a command
+  // line option line like `-ffpmodel=strict` is in effect. Set
+  // constant rounding to default in this case.
+  FPOptions NewFPO = Actions.getCurFPFeatures();
+  NewFPO.setRoundingMode(llvm::RoundingMode::NearestTiesToEven);
+  Actions.setCurFPFeatures(NewFPO);
+}
+  }
+}
+
   ExprResult Init = ParseInitializer();
 
   // If this is the only decl in (possibly) range based for statement,
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -589,13 +589,7 @@
   // This stack tracks the current state of Sema.CurFPFeatures.
   PragmaStack FpPragmaStack;
   FPOptionsOverride CurFPFeatureOverrides() {
-FPOptionsOverride result;
-if (!FpPragmaStack.hasValue()) {
-  result = FPOptionsOverride();
-} else {
-  result = FpPragmaStack.CurrentValue;
-}
-return result;
+return FpPragmaStack.CurrentValue;
   }
 
   // RAII 

[clang] 1192747 - NFC, add a missing stdlib include for the use of abort

2020-09-29 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-09-29T08:50:51-07:00
New Revision: 119274748bce6d1248aa57cb55d79bfeae8a2f8e

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

LOG: NFC, add a missing stdlib include for the use of abort

The FatalErrorHandler.cpp file uses 'abort', but doesn't include
'stdlib.h'. This causes a build error when modules are used in clang.

Added: 


Modified: 
clang/tools/libclang/FatalErrorHandler.cpp

Removed: 




diff  --git a/clang/tools/libclang/FatalErrorHandler.cpp 
b/clang/tools/libclang/FatalErrorHandler.cpp
index 6b435fcfcc95..ef21569637f0 100644
--- a/clang/tools/libclang/FatalErrorHandler.cpp
+++ b/clang/tools/libclang/FatalErrorHandler.cpp
@@ -9,6 +9,7 @@
 
 #include "clang-c/FatalErrorHandler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 
 static void aborting_fatal_error_handler(void *, const std::string ,
  bool) {



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


[clang-tools-extra] a9f63d2 - [clangd] Disable msan instrumentation for generated Evaluate().

2020-09-29 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2020-09-29T17:44:10+02:00
New Revision: a9f63d22fafb0d7de768efc6b7447f8e7f6bb220

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

LOG: [clangd] Disable msan instrumentation for generated Evaluate().

MSAN build times out for generated DecisionForest inference runtime.

A solution worth trying is splitting the function into 300 smaller
functions and then re-enable msan.

For now we are disabling instrumentation for the generated function.

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

Added: 


Modified: 
clang-tools-extra/clangd/quality/CompletionModelCodegen.py

Removed: 




diff  --git a/clang-tools-extra/clangd/quality/CompletionModelCodegen.py 
b/clang-tools-extra/clangd/quality/CompletionModelCodegen.py
index 20bfccd8806f..423e5d14cf52 100644
--- a/clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ b/clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@ class can be used to represent a code completion candidate.
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,9 @@ class %s {
   friend float Evaluate(const %s&);
 };
 
+// The function may have large number of lines of code. MSAN
+// build times out in such case.
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s



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


[PATCH] D88495: [clangd] Disable msan instrumentation for generated Evaluate().

2020-09-29 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa9f63d22fafb: [clangd] Disable msan instrumentation for 
generated Evaluate(). (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88495

Files:
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py


Index: clang-tools-extra/clangd/quality/CompletionModelCodegen.py
===
--- clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,9 @@
   friend float Evaluate(const %s&);
 };
 
+// The function may have large number of lines of code. MSAN
+// build times out in such case.
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s


Index: clang-tools-extra/clangd/quality/CompletionModelCodegen.py
===
--- clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,9 @@
   friend float Evaluate(const %s&);
 };
 
+// The function may have large number of lines of code. MSAN
+// build times out in such case.
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78938: Make LLVM build in C++20 mode

2020-09-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/IR/BasicBlock.h:324-325
+template ::value>>
 phi_iterator_impl(const phi_iterator_impl )

dblaikie wrote:
> Quuxplusone wrote:
> > BRevzin wrote:
> > > dblaikie wrote:
> > > > BRevzin wrote:
> > > > > dblaikie wrote:
> > > > > > What tripped over/required this SFINAE?
> > > > > There's somewhere which compared a const iterator to a non-const 
> > > > > iterator, that ends up doing conversions in both directions under 
> > > > > C++20 rules, one direction of which is perfectly fine and the other 
> > > > > was a hard error. Need to make the non-const iterator not 
> > > > > constructible from a const iterator.
> > > > Is this true for all iterators? Or some quirk of how this one is 
> > > > written/used (that could be fixed/changed there instead)?
> > > So I undid this change to copy the exact issue that I ran into. But it 
> > > actually ended up still compiling anyway. Part of the issue might be that 
> > > I keep futzing with the cmake configuration since it takes me more than 
> > > an hour to compile, so maybe there's some target that needed this change 
> > > that I no longer compile.
> > > 
> > > But the kind of problem I think this had was:
> > > 
> > > ```
> > > template 
> > > struct iterator {
> > > T* p;
> > > 
> > > template 
> > > iterator(iterator rhs)
> > > : p(rhs.p)
> > > { } 
> > > 
> > > bool operator==(iterator const& rhs);
> > > };
> > > 
> > > bool check(iterator a, iterator b) {
> > > return a == b;
> > > }
> > > ```
> > > 
> > > which compiles fine in C++17 but is ambiguous in C++20 because 
> > > `b.operator==(a)` is also a candidate (even though it's not _really_ a 
> > > candidate, and would be a hard error if selected). the sfinae removes the 
> > > bad candidate from the set. 
> > > 
> > > It's true for all iterators in general in that you want `const_iterator` 
> > > constructible from `iterator` but not the reverse (unless they're the 
> > > same type).
> > IMO there is a (much) bigger task hiding here, which is to audit every type 
> > in the codebase whose name contains the string "Iterator" and compare them 
> > to the C++20 Ranges `std::forward_iterator` concept. My impression is that 
> > the vast majority of real-world "iterator types" are not iterators 
> > according to C++20 Ranges, and that this can have arbitrarily weird effects 
> > when you mix them with the C++20 STL.
> > 
> > However, that is //massive// scope creep re this particular patch. I think 
> > the larger question of "do all our iterators need X / are all our iterators 
> > written wrong" should be scoped-outside-of this patch.
> Sorry, not suggesting that kind of scope creep - but do want to understand 
> whether this is representative of the way code should generally be written, 
> or whether this is working around some other issue/different fix.
Fair enough - don't mind keeping it in then.



Comment at: llvm/include/llvm/Support/BinaryStreamRef.h:124
 
-  bool operator==(const RefType ) const {
-if (BorrowedImpl != Other.BorrowedImpl)
+  friend bool operator==(const RefType , const RefType ) {
+if (Self.BorrowedImpl != Other.BorrowedImpl)

dblaikie wrote:
> Quuxplusone wrote:
> > Is there a neat rule of thumb for when you were able to preserve the member 
> > `bool Me::operator==(const Me& rhs) const` versus when you were forced to 
> > change it to a hidden friend? It seems like maybe you changed it to a 
> > hidden friend only in cases where `Me` was a base class, is that right?
> Be curious of the answer here - and, honestly, I'd be fine with changing them 
> all to friends. It makes them more consistent - equal rank for implicit 
> conversions on LHS and RHS, etc. (generally considered best practice 
> basically to not define op overloads as members if they can be defined as 
> non-members)
Ping on this (& I'd usually call the parameters LHS and RHS rather than Self 
and Other)



Comment at: llvm/unittests/ADT/STLExtrasTest.cpp:465
   // Check fancy pointer overload for unique_ptr
+  // Parenthesizing to_address to avoid ADL finding std::to_address
   std::unique_ptr V2 = std::make_unique(0);

dblaikie wrote:
> jhenderson wrote:
> > Nit: trailing full stop.
> Probably more suitable to use qualify the name rather than use parens (teh 
> comment's still helpful to explain why either strategy is used) - that's 
> what's done with llvm::make_unique, for instance.
Ping on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D88329: [objc] Consolidate ObjC name mangle code to AST

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

https://reviews.llvm.org/D88497 will fix the leak


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88329

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


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis created this revision.
ellis added a reviewer: rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
ellis requested review of this revision.

A memory leak was introduced in https://reviews.llvm.org/D88329

CGObjCMac.cpp was leaking a MangleContext everytime it mangled
an ObjC method. We now have an instance variable that allocates
and deallocates the context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88497

Files:
  clang/lib/CodeGen/CGObjCMac.cpp


Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1079,8 +1079,9 @@
   void EmitImageInfo();
 
 public:
-  CGObjCCommonMac(CodeGen::CodeGenModule ) :
-CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) { }
+  CGObjCCommonMac(CodeGen::CodeGenModule )
+  : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()),
+Mangler(cgm.getContext().createMangleContext()) {}
 
   bool isNonFragileABI() const {
 return ObjCABI == 2;
@@ -1121,6 +1122,7 @@
 
 private:
   void fillRunSkipBlockVars(CodeGenModule , const CGBlockInfo );
+  std::unique_ptr Mangler;
 };
 
 namespace {
@@ -4003,9 +4005,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/true);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/true);
 
 CodeGenTypes  = CGM.getTypes();
 llvm::FunctionType *MethodTy =
@@ -4059,9 +4060,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/false);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/false);
 
 Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
 Name.str(), ());


Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1079,8 +1079,9 @@
   void EmitImageInfo();
 
 public:
-  CGObjCCommonMac(CodeGen::CodeGenModule ) :
-CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) { }
+  CGObjCCommonMac(CodeGen::CodeGenModule )
+  : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()),
+Mangler(cgm.getContext().createMangleContext()) {}
 
   bool isNonFragileABI() const {
 return ObjCABI == 2;
@@ -1121,6 +1122,7 @@
 
 private:
   void fillRunSkipBlockVars(CodeGenModule , const CGBlockInfo );
+  std::unique_ptr Mangler;
 };
 
 namespace {
@@ -4003,9 +4005,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/true);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/true);
 
 CodeGenTypes  = CGM.getTypes();
 llvm::FunctionType *MethodTy =
@@ -4059,9 +4060,8 @@
   } else {
 SmallString<256> Name;
 llvm::raw_svector_ostream OS(Name);
-const auto  = CGM.getContext().createMangleContext();
-MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
- /*includeCategoryNamespace=*/false);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+  /*includeCategoryNamespace=*/false);
 
 Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
 Name.str(), ());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88495: [clangd] Disable msan instrumentation for generated Evaluate().

2020-09-29 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 295005.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88495

Files:
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py


Index: clang-tools-extra/clangd/quality/CompletionModelCodegen.py
===
--- clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,9 @@
   friend float Evaluate(const %s&);
 };
 
+// The function may have large number of lines of code. MSAN
+// build times out in such case.
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s


Index: clang-tools-extra/clangd/quality/CompletionModelCodegen.py
===
--- clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,9 @@
   friend float Evaluate(const %s&);
 };
 
+// The function may have large number of lines of code. MSAN
+// build times out in such case.
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88359: [analyzer][RFC] Complete rewrite of ArrayBoundCheckerV2

2020-09-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:61
+
+  return NeedsExtraBitToPreserveSigness ? Signed : ExtendedSigned;
+}

Should not the `ExtendedSigned` be in the true branch?



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:87
+/// stored value.
+static APSInt absWithoutWrapping(const llvm::APSInt ) {
+  // If unsigned, we might need a sign bit.

I do not like these function names. `getCommonSignedTypeToFit`, 
`isRepresentableBySigned`, `getAbsWithoutWrapping` is better to have the common 
"start verbs" in the names.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:241
+  const APSInt )
+  : LastValidState(std::move(State)), SVB(SVB), RootSymbol(RootSymbol) {
+assert(LastValidState);

std::move is not needed here



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:269
+  /// Starts the simplification process.
+  SimplificationResult Simplify() {
+LLVM_DEBUG(llvm::dbgs() << __func__ << ": initially: '";

Function name should start with lower case.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:285
+   LastValidState->printJson(llvm::dbgs()); llvm::dbgs() << '\n';);
+return {std::move(LastValidState), std::move(LowerBound),
+std::move(UpperBound), SymbolVal(RootSymbol), 
SimplificationFailed};

The moves here are not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88359

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


[PATCH] D88495: [clangd] Disable msan instrumentation for generated Evaluate().

2020-09-29 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz accepted this revision.
adamcz added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:164
 
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);

Please add a comment here explaining why this is disabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88495

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


[PATCH] D88495: [clangd] Disable msan instrumentation for generated Evaluate().

2020-09-29 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added a reviewer: adamcz.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

MSAN build times out for generated DecisionForest inference runtime.

A solution worth trying is splitting the function into 300 smaller
functions and then re-enable msan.

For now we are disabling instrumentation for the generated function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88495

Files:
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py


Index: clang-tools-extra/clangd/quality/CompletionModelCodegen.py
===
--- clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,7 @@
   friend float Evaluate(const %s&);
 };
 
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s


Index: clang-tools-extra/clangd/quality/CompletionModelCodegen.py
===
--- clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -145,6 +145,7 @@
 return """#ifndef %s
 #define %s
 #include 
+#include "llvm/Support/Compiler.h"
 
 %s
 class %s {
@@ -160,6 +161,7 @@
   friend float Evaluate(const %s&);
 };
 
+LLVM_NO_SANITIZE("memory")
 float Evaluate(const %s&);
 %s
 #endif // %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88329: [objc] Consolidate ObjC name mangle code to AST

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

Oops, I meant to create a new commit rather than amend to this one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88329

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


[PATCH] D88329: [objc] Consolidate ObjC name mangle code to AST

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 295000.
ellis added a comment.

[objc] Fix memory leak in CGObjCMac.cpp

CGObjCMac.cpp was leaking a MangleContext everytime it mangled an ObjC method. 
We now have an instance variable that allocates and deallocates the context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88329

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGObjCMac.cpp

Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/Mangle.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/Basic/CodeGenOptions.h"
@@ -924,13 +925,6 @@
 
   llvm::StringMap NSConstantStringMap;
 
-  /// GetNameForMethod - Return a name for the given method.
-  /// \param[out] NameOut - The return value.
-  void GetNameForMethod(const ObjCMethodDecl *OMD,
-const ObjCContainerDecl *CD,
-SmallVectorImpl ,
-bool ignoreCategoryNamespace = false);
-
   /// GetMethodVarName - Return a unique constant for the given
   /// selector's name. The return value has type char *.
   llvm::Constant *GetMethodVarName(Selector Sel);
@@ -1086,7 +1080,7 @@
 
 public:
   CGObjCCommonMac(CodeGen::CodeGenModule ) :
-CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) { }
+CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()), Mangler(cgm.getContext().createMangleContext()) { }
 
   bool isNonFragileABI() const {
 return ObjCABI == 2;
@@ -1127,6 +1121,7 @@
 
 private:
   void fillRunSkipBlockVars(CodeGenModule , const CGBlockInfo );
+  std::unique_ptr Mangler;
 };
 
 namespace {
@@ -4008,7 +4003,9 @@
 Method = GenerateDirectMethod(OMD, CD);
   } else {
 SmallString<256> Name;
-GetNameForMethod(OMD, CD, Name);
+llvm::raw_svector_ostream OS(Name);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+ /*includeCategoryNamespace=*/true);
 
 CodeGenTypes  = CGM.getTypes();
 llvm::FunctionType *MethodTy =
@@ -4061,7 +4058,9 @@
 I->second = Fn;
   } else {
 SmallString<256> Name;
-GetNameForMethod(OMD, CD, Name, /*ignoreCategoryNamespace*/ true);
+llvm::raw_svector_ostream OS(Name);
+Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
+ /*includeCategoryNamespace=*/false);
 
 Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
 Name.str(), ());
@@ -5715,21 +5714,6 @@
   return GetPropertyName(().Idents.get(TypeStr));
 }
 
-void CGObjCCommonMac::GetNameForMethod(const ObjCMethodDecl *D,
-   const ObjCContainerDecl *CD,
-   SmallVectorImpl ,
-   bool ignoreCategoryNamespace) {
-  llvm::raw_svector_ostream OS(Name);
-  assert (CD && "Missing container decl in GetNameForMethod");
-  OS << '\01' << (D->isInstanceMethod() ? '-' : '+')
- << '[' << CD->getName();
-  if (!ignoreCategoryNamespace)
-if (const ObjCCategoryImplDecl *CID =
-dyn_cast(D->getDeclContext()))
-  OS << '(' << *CID << ')';
-  OS << ' ' << D->getSelector().getAsString() << ']';
-}
-
 void CGObjCMac::FinishModule() {
   EmitModuleInfo();
 
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -1323,7 +1323,7 @@
 }
 
 void MicrosoftCXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
-  Context.mangleObjCMethodName(MD, Out);
+  Context.mangleObjCMethodNameAsSourceName(MD, Out);
 }
 
 void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -175,7 +175,7 @@
   const TargetInfo  = Context.getTargetInfo();
   if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) {
 if (const ObjCMethodDecl *OMD = dyn_cast(D))
-  mangleObjCMethodName(OMD, Out);
+  mangleObjCMethodNameAsSourceName(OMD, Out);
 else
   mangleCXXName(GD, Out);
 return;
@@ -192,7 +192,7 @@
   if (!MCXX)
 Out << D->getIdentifier()->getName();
   else if (const ObjCMethodDecl *OMD = dyn_cast(D))
-mangleObjCMethodName(OMD, Out);
+mangleObjCMethodNameAsSourceName(OMD, Out);
   else
 mangleCXXName(GD, Out);
 
@@ -275,7 +275,7 @@
   SmallString<64> Buffer;
   llvm::raw_svector_ostream Stream(Buffer);

[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-29 Thread Axel Y. Rivera via Phabricator via cfe-commits
ayrivera added inline comments.



Comment at: lld/ELF/Driver.cpp:895
   const char *argv[] = {config->progName.data(), opt.data()};
+  cl::ResetAllOptionOccurrences();
   if (cl::ParseCommandLineOptions(2, argv, "", ))

aganea wrote:
> ayrivera wrote:
> > MaskRay wrote:
> > > ayrivera wrote:
> > > > Hi,
> > > > 
> > > > I built locally lld and came across an issue. The ELF driver isn't 
> > > > recognizing multiple -mllvm options. It only process the last -mllvm 
> > > > option that was entered in the command line. For example, I can add 
> > > > -mllvm -print-after-all -debug-pass=Arguments and it only prints the 
> > > > information from -debug-pass=Arguments, and not the IR and the debug 
> > > > data. If I swap the order, then the IR is printed and not the debug 
> > > > information.
> > > > 
> > > > I noticed that this change set added a call to 
> > > > cl:ResetAllOptionOccurrences() (line 895) inside parseClangOption. The 
> > > > function parseClangOption is called inside the loop that process the 
> > > > -mllvm options. If I comment this line, then everything works correctly 
> > > > and I can pass multiple -mllvm options through the command.
> > > > 
> > > > Is this an intended behavior or an actual issue? Thanks for your time.
> > > Hi,
> > > 
> > > > For example, I can add -mllvm -print-after-all -debug-pass=Arguments
> > > 
> > > You need two -mllvm, i.e. `-mllvm -print-after-all -mllvm 
> > > -debug-pass=Arguments`. And with the option, I see the print-after-all 
> > > dump.
> > Hi,
> > 
> > 
> > > You need two -mllvm, i.e. -mllvm -print-after-all -mllvm 
> > > -debug-pass=Arguments. And with the option, I see the print-after-all 
> > > dump.
> > 
> > 
> > Thanks for the quick reply. Sorry, this is a typo. I'm using both -mllvm 
> > and still got the issue.
> > Is this an intended behavior or an actual issue?
> At first sight, this is an actual issue. Normally, 
> `cl::ResetAllOptionOccurrences()` should be called only once per compiler or 
> linker instance, to reset the internal counters for the `cl::opt`s. I would 
> move it somewhere at the begining of `readConfigs()`. Can you try that see if 
> that solves your issue?
Hi @aganea ,

This patch https://reviews.llvm.org/D88461 , posted by @MaskRay , works. It 
does what you suggested. Thanks for the quick reply.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

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


[PATCH] D88491: [ASTContext] Use AllowCXX in all merge*Type methods, strip references

2020-09-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added a reviewer: aaron.ballman.
Herald added a subscriber: bollu.
Herald added a project: clang.
jdoerfert requested review of this revision.

Add and pass AllowCXX not only in mergeFunctionTypes but all merge*Type
methods. Use it to determine if reference types should be stripped or
are invalid in mergeTypes. The reason for this is that
mergeFunctionTypes allows CXX functions with exception specifiers but
crashes on reference types (in the return or argument position). This is
going to be used by D88384 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88491

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp

Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9179,13 +9179,15 @@
 /// QualType()
 QualType ASTContext::mergeTransparentUnionType(QualType T, QualType SubType,
bool OfBlockPointer,
-   bool Unqualified) {
+   bool Unqualified,
+   bool AllowCXX) {
   if (const RecordType *UT = T->getAsUnionType()) {
 RecordDecl *UD = UT->getDecl();
 if (UD->hasAttr()) {
   for (const auto *I : UD->fields()) {
 QualType ET = I->getType().getUnqualifiedType();
-QualType MT = mergeTypes(ET, SubType, OfBlockPointer, Unqualified);
+QualType MT = mergeTypes(ET, SubType, OfBlockPointer, Unqualified,
+ /* BlockReturnType */ false, AllowCXX);
 if (!MT.isNull())
   return MT;
   }
@@ -9199,21 +9201,23 @@
 /// parameter types
 QualType ASTContext::mergeFunctionParameterTypes(QualType lhs, QualType rhs,
  bool OfBlockPointer,
- bool Unqualified) {
+ bool Unqualified,
+ bool AllowCXX) {
   // GNU extension: two types are compatible if they appear as a function
   // argument, one of the types is a transparent union type and the other
   // type is compatible with a union member
   QualType lmerge = mergeTransparentUnionType(lhs, rhs, OfBlockPointer,
-  Unqualified);
+  Unqualified, AllowCXX);
   if (!lmerge.isNull())
 return lmerge;
 
   QualType rmerge = mergeTransparentUnionType(rhs, lhs, OfBlockPointer,
-  Unqualified);
+  Unqualified, AllowCXX);
   if (!rmerge.isNull())
 return rmerge;
 
-  return mergeTypes(lhs, rhs, OfBlockPointer, Unqualified);
+  return mergeTypes(lhs, rhs, OfBlockPointer, Unqualified,
+/* BlockReturnType */ false, AllowCXX);
 }
 
 QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
@@ -9234,11 +9238,11 @@
 bool UnqualifiedResult = Unqualified;
 if (!UnqualifiedResult)
   UnqualifiedResult = (!RHS.hasQualifiers() && LHS.hasQualifiers());
-retType = mergeTypes(LHS, RHS, true, UnqualifiedResult, true);
-  }
-  else
+retType = mergeTypes(LHS, RHS, true, UnqualifiedResult,
+ /* BlockReturnType */ true, AllowCXX);
+  } else
 retType = mergeTypes(lbase->getReturnType(), rbase->getReturnType(), false,
- Unqualified);
+ Unqualified, /* BlockReturnType */ false, AllowCXX);
   if (retType.isNull())
 return {};
 
@@ -9323,7 +9327,7 @@
   QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
   QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
   QualType paramType = mergeFunctionParameterTypes(
-  lParamType, rParamType, OfBlockPointer, Unqualified);
+  lParamType, rParamType, OfBlockPointer, Unqualified, AllowCXX);
   if (paramType.isNull())
 return {};
 
@@ -9416,9 +9420,18 @@
   return {};
 }
 
-QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
-bool OfBlockPointer,
-bool Unqualified, bool BlockReturnType) {
+QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer,
+bool Unqualified, bool BlockReturnType,
+bool AllowCXX) {
+  // If AllowCXX is specifically set we strip reference types on demand.
+  assert((AllowCXX ||
+  (!LHS->getAs() && !RHS->getAs())) &&
+ "C++ references should have been stripped");
+  if (const ReferenceType *lRT = LHS->getAs())
+LHS = lRT->getPointeeType();
+  if (const ReferenceType *rRT = RHS->getAs())
+RHS = 

[PATCH] D88434: [clangd] Improve PopulateSwitch tweak to work on non-empty switches

2020-09-29 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4fb303f340e2: [clangd] Improve PopulateSwitch tweak to work 
on non-empty switches (authored by tdeo, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88434

Files:
  clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2829,9 +2829,48 @@
   "unavailable",
   },
   {
-  // Existing enumerators in switch
+  // All enumerators already in switch (unscoped)
   Function,
-  R""(enum Enum {A}; ^switch ((Enum)0) {case A:break;})"",
+  R""(enum Enum {A,B}; ^switch (A) {case A:break;case B:break;})"",
+  "unavailable",
+  },
+  {
+  // All enumerators already in switch (scoped)
+  Function,
+  R""(
+enum class Enum {A,B};
+^switch (Enum::A) {case Enum::A:break;case Enum::B:break;}
+  )"",
+  "unavailable",
+  },
+  {
+  // Default case in switch
+  Function,
+  R""(
+enum class Enum {A,B};
+^switch (Enum::A) {default:break;}
+  )"",
+  "unavailable",
+  },
+  {
+  // GNU range in switch
+  Function,
+  R""(
+enum class Enum {A,B};
+^switch (Enum::A) {case Enum::A ... Enum::B:break;}
+  )"",
+  "unavailable",
+  },
+  {
+  // Value dependent case expression
+  File,
+  R""(
+enum class Enum {A,B};
+template
+void function() {
+^switch (Enum::A) {case Value:break;}
+}
+  )"",
   "unavailable",
   },
   {
@@ -2867,9 +2906,53 @@
   {
   // Scoped enumeration with multiple enumerators
   Function,
-  R""(enum class Enum {A,B}; ^switch (Enum::A) {})"",
-  R""(enum class Enum {A,B}; )""
-  R""(switch (Enum::A) {case Enum::A:case Enum::B:break;})"",
+  R""(
+enum class Enum {A,B};
+^switch (Enum::A) {}
+  )"",
+  R""(
+enum class Enum {A,B};
+switch (Enum::A) {case Enum::A:case Enum::B:break;}
+  )"",
+  },
+  {
+  // Only filling in missing enumerators (unscoped)
+  Function,
+  R""(
+enum Enum {A,B,C};
+^switch (A) {case B:break;}
+  )"",
+  R""(
+enum Enum {A,B,C};
+switch (A) {case B:break;case A:case C:break;}
+  )"",
+  },
+  {
+  // Only filling in missing enumerators,
+  // even when using integer literals
+  Function,
+  R""(
+enum Enum {A,B=1,C};
+^switch (A) {case 1:break;}
+  )"",
+  R""(
+enum Enum {A,B=1,C};
+switch (A) {case 1:break;case A:case C:break;}
+  )"",
+  },
+  {
+  // Only filling in missing enumerators (scoped)
+  Function,
+  R""(
+enum class Enum {A,B,C};
+^switch (Enum::A)
+{case Enum::B:break;}
+  )"",
+  R""(
+enum class Enum {A,B,C};
+switch (Enum::A)
+{case Enum::B:break;case Enum::A:case Enum::C:break;}
+  )"",
   },
   {
   // Scoped enumerations in namespace
Index: clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
@@ -33,12 +33,15 @@
 #include "AST.h"
 #include "Selection.h"
 #include "refactor/Tweak.h"
+#include "support/Logger.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/SmallSet.h"
+#include 
 #include 
 
 namespace clang {
@@ -52,18 +55,16 @@
   Intent intent() const override { return Refactor; }
 
 private:
-  ASTContext *ASTCtx = nullptr;
   const DeclContext *DeclCtx = nullptr;
   const SwitchStmt *Switch = nullptr;
   const CompoundStmt *Body = nullptr;
+  const EnumType *EnumT = nullptr;
   const EnumDecl *EnumD = nullptr;
 };
 
 REGISTER_TWEAK(PopulateSwitch)
 
 bool PopulateSwitch::prepare(const Selection ) {
-  ASTCtx = >getASTContext();
-
   const SelectionTree::Node *CA = Sel.ASTSelection.commonAncestor();
   if (!CA)
 

[clang-tools-extra] 4fb303f - [clangd] Improve PopulateSwitch tweak to work on non-empty switches

2020-09-29 Thread Sam McCall via cfe-commits

Author: Tadeo Kondrak
Date: 2020-09-29T16:37:51+02:00
New Revision: 4fb303f340e2c55783f9b0f3ed33fa2c36360acf

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

LOG: [clangd] Improve PopulateSwitch tweak to work on non-empty switches

Improve the recently-added PopulateSwitch tweak to work on non-empty switches.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
index e84a420f6218..753e8b4df826 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
@@ -33,12 +33,15 @@
 #include "AST.h"
 #include "Selection.h"
 #include "refactor/Tweak.h"
+#include "support/Logger.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/SmallSet.h"
+#include 
 #include 
 
 namespace clang {
@@ -52,18 +55,16 @@ class PopulateSwitch : public Tweak {
   Intent intent() const override { return Refactor; }
 
 private:
-  ASTContext *ASTCtx = nullptr;
   const DeclContext *DeclCtx = nullptr;
   const SwitchStmt *Switch = nullptr;
   const CompoundStmt *Body = nullptr;
+  const EnumType *EnumT = nullptr;
   const EnumDecl *EnumD = nullptr;
 };
 
 REGISTER_TWEAK(PopulateSwitch)
 
 bool PopulateSwitch::prepare(const Selection ) {
-  ASTCtx = >getASTContext();
-
   const SelectionTree::Node *CA = Sel.ASTSelection.commonAncestor();
   if (!CA)
 return false;
@@ -94,11 +95,6 @@ bool PopulateSwitch::prepare(const Selection ) {
   if (!Body)
 return false;
 
-  // Since we currently always insert all enumerators, don't suggest this tweak
-  // if the body is not empty.
-  if (!Body->body_empty())
-return false;
-
   const Expr *Cond = Switch->getCond();
   if (!Cond)
 return false;
@@ -106,7 +102,7 @@ bool PopulateSwitch::prepare(const Selection ) {
   // Ignore implicit casts, since enums implicitly cast to integer types.
   Cond = Cond->IgnoreParenImpCasts();
 
-  const EnumType *EnumT = Cond->getType()->getAsAdjusted();
+  EnumT = Cond->getType()->getAsAdjusted();
   if (!EnumT)
 return false;
 
@@ -114,21 +110,65 @@ bool PopulateSwitch::prepare(const Selection ) {
   if (!EnumD)
 return false;
 
-  // If there aren't any enumerators, there's nothing to insert.
-  if (EnumD->enumerator_begin() == EnumD->enumerator_end())
-return false;
+  // We trigger if there are fewer cases than enum values (and no case covers
+  // multiple values). This guarantees we'll have at least one case to insert.
+  // We don't yet determine what the cases are, as that means evaluating
+  // expressions.
+  auto I = EnumD->enumerator_begin();
+  auto E = EnumD->enumerator_end();
+
+  for (const SwitchCase *CaseList = Switch->getSwitchCaseList();
+   CaseList && I != E; CaseList = CaseList->getNextSwitchCase(), I++) {
+// Default likely intends to cover cases we'd insert.
+if (isa(CaseList))
+  return false;
+
+const CaseStmt *CS = cast(CaseList);
+// Case statement covers multiple values, so just counting doesn't work.
+if (CS->caseStmtIsGNURange())
+  return false;
 
-  return true;
+// Case expression is not a constant expression or is value-dependent,
+// so we may not be able to work out which cases are covered.
+const ConstantExpr *CE = dyn_cast(CS->getLHS());
+if (!CE || CE->isValueDependent())
+  return false;
+  }
+
+  // Only suggest tweak if we have more enumerators than cases.
+  return I != E;
 }
 
 Expected PopulateSwitch::apply(const Selection ) {
-  const SourceManager  = ASTCtx->getSourceManager();
+  ASTContext  = Sel.AST->getASTContext();
+
+  // Get the enum's integer width and signedness, for adjusting case literals.
+  unsigned EnumIntWidth = Ctx.getIntWidth(QualType(EnumT, 0));
+  bool EnumIsSigned = EnumT->isSignedIntegerOrEnumerationType();
+
+  llvm::SmallSet ExistingEnumerators;
+  for (const SwitchCase *CaseList = Switch->getSwitchCaseList(); CaseList;
+   CaseList = CaseList->getNextSwitchCase()) {
+const CaseStmt *CS = cast(CaseList);
+assert(!CS->caseStmtIsGNURange());
+const ConstantExpr *CE = cast(CS->getLHS());
+assert(!CE->isValueDependent());
+llvm::APSInt Val = CE->getResultAsAPSInt();
+Val = Val.extOrTrunc(EnumIntWidth);
+Val.setIsSigned(EnumIsSigned);
+ExistingEnumerators.insert(Val);
+  }
+
   SourceLocation 

[PATCH] D88489: [clangd] Mark code action as "preferred" if it's the sole quickfix action

2020-09-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: usaxena95.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88489

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test


Index: clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
===
--- clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
+++ clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
@@ -28,6 +28,7 @@
 # CHECK-NEXT:]
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
+# CHECK-NEXT:"isPreferred": true,
 # CHECK-NEXT:"kind": "quickfix",
 # CHECK-NEXT:"title": "change 'union' to 'struct'"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -952,6 +952,13 @@
   /// The diagnostics that this code action resolves.
   llvm::Optional> diagnostics;
 
+  /// Marks this as a preferred action. Preferred actions are used by the
+  /// `auto fix` command and can be targeted by keybindings.
+  /// A quick fix should be marked preferred if it properly addresses the
+  /// underlying error. A refactoring should be marked preferred if it is the
+  /// most reasonable choice of actions to take.
+  bool isPreferred = false;
+
   /// The workspace edit this code action performs.
   llvm::Optional edit;
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -740,6 +740,8 @@
 CodeAction["kind"] = *CA.kind;
   if (CA.diagnostics)
 CodeAction["diagnostics"] = llvm::json::Array(*CA.diagnostics);
+  if (CA.isPreferred)
+CodeAction["isPreferred"] = true;
   if (CA.edit)
 CodeAction["edit"] = *CA.edit;
   if (CA.command)
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -411,6 +411,8 @@
 Main.codeActions.emplace();
 for (const auto  : D.Fixes)
   Main.codeActions->push_back(toCodeAction(Fix, File));
+if (Main.codeActions->size() == 1)
+  Main.codeActions->front().isPreferred = true;
   }
   if (Opts.SendDiagnosticCategory && !D.Category.empty())
 Main.category = D.Category;
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1009,6 +1009,20 @@
 for (const auto  : *Tweaks)
   Actions.push_back(toCodeAction(T, File, Selection));
 
+// If there's exactly one quick-fix, call it "preferred".
+// We never consider refactorings etc as preferred.
+CodeAction *OnlyFix = nullptr;
+for (auto  : Actions) {
+  if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) {
+if (OnlyFix) {
+  OnlyFix->isPreferred = false;
+  break;
+}
+Action.isPreferred = true;
+OnlyFix = 
+  }
+}
+
 if (SupportsCodeAction)
   return Reply(llvm::json::Array(Actions));
 std::vector Commands;


Index: clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
===
--- clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
+++ clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
@@ -28,6 +28,7 @@
 # CHECK-NEXT:]
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
+# CHECK-NEXT:"isPreferred": true,
 # CHECK-NEXT:"kind": "quickfix",
 # CHECK-NEXT:"title": "change 'union' to 'struct'"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -952,6 +952,13 @@
   /// The diagnostics that this code action resolves.
   llvm::Optional> diagnostics;
 
+  /// Marks this as a preferred action. Preferred actions are used by the
+  /// `auto fix` command and can be targeted by keybindings.
+  /// A quick fix should be marked preferred if it properly addresses the
+  /// underlying error. A refactoring should be marked preferred if it is the
+ 

[PATCH] D88260: [NFC][FE] Replace TypeSize with StorageUnitSize

2020-09-29 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1749-1750
 
-// Otherwise, allocate just the number of bytes required to store
-// the bitfield.
+  // Otherwise, allocate just the number of bytes required to store
+  // the bitfield.
 } else {

nit: drive-by fix? 
I think we should move this block of comments into the else block.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1768-1770
+// Otherwise, bump the data size up to include the bitfield,
+// including padding up to char alignment, and then remember how
+// bits we didn't use.

nit: same as the above driver-by fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88260

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


  1   2   >