[PATCH] D101156: [Clang] Support a user-defined __dso_handle

2021-04-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

What's the crash exactly/  Is IRGen just unhappy about processing the user 
definition when we've generated a declaration with a different type?  Because 
we're already supposed to be being cautious about this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101156

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


[PATCH] D101097: [Sema] Don't set BlockDecl's DoesNotEscape bit If the block is being passed to a function taking a reference parameter

2021-04-28 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101097

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


[PATCH] D101389: [clang][CodeGen] Fix address space for sret

2021-04-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D101389#2724700 , @yaxunl wrote:

> In D101389#2724636 , @rjmccall 
> wrote:
>
>> I think this is intentional; requiring the indirect-result parameter to be 
>> in the alloca address space would prevent direct initialization of 
>> non-temporary memory, which is an important optimization in C++.
>
> You mean situations like this? https://godbolt.org/z/KnPs6znK8
>
> Address of a global variable is directly passed as the sret arg to the 
> function returning a struct, instead of creating a temporary struct variable 
> and passing its address as the sret arg?

That's one specific case of copy-elision, but there are others, e.g.: 
https://godbolt.org/z/boTeMseaM

I suppose you could disable general copy-elision.  But don't you have 
aggressive optimizations to strength-reduce generic pointer operations?


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

https://reviews.llvm.org/D101389

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


[PATCH] D101506: Support: Remove F_{None,Text,Append} compatibility synonyms, NFC

2021-04-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Perhaps split the migration part from the `OpenFlags` removal part. I thought 
about deleting the aliases too but refrained because I noticed our internal 
code base needs migration.
Since you propose this, I will start migration and hopefully can finish that 
next week so that you will not be blocked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101506

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


[PATCH] D97265: [clang] Allow clang-check to customize analyzer output file or dir name

2021-04-28 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

If this patch is OK, could you please commit it on my behalf (Ella Ma 
)?
Thx.
And I will continue working on the `-Xanalyzer` option for clang-check, as it 
is too complex when adding analyzer options via the `-extra-arg` option.


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

https://reviews.llvm.org/D97265

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


[PATCH] D101389: [clang][CodeGen] Fix address space for sret

2021-04-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D101389#2724636 , @rjmccall wrote:

> I think this is intentional; requiring the indirect-result parameter to be in 
> the alloca address space would prevent direct initialization of non-temporary 
> memory, which is an important optimization in C++.

You mean situations like this? https://godbolt.org/z/KnPs6znK8

Address of a global variable is directly passed as the sret arg to the function 
returning a struct, instead of creating a temporary struct variable and passing 
its address as the sret arg?

However, this is forbidden in CUDA/HIP: https://godbolt.org/z/1hjsrn9Tn

So can we assume sret arg is always in alloca addr space for CUDA/HIP?


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

https://reviews.llvm.org/D101389

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


[PATCH] D101389: [clang][CodeGen] Fix address space for sret

2021-04-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think this is intentional; requiring the indirect-result parameter to be in 
the alloca address space would prevent direct initialization of non-temporary 
memory, which is an important optimization in C++.


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

https://reviews.llvm.org/D101389

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


[PATCH] D101502: [ObjC][ARC] Don't enter the cleanup scope if the initializer expression isn't an ExprWithCleanups

2021-04-28 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.

Okay, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101502

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


[PATCH] D101491: [ASan] Rename `-fsanitize-address-destructor-kind=` to drop the `-kind` suffix.

2021-04-28 Thread Dan Liew via Phabricator via cfe-commits
delcypher updated this revision to Diff 341384.
delcypher added a comment.

Remove metavar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101491

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/asan-destructor-kind.cpp
  clang/test/Driver/darwin-asan-mkernel-kext.c
  clang/test/Driver/fsanitize-address-destructor-kind.c
  clang/test/Driver/fsanitize-address-destructor.c

Index: clang/test/Driver/fsanitize-address-destructor.c
===
--- clang/test/Driver/fsanitize-address-destructor.c
+++ clang/test/Driver/fsanitize-address-destructor.c
@@ -2,19 +2,19 @@
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address %s \
 // RUN:   -### 2>&1 | \
 // RUN:   FileCheck %s
-// CHECK-NOT: -fsanitize-address-destructor-kind
+// CHECK-NOT: -fsanitize-address-destructor
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=none %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=none %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-NONE-ARG %s
-// CHECK-NONE-ARG: "-fsanitize-address-destructor-kind=none"
+// CHECK-NONE-ARG: "-fsanitize-address-destructor=none"
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=global %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-GLOBAL-ARG %s
-// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor-kind=global"
+// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor=global"
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=bad_arg %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=bad_arg %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-INVALID-ARG %s
-// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
+// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor='
Index: clang/test/Driver/darwin-asan-mkernel-kext.c
===
--- clang/test/Driver/darwin-asan-mkernel-kext.c
+++ clang/test/Driver/darwin-asan-mkernel-kext.c
@@ -5,11 +5,11 @@
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
 // RUN:   -mkernel -### %s 2>&1 | FileCheck %s
 
-// CHECK: "-fsanitize-address-destructor-kind=none"
+// CHECK: "-fsanitize-address-destructor=none"
 
 // Check it's possible to override the driver's decision.
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
-// RUN:   -mkernel -### -fsanitize-address-destructor-kind=global %s 2>&1 | \
+// RUN:   -mkernel -### -fsanitize-address-destructor=global %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-OVERRIDE %s
 
-// CHECK-OVERRIDE: "-fsanitize-address-destructor-kind=global"
+// CHECK-OVERRIDE: "-fsanitize-address-destructor=global"
Index: clang/test/CodeGen/asan-destructor-kind.cpp
===
--- clang/test/CodeGen/asan-destructor-kind.cpp
+++ clang/test/CodeGen/asan-destructor-kind.cpp
@@ -1,9 +1,9 @@
 // Frontend rejects invalid option
 // RUN: not %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=bad_arg -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=bad_arg -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 %s 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-BAD-ARG
-// CHECK-BAD-ARG: invalid value 'bad_arg' in '-fsanitize-address-destructor-kind=bad_arg'
+// CHECK-BAD-ARG: invalid value 'bad_arg' in '-fsanitize-address-destructor=bad_arg'
 
 // Default is global dtor
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
@@ -16,12 +16,12 @@
 
 // Explictly ask for global dtor
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
 //
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
 
@@ -30,12 +30,12 @@
 
 // Explictly ask for no dtors
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=none -emit-llvm -o - \
 // 

[PATCH] D101490: [NFC] Rename SanitizeAddressDtorKind codegen opt to not have `Kind` suffix.

2021-04-28 Thread Dan Liew 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 rG1bbbcff99de8: [NFC] Rename SanitizeAddressDtorKind codegen 
opt to not have `Kind` suffix. (authored by delcypher).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101490

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -287,7 +287,7 @@
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
   bool UseOdrIndicator = CGOpts.SanitizeAddressUseOdrIndicator;
   bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
-  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtorKind();
+  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtor();
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
   PM.add(createModuleAddressSanitizerLegacyPassPass(
@@ -1150,7 +1150,7 @@
 bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
-CodeGenOpts.getSanitizeAddressDtorKind();
+CodeGenOpts.getSanitizeAddressDtor();
 MPM.addPass(RequireAnalysisPass());
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1548,7 +1548,7 @@
   Values<"none,global">,
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
-  MarshallingInfoEnum, "Global">;
+  MarshallingInfoEnum, "Global">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -219,7 +219,7 @@
 CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator 
globals
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
  ///< MemorySanitizer
-ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
+ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -287,7 +287,7 @@
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
   bool UseOdrIndicator = CGOpts.SanitizeAddressUseOdrIndicator;
   bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
-  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtorKind();
+  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtor();
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
   PM.add(createModuleAddressSanitizerLegacyPassPass(
@@ -1150,7 +1150,7 @@
 bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
-CodeGenOpts.getSanitizeAddressDtorKind();
+CodeGenOpts.getSanitizeAddressDtor();
 MPM.addPass(RequireAnalysisPass());
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1548,7 +1548,7 @@
   Values<"none,global">,
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
-  MarshallingInfoEnum, "Global">;
+  MarshallingInfoEnum, "Global">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for 

[clang] 1bbbcff - [NFC] Rename SanitizeAddressDtorKind codegen opt to not have `Kind` suffix.

2021-04-28 Thread Dan Liew via cfe-commits

Author: Dan Liew
Date: 2021-04-28T18:37:16-07:00
New Revision: 1bbbcff99de8e53b89146386bb2587ed4fc8e9cf

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

LOG: [NFC] Rename SanitizeAddressDtorKind codegen opt to not have `Kind` suffix.

This is post commit follow up based on discussions in
https://reviews.llvm.org/D101122.

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

(cherry picked from commit f4c7e82d1b21e637c4e0c53125b126c407d8bdbf)

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 68ebcc62ab2c..d30dca5b18da 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -219,7 +219,7 @@ CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< 
Enable linker dead st
 CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator 
globals
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
  ///< MemorySanitizer
-ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
+ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1b4dfe4b6d3b..eaebed597836 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1548,7 +1548,7 @@ def sanitize_address_destructor_kind_EQ
   Values<"none,global">,
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
-  MarshallingInfoEnum, "Global">;
+  MarshallingInfoEnum, "Global">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 844fe4c5c8f0..6df2d291384c 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -287,7 +287,7 @@ static void addAddressSanitizerPasses(const 
PassManagerBuilder ,
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
   bool UseOdrIndicator = CGOpts.SanitizeAddressUseOdrIndicator;
   bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
-  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtorKind();
+  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtor();
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
   PM.add(createModuleAddressSanitizerLegacyPassPass(
@@ -1150,7 +1150,7 @@ static void addSanitizers(const Triple ,
 bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
-CodeGenOpts.getSanitizeAddressDtorKind();
+CodeGenOpts.getSanitizeAddressDtor();
 MPM.addPass(RequireAnalysisPass());
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,



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


[PATCH] D101506: Support: Remove F_{None,Text,Append} compatibility synonyms, NFC

2021-04-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: zturner.
Herald added subscribers: dcaballe, cota, teijeong, rdzhabarov, tatianashp, 
bmahjour, msifontes, jurahul, Kayjukh, grosul1, jvesely, Joonsoo, liufengdb, 
aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, rriddle, 
mehdi_amini, hiraditya, arichardson, emaste.
Herald added a reviewer: MaskRay.
dexonsmith requested review of this revision.
Herald added subscribers: cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

Clean up compatibility spellings of `OF_{None,Text,Append}` missing the
initial `O` left behind by 1f67a3cba9b09636c56e2109d8a35ae96dc15782.
Seems better to use the canonical ones everywhere.

No functionality change here, just an API cleanup.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101506

Files:
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
  libclc/utils/prepare-builtins.cpp
  lld/ELF/Driver.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Analysis/CFGPrinter.cpp
  llvm/lib/Analysis/CallPrinter.cpp
  llvm/lib/Analysis/DDGPrinter.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  mlir/lib/Support/FileUtilities.cpp

Index: mlir/lib/Support/FileUtilities.cpp
===
--- mlir/lib/Support/FileUtilities.cpp
+++ mlir/lib/Support/FileUtilities.cpp
@@ -35,7 +35,7 @@
 mlir::openOutputFile(StringRef outputFilename, std::string *errorMessage) {
   std::error_code error;
   auto result = std::make_unique(outputFilename, error,
-   llvm::sys::fs::F_None);
+   llvm::sys::fs::OF_None);
   if (error) {
 if (errorMessage)
   *errorMessage = "cannot open output file '" + outputFilename.str() +
Index: llvm/tools/llvm-ml/llvm-ml.cpp
===
--- llvm/tools/llvm-ml/llvm-ml.cpp
+++ llvm/tools/llvm-ml/llvm-ml.cpp
@@ -96,7 +96,7 @@
 
 static std::unique_ptr GetOutputStream(StringRef Path) {
   std::error_code EC;
-  auto Out = std::make_unique(Path, EC, sys::fs::F_None);
+  auto Out = std::make_unique(Path, EC, sys::fs::OF_None);
   if (EC) {
 WithColor::error() << EC.message() << '\n';
 return nullptr;
Index: llvm/lib/Analysis/DDGPrinter.cpp
===
--- llvm/lib/Analysis/DDGPrinter.cpp
+++ llvm/lib/Analysis/DDGPrinter.cpp
@@ -42,7 +42,7 @@
   errs() << "Writing '" << Filename << "'...";
 
   std::error_code EC;
-  raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
+  raw_fd_ostream File(Filename, EC, sys::fs::OF_Text);
 
   if (!EC)
 // We only provide the constant verson of the DOTGraphTrait specialization,
Index: llvm/lib/Analysis/CallPrinter.cpp
===
--- llvm/lib/Analysis/CallPrinter.cpp
+++ llvm/lib/Analysis/CallPrinter.cpp
@@ -274,7 +274,7 @@
   errs() << "Writing '" << Filename << "'...";
 
   std::error_code EC;
-  raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
+  raw_fd_ostream File(Filename, EC, sys::fs::OF_Text);
 
   CallGraph CG(M);
   CallGraphDOTInfo CFGInfo(, , LookupBFI);
Index: llvm/lib/Analysis/CFGPrinter.cpp
===
--- llvm/lib/Analysis/CFGPrinter.cpp
+++ llvm/lib/Analysis/CFGPrinter.cpp
@@ -63,7 +63,7 @@
   errs() << "Writing '" << Filename << "'...";
 
   std::error_code EC;
-  raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
+  raw_fd_ostream File(Filename, EC, sys::fs::OF_Text);
 
   DOTFuncInfo CFGInfo(, BFI, BPI, MaxFreq);
   CFGInfo.setHeatColors(ShowHeatColors);
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -755,12 +755,10 @@
 
 enum OpenFlags : unsigned {
   OF_None = 0,
-  F_None = 0, // For compatibility
 
   /// The file should be opened in text mode on platforms like z/OS that make
   /// this distinction.
   OF_Text = 1,
-  F_Text = 1, // For compatibility
 
   /// The file should use a carriage linefeed '\r\n'. This flag should only be
   /// used with OF_Text. Only makes a difference on Windows.
@@ -773,7 +771,6 @@
 
   /// The file should be opened in append mode.
   OF_Append = 4,
-  F_Append = 4, // For compatibility
 
   /// Delete the file on close. Only makes a difference on windows.
   OF_Delete = 8,
Index: lld/ELF/Driver.cpp
===
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1690,7 +1690,7 @@
 // easily.
 static void writeDependencyFile() {
   std::error_code ec;
-  raw_fd_ostream os(config->dependencyFile, ec, sys::fs::F_None);
+  raw_fd_ostream os(config->dependencyFile, ec, sys::fs::OF_None);
   if (ec) {
 

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:28
+  std::string FullNameTrimmed;
+  int Count = 0;
+  for (const auto  : FullName) {

Can you add a comment explaining what this loops tries to do? Ideally, with a 
short example like `some_func --> ::some_func`



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:29
+  int Count = 0;
+  for (const auto  : FullName) {
+if (Character == '<') {

Eugene.Zelenko wrote:
> I'm not sure, but probably braces could be elided in `for` and `if else`.
-1 for removing braces in multi-statement loops



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:46
+} else if (FullNameTrimmedRef.endswith(Pattern) &&
+   FullNameTrimmedRef.drop_back(Pattern.size()).endswith("::")) {
+  return true;

Eugene.Zelenko wrote:
> I'm not sure, but probably braces could be elided.
-1



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:294
+  } else {
+if ((MakeCall ? MakeCall->getNumArgs() : CtorCall->getNumArgs()) == 0) {
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(

Can you pull this ternary expression into a variable so that it does not have 
to repeated when the diagnostic is emitted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D101503: [OpenMPIRBuilder] Add createOffloadMaptypes and createOffloadMapnames functions

2021-04-28 Thread Valentin Clement via Phabricator via cfe-commits
clementval created this revision.
clementval added reviewers: jdoerfert, kiranchandramohan.
Herald added subscribers: rriddle, guansong, hiraditya, yaxunl.
clementval requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, 
stephenneuendorffer.
Herald added projects: clang, LLVM.

Add function to create the offload_maptypes and the offload_mapnames globals. 
These two functions
are used in clang. They will be used in the Flang/MLIR lowering as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101503

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2095,6 +2095,33 @@
   return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
 }
 
+// Create the global variable holding the offload mappings information.
+GlobalVariable *
+OpenMPIRBuilder::createOffloadMaptypes(SmallVector ) {
+  llvm::Constant *MaptypesArrayInit =
+  llvm::ConstantDataArray::get(M.getContext(), Mappings);
+  auto *MaptypesArrayGlobal = new llvm::GlobalVariable(
+  M, MaptypesArrayInit->getType(),
+  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, MaptypesArrayInit,
+  "offload_maptypes");
+  MaptypesArrayGlobal->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+  return MaptypesArrayGlobal;
+}
+
+// Create the global variables holding the offload names information.
+GlobalVariable *
+OpenMPIRBuilder::createOffloadMapnames(SmallVector ) {
+  llvm::Constant *MapNamesArrayInit = llvm::ConstantArray::get(
+  llvm::ArrayType::get(
+  llvm::Type::getInt8Ty(M.getContext())->getPointerTo(), Names.size()),
+  Names);
+  auto *MapNamesArrayGlobal = new llvm::GlobalVariable(
+  M, MapNamesArrayInit->getType(),
+  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, MapNamesArrayInit,
+  "offload_mapnames");
+  return MapNamesArrayGlobal;
+}
+
 // Create all simple and struct types exposed by the runtime and remember
 // the llvm::PointerTypes of them for easy access later.
 void OpenMPIRBuilder::initializeTypes(Module ) {
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -615,6 +615,12 @@
   /// variables.
   StringMap, BumpPtrAllocator> InternalVars;
 
+  /// Create the global variable holding the offload mappings information.
+  GlobalVariable *createOffloadMaptypes(SmallVector );
+
+  /// Create the global variable holding the offload names information.
+  GlobalVariable *createOffloadMapnames(SmallVector );
+
 public:
   /// Generator for __kmpc_copyprivate
   ///
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9375,17 +9375,9 @@
 
 // The map types are always constant so we don't need to generate code to
 // fill arrays. Instead, we create an array constant.
-SmallVector Mapping(CombinedInfo.Types.size(), 0);
+SmallVector Mapping(CombinedInfo.Types.size(), 0);
 llvm::copy(CombinedInfo.Types, Mapping.begin());
-llvm::Constant *MapTypesArrayInit =
-llvm::ConstantDataArray::get(CGF.Builder.getContext(), Mapping);
-std::string MaptypesName =
-CGM.getOpenMPRuntime().getName({"offload_maptypes"});
-auto *MapTypesArrayGbl = new llvm::GlobalVariable(
-CGM.getModule(), MapTypesArrayInit->getType(),
-/*isConstant=*/true, llvm::GlobalValue::PrivateLinkage,
-MapTypesArrayInit, MaptypesName);
-MapTypesArrayGbl->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+auto *MapTypesArrayGbl = OMPBuilder.createOffloadMaptypes(Mapping);
 Info.MapTypesArray = MapTypesArrayGbl;
 
 // The information types are only built if there is debug information
@@ -9397,19 +9389,10 @@
   auto fillInfoMap = [&](MappableExprsHandler::MappingExprInfo ) {
 return emitMappingInformation(CGF, OMPBuilder, MapExpr);
   };
-  SmallVector InfoMap(CombinedInfo.Exprs.size());
+  SmallVector InfoMap(CombinedInfo.Exprs.size());
   llvm::transform(CombinedInfo.Exprs, InfoMap.begin(), fillInfoMap);
 
-  llvm::Constant *MapNamesArrayInit = llvm::ConstantArray::get(
-  llvm::ArrayType::get(
-  llvm::Type::getInt8Ty(CGF.Builder.getContext())->getPointerTo(),
-  CombinedInfo.Exprs.size()),
-  InfoMap);
-  auto *MapNamesArrayGbl = new llvm::GlobalVariable(
-  CGM.getModule(), MapNamesArrayInit->getType(),
-  /*isConstant=*/true, 

[PATCH] D101502: [ObjC][ARC] Don't enter the cleanup scope if the initializer expression isn't an ExprWithCleanups

2021-04-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, erik.pilkington.
ahatanak added a project: clang.
ahatanak requested review of this revision.

This patch fixes a bug where a temporary ObjC pointer is released before the 
end of the full expression.

This fixes PR50043.

rdar://77030453


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101502

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/CodeGenObjCXX/arc.mm


Index: clang/test/CodeGenObjCXX/arc.mm
===
--- clang/test/CodeGenObjCXX/arc.mm
+++ clang/test/CodeGenObjCXX/arc.mm
@@ -334,3 +334,17 @@
 // CHECK:  [[T0:%.*]] = load i8**, i8*** [[X]]
 // CHECK-NEXT: call void @llvm.objc.moveWeak(i8** [[Y]], i8** [[T0]])
 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[Y]])
+
+void test42() {
+  __attribute__((ns_returns_retained)) id test42_0();
+  id test42_1(id);
+  void test42_2(id &&);
+  test42_2(test42_1(test42_0()));
+}
+
+// Check that the pointer returned by test42_0 is released after the full 
expression.
+
+// CHECK-LABEL: define void @_Z6test42v()
+// CHECK: %[[CALL:.*]] = call i8* @_Z8test42_0v()
+// CHECK: call void @_Z8test42_2OU15__autoreleasingP11objc_object(
+// CHECK: call void @llvm.objc.release(i8* %[[CALL]])
Index: clang/test/CodeGenObjCXX/arc-blocks.mm
===
--- clang/test/CodeGenObjCXX/arc-blocks.mm
+++ clang/test/CodeGenObjCXX/arc-blocks.mm
@@ -204,10 +204,10 @@
 
 // Test that calls to @llvm.objc.retainBlock aren't emitted in some cases.
 
-namespace test_block_retain {
-  typedef void (^BlockTy)();
+typedef void (^BlockTy)();
+void foo1(id);
 
-  void foo1(id);
+namespace test_block_retain {
 
 // CHECK-LABEL: define{{.*}} void 
@_ZN17test_block_retain14initializationEP11objc_object(
 // CHECK-NOT: @llvm.objc.retainBlock(
@@ -320,4 +320,25 @@
 b1 = b0;
 ((BlockTy)b1)();
   }
-}
+  }
+
+  // Check that the block capture is released after the full expression.
+
+  // CHECK-LABEL: define void @_ZN13test_rval_ref4testEP11objc_object(
+  // CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8
+  // CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 5
+  // CHECK: %[[V1:.*]] = call i8* @llvm.objc.retain(
+  // CHECK: store i8* %[[V1]], i8** %[[BLOCK_CAPTURED]], align 8
+  // CHECK: invoke void 
@_ZN13test_rval_ref17callTemplateBlockEOU15__autoreleasingU13block_pointerFvvE(
+
+  // CHECK: call void @llvm.objc.storeStrong(i8** %[[BLOCK_CAPTURED]], i8* 
null)
+
+  namespace test_rval_ref {
+  void callTemplateBlock(BlockTy &);
+
+  void test(id str) {
+return callTemplateBlock(^void() {
+  foo1(str);
+});
+  }
+  }
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -772,9 +772,10 @@
 
   // If we're emitting a value with lifetime, we have to do the
   // initialization *before* we leave the cleanup scopes.
-  if (const ExprWithCleanups *EWC = dyn_cast(init))
-init = EWC->getSubExpr();
-  CodeGenFunction::RunCleanupsScope Scope(*this);
+  if (auto *EWC = dyn_cast(init)) {
+CodeGenFunction::RunCleanupsScope Scope(*this);
+return EmitScalarInit(EWC->getSubExpr(), D, lvalue, capturedByInit);
+  }
 
   // We have to maintain the illusion that the variable is
   // zero-initialized.  If the variable might be accessed in its


Index: clang/test/CodeGenObjCXX/arc.mm
===
--- clang/test/CodeGenObjCXX/arc.mm
+++ clang/test/CodeGenObjCXX/arc.mm
@@ -334,3 +334,17 @@
 // CHECK:  [[T0:%.*]] = load i8**, i8*** [[X]]
 // CHECK-NEXT: call void @llvm.objc.moveWeak(i8** [[Y]], i8** [[T0]])
 // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[Y]])
+
+void test42() {
+  __attribute__((ns_returns_retained)) id test42_0();
+  id test42_1(id);
+  void test42_2(id &&);
+  test42_2(test42_1(test42_0()));
+}
+
+// Check that the pointer returned by test42_0 is released after the full expression.
+
+// CHECK-LABEL: define void @_Z6test42v()
+// CHECK: %[[CALL:.*]] = call i8* @_Z8test42_0v()
+// CHECK: call void @_Z8test42_2OU15__autoreleasingP11objc_object(
+// CHECK: call void @llvm.objc.release(i8* %[[CALL]])
Index: clang/test/CodeGenObjCXX/arc-blocks.mm
===
--- clang/test/CodeGenObjCXX/arc-blocks.mm
+++ clang/test/CodeGenObjCXX/arc-blocks.mm
@@ -204,10 +204,10 @@
 
 // Test that calls to @llvm.objc.retainBlock aren't emitted in some cases.
 
-namespace test_block_retain {
-  typedef void (^BlockTy)();
+typedef void (^BlockTy)();
+void foo1(id);
 
-  void foo1(id);
+namespace 

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:29
+  int Count = 0;
+  for (const auto  : FullName) {
+if (Character == '<') {

I'm not sure, but probably braces could be elided in `for` and `if else`.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:46
+} else if (FullNameTrimmedRef.endswith(Pattern) &&
+   FullNameTrimmedRef.drop_back(Pattern.size()).endswith("::")) {
+  return true;

I'm not sure, but probably braces could be elided.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:57
+  clang::ast_matchers::internal::Matcher, InnerMatcher) {
+  if (Node.getNumArgs() == 0) {
+return false;

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:69
+AST_MATCHER(CXXMemberCallExpr, hasSameNumArgsAsDeclNumParams) {
+  if (Node.getMethodDecl()->isFunctionTemplateSpecialization()) {
+return Node.getNumArgs() == Node.getMethodDecl()

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:268
+  if (PushBackCall) {
+const auto *EmplacePrefix = MakeCall ? "emplace_back" : "emplace_back(";
+Diag << FixItHint::CreateReplacement(FunctionNameSourceRange,

It's not yours, but please fix it, since code was affected by your change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D100768: [Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1

2021-04-28 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100768

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


[PATCH] D101139: Create install targets for scan-build-py.

2021-04-28 Thread Yu Shan via Phabricator via cfe-commits
aabbaabb added a comment.

In D101139#2721880 , @phosek wrote:

> In D101139#2718112 , @aabbaabb 
> wrote:
>
>> In D101139#2718057 , @phosek wrote:
>>
>>> In D101139#2713530 , @aabbaabb 
>>> wrote:
>>>
 The python script assumes relative directory while finding things. For 
 example, for resources folder, it uses os.path.join(this_dir, 'resources') 
 in report.py, which means resource need to be in the same dir as 
 report.py. Similarly for the libscanbuild. it assumes the library is 
 always at one level up from bin folder. Installing them to different 
 directories would break the script.
>>>
>>> We could reorganize things to match the final layout, that's the strategy 
>>> that https://github.com/llvm/llvm-project/tree/main/clang/tools/scan-build 
>>> uses as well.
>>>
>>> In D101139#2713551 , @aabbaabb 
>>> wrote:
>>>
 libear is built dynamically at runtime from build_libear function in 
 libear/__init__.py which would be called by libscanbuild/analyze.py. It is 
 not built statically.
>>>
>>> Could we modify the code to avoid building libear at runtime and instead 
>>> build it with CMake. Is libear even needed when using compilation database?
>>
>> If i copy libscanbuild/resources to out/share/, libscanbuild to 
>> out/libscanbuild, bin/* to bin, then resources would be in a different 
>> layout than the original src. You mean modifying the original source and 
>> move libscanbuild/resources out to share/resources and update the code 
>> reference?
>
> Do we still keep the source in sync with 
> https://github.com/rizsotto/scan-build? I was under the impression that the 
> two codebases have already started diverging.
>
>> We are not using libear, we are only using analyze-build not scan-build. For 
>> our usage, I could define a target that only copies analyze-build, not 
>> scan-build. However, I am not sure whether this is appropriate. On the other 
>> hand, building libear statically might require significant change to the 
>> code.
>
> We may consider introducing a CMake option to control whether to include 
> libear or not (which would also control whether to include `scan-build` or 
> not).

Updated the layout and listed individual files.
It is not trivial to separate out scan-build with analyze-build since all the 
logic is in one python lib file. Furthermore, libear is compiled with the cc 
compiler that is supplied as an argument to the tool, so i cannot turn that 
into a prebuilt without a large refactor to the codebase. I added a comment 
listing the reason.


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

https://reviews.llvm.org/D101139

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


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank marked 3 inline comments as done.
nicovank added a comment.

Thank you for the feedback, I appreciate it! Let me know if there is any other 
I missed, AFAIK all `auto` uses introduced by me should be good now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D101139: Create install targets for scan-build-py.

2021-04-28 Thread Yu Shan via Phabricator via cfe-commits
aabbaabb updated this revision to Diff 341352.
aabbaabb edited the summary of this revision.

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

https://reviews.llvm.org/D101139

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/tools/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  clang/tools/scan-build-py/bin/analyze-build
  clang/tools/scan-build-py/bin/analyze-c++
  clang/tools/scan-build-py/bin/analyze-cc
  clang/tools/scan-build-py/bin/intercept-build
  clang/tools/scan-build-py/bin/intercept-c++
  clang/tools/scan-build-py/bin/intercept-cc
  clang/tools/scan-build-py/bin/scan-build
  clang/tools/scan-build-py/lib/libear/__init__.py
  clang/tools/scan-build-py/lib/libear/config.h.in
  clang/tools/scan-build-py/lib/libear/ear.c
  clang/tools/scan-build-py/lib/libscanbuild/__init__.py
  clang/tools/scan-build-py/lib/libscanbuild/analyze.py
  clang/tools/scan-build-py/lib/libscanbuild/arguments.py
  clang/tools/scan-build-py/lib/libscanbuild/clang.py
  clang/tools/scan-build-py/lib/libscanbuild/compilation.py
  clang/tools/scan-build-py/lib/libscanbuild/intercept.py
  clang/tools/scan-build-py/lib/libscanbuild/report.py
  clang/tools/scan-build-py/lib/libscanbuild/resources/scanview.css
  clang/tools/scan-build-py/lib/libscanbuild/resources/selectable.js
  clang/tools/scan-build-py/lib/libscanbuild/resources/sorttable.js
  clang/tools/scan-build-py/lib/libscanbuild/shell.py
  clang/tools/scan-build-py/libear/__init__.py
  clang/tools/scan-build-py/libear/config.h.in
  clang/tools/scan-build-py/libear/ear.c
  clang/tools/scan-build-py/libscanbuild/__init__.py
  clang/tools/scan-build-py/libscanbuild/analyze.py
  clang/tools/scan-build-py/libscanbuild/arguments.py
  clang/tools/scan-build-py/libscanbuild/clang.py
  clang/tools/scan-build-py/libscanbuild/compilation.py
  clang/tools/scan-build-py/libscanbuild/intercept.py
  clang/tools/scan-build-py/libscanbuild/report.py
  clang/tools/scan-build-py/libscanbuild/resources/scanview.css
  clang/tools/scan-build-py/libscanbuild/resources/selectable.js
  clang/tools/scan-build-py/libscanbuild/resources/sorttable.js
  clang/tools/scan-build-py/libscanbuild/shell.py

Index: clang/tools/scan-build-py/bin/scan-build
===
--- clang/tools/scan-build-py/bin/scan-build
+++ clang/tools/scan-build-py/bin/scan-build
@@ -8,7 +8,7 @@
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.dirname(this_dir))
+sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib'))
 
 from libscanbuild.analyze import scan_build
 
Index: clang/tools/scan-build-py/bin/intercept-cc
===
--- clang/tools/scan-build-py/bin/intercept-cc
+++ clang/tools/scan-build-py/bin/intercept-cc
@@ -7,7 +7,7 @@
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.dirname(this_dir))
+sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib'))
 
 from libscanbuild.intercept import intercept_compiler_wrapper
 sys.exit(intercept_compiler_wrapper())
Index: clang/tools/scan-build-py/bin/intercept-c++
===
--- clang/tools/scan-build-py/bin/intercept-c++
+++ clang/tools/scan-build-py/bin/intercept-c++
@@ -7,7 +7,7 @@
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.dirname(this_dir))
+sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib'))
 
 from libscanbuild.intercept import intercept_compiler_wrapper
 sys.exit(intercept_compiler_wrapper())
Index: clang/tools/scan-build-py/bin/intercept-build
===
--- clang/tools/scan-build-py/bin/intercept-build
+++ clang/tools/scan-build-py/bin/intercept-build
@@ -8,7 +8,7 @@
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.dirname(this_dir))
+sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib'))
 
 from libscanbuild.intercept import intercept_build
 
Index: clang/tools/scan-build-py/bin/analyze-cc
===
--- clang/tools/scan-build-py/bin/analyze-cc
+++ clang/tools/scan-build-py/bin/analyze-cc
@@ -7,7 +7,7 @@
 import sys
 import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.dirname(this_dir))
+sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib'))
 
 from libscanbuild.analyze import analyze_compiler_wrapper
 sys.exit(analyze_compiler_wrapper())
Index: clang/tools/scan-build-py/bin/analyze-c++
===
--- clang/tools/scan-build-py/bin/analyze-c++
+++ clang/tools/scan-build-py/bin/analyze-c++
@@ -7,7 +7,8 @@
 import sys
 import os.path
 this_dir = 

[PATCH] D97955: [clang-tidy] Refactor loop-convert to bring most of the checking into matchers

2021-04-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 341350.
njames93 added a comment.

Remove unnecessary test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97955

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h

Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
@@ -68,9 +68,6 @@
 const UsageResult ,
 RangeDescriptor );
 
-  bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes ,
- const ForStmt *Loop, LoopFixerKind FixerKind);
-
   StringRef getReverseFunction() const;
   StringRef getReverseHeader() const;
 
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -61,9 +61,8 @@
 static const char LoopNameReverseIterator[] = "forLoopReverseIterator";
 static const char LoopNamePseudoArray[] = "forLoopPseudoArray";
 static const char ConditionBoundName[] = "conditionBound";
+static const char ContainerMemberExpr[] = "containerMemberExpr";
 static const char InitVarName[] = "initVar";
-static const char BeginCallName[] = "beginCall";
-static const char EndCallName[] = "endCall";
 static const char EndVarName[] = "endVar";
 static const char DerefByValueResultName[] = "derefByValueResult";
 static const char DerefByRefResultName[] = "derefByRefResult";
@@ -119,6 +118,44 @@
   .bind(LoopNameArray);
 }
 
+namespace {
+AST_MATCHER(VarDecl, isCStyleInit) {
+  return Node.getInitStyle() == VarDecl::CInit;
+}
+
+AST_MATCHER(VarDecl, samePtrTypeAsBeginResult) {
+  QualType VarType = Node.getType().getCanonicalType();
+  if (!VarType->isPointerType())
+return true;
+  return Builder->removeBindings(
+  [&](const ast_matchers::internal::BoundNodesMap ) {
+const auto *BeginMember =
+Nodes.getNodeAs(ContainerMemberExpr);
+assert(BeginMember);
+QualType RetType = cast(BeginMember->getMemberDecl())
+   ->getReturnType()
+   .getCanonicalType();
+if (RetType->isPointerType())
+  return !Finder->getASTContext().hasSameUnqualifiedType(
+  VarType->getPointeeType(), RetType->getPointeeType());
+return false;
+  });
+}
+
+AST_MATCHER(MemberExpr, matchesBoundBeginContainer) {
+  return Builder->removeBindings(
+  [&](const ast_matchers::internal::BoundNodesMap ) {
+const auto *BeginMember =
+Nodes.getNodeAs(ContainerMemberExpr);
+assert(BeginMember);
+if (BeginMember->isArrow() != Node.isArrow())
+  return true;
+return !areSameExpr(>getASTContext(), BeginMember->getBase(),
+Node.getBase());
+  });
+}
+} // namespace
+
 /// The matcher used for iterator-based for loops.
 ///
 /// This matcher is more flexible than array-based loops. It will match
@@ -127,20 +164,34 @@
 ///
 /// \code
 ///   for (containerType::iterator it = container.begin(),
-///e = createIterator(); it != e; ++it) { ... }
+///e = container.end(); it != e; ++it) { ... }
 ///   for (containerType::iterator it = container.begin();
-///it != anotherContainer.end(); ++it) { ... }
+///it != container.end(); ++it) { ... }
 /// \endcode
 /// The following string identifiers are bound to the parts of the AST:
 ///   InitVarName: 'it' (as a VarDecl)
 ///   LoopName: The entire for loop (as a ForStmt)
+///   ContainerMemberExpr: 'container.begin' (as a MemberExpr)
 ///   In the first example only:
 /// EndVarName: 'e' (as a VarDecl)
-///   In the second example only:
-/// EndCallName: 'container.end()' (as a CXXMemberCallExpr)
 ///
 /// Client code will need to make sure that:
-///   - The two containers on which 'begin' and 'end' are called are the same.
+///   - 'it' is only accessed using the '*' or '->' operators.
+///   - The container's iterators would not be invalidated during the loop.
+///
+/// This will not match cases such as:
+/// \code
+///   for (containerType::iterator it = container.begin(),
+///e = differentContainer.end(); it != e; ++it) { ... }
+///   for (containerType::iterator it = container.begin(),
+///e = container.end(); it != f; ++it) { ... }
+///   for (containerType::iterator it = container.myBegin(),
+///e = container.myEnd(); it != e; ++it) { ... }
+///   for (containerType::iterator it = container.begin(),
+///e = container->end(); it != e; ++it) { ... }
+///   for 

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 341349.
nicovank added a comment.

Explicitely specify one more type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -26,55 +47,231 @@
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  void emplace_back(Args &&...args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void 

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mark fixed suggestions as done.




Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:248
 
+  const auto *Call = PushBackCall ? PushBackCall : EmplacyCall;
+

Please don't use auto unless type is spelled explicitly in same statement or 
iterator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 341342.
nicovank added a comment.

Fix a couple variable names and explicitely specify a couple types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -26,55 +47,231 @@
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  void emplace_back(Args &&...args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; 

[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-04-28 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 341338.
Ericson2314 added a comment.

Rebase, no changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

Files:
  clang/tools/scan-build/CMakeLists.txt
  libclc/CMakeLists.txt
  lldb/cmake/modules/FindLibEdit.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt

Index: openmp/runtime/src/CMakeLists.txt
===
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -319,7 +319,7 @@
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
   \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -331,7 +331,7 @@
 foreach(alias IN LISTS LIBOMP_ALIASES)
   install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
 endforeach()
   endif()
 endif()
Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -25,7 +25,7 @@
 intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_INCLUDEDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_BINDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,8 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
Index: 

[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-04-28 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> I would say if it is going to take longer than the end of the week to fix the 
> issue, it might be nice to have it reverted so that other people's builds 
> continue to work (I know a few people who build with full LTO in a two stage 
> configuration every week).

Definitely! If I cannot fix it in two days,  I'll revert the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D101344: [clang-format] Add `SpacesInAngles: Leave` option to keep spacing inside angle brackets as is.

2021-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101344

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


[PATCH] D101491: [ASan] Rename `-fsanitize-address-destructor-kind=` to drop the `-kind` suffix.

2021-04-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/docs/ClangCommandLineReference.rst:873
 
-.. option:: -fsanitize-address-destructor-kind=
+.. option:: -fsanitize-address-destructor=
 

 here is inconsistent with MetaVarName<""


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101491

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


[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2021-04-28 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb30521c28a4d: [analyzer] Wrong type cast occurs during 
pointer dereferencing after type… (authored by ASDenysPetrov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89055

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/casts.c
  clang/test/Analysis/string.c


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,20 @@
 strcpy(x, y); // no-warning
 }
 
+// PR37503
+void *get_void_ptr();
+char ***type_punned_ptr;
+void strcpy_no_assertion(char c) {
+  *(unsigned char **)type_punned_ptr = (unsigned char *)(get_void_ptr());
+  strcpy(**type_punned_ptr, ); // no-crash
+}
+
+// PR49007
+char f(char ***c, int *i) {
+  *(void **)c = i + 1;
+  return (**c)[0]; // no-crash
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -245,3 +245,8 @@
   return a * a;
 }
 
+void no_crash_reinterpret_char_as_uchar(char ***a, int *b) {
+  *(unsigned char **)a = (unsigned char *)b;
+  if (**a == 0) // no-crash
+;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -748,8 +748,8 @@
   // pointers as well.
   // FIXME: We really need a single good function to perform casts for us
   // correctly every time we need it.
+  const MemRegion *R = V.getRegion();
   if (CastTy->isPointerType() && !CastTy->isVoidPointerType()) {
-const MemRegion *R = V.getRegion();
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
@@ -758,6 +758,13 @@
   }
 }
   }
+  // Next fixes pointer dereference using type different from its initial
+  // one. See PR37503 and PR49007 for details.
+  if (const auto *ER = dyn_cast(R)) {
+R = StateMgr.getStoreManager().castRegion(ER, CastTy);
+return loc::MemRegionVal(R);
+  }
+
   return V;
 }
 


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,20 @@
 strcpy(x, y); // no-warning
 }
 
+// PR37503
+void *get_void_ptr();
+char ***type_punned_ptr;
+void strcpy_no_assertion(char c) {
+  *(unsigned char **)type_punned_ptr = (unsigned char *)(get_void_ptr());
+  strcpy(**type_punned_ptr, ); // no-crash
+}
+
+// PR49007
+char f(char ***c, int *i) {
+  *(void **)c = i + 1;
+  return (**c)[0]; // no-crash
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -245,3 +245,8 @@
   return a * a;
 }
 
+void no_crash_reinterpret_char_as_uchar(char ***a, int *b) {
+  *(unsigned char **)a = (unsigned char *)b;
+  if (**a == 0) // no-crash
+;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -748,8 +748,8 @@
   // pointers as well.
   // FIXME: We really need a single good function to perform casts for us
   // correctly every time we need it.
+  const MemRegion *R = V.getRegion();
   if (CastTy->isPointerType() && !CastTy->isVoidPointerType()) {
-const MemRegion *R = V.getRegion();
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
@@ -758,6 +758,13 @@
   }
 }
   }
+  // Next fixes pointer dereference using type different from its initial
+  // one. See PR37503 and PR49007 for details.
+  if (const auto *ER = dyn_cast(R)) {
+R = StateMgr.getStoreManager().castRegion(ER, CastTy);
+return loc::MemRegionVal(R);
+  }
+
   return V;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b30521c - [analyzer] Wrong type cast occurs during pointer dereferencing after type punning

2021-04-28 Thread Denys Petrov via cfe-commits

Author: Denys Petrov
Date: 2021-04-29T01:03:38+03:00
New Revision: b30521c28a4dc1b94d793385e4144ede5822b2c1

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

LOG: [analyzer] Wrong type cast occurs during pointer dereferencing after type 
punning

Summary: During pointer dereferencing CastRetrievedVal uses wrong type from the 
Store after type punning. Namely, the pointer casts to another type and then 
assigns with a value of one more another type. It produces NonLoc value when 
Loc is expected.

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

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/test/Analysis/casts.c
clang/test/Analysis/string.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index a49099384d2a..f376922754bf 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -748,8 +748,8 @@ SVal SValBuilder::evalCastSubKind(loc::MemRegionVal V, 
QualType CastTy,
   // pointers as well.
   // FIXME: We really need a single good function to perform casts for us
   // correctly every time we need it.
+  const MemRegion *R = V.getRegion();
   if (CastTy->isPointerType() && !CastTy->isVoidPointerType()) {
-const MemRegion *R = V.getRegion();
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
@@ -758,6 +758,13 @@ SVal SValBuilder::evalCastSubKind(loc::MemRegionVal V, 
QualType CastTy,
   }
 }
   }
+  // Next fixes pointer dereference using type 
diff erent from its initial
+  // one. See PR37503 and PR49007 for details.
+  if (const auto *ER = dyn_cast(R)) {
+R = StateMgr.getStoreManager().castRegion(ER, CastTy);
+return loc::MemRegionVal(R);
+  }
+
   return V;
 }
 

diff  --git a/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c
index ae7b84641b13..702e53a82f2e 100644
--- a/clang/test/Analysis/casts.c
+++ b/clang/test/Analysis/casts.c
@@ -245,3 +245,8 @@ double no_crash_reinterpret_double_as_sym_ptr(double a, 
void * b) {
   return a * a;
 }
 
+void no_crash_reinterpret_char_as_uchar(char ***a, int *b) {
+  *(unsigned char **)a = (unsigned char *)b;
+  if (**a == 0) // no-crash
+;
+}

diff  --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c
index debcea481adb..2bf34ca757e7 100644
--- a/clang/test/Analysis/string.c
+++ b/clang/test/Analysis/string.c
@@ -363,6 +363,20 @@ void strcpy_no_overflow(char *y) {
 strcpy(x, y); // no-warning
 }
 
+// PR37503
+void *get_void_ptr();
+char ***type_punned_ptr;
+void strcpy_no_assertion(char c) {
+  *(unsigned char **)type_punned_ptr = (unsigned char *)(get_void_ptr());
+  strcpy(**type_punned_ptr, ); // no-crash
+}
+
+// PR49007
+char f(char ***c, int *i) {
+  *(void **)c = i + 1;
+  return (**c)[0]; // no-crash
+}
+
 //===--===
 // stpcpy()
 //===--===



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


[PATCH] D101491: [ASan] Rename `-fsanitize-address-destructor-kind=` to drop the `-kind` suffix.

2021-04-28 Thread Dan Liew via Phabricator via cfe-commits
delcypher added a comment.

@jansvoboda11 Should I use the the alias feature so that the old 
`-fsanitize-address-destructor-kind` argument is still parsed? I'm not sure if 
it's worth it but if doing so is very simple and has a low maintenance burden 
we should probably do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101491

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


[clang-tools-extra] c3846bc - [clangd][NFC] Reserve storage when creating semantic token encoding.

2021-04-28 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-04-28T22:39:54+01:00
New Revision: c3846bcfe1cc6d6421a543757b5046ea841d4610

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

LOG: [clangd][NFC] Reserve storage when creating semantic token encoding.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 543239264909..71a89ccdc587 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1075,6 +1075,7 @@ llvm::json::Value toJSON(const FileStatus ) {
 constexpr unsigned SemanticTokenEncodingSize = 5;
 static llvm::json::Value encodeTokens(llvm::ArrayRef Toks) {
   llvm::json::Array Result;
+  Result.reserve(SemanticTokenEncodingSize * Toks.size());
   for (const auto  : Toks) {
 Result.push_back(Tok.deltaLine);
 Result.push_back(Tok.deltaStart);



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


[PATCH] D101461: [clangd][NFC] Reserve storage when creating semantic token encoding.

2021-04-28 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3846bcfe1cc: [clangd][NFC] Reserve storage when creating 
semantic token encoding. (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101461

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


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1075,6 +1075,7 @@
 constexpr unsigned SemanticTokenEncodingSize = 5;
 static llvm::json::Value encodeTokens(llvm::ArrayRef Toks) {
   llvm::json::Array Result;
+  Result.reserve(SemanticTokenEncodingSize * Toks.size());
   for (const auto  : Toks) {
 Result.push_back(Tok.deltaLine);
 Result.push_back(Tok.deltaStart);


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1075,6 +1075,7 @@
 constexpr unsigned SemanticTokenEncodingSize = 5;
 static llvm::json::Value encodeTokens(llvm::ArrayRef Toks) {
   llvm::json::Array Result;
+  Result.reserve(SemanticTokenEncodingSize * Toks.size());
   for (const auto  : Toks) {
 Result.push_back(Tok.deltaLine);
 Result.push_back(Tok.deltaStart);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-28 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:225-228
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturnMode,
+llvm::AsanDetectStackUseAfterReturnMode, 2,
+llvm::AsanDetectStackUseAfterReturnMode::Runtime
+) ///< Set detection mode for stack-use-after-return.

vitalybuka wrote:
> delcypher wrote:
> > vitalybuka wrote:
> > > vitalybuka wrote:
> > > > Mode->Kind to be consistent with the file
> > > I believe for consistency we need:
> > > 1. Var name (SanitizeAddressDetectStackUseAfterReturn) no Mode/Kind suffix
> > > 2. Enum type AsanDetectStackUseAfterReturnKind uses "kind"
> > > 3. Actual flag includes no "kind" 
> > > -fsanitize-address-detect-stack-use-after-return=
> > > 
> > > BTW. @delcypher  -fsanitize-address-destructor-kind was not consistent 
> > > with the rest of file, but I am not sure it's worth of fixing now.
> > > 
> > > 
> > @vitalybuka It's not too late to fix this because the 
> > `-fsanitize-address-destructor-kind=` flag hasn't been adopted yet AFAIK.
> > 
> > Am I right in understanding that what I landed doesn't match points 1 and 3 
> > above? If you can confirm that's what you'd like to be changed I can put up 
> > some patches to fix this.
> Correct
> I'd expect 
> 
> ```
> ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
> llvm::AsanDtorKind::Global)
> ```
> 
> and 
> 
> ```
> def sanitize_address_destructor_EQ
> : Joined<["-"], "fsanitize-address-destructor=">,
>   MetaVarName<"">,
>   Flags<[CC1Option]>,
>   HelpText<"Set destructor type used in ASan instrumentation">,
>   Group,
>   Values<"none,global">,
>   NormalizedValuesScope<"llvm::AsanDtorKind">,
>   NormalizedValues<["None", "Global"]>,
>   MarshallingInfoEnum, "Global">;
> ```
> 
> And one more thing, probably not very important, and matter of personal 
> preferences.
> Maybe we don't need MetaVarName<""> for both of these flags.
> Without MetaVarName documentation is going to be 
> -fsanitize-address-destructor= 
> MetaVarName just lets use to replace  with more common and specific 
> , .. etc.
> To me  is almost generic as , so why not to stick to default.
@vitalybuka I put up the following patches for review

https://reviews.llvm.org/D101490
https://reviews.llvm.org/D101491


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

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


[PATCH] D101491: [ASan] Rename `-fsanitize-address-destructor-kind=` to drop the `-kind` suffix.

2021-04-28 Thread Dan Liew via Phabricator via cfe-commits
delcypher created this revision.
delcypher added reviewers: vitalybuka, jansvoboda11.
Herald added a subscriber: dang.
delcypher requested review of this revision.
Herald added a project: clang.

Renaming the option is based on discussions in https://reviews.llvm.org/D101122.

It is normally not a good idea to rename driver flags but this flag is
new enough and obscure enough that it is very unlikely to have adopters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101491

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/asan-destructor-kind.cpp
  clang/test/Driver/darwin-asan-mkernel-kext.c
  clang/test/Driver/fsanitize-address-destructor-kind.c
  clang/test/Driver/fsanitize-address-destructor.c

Index: clang/test/Driver/fsanitize-address-destructor.c
===
--- clang/test/Driver/fsanitize-address-destructor.c
+++ clang/test/Driver/fsanitize-address-destructor.c
@@ -2,19 +2,19 @@
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address %s \
 // RUN:   -### 2>&1 | \
 // RUN:   FileCheck %s
-// CHECK-NOT: -fsanitize-address-destructor-kind
+// CHECK-NOT: -fsanitize-address-destructor
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=none %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=none %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-NONE-ARG %s
-// CHECK-NONE-ARG: "-fsanitize-address-destructor-kind=none"
+// CHECK-NONE-ARG: "-fsanitize-address-destructor=none"
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=global %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-GLOBAL-ARG %s
-// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor-kind=global"
+// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor=global"
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=bad_arg %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=bad_arg %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-INVALID-ARG %s
-// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
+// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor='
Index: clang/test/Driver/darwin-asan-mkernel-kext.c
===
--- clang/test/Driver/darwin-asan-mkernel-kext.c
+++ clang/test/Driver/darwin-asan-mkernel-kext.c
@@ -5,11 +5,11 @@
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
 // RUN:   -mkernel -### %s 2>&1 | FileCheck %s
 
-// CHECK: "-fsanitize-address-destructor-kind=none"
+// CHECK: "-fsanitize-address-destructor=none"
 
 // Check it's possible to override the driver's decision.
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
-// RUN:   -mkernel -### -fsanitize-address-destructor-kind=global %s 2>&1 | \
+// RUN:   -mkernel -### -fsanitize-address-destructor=global %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-OVERRIDE %s
 
-// CHECK-OVERRIDE: "-fsanitize-address-destructor-kind=global"
+// CHECK-OVERRIDE: "-fsanitize-address-destructor=global"
Index: clang/test/CodeGen/asan-destructor-kind.cpp
===
--- clang/test/CodeGen/asan-destructor-kind.cpp
+++ clang/test/CodeGen/asan-destructor-kind.cpp
@@ -1,9 +1,9 @@
 // Frontend rejects invalid option
 // RUN: not %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=bad_arg -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=bad_arg -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 %s 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-BAD-ARG
-// CHECK-BAD-ARG: invalid value 'bad_arg' in '-fsanitize-address-destructor-kind=bad_arg'
+// CHECK-BAD-ARG: invalid value 'bad_arg' in '-fsanitize-address-destructor=bad_arg'
 
 // Default is global dtor
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
@@ -16,12 +16,12 @@
 
 // Explictly ask for global dtor
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
 //
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
 // RUN:   FileCheck %s 

[PATCH] D101490: [NFC] Rename SanitizeAddressDtorKind codegen opt to not have `Kind` suffix.

2021-04-28 Thread Dan Liew via Phabricator via cfe-commits
delcypher created this revision.
delcypher added a reviewer: vitalybuka.
Herald added subscribers: dexonsmith, dang.
delcypher requested review of this revision.
Herald added a project: clang.

This is post commit follow up based on discussions in
https://reviews.llvm.org/D101122.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101490

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -287,7 +287,7 @@
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
   bool UseOdrIndicator = CGOpts.SanitizeAddressUseOdrIndicator;
   bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
-  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtorKind();
+  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtor();
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
   PM.add(createModuleAddressSanitizerLegacyPassPass(
@@ -1150,7 +1150,7 @@
 bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
-CodeGenOpts.getSanitizeAddressDtorKind();
+CodeGenOpts.getSanitizeAddressDtor();
 MPM.addPass(RequireAnalysisPass());
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1548,7 +1548,7 @@
   Values<"none,global">,
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
-  MarshallingInfoEnum, "Global">;
+  MarshallingInfoEnum, "Global">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -219,7 +219,7 @@
 CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator 
globals
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
  ///< MemorySanitizer
-ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
+ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -287,7 +287,7 @@
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
   bool UseOdrIndicator = CGOpts.SanitizeAddressUseOdrIndicator;
   bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
-  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtorKind();
+  llvm::AsanDtorKind DestructorKind = CGOpts.getSanitizeAddressDtor();
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
   PM.add(createModuleAddressSanitizerLegacyPassPass(
@@ -1150,7 +1150,7 @@
 bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
-CodeGenOpts.getSanitizeAddressDtorKind();
+CodeGenOpts.getSanitizeAddressDtor();
 MPM.addPass(RequireAnalysisPass());
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1548,7 +1548,7 @@
   Values<"none,global">,
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
-  MarshallingInfoEnum, "Global">;
+  MarshallingInfoEnum, "Global">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the 

[clang] ea12d77 - [libc++] Support per-target __config_site in per-target runtime build

2021-04-28 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-04-28T14:27:16-07:00
New Revision: ea12d779bc238c387511fe7462020f4ecf4a8246

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

LOG: [libc++] Support per-target __config_site in per-target runtime build

When using the per-target runtime build, it may be desirable to have
different __config_site headers for each target where all targets cannot
share a single configuration.

The layout used for libc++ headers after this change is:

```
include/
  c++/
v1/
  
  /
c++/
  v1/
__config_site
  /
c++/
  v1/
__config_site
  
```

This is the most optimal layout since it avoids duplication, the only
headers that's per-target is __config_site, all other headers are
shared across targets. This also means that we no need two
-isystem flags: one for the target-agnostic headers and one for
the target specific headers.

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

Added: 

clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/c++/v1/.keep

clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/c++/v1/.keep

clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/c++/v1/.keep

clang/test/Driver/Inputs/basic_linux_libcxx_tree/usr/include/x86_64-unknown-linux-gnu/c++/v1/.keep

clang/test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/x86_64-unknown-linux-gnu/c++/v2/.keep

clang/test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/x86_64-unknown-linux-gnu/c++/v2/.keep

Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/fuchsia.cpp
clang/test/Driver/linux-header-search.cpp
libcxx/CMakeLists.txt
libcxx/benchmarks/CMakeLists.txt
libcxx/include/CMakeLists.txt
libcxx/utils/libcxx/test/config.py
libcxxabi/test/libcxxabi/test/config.py

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6ee367ab4ecc6..cf562335e18e6 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -358,13 +358,31 @@ void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList 
,
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
+  const Driver  = getDriver();
+  std::string Target = getTripleString();
+
+  auto AddCXXIncludePath = [&](StringRef Path) {
+std::string Version = detectLibcxxVersion(Path);
+if (Version.empty())
+  return;
+
+// First add the per-target include path.
+SmallString<128> TargetDir(Path);
+llvm::sys::path::append(TargetDir, Target, "c++", Version);
+if (getVFS().exists(TargetDir))
+  addSystemInclude(DriverArgs, CC1Args, TargetDir);
+
+// Second add the generic one.
+SmallString<128> Dir(Path);
+llvm::sys::path::append(Dir, "c++", Version);
+addSystemInclude(DriverArgs, CC1Args, Dir);
+  };
+
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
-SmallString<128> P(getDriver().Dir);
+SmallString<128> P(D.Dir);
 llvm::sys::path::append(P, "..", "include");
-std::string Version = detectLibcxxVersion(P);
-llvm::sys::path::append(P, "c++", Version);
-addSystemInclude(DriverArgs, CC1Args, P.str());
+AddCXXIncludePath(P);
 break;
   }
 

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 53bba72dc270e..a27841dc5985e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2900,14 +2900,25 @@ void Generic_GCC::AddClangCXXStdlibIncludeArgs(const 
ArgList ,
 void
 Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const {
+  const Driver  = getDriver();
+  std::string SysRoot = computeSysRoot();
+  std::string Target = getTripleString();
+
   auto AddIncludePath = [&](std::string Path) {
 std::string Version = detectLibcxxVersion(Path);
-std::string IncludePath = Path + "/c++/" + Version;
-if (Version.empty() || !getVFS().exists(IncludePath))
+if (Version.empty())
   return false;
-addSystemInclude(DriverArgs, CC1Args, IncludePath);
+
+// First add the per-target include path if it exists.
+std::string TargetDir = Path + "/" + Target + "/c++/" + Version;
+if (D.getVFS().exists(TargetDir))
+  addSystemInclude(DriverArgs, CC1Args, TargetDir);
+
+// Second add the generic one.
+addSystemInclude(DriverArgs, CC1Args, Path + "/c++/" + Version);
 return true;
   };
+
   // Android never uses the libc++ headers installed alongside the toolchain,
   // which are generally incompatible with the NDK libraries anyway.
   if 

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:25
+  Names) {
+  const auto FullName = "::" + Node.getQualifiedNameAsString();
+

Please don't use auto unless type is spelled explicitly in same statement or 
iterator.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:39
+
+  const auto FullNameTrimmedRef = StringRef(FullNameTrimmed);
+

Please don't use auto unless type is spelled explicitly in same statement or 
iterator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

In D100581#2723801 , @xbolva00 wrote:

> 



> Yes, the best solution. Also consider to check gcc’s test-suite - if they 
> have this type of testcase, then this is wanted behaviour.

gcc has `Wunused-var-5.c`, where the warning `-Wunused-but-set-variable` is 
applied but

  void bar (int, ...);
  void f18 (void) { _Atomic int x = 0; int y = 3; bar (x = y); }

is not expected to trigger the warning, which does seem to imply this is 
intentional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

When this change returns, I'd like to see a different implementation strategy. 
Running a recursive AST visitation after the fact is generally not the right 
way to look for this kind of issue; adding an extra pass to speculatively hunt 
for each kind of warning we might want to issue is too expensive. Instead, I 
think we should do something simpler and cheaper, such as tracking, for each 
variable in scope, the number of potentially-evaluated non-assignment 
references to that variable. For example:

- in `DoMarkVarDeclReferenced`, increment a per-variable counter if the 
variable is a local and the reference is an odr-use
- in `IgnoredValueConversions`, if we're discarding a potentially-evaluated 
assignment or increment expression acting on a local variable, decrement the 
counter for that variable
- in `ActOnPopScope`, or perhaps in `DiagnoseUnusedDecl`, when we're diagnosing 
unused variables, also diagnose set-but-not-used variables (where the variable 
is marked as used but the counter is equal to zero)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-04-28 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@rsmith ping2...


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

https://reviews.llvm.org/D96033

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D100581#2723794 , @nickdesaulniers 
wrote:

> In D100581#2723789 , @mbenfield 
> wrote:
>
>> But gcc's behavior is to not trigger here so maybe following it is best.
>
> Perhaps file a bug against GCC to find whether that was intentional or a bug?

Yes, the best solution. Also consider to check gcc’s test-suite - if they have 
this type of testcase, then this is wanted behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D100581#2723789 , @mbenfield wrote:

> But gcc's behavior is to not trigger here so maybe following it is best.

Perhaps file a bug against GCC to find whether that was intentional or a bug?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

So it seems there are 3 issues here:

1. local variables declared extern should not trigger this warning. I'll fix 
this.

2. Should `x` in this code trigger the warning:

  int x;
  int y = (x = 0);

These are essentially the "false positives" reported in the Linux kernel. I 
find it questionable to consider these "false positives"; it seems to me that 
`x` is not really used. But gcc's behavior is to not trigger here so maybe 
following it is best.

3. If `x` above should not trigger the warning, it might be difficult to detect 
this case with an AST walk using the current data. Would it be acceptable to 
add a bit to `VarDecl` or `Decl` indicating whether it's ever //read// (not 
just referenced), which could then be set, maybe in `Sema::ActOnFinishFullExpr` 
? This would then prevent the need for the new AST walk altogether. (it seems 
gcc has such a bit)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D100581#2723709 , @aeubanks wrote:

> reverted
> regarding having a reviewer who is knowledgable in clang diagnostics, I 
> assumed that george.burgess.iv was knowledgable and was happy with the change 
> after his comments, perhaps I should have waited for an explicit LGTM

It's fine, there are always bugs everywhere, won't all be caught.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

reverted
regarding having a reviewer who is knowledgable in clang diagnostics, I assumed 
that george.burgess.iv was knowledgable and was happy with the change after his 
comments, perhaps I should have waited for an explicit LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101480: Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"

2021-04-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

https://reviews.llvm.org/rG6d8d1338629ceeaf6f56dc9eabc72e1a63f05169


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101480

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


[clang] 6d8d133 - Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"

2021-04-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-04-28T12:47:18-07:00
New Revision: 6d8d1338629ceeaf6f56dc9eabc72e1a63f05169

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

LOG: Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"

This reverts commit 9b0501abc7b515b740fb5ee929817442dd3029a5.

False positives reported in D100581.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/CodeGen/X86/x86_32-xsave.c
clang/test/CodeGen/X86/x86_64-xsave.c
clang/test/CodeGen/builtins-arm.c
clang/test/CodeGen/builtins-riscv.c
clang/test/FixIt/fixit.cpp
clang/test/Misc/warning-wall.c
clang/test/Sema/shift.c
clang/test/Sema/vector-gcc-compat.c
clang/test/SemaCXX/goto.cpp
clang/test/SemaCXX/shift.cpp
clang/test/SemaCXX/sizeless-1.cpp
clang/test/SemaObjC/foreach.m

Removed: 
clang/test/Sema/warn-unused-but-set-parameters.c
clang/test/Sema/warn-unused-but-set-variables.c
clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d4e670c7e7d5..3a7f18b60398b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -724,8 +724,6 @@ def UnusedMemberFunction : 
DiagGroup<"unused-member-function",
 def UnusedLabel : DiagGroup<"unused-label">;
 def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
 def UnusedParameter : DiagGroup<"unused-parameter">;
-def UnusedButSetParameter : DiagGroup<"unused-but-set-parameter">;
-def UnusedButSetVariable : DiagGroup<"unused-but-set-variable">;
 def UnusedResult : DiagGroup<"unused-result">;
 def PotentiallyEvaluatedExpression : 
DiagGroup<"potentially-evaluated-expression">;
 def UnevaluatedExpression : DiagGroup<"unevaluated-expression",
@@ -867,8 +865,7 @@ def Conversion : DiagGroup<"conversion",
  DiagCategory<"Value Conversion Issue">;
 
 def Unused : DiagGroup<"unused",
-   [UnusedArgument, UnusedButSetVariable,
-UnusedFunction, UnusedLabel,
+   [UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
 // UnusedTemplate, (clean-up libc++ before enabling)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
@@ -925,7 +922,6 @@ def Extra : DiagGroup<"extra", [
 SemiBeforeMethodBody,
 MissingMethodReturnType,
 SignCompare,
-UnusedButSetParameter,
 UnusedParameter,
 NullPointerArithmetic,
 EmptyInitStatement,

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 552a9d349e396..639565feb5766 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -310,12 +310,8 @@ def note_riscv_repeated_interrupt_attribute : Note<
   "repeated RISC-V 'interrupt' attribute is here">;
 def warn_unused_parameter : Warning<"unused parameter %0">,
   InGroup, DefaultIgnore;
-def warn_unused_but_set_parameter : Warning<"parameter %0 set but not used">,
-  InGroup, DefaultIgnore;
 def warn_unused_variable : Warning<"unused variable %0">,
   InGroup, DefaultIgnore;
-def warn_unused_but_set_variable : Warning<"variable %0 set but not used">,
-  InGroup, DefaultIgnore;
 def warn_unused_local_typedef : Warning<
   "unused %select{typedef|type alias}0 %1">,
   InGroup, DefaultIgnore;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index aeb05d758cae6..44f97c0d949f7 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2832,13 +2832,6 @@ class Sema final {
   /// ParmVarDecl pointers.
   void DiagnoseUnusedParameters(ArrayRef Parameters);
 
-  /// Diagnose any unused but set parameters in the given sequence of
-  /// ParmVarDecl pointers.
-  void DiagnoseUnusedButSetParameters(ArrayRef Parameters);
-
-  /// Diagnose any unused but set variables declared in this CompoundStmt
-  void DiagnoseUnusedButSetVariables(CompoundStmt *CS);
-
   /// Diagnose whether the size of parameters or return value of a
   /// function or obj-c method definition is pass-by-value and larger than a
   /// specified threshold.

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c5bc19f22153..f95bd7fe5634f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ 

[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D100581#2723621 , @Abpostelnicu 
wrote:

> In D100581#2723611 , @lebedev.ri 
> wrote:
>
>> In D100581#2723505 , @Abpostelnicu 
>> wrote:
>>
>>> Also I don’t remember seeing this proposed on cfe dev mailing list.
>>
>> There is no such requirement. I don't recall that happening basically ever, 
>> actually.
>
> Of course, but I would have wanted to see this discussed on the mailing list 
> since the pool of the affected actors by this is very big.

If we subtract the false-positives, i'm not really sure what should be 
discussed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101480: Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"

2021-04-28 Thread Andi via Phabricator via cfe-commits
Abpostelnicu accepted this revision.
Abpostelnicu added a comment.
This revision is now accepted and ready to land.

Thank you for this! Also I think it’s very well that you want to implement this 
warning in clang, with a little bit of more polish it will be up for merger!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101480

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In D100581#2723611 , @lebedev.ri 
wrote:

> In D100581#2723505 , @Abpostelnicu 
> wrote:
>
>> Also I don’t remember seeing this proposed on cfe dev mailing list.
>
> There is no such requirement. I don't recall that happening basically ever, 
> actually.

Of course, but I would have wanted to see this discussed on the mailing list 
since the pool of the affected actors by this is very big.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D100581#2723505 , @Abpostelnicu 
wrote:

> Also I don’t remember seeing this proposed on cfe dev mailing list.

There is no such requirement. I don't recall that happening basically ever, 
actually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

Link for the revert: https://reviews.llvm.org/D101480


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101480: Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"

2021-04-28 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield created this revision.
mbenfield added reviewers: aeubanks, george.burgess.iv, lebedev.ri, 
Abpostelnicu.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb.
mbenfield requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 9b0501abc7b515b740fb5ee929817442dd3029a5 
.

There are false positives in the linux kernel and other projects.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101480

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/X86/x86_32-xsave.c
  clang/test/CodeGen/X86/x86_64-xsave.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-riscv.c
  clang/test/FixIt/fixit.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/shift.c
  clang/test/Sema/vector-gcc-compat.c
  clang/test/Sema/warn-unused-but-set-parameters.c
  clang/test/Sema/warn-unused-but-set-variables.c
  clang/test/SemaCXX/goto.cpp
  clang/test/SemaCXX/shift.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
  clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
  clang/test/SemaObjC/foreach.m

Index: clang/test/SemaObjC/foreach.m
===
--- clang/test/SemaObjC/foreach.m
+++ clang/test/SemaObjC/foreach.m
@@ -1,4 +1,4 @@
-/* RUN: %clang_cc1 -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -fsyntax-only -verify -std=c89 -pedantic %s
+/* RUN: %clang_cc1 -Wall -fsyntax-only -verify -std=c89 -pedantic %s
  */
 
 @class NSArray;
Index: clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
===
--- clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-variable -verify %s
-
-struct S {
-  int i;
-};
-
-int f0() {
-  int y; // expected-warning{{variable 'y' set but not used}}
-  y = 0;
-
-  int z __attribute__((unused));
-  z = 0;
-
-  // In C++, don't warn for structs. (following gcc's behavior)
-  struct S s;
-  struct S t;
-  s = t;
-
-  int x;
-  x = 0;
-  return x + 5;
-}
-
-void f1(void) {
-  (void)^() {
-int y; // expected-warning{{variable 'y' set but not used}}
-y = 0;
-
-int x;
-x = 0;
-return x;
-  };
-}
-
-void f2() {
-  // Don't warn for either of these cases.
-  constexpr int x = 2;
-  const int y = 1;
-  char a[x];
-  char b[y];
-}
Index: clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
===
--- clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-parameter -verify %s
-
-int f0(int x,
-   int y, // expected-warning{{parameter 'y' set but not used}}
-   int z __attribute__((unused))) {
-  y = 0;
-  return x;
-}
-
-void f1(void) {
-  (void)^(int x,
-  int y, // expected-warning{{parameter 'y' set but not used}}
-  int z __attribute__((unused))) {
-y = 0;
-return x;
-  };
-}
-
-struct S {
-  int i;
-};
-
-// In C++, don't warn for a struct (following gcc).
-void f3(struct S s) {
-  struct S t;
-  s = t;
-}
-
-// Make sure this doesn't warn.
-struct A {
-  int i;
-  A(int j) : i(j) {}
-};
Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
+// RUN: 

[PATCH] D100772: [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-28 Thread Ryan Santhirarajan 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 rG0395f9e70b8f: [ARM] Neon Polynomial vadd Intrinsic fix 
(authored by rsanthir.quic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100772

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-poly-add.c

Index: clang/test/CodeGen/arm-poly-add.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-poly-add.c
@@ -0,0 +1,86 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi \
+// RUN:   -target-feature +neon \
+// RUN:   -mfloat-abi hard \
+// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \
+// RUN:  | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vadd_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <8 x i8> [[TMP0]]
+//
+poly8x8_t test_vadd_p8(poly8x8_t a, poly8x8_t b) {
+  return vadd_p8 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i16> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <4 x i16>
+// CHECK-NEXT:ret <4 x i16> [[TMP3]]
+//
+poly16x4_t test_vadd_p16(poly16x4_t a, poly16x4_t b) {
+  return vadd_p16 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <1 x i64> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <1 x i64>
+// CHECK-NEXT:ret <1 x i64> [[TMP3]]
+//
+poly64x1_t test_vadd_p64(poly64x1_t a, poly64x1_t b) {
+  return vadd_p64(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+poly8x16_t test_vaddq_p8(poly8x16_t a, poly8x16_t b){
+  return vaddq_p8(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i16> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP3]]
+//
+poly16x8_t test_vaddq_p16(poly16x8_t a, poly16x8_t b){
+  return vaddq_p16(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <2 x i64> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x i64> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
+// CHECK-NEXT:ret <2 x i64> [[TMP3]]
+//
+poly64x2_t test_vaddq_p64(poly64x2_t a, poly64x2_t b){
+  return vaddq_p64(a, b);
+}
+
+// TODO: poly128_t not implemented on aarch32
+// CHCK-LABEL: @test_vaddq_p128(
+// CHCK-NEXT:  entry:
+// CHCK-NEXT:[[TMP0:%.*]] = bitcast i128 [[A:%.*]] to <16 x i8>
+// CHCK-NEXT:[[TMP1:%.*]] = bitcast i128 [[B:%.*]] to <16 x i8>
+// CHCK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHCK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to i128
+// CHCK-NEXT:ret i128 [[TMP3]]
+//
+//poly128_t test_vaddq_p128 (poly128_t a, poly128_t b){
+//  return vaddq_p128(a, b);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5460,7 +5460,6 @@
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
   NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
   NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -708,6 +708,11 @@
 def SCALAR_HALF_GET_LANEQ : IOpInst<"vget_lane", "1.I", "Qh", OP_SCALAR_HALF_GET_LNQ>;
 def SCALAR_HALF_SET_LANEQ : IOpInst<"vset_lane", ".1.I", "Qh", OP_SCALAR_HALF_SET_LNQ>;
 
+
+// Non poly128_t vaddp for Arm and AArch64
+// TODO: poly128_t not implemented on arm32
+def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">;
+
 
 // 

[clang] 0395f9e - [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-28 Thread Ryan Santhirarajan via cfe-commits

Author: Ryan Santhirarajan
Date: 2021-04-28T11:59:40-07:00
New Revision: 0395f9e70b8f2dc55d3ef0bb7195c3542deffc5a

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

LOG: [ARM] Neon Polynomial vadd Intrinsic fix

The Neon vadd intrinsics were added to the ARMSIMD intrinsic map,
however due to being defined under an AArch64 guard in arm_neon.td,
were not previously useable on ARM. This change rectifies that.

It is important to note that poly128 is not valid on ARM, thus it was
extracted out of the original arm_neon.td definition and separated
for the sake of AArch64.

Reviewed By: DavidSpickett

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

Added: 
clang/test/CodeGen/arm-poly-add.c

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 0d97f0a1c2dc..fdd82692223c 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -708,6 +708,11 @@ def SCALAR_HALF_SET_LANE : IOpInst<"vset_lane", ".1.I", 
"h", OP_SCALAR_HALF_SET_
 def SCALAR_HALF_GET_LANEQ : IOpInst<"vget_lane", "1.I", "Qh", 
OP_SCALAR_HALF_GET_LNQ>;
 def SCALAR_HALF_SET_LANEQ : IOpInst<"vset_lane", ".1.I", "Qh", 
OP_SCALAR_HALF_SET_LNQ>;
 
+
+// Non poly128_t vaddp for Arm and AArch64
+// TODO: poly128_t not implemented on arm32
+def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">;
+
 

 // AArch64 Intrinsics
 
@@ -1171,7 +1176,9 @@ def SM4E : SInst<"vsm4e", "...", "QUi">;
 def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
 }
 
-def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPlQPk">;
+
+// poly128_t vadd for AArch64 only see VADDP for the rest
+def VADDP_Q   : WInst<"vadd", "...", "QPk">;
 
 

 // Float -> Int conversions with explicit rounding mode

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9681a8ad5cd3..8990cd825af3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5460,7 +5460,6 @@ static const ARMVectorIntrinsicInfo ARMSIMDIntrinsicMap 
[] = {
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
   NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
   NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),

diff  --git a/clang/test/CodeGen/arm-poly-add.c 
b/clang/test/CodeGen/arm-poly-add.c
new file mode 100644
index ..fe2afca00d47
--- /dev/null
+++ b/clang/test/CodeGen/arm-poly-add.c
@@ -0,0 +1,86 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi \
+// RUN:   -target-feature +neon \
+// RUN:   -mfloat-abi hard \
+// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \
+// RUN:  | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vadd_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <8 x i8> [[TMP0]]
+//
+poly8x8_t test_vadd_p8(poly8x8_t a, poly8x8_t b) {
+  return vadd_p8 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i16> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <4 x i16>
+// CHECK-NEXT:ret <4 x i16> [[TMP3]]
+//
+poly16x4_t test_vadd_p16(poly16x4_t a, poly16x4_t b) {
+  return vadd_p16 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <1 x i64> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <1 x i64>
+// CHECK-NEXT:ret <1 x i64> [[TMP3]]
+//
+poly64x1_t test_vadd_p64(poly64x1_t a, poly64x1_t b) {
+  return vadd_p64(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+poly8x16_t test_vaddq_p8(poly8x16_t a, poly8x16_t b){
+  return vaddq_p8(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i16> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> 

[PATCH] D99381: [compiler-rt][hwasan] Add Fuchsia-specific sanitizer platform limits

2021-04-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D99381#2721619 , @phosek wrote:

> What I think @vitalybuka meant is keeping 
> `sanitizer_platform_limits_fuchsia.h` as you had it, but including it 
> unconditionally. Since the entire file is wrapped in `#if SANITIZER_FUCHSIA 
> ... #endif`, the inclusion would be a no-op on platforms other than Fuchsia 
> so no need to wrap the `#include` in `#if SANITIZER_FUCHSIA` as well.

Correct., Just:

  #include "sanitizer_common/sanitizer_platform_limits_fuchsia.h"
  #include "sanitizer_common/sanitizer_platform_limits_posix.h"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99381

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-04-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 341280.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetCXXABI.def
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/cxx-abi-switch.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp

Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -0,0 +1,34 @@
+// These should succeed.
+// RUN: %clang -c -fc++-abi=itanium %s
+// RUN: %clang -c -fc++-abi=arm -target arm64 %s
+// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
+// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
+// RUN: %clang -c -fc++-abi=mips -target mips %s
+// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
+// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
+// RUN: %clang_cc1 -fc++-abi=itanium %s
+// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
+// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
+// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
+// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
+
+// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// INVALID: error: Invalid C++ ABI name 'InvalidABI'
+// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
+
+// The flag is propgated from the driver to cc1.
+// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s -check-prefix=CC1-FLAG
+// CC1-FLAG: -fc++-abi=InvalidABI
+
+// Some C++ ABIs are not supported on some platforms.
+// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
+// UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target triple 'i386'
Index: clang/test/CodeGenCXX/cxx-abi-switch.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx-abi-switch.cpp
@@ -0,0 +1,28 @@
+// Assert that the ABI switch uses the proper codegen. Fuchsia uses the
+// "return this" ABI on constructors and destructors by default, but if we
+// explicitly choose the generic itanium C++ ABI, we should not return "this" on
+// ctors/dtors.
+//
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-fuchsia -fc++-abi=itanium | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=aarch64-unknown-fuchsia -fc++-abi=itanium | FileCheck %s
+
+class A {
+public:
+  virtual ~A();
+  int x_;
+};
+
+class B : public A {
+public:
+  B(int *i);
+  virtual ~B();
+  int *i_;
+};
+
+B::B(int *i) : i_(i) {}
+B::~B() {}
+
+// CHECK: define{{.*}} void @_ZN1BC2EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BC1EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BD2Ev(%class.B* {{[^,]*}} %this)
+// CHECK: define{{.*}} void @_ZN1BD1Ev(%class.B* {{[^,]*}} %this)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3506,6 +3506,10 @@
   if (Opts.getSignReturnAddressKey() ==
   LangOptions::SignReturnAddressKeyKind::BKey)
 GenerateArg(Args, OPT_msign_return_address_key_EQ, "b_key", SA);
+
+  if (Opts.CXXABI)
+GenerateArg(Args, OPT_fcxx_abi_EQ, TargetCXXABI::getSpelling(*Opts.CXXABI),
+SA);
 }
 
 bool CompilerInvocation::ParseLangArgs(LangOptions , ArgList ,
@@ -3989,6 +3993,20 @@
 }
   }
 
+  // The value can be empty, which indicates the system default should be used.
+  StringRef CXXABI = Args.getLastArgValue(OPT_fcxx_abi_EQ);
+  if (!CXXABI.empty()) {
+if (!TargetCXXABI::isABI(CXXABI)) {
+  Diags.Report(diag::err_invalid_cxx_abi) << CXXABI;
+} else {
+  auto Kind = 

[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-04-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 341279.
leonardchan marked 3 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetCXXABI.def
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/cxx-abi-switch.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp

Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -0,0 +1,34 @@
+// These should succeed.
+// RUN: %clang -c -fc++-abi=itanium %s
+// RUN: %clang -c -fc++-abi=arm -target arm64 %s
+// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
+// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
+// RUN: %clang -c -fc++-abi=mips -target mips %s
+// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
+// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
+// RUN: %clang_cc1 -fc++-abi=itanium %s
+// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
+// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
+// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
+// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
+
+// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// INVALID: error: Invalid C++ ABI name 'InvalidABI'
+// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
+
+// The flag is propgated from the driver to cc1.
+// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s -check-prefix=CC1-FLAG
+// CC1-FLAG: -fc++-abi=InvalidABI
+
+// Some C++ ABIs are not supported on some platforms.
+// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
+// UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target triple 'i386'
Index: clang/test/CodeGenCXX/cxx-abi-switch.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx-abi-switch.cpp
@@ -0,0 +1,28 @@
+// Assert that the ABI switch uses the proper codegen. Fuchsia uses the
+// "return this" ABI on constructors and destructors by default, but if we
+// explicitly choose the generic itanium C++ ABI, we should not return "this" on
+// ctors/dtors.
+//
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-linux-gnu -fc++-abi=itanium | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=aarch64-unknown-linux-gnu -fc++-abi=itanium | FileCheck %s
+
+class A {
+public:
+  virtual ~A();
+  int x_;
+};
+
+class B : public A {
+public:
+  B(int *i);
+  virtual ~B();
+  int *i_;
+};
+
+B::B(int *i) : i_(i) {}
+B::~B() {}
+
+// CHECK: define{{.*}} void @_ZN1BC2EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BC1EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BD2Ev(%class.B* {{[^,]*}} %this)
+// CHECK: define{{.*}} void @_ZN1BD1Ev(%class.B* {{[^,]*}} %this)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3506,6 +3506,10 @@
   if (Opts.getSignReturnAddressKey() ==
   LangOptions::SignReturnAddressKeyKind::BKey)
 GenerateArg(Args, OPT_msign_return_address_key_EQ, "b_key", SA);
+
+  if (Opts.CXXABI)
+GenerateArg(Args, OPT_fcxx_abi_EQ, TargetCXXABI::getSpelling(*Opts.CXXABI),
+SA);
 }
 
 bool CompilerInvocation::ParseLangArgs(LangOptions , ArgList ,
@@ -3989,6 +3993,20 @@
 }
   }
 
+  // The value can be empty, which indicates the system default should be used.
+  StringRef CXXABI = Args.getLastArgValue(OPT_fcxx_abi_EQ);
+  if (!CXXABI.empty()) {
+if (!TargetCXXABI::isABI(CXXABI)) {
+  Diags.Report(diag::err_invalid_cxx_abi) << CXXABI;

[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-04-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: hans, rnk, thakis.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This implements support for using libc++ headers in MSVC toolchain.
We only support libc++ headers that are part of the toolchain, and
not headers installed elsewhere on the system.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101479

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/msvc-libcxx.cpp


Index: clang/test/Driver/msvc-libcxx.cpp
===
--- /dev/null
+++ clang/test/Driver/msvc-libcxx.cpp
@@ -0,0 +1,3 @@
+// RUN: %clangxx -target x86_64-pc-windows-msvc --stdlib=libc++ -### %s 2>&1 | 
FileCheck %s -check-prefix MSVC-LIBCXX
+
+// MSVC-LIBCXX: "-internal-isystem" 
"{{.*[/\\]}}include{{/|}}c++{{/|}}v1"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1323,7 +1323,34 @@
 
 void MSVCToolChain::AddClangCXXStdlibIncludeArgs(const ArgList ,
  ArgStringList ) const 
{
-  // FIXME: There should probably be logic here to find libc++ on Windows.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  DriverArgs.hasArg(options::OPT_nostdincxx))
+return;
+
+  const Driver  = getDriver();
+
+  auto AddLibcxxIncludePath = [&](StringRef Path) {
+std::string Version = detectLibcxxVersion(Path);
+if (Version.empty())
+  return;
+
+SmallString<128> Dir(Path);
+llvm::sys::path::append(Dir, "c++", Version);
+addSystemInclude(DriverArgs, CC1Args, Dir);
+  };
+
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx: {
+SmallString<128> P(D.Dir);
+llvm::sys::path::append(P, "..", "include");
+AddLibcxxIncludePath(P);
+break;
+  }
+
+  default:
+// TODO: Shall we report an error for other C++ standard libraries?
+break;
+  }
 }
 
 VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D,


Index: clang/test/Driver/msvc-libcxx.cpp
===
--- /dev/null
+++ clang/test/Driver/msvc-libcxx.cpp
@@ -0,0 +1,3 @@
+// RUN: %clangxx -target x86_64-pc-windows-msvc --stdlib=libc++ -### %s 2>&1 | FileCheck %s -check-prefix MSVC-LIBCXX
+
+// MSVC-LIBCXX: "-internal-isystem" "{{.*[/\\]}}include{{/|}}c++{{/|}}v1"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1323,7 +1323,34 @@
 
 void MSVCToolChain::AddClangCXXStdlibIncludeArgs(const ArgList ,
  ArgStringList ) const {
-  // FIXME: There should probably be logic here to find libc++ on Windows.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  DriverArgs.hasArg(options::OPT_nostdincxx))
+return;
+
+  const Driver  = getDriver();
+
+  auto AddLibcxxIncludePath = [&](StringRef Path) {
+std::string Version = detectLibcxxVersion(Path);
+if (Version.empty())
+  return;
+
+SmallString<128> Dir(Path);
+llvm::sys::path::append(Dir, "c++", Version);
+addSystemInclude(DriverArgs, CC1Args, Dir);
+  };
+
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx: {
+SmallString<128> P(D.Dir);
+llvm::sys::path::append(P, "..", "include");
+AddLibcxxIncludePath(P);
+break;
+  }
+
+  default:
+// TODO: Shall we report an error for other C++ standard libraries?
+break;
+  }
 }
 
 VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

Please revert this. This change hasn’t been tested nor reviewed enough. Also I 
don’t remember seeing this proposed on cfe dev mailing list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101344: [clang-format] Add `SpacesInAngles: Leave` option to keep spacing inside angle brackets as is.

2021-04-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

Looks good, and I'm always in favor of having a `Leave` Option. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101344

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

In D100581#2723348 , @lebedev.ri 
wrote:

> Also, from the reviewer list, it doesn't look like anyone with much 
> familiarity with clang/clang diags actually participated in the review?
> I think this might be the point to revert and re-review.

Alright, someone with the capability please revert if that's the correct action.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101209: [PowerPC] Provide fastmath sqrt and div functions in altivec.h

2021-04-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15130
+  Value *Y = EmitScalarExpr(E->getArg(1));
+  auto Ret = Builder.CreateFDiv(X, Y, "recipdiv");
+  Builder.setFastMathFlags(FMF);

bmahjour wrote:
> I wonder if we can do better than "fdiv fast"... does the current lowering of 
> "fdiv fast" employ an estimation algorithm via iterative refinement on POWER?
Yes. This `fast` includes `arcp` which will trigger the estimation+refinement 
algorithm in the back end.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15134
+}
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
+auto Ret = Builder.CreateCall(F, X);

bmahjour wrote:
> This doesn't implement a reciprocal square root, it just performs a square 
> root! At the very least we need a divide instruction following the call to 
> the intrinsic, but I'm not sure if that'll result in the most optimal codegen 
> at the end. Perhaps we need a new builtin?
Oh, I misread the documentation. This really seems like a bizarre thing to 
offer a user. I will change this to `1/sqrt()`.
In terms of providing optimal performance, with fast-math, the optimizer should 
get rid of the divide. If compiled at `-O0`, it isn't reasonable to expect 
optimal performance to begin with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101209

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:225-228
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturnMode,
+llvm::AsanDetectStackUseAfterReturnMode, 2,
+llvm::AsanDetectStackUseAfterReturnMode::Runtime
+) ///< Set detection mode for stack-use-after-return.

delcypher wrote:
> vitalybuka wrote:
> > vitalybuka wrote:
> > > Mode->Kind to be consistent with the file
> > I believe for consistency we need:
> > 1. Var name (SanitizeAddressDetectStackUseAfterReturn) no Mode/Kind suffix
> > 2. Enum type AsanDetectStackUseAfterReturnKind uses "kind"
> > 3. Actual flag includes no "kind" 
> > -fsanitize-address-detect-stack-use-after-return=
> > 
> > BTW. @delcypher  -fsanitize-address-destructor-kind was not consistent with 
> > the rest of file, but I am not sure it's worth of fixing now.
> > 
> > 
> @vitalybuka It's not too late to fix this because the 
> `-fsanitize-address-destructor-kind=` flag hasn't been adopted yet AFAIK.
> 
> Am I right in understanding that what I landed doesn't match points 1 and 3 
> above? If you can confirm that's what you'd like to be changed I can put up 
> some patches to fix this.
Correct
I'd expect 

```
ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
llvm::AsanDtorKind::Global)
```

and 

```
def sanitize_address_destructor_EQ
: Joined<["-"], "fsanitize-address-destructor=">,
  MetaVarName<"">,
  Flags<[CC1Option]>,
  HelpText<"Set destructor type used in ASan instrumentation">,
  Group,
  Values<"none,global">,
  NormalizedValuesScope<"llvm::AsanDtorKind">,
  NormalizedValues<["None", "Global"]>,
  MarshallingInfoEnum, "Global">;
```

And one more thing, probably not very important, and matter of personal 
preferences.
Maybe we don't need MetaVarName<""> for both of these flags.
Without MetaVarName documentation is going to be 
-fsanitize-address-destructor= 
MetaVarName just lets use to replace  with more common and specific 
, .. etc.
To me  is almost generic as , so why not to stick to default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Also, from the reviewer list, it doesn't look like anyone with much familiarity 
with clang/clang diags actually participated in the review?
I think this might be the point to revert and re-review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D100581#2723329 , @nathanchance 
wrote:

> In D100581#2721430 , 
> @nickdesaulniers wrote:
>
>> Huh, maybe not: https://godbolt.org/z/PnE1fMGWo
>
> This difference has caused some confusion already for the Linux kernel:

It's quite obviously used, since it's the condition variable for the loop.
Is clang CFG not modelling that correctly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

In D100581#2721430 , @nickdesaulniers 
wrote:

> Huh, maybe not: https://godbolt.org/z/PnE1fMGWo

This difference has caused some confusion already for the Linux kernel: 
https://lore.kernel.org/r/202104280827.lsczw8xg-...@intel.com

I am not sure it is appropriate to warn there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101389: [clang][CodeGen] Fix address space for sret

2021-04-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 341257.
yaxunl added a comment.

cast return value to default address space since it is expected. also fix debug 
info


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

https://reviews.llvm.org/D101389

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCUDA/amdgpu-sret.cu

Index: clang/test/CodeGenCUDA/amdgpu-sret.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-sret.cu
@@ -0,0 +1,101 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx906 \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s -debug-info-kind=limited \
+// RUN:   | FileCheck %s
+
+// Check no assertion with debug info.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx906 \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device \
+// RUN:   -S -o %t.s -x hip %s \
+// RUN:   -debug-info-kind=limited
+
+#include "Inputs/cuda.h"
+ 
+struct A {
+  int x[100];
+  __device__ A();
+};
+
+struct B {
+  int x[100];
+};
+
+__device__ B b;
+
+__device__ void callee(A *a);
+
+// CHECK-LABEL: @_Z5func1v(
+// CHECK-SAME: %struct.A addrspace(5)* noalias sret(%struct.A) align 4 %[[RET:.*]])
+// CHECK: %x = alloca [100 x i32], align 16, addrspace(5)
+// CHECK: %x.ascast = addrspacecast [100 x i32] addrspace(5)* %x to [100 x i32]*
+// CHECK: %p = alloca %struct.A*, align 8, addrspace(5)
+// CHECK: %p.ascast = addrspacecast %struct.A* addrspace(5)* %p to %struct.A**
+// CHECK: %[[RET_CAST:.*]] = addrspacecast %struct.A addrspace(5)* %[[RET]] to %struct.A*
+// CHECK: call void @llvm.dbg.declare(metadata %struct.A addrspace(5)* %[[RET]]
+// CHECK: call void @_ZN1AC1Ev(%struct.A* nonnull dereferenceable(400) %[[RET_CAST]])
+// CHECK: call void @llvm.dbg.declare(metadata [100 x i32] addrspace(5)* %x
+// CHECK: call void @_Z6calleeP1A(%struct.A* %[[RET_CAST]])
+// CHECK: %[[RET_CAST2:.*]] = bitcast %struct.A* %[[RET_CAST]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %[[RET_CAST2]], i8* align 16 %{{.*}}, i64 400, i1 false)
+// CHECK: call void @llvm.dbg.declare(metadata %struct.A* addrspace(5)* %p
+// CHECK: store %struct.A* %[[RET_CAST]], %struct.A** %p.ascast
+__device__ A func1() {
+  A a;
+  int x[100];
+  callee();
+  __builtin_memcpy(, x, 400);
+  A *p = 
+  return a;
+}
+
+// CHECK-LABEL: @_Z6func1av(%struct.B addrspace(5)* noalias sret(%struct.B) align 4 
+__device__ B func1a() {
+  B b;
+  return b;
+}
+
+// Check returning the return value again.
+
+// CHECK-LABEL: @_Z5func2v(
+// CHECK-SAME: %struct.A addrspace(5)* noalias sret(%struct.A) align 4 %[[RET:.*]])
+// CHECK: %[[CAST1:.*]] = addrspacecast %struct.A addrspace(5)* %[[RET]] to %struct.A*
+// CHECK: %[[CAST2:.*]] = addrspacecast %struct.A* %[[CAST1]] to %struct.A addrspace(5)*
+// CHECK: call void @_Z5func1v(%struct.A addrspace(5)* sret(%struct.A) align 4 %[[CAST2]])
+__device__ A func2() {
+  A a = func1();
+  return a;
+}
+
+// Check assigning the return value to a global variable.
+
+// CHECK-LABEL: @_Z5func3v(
+// CHECK: %[[RET:.*]] = alloca %struct.B, align 4, addrspace(5)
+// CHECK: %[[CAST1:.*]] = addrspacecast %struct.B addrspace(5)* %[[RET]] to %struct.B*
+// CHECK: %[[CAST2:.*]] = addrspacecast %struct.B* %[[CAST1]] to %struct.B addrspace(5)*
+// CHECK: call void @_Z6func1av(%struct.B addrspace(5)* sret(%struct.B) align 4 %[[CAST2]]
+// CHECK: %[[CAST3:.*]] = bitcast %struct.B* %[[CAST1]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64{{.*}}@b{{.*}}%[[CAST3]]
+__device__ void func3() {
+  b = func1a();
+}
+
+// Check assigning the return value to a temporary variable.
+
+// CHECK-LABEL: @_Z5func4v(
+// CHECK: %[[TMP:.*]] = alloca %struct.A, align 4, addrspace(5)
+// CHECK: %[[TMP_CAST1:.*]] = addrspacecast %struct.A addrspace(5)* %[[TMP]] to %struct.A*
+// CHECK: %[[RET:.*]] = alloca %struct.A, align 4, addrspace(5)
+// CHECK: %[[RET_CAST1:.*]] = addrspacecast %struct.A addrspace(5)* %[[RET]] to %struct.A*
+// CHECK: call void @_ZN1AC1Ev(%struct.A* nonnull dereferenceable(400) %[[TMP_CAST1]])
+// CHECK: %[[RET_CAST2:.*]] = addrspacecast %struct.A* %[[RET_CAST1]] to %struct.A addrspace(5)*
+// CHECK: call void @_Z5func1v(%struct.A addrspace(5)* sret(%struct.A) align 4 %[[RET_CAST2]]
+// CHECK: %[[TMP_CAST2:.*]] = bitcast %struct.A* %[[TMP_CAST1]] to i8*
+// CHECK: %[[RET_CAST3:.*]] = bitcast %struct.A* %[[RET_CAST1]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64{{.*}}%[[TMP_CAST2]]{{.*}}%[[RET_CAST3]]
+__device__ void func4() {
+  A a;
+  a = func1();
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1084,6 +1084,22 @@
 RetTy->isObjCRetainableType())
   

[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Dmitry Babokin via Phabricator via cfe-commits
dbabokin added a comment.

> Thanks for the report. It seems the thing to do is to modify the warning so 
> that variables marked extern are not candidates for this warning. I will make 
> a new commit with that modification unless there are other suggestions.

I agree, this seems to be the right fix. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-28 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added a comment.

In D100581#2721705 , @dbabokin wrote:

> One more false-positive:
>
>   void foo() {
> extern int yydebug;
> yydebug = 1;
>   }
>
> It was triggered in ISPC build.

Thanks for the report. It seems the thing to do is to modify the warning so 
that variables marked extern are not candidates for this warning. I will make a 
new commit with that modification unless there are other suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

2021-04-28 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:225-228
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturnMode,
+llvm::AsanDetectStackUseAfterReturnMode, 2,
+llvm::AsanDetectStackUseAfterReturnMode::Runtime
+) ///< Set detection mode for stack-use-after-return.

vitalybuka wrote:
> vitalybuka wrote:
> > Mode->Kind to be consistent with the file
> I believe for consistency we need:
> 1. Var name (SanitizeAddressDetectStackUseAfterReturn) no Mode/Kind suffix
> 2. Enum type AsanDetectStackUseAfterReturnKind uses "kind"
> 3. Actual flag includes no "kind" 
> -fsanitize-address-detect-stack-use-after-return=
> 
> BTW. @delcypher  -fsanitize-address-destructor-kind was not consistent with 
> the rest of file, but I am not sure it's worth of fixing now.
> 
> 
@vitalybuka It's not too late to fix this because the 
`-fsanitize-address-destructor-kind=` flag hasn't been adopted yet AFAIK.

Am I right in understanding that what I landed doesn't match points 1 and 3 
above? If you can confirm that's what you'd like to be changed I can put up 
some patches to fix this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101122

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


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

As you can see, this will fail some tests as there is one corner case which is 
tricky to handle:

  std::vector>> vec;
  // This is valid and should not be changed.
  vec.emplace_back(std::make_tuple(13, 31));

Does anyone have a suggestion for a good way to handle this?

Ideally, it would be nice to just check that the type of the temporary matches 
the type of the `value_type`, but I've tried that with a simple `==`, and it 
then becomes a problem with strings, where for example

  std::vector> vec;
  vec.emplace_back(std::make_pair("foo", "bar"));

would not be changed as it would list the pair as a `std::pair`, and not match with `std::pair`.
Is there some way that I couldn't find to check if two `clang::Types` are 
"compatible"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank created this revision.
nicovank added reviewers: alexfh, Prazek, kuhar.
nicovank added projects: clang, clang-tools-extra.
Herald added a subscriber: xazax.hun.
nicovank requested review of this revision.
Herald added a subscriber: cfe-commits.

modernize-use-emplace only recommends going from a push_back to an
emplace_back, but does not provide a recommendation when emplace_back is
improperly used. This adds the functionality of warning the user when
an unecessary temporary is created while calling emplace_back or other "emplacy"
functions from the STL containers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -26,55 +47,231 @@
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  void emplace_back(Args &&...args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  

[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-28 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 341244.
adamcz added a comment.

moved the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -std=c++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,10 @@
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
+   // expected-error {{use of undeclared identifier 
'typeof'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'var'}}
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +119,23 @@
 template const int k = f(T()); // expected-error {{no matching 
function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T );
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19661,8 +19661,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,7 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -std=c++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,10 @@
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
+   // expected-error {{use of undeclared identifier 'typeof'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'var'}}
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +119,23 @@
 template const int k = f(T()); // expected-error {{no matching function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T );
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11
Index: 

[PATCH] D101463: [clang] Make libBasic not depend on MC

2021-04-28 Thread Nico Weber 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 rG671f0e2e189c: [clang] Make libBasic not depend on MC 
(authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101463

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
  llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
  llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn

Index: llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn
+++ llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn
@@ -12,6 +12,7 @@
 "//clang/lib/Frontend/",
 "//clang/lib/Sema/",
 "//llvm/lib/IR",
+"//llvm/lib/MC",
   ]
   sources = [ "ClangFormat.cpp" ]
 }
Index: llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
@@ -25,6 +25,7 @@
 "//clang/lib/Edit",
 "//clang/lib/Lex",
 "//llvm/lib/Frontend/OpenMP",
+"//llvm/lib/MC",
 "//llvm/lib/Support",
   ]
   sources = [
Index: llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -49,7 +49,6 @@
 "//clang/include/clang/Sema:AttrParsedAttrKinds",
 "//clang/include/clang/Sema:AttrSpellingListIndex",
 "//llvm/include/llvm/Config:llvm-config",
-"//llvm/lib/MC",
 "//llvm/lib/Support",
   ]
   include_dirs = [ "." ]
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -40,6 +40,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Assumptions.h"
+#include "llvm/MC/MCSectionMachO.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
@@ -2985,9 +2986,29 @@
   return ::new (Context) SectionAttr(Context, CI, Name);
 }
 
+/// Used to implement to perform semantic checking on
+/// attribute((section("foo"))) specifiers.
+///
+/// In this case, "foo" is passed in to be checked.  If the section
+/// specifier is invalid, return an Error that indicates the problem.
+///
+/// This is a simple quality of implementation feature to catch errors
+/// and give good diagnostics in cases when the assembler or code generator
+/// would otherwise reject the section specifier.
+llvm::Error Sema::isValidSectionSpecifier(StringRef SecName) {
+  if (!Context.getTargetInfo().getTriple().isOSDarwin())
+return llvm::Error::success();
+
+  // Let MCSectionMachO validate this.
+  StringRef Segment, Section;
+  unsigned TAA, StubSize;
+  bool HasTAA;
+  return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
+ TAA, HasTAA, StubSize);
+}
+
 bool Sema::checkSectionName(SourceLocation LiteralLoc, StringRef SecName) {
-  if (llvm::Error E =
-  Context.getTargetInfo().isValidSectionSpecifier(SecName)) {
+  if (llvm::Error E = isValidSectionSpecifier(SecName)) {
 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
 << toString(std::move(E)) << 1 /*'section'*/;
 return false;
@@ -3021,8 +3042,7 @@
 // `#pragma code_seg("segname")` uses checkSectionName() instead.
 static bool checkCodeSegName(Sema , SourceLocation LiteralLoc,
  StringRef CodeSegName) {
-  if (llvm::Error E =
-  S.Context.getTargetInfo().isValidSectionSpecifier(CodeSegName)) {
+  if (llvm::Error E = S.isValidSectionSpecifier(CodeSegName)) {
 S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
 << toString(std::move(E)) << 0 /*'code-seg'*/;
 return false;
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -269,8 +269,10 @@
   AlignPackStack.Act(PragmaLoc, Action, StringRef(), Info);
 }
 
-void Sema::ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action,
-   

[clang] 671f0e2 - [clang] Make libBasic not depend on MC

2021-04-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-04-28T12:16:22-04:00
New Revision: 671f0e2e189c561512511331d95de382e2d6d15d

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

LOG: [clang] Make libBasic not depend on MC

Reduces numbers of files built for clang-format from 575 to 449.

Requires two small changes:

1. Don't use llvm::ExceptionHandling in LangOptions. This isn't
   even quite the right type since we don't use all of its values.
   Tweaks the changes made in:
   - https://reviews.llvm.org/D93215
   - https://reviews.llvm.org/D93216

2. Move section name validation code added (long ago) in commit 30ba67439 out
   of libBasic into Sema and base the check on the triple. This is a bit less
   OOP-y, but completely in line with what we do in many other places in Sema.

No behavior change.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/CMakeLists.txt
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDeclAttr.cpp
llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 39fdefc77fbee..5122770316cde 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -112,7 +112,7 @@ def err_fe_action_not_available : Error<
 def err_fe_invalid_alignment : Error<
 "invalid value '%1' in '%0'; alignment must be a power of 2">;
 def err_fe_invalid_exception_model
-   : Error<"invalid exception model 
'%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">;
+   : Error<"invalid exception model '%select{none|sjlj|seh|dwarf|wasm}0' for 
target '%1'">;
 def warn_fe_concepts_ts_flag : Warning<
   "-fconcepts-ts is deprecated - use '-std=c++20' for Concepts support">,
   InGroup;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index c898ef19a6cfd..85fe4af720235 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -23,7 +23,6 @@
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/MC/MCTargetOptions.h"
 #include 
 #include 
 
@@ -222,7 +221,7 @@ class LangOptions : public LangOptionsBase {
   };
 
   /// Possible exception handling behavior.
-  using ExceptionHandlingKind = llvm::ExceptionHandling;
+  enum class ExceptionHandlingKind { None, SjLj, WinEH, DwarfCFI, Wasm };
 
   enum class LaxVectorConversionKind {
 /// Permit no implicit vector bitcasts.
@@ -410,19 +409,19 @@ class LangOptions : public LangOptionsBase {
   }
 
   bool hasSjLjExceptions() const {
-return getExceptionHandling() == llvm::ExceptionHandling::SjLj;
+return getExceptionHandling() == ExceptionHandlingKind::SjLj;
   }
 
   bool hasSEHExceptions() const {
-return getExceptionHandling() == llvm::ExceptionHandling::WinEH;
+return getExceptionHandling() == ExceptionHandlingKind::WinEH;
   }
 
   bool hasDWARFExceptions() const {
-return getExceptionHandling() == llvm::ExceptionHandling::DwarfCFI;
+return getExceptionHandling() == ExceptionHandlingKind::DwarfCFI;
   }
 
   bool hasWasmExceptions() const {
-return getExceptionHandling() == llvm::ExceptionHandling::Wasm;
+return getExceptionHandling() == ExceptionHandlingKind::Wasm;
   }
 };
 

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 3300fe012aa81..532ff4554656c 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1147,21 +1147,6 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
 getTriple().getVendor() == llvm::Triple::SCEI);
   }
 
-  /// An optional hook that targets can implement to perform semantic
-  /// checking on attribute((section("foo"))) specifiers.
-  ///
-  /// In this case, "foo" is passed in to be checked.  If the section
-  /// specifier is invalid, the backend should return an Error that indicates
-  /// the problem.
-  ///
-  /// This hook is a simple quality of implementation feature to catch errors
-  /// and give good diagnostics in cases when the assembler or code generator
-  /// would otherwise reject the section specifier.
- 

[PATCH] D101426: [RISCV] Update subset naming convertion for the latest spec

2021-04-28 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:180
+  // as described in RISC-V User-Level ISA 20191213.
   SmallVector Split;
   Exts.split(Split, StringRef("_"));

If we want to update the arch string rules to ISA 20191213, should we also need 
to handle `Zicsr`, `Zifencei`, `Zam` and `Ztso`?



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:294
   // The canonical order specified in ISA manual.
   // Ref: Table 22.1 in RISC-V User-Level ISA V2.2
   StringRef StdExts = "mafdqlcbjtpvn";

nit: Table 27.1 in RISC-V User-Level ISA 20191213


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101426

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


[clang] 602c8b4 - [analyzer][NFC] Fix tests failing after a rebase

2021-04-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-04-28T18:55:20+03:00
New Revision: 602c8b4db5dbe88be7080b411455538c9b4cd117

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

LOG: [analyzer][NFC] Fix tests failing after a rebase

Added: 


Modified: 
clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist

Removed: 




diff  --git 
a/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist 
b/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
index fb92943d00dc..e9f4f7577649 100644
--- 
a/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
+++ 
b/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
@@ -6561,12 +6561,12 @@
 start
  
   
-   line381
+   line391
col3
file0
   
   
-   line381
+   line391
col4
file0
   
@@ -6574,12 +6574,12 @@
 end
  
   
-   line381
+   line391
col17
file0
   
   
-   line381
+   line391
col17
file0
   
@@ -6591,7 +6591,7 @@
  kindevent
  location
  
-  line381
+  line391
   col17
   file0
  
@@ -6599,12 +6599,12 @@
  

 
- line381
+ line391
  col17
  file0
 
 
- line381
+ line391
  col37
  file0
 
@@ -6731,7 +6731,7 @@
  kindevent
  location
  
-  line381
+  line391
   col17
   file0
  
@@ -6739,12 +6739,12 @@
  

 
- line381
+ line391
  col17
  file0
 
 
- line381
+ line391
  col37
  file0
 
@@ -6764,12 +6764,12 @@
 start
  
   
-   line381
+   line391
col17
file0
   
   
-   line381
+   line391
col17
file0
   
@@ -6777,12 +6777,12 @@
 end
  
   
-   line381
+   line391
col3
file0
   
   
-   line381
+   line391
col4
file0
   
@@ -6798,12 +6798,12 @@
 start
  
   
-   line381
+   line391
col3
file0
   
   
-   line381
+   line391
col4
file0
   
@@ -6811,12 +6811,12 @@
 end
  
   
-   line385
+   line395
col3
file0
   
   
-   line385
+   line395
col3
file0
   
@@ -6828,7 +6828,7 @@
  kindevent
  location
  
-  line385
+  line395
   col3
   file0
  
@@ -6836,12 +6836,12 @@
  

 
- line385
+ line395
  col3
  file0
 
 
- line385
+ line395
  col20
  file0
 
@@ -6865,7 +6865,7 @@
   issue_hash_function_offset1
   location
   
-   line385
+   line395
col3
file0
   
@@ -6879,10 +6879,10 @@
 219
 220
 221
-380
-381
-384
-385
+390
+391
+394
+395

   
   
@@ -6897,12 +6897,12 @@
 start
  
   
-   line390
+   line400
col3
file0
   
   
-   line390
+   line400
col4
file0
   
@@ -6910,12 +6910,12 @@
 end
  
   
-   line390
+   line400
col17
file0
   
   
-   line390
+   line400
col17
file0
   
@@ -6927,7 +6927,7 @@
  kindevent
  location
  
-  line390
+  line400
   col17
   file0
  
@@ -6935,12 +6935,12 @@
  

 
- line390
+ line400
  col17
  file0
 
 
- line390
+ line400
  col37
  file0
 
@@ -7067,7 +7067,7 @@
  kindevent
  location
  
-  line390
+  line400
   col17
   file0
  
@@ -7075,12 +7075,12 @@
  

 
- line390
+ line400
  col17
  file0
 
 
- line390
+ line400
  col37
  file0
 
@@ -7100,12 +7100,12 @@
 start
  
   
-   line390
+   line400
col17

[PATCH] D101209: [PowerPC] Provide fastmath sqrt and div functions in altivec.h

2021-04-28 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour requested changes to this revision.
bmahjour added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15130
+  Value *Y = EmitScalarExpr(E->getArg(1));
+  auto Ret = Builder.CreateFDiv(X, Y, "recipdiv");
+  Builder.setFastMathFlags(FMF);

I wonder if we can do better than "fdiv fast"... does the current lowering of 
"fdiv fast" employ an estimation algorithm via iterative refinement on POWER?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15134
+}
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
+auto Ret = Builder.CreateCall(F, X);

This doesn't implement a reciprocal square root, it just performs a square 
root! At the very least we need a divide instruction following the call to the 
intrinsic, but I'm not sure if that'll result in the most optimal codegen at 
the end. Perhaps we need a new builtin?



Comment at: clang/test/CodeGen/builtins-ppc-vsx.c:2297
+  // CHECK-LABEL: test_rsqrtd
+  // CHECK: call fast <2 x double> @llvm.sqrt.v2f64
+  // CHECK-LE-LABEL: test_rsqrtd

See my comment above about the missing reciprocal operation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101209

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


[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab5823867c4a: [analyzer] Find better description for tracked 
symbolic values (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/diagnostics/deref-track-symbolic-region.cpp
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp

Index: clang/test/Analysis/uninit-const.cpp
===
--- clang/test/Analysis/uninit-const.cpp
+++ clang/test/Analysis/uninit-const.cpp
@@ -63,7 +63,7 @@
 }
 
 void f6_1(void) {
-  int t; // expected-note{{'t' declared without an initial value}}
+  int t;   // expected-note{{'t' declared without an initial value}}
   int p = f6_1_sub(t); //expected-warning {{Assigned value is garbage or undefined}}
//expected-note@-1 {{Passing value via 1st parameter 'p'}}
//expected-note@-2 {{Calling 'f6_1_sub'}}
@@ -76,8 +76,8 @@
 void f6_2(void) {
   int t;   //expected-note {{'t' declared without an initial value}}
   int  = t;  //expected-note {{'p' initialized here}}
-  int  = p;  //expected-note {{'s' initialized here}}
-  int  = s;  //expected-note {{'q' initialized here}}
+  int  = p;  //expected-note {{'s' initialized to the value of 'p'}}
+  int  = s;  //expected-note {{'q' initialized to the value of 's'}}
   doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
//expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
Index: clang/test/Analysis/uninit-const.c
===
--- clang/test/Analysis/uninit-const.c
+++ clang/test/Analysis/uninit-const.c
@@ -37,7 +37,7 @@
 void f_1_1(void) {
   int t; // expected-note {{'t' declared without an initial value}}
   int *tp1 =  // expected-note {{'tp1' initialized here}}
-  int* tp2 = tp1;// expected-note {{'tp2' initialized here}}
+  int *tp2 = tp1;// expected-note {{'tp2' initialized to the value of 'tp1'}}
   doStuff_pointerToConstInt(tp2);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -53,7 +53,7 @@
 // expected-note@-1{{Calling 'f_2_sub'}}
 // expected-note@-2{{Returning from 'f_2_sub'}}
 // expected-note@-3{{'p' initialized here}}
-  int* tp = p; // expected-note {{'tp' initialized here}}
+  int *tp = p;  // expected-note {{'tp' initialized to the value of 'p'}}
   doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}}
   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -70,7 +70,7 @@
 
 void f_5(void) {
   int ta[5];   // expected-note {{'ta' initialized here}}
-  int* tp = ta;// expected-note {{'tp' initialized here}}
+  int *tp = ta;// expected-note {{'tp' initialized here}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -339,7 +339,7 @@
// expected-note@216 {{Returning pointer (loaded from 'self')}}
// expected-note@-3 {{Returning from 'initY'}}
// expected-note@-4 {{'Original' initialized here}}
-  id New = Original;   // expected-note {{'New' initialized here}}
+  id New = Original;   // expected-note {{'New' initialized to the value of 'Original'}}
   Original = [[MyObj alloc] initZ];
   (void)New;
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
@@ -352,8 +352,8 @@
// expected-note@216 {{Returning pointer (loaded from 'self')}}
// expected-note@-3 {{Returning from 'initY'}}
// expected-note@-4 {{'Original' initialized here}}
-  id Intermediate = Original;  

[PATCH] D100852: [analyzer] Track leaking object through stores

2021-04-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe273918038a7: [analyzer] Track leaking object through stores 
(authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100852

Files:
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/retain-release-path-notes.m

Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -335,8 +335,11 @@
 @implementation LeakReassignmentTests
 +(void)testLeakAliasSimple {
   id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
-   // expected-note@-1 {{Returning from 'initY'}}
-  id New = Original;
+   // expected-note@215 {{Value assigned to 'self'}}
+   // expected-note@216 {{Returning pointer (loaded from 'self')}}
+   // expected-note@-3 {{Returning from 'initY'}}
+   // expected-note@-4 {{'Original' initialized here}}
+  id New = Original;   // expected-note {{'New' initialized here}}
   Original = [[MyObj alloc] initZ];
   (void)New;
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
@@ -345,9 +348,12 @@
 
 +(void)testLeakAliasChain {
   id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
-   // expected-note@-1 {{Returning from 'initY'}}
-  id Intermediate = Original;
-  id New = Intermediate;
+   // expected-note@215 {{Value assigned to 'self'}}
+   // expected-note@216 {{Returning pointer (loaded from 'self')}}
+   // expected-note@-3 {{Returning from 'initY'}}
+   // expected-note@-4 {{'Original' initialized here}}
+  id Intermediate = Original;  // expected-note {{'Intermediate' initialized here}}
+  id New = Intermediate;   // expected-note {{'New' initialized here}}
   Original = [[MyObj alloc] initZ];
   (void)New;
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
@@ -369,8 +375,12 @@
 
 +(void)testLeakAliasDeathInExpr {
   id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
-   // expected-note@-1 {{Returning from 'initY'}}
-  id New = Original;
+   // expected-note@215 {{Value assigned to 'self'}}
+   // expected-note@216 {{Returning pointer (loaded from 'self')}}
+   // expected-note@-3 {{Returning from 'initY'}}
+   // expected-note@-4 {{'Original' initialized here}}
+  id New = 0;
+  New = Original; // expected-note {{Value assigned to 'New'}}
   Original = [[MyObj alloc] initZ];
   [self log:New with:[self calculate]];
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
Index: clang/test/Analysis/osobject-retain-release.cpp
===
--- clang/test/Analysis/osobject-retain-release.cpp
+++ clang/test/Analysis/osobject-retain-release.cpp
@@ -526,19 +526,58 @@
 
 void check_dynamic_cast_null_check() {
   OSArray *arr = OSDynamicCast(OSArray, OSObject::generateObject(1)); // expected-note{{Call to method 'OSObject::generateObject' returns an OSObject}}
-// expected-warning@-1{{Potential leak of an object}}
-// expected-note@-2{{Object leaked}}
-// expected-note@-3{{Assuming dynamic cast returns null due to type mismatch}}
+  // expected-warning@-1{{Potential leak of an object}}
+  // expected-note@-2{{Object leaked}}
+  // expected-note@-3{{Assuming dynamic cast returns null due to type mismatch}}
   if (!arr)
 return;
   arr->release();
 }
 
+void check_dynamic_cast_alias() {
+  OSObject *originalPtr = OSObject::generateObject(1);   // expected-note {{Call to method 'OSObject::generateObject' returns an OSObject}}
+  OSArray *newPtr 

[PATCH] D100839: [analyzer] Adjust the reported variable name in retain count checker

2021-04-28 Thread Valeriy Savchenko 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 rG61ae2db2d7a9: [analyzer] Adjust the reported variable name 
in retain count checker (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100839

Files:
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/retain-release.m

Index: clang/test/Analysis/retain-release.m
===
--- clang/test/Analysis/retain-release.m
+++ clang/test/Analysis/retain-release.m
@@ -2282,7 +2282,7 @@
 
 void testAutoreleaseReturnsInput() {
   extern CFTypeRef CFCreateSomething();
-  CFTypeRef obj = CFCreateSomething(); // expected-warning{{Potential leak of an object stored into 'obj'}}
+  CFTypeRef obj = CFCreateSomething(); // expected-warning{{Potential leak of an object stored into 'second'}}
   CFTypeRef second = CFAutorelease(obj);
   CFRetain(second);
 }
@@ -2302,7 +2302,7 @@
 }
 
 void autoreleaseReturningTypedObject() {
-  CFArrayRef arr = CFArrayCreateMutable(0, 10, ); // expected-warning{{Potential leak of an object stored into 'arr'}}
+  CFArrayRef arr = CFArrayCreateMutable(0, 10, ); // expected-warning{{Potential leak of an object stored into 'alias'}}
   CFArrayRef alias = (CFArrayRef)CFAutorelease((CFTypeRef)arr);
   CFRetain(alias);
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -212,7 +212,7 @@
 }
 
 -(id)initY {
-  self = [super init]; //expected-note {{Method returns an instance of MyObj with a +1 retain count}}
+  self = [super init]; // expected-note 6 {{Method returns an instance of MyObj with a +1 retain count}}
   return self;
 }
 
@@ -327,5 +327,74 @@
 
 @end
 
+int seed();
 
+@interface LeakReassignmentTests : MyObj
+@end
+
+@implementation LeakReassignmentTests
++(void)testLeakAliasSimple {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  id New = Original;
+  Original = [[MyObj alloc] initZ];
+  (void)New;
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'New' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)testLeakAliasChain {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  id Intermediate = Original;
+  id New = Intermediate;
+  Original = [[MyObj alloc] initZ];
+  (void)New;
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'New' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)log:(id)Obj with:(int)Num {
+  Num *= 42;
+  if (Obj )
+Num /= 2;
+}
+
++(int)calculate {
+  int x = 10;
+  int y = 25;
+  x += y * x + seed();
+  return y - x * y;
+}
+
++(void)testLeakAliasDeathInExpr {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  id New = Original;
+  Original = [[MyObj alloc] initZ];
+  [self log:New with:[self calculate]];
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'New' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)testLeakReassign {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  // TODO: move warning here
+  Original = [[MyObj alloc] initZ];
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'Original'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'Original' is not referenced later in this execution path 

[clang] ab58238 - [analyzer] Find better description for tracked symbolic values

2021-04-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-04-28T18:37:38+03:00
New Revision: ab5823867c4aee7f3e02ddfaa217905c87471bf9

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

LOG: [analyzer] Find better description for tracked symbolic values

When searching for stores and creating corresponding notes, the
analyzer is more specific about the target region of the store
as opposed to the stored value.  While this description was tweaked
for constant and undefined values, it lacked in the most general
case of symbolic values.

This patch tries to find a memory region, where this value is stored,
to use it as a better alias for the value.

rdar://76645710

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
clang/test/Analysis/diagnostics/deref-track-symbolic-region.cpp
clang/test/Analysis/osobject-retain-release.cpp
clang/test/Analysis/retain-release-path-notes.m
clang/test/Analysis/uninit-const.c
clang/test/Analysis/uninit-const.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index fd334b0bc9c36..c0526469909b3 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -153,6 +153,28 @@ const Expr *bugreporter::getDerefExpr(const Stmt *S) {
   return E;
 }
 
+static const MemRegion *
+getLocationRegionIfReference(const Expr *E, const ExplodedNode *N,
+ bool LookingForReference = true) {
+  if (const auto *DR = dyn_cast(E)) {
+if (const auto *VD = dyn_cast(DR->getDecl())) {
+  if (LookingForReference && !VD->getType()->isReferenceType())
+return nullptr;
+  return N->getState()
+  ->getLValue(VD, N->getLocationContext())
+  .getAsRegion();
+}
+  }
+
+  // FIXME: This does not handle other kinds of null references,
+  // for example, references from FieldRegions:
+  //   struct Wrapper { int  };
+  //   Wrapper w = { *(int *)0 };
+  //   w.ref = 1;
+
+  return nullptr;
+}
+
 /// Comparing internal representations of symbolic values (via
 /// SVal::operator==()) is a valid way to check if the value was updated,
 /// unless it's a LazyCompoundVal that may have a 
diff erent internal
@@ -1241,16 +1263,17 @@ static bool isInitializationOfVar(const ExplodedNode 
*N, const VarRegion *VR) {
 
 /// Show diagnostics for initializing or declaring a region \p R with a bad 
value.
 static void showBRDiagnostics(const char *action, llvm::raw_svector_ostream 
,
-  const MemRegion *R, SVal V, const DeclStmt *DS) {
-  if (R->canPrintPretty()) {
-R->printPretty(os);
+  const MemRegion *NewR, SVal V,
+  const MemRegion *OldR, const DeclStmt *DS) {
+  if (NewR->canPrintPretty()) {
+NewR->printPretty(os);
 os << " ";
   }
 
   if (V.getAs()) {
 bool b = false;
-if (R->isBoundable()) {
-  if (const auto *TR = dyn_cast(R)) {
+if (NewR->isBoundable()) {
+  if (const auto *TR = dyn_cast(NewR)) {
 if (TR->getValueType()->isObjCObjectPointerType()) {
   os << action << "nil";
   b = true;
@@ -1262,29 +1285,31 @@ static void showBRDiagnostics(const char *action, 
llvm::raw_svector_ostream ,
 
   } else if (auto CVal = V.getAs()) {
 os << action << CVal->getValue();
+  } else if (OldR && OldR->canPrintPretty()) {
+os << action << "the value of ";
+OldR->printPretty(os);
   } else if (DS) {
 if (V.isUndef()) {
-  if (isa(R)) {
+  if (isa(NewR)) {
 const auto *VD = cast(DS->getSingleDecl());
 if (VD->getInit()) {
-  os << (R->canPrintPretty() ? "initialized" : "Initializing")
-<< " to a garbage value";
+  os << (NewR->canPrintPretty() ? "initialized" : "Initializing")
+ << " to a garbage value";
 } else {
-  os << (R->canPrintPretty() ? "declared" : "Declaring")
-<< " without an initial value";
+  os << (NewR->canPrintPretty() ? "declared" : "Declaring")
+ << " without an initial value";
 }
   }
 } else {
-  os << (R->canPrintPretty() ? "initialized" : "Initialized")
-<< " here";
+  os << (NewR->canPrintPretty() ? "initialized" : "Initialized") << " 
here";
 }
   }
 }
 
 /// Display diagnostics for passing bad region as a parameter.
-static void showBRParamDiagnostics(llvm::raw_svector_ostream& os,
-const VarRegion *VR,
-SVal V) {
+static void showBRParamDiagnostics(llvm::raw_svector_ostream ,
+   

[clang] e273918 - [analyzer] Track leaking object through stores

2021-04-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-04-28T18:37:38+03:00
New Revision: e273918038a7aa300cb8e6afebd9714bf647eed0

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

LOG: [analyzer] Track leaking object through stores

Since we can report memory leaks on one variable, while the originally
allocated object was stored into another one, we should explain
how did it get there.

rdar://76645710

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

Added: 


Modified: 

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
clang/test/Analysis/osobject-retain-release.cpp
clang/test/Analysis/retain-release-path-notes.m

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 48b5f8d9ba7c9..eaa1e35f62bef 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -616,7 +616,7 @@ static Optional describeRegion(const MemRegion 
*MR) {
   return None;
 }
 
-using Bindings = llvm::SmallVector;
+using Bindings = llvm::SmallVector, 4>;
 
 class VarBindingsCollector : public StoreManager::BindingsHandler {
   SymbolRef Sym;
@@ -633,7 +633,7 @@ class VarBindingsCollector : public 
StoreManager::BindingsHandler {
   return true;
 
 if (isa(R))
-  Result.push_back(R);
+  Result.emplace_back(R, Val);
 
 return true;
   }
@@ -968,11 +968,28 @@ void RefLeakReport::findBindingToReport(CheckerContext 
,
   // `AllocFirstBinding` to be one of them.  In situations like this,
   // it would still be the easiest case to explain to our users.
   if (!AllVarBindings.empty() &&
-  llvm::count(AllVarBindings, AllocFirstBinding) == 0)
+  llvm::count_if(AllVarBindings,
+ [this](const std::pair Binding) {
+   return Binding.first == AllocFirstBinding;
+ }) == 0) {
 // Let's pick one of them at random (if there is something to pick from).
-AllocBindingToReport = AllVarBindings[0];
-  else
+AllocBindingToReport = AllVarBindings[0].first;
+
+// Because 'AllocBindingToReport' is not the the same as
+// 'AllocFirstBinding', we need to explain how the leaking object
+// got from one to another.
+//
+// NOTE: We use the actual SVal stored in AllocBindingToReport here because
+//   FindLastStoreBRVisitor compares SVal's and it can get trickier for
+//   something like derived regions if we want to construct SVal from
+//   Sym. Instead, we take the value that is definitely stored in that
+//   region, thus guaranteeing that FindLastStoreBRVisitor will work.
+addVisitor(std::make_unique(
+AllVarBindings[0].second.castAs(), AllocBindingToReport,
+false, bugreporter::TrackingKind::Thorough));
+  } else {
 AllocBindingToReport = AllocFirstBinding;
+  }
 }
 
 RefLeakReport::RefLeakReport(const RefCountBug , const LangOptions ,

diff  --git a/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist 
b/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
index 0665e976efe9d..62cd52b7aa822 100644
--- a/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
+++ b/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
@@ -21827,6 +21827,35 @@

   
 
+
+ kindevent
+ location
+ 
+  line566
+  col3
+  file0
+ 
+ ranges
+ 
+   
+
+ line566
+ col3
+ file0
+
+
+ line566
+ col11
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ garply initialized here
+ message
+ garply initialized here
+
 
  kindcontrol
  edges

diff  --git 
a/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist 
b/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
index 185525c3a8473..3b0ce877b76e6 100644
--- 
a/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
+++ 
b/clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
@@ -5155,6 +5155,35 @@
  message
  Method returns an instance of MyObj with a +1 retain 
count
 
+
+ kindevent
+ location
+ 
+  line215
+  col3
+  

[PATCH] D100626: [analyzer][NFC] Remove duplicated work from retain count leak report

2021-04-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1dad8c5036bc: [analyzer][NFC] Remove duplicated work from 
retain count leak report (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100626

Files:
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp


Index: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -337,11 +337,15 @@
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
-  RefLeakReportVisitor(SymbolRef sym) : RefCountReportVisitor(sym) {}
+  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *FirstBinding)
+  : RefCountReportVisitor(Sym), FirstBinding(FirstBinding) {}
 
   PathDiagnosticPieceRef getEndPath(BugReporterContext ,
 const ExplodedNode *N,
 PathSensitiveBugReport ) override;
+
+private:
+  const MemRegion *FirstBinding;
 };
 
 } // end namespace retaincountchecker
@@ -729,14 +733,6 @@
   // assigned to different variables, etc.
   BR.markInteresting(Sym);
 
-  // We are reporting a leak.  Walk up the graph to get to the first node where
-  // the symbol appeared, and also get the first VarDecl that tracked object
-  // is stored to.
-  AllocationInfo AllocI = GetAllocationSite(BRC.getStateManager(), EndN, Sym);
-
-  const MemRegion* FirstBinding = AllocI.R;
-  BR.markInteresting(AllocI.InterestingMethodContext);
-
   PathDiagnosticLocation L = cast(BR).getEndOfPath();
 
   std::string sbuf;
@@ -902,15 +898,15 @@
 }
 
 RefLeakReport::RefLeakReport(const RefCountBug , const LangOptions ,
- ExplodedNode *n, SymbolRef sym,
+ ExplodedNode *N, SymbolRef Sym,
  CheckerContext )
-: RefCountReport(D, LOpts, n, sym, /*isLeak=*/true) {
+: RefCountReport(D, LOpts, N, Sym, /*isLeak=*/true) {
 
-  deriveAllocLocation(Ctx, sym);
+  deriveAllocLocation(Ctx, Sym);
   if (!AllocBinding)
-deriveParamLocation(Ctx, sym);
+deriveParamLocation(Ctx, Sym);
 
   createDescription(Ctx);
 
-  addVisitor(std::make_unique(sym));
+  addVisitor(std::make_unique(Sym, AllocBinding));
 }


Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -337,11 +337,15 @@
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
-  RefLeakReportVisitor(SymbolRef sym) : RefCountReportVisitor(sym) {}
+  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *FirstBinding)
+  : RefCountReportVisitor(Sym), FirstBinding(FirstBinding) {}
 
   PathDiagnosticPieceRef getEndPath(BugReporterContext ,
 const ExplodedNode *N,
 PathSensitiveBugReport ) override;
+
+private:
+  const MemRegion *FirstBinding;
 };
 
 } // end namespace retaincountchecker
@@ -729,14 +733,6 @@
   // assigned to different variables, etc.
   BR.markInteresting(Sym);
 
-  // We are reporting a leak.  Walk up the graph to get to the first node where
-  // the symbol appeared, and also get the first VarDecl that tracked object
-  // is stored to.
-  AllocationInfo AllocI = GetAllocationSite(BRC.getStateManager(), EndN, Sym);
-
-  const MemRegion* FirstBinding = AllocI.R;
-  BR.markInteresting(AllocI.InterestingMethodContext);
-
   PathDiagnosticLocation L = cast(BR).getEndOfPath();
 
   std::string sbuf;
@@ -902,15 +898,15 @@
 }
 
 RefLeakReport::RefLeakReport(const RefCountBug , const LangOptions ,
- ExplodedNode *n, SymbolRef sym,
+ ExplodedNode *N, SymbolRef Sym,
  CheckerContext )
-: RefCountReport(D, LOpts, n, sym, /*isLeak=*/true) {
+: RefCountReport(D, LOpts, N, Sym, /*isLeak=*/true) {
 
-  deriveAllocLocation(Ctx, sym);
+  deriveAllocLocation(Ctx, Sym);
   if (!AllocBinding)
-deriveParamLocation(Ctx, sym);
+deriveParamLocation(Ctx, Sym);
 
   createDescription(Ctx);
 
-  addVisitor(std::make_unique(sym));
+  addVisitor(std::make_unique(Sym, AllocBinding));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 61ae2db - [analyzer] Adjust the reported variable name in retain count checker

2021-04-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-04-28T18:37:37+03:00
New Revision: 61ae2db2d7a97af5206afe609a303071711f9e6e

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

LOG: [analyzer] Adjust the reported variable name in retain count checker

When reporting leaks, we try to attach the leaking object to some
variable, so it's easier to understand.  Before the patch, we always
tried to use the first variable that stored the object in question.
This can get very confusing for the user, if that variable doesn't
contain that object at the moment of the actual leak.  In many cases,
the warning is dismissed as false positive and it is effectively a
false positive when we fail to properly explain the warning to the
user.

This patch addresses the bigest issue in cases like this.  Now we
check if the variable still contains the leaking symbolic object.
If not, we look for the last variable to actually hold it and use
that variable instead.

rdar://76645710

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

Added: 


Modified: 

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
clang/test/Analysis/osobject-retain-release.cpp
clang/test/Analysis/retain-release-path-notes.m
clang/test/Analysis/retain-release.m

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index a004d78bfe397..48b5f8d9ba7c9 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -13,6 +13,8 @@
 
 #include "RetainCountDiagnostics.h"
 #include "RetainCountChecker.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 
 using namespace clang;
 using namespace ento;
@@ -337,15 +339,15 @@ class RefCountReportVisitor : public BugReporterVisitor {
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
-  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *FirstBinding)
-  : RefCountReportVisitor(Sym), FirstBinding(FirstBinding) {}
+  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *LastBinding)
+  : RefCountReportVisitor(Sym), LastBinding(LastBinding) {}
 
   PathDiagnosticPieceRef getEndPath(BugReporterContext ,
 const ExplodedNode *N,
 PathSensitiveBugReport ) override;
 
 private:
-  const MemRegion *FirstBinding;
+  const MemRegion *LastBinding;
 };
 
 } // end namespace retaincountchecker
@@ -614,6 +616,41 @@ static Optional describeRegion(const 
MemRegion *MR) {
   return None;
 }
 
+using Bindings = llvm::SmallVector;
+
+class VarBindingsCollector : public StoreManager::BindingsHandler {
+  SymbolRef Sym;
+  Bindings 
+
+public:
+  VarBindingsCollector(SymbolRef Sym, Bindings )
+  : Sym(Sym), Result(ToFill) {}
+
+  bool HandleBinding(StoreManager , Store Store, const MemRegion *R,
+ SVal Val) override {
+SymbolRef SymV = Val.getAsLocSymbol();
+if (!SymV || SymV != Sym)
+  return true;
+
+if (isa(R))
+  Result.push_back(R);
+
+return true;
+  }
+};
+
+Bindings getAllVarBindingsForSymbol(ProgramStateManager ,
+const ExplodedNode *Node, SymbolRef Sym) {
+  Bindings Result;
+  VarBindingsCollector Collector{Sym, Result};
+  while (Result.empty() && Node) {
+Manager.iterBindings(Node->getState(), Collector);
+Node = Node->getFirstPred();
+  }
+
+  return Result;
+}
+
 namespace {
 // Find the first node in the current function context that referred to the
 // tracked symbol and the memory location that value was stored to. Note, the
@@ -740,7 +777,7 @@ RefLeakReportVisitor::getEndPath(BugReporterContext ,
 
   os << "Object leaked: ";
 
-  Optional RegionDescription = describeRegion(FirstBinding);
+  Optional RegionDescription = describeRegion(LastBinding);
   if (RegionDescription) {
 os << "object allocated and stored into '" << *RegionDescription << '\'';
   } else {
@@ -749,7 +786,7 @@ RefLeakReportVisitor::getEndPath(BugReporterContext ,
   }
 
   // Get the retain count.
-  const RefVal* RV = getRefBinding(EndN->getState(), Sym);
+  const RefVal *RV = getRefBinding(EndN->getState(), Sym);
   assert(RV);
 
   if 

[clang] 1dad8c5 - [analyzer][NFC] Remove duplicated work from retain count leak report

2021-04-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-04-28T18:37:37+03:00
New Revision: 1dad8c5036bc912078f7859d89e3ea571616fc4a

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

LOG: [analyzer][NFC] Remove duplicated work from retain count leak report

Allocation site is the key location for the leak checker.  It is a
uniqueing location for the report and a source of information for
the warning's message.

Before this patch, we calculated and used it twice in bug report and
in bug report visitor.  Such duplication is not only harmful
performance-wise (not much, but still), but also design-wise.  Because
changing something about the end piece of the report should've been
repeated for description as well.

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

Added: 


Modified: 

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 1fc3ee03d2e10..a004d78bfe397 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -337,11 +337,15 @@ class RefCountReportVisitor : public BugReporterVisitor {
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
-  RefLeakReportVisitor(SymbolRef sym) : RefCountReportVisitor(sym) {}
+  RefLeakReportVisitor(SymbolRef Sym, const MemRegion *FirstBinding)
+  : RefCountReportVisitor(Sym), FirstBinding(FirstBinding) {}
 
   PathDiagnosticPieceRef getEndPath(BugReporterContext ,
 const ExplodedNode *N,
 PathSensitiveBugReport ) override;
+
+private:
+  const MemRegion *FirstBinding;
 };
 
 } // end namespace retaincountchecker
@@ -729,14 +733,6 @@ RefLeakReportVisitor::getEndPath(BugReporterContext ,
   // assigned to 
diff erent variables, etc.
   BR.markInteresting(Sym);
 
-  // We are reporting a leak.  Walk up the graph to get to the first node where
-  // the symbol appeared, and also get the first VarDecl that tracked object
-  // is stored to.
-  AllocationInfo AllocI = GetAllocationSite(BRC.getStateManager(), EndN, Sym);
-
-  const MemRegion* FirstBinding = AllocI.R;
-  BR.markInteresting(AllocI.InterestingMethodContext);
-
   PathDiagnosticLocation L = cast(BR).getEndOfPath();
 
   std::string sbuf;
@@ -902,15 +898,15 @@ void RefLeakReport::createDescription(CheckerContext 
) {
 }
 
 RefLeakReport::RefLeakReport(const RefCountBug , const LangOptions ,
- ExplodedNode *n, SymbolRef sym,
+ ExplodedNode *N, SymbolRef Sym,
  CheckerContext )
-: RefCountReport(D, LOpts, n, sym, /*isLeak=*/true) {
+: RefCountReport(D, LOpts, N, Sym, /*isLeak=*/true) {
 
-  deriveAllocLocation(Ctx, sym);
+  deriveAllocLocation(Ctx, Sym);
   if (!AllocBinding)
-deriveParamLocation(Ctx, sym);
+deriveParamLocation(Ctx, Sym);
 
   createDescription(Ctx);
 
-  addVisitor(std::make_unique(sym));
+  addVisitor(std::make_unique(Sym, AllocBinding));
 }



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


[PATCH] D101461: [clangd][NFC] Reserve storage when creating semantic token encoding.

2021-04-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101461

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


[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-28 Thread David Candler via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb8baa2a91324: [ARM][AArch64] Require appropriate features 
for crypto algorithms (authored by dcandler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99079

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sha3.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm-target-features.c
  clang/test/CodeGen/arm64_crypto.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Driver/arm-features.c
  clang/test/Driver/arm-mfpu.c
  clang/test/Driver/armv8.1m.main.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/test/Bindings/llvm-c/ARM/disassemble.test
  llvm/test/MC/ARM/directive-arch_extension-aes-sha2.s
  llvm/test/MC/ARM/directive-arch_extension-crypto.s
  llvm/test/MC/ARM/neon-crypto.s

Index: llvm/test/MC/ARM/neon-crypto.s
===
--- llvm/test/MC/ARM/neon-crypto.s
+++ llvm/test/MC/ARM/neon-crypto.s
@@ -9,10 +9,10 @@
 @ CHECK: aese.8 q0, q1  @ encoding: [0x02,0x03,0xb0,0xf3]
 @ CHECK: aesimc.8 q0, q1@ encoding: [0xc2,0x03,0xb0,0xf3]
 @ CHECK: aesmc.8 q0, q1 @ encoding: [0x82,0x03,0xb0,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
 
 sha1h.32  q0, q1
 sha1su1.32  q0, q1
@@ -20,9 +20,9 @@
 @ CHECK: sha1h.32  q0, q1   @ encoding: [0xc2,0x02,0xb9,0xf3]
 @ CHECK: sha1su1.32 q0, q1  @ encoding: [0x82,0x03,0xba,0xf3]
 @ CHECK: sha256su0.32 q0, q1@ encoding: [0xc2,0x03,0xba,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 sha1c.32  q0, q1, q2
 sha1m.32  q0, q1, q2
@@ -38,14 +38,14 @@
 @ CHECK: sha256h.32  q0, q1, q2  @ encoding: [0x44,0x0c,0x02,0xf3]
 @ CHECK: sha256h2.32 q0, q1, q2  @ encoding: [0x44,0x0c,0x12,0xf3]
 @ CHECK: sha256su1.32 q0, q1, q2 @ encoding: [0x44,0x0c,0x22,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 vmull.p64 q8, d16, d17
 @ CHECK: vmull.p64  q8, d16, d17@ encoding: [0xa1,0x0e,0xe0,0xf2]
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
Index: llvm/test/MC/ARM/directive-arch_extension-crypto.s
===
--- llvm/test/MC/ARM/directive-arch_extension-crypto.s
+++ llvm/test/MC/ARM/directive-arch_extension-crypto.s
@@ -17,38 +17,38 @@
 	.type crypto,%function
 crypto:
 	vmull.p64 q0, d0, d1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 
 	aesd.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aese.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aesimc.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 	aesmc.8 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: aes armv8
 
 	sha1h.32 q0, q1
-@ CHECK-V7: error: instruction requires: crypto armv8
+@ CHECK-V7: error: instruction requires: sha2 armv8
 	sha1su1.32 q0, q1
-@ CHECK-V7: error: instruction 

[clang] b8baa2a - [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-28 Thread David Candler via cfe-commits

Author: David Candler
Date: 2021-04-28T16:26:18+01:00
New Revision: b8baa2a9132498ea286dbb0d03f005760ecc6fdb

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

LOG: [ARM][AArch64] Require appropriate features for crypto algorithms

This patch changes the AArch32 crypto instructions (sha2 and aes) to
require the specific sha2 or aes features. These features have
already been implemented and can be controlled through the command
line, but do not have the expected result (i.e. `+noaes` will not
disable aes instructions). The crypto feature retains its existing
meaning of both sha2 and aes.

Several small changes are included due to the knock-on effect this has:

- The AArch32 driver has been modified to ensure sha2/aes is correctly
  set based on arch/cpu/fpu selection and feature ordering.
- Crypto extensions are permitted for AArch32 v8-R profile, but not
  enabled by default.
- ACLE feature macros have been updated with the fine grained crypto
  algorithms. These are also used by AArch64.
- Various tests updated due to the change in feature lists and macros.

Reviewed By: lenary

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

Added: 
llvm/test/MC/ARM/directive-arch_extension-aes-sha2.s

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/CodeGen/aarch64-neon-range-checks.c
clang/test/CodeGen/aarch64-neon-sha3.c
clang/test/CodeGen/aarch64-neon-sm4-sm3.c
clang/test/CodeGen/arm-target-features.c
clang/test/CodeGen/arm64_crypto.c
clang/test/CodeGen/neon-crypto.c
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arm-cortex-cpus.c
clang/test/Driver/arm-features.c
clang/test/Driver/arm-mfpu.c
clang/test/Driver/armv8.1m.main.c
clang/test/Preprocessor/aarch64-target-features.c
clang/test/Preprocessor/arm-target-features.c
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Target/ARM/ARMInstrNEON.td
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/test/Bindings/llvm-c/ARM/disassemble.test
llvm/test/MC/ARM/directive-arch_extension-crypto.s
llvm/test/MC/ARM/neon-crypto.s

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 6e3ed6ebbd39f..0d97f0a1c2dc5 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1117,12 +1117,14 @@ def VEXT_A64 : WInst<"vext", "...I", "dQdPlQPl">;
 
 

 // Crypto
-let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_CRYPTO)" in {
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_AES)" in {
 def AESE : SInst<"vaese", "...", "QUc">;
 def AESD : SInst<"vaesd", "...", "QUc">;
 def AESMC : SInst<"vaesmc", "..", "QUc">;
 def AESIMC : SInst<"vaesimc", "..", "QUc">;
+}
 
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA2)" in {
 def SHA1H : SInst<"vsha1h", "11", "Ui">;
 def SHA1SU1 : SInst<"vsha1su1", "...", "QUi">;
 def SHA256SU0 : SInst<"vsha256su0", "...", "QUi">;
@@ -1134,7 +1136,9 @@ def SHA1SU0 : SInst<"vsha1su0", "", "QUi">;
 def SHA256H : SInst<"vsha256h", "", "QUi">;
 def SHA256H2 : SInst<"vsha256h2", "", "QUi">;
 def SHA256SU1 : SInst<"vsha256su1", "", "QUi">;
+}
 
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA3) && 
defined(__aarch64__)" in {
 def BCAX : SInst<"vbcax", "", "QUcQUsQUiQUlQcQsQiQl">;
 def EOR3 : SInst<"veor3", "", "QUcQUsQUiQUlQcQsQiQl">;
 def RAX1 : SInst<"vrax1", "...", "QUl">;
@@ -1142,12 +1146,17 @@ def RAX1 : SInst<"vrax1", "...", "QUl">;
 let isVXAR = 1 in {
 def XAR :  SInst<"vxar", "...I", "QUl">;
 }
+}
+
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SHA512) && 
defined(__aarch64__)" in {
 
 def SHA512SU0 : SInst<"vsha512su0", "...", "QUl">;
 def SHA512su1 : SInst<"vsha512su1", "", "QUl">;
 def SHA512H : SInst<"vsha512h", "", "QUl">;
 def SHA512H2 : SInst<"vsha512h2", "", "QUl">;
+}
 
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SM3) && 
defined(__aarch64__)" in {
 def SM3SS1 : SInst<"vsm3ss1", "", "QUi">;
 def SM3TT1A : SInst<"vsm3tt1a", "I", "QUi">;
 def SM3TT1B : SInst<"vsm3tt1b", "I", "QUi">;
@@ -1155,7 +1164,9 @@ def SM3TT2A : SInst<"vsm3tt2a", "I", "QUi">;
 def SM3TT2B : SInst<"vsm3tt2b", "I", "QUi">;
 def SM3PARTW1 : SInst<"vsm3partw1", "", "QUi">;
 def SM3PARTW2 : SInst<"vsm3partw2", "", "QUi">;
+}
 
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_SM4) && 
defined(__aarch64__)" 

[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-28 Thread David Candler via Phabricator via cfe-commits
dcandler added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.h:36
+  bool HasSHA3;
+  bool HasSM4;
   bool HasUnaligned;

rsanthir.quic wrote:
> Would it make sense to further differentiate SM3 and SM4? I see that we 
> differentiate between the two in arm_neon.td ("ARM_FEATURE_SM3" & 
> "ARM_FEATURE_SM4") but we don't include this differentiation as flags (only 
> HasSM4, +sm4 etc)
It might make more sense in the code to differentiate them, however the current 
feature and command line options align with GCC, so changing them would go 
beyond the scope of this patch.


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

https://reviews.llvm.org/D99079

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


[PATCH] D101439: [clang-cl] Add parsing support for a bunch of new flags

2021-04-28 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Great :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101439

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


[PATCH] D101463: [clang] Make libBasic not depend on MC

2021-04-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
Herald added subscribers: dexonsmith, dang, mgorny.
Herald added a reviewer: aaron.ballman.
thakis requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

Reduces numbers of files built for clang-format from 575 to 449.

Requires two small changes.

1. Don't use llvm::ExceptionHandling in LangOptions. This isn't even quite the 
right type since we don't use all of its values. Tweaks the changes made in:
  - https://reviews.llvm.org/D93215
  - https://reviews.llvm.org/D93216

2. Move section name validation code added (long ago) in commit 30ba67439 out 
of libBasic into Sema and base the check on the triple. This is a bit less 
OOP-y, but completely in line with what we do in many other places in Sema.

No behavior change.


https://reviews.llvm.org/D101463

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
  llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
  llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn

Index: llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn
+++ llvm/utils/gn/secondary/clang/tools/clang-format/BUILD.gn
@@ -12,6 +12,7 @@
 "//clang/lib/Frontend/",
 "//clang/lib/Sema/",
 "//llvm/lib/IR",
+"//llvm/lib/MC",
   ]
   sources = [ "ClangFormat.cpp" ]
 }
Index: llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn
@@ -25,6 +25,7 @@
 "//clang/lib/Edit",
 "//clang/lib/Lex",
 "//llvm/lib/Frontend/OpenMP",
+"//llvm/lib/MC",
 "//llvm/lib/Support",
   ]
   sources = [
Index: llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn
@@ -49,7 +49,6 @@
 "//clang/include/clang/Sema:AttrParsedAttrKinds",
 "//clang/include/clang/Sema:AttrSpellingListIndex",
 "//llvm/include/llvm/Config:llvm-config",
-"//llvm/lib/MC",
 "//llvm/lib/Support",
   ]
   include_dirs = [ "." ]
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -40,6 +40,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Assumptions.h"
+#include "llvm/MC/MCSectionMachO.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
@@ -2985,9 +2986,29 @@
   return ::new (Context) SectionAttr(Context, CI, Name);
 }
 
+/// Used to implement to perform semantic checking on
+/// attribute((section("foo"))) specifiers.
+///
+/// In this case, "foo" is passed in to be checked.  If the section
+/// specifier is invalid, return an Error that indicates the problem.
+///
+/// This is a simple quality of implementation feature to catch errors
+/// and give good diagnostics in cases when the assembler or code generator
+/// would otherwise reject the section specifier.
+llvm::Error Sema::isValidSectionSpecifier(StringRef SecName) {
+  if (!Context.getTargetInfo().getTriple().isOSDarwin())
+return llvm::Error::success();
+
+  // Let MCSectionMachO validate this.
+  StringRef Segment, Section;
+  unsigned TAA, StubSize;
+  bool HasTAA;
+  return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
+ TAA, HasTAA, StubSize);
+}
+
 bool Sema::checkSectionName(SourceLocation LiteralLoc, StringRef SecName) {
-  if (llvm::Error E =
-  Context.getTargetInfo().isValidSectionSpecifier(SecName)) {
+  if (llvm::Error E = isValidSectionSpecifier(SecName)) {
 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
 << toString(std::move(E)) << 1 /*'section'*/;
 return false;
@@ -3021,8 +3042,7 @@
 // `#pragma code_seg("segname")` uses checkSectionName() instead.
 static bool checkCodeSegName(Sema , SourceLocation LiteralLoc,
  StringRef CodeSegName) {
-  if (llvm::Error E =
-  S.Context.getTargetInfo().isValidSectionSpecifier(CodeSegName)) {
+  if (llvm::Error E = S.isValidSectionSpecifier(CodeSegName)) {
 S.Diag(LiteralLoc, 

[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-04-28 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 341211.
Ericson2314 added a comment.

Fix stray ':' typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

Files:
  clang/tools/scan-build/CMakeLists.txt
  libclc/CMakeLists.txt
  lldb/cmake/modules/FindLibEdit.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt

Index: openmp/runtime/src/CMakeLists.txt
===
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -319,7 +319,7 @@
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
   \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -331,7 +331,7 @@
 foreach(alias IN LISTS LIBOMP_ALIASES)
   install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
 endforeach()
   endif()
 endif()
Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -25,7 +25,7 @@
 intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_INCLUDEDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_BINDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,8 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
Index: 

[PATCH] D101461: [clangd][NFC] Reserve storage when creating semantic token encoding.

2021-04-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: sammccall, kadircet.
Herald added subscribers: usaxena95, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101461

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


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1075,6 +1075,7 @@
 constexpr unsigned SemanticTokenEncodingSize = 5;
 static llvm::json::Value encodeTokens(llvm::ArrayRef Toks) {
   llvm::json::Array Result;
+  Result.reserve(SemanticTokenEncodingSize * Toks.size());
   for (const auto  : Toks) {
 Result.push_back(Tok.deltaLine);
 Result.push_back(Tok.deltaStart);


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1075,6 +1075,7 @@
 constexpr unsigned SemanticTokenEncodingSize = 5;
 static llvm::json::Value encodeTokens(llvm::ArrayRef Toks) {
   llvm::json::Array Result;
+  Result.reserve(SemanticTokenEncodingSize * Toks.size());
   for (const auto  : Toks) {
 Result.push_back(Tok.deltaLine);
 Result.push_back(Tok.deltaStart);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101457: [clang] remove dead code after 2a1332245fc

2021-04-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> The real question is how did you find this? :)

No exciting answer, I'm afraid: I just happened to read this code while looking 
at something else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101457

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


[PATCH] D101457: [clang] remove dead code after 2a1332245fc

2021-04-28 Thread Nico Weber 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 rG5d493291bd01: [clang] remove dead code after 2a1332245fc 
(authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101457

Files:
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3006,13 +3006,6 @@
   if (!S.checkSectionName(LiteralLoc, Str))
 return;
 
-  // If the target wants to validate the section specifier, make it happen.
-  if (llvm::Error E = S.Context.getTargetInfo().isValidSectionSpecifier(Str)) {
-S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
-<< toString(std::move(E));
-return;
-  }
-
   SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
   if (NewAttr) {
 D->addAttr(NewAttr);


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3006,13 +3006,6 @@
   if (!S.checkSectionName(LiteralLoc, Str))
 return;
 
-  // If the target wants to validate the section specifier, make it happen.
-  if (llvm::Error E = S.Context.getTargetInfo().isValidSectionSpecifier(Str)) {
-S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
-<< toString(std::move(E));
-return;
-  }
-
   SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
   if (NewAttr) {
 D->addAttr(NewAttr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5d49329 - [clang] remove dead code after 2a1332245fc

2021-04-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-04-28T10:27:31-04:00
New Revision: 5d493291bd010bbba0fdc1e7da0922fd214fdffd

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

LOG: [clang] remove dead code after 2a1332245fc

Commit 2a1332245fc extracted this code to a new function checkSectionName() and
added a call to it, but didn't remove the original code. The original code
is dead since the checkSectionName() early return would fire when it would
trigger. (If it weren't dead, it'd make clang crash since
err_attribute_section_invalid_for_target now takes two args instead of just the
one that's passed.)

No behavior change.

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b31f9ecb2aceb..7db720f6c57d3 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3006,13 +3006,6 @@ static void handleSectionAttr(Sema , Decl *D, const 
ParsedAttr ) {
   if (!S.checkSectionName(LiteralLoc, Str))
 return;
 
-  // If the target wants to validate the section specifier, make it happen.
-  if (llvm::Error E = S.Context.getTargetInfo().isValidSectionSpecifier(Str)) {
-S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
-<< toString(std::move(E));
-return;
-  }
-
   SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
   if (NewAttr) {
 D->addAttr(NewAttr);



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


[PATCH] D101457: [clang] remove dead code after 2a1332245fc

2021-04-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

The real question is how did you find this? :)


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

https://reviews.llvm.org/D101457

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


  1   2   >