[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2021-11-02 Thread wangpc via Phabricator via cfe-commits
pcwang-thead updated this revision to Diff 384344.
pcwang-thead marked an inline comment as done.
pcwang-thead added a comment.

Adds `ADDITIONAL_COMPILE_FLAGS` and guard macros to:

- 
`libcxx\test\std\language.support\support.dynamic\new.delete\new.delete.single\sized_delete14.pass.cpp`
- 
`libcxx\test\std\language.support\support.dynamic\new.delete\new.delete.array\sized_delete_array14.pass.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  clang/unittests/StaticAnalyzer/CallEventTest.cpp
  clang/www/cxx_status.html
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp

Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -9,10 +9,19 @@
 // test sized operator delete replacement.
 
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-12, clang-13
+// XFAIL: apple-clang-13
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// REQUIRES: -fsized-deallocation
+// ADDITIONAL_COMPILE_FLAGS: -fsized-deallocation
+
+#if !defined(__cpp_sized_deallocation)
+#  error __cpp_sized_deallocation should be defined
+#endif
+
+#if !(__cpp_sized_deallocation >= 201309L)
+#  error expected __cpp_sized_deallocation >= 201309L
+#endif
 
 #include 
 #include 
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -9,10 +9,19 @@
 // test sized operator delete[] replacement.
 
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-12, clang-13
+// XFAIL: apple-clang-13
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// REQUIRES: -fsized-deallocation
+// ADDITIONAL_COMPILE_FLAGS: -fsized-deallocation
+
+#if !defined(__cpp_sized_deallocation)
+#  error __cpp_sized_deallocation should be defined
+#endif
+
+#if !(__cpp_sized_deallocation >= 201309L)
+#  error expected __cpp_sized_deallocation >= 201309L
+#endif
 
 #include 
 #include 
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -578,12 +578,11 @@
 
 
 
-(7): In Clang 3.7 and later, sized deallocation is only enabled
-if the user passes the -fsized-deallocation flag. The user must
-supply definitions of the sized deallocation functions, either by providing them
-explicitly or by using a C++ standard library that does. libstdc++
-added these functions in version 5.0, and libc++ added them in
-version 3.7.
+(7): The user must supply definitions of the sized deallocation
+functions, either by providing them explicitly or by using a C++ standard library
+that does. libstdc++ added these functions in version 5.0, and
+libc++ added them in version 3.7. The user can also use the
+-fno-sized-deallocation option to disable sized deallocation.
 
 
 
Index: clang/unittests/StaticAnalyzer/CallEventTest.cpp
===
--- clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ clang/unittests/StaticAnalyzer/CallEventTest.cpp

[PATCH] D113080: [Support] Improve Caching conformance with Support library behavior

2021-11-02 Thread Noah Shutty via Phabricator via cfe-commits
noajshu created this revision.
Herald added subscribers: ormris, dexonsmith, steven_wu, hiraditya, 
arichardson, sbc100, emaste.
Herald added a reviewer: MaskRay.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
noajshu requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.

This diff makes several amendments to the local file caching mechanism which 
was migrated from ThinLTO to Support in D112751 
 in response to follow-up discussion on that 
commit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113080

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -362,20 +362,20 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream = [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
 *AddStream(Task)->OS << MB->getBuffer();
   };
 
-  NativeObjectCache Cache;
+  FileCache Cache;
   if (!CacheDir.empty())
 Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
   "failed to create cache");
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,7 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream = [&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1107,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -1081,11 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream = [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1093,7 +1093,7 @@
 *AddStream(Task)->OS << MB->getBuffer();
   };
 
-  NativeObjectCache Cache;
+  FileCache Cache;
   if (!options::cache_dir.empty())
 Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM File Cache Handling --===//
+//===-Caching.cpp - LLVM Local File Cache -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,18 +6,17 @@
 //
 //===--===//
 //
-// This file implements the Caching used by ThinLTO.
+// This file implements the localCache function, which simplifies creating,
+// adding to, and querying a local file system cache. localCache takes care of
+// periodically pruning older files from the cache using a CachePruningPolicy.
 //
 //===--===//
 
 #include "llvm/Support/Caching.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
-#include 

[PATCH] D111866: [RISCV] Support Zfhmin extension

2021-11-02 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence marked 4 inline comments as done.
achieveartificialintelligence added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111866

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


[PATCH] D111866: [RISCV] Support Zfhmin extension

2021-11-02 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 384337.
achieveartificialintelligence added a comment.

Address @asb 's comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111866

Files:
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zfhmin-invalid.s
  llvm/test/MC/RISCV/rv32zfhmin-valid.s

Index: llvm/test/MC/RISCV/rv32zfhmin-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zfhmin-valid.s
@@ -0,0 +1,62 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfhmin,+d -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfhmin,+d -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zfhmin,+d < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zfhmin,+d -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zfhmin,+d < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zfhmin,+d -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: flh ft0, 12(a0)
+# CHECK-ASM: encoding: [0x07,0x10,0xc5,0x00]
+flh f0, 12(a0)
+# CHECK-ASM-AND-OBJ: flh ft1, 4(ra)
+# CHECK-ASM: encoding: [0x87,0x90,0x40,0x00]
+flh f1, +4(ra)
+# CHECK-ASM-AND-OBJ: flh ft2, -2048(a3)
+# CHECK-ASM: encoding: [0x07,0x91,0x06,0x80]
+flh f2, -2048(x13)
+# CHECK-ASM-AND-OBJ: flh ft3, -2048(s1)
+# CHECK-ASM: encoding: [0x87,0x91,0x04,0x80]
+flh f3, %lo(2048)(s1)
+# CHECK-ASM-AND-OBJ: flh ft4, 2047(s2)
+# CHECK-ASM: encoding: [0x07,0x12,0xf9,0x7f]
+flh f4, 2047(s2)
+# CHECK-ASM-AND-OBJ: flh ft5, 0(s3)
+# CHECK-ASM: encoding: [0x87,0x92,0x09,0x00]
+flh f5, 0(s3)
+
+# CHECK-ASM-AND-OBJ: fsh ft6, 2047(s4)
+# CHECK-ASM: encoding: [0xa7,0x1f,0x6a,0x7e]
+fsh f6, 2047(s4)
+# CHECK-ASM-AND-OBJ: fsh ft7, -2048(s5)
+# CHECK-ASM: encoding: [0x27,0x90,0x7a,0x80]
+fsh f7, -2048(s5)
+# CHECK-ASM-AND-OBJ: fsh fs0, -2048(s6)
+# CHECK-ASM: encoding: [0x27,0x10,0x8b,0x80]
+fsh f8, %lo(2048)(s6)
+# CHECK-ASM-AND-OBJ: fsh fs1, 999(s7)
+# CHECK-ASM: encoding: [0xa7,0x93,0x9b,0x3e]
+fsh f9, 999(s7)
+
+# CHECK-ASM-AND-OBJ: fmv.x.h a2, fs7
+# CHECK-ASM: encoding: [0x53,0x86,0x0b,0xe4]
+fmv.x.h a2, fs7
+# CHECK-ASM-AND-OBJ: fmv.h.x ft1, a6
+# CHECK-ASM: encoding: [0xd3,0x00,0x08,0xf4]
+fmv.h.x ft1, a6
+
+# CHECK-ASM-AND-OBJ: fcvt.s.h fa0, ft0
+# CHECK-ASM: encoding: [0x53,0x05,0x20,0x40]
+fcvt.s.h fa0, ft0
+# CHECK-ASM-AND-OBJ: fcvt.h.s ft2, fa2
+# CHECK-ASM: encoding: [0x53,0x71,0x06,0x44]
+fcvt.h.s ft2, fa2
+# CHECK-ASM-AND-OBJ: fcvt.d.h fa0, ft0
+# CHECK-ASM: encoding: [0x53,0x05,0x20,0x42]
+fcvt.d.h fa0, ft0
+# CHECK-ASM-AND-OBJ: fcvt.h.d ft2, fa2
+# CHECK-ASM: encoding: [0x53,0x71,0x16,0x44]
+fcvt.h.d ft2, fa2
Index: llvm/test/MC/RISCV/rv32zfhmin-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zfhmin-invalid.s
@@ -0,0 +1,23 @@
+# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zfhmin < %s 2>&1 | \
+# RUN:   FileCheck %s
+
+# Out of range immediates
+## simm12
+flh ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
+fsh ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
+
+# Memory operand not formatted correctly
+flh ft1, a0, -200 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
+
+# Invalid register names
+flh ft15, 100(a0) # CHECK: :[[@LINE]]:5: error: invalid operand for instruction
+flh ft1, 100(a10) # CHECK: :[[@LINE]]:14: error: expected register
+
+# Integer registers where FP regs are expected
+fmv.x.h fs7, a2 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+
+# FP registers where integer regs are expected
+fmv.h.x a8, ft2 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+
+# Zfh instructions
+fmadd.h f10, f11, f12, f13, dyn # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -66,8 +66,11 @@
 .attribute arch, "rv32izbt"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
 
+.attribute 

[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-11-02 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

This commit seems to cause some regression for "-save-temps" as there is no new 
line before the pragma. See the below test case, -E will output
int test();#pragma clang assume_nonnull
It will fail the compilation on the preprocessed output with
error: expected unqualified-id
int test();#pragma clang assume_nonnull end

  ^

Thanks,

Manman
--

cat test-pragma.mm 
// RUN: %clang -E -o - %s | FileCheck %s

#define CF_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define CF_ASSUME_NONNULL_END   _Pragma("clang assume_nonnull end")

CF_ASSUME_NONNULL_BEGIN
int test();

CF_ASSUME_NONNULL_END
// CHECK-NOT: test();#pragma clang assume_nonnull


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D112941: [clang] Add support for the new pointer authentication builtins.

2021-11-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Mostly LGTM, although I am not the most unbiased reviewer. :)




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:839
+def err_ptrauth_disabled :
+  Error<"pointer authentication is disabled for the current target">;
+def err_ptrauth_invalid_key :

apazos wrote:
> These two error types are confusing. 
> In which situation would err_ptrauth_disabled be printed?
> With this patch, it is only supported with arm64e triple, all other targets 
> it is unsupported.
We could probably just have one of these, yes.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:847
+const llvm::APSInt ) const {
+  return 0 <= value && value <= 3;
+}

There's an LLVM constants header for this now, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112941

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


[PATCH] D112915: WIP: [clang][modules] Granular tracking of includes

2021-11-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I'm not going to cover the entire change, some parts I need to consider more 
carefully.

There can be other reasons to keep `IncludeMap` out of `SubmoduleState` but I'm 
not sure the local submodule visibility is the right reason. I might be reading 
the code incorrectly but looks like `CurSubmoduleState` is used when local 
submodule visibility is disabled. The difference is it's tracking the aggregate 
state instead of per-submodule state. Need to experiment more but so far 
tracking includes in `SubmoduleState` follows the spirit of local submodule 
visibility. Though it's not guaranteed it'll work perfectly from the technical 
perspective.

Also I think we'll need to increase granularity to track other HeaderFileInfo 
attributes, not just NumIncludes. Don't have a test case to illustrate that 
right now and no need to change that now but something to keep in mind.




Comment at: clang/lib/Lex/PPLexerChange.cpp:699
+// current.
+for (const auto& Includes : CurIncludeMap->OuterIncludes)
+  IncludeState.OuterIncludes[Includes.getFirst()] += Includes.getSecond();

How many includes are expected to be here? Are this only immediate includes or 
also transitive?

Asking to evaluate how expensive iterating through the includes can get.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112915

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-02 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.

Lets keep AddressSanitizerPass for a while, we don't have to remove it in the 
same patch




Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:1289
+  }
+  Modified |= ModuleSanitizer.instrumentModule(M);
+  if (Modified)

kstoimenov wrote:
> At first I had module sanitizer run first, but some tests failed. Is it 
> possible that the function pass has some side effects, which are used by the 
> module pass? 
That's OK.

NewPMDriver.cpp was wrong, BackendUtil.cpp was wrong

if we put module in-front of function  the following with disable globals 
instrumentation:
```
 if (G && (!ClInitializers || GlobalIsLinkerInitialized(G)) &&
isSafeAccess(ObjSizeVis, Addr, O.TypeSize)) {
```




Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:2829
   if (F.getName().startswith("__asan_")) return false;
+  if (F.empty()) return false;
 

kstoimenov wrote:
> This was a pain to figure out. Maybe we should apply the same check in 
> HWAsan? 
I looks like should be the first "if" in the function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 384303.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/tools/opt/NewPMDriver.cpp


Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -344,8 +344,6 @@
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 
-sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s 
-passes='module(require,sancov-module,asan-module),function(asan)'
 -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | 
FileCheck %s
+; RUN: opt < %s 
-passes='module(require,sancov-module,asan-module)' 
-sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck 
%s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1300,14 +1300,22 @@
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module ,
-  AnalysisManager ) 
{
-  GlobalsMetadata  = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, , Options.CompileKernel,
-   Options.Recover, UseGlobalGC,
-   UseOdrIndicator, DestructorKind);
-  if (Sanitizer.instrumentModule(M))
-return PreservedAnalyses::none();
-  return PreservedAnalyses::all();
+  ModuleAnalysisManager ) {
+  GlobalsMetadata  = MAM.getResult(M);
+  ModuleAddressSanitizer ModuleSanitizer(M, , Options.CompileKernel,
+ Options.Recover, UseGlobalGC,
+ UseOdrIndicator, DestructorKind);
+  bool Modified = false;
+  auto  = 
MAM.getResult(M).getManager();
+  for (Function  : M) {
+AddressSanitizer FunctionSanitizer(M, , Options.CompileKernel,
+   Options.Recover, Options.UseAfterScope,
+   Options.UseAfterReturn);
+const TargetLibraryInfo  = FAM.getResult(F);
+Modified |= FunctionSanitizer.instrumentFunction(F, );
+  }
+  Modified |= ModuleSanitizer.instrumentModule(M);
+  return Modified ? PreservedAnalyses::none() : PreservedAnalyses::all();
 }
 
 INITIALIZE_PASS(ASanGlobalsMetadataWrapperPass, "asan-globals-md",
@@ -2841,6 +2849,8 @@
 
 bool AddressSanitizer::instrumentFunction(Function ,
   const TargetLibraryInfo *TLI) {
+  if (F.empty())
+return false;
   if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
   if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
   if (F.getName().startswith("__asan_")) return false;
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -580,10 +580,6 @@
   return parseSinglePassOption(Params, "minimal", "LowerMatrixIntrinsics");
 }
 
-Expected parseModuleAddressSanitizerPassOptions(StringRef Params) {
-  return parseSinglePassOption(Params, "kernel", "ModuleAddressSanitizer");
-}
-
 Expected parseASanPassOptions(StringRef Params) {
   AddressSanitizerOptions Result;
   while (!Params.empty()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1188,8 +1188,6 @@
 MPM.addPass(RequireAnalysisPass());
 MPM.addPass(ModuleAddressSanitizerPass(
 Opts, UseGlobalGC, 

[PATCH] D113072: [NFC][asan] Use AddressSanitizerOptions in ModuleAddressSanitizerPass

2021-11-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 384302.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113072

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -346,7 +346,7 @@
   RequireAnalysisPass());
   MPM.addPass(
   createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
-  MPM.addPass(ModuleAddressSanitizerPass());
+  MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
   MPM.addPass(
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1288,23 +1288,23 @@
   static_cast *>(this)->printPipeline(
   OS, MapClassName2PassName);
   OS << "<";
-  if (CompileKernel)
+  if (Options.CompileKernel)
 OS << "kernel";
   OS << ">";
 }
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
-bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
-: CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
+const AddressSanitizerOptions , bool UseGlobalGC,
+bool UseOdrIndicator, AsanDtorKind DestructorKind)
+: Options(Options), UseGlobalGC(UseGlobalGC),
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module ,
   AnalysisManager ) {
   GlobalsMetadata  = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, , CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
+  ModuleAddressSanitizer Sanitizer(M, , Options.CompileKernel,
+   Options.Recover, UseGlobalGC,
+   UseOdrIndicator, DestructorKind);
   if (Sanitizer.instrumentModule(M))
 return PreservedAnalyses::none();
   return PreservedAnalyses::all();
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -138,12 +138,10 @@
 "kernel;recover")
 MODULE_PASS_WITH_PARAMS("asan-module",
 "ModuleAddressSanitizerPass",
-[](bool CompileKernel) {
-  return ModuleAddressSanitizerPass(CompileKernel,
-false, true,
-false);
+[](AddressSanitizerOptions Opts) {
+  return ModuleAddressSanitizerPass(Opts);
 },
-parseModuleAddressSanitizerPassOptions,
+parseASanPassOptions,
 "kernel")
 #undef MODULE_PASS_WITH_PARAMS
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -106,7 +106,7 @@
 /// surrounding requested memory to be checked for invalid accesses.
 class AddressSanitizerPass : public PassInfoMixin {
 public:
-  explicit AddressSanitizerPass(AddressSanitizerOptions Options)
+  AddressSanitizerPass(const AddressSanitizerOptions )
   : Options(Options){};
   PreservedAnalyses run(Function , FunctionAnalysisManager );
   void printPipeline(raw_ostream ,
@@ -125,8 +125,8 @@
 class ModuleAddressSanitizerPass
 : public PassInfoMixin {
 public:
-  explicit ModuleAddressSanitizerPass(
-  bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = true,
+  ModuleAddressSanitizerPass(
+  const AddressSanitizerOptions , bool UseGlobalGC = true,
   bool UseOdrIndicator = false,
   AsanDtorKind DestructorKind = AsanDtorKind::Global);
   PreservedAnalyses run(Module , ModuleAnalysisManager );
@@ -135,8 +135,7 @@
   static bool isRequired() { return true; }
 
 private:
-  bool CompileKernel;
-  bool Recover;
+  AddressSanitizerOptions Options;
   bool UseGlobalGC;
   bool UseOdrIndicator;
   AsanDtorKind DestructorKind;
Index: clang/lib/CodeGen/BackendUtil.cpp

[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2021-11-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@aaron.ballman I checked the source. Looks like we can easily get TypeLoc from 
TypeSourceInfo, but not from TypeSourceInfo to TypeLoc. But We need TypeLoc so 
we can get attr information and also traverse TypeLoc's.. We might be able to 
pass TypeSourceInfo in a few functions e.g., createFieldType(), but we still 
need to do TSI->getTypeLoc() and pass TypeLoc to other functions like 
getOrCreateType(), createType() etc. So I am inclined to just use TypeLoc.

@dblaikie Based on the discussion so far, I suspect we might have to use 
TypeLoc. Please let me know what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D113072: [NFC][asan] Use AddressSanitizerOptions in ModuleAddressSanitizerPass

2021-11-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 384292.
vitalybuka added a comment.

unused var


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113072

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -346,7 +346,7 @@
   RequireAnalysisPass());
   MPM.addPass(
   createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
-  MPM.addPass(ModuleAddressSanitizerPass());
+  MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
   MPM.addPass(
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1288,23 +1288,23 @@
   static_cast *>(this)->printPipeline(
   OS, MapClassName2PassName);
   OS << "<";
-  if (CompileKernel)
+  if (Options.CompileKernel)
 OS << "kernel";
   OS << ">";
 }
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
-bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
-: CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
+const AddressSanitizerOptions , bool UseGlobalGC,
+bool UseOdrIndicator, AsanDtorKind DestructorKind)
+: Options(Options), UseGlobalGC(UseGlobalGC),
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module ,
   AnalysisManager ) {
   GlobalsMetadata  = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, , CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
+  ModuleAddressSanitizer Sanitizer(M, , Options.CompileKernel,
+   Options.Recover, UseGlobalGC,
+   UseOdrIndicator, DestructorKind);
   if (Sanitizer.instrumentModule(M))
 return PreservedAnalyses::none();
   return PreservedAnalyses::all();
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -138,12 +138,10 @@
 "kernel;recover")
 MODULE_PASS_WITH_PARAMS("asan-module",
 "ModuleAddressSanitizerPass",
-[](bool CompileKernel) {
-  return ModuleAddressSanitizerPass(CompileKernel,
-false, true,
-false);
+[](AddressSanitizerOptions Opts) {
+  return ModuleAddressSanitizerPass(Opts);
 },
-parseModuleAddressSanitizerPassOptions,
+parseASanPassOptions,
 "kernel")
 #undef MODULE_PASS_WITH_PARAMS
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -106,7 +106,7 @@
 /// surrounding requested memory to be checked for invalid accesses.
 class AddressSanitizerPass : public PassInfoMixin {
 public:
-  explicit AddressSanitizerPass(AddressSanitizerOptions Options)
+  AddressSanitizerPass(const AddressSanitizerOptions )
   : Options(Options){};
   PreservedAnalyses run(Function , FunctionAnalysisManager );
   void printPipeline(raw_ostream ,
@@ -125,8 +125,8 @@
 class ModuleAddressSanitizerPass
 : public PassInfoMixin {
 public:
-  explicit ModuleAddressSanitizerPass(
-  bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = true,
+  ModuleAddressSanitizerPass(
+  const AddressSanitizerOptions , bool UseGlobalGC = true,
   bool UseOdrIndicator = false,
   AsanDtorKind DestructorKind = AsanDtorKind::Global);
   PreservedAnalyses run(Module , ModuleAnalysisManager );
@@ -135,8 +135,7 @@
   static bool isRequired() { return true; }
 
 private:
-  bool CompileKernel;
-  bool Recover;
+  AddressSanitizerOptions Options;
   bool UseGlobalGC;
   bool UseOdrIndicator;
   AsanDtorKind DestructorKind;
Index: 

[PATCH] D112971: [NFC] Remove LinkAll*.h

2021-11-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

Turns out the comments are misleading, they aren't to prevent specific 
functions from being removed, they're to force an odr usage of various 
functions, which in turn makes sure that globals in the corresponding 
translation units with the function definition are initialized. Those globals 
populate registries that are necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112971

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


[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-11-02 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In D107049#3104558 , @dblaikie wrote:

> In D107049#3103984 , @lhames wrote:
>
>> In D107049#3101456 , @dblaikie 
>> wrote:
>>
>>> Yeah, seems we've had some precedent for this for a while, as @lhames says 
>>> (doing some archaeology I see one of the clang-interpreter tests added 
>>> here, for instance: 
>>> https://github.com/llvm/llvm-project/commit/1d487617f20ab9df65ab60d6cf9431ef288312ab
>>
>> Also all of the MJCIT and Orc tests in LLVM.
>
> I think @rnk was asking/drawing a distinction between execution tests in LLVM 
> (which is at least only testing LLVM code in LLVM) and execution tests in 
> Clang (which is both execution, and cross-project) - so I was just talking 
> about the Clang->LLVM->execution tests. Though I think in LLVM there'd also 
> be some opportunity to find some ways to isolate/test JIT infrastructure with 
> less execution (had sort of hoped in the early days of Orc that the layered 
> architecture would allow more isolated/unit testing to robustly test pieces 
> without execution for that testing).

Orc has plenty of isolated unit testing and regression testing too, it's just 
that the nature of the project (dynamic compilation, and with relatively few 
resources dedicated to it) makes end to end testing attractive for now too. 
Perhaps in the long term we could build out enough mocking infrastructure to be 
confident that the JIT works without running any JIT'd code, but we're a fair 
way off that.

I think testing of the clang-repl is probably in a similar place: In theory you 
could build infrastructure to test out all the interesting states that a REPL 
could put your AST into. In practice we don't have the resources to do that 
yet, and without execution tests we're left with essentially no testing of the 
feature.

Execution testing seems like the right compromise for now, as long as we can 
make sure that there's not too much noise from the testers. The lesson from the 
LLVM execution tests is that this is possible without an excessive amount of 
work.

> I think cross-project-tests (originally debuginfo-tests) has always had/been 
> a place for execution tests. Not all of them, and still value in having 
> lit-style non-execution cross-project tests where possible for more 
> robust/variation testing where possible, with fewer full 
> end-to-end-including-execution tests where possible (always going to be fuzzy 
> lines of what's worth the cost/benefit, etc - and we're all going to have 
> different points on that spectrum).

Yeah. Cross-project tests sounds like a great place to add more JIT tests, and 
maybe it's the correct home for clang-repl tests, but I think for now the right 
trade off is still to have execution tests and just restrict them to running on 
known-good configs.


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

https://reviews.llvm.org/D107049

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


[PATCH] D113072: [NFC][asan] Use AddressSanitizerOptions in ModuleAddressSanitizerPass

2021-11-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added subscribers: ormris, hiraditya.
vitalybuka requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113072

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -346,7 +346,7 @@
   RequireAnalysisPass());
   MPM.addPass(
   createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
-  MPM.addPass(ModuleAddressSanitizerPass());
+  MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
   MPM.addPass(
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1288,23 +1288,23 @@
   static_cast *>(this)->printPipeline(
   OS, MapClassName2PassName);
   OS << "<";
-  if (CompileKernel)
+  if (Options.CompileKernel)
 OS << "kernel";
   OS << ">";
 }
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
-bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
-: CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
+const AddressSanitizerOptions , bool UseGlobalGC,
+bool UseOdrIndicator, AsanDtorKind DestructorKind)
+: Options(Options), UseGlobalGC(UseGlobalGC),
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module ,
   AnalysisManager ) {
   GlobalsMetadata  = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, , CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
+  ModuleAddressSanitizer Sanitizer(M, , Options.CompileKernel,
+   Options.Recover, UseGlobalGC,
+   UseOdrIndicator, DestructorKind);
   if (Sanitizer.instrumentModule(M))
 return PreservedAnalyses::none();
   return PreservedAnalyses::all();
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -138,12 +138,10 @@
 "kernel;recover")
 MODULE_PASS_WITH_PARAMS("asan-module",
 "ModuleAddressSanitizerPass",
-[](bool CompileKernel) {
-  return ModuleAddressSanitizerPass(CompileKernel,
-false, true,
-false);
+[](AddressSanitizerOptions Opts) {
+  return ModuleAddressSanitizerPass(Opts);
 },
-parseModuleAddressSanitizerPassOptions,
+parseASanPassOptions,
 "kernel")
 #undef MODULE_PASS_WITH_PARAMS
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -106,7 +106,7 @@
 /// surrounding requested memory to be checked for invalid accesses.
 class AddressSanitizerPass : public PassInfoMixin {
 public:
-  explicit AddressSanitizerPass(AddressSanitizerOptions Options)
+  AddressSanitizerPass(const AddressSanitizerOptions )
   : Options(Options){};
   PreservedAnalyses run(Function , FunctionAnalysisManager );
   void printPipeline(raw_ostream ,
@@ -125,8 +125,8 @@
 class ModuleAddressSanitizerPass
 : public PassInfoMixin {
 public:
-  explicit ModuleAddressSanitizerPass(
-  bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = true,
+  ModuleAddressSanitizerPass(
+  const AddressSanitizerOptions , bool UseGlobalGC = true,
   bool UseOdrIndicator = false,
   AsanDtorKind DestructorKind = AsanDtorKind::Global);
   PreservedAnalyses run(Module , ModuleAnalysisManager );
@@ -135,8 +135,7 @@
   static bool isRequired() { return true; }
 
 private:
-  bool CompileKernel;
-  bool Recover;
+  AddressSanitizerOptions Options;
   bool UseGlobalGC;
   bool UseOdrIndicator;
   

[clang] ee4634f - [NFC][asan] Fix confusing variable name

2021-11-02 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-11-02T16:49:15-07:00
New Revision: ee4634f7feb38982bd90192e3d2866c07db3e065

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

LOG: [NFC][asan] Fix confusing variable name

There is no such thing as ModuleUseAfterScope.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 30f81b8ae473..534d98be4344 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1178,16 +1178,16 @@ static void addSanitizers(const Triple ,
   if (LangOpts.Sanitize.has(Mask)) {
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
 bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
-bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
+bool UseGlobalGC = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
 CodeGenOpts.getSanitizeAddressDtor();
 llvm::AsanDetectStackUseAfterReturnMode UseAfterReturn =
 CodeGenOpts.getSanitizeAddressUseAfterReturn();
 MPM.addPass(RequireAnalysisPass());
-MPM.addPass(ModuleAddressSanitizerPass(
-CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
-DestructorKind));
+MPM.addPass(ModuleAddressSanitizerPass(CompileKernel, Recover,
+   UseGlobalGC, UseOdrIndicator,
+   DestructorKind));
 MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
 {CompileKernel, Recover, UseAfterScope, UseAfterReturn})));
   }



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


[PATCH] D112941: [clang] Add support for the new pointer authentication builtins.

2021-11-02 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

The plan to push support for ptrauth_sign_constant, and 
ptrauth_type_discriminator/ptrauth_string_discriminator in a separate patch is 
good.
 This current patch is already big.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112941

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


[PATCH] D112941: [clang] Add support for the new pointer authentication builtins.

2021-11-02 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:839
+def err_ptrauth_disabled :
+  Error<"pointer authentication is disabled for the current target">;
+def err_ptrauth_invalid_key :

These two error types are confusing. 
In which situation would err_ptrauth_disabled be printed?
With this patch, it is only supported with arm64e triple, all other targets it 
is unsupported.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112941

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


[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-11-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D107049#3103984 , @lhames wrote:

> In D107049#3101456 , @dblaikie 
> wrote:
>
>> In D107049#3100630 , @rnk wrote:
>>
>>> So, to back up a bit, do I understand correctly that this change adds tests 
>>> to the check-clang test suite that JIT compiles C++ code for the host and 
>>> throws C++ exceptions? Can we reconsider that?
>>>
>>> We have a policy of not running execution tests in the clang test suite 
>>> because we know they always turn out to be unreliable, flaky, and highly 
>>> dependent on the environment rather than the code under test. Integration 
>>> tests are great, everyone needs them, but they should definitely not be 
>>> part of the default set of tests that developers run anywhere and 
>>> everywhere and expect to work out of the box, regardless of the 
>>> environment. +@dblaikie to confirm if I am off base here about our testing 
>>> strategy, and maybe Lang can advise us about past JIT testing strategies.
>>
>> Yeah, seems we've had some precedent for this for a while, as @lhames says 
>> (doing some archaeology I see one of the clang-interpreter tests added here, 
>> for instance: 
>> https://github.com/llvm/llvm-project/commit/1d487617f20ab9df65ab60d6cf9431ef288312ab
>
> Also all of the MJCIT and Orc tests in LLVM.

I think @rnk was asking/drawing a distinction between execution tests in LLVM 
(which is at least only testing LLVM code in LLVM) and execution tests in Clang 
(which is both execution, and cross-project) - so I was just talking about the 
Clang->LLVM->execution tests. Though I think in LLVM there'd also be some 
opportunity to find some ways to isolate/test JIT infrastructure with less 
execution (had sort of hoped in the early days of Orc that the layered 
architecture would allow more isolated/unit testing to robustly test pieces 
without execution for that testing).

>> I push back pretty hard on end-to-end tests in clang in most cases - one 
>> place that slips through either untested or with end to end tests is 
>> anything in MCOptions, etc, since they aren't in IR and are only observable 
>> through their effect on the resulting assembly. And JITs - I didn't actually 
>> know we had live JIT tests up in clang - and yeah, would rather we didn't - 
>> perhaps via a mode in such frontends that emits the IR at various points, 
>> but it'll be a pretty significant investment to make something fairly 
>> robust, I would imagine (sort of like lldb reproducers replays (which are 
>> being removed due to unmaintainability, by the sounds of it) but being able 
>> to stub out the actual execution) -  hmm, perhaps a remote execution mock 
>> would be feasible? That'd at least remove the execution part, make it 
>> portable to run on non-native environments - but wouldn't remove the 
>> end-to-end-ness, for that maybe you'd need a mock target that worked as 
>> though it ran IR natively, perhaps? Not sure.
>
> The LLVM MCJIT and Orc tests have been stable enough once we constrained the 
> environments that they run in. I don't see why this would be any less stable. 
> The features being exercised (essentially the object runtimes) are likely to 
> be more stable in practice than the environments being tested in the LLDB 
> tests.
>
>> Then maybe the more end-to-end-y tests could move out to cross-project-tests.
>
> Are you suggesting execution tests for cross-project-tests?

I think cross-project-tests (originally debuginfo-tests) has always had/been a 
place for execution tests. Not all of them, and still value in having lit-style 
non-execution cross-project tests where possible for more robust/variation 
testing where possible, with fewer full end-to-end-including-execution tests 
where possible (always going to be fuzzy lines of what's worth the 
cost/benefit, etc - and we're all going to have different points on that 
spectrum).


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

https://reviews.llvm.org/D107049

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-02 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein added a comment.

Hmm. When I try to compile an object file where the resolver is a declaration, 
both clang-13, clang-14, and gcc-9.3 complain that the ifunc must point to a 
defined function:

  void *foo_resolver();
  void foo(void) __attribute__((ifunc("foo_resolver")));

clang (13 and 14) complain:

  obj.c:2:31: error: ifunc must point to a defined function
  void foo(void) __attribute__((ifunc("foo_resolver")));
^
  1 error generated.

gcc 9.3.0 complains:

  obj.c:3:6: error: ‘foo’ aliased to undefined symbol ‘foo_resolver’
  3 | void foo(void) __attribute__((ifunc("foo_resolver")));
|  ^~~

I realize that the fact that frontends reject this doesn't necessarily mean 
that the IR they would have hypothetically produced is invalid, I'm just 
wondering about the semantics.
Drawing some parallels to GlobalAliases, you'll see that they also check that 
the aliasee is a definition rather than a declaration 
(`Verifier::visitAliaseeSubExpr`), which was the reason I added the same check 
to `Verifier::visitGlobalIFunc`.
Should an object file be produced with an UND ifunc symbol in that case? 
Wouldn't it be more correct to emit a plain old function declaration? (see 
`llvm/test/Linker/ifunc.ll` for behavior of linking an ifunc on top of a 
function declaration, should work correctly).

At the very least to alleviate the breakage I think we can just rip out the 
`Assert(!Resolver->isDeclarationForLinker(), "...")` from the Verifier, but I 
have a feeling that this is not the right long-term solution.

The cpu_specific/cpu_dispatch attributes are completely new to me, so bear with 
me if I'm misunderstanding; wouldn't the following implementation both provide 
the correct semantics and avoid an ifunc-with-an-undefined-resolver situation?

- The cpu_specific attribute emits
  1. A Function Declaration with a computed name "x.ifunc"
  2. A single Function with the cpu-specific body
  3. Multiple GlobalAliases with computed named whose aliasee is the function 
from 2)
- The cpu_dispatch attribute emits a strongly-defined non-interposable ifunc 
with the same computed name "x.ifunc", and a hidden defined resolver. Both IR 
linking and regular linking should resolve the plain 
function-delcaration-references to the ifunc properly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

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


[PATCH] D112883: [bazel] Re-introduce `copts` hacks for lib/AST includes.

2021-11-02 Thread Geoffrey Martin-Noble via Phabricator via cfe-commits
GMNGeoffrey added a comment.

In D112883#3101685 , @GMNGeoffrey 
wrote:

> In D112883#3101665 , @chandlerc 
> wrote:
>
>> However, I thought with Bazel having a consistent repo name was important to 
>> allow cross-repo dependencies to reliably resolve, and so maybe this isn't 
>> that bad of a thing to rely on?
>
> I think cross-repo dependencies just tend to only work by chance. I haven't 
> seen any specific guidance for how to name repository, so I don't think it 
> can really be relied upon. Bazel has functionality in `local_repository` 
> specifically to remap repository names 
> (https://docs.bazel.build/versions/main/be/workspace.html#local_repository.repo_mapping),
>  but of course it's only available in local_repository and there's no way to 
> compose it.

I recently learned that apparently `repo_mapping` works for *all* repository 
rules. That's just not documented anywhere: 
https://github.com/bazelbuild/bazel/issues/10410. So yeah relying on repository 
naming is for sure a bug. Of course, so are all the other options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112883

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


[PATCH] D112647: [clang-apply-replacements] Correctly handle relative paths

2021-11-02 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang updated this revision to Diff 384239.
avogelsgesang marked 2 inline comments as done.
avogelsgesang added a comment.

Use `llvm::Optional` instead of pointer as suggested by @ymandel


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112647

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
  
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
  clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp

Index: clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp
@@ -0,0 +1,7 @@
+// RUN: mkdir -p %T/Inputs/relative-paths
+// RUN: mkdir -p %T/Inputs/relative-paths/subdir
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/relative-paths/basic.h > %T/Inputs/relative-paths/basic.h
+// RUN: sed "s#\$(path)#%/T/Inputs/relative-paths#" %S/Inputs/relative-paths/file1.yaml > %T/Inputs/relative-paths/file1.yaml
+// RUN: sed "s#\$(path)#%/T/Inputs/relative-paths#" %S/Inputs/relative-paths/file2.yaml > %T/Inputs/relative-paths/file2.yaml
+// RUN: clang-apply-replacements %T/Inputs/relative-paths
+// RUN: FileCheck -input-file=%T/Inputs/relative-paths/basic.h %S/Inputs/relative-paths/basic.h
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml
@@ -0,0 +1,15 @@
+---
+MainSourceFile: source2.cpp
+Diagnostics:
+  - BuildDirectory: $(path)
+DiagnosticName: test-relative-path
+DiagnosticMessage:
+  Message: Fix
+  FilePath: ./basic.h
+  FileOffset: 148
+  Replacements:
+- FilePath:./basic.h
+  Offset:  298
+  Length:  1
+  ReplacementText: elem
+...
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml
@@ -0,0 +1,27 @@
+---
+MainSourceFile: source1.cpp
+Diagnostics:
+  - BuildDirectory: $(path)/subdir/
+DiagnosticName: test-relative-path
+DiagnosticMessage:
+  Message: Fix
+  FilePath: ../relative-path.h
+  FileOffset: 242
+  Replacements:
+- FilePath:../basic.h
+  Offset:  242
+  Length:  26
+  ReplacementText: 'auto & elem : ints'
+- FilePath:$(path)/basic.h
+  Offset:  276
+  Length:  22
+  ReplacementText: ''
+- FilePath:../basic.h
+  Offset:  298
+  Length:  1
+  ReplacementText: elem
+- FilePath:../../relative-paths/basic.h
+  Offset:  148
+  Length:  0
+  ReplacementText: 'override '
+...
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h
@@ -0,0 +1,32 @@
+#ifndef BASIC_H
+#define BASIC_H
+
+
+class Parent {
+public:
+  virtual void func() {}
+};
+
+class Derived : public Parent {
+public:
+  virtual void func() {}
+  // CHECK: virtual void func() override {}
+};
+
+extern void ext(int (&)[5], const Parent &);
+
+void func(int t) {
+  int ints[5];
+  for (unsigned i = 0; i < 5; ++i) {
+int  = ints[i];
+e = t;
+// CHECK: for (auto & elem : ints) {
+// CHECK-NEXT: elem = t;
+  }
+
+  Derived d;
+
+  ext(ints, d);
+}
+
+#endif // BASIC_H
Index: clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -23,6 +23,7 @@
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -152,9 +153,14 @@
   DiagReplacements;
 
   auto AddToGroup = [&](const tooling::Replacement ,
-const tooling::TranslationUnitDiagnostics *SourceTU) {
+const tooling::TranslationUnitDiagnostics *SourceTU,
+

[PATCH] D112914: Misleading identifier detection

2021-11-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h:2
+//===--- MisleadingIdentifierCheck.h - clang-tidy *- 
C++
+//-*-===//
+//

This needs fixing too.


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

https://reviews.llvm.org/D112914

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


[PATCH] D112913: Misleading bidirectional detection

2021-11-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp:59
+// If conversion fails, utf-8 is designed so that we can just try next 
char.
+if (Result != llvm::conversionOK) {
+  ++CurPtr;

Is there a guarantee that `convertUTF8Sequence` doesn't update `CurPtr` on 
error? I'm concerned we might increment *past* the end in the case where 
`CurPtr` points to the end, below, which would at least formally be UB.


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

https://reviews.llvm.org/D112913

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


[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-11-02 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

You are absolutely right. X86 variant uses an "=a" constraint (rax register), 
others pin the output variable to a specific register with __asm__ declaration. 
It appears we've missed it in Aarch64.

Could you check if __asm__("x0") in the declaration of res helps?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-11-02 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a comment.

> [...] If we want to follow container-size-empty's convention, we should 
> include the replaced method in the name [...]

Note that this commit is slightly different from `container-size-empty`: it 
doesn't only replace `count(...)` by `contains(...)` but also replaces `find() 
== end()` by `contains`. So I guess the name would have to be 
`container-count-begin-end-contains` or similar... which would be a bit much in 
my opinion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[clang] 60a085b - Revert "[clang] deprecate frelaxed-template-template-args, make it on by default"

2021-11-02 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-11-02T17:02:19-04:00
New Revision: 60a085beb04b055cf44c379c56cb247cb3587658

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

LOG: Revert "[clang] deprecate frelaxed-template-template-args, make it on by 
default"

This reverts commit 2d7fba5f95f0614f6f2c4a4ed966b307d617898b.

The patch was reverted because it caused regression with rocThrust
due to ambiguity of template specialization.

For details please see https://reviews.llvm.org/D109496

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
clang/test/Lexer/cxx-features.cpp
clang/test/SemaTemplate/deduction.cpp
clang/test/SemaTemplate/default-arguments.cpp
clang/test/SemaTemplate/instantiate-template-template-parm.cpp
clang/test/SemaTemplate/nested-template.cpp
clang/test/SemaTemplate/temp_arg_template.cpp
clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
clang/www/cxx_status.html

Removed: 
clang/test/Driver/frelaxed-template-template-args.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index b823ade0eafb5..fa464952189ba 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -355,7 +355,7 @@ def warn_drv_diagnostics_hotness_requires_pgo : Warning<
 def warn_drv_clang_unsupported : Warning<
   "the clang compiler does not support '%0'">;
 def warn_drv_deprecated_arg : Warning<
-  "argument '%0' is deprecated%select{|, use '%2' instead}1">, 
InGroup;
+  "argument '%0' is deprecated, use '%1' instead">, InGroup;
 def warn_drv_assuming_mfloat_abi_is : Warning<
   "unknown platform, assuming -mfloat-abi=%0">;
 def warn_ignoring_ftabstop_value : Warning<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 565ecd94f977c..4651f4fff6aa0 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -149,7 +149,7 @@ LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin 
functions")
 LANGOPT(GNUAsm, 1, 1, "GNU-style inline assembly")
 LANGOPT(Coroutines, 1, 0, "C++20 coroutines")
 LANGOPT(DllExportInlines  , 1, 1, "dllexported classes dllexport inline 
methods")
-LANGOPT(RelaxedTemplateTemplateArgs, 1, 1, "C++17 relaxed matching of template 
template arguments")
+LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of template 
template arguments")
 
 LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for 
all language standard modes")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0d3c053e89ae4..b4a2411fa5c5c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2335,9 +2335,9 @@ defm application_extension : 
BoolFOption<"application-extension",
   PosFlag,
   NegFlag>;
 defm relaxed_template_template_args : 
BoolFOption<"relaxed-template-template-args",
-  LangOpts<"RelaxedTemplateTemplateArgs">, DefaultTrue,
-  PosFlag,
-  NegFlag>;
+  LangOpts<"RelaxedTemplateTemplateArgs">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 defm sized_deallocation : BoolFOption<"sized-deallocation",
   LangOpts<"SizedDeallocation">, DefaultFalse,
   PosFlag,

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 6f426c6cad69c..36579060d8a26 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -683,8 +683,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
 Arg->claim();
 if (LegacySanitizeCoverage != 0) {
   D.Diag(diag::warn_drv_deprecated_arg)
-  << Arg->getAsString(Args) << true
-  << "-fsanitize-coverage=trace-pc-guard";
+  << Arg->getAsString(Args) << 
"-fsanitize-coverage=trace-pc-guard";
 }
 continue;
   }
@@ -719,11 +718,11 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
   // enabled.
   if (CoverageFeatures & CoverageTraceBB)
 D.Diag(clang::diag::warn_drv_deprecated_arg)
-<< "-fsanitize-coverage=trace-bb" << true
+<< "-fsanitize-coverage=trace-bb"
 << "-fsanitize-coverage=trace-pc-guard";
   if (CoverageFeatures & Coverage8bitCounters)
 D.Diag(clang::diag::warn_drv_deprecated_arg)
-<< "-fsanitize-coverage=8bit-counters" << true
+<< 

[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2021-11-02 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 384220.
Jake-Egan added a comment.

Fix llvm/test/DebugInfo/omit-empty.ll.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113049

Files:
  clang/test/ASTMerge/anonymous-fields/test.cpp
  clang/test/ASTMerge/codegen-body/test.c
  clang/test/ASTMerge/injected-class-name-decl/test.cpp
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/ClangScanDeps/resource_directory.c
  clang/test/CodeGenCXX/crash.cpp
  clang/test/CodeGenCXX/ubsan-coroutines.cpp
  clang/test/Driver/as-version.s
  clang/test/Driver/cc-print-proc-stat.c
  clang/test/Driver/compilation_database.c
  clang/test/Driver/modules-ts.cpp
  clang/test/Driver/report-stat.c
  clang/test/Misc/clear-ast-before-backend.c
  clang/test/Misc/time-passes.c
  clang/test/Modules/DebugInfoSubmodules.c
  clang/test/Modules/lsv-debuginfo.cpp
  clang/test/Modules/odr_hash-Friend.cpp
  clang/test/Modules/path-resolution.modulemap
  clang/test/Modules/self-referencing-lambda.cpp
  clang/test/PCH/debug-info-pch-container-path.c
  clang/test/PCH/debug-info-pch-path.c
  clang/test/PCH/pch-hdrstop-warn.cpp
  clang/test/PCH/pch-hdrstop.cpp
  clang/test/PCH/pch-no-hdrstop.cpp
  clang/test/PCH/pch-through4.cpp
  clang/test/PCH/pch-through4a.cpp
  llvm/test/CodeGen/X86/dbg-distringtype-uint.ll
  llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll
  llvm/test/DebugInfo/Generic/2010-05-10-MultipleCU.ll
  llvm/test/DebugInfo/Generic/DICommonBlock.ll
  llvm/test/DebugInfo/Generic/PR20038.ll
  llvm/test/DebugInfo/Generic/constant-pointers.ll
  llvm/test/DebugInfo/Generic/containing-type-extension.ll
  llvm/test/DebugInfo/Generic/cross-cu-inlining.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce.ll
  llvm/test/DebugInfo/Generic/cu-range-hole.ll
  llvm/test/DebugInfo/Generic/cu-ranges.ll
  llvm/test/DebugInfo/Generic/dead-argument-order.ll
  llvm/test/DebugInfo/Generic/debug-info-enum.ll
  llvm/test/DebugInfo/Generic/debug-info-qualifiers.ll
  llvm/test/DebugInfo/Generic/debug-label-inline.ll
  llvm/test/DebugInfo/Generic/debug-label.ll
  llvm/test/DebugInfo/Generic/debug-names-empty-cu.ll
  llvm/test/DebugInfo/Generic/def-line.ll
  llvm/test/DebugInfo/Generic/discriminated-union.ll
  llvm/test/DebugInfo/Generic/discriminator.ll
  llvm/test/DebugInfo/Generic/disubrange_vla.ll
  llvm/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll
  llvm/test/DebugInfo/Generic/dwarf-public-names.ll
  llvm/test/DebugInfo/Generic/empty.ll
  llvm/test/DebugInfo/Generic/enum.ll
  llvm/test/DebugInfo/Generic/fortran-subprogram-attr.ll
  llvm/test/DebugInfo/Generic/global.ll
  llvm/test/DebugInfo/Generic/gmlt.test
  llvm/test/DebugInfo/Generic/gmlt_profiling.ll
  llvm/test/DebugInfo/Generic/imported-name-inlined.ll
  llvm/test/DebugInfo/Generic/incorrect-variable-debugloc.ll
  llvm/test/DebugInfo/Generic/inline-scopes.ll
  llvm/test/DebugInfo/Generic/inlined-arguments.ll
  llvm/test/DebugInfo/Generic/inlined-strings.ll
  llvm/test/DebugInfo/Generic/linkage-name-abstract.ll
  llvm/test/DebugInfo/Generic/lto-comp-dir.ll
  llvm/test/DebugInfo/Generic/mainsubprogram.ll
  llvm/test/DebugInfo/Generic/member-order.ll
  llvm/test/DebugInfo/Generic/member-pointers.ll
  llvm/test/DebugInfo/Generic/namespace_function_definition.ll
  llvm/test/DebugInfo/Generic/namespace_inline_function_definition.ll
  llvm/test/DebugInfo/Generic/no-empty-child-vars.ll
  llvm/test/DebugInfo/Generic/noscopes.ll
  llvm/test/DebugInfo/Generic/pass-by-value.ll
  llvm/test/DebugInfo/Generic/ptrsize.ll
  llvm/test/DebugInfo/Generic/recursive_inlining.ll
  llvm/test/DebugInfo/Generic/skeletoncu.ll
  llvm/test/DebugInfo/Generic/sugared-constants.ll
  llvm/test/DebugInfo/Generic/template-recursive-void.ll
  llvm/test/DebugInfo/Generic/thrownTypes.ll
  llvm/test/DebugInfo/Generic/two-cus-from-same-file.ll
  llvm/test/DebugInfo/Generic/typedef.ll
  llvm/test/DebugInfo/Generic/unconditional-branch.ll
  llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll
  llvm/test/DebugInfo/Generic/version.ll
  llvm/test/DebugInfo/Generic/virtual-index.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange_const.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange_count.ll
  llvm/test/DebugInfo/X86/dwarfdump-rankConst.ll
  llvm/test/DebugInfo/X86/dwarfdump-rankExp.ll
  llvm/test/DebugInfo/X86/dwarfdump-signed_const.ll
  llvm/test/DebugInfo/X86/global-constants.ll
  llvm/test/DebugInfo/X86/invalid-global-constants.ll
  llvm/test/DebugInfo/cross-cu-scope.ll
  llvm/test/DebugInfo/dwo.ll
  llvm/test/DebugInfo/omit-empty.ll
  llvm/test/DebugInfo/skeletoncu.ll
  llvm/test/LTO/X86/bcsection.ll
  

[PATCH] D113043: [mlir][sparse] Rename SparseUtils.cpp file to SparseTensorUtils.cpp

2021-11-02 Thread Aart Bik via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8a91bc7bf436: [mlir][sparse] Rename SparseUtils.cpp file to 
SparseTensorUtils.cpp (authored by HarrietAkot, committed by aartbik).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113043

Files:
  clang/docs/tools/clang-formatted-files.txt
  mlir/lib/ExecutionEngine/CMakeLists.txt
  mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
  mlir/lib/ExecutionEngine/SparseUtils.cpp


Index: mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
===
--- mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -1,4 +1,4 @@
-//===- SparseUtils.cpp - Sparse Utils for MLIR execution 
--===//
+//===- SparseTensorUtils.cpp - Sparse Tensor Utils for MLIR execution 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -5,7 +5,7 @@
   AsyncRuntime.cpp
   CRunnerUtils.cpp
   CudaRuntimeWrappers.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
   ExecutionEngine.cpp
   RocmRuntimeWrappers.cpp
   RunnerUtils.cpp
@@ -79,7 +79,7 @@
 add_mlir_library(mlir_c_runner_utils
   SHARED
   CRunnerUtils.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
 
   EXCLUDE_FROM_LIBMLIR
   )
Index: clang/docs/tools/clang-formatted-files.txt
===
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -7406,7 +7406,7 @@
 mlir/lib/ExecutionEngine/OptUtils.cpp
 mlir/lib/ExecutionEngine/RocmRuntimeWrappers.cpp
 mlir/lib/ExecutionEngine/RunnerUtils.cpp
-mlir/lib/ExecutionEngine/SparseUtils.cpp
+mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
 mlir/lib/Interfaces/CallInterfaces.cpp
 mlir/lib/Interfaces/CastInterfaces.cpp
 mlir/lib/Interfaces/ControlFlowInterfaces.cpp


Index: mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
===
--- mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -1,4 +1,4 @@
-//===- SparseUtils.cpp - Sparse Utils for MLIR execution --===//
+//===- SparseTensorUtils.cpp - Sparse Tensor Utils for MLIR execution -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -5,7 +5,7 @@
   AsyncRuntime.cpp
   CRunnerUtils.cpp
   CudaRuntimeWrappers.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
   ExecutionEngine.cpp
   RocmRuntimeWrappers.cpp
   RunnerUtils.cpp
@@ -79,7 +79,7 @@
 add_mlir_library(mlir_c_runner_utils
   SHARED
   CRunnerUtils.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
 
   EXCLUDE_FROM_LIBMLIR
   )
Index: clang/docs/tools/clang-formatted-files.txt
===
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -7406,7 +7406,7 @@
 mlir/lib/ExecutionEngine/OptUtils.cpp
 mlir/lib/ExecutionEngine/RocmRuntimeWrappers.cpp
 mlir/lib/ExecutionEngine/RunnerUtils.cpp
-mlir/lib/ExecutionEngine/SparseUtils.cpp
+mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
 mlir/lib/Interfaces/CallInterfaces.cpp
 mlir/lib/Interfaces/CastInterfaces.cpp
 mlir/lib/Interfaces/ControlFlowInterfaces.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8a91bc7 - [mlir][sparse] Rename SparseUtils.cpp file to SparseTensorUtils.cpp

2021-11-02 Thread Aart Bik via cfe-commits

Author: HarrietAkot
Date: 2021-11-02T13:54:33-07:00
New Revision: 8a91bc7bf436d345cc1b26d0073753a7f5e66e10

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

LOG: [mlir][sparse] Rename SparseUtils.cpp file to SparseTensorUtils.cpp

Bug 52304 - Rename the sparse runtime support library cpp file

Reviewed By: aartbik

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

Added: 
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp

Modified: 
clang/docs/tools/clang-formatted-files.txt
mlir/lib/ExecutionEngine/CMakeLists.txt

Removed: 
mlir/lib/ExecutionEngine/SparseUtils.cpp



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 45451c9090b50..8b3b480f719e6 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -7406,7 +7406,7 @@ mlir/lib/ExecutionEngine/JitRunner.cpp
 mlir/lib/ExecutionEngine/OptUtils.cpp
 mlir/lib/ExecutionEngine/RocmRuntimeWrappers.cpp
 mlir/lib/ExecutionEngine/RunnerUtils.cpp
-mlir/lib/ExecutionEngine/SparseUtils.cpp
+mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
 mlir/lib/Interfaces/CallInterfaces.cpp
 mlir/lib/Interfaces/CastInterfaces.cpp
 mlir/lib/Interfaces/ControlFlowInterfaces.cpp

diff  --git a/mlir/lib/ExecutionEngine/CMakeLists.txt 
b/mlir/lib/ExecutionEngine/CMakeLists.txt
index 97e354cdba299..d630a3cb17956 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_OPTIONAL_SOURCES
   AsyncRuntime.cpp
   CRunnerUtils.cpp
   CudaRuntimeWrappers.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
   ExecutionEngine.cpp
   RocmRuntimeWrappers.cpp
   RunnerUtils.cpp
@@ -79,7 +79,7 @@ add_mlir_library(MLIRJitRunner
 add_mlir_library(mlir_c_runner_utils
   SHARED
   CRunnerUtils.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
 
   EXCLUDE_FROM_LIBMLIR
   )

diff  --git a/mlir/lib/ExecutionEngine/SparseUtils.cpp 
b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
similarity index 99%
rename from mlir/lib/ExecutionEngine/SparseUtils.cpp
rename to mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
index 24b60300a760f..fcdc23104ae3a 100644
--- a/mlir/lib/ExecutionEngine/SparseUtils.cpp
+++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -1,4 +1,4 @@
-//===- SparseUtils.cpp - Sparse Utils for MLIR execution 
--===//
+//===- SparseTensorUtils.cpp - Sparse Tensor Utils for MLIR execution 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.



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


[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2021-11-02 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan created this revision.
Herald added subscribers: ormris, lxfind, pengfei, arphaman, steven_wu, 
hiraditya.
Jake-Egan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113049

Files:
  clang/test/ASTMerge/anonymous-fields/test.cpp
  clang/test/ASTMerge/codegen-body/test.c
  clang/test/ASTMerge/injected-class-name-decl/test.cpp
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/ClangScanDeps/resource_directory.c
  clang/test/CodeGenCXX/crash.cpp
  clang/test/CodeGenCXX/ubsan-coroutines.cpp
  clang/test/Driver/as-version.s
  clang/test/Driver/cc-print-proc-stat.c
  clang/test/Driver/compilation_database.c
  clang/test/Driver/modules-ts.cpp
  clang/test/Driver/report-stat.c
  clang/test/Misc/clear-ast-before-backend.c
  clang/test/Misc/time-passes.c
  clang/test/Modules/DebugInfoSubmodules.c
  clang/test/Modules/lsv-debuginfo.cpp
  clang/test/Modules/odr_hash-Friend.cpp
  clang/test/Modules/path-resolution.modulemap
  clang/test/Modules/self-referencing-lambda.cpp
  clang/test/PCH/debug-info-pch-container-path.c
  clang/test/PCH/debug-info-pch-path.c
  clang/test/PCH/pch-hdrstop-warn.cpp
  clang/test/PCH/pch-hdrstop.cpp
  clang/test/PCH/pch-no-hdrstop.cpp
  clang/test/PCH/pch-through4.cpp
  clang/test/PCH/pch-through4a.cpp
  llvm/test/CodeGen/X86/dbg-distringtype-uint.ll
  llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll
  llvm/test/DebugInfo/Generic/2010-05-10-MultipleCU.ll
  llvm/test/DebugInfo/Generic/DICommonBlock.ll
  llvm/test/DebugInfo/Generic/PR20038.ll
  llvm/test/DebugInfo/Generic/constant-pointers.ll
  llvm/test/DebugInfo/Generic/containing-type-extension.ll
  llvm/test/DebugInfo/Generic/cross-cu-inlining.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce.ll
  llvm/test/DebugInfo/Generic/cu-range-hole.ll
  llvm/test/DebugInfo/Generic/cu-ranges.ll
  llvm/test/DebugInfo/Generic/dead-argument-order.ll
  llvm/test/DebugInfo/Generic/debug-info-enum.ll
  llvm/test/DebugInfo/Generic/debug-info-qualifiers.ll
  llvm/test/DebugInfo/Generic/debug-label-inline.ll
  llvm/test/DebugInfo/Generic/debug-label.ll
  llvm/test/DebugInfo/Generic/debug-names-empty-cu.ll
  llvm/test/DebugInfo/Generic/def-line.ll
  llvm/test/DebugInfo/Generic/discriminated-union.ll
  llvm/test/DebugInfo/Generic/discriminator.ll
  llvm/test/DebugInfo/Generic/disubrange_vla.ll
  llvm/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll
  llvm/test/DebugInfo/Generic/dwarf-public-names.ll
  llvm/test/DebugInfo/Generic/empty.ll
  llvm/test/DebugInfo/Generic/enum.ll
  llvm/test/DebugInfo/Generic/fortran-subprogram-attr.ll
  llvm/test/DebugInfo/Generic/global.ll
  llvm/test/DebugInfo/Generic/gmlt.test
  llvm/test/DebugInfo/Generic/gmlt_profiling.ll
  llvm/test/DebugInfo/Generic/imported-name-inlined.ll
  llvm/test/DebugInfo/Generic/incorrect-variable-debugloc.ll
  llvm/test/DebugInfo/Generic/inline-scopes.ll
  llvm/test/DebugInfo/Generic/inlined-arguments.ll
  llvm/test/DebugInfo/Generic/inlined-strings.ll
  llvm/test/DebugInfo/Generic/linkage-name-abstract.ll
  llvm/test/DebugInfo/Generic/lto-comp-dir.ll
  llvm/test/DebugInfo/Generic/mainsubprogram.ll
  llvm/test/DebugInfo/Generic/member-order.ll
  llvm/test/DebugInfo/Generic/member-pointers.ll
  llvm/test/DebugInfo/Generic/namespace_function_definition.ll
  llvm/test/DebugInfo/Generic/namespace_inline_function_definition.ll
  llvm/test/DebugInfo/Generic/no-empty-child-vars.ll
  llvm/test/DebugInfo/Generic/noscopes.ll
  llvm/test/DebugInfo/Generic/pass-by-value.ll
  llvm/test/DebugInfo/Generic/ptrsize.ll
  llvm/test/DebugInfo/Generic/recursive_inlining.ll
  llvm/test/DebugInfo/Generic/skeletoncu.ll
  llvm/test/DebugInfo/Generic/sugared-constants.ll
  llvm/test/DebugInfo/Generic/template-recursive-void.ll
  llvm/test/DebugInfo/Generic/thrownTypes.ll
  llvm/test/DebugInfo/Generic/two-cus-from-same-file.ll
  llvm/test/DebugInfo/Generic/typedef.ll
  llvm/test/DebugInfo/Generic/unconditional-branch.ll
  llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll
  llvm/test/DebugInfo/Generic/version.ll
  llvm/test/DebugInfo/Generic/virtual-index.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange_const.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange_count.ll
  llvm/test/DebugInfo/X86/dwarfdump-rankConst.ll
  llvm/test/DebugInfo/X86/dwarfdump-rankExp.ll
  llvm/test/DebugInfo/X86/dwarfdump-signed_const.ll
  llvm/test/DebugInfo/X86/global-constants.ll
  llvm/test/DebugInfo/X86/invalid-global-constants.ll
  llvm/test/DebugInfo/cross-cu-scope.ll
  llvm/test/DebugInfo/dwo.ll
  llvm/test/DebugInfo/omit-empty.ll
  llvm/test/DebugInfo/skeletoncu.ll
 

[PATCH] D113043: [mlir][sparse] Rename SparseUtils.cpp file to SparseTensorUtils.cpp

2021-11-02 Thread Aart Bik via Phabricator via cfe-commits
aartbik accepted this revision.
aartbik added a comment.
This revision is now accepted and ready to land.

I removed the quotes from the title, no need for these. Also, please address 
the last open question (on arc diff --update).

But good to go as revision.

I have approved the revision and will submit this one for you. Congrats on your 
first contribution or sparse compilation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113043

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


[PATCH] D113043: "[mlir][sparse]Rename SparseUtils.cpp library to SparseTensorUtils.cpp"

2021-11-02 Thread Akot Harriet Peace via Phabricator via cfe-commits
HarrietAkot added a comment.

In D113043#3103979 , @aartbik wrote:

> Did you see my comment on clang/docs/tools/clang-formatted-files.txt?
> You will need to update that file too (SparseUtils.cpp -> 
> SparseTensorUtils.cpp)
>
> after that this revision is good to go!
> (do you have submit rights, or do you want me to do that, once we are there?)

I have made the changes to the clang-formatted-files.txt. Kindly submit this 
revision for me. Thank you




Comment at: mlir/lib/ExecutionEngine/SparseTensorUtils.cpp:1
-//===- SparseUtils.cpp - Sparse Utils for MLIR execution 
--===//
+//===- SparseTensorUtils.cpp - Sparse Utils for MLIR execution 
===//
 //

aartbik wrote:
> While you are here, how about changing the contents to
> 
> //===- SparseTensorUtils.cpp - Sparse tensor utils for MLIR execution 
> 
> to make it more consistent with the name
Done :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113043

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


[PATCH] D113043: "[mlir][sparse]Rename SparseUtils.cpp library to SparseTensorUtils.cpp"

2021-11-02 Thread Aart Bik via Phabricator via cfe-commits
aartbik added a comment.

One last question, I just noticed you started a whole new revision (instead of 
updating https://reviews.llvm.org/D112995).

Was that intentional?

If you use arc, then arc diff  first time creates one, but subsequent 
updates should use arc diff ... --update D to make sure we stay in one 
revision.
It is not a big deal, we can proceed with this one and abandon the other, but 
just making sure you are aware of the procedure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113043

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


[PATCH] D109496: [clang] deprecate frelaxed-template-template-args, make it on by default

2021-11-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D109496#3103978 , @mizvekov wrote:

> Feel free to revert it if this is blocking you. I don't seem to find a way to 
> do it via web interface, so I need more time to have access to a machine that 
> can do it

I will revert it since it is blocking us. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109496

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


[PATCH] D109496: [clang] deprecate frelaxed-template-template-args, make it on by default

2021-11-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D109496#3103963 , @mizvekov wrote:

> Thanks for reporting this!
>
> This change in the standard was worked a long time ago, and there was some 
> expectation that there would be follow up work to add new partial ordering 
> rules so that reasonable code would keep working. But the person behind that 
> effort stopped participating in the process, so this fell into the cracks.
>
> We tried with this patch here to see if the rules would just work out as 
> intended. Another option, which I believe is what GCC does, is to not do the 
> DR part and apply it only to c++17 and later.
> However the breakage example you posted seems to be from a CUDA library which 
> is not usable in the GCC ecosystem, is that correct? And that this library 
> might be modern and used with newer standard as well?
>
> If that is the case, the GCC solution might not be good for us anyway, and 
> the simplest thing would be to just implement some new rules.

The regression happens with rocThrust, which is CUDA Thrust ported to HIP 
language. However, I think the same issue would happen to CUDA Thrust.

These libraries need to work with C++17, therefore it is better to implement 
some new rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109496

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


[PATCH] D113043: "[mlir][sparse]Rename SparseUtils.cpp library to SparseTensorUtils.cpp"

2021-11-02 Thread Akot Harriet Peace via Phabricator via cfe-commits
HarrietAkot updated this revision to Diff 384203.
HarrietAkot marked an inline comment as done.
HarrietAkot added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- "Updating clang-formatted-files"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113043

Files:
  clang/docs/tools/clang-formatted-files.txt
  mlir/lib/ExecutionEngine/CMakeLists.txt
  mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
  mlir/lib/ExecutionEngine/SparseUtils.cpp


Index: mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
===
--- mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -1,4 +1,4 @@
-//===- SparseUtils.cpp - Sparse Utils for MLIR execution 
--===//
+//===- SparseTensorUtils.cpp - Sparse Tensor Utils for MLIR execution 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -5,7 +5,7 @@
   AsyncRuntime.cpp
   CRunnerUtils.cpp
   CudaRuntimeWrappers.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
   ExecutionEngine.cpp
   RocmRuntimeWrappers.cpp
   RunnerUtils.cpp
@@ -79,7 +79,7 @@
 add_mlir_library(mlir_c_runner_utils
   SHARED
   CRunnerUtils.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
 
   EXCLUDE_FROM_LIBMLIR
   )
Index: clang/docs/tools/clang-formatted-files.txt
===
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -7406,7 +7406,7 @@
 mlir/lib/ExecutionEngine/OptUtils.cpp
 mlir/lib/ExecutionEngine/RocmRuntimeWrappers.cpp
 mlir/lib/ExecutionEngine/RunnerUtils.cpp
-mlir/lib/ExecutionEngine/SparseUtils.cpp
+mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
 mlir/lib/Interfaces/CallInterfaces.cpp
 mlir/lib/Interfaces/CastInterfaces.cpp
 mlir/lib/Interfaces/ControlFlowInterfaces.cpp


Index: mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
===
--- mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -1,4 +1,4 @@
-//===- SparseUtils.cpp - Sparse Utils for MLIR execution --===//
+//===- SparseTensorUtils.cpp - Sparse Tensor Utils for MLIR execution -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -5,7 +5,7 @@
   AsyncRuntime.cpp
   CRunnerUtils.cpp
   CudaRuntimeWrappers.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
   ExecutionEngine.cpp
   RocmRuntimeWrappers.cpp
   RunnerUtils.cpp
@@ -79,7 +79,7 @@
 add_mlir_library(mlir_c_runner_utils
   SHARED
   CRunnerUtils.cpp
-  SparseUtils.cpp
+  SparseTensorUtils.cpp
 
   EXCLUDE_FROM_LIBMLIR
   )
Index: clang/docs/tools/clang-formatted-files.txt
===
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -7406,7 +7406,7 @@
 mlir/lib/ExecutionEngine/OptUtils.cpp
 mlir/lib/ExecutionEngine/RocmRuntimeWrappers.cpp
 mlir/lib/ExecutionEngine/RunnerUtils.cpp
-mlir/lib/ExecutionEngine/SparseUtils.cpp
+mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
 mlir/lib/Interfaces/CallInterfaces.cpp
 mlir/lib/Interfaces/CastInterfaces.cpp
 mlir/lib/Interfaces/ControlFlowInterfaces.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-11-02 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In D107049#3101456 , @dblaikie wrote:

> In D107049#3100630 , @rnk wrote:
>
>> So, to back up a bit, do I understand correctly that this change adds tests 
>> to the check-clang test suite that JIT compiles C++ code for the host and 
>> throws C++ exceptions? Can we reconsider that?
>>
>> We have a policy of not running execution tests in the clang test suite 
>> because we know they always turn out to be unreliable, flaky, and highly 
>> dependent on the environment rather than the code under test. Integration 
>> tests are great, everyone needs them, but they should definitely not be part 
>> of the default set of tests that developers run anywhere and everywhere and 
>> expect to work out of the box, regardless of the environment. +@dblaikie to 
>> confirm if I am off base here about our testing strategy, and maybe Lang can 
>> advise us about past JIT testing strategies.
>
> Yeah, seems we've had some precedent for this for a while, as @lhames says 
> (doing some archaeology I see one of the clang-interpreter tests added here, 
> for instance: 
> https://github.com/llvm/llvm-project/commit/1d487617f20ab9df65ab60d6cf9431ef288312ab

Also all of the MJCIT and Orc tests in LLVM.

> I push back pretty hard on end-to-end tests in clang in most cases - one 
> place that slips through either untested or with end to end tests is anything 
> in MCOptions, etc, since they aren't in IR and are only observable through 
> their effect on the resulting assembly. And JITs - I didn't actually know we 
> had live JIT tests up in clang - and yeah, would rather we didn't - perhaps 
> via a mode in such frontends that emits the IR at various points, but it'll 
> be a pretty significant investment to make something fairly robust, I would 
> imagine (sort of like lldb reproducers replays (which are being removed due 
> to unmaintainability, by the sounds of it) but being able to stub out the 
> actual execution) -  hmm, perhaps a remote execution mock would be feasible? 
> That'd at least remove the execution part, make it portable to run on 
> non-native environments - but wouldn't remove the end-to-end-ness, for that 
> maybe you'd need a mock target that worked as though it ran IR natively, 
> perhaps? Not sure.

The LLVM MCJIT and Orc tests have been stable enough once we constrained the 
environments that they run in. I don't see why this would be any less stable. 
The features being exercised (essentially the object runtimes) are likely to be 
more stable in practice than the environments being tested in the LLDB tests.

> Then maybe the more end-to-end-y tests could move out to cross-project-tests.

Are you suggesting execution tests for cross-project-tests?


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

https://reviews.llvm.org/D107049

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


[PATCH] D109496: [clang] deprecate frelaxed-template-template-args, make it on by default

2021-11-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Feel free to revert it if this is blocking you. I don't seem to find a way to 
do it via web interface, so I need more time to have access to a machine that 
can do it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109496

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


[PATCH] D109496: [clang] deprecate frelaxed-template-template-args, make it on by default

2021-11-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Thanks for reporting this!

This change in the standard was worked a long time ago, and there was some 
expectation that there would be follow up work to add new partial ordering 
rules so that reasonable code would keep working. But the person behind that 
effort stopped participating in the process, so this fell into the cracks.

We tried with this patch here to see if the rules would just work out as 
intended. Another option, which I believe is what GCC does, is to not do the DR 
part and apply it only to c++17 and later.
However the breakage example you posted seems to be from a CUDA library which 
is not usable in the GCC ecosystem, is that correct? And that this library 
might be modern and used with newer standard as well?

If that is the case, the GCC solution might not be good for us anyway, and the 
simplest thing would be to just implement some new rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109496

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2021-11-02 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Looks good from my end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D110833: [clang-format] Refactor SpaceBeforeParens to add options

2021-11-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Looks good, and I really need this to land, to expand it. ;)




Comment at: clang/include/clang/Format/Format.h:3369
+/// \endcode
+bool AfterForeachMacros;
+/// If ``true``, put a space before opening parentheses only if the

Sort before AfterFunction



Comment at: clang/unittests/Format/FormatTest.cpp:14275
+  verifyFormat("A::A() : a (1) {}", SomeSpace2);
+  verifyFormat("void f() __attribute__ ((asdf));", SomeSpace2);
+  verifyFormat("*( + 1);\n"

Is this really desired?


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

https://reviews.llvm.org/D110833

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


[PATCH] D113000: [clang-format] NOT FOR COMMIT - Demo of AutomaticBraces: Remove

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



Comment at: clang/lib/Format/TokenAnnotator.cpp:3230
   return false;
-  } else if (Style.isCSharp()) {
-// Require spaces around '{' and  before '}' unless they appear in
-// interpolated strings. Interpolated strings are merged into a single 
token
-// so cannot have spaces inserted by this function.
+else if (Style.isCSharp()) {
+  // Require spaces around '{' and  before '}' unless they appear in

Here we really have an error!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113000

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D95168#3102247 , @owenpan wrote:

> In D95168#3100969 , @MyDeveloperDay 
> wrote:
>
>> In D95168#3099920 , @owenpan wrote:
>>
>>> In D95168#3099739 , 
>>> @MyDeveloperDay wrote:
>>>
 - Look further into possible Removal (I have an idea for how this might be 
 possible, and super useful for LLVM where we don't like single if {} ), 
 I'd like to round out on this before introducing the options rather than 
 having to change them later

 - Should we add the possibility of removal should we change the option 
 name to "AutomaticBraces" (thoughts?)
>>>
>>> As mentioned in D95168#3039033 , I 
>>> think it would be better to handle the removal separately. The LLVM Coding 
>>> Standards has an entire section 
>>> 
>>>  about this. Some of the listed exceptions/examples there can make things 
>>> more difficult.
>>
>> I'm thinking more about not adding a "InsertBraces" only later to find it 
>> should have been `InsertRemoveBraces` or `AutomaticBraces` i.e. I want to 
>> have some idea as to how this might work, if it might be possible even if we 
>> land separately.
>
> I think the InsertBraces options can be handled by an `enum`, but the 
> RemoveBraces options most likely will use a `struct`. Does it make sense to 
> have both turned on in the same configuration?

I'm in favor of a struct of enums:

  AutomaticBraces:
AfterIf: OnlyIfElse
AfterElse: Remove #this is obviously only to remove, if the else body is a 
single line
AfterWhile: ...

And we can gradually add new enumerators to handle the delicate nuances of 
adding or removing the braces.
And we should add them one after another.




Comment at: clang/include/clang/Format/Format.h:3696
IndentRequires == R.IndentRequires && IndentWidth == R.IndentWidth 
&&
-   Language == R.Language &&
+   AutomaticBraces == R.AutomaticBraces && Language == R.Language &&
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&

Resort ;)



Comment at: clang/lib/Format/BraceInserter.cpp:105
+  FormatToken *getNext(int , FormatToken *current) {
+if (Line == 0 && current == nullptr) {
+  return Lines[0]->First;

Remove the {
Oh the irony. :)



Comment at: clang/lib/Format/BraceInserter.h:1
+//===--- BraceInserter.h - Format C++ code 
===//
+//

Inserter is misleading, if we want it to be able to remove.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D112975: Fix complex types declared using mode TC

2021-11-02 Thread Elizabeth Andrews 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 rG5c8d3053fa0c: Fix complex types declared using mode TC 
(authored by eandrews).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112975

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGenCXX/complex128.cpp


Index: clang/test/CodeGenCXX/complex128.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/complex128.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | 
FileCheck %s
+
+// Define __complex128 type corresponding to __float128 (as in GCC headers).
+typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+void check() {
+  // CHECK: alloca { fp128, fp128 }
+  __complex128 tmp;
+}
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -300,8 +300,11 @@
 if (ExplicitType == FloatModeKind::Ibm128)
   return hasIbm128Type() ? FloatModeKind::Ibm128
  : FloatModeKind::NoFloat;
-if (ExplicitType == FloatModeKind::LongDouble)
-  return ExplicitType;
+if (() == ::APFloat::PPCDoubleDouble() ||
+() == ::APFloat::IEEEquad())
+  return FloatModeKind::LongDouble;
+if (hasFloat128Type())
+  return FloatModeKind::Float128;
 break;
   }
 


Index: clang/test/CodeGenCXX/complex128.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/complex128.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s
+
+// Define __complex128 type corresponding to __float128 (as in GCC headers).
+typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+void check() {
+  // CHECK: alloca { fp128, fp128 }
+  __complex128 tmp;
+}
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -300,8 +300,11 @@
 if (ExplicitType == FloatModeKind::Ibm128)
   return hasIbm128Type() ? FloatModeKind::Ibm128
  : FloatModeKind::NoFloat;
-if (ExplicitType == FloatModeKind::LongDouble)
-  return ExplicitType;
+if (() == ::APFloat::PPCDoubleDouble() ||
+() == ::APFloat::IEEEquad())
+  return FloatModeKind::LongDouble;
+if (hasFloat128Type())
+  return FloatModeKind::Float128;
 break;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5c8d305 - Fix complex types declared using mode TC

2021-11-02 Thread Elizabeth Andrews via cfe-commits

Author: Elizabeth Andrews
Date: 2021-11-02T12:00:26-07:00
New Revision: 5c8d3053fa0c183ea4f908e51a111ada3d4031f2

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

LOG: Fix complex types declared using mode TC

This patch reverts incorrect IR introduced in commit d11ec6f67e45
[Clang] Enable IC/IF mode for __ibm128, for complex types declared
using __attribute__((mode(TC))). TC corresponds to an unspecified
128-bit format, which on some targets is a double-double format
(like __ibm128_t) and on others is float128_t. The bug in d11ec6f67e45
is that long double is only safe to use when it's known to be one of
these formats.

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

Added: 
clang/test/CodeGenCXX/complex128.cpp

Modified: 
clang/lib/Basic/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 514893b47b4f4..76855b0c045c5 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -300,8 +300,11 @@ FloatModeKind TargetInfo::getRealTypeByWidth(unsigned 
BitWidth,
 if (ExplicitType == FloatModeKind::Ibm128)
   return hasIbm128Type() ? FloatModeKind::Ibm128
  : FloatModeKind::NoFloat;
-if (ExplicitType == FloatModeKind::LongDouble)
-  return ExplicitType;
+if (() == ::APFloat::PPCDoubleDouble() ||
+() == ::APFloat::IEEEquad())
+  return FloatModeKind::LongDouble;
+if (hasFloat128Type())
+  return FloatModeKind::Float128;
 break;
   }
 

diff  --git a/clang/test/CodeGenCXX/complex128.cpp 
b/clang/test/CodeGenCXX/complex128.cpp
new file mode 100644
index 0..71746314b9d39
--- /dev/null
+++ b/clang/test/CodeGenCXX/complex128.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | 
FileCheck %s
+
+// Define __complex128 type corresponding to __float128 (as in GCC headers).
+typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+void check() {
+  // CHECK: alloca { fp128, fp128 }
+  __complex128 tmp;
+}



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


[PATCH] D112664: [clang-format][docs] fix indentation of rst code block

2021-11-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D112664#3101142 , @MyDeveloperDay 
wrote:

> This should be Format.h, didn't we recently fix this?

Yes we did, this is from before. :) So it is now obsolete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112664

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


[PATCH] D112768: [ARM] implement support for TLS register based stack protector

2021-11-02 Thread Ard Biesheuvel via Phabricator via cfe-commits
ardb added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3177-3179
+  if (!Args.hasArg(options::OPT_mstack_protector_guard_offset_EQ)) {
+D.Diag(diag::err_drv_ssp_missing_offset_argument)
+<< A->getOption().getName() << Value;

nickdesaulniers wrote:
> Does GCC require these flags to be paired (`-mstack-protector-guard=` and 
> `-mstack-protector-guard-offset`) ? Only for ARM and THUMB?  Doesn't the 
> offset only make sense for sysreg and tls, or global, too?
> 
> Seems to me like `0` would be a good default offset, if unspecified.
> 
> Perhaps this would good to check then warn on for //all// supported 
> architectures, and perhaps as another child patch? (or just default to `0` 
> and not require `-mstack-protector-offset=`).
> Does GCC require these flags to be paired (`-mstack-protector-guard=` and 
> `-mstack-protector-guard-offset`) ? Only for ARM and THUMB?  Doesn't the 
> offset only make sense for sysreg and tls, or global, too?
> 

GCC does not implement this for ARM yet. For AArch64, it requires all three 
options: guard, guard-reg and guard-offset.

> Seems to me like `0` would be a good default offset, if unspecified.
> 

The default is INT_MAX at the moment, and I wasn't sure if we can simply change 
that without breaking users.

> Perhaps this would good to check then warn on for //all// supported 
> architectures, and perhaps as another child patch? (or just default to `0` 
> and not require `-mstack-protector-offset=`).

Yes, I think it makes sense to check this for AAch64 as well. 



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3190-3191
+  }
+  CmdArgs.push_back("-target-feature");
+  CmdArgs.push_back("+read-tp-hard");
+}

nickdesaulniers wrote:
> Isn't this redundant/set elsewhere?
No, it is not. The alternative is requiring the user to pass -mtp=cp15 when 
using the TLS stack protector, which is silly because it is implied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112768

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


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D112996#3102925 , @ckandeler wrote:

>> WDYT about detecting QT headers specifically? It seems hacky, but I don't 
>> see a way out of this that doesn't involve hardcoding some filenames. Are 
>> they in a directory like `"qt-11/QFoo"` that we can recognize? Even Q 
>> followed by another capital letter might be a good enough heuristic.
>> (The docs suggest it's just `` but the docs also say to use angle 
>> brackets so I'm not sure whether to believe them)
>
> The headers are, as far as I can tell, always located in a directory whose 
> name starts with "Qt". This parent directory is also in the include path, so 
> e.g. to get access to QString, which is located under QtCore/, you'd 
> typically just write:
>
>   #include 
>
> This is the recommended, documented way of pulling in headers.
> Though you could also write:
>
>   #include 
>
> as the parent parent directory is also in the list of include paths.
>
> Looking at the code, it seems we have access to the parent directory, so we 
> could do that name check (which I suppose has less potential for false 
> positives than checking the file name).

Yeah, that makes sense to me. Also a bit cheaper since we only have to do this 
once per parent dir.

> For framework builds, the directory would be "Headers", which also seems safe.

I agree extensionless headers in frameworks seem fine to show.
We already know which includepath entries are frameworks, so we can just use 
that info directly (see line 9674)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D113026: [ARM] reject -mtp=cp15 if target subarch does not support it

2021-11-02 Thread Ard Biesheuvel via Phabricator via cfe-commits
ardb marked 2 inline comments as done.
ardb added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:160-161
+if (ThreadPointer == ReadTPMode::Cp15 &&
+getARMSubArchVersionNumber(Triple) < 7 &&
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2) {
+  D.Diag(diag::err_target_unsupported_tp_hard) << Triple.getArchName();

nickdesaulniers wrote:
> The last two checks seems redundant (`getARMSubArchVersionNumber(Triple) < 7 
> && llvm::ARM::parseArch(Triple.getArchName()) != 
> llvm::ARM::ArchKind::ARMV6T2`).  If the `ArchKind` was `ARMV6T2` then 
> `getARMSubArchVersionNumber` should return `6`.
> 
> Or do we want to support ARMv6T2, in which case the patch description should 
> be edited:
> 
> > ensure that -mtp=cp15 is rejected for ARMv6T2 or earlier.
> 
> s/ARMv6T2 or earlier/ARMv6 (except ARMv6T2) or earlier/
> The last two checks seems redundant (`getARMSubArchVersionNumber(Triple) < 7 
> && llvm::ARM::parseArch(Triple.getArchName()) != 
> llvm::ARM::ArchKind::ARMV6T2`).  If the `ArchKind` was `ARMV6T2` then 
> `getARMSubArchVersionNumber` should return `6`.
> 
> Or do we want to support ARMv6T2, in which case the patch description should 
> be edited:
> 
> > ensure that -mtp=cp15 is rejected for ARMv6T2 or earlier.
> 
> s/ARMv6T2 or earlier/ARMv6 (except ARMv6T2) or earlier/

Yeah, the latter. ARMv6T2 is the first core that implements Thumb2, 




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

https://reviews.llvm.org/D113026

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


[PATCH] D113026: [ARM] reject -mtp=cp15 if target subarch does not support it

2021-11-02 Thread Ard Biesheuvel via Phabricator via cfe-commits
ardb updated this revision to Diff 384175.
ardb edited the summary of this revision.
ardb added a comment.

Fix test issue and add more test cases


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

https://reviews.llvm.org/D113026

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/test/Driver/clang-translation.c


Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -110,15 +110,27 @@
 // ARMV5E: "-cc1"
 // ARMV5E: "-target-cpu" "arm1022e"
 
-// RUN: %clang -target arm-linux -mtp=cp15 -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv7-linux -mtp=cp15 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s
 // ARMv7_THREAD_POINTER-HARD: "-target-feature" "+read-tp-hard"
 
-// RUN: %clang -target arm-linux -mtp=soft -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv6t2-linux -mtp=cp15 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv6T2_THREAD_POINTER-HARD %s
+// ARMv6T2_THREAD_POINTER-HARD: "-target-feature" "+read-tp-hard"
+
+// RUN: %clang -target armv5t-linux -mtp=cp15 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv5_THREAD_POINTER_UNSUPP %s
+// ARMv5_THREAD_POINTER_UNSUPP: hardware TLS register is not supported for the 
armv5 sub-architecture
+
+// RUN: %clang -target thumbv6-linux -mtp=cp15 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv6_THREAD_POINTER_UNSUPP %s
+// ARMv6_THREAD_POINTER_UNSUPP: hardware TLS register is not supported for the 
armv6 sub-architecture
+
+// RUN: %clang -target armv7-linux -mtp=soft -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_SOFT %s
 // ARMv7_THREAD_POINTER_SOFT-NOT: "-target-feature" "+read-tp-hard"
 
-// RUN: %clang -target arm-linux -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv7-linux -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
 // ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-hard"
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -53,7 +53,8 @@
 const llvm::opt::ArgList );
 void setFloatABIInTriple(const Driver , const llvm::opt::ArgList ,
  llvm::Triple );
-ReadTPMode getReadTPMode(const Driver , const llvm::opt::ArgList );
+ReadTPMode getReadTPMode(const Driver , const llvm::opt::ArgList ,
+ const llvm::Triple );
 void setArchNameInTriple(const Driver , const llvm::opt::ArgList ,
  types::ID InputType, llvm::Triple );
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -148,13 +148,21 @@
 }
 
 // Select mode for reading thread pointer (-mtp=soft/cp15).
-arm::ReadTPMode arm::getReadTPMode(const Driver , const ArgList ) {
+arm::ReadTPMode arm::getReadTPMode(const Driver , const ArgList ,
+   const llvm::Triple ) {
   if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) {
 arm::ReadTPMode ThreadPointer =
 llvm::StringSwitch(A->getValue())
 .Case("cp15", ReadTPMode::Cp15)
 .Case("soft", ReadTPMode::Soft)
 .Default(ReadTPMode::Invalid);
+if (ThreadPointer == ReadTPMode::Cp15 &&
+getARMSubArchVersionNumber(Triple) < 7 &&
+llvm::ARM::parseArch(Triple.getArchName()) !=
+llvm::ARM::ArchKind::ARMV6T2) {
+  D.Diag(diag::err_target_unsupported_tp_hard) << Triple.getArchName();
+  return ReadTPMode::Invalid;
+}
 if (ThreadPointer != ReadTPMode::Invalid)
   return ThreadPointer;
 if (StringRef(A->getValue()).empty())
@@ -422,7 +430,7 @@
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
   arm::FloatABI ABI = arm::getARMFloatABI(D, Triple, Args);
-  arm::ReadTPMode ThreadPointer = arm::getReadTPMode(D, Args);
+  arm::ReadTPMode ThreadPointer = arm::getReadTPMode(D, Args, Triple);
   llvm::Optional> WaCPU, WaFPU, WaHDiv,
   WaArch;
 


Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -110,15 +110,27 @@
 // ARMV5E: "-cc1"
 // ARMV5E: "-target-cpu" "arm1022e"
 
-// RUN: %clang -target arm-linux -mtp=cp15 -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv7-linux -mtp=cp15 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s
 // ARMv7_THREAD_POINTER-HARD: "-target-feature" "+read-tp-hard"
 
-// RUN: %clang -target arm-linux -mtp=soft -### 

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

2021-11-02 Thread Med Ismail Bennani via Phabricator via cfe-commits
mib added a comment.

I reverted this patch locally and try building with clang modules 
(`-DLLVM_ENABLE_MODULE=On`) which confirmed it was causing the build failure on 
the bots.

I had to revert your patch upstream to fix our bots. If you need some help to 
reproduce the build failure, let me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


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

2021-11-02 Thread Med Ismail Bennani via Phabricator via cfe-commits
mib added a comment.

Hi @Ericson2314, I think this patch broke our macOS lldb-incremental bot on 
GreenDragon (https://green.lab.llvm.org/green/job/lldb-cmake/37560/console).

Could you please take a look ? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


[PATCH] D112768: [ARM] implement support for TLS register based stack protector

2021-11-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3177-3179
+  if (!Args.hasArg(options::OPT_mstack_protector_guard_offset_EQ)) {
+D.Diag(diag::err_drv_ssp_missing_offset_argument)
+<< A->getOption().getName() << Value;

Does GCC require these flags to be paired (`-mstack-protector-guard=` and 
`-mstack-protector-guard-offset`) ? Only for ARM and THUMB?  Doesn't the offset 
only make sense for sysreg and tls, or global, too?

Seems to me like `0` would be a good default offset, if unspecified.

Perhaps this would good to check then warn on for //all// supported 
architectures, and perhaps as another child patch? (or just default to `0` and 
not require `-mstack-protector-offset=`).



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3190-3191
+  }
+  CmdArgs.push_back("-target-feature");
+  CmdArgs.push_back("+read-tp-hard");
+}

Isn't this redundant/set elsewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112768

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-11-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: luke957.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 384171.
MyDeveloperDay removed a reviewer: klimek.
MyDeveloperDay set the repository for this revision to rG LLVM Github Monorepo.
MyDeveloperDay added a comment.

Add some more testcases to catch handling removing {} from the nested if, but 
not the outer if


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BraceInserter.cpp
  clang/lib/Format/BraceInserter.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/unittests/Format/BraceInserterTests.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -72,7 +72,10 @@
 EXPECT_EQ(Expected.str(), format(Expected, Style))
 << "Expected code is not stable";
 EXPECT_EQ(Expected.str(), format(Code, Style));
-if (Style.Language == FormatStyle::LK_Cpp) {
+// clang::format::internal::reformat does not run any of the options that
+// modify code for ObjC
+if (Style.Language == FormatStyle::LK_Cpp &&
+Style.AutomaticBraces == FormatStyle::BIS_Leave) {
   // Objective-C++ is a superset of C++, so everything checked for C++
   // needs to be checked for Objective-C++ as well.
   FormatStyle ObjCStyle = Style;
@@ -18609,6 +18612,16 @@
   CHECK_PARSE("AllowShortFunctionsOnASingleLine: true",
   AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All);
 
+  Style.AutomaticBraces = FormatStyle::BIS_Leave;
+  CHECK_PARSE("AutomaticBraces: Always", AutomaticBraces,
+  FormatStyle::BIS_Always);
+  CHECK_PARSE("AutomaticBraces: WrapLikely", AutomaticBraces,
+  FormatStyle::BIS_WrapLikely);
+  CHECK_PARSE("AutomaticBraces: Leave", AutomaticBraces,
+  FormatStyle::BIS_Leave);
+  CHECK_PARSE("AutomaticBraces: Remove", AutomaticBraces,
+  FormatStyle::BIS_Remove);
+
   Style.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Both;
   CHECK_PARSE("SpaceAroundPointerQualifiers: Default",
   SpaceAroundPointerQualifiers, FormatStyle::SAPQ_Default);
@@ -22396,7 +22409,6 @@
   "}";
   EXPECT_EQ(Code, format(Code, Style));
 }
-
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/unittests/Format/CMakeLists.txt
===
--- clang/unittests/Format/CMakeLists.txt
+++ clang/unittests/Format/CMakeLists.txt
@@ -3,6 +3,7 @@
   )
 
 add_clang_unittest(FormatTests
+  BraceInserterTests.cpp
   CleanupTest.cpp
   FormatTest.cpp
   FormatTestComments.cpp
Index: clang/unittests/Format/BraceInserterTests.cpp
===
--- /dev/null
+++ clang/unittests/Format/BraceInserterTests.cpp
@@ -0,0 +1,461 @@
+//===- unittest/Format/BraceInserterTest.cpp - brace insertion unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "../Tooling/ReplacementTest.h"
+#include "FormatTestUtils.h"
+
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "brace-inserter-test"
+
+using clang::tooling::ReplacementTest;
+using clang::tooling::toReplacements;
+using testing::ScopedTrace;
+
+namespace clang {
+namespace format {
+namespace {
+
+class BraceInserterTest : public ::testing::Test {
+protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
+  std::string format(llvm::StringRef Code,
+ const FormatStyle  = getLLVMStyle(),
+ StatusCheck CheckComplete = SC_ExpectComplete) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(0, Code.size()));
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", );
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
+

[clang] 797b50d - Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM"

2021-11-02 Thread Med Ismail Bennani via cfe-commits

Author: Med Ismail Bennani
Date: 2021-11-02T19:11:44+01:00
New Revision: 797b50d4be873b4662983413a06806fca544c276

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

LOG: Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM"

This reverts commit 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73 since it
broke GreenDragon LLDB-Incremental bot:

https://green.lab.llvm.org/green/job/lldb-cmake/37560/console

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
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

Removed: 




diff  --git a/clang/tools/scan-build/CMakeLists.txt 
b/clang/tools/scan-build/CMakeLists.txt
index 74334e53c9b18..ec0702d76f184 100644
--- a/clang/tools/scan-build/CMakeLists.txt
+++ b/clang/tools/scan-build/CMakeLists.txt
@@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"
+add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
COMMAND ${CMAKE_COMMAND} -E make_directory
- "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
COMMAND ${CMAKE_COMMAND} -E copy
- "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"
- "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"
+ ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")
+list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
 install(PROGRAMS man/${ManPage}
-DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
 COMPONENT scan-build)
   endforeach()
 

diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index e90e0fd852012..ec39ea63f2d02 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -183,8 +183,8 @@ endif()
 
 # pkg-config file
 configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
"${CMAKE_INSTALL_DATADIR}/pkgconfig" )
-install( DIRECTORY generic/include/clc DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}" )
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
${CMAKE_INSTALL_DATADIR}/pkgconfig )
+install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 
)
 
 if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_use_default STATIC
@@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_disable STATIC
generic/lib/subnormal_disable.ll )
install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-   DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
+   DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
 endif()
 
 find_package( Python3 REQUIRED COMPONENTS Interpreter )
@@ -343,7 +343,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
add_custom_target( "prepare-${spv_suffix}" ALL
   DEPENDS "${spv_suffix}" )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix}
-DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
+DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
else()
 
# Add prepare target
@@ -366,7 +366,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
PROPERTIES ENVIRONMENT 
"LLVM_CONFIG=${LLVM_CONFIG}" )
endif()
 
-   install( FILES 
${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION 
"${CMAKE_INSTALL_DATADIR}/clc" )
+   install( FILES 
${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION 
${CMAKE_INSTALL_DATADIR}/clc )

[PATCH] D113026: [ARM] reject -mtp=cp15 if target subarch does not support it

2021-11-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for the patch! Don't forget to run `git-clang-format HEAD~`.




Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:160-161
+if (ThreadPointer == ReadTPMode::Cp15 &&
+getARMSubArchVersionNumber(Triple) < 7 &&
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2) {
+  D.Diag(diag::err_target_unsupported_tp_hard) << Triple.getArchName();

The last two checks seems redundant (`getARMSubArchVersionNumber(Triple) < 7 && 
llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::ArchKind::ARMV6T2`).  
If the `ArchKind` was `ARMV6T2` then `getARMSubArchVersionNumber` should return 
`6`.

Or do we want to support ARMv6T2, in which case the patch description should be 
edited:

> ensure that -mtp=cp15 is rejected for ARMv6T2 or earlier.

s/ARMv6T2 or earlier/ARMv6 (except ARMv6T2) or earlier/



Comment at: clang/test/Driver/clang-translation.c:118-119
+// RUN: %clang -target armv5t-linux -mtp=cp15 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_UNSUPPORTED %s
+// ARMv7_THREAD_POINTER_UNSUPPORTED: error: hardware TLS register is not 
supported for the armv5 sub-architecture
+

The `-check-prefix` should probably s/ARMv7/ARMv5T/.

It might be interesting to additionally test armv6 vs armv6t, depending on the 
answer to my question above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113026

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


[clang] 5a892be - [clang] Fix cmake error

2021-11-02 Thread Dave Lee via cfe-commits

Author: Dave Lee
Date: 2021-11-02T10:47:44-07:00
New Revision: 5a892be237a20002c88a80b618e6f5febfd7a4f6

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

LOG: [clang] Fix cmake error

Added: 


Modified: 
clang/tools/driver/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 3d2996b0b9ec..52d439ce6a3b 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -95,7 +95,7 @@ if(CLANG_ORDER_FILE AND
 (LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
   include(LLVMCheckLinkerFlag)
 
-  if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD and APPLE))
+  if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD AND APPLE))
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
   elseif (LLVM_LINKER_IS_GOLD)
 set(LINKER_ORDER_FILE_OPTION 
"-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")



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


[PATCH] D113021: [cmake] Make LLVM_ENABLE_LLD=ON work better on macOS

2021-11-02 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d3953499c8c: [cmake] Make LLVM_ENABLE_LLD=ON work better on 
macOS (authored by thakis).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D113021?vs=384101=384159#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113021

Files:
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -166,33 +166,43 @@
   set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
 endfunction(add_llvm_symbol_exports)
 
-if (NOT DEFINED LLVM_LINKER_DETECTED)
+if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
+  # Detect what linker we have here.
+  if(APPLE)
+# Linkers with ld64-compatible flags.
+set(version_flag "-Wl,-v")
+  else()
+# Linkers with BFD ld-compatible flags.
+set(version_flag "-Wl,--version")
+  endif()
+
+  if(LLVM_USE_LINKER)
+set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} 
${version_flag})
+  else()
+separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
+set(command ${CMAKE_C_COMPILER} ${flags} ${version_flag})
+  endif()
+  execute_process(
+COMMAND ${command}
+OUTPUT_VARIABLE stdout
+ERROR_VARIABLE stderr
+)
+
   if(APPLE)
-execute_process(
-  COMMAND "${CMAKE_LINKER}" -v
-  ERROR_VARIABLE stderr
-  )
 if("${stderr}" MATCHES "PROJECT:ld64")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   set(LLVM_LINKER_IS_LD64 YES CACHE INTERNAL "")
   message(STATUS "Linker detection: ld64")
+elseif("${stderr}" MATCHES "^LLD" OR
+   "${stdout}" MATCHES "^LLD")
+  set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+  set(LLVM_LINKER_IS_LLD YES CACHE INTERNAL "")
+  message(STATUS "Linker detection: lld")
 else()
   set(LLVM_LINKER_DETECTED NO CACHE INTERNAL "")
   message(STATUS "Linker detection: unknown")
 endif()
-  elseif(NOT WIN32)
-# Detect what linker we have here
-if( LLVM_USE_LINKER )
-  set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} 
-Wl,--version)
-else()
-  separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
-  set(command ${CMAKE_C_COMPILER} ${flags} -Wl,--version)
-endif()
-execute_process(
-  COMMAND ${command}
-  OUTPUT_VARIABLE stdout
-  ERROR_VARIABLE stderr
-  )
+  else()
 if("${stdout}" MATCHES "^mold")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   message(STATUS "Linker detection: mold")
Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -95,7 +95,7 @@
 (LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
   include(LLVMCheckLinkerFlag)
 
-  if (LLVM_LINKER_IS_LD64)
+  if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD and APPLE))
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
   elseif (LLVM_LINKER_IS_GOLD)
 set(LINKER_ORDER_FILE_OPTION 
"-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -166,33 +166,43 @@
   set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
 endfunction(add_llvm_symbol_exports)
 
-if (NOT DEFINED LLVM_LINKER_DETECTED)
+if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
+  # Detect what linker we have here.
+  if(APPLE)
+# Linkers with ld64-compatible flags.
+set(version_flag "-Wl,-v")
+  else()
+# Linkers with BFD ld-compatible flags.
+set(version_flag "-Wl,--version")
+  endif()
+
+  if(LLVM_USE_LINKER)
+set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} ${version_flag})
+  else()
+separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
+set(command ${CMAKE_C_COMPILER} ${flags} ${version_flag})
+  endif()
+  execute_process(
+COMMAND ${command}
+OUTPUT_VARIABLE stdout
+ERROR_VARIABLE stderr
+)
+
   if(APPLE)
-execute_process(
-  COMMAND "${CMAKE_LINKER}" -v
-  ERROR_VARIABLE stderr
-  )
 if("${stderr}" MATCHES "PROJECT:ld64")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   set(LLVM_LINKER_IS_LD64 YES CACHE INTERNAL "")
   message(STATUS "Linker detection: ld64")
+elseif("${stderr}" MATCHES "^LLD" OR
+   "${stdout}" MATCHES "^LLD")
+  set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+  set(LLVM_LINKER_IS_LLD YES CACHE INTERNAL "")
+  message(STATUS "Linker detection: lld")
 else()
   

[clang] 2d39534 - [cmake] Make LLVM_ENABLE_LLD=ON work better on macOS

2021-11-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-11-02T13:35:21-04:00
New Revision: 2d3953499c8ca73c12e9417f5c4516c8a930a689

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

LOG: [cmake] Make LLVM_ENABLE_LLD=ON work better on macOS

LLVM_LINKER_IS_LLD is now set with LLVM_ENABLE_LLD=ON (or LLVM_USER_LINKER=lld)
even on APPLE, and we pass -Wl,-order_file when LLVM_LINKER_IS_LLD on APPLE
too.

To make this straightforward, change the linker detection logic to go through
the compiler driver on APPLE like on the other platforms.

No intended behavior change if LLVM_ENABLE_LLD isn't set.

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

Added: 


Modified: 
clang/tools/driver/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake

Removed: 




diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 1bea470ed3010..3d2996b0b9ece 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -95,7 +95,7 @@ if(CLANG_ORDER_FILE AND
 (LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
   include(LLVMCheckLinkerFlag)
 
-  if (LLVM_LINKER_IS_LD64)
+  if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD and APPLE))
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
   elseif (LLVM_LINKER_IS_GOLD)
 set(LINKER_ORDER_FILE_OPTION 
"-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 3c4e9f69538c3..7c2b801a423df 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -166,33 +166,43 @@ function(add_llvm_symbol_exports target_name export_file)
   set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
 endfunction(add_llvm_symbol_exports)
 
-if (NOT DEFINED LLVM_LINKER_DETECTED)
+if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
+  # Detect what linker we have here.
+  if(APPLE)
+# Linkers with ld64-compatible flags.
+set(version_flag "-Wl,-v")
+  else()
+# Linkers with BFD ld-compatible flags.
+set(version_flag "-Wl,--version")
+  endif()
+
+  if(LLVM_USE_LINKER)
+set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} 
${version_flag})
+  else()
+separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
+set(command ${CMAKE_C_COMPILER} ${flags} ${version_flag})
+  endif()
+  execute_process(
+COMMAND ${command}
+OUTPUT_VARIABLE stdout
+ERROR_VARIABLE stderr
+)
+
   if(APPLE)
-execute_process(
-  COMMAND "${CMAKE_LINKER}" -v
-  ERROR_VARIABLE stderr
-  )
 if("${stderr}" MATCHES "PROJECT:ld64")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   set(LLVM_LINKER_IS_LD64 YES CACHE INTERNAL "")
   message(STATUS "Linker detection: ld64")
+elseif("${stderr}" MATCHES "^LLD" OR
+   "${stdout}" MATCHES "^LLD")
+  set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+  set(LLVM_LINKER_IS_LLD YES CACHE INTERNAL "")
+  message(STATUS "Linker detection: lld")
 else()
   set(LLVM_LINKER_DETECTED NO CACHE INTERNAL "")
   message(STATUS "Linker detection: unknown")
 endif()
-  elseif(NOT WIN32)
-# Detect what linker we have here
-if( LLVM_USE_LINKER )
-  set(command ${CMAKE_C_COMPILER} -fuse-ld=${LLVM_USE_LINKER} 
-Wl,--version)
-else()
-  separate_arguments(flags UNIX_COMMAND "${CMAKE_EXE_LINKER_FLAGS}")
-  set(command ${CMAKE_C_COMPILER} ${flags} -Wl,--version)
-endif()
-execute_process(
-  COMMAND ${command}
-  OUTPUT_VARIABLE stdout
-  ERROR_VARIABLE stderr
-  )
+  else()
 if("${stdout}" MATCHES "^mold")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   message(STATUS "Linker detection: mold")



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


[clang] 98b761f - [RISCV] Rename vfredusum/vfredosum intrinsic test files. Merge some tests. NFC

2021-11-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-11-02T10:33:20-07:00
New Revision: 98b761fce68b194674a98f347c641f8ce3e85eff

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

LOG: [RISCV] Rename vfredusum/vfredosum intrinsic test files. Merge some tests. 
NFC

I recently renamed some tests from vfredsum to vfredusum without
noticing they tested both ordered and unordered reductions. This
patch renames them back.

I've also merged test files for vfwredosum/vfwredusum into a single
file for consistency with the other 3 floating point reduction test
files. The inconsistency is what caused my original confusion.

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfredsum.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c

Modified: 


Removed: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredusum.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredusum.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfredusum.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredosum.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredusum.c



diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredusum.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
similarity index 100%
rename from clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredusum.c
rename to clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredusum.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c
similarity index 100%
rename from clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredusum.c
rename to clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vfredusum.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vfredsum.c
similarity index 100%
rename from clang/test/CodeGen/RISCV/rvv-intrinsics/vfredusum.c
rename to clang/test/CodeGen/RISCV/rvv-intrinsics/vfredsum.c

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredosum.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c
similarity index 50%
rename from clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredosum.c
rename to clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c
index 590cd741d155d..7c060e1829445 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredosum.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c
@@ -223,3 +223,221 @@ vfloat32m1_t test_vfwredosum_vs_f16m4_f32m1_m (vbool4_t 
mask, vfloat32m1_t dest,
 vfloat32m1_t test_vfwredosum_vs_f16m8_f32m1_m (vbool2_t mask, vfloat32m1_t 
dest, vfloat16m8_t vector, vfloat32m1_t scalar, size_t vl) {
   return vfwredosum_vs_f16m8_f32m1_m(mask, dest, vector, scalar, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vfwredusum_vs_f32mf2_f64m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfwredusum.nxv1f64.nxv1f32.i64( [[DST:%.*]], 
 [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 
[[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat64m1_t test_vfwredusum_vs_f32mf2_f64m1(vfloat64m1_t dst,
+vfloat32mf2_t vector,
+vfloat64m1_t scalar, size_t vl) {
+  return vfwredusum_vs_f32mf2_f64m1(dst, vector, scalar, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vfwredusum_vs_f32m1_f64m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfwredusum.nxv1f64.nxv2f32.i64( [[DST:%.*]], 
 [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 
[[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat64m1_t test_vfwredusum_vs_f32m1_f64m1(vfloat64m1_t dst,
+   vfloat32m1_t vector,
+   vfloat64m1_t scalar, size_t vl) {
+  return vfwredusum_vs_f32m1_f64m1(dst, vector, scalar, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vfwredusum_vs_f32m2_f64m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfwredusum.nxv1f64.nxv4f32.i64( [[DST:%.*]], 
 [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 
[[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat64m1_t test_vfwredusum_vs_f32m2_f64m1(vfloat64m1_t dst,
+   vfloat32m2_t vector,
+   vfloat64m1_t scalar, size_t vl) {
+  return vfwredusum_vs_f32m2_f64m1(dst, vector, scalar, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vfwredusum_vs_f32m4_f64m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfwredusum.nxv1f64.nxv8f32.i64( [[DST:%.*]], 
 [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 
[[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]

[PATCH] D112768: [ARM] implement support for TLS register based stack protector

2021-11-02 Thread Ard Biesheuvel via Phabricator via cfe-commits
ardb updated this revision to Diff 384154.
ardb added a comment.

- fix failure in newly added LLVM test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112768

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-protector-guard.c
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMInstrInfo.cpp
  llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
  llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
  llvm/test/CodeGen/ARM/stack-guard-tls.ll

Index: llvm/test/CodeGen/ARM/stack-guard-tls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/stack-guard-tls.ll
@@ -0,0 +1,38 @@
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
+; RUN: llc %t/a2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-SMALL %s
+; RUN: llc %t/a2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-SMALL %s
+; RUN: llc %t/b2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-LARGE %s
+; RUN: llc %t/b2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-LARGE %s
+
+;--- main.ll
+declare void @baz(i32*)
+
+define void @foo(i64 %t) sspstrong {
+  %vla = alloca i32, i64 %t, align 4
+  call void @baz(i32* nonnull %vla)
+  ret void
+}
+!llvm.module.flags = !{!1, !2}
+!1 = !{i32 2, !"stack-protector-guard", !"tls"}
+
+;--- a.ll
+!2 = !{i32 2, !"stack-protector-guard-offset", i32 1296}
+
+;--- b.ll
+!2 = !{i32 2, !"stack-protector-guard-offset", i32 4296}
+
+; CHECK: mrc p15, #0, [[REG1:r[0-9]+]], c13, c0, #3
+; CHECK-SMALL-NEXT: ldr{{(\.w)?}} [[REG1]], {{\[}}[[REG1]], #1296]
+; CHECK-LARGE-NEXT: add{{(\.w)?}} [[REG1]], [[REG1]], #4096
+; CHECK-LARGE-NEXT: ldr{{(\.w)?}} [[REG1]], {{\[}}[[REG1]], #200]
+; CHECK: bl baz
+; CHECK: mrc p15, #0, [[REG2:r[0-9]+]], c13, c0, #3
+; CHECK-SMALL-NEXT: ldr{{(\.w)?}} [[REG2]], {{\[}}[[REG2]], #1296]
+; CHECK-LARGE-NEXT: add{{(\.w)?}} [[REG2]], [[REG2]], #4096
+; CHECK-LARGE-NEXT: ldr{{(\.w)?}} [[REG2]], {{\[}}[[REG2]], #200]
Index: llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
===
--- llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
+++ llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
@@ -250,6 +250,13 @@
 void Thumb2InstrInfo::expandLoadStackGuard(
 MachineBasicBlock::iterator MI) const {
   MachineFunction  = *MI->getParent()->getParent();
+  Module  = *MF.getFunction().getParent();
+
+  if (M.getStackProtectorGuard() == "tls") {
+expandLoadStackGuardBase(MI, ARM::t2MRC, ARM::t2LDRi12);
+return;
+  }
+
   const GlobalValue *GV =
   cast((*MI->memoperands_begin())->getValue());
 
Index: llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
===
--- llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
+++ llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
@@ -135,6 +135,11 @@
 MachineBasicBlock::iterator MI) const {
   MachineFunction  = *MI->getParent()->getParent();
   const TargetMachine  = MF.getTarget();
+  Module  = *MF.getFunction().getParent();
+
+  assert(M.getStackProtectorGuard() != "tls" &&
+ "TLS stack protector not supported for Thumb1 targets");
+
   if (TM.isPositionIndependent())
 expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_pcrel, ARM::tLDRi);
   else
Index: llvm/lib/Target/ARM/ARMInstrInfo.cpp
===
--- llvm/lib/Target/ARM/ARMInstrInfo.cpp
+++ llvm/lib/Target/ARM/ARMInstrInfo.cpp
@@ -95,6 +95,12 @@
   MachineFunction  = *MI->getParent()->getParent();
   const ARMSubtarget  = MF.getSubtarget();
   const TargetMachine  = MF.getTarget();
+  Module  = *MF.getFunction().getParent();
+
+  if (M.getStackProtectorGuard() == "tls") {
+expandLoadStackGuardBase(MI, ARM::MRC, ARM::LDRi12);
+return;
+  }
 
   const GlobalValue *GV =
   cast((*MI->memoperands_begin())->getValue());
Index: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
===
--- llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -4891,40 +4891,70 @@
   MachineBasicBlock  = *MI->getParent();
   DebugLoc DL = MI->getDebugLoc();
   Register Reg = MI->getOperand(0).getReg();
-  const GlobalValue *GV =
-  cast((*MI->memoperands_begin())->getValue());
-  bool IsIndirect = Subtarget.isGVIndirectSymbol(GV);
   MachineInstrBuilder MIB;
+  unsigned int Offset = 0;
 
-  unsigned TargetFlags = ARMII::MO_NO_FLAG;
-  if (Subtarget.isTargetMachO()) {
-TargetFlags |= ARMII::MO_NONLAZY;
-  } else 

[PATCH] D112453: [Sema] When dereferencing a pointer of dependent type, infer the result type.

2021-11-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I think the idea of this change is OK. The key is that the dereference 
expression will still be type-dependent, even if we happen to actually know its 
type. (For an `Expr` that `isTypeDependent()`, the type produced by `getType()` 
isn't something the standard knows or cares about and is only used for our own 
type-checking-of-templates purposes.) The property we need to guarantee is 
that, if the `Expr` is valid, then the type is correct, and I think that holds 
here. However, I wouldn't want to guarantee that all parts of Clang get this 
right, and we might find some lurking bugs are exposed by this change.

I think this change is being made in an imperfect place, though. Instead of 
putting a special case in here, how would we feel about making 
`Type::isOverloadableType()` smarter, to return `false` for dependent types 
that can't possibly be class or enum types (eg, dependent pointer types, array 
types, and maybe more exotic things like function types, atomic types, and 
complex types)? This would then apply to all operators, not only unary `*`. Eg, 
we know the type of `` where `p` is `T*`, and we know the type of `p + n` 
where  `p` is `T*` and  `n` is integral. That change might have a lot more 
fallout, but it'd certainly be interesting to see what it breaks.

Is this change observable in some way? We should include a test with this 
change that demonstrates what effect it has. (The existing test in this patch 
passes with or without the change.) If nothing else I think we should be able 
to see the effect of this change in the output of `-ast-dump`. (Making the more 
general change I mentioned above may help here, by giving earlier diagnostics 
for some cases for which instantiation could never succeed, such as rejecting 
`p + q` where `p` and `q` are both pointer types.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112453

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


[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from some possible nits.




Comment at: clang/lib/Serialization/ASTWriter.cpp:5018
 Record.AddStmt(A->getAllocator());
+Record.AddStmt(A->getAlignment());
 Record.AddSourceRange(A->getRange());

This can potentially add a null statement to emit to the serialized form.



Comment at: clang/lib/Serialization/ASTWriter.cpp:6224
+void OMPClauseWriter::VisitOMPAlignClause(OMPAlignClause *C) {
+  Record.AddStmt(C->getAlignment());
+  Record.AddSourceLocation(C->getLParenLoc());

Same for this one, maybe?


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

https://reviews.llvm.org/D112577

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


[PATCH] D113029: [clangd] Find definition of ClassTemplate without going through index.

2021-11-02 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
adamcz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

I noticed that, while go-to-def works on cases like:

namespace ns {

  template struct Foo {};

}
using ::ns::Fo^o;

it only works because of the FileIndex. We can get definition location
directly from AST too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113029

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -675,7 +675,7 @@
 
   R"cpp(// Declaration of explicit template specialization
 template 
-struct $decl[[Foo]] {};
+struct $decl[[$def[[Foo {};
 
 template <>
 struct Fo^o {};
@@ -683,12 +683,25 @@
 
   R"cpp(// Declaration of partial template specialization
 template 
-struct $decl[[Foo]] {};
+struct $decl[[$def[[Foo {};
 
 template 
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// Definition on ClassTemplateDecl
+namespace ns {
+  // Forward declaration.
+  template
+  struct $decl[[Foo]];
+
+  template 
+  struct $def[[Foo]] {};
+}
+
+using ::ns::Fo^o;
+  )cpp",
+
   R"cpp(// auto builtin type (not supported)
 ^auto x = 42;
   )cpp",
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -80,6 +80,9 @@
 return VD->getDefinition();
   if (const auto *FD = dyn_cast(D))
 return FD->getDefinition();
+  if (const auto *CTD = dyn_cast(D))
+if (const auto *RD = CTD->getTemplatedDecl())
+  return RD->getDefinition();
   // Objective-C classes can have three types of declarations:
   //
   // - forward declaration: @class MyClass;


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -675,7 +675,7 @@
 
   R"cpp(// Declaration of explicit template specialization
 template 
-struct $decl[[Foo]] {};
+struct $decl[[$def[[Foo {};
 
 template <>
 struct Fo^o {};
@@ -683,12 +683,25 @@
 
   R"cpp(// Declaration of partial template specialization
 template 
-struct $decl[[Foo]] {};
+struct $decl[[$def[[Foo {};
 
 template 
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// Definition on ClassTemplateDecl
+namespace ns {
+  // Forward declaration.
+  template
+  struct $decl[[Foo]];
+
+  template 
+  struct $def[[Foo]] {};
+}
+
+using ::ns::Fo^o;
+  )cpp",
+
   R"cpp(// auto builtin type (not supported)
 ^auto x = 42;
   )cpp",
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -80,6 +80,9 @@
 return VD->getDefinition();
   if (const auto *FD = dyn_cast(D))
 return FD->getDefinition();
+  if (const auto *CTD = dyn_cast(D))
+if (const auto *RD = CTD->getTemplatedDecl())
+  return RD->getDefinition();
   // Objective-C classes can have three types of declarations:
   //
   // - forward declaration: @class MyClass;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113026: [ARM] reject -mtp=cp15 if target subarch does not support it

2021-11-02 Thread Ard Biesheuvel via Phabricator via cfe-commits
ardb created this revision.
ardb added reviewers: nickdesaulniers, peter.smith, rengolin, kees, ostannard.
Herald added a subscriber: kristof.beyls.
ardb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, we permit -mtp=cp15 even for targets that don't implement the TLS 
register. When building for ARMv6 or earlier, this means we emit instructions 
that will UNDEF at runtime. For Thumb1, passing -mtp=cp15 will trigger an 
assert in the backend.

So let's add some diagnostics to ensure that -mtp=cp15 is rejected for ARMv6T2 
or earlier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113026

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/test/Driver/clang-translation.c


Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -110,15 +110,19 @@
 // ARMV5E: "-cc1"
 // ARMV5E: "-target-cpu" "arm1022e"
 
-// RUN: %clang -target arm-linux -mtp=cp15 -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv7-linux -mtp=cp15 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s
 // ARMv7_THREAD_POINTER-HARD: "-target-feature" "+read-tp-hard"
 
-// RUN: %clang -target arm-linux -mtp=soft -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv5t-linux -mtp=cp15 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_UNSUPPORTED %s
+// ARMv7_THREAD_POINTER_UNSUPPORTED: error: hardware TLS register is not 
supported for the armv5 sub-architecture
+
+// RUN: %clang -target armv7-linux -mtp=soft -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_SOFT %s
 // ARMv7_THREAD_POINTER_SOFT-NOT: "-target-feature" "+read-tp-hard"
 
-// RUN: %clang -target arm-linux -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv7-linux -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
 // ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-hard"
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -53,7 +53,8 @@
 const llvm::opt::ArgList );
 void setFloatABIInTriple(const Driver , const llvm::opt::ArgList ,
  llvm::Triple );
-ReadTPMode getReadTPMode(const Driver , const llvm::opt::ArgList );
+ReadTPMode getReadTPMode(const Driver , const llvm::opt::ArgList ,
+ const llvm::Triple );
 void setArchNameInTriple(const Driver , const llvm::opt::ArgList ,
  types::ID InputType, llvm::Triple );
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -148,13 +148,20 @@
 }
 
 // Select mode for reading thread pointer (-mtp=soft/cp15).
-arm::ReadTPMode arm::getReadTPMode(const Driver , const ArgList ) {
+arm::ReadTPMode arm::getReadTPMode(const Driver , const ArgList ,
+   const llvm::Triple ) {
   if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) {
 arm::ReadTPMode ThreadPointer =
 llvm::StringSwitch(A->getValue())
 .Case("cp15", ReadTPMode::Cp15)
 .Case("soft", ReadTPMode::Soft)
 .Default(ReadTPMode::Invalid);
+if (ThreadPointer == ReadTPMode::Cp15 &&
+getARMSubArchVersionNumber(Triple) < 7 &&
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2) {
+  D.Diag(diag::err_target_unsupported_tp_hard) << Triple.getArchName();
+  return ReadTPMode::Invalid;
+}
 if (ThreadPointer != ReadTPMode::Invalid)
   return ThreadPointer;
 if (StringRef(A->getValue()).empty())
@@ -422,7 +429,7 @@
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
   arm::FloatABI ABI = arm::getARMFloatABI(D, Triple, Args);
-  arm::ReadTPMode ThreadPointer = arm::getReadTPMode(D, Args);
+  arm::ReadTPMode ThreadPointer = arm::getReadTPMode(D, Args, Triple);
   llvm::Optional> WaCPU, WaFPU, WaHDiv,
   WaArch;
 


Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -110,15 +110,19 @@
 // ARMV5E: "-cc1"
 // ARMV5E: "-target-cpu" "arm1022e"
 
-// RUN: %clang -target arm-linux -mtp=cp15 -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target armv7-linux -mtp=cp15 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s
 // ARMv7_THREAD_POINTER-HARD: "-target-feature" "+read-tp-hard"
 
-// RUN: %clang -target arm-linux -mtp=soft 

[PATCH] D112453: [Sema] When dereferencing a pointer of dependent type, infer the result type.

2021-11-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D112453#3084394 , @courbet wrote:

> As per the comment in BuiltinTypes.def (see below), `Dependent` is
> allowed in context where the type is deducible, but is there any reason
> **not** to deduce the type if we can do it cheaply in some cases ?
>
>   // This represents the type of an expression whose type is
>   // totally unknown, e.g. 'T::foo'.  It is permitted for this to
>   // appear in situations where the structure of the type is
>   // theoretically deducible.
>   BUILTIN_TYPE(Dependent, DependentTy)

I've been trying to think if this will cause problems or not, and I'm not 
convinced one way or the other. I was thinking that if we resolve the type to a 
non-dependent type, but it is used within another type (making the second type 
also dependent), won't we change the point of instantiation for that second 
dependent type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112453

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


[PATCH] D112975: Fix complex types declared using mode TC

2021-11-02 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In D112975#3101720 , @rjmccall wrote:

> For posterity in case someone tracks down this review: `TC` corresponds to an 
> unspecified 128-bit format, which on some targets is a double-double format 
> (like `__ibm128_t`) and on others is `float128_t`.  The bug in the previous 
> patch is that  `long double` is only safe to use when it's known to be one of 
> those formats.
>
> Patch LGTM.

Thanks for the note. I'll update the commit message when I check this in.


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

https://reviews.llvm.org/D112975

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


[clang] e2024d7 - Revert "[NFC] Remove LinkAll*.h"

2021-11-02 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-11-02T09:08:09-07:00
New Revision: e2024d72fae778e0369127e078a40b4d6eb6c7bd

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

LOG: Revert "[NFC] Remove LinkAll*.h"

This reverts commit fe364e5dc78c58a915986d9a44cfd65f919a00c2.

Causes breakages, e.g. https://lab.llvm.org/buildbot/#/builders/188/builds/5266

Added: 
llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
llvm/include/llvm/LinkAllIR.h
llvm/include/llvm/LinkAllPasses.h

Modified: 
clang/tools/driver/cc1_main.cpp
llvm/docs/WritingAnLLVMPass.rst
llvm/include/llvm/module.modulemap
llvm/lib/Analysis/CallPrinter.cpp
llvm/lib/Analysis/DomPrinter.cpp
llvm/lib/Analysis/RegionInfo.cpp
llvm/lib/CodeGen/MachineRegionInfo.cpp
llvm/tools/bugpoint/bugpoint.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 19273f97c921b..fd3b25ccb3cb1 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -27,6 +27,7 @@
 #include "clang/FrontendTool/Utils.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/LinkAllPasses.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"

diff  --git a/llvm/docs/WritingAnLLVMPass.rst b/llvm/docs/WritingAnLLVMPass.rst
index c9955d177036e..133775c92dde4 100644
--- a/llvm/docs/WritingAnLLVMPass.rst
+++ b/llvm/docs/WritingAnLLVMPass.rst
@@ -1308,6 +1308,11 @@ option.  Registering instruction schedulers is similar 
except use the
 ``RegisterScheduler::FunctionPassCtor`` is significantly 
diff erent from
 ``RegisterRegAlloc::FunctionPassCtor``.
 
+To force the load/linking of your register allocator into the
+:program:`llc`/:program:`lli` tools, add your creator function's global
+declaration to ``Passes.h`` and add a "pseudo" call line to
+``llvm/Codegen/LinkAllCodegenComponents.h``.
+
 Creating new registries
 ---
 

diff  --git a/llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h 
b/llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
new file mode 100644
index 0..81b0025fdddc5
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
@@ -0,0 +1,37 @@
+//===- llvm/Codegen/LinkAllAsmWriterComponents.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This header file pulls in all assembler writer related passes for tools like
+// llc that need this functionality.
+//
+//===--===//
+
+#ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
+#define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
+
+#include "llvm/IR/BuiltinGCs.h"
+#include 
+
+namespace {
+  struct ForceAsmWriterLinking {
+ForceAsmWriterLinking() {
+  // We must reference the plug-ins in such a way that compilers will not
+  // delete it all as dead code, even with whole program optimization,
+  // yet is effectively a NO-OP. As the compiler isn't smart enough
+  // to know that getenv() never returns -1, this will do the job.
+  if (std::getenv("bar") != (char*) -1)
+return;
+
+  llvm::linkOcamlGCPrinter();
+  llvm::linkErlangGCPrinter();
+
+}
+  } ForceAsmWriterLinking; // Force link by creating a global definition.
+}
+
+#endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H

diff  --git a/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h 
b/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
new file mode 100644
index 0..1b13ff53ac857
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
@@ -0,0 +1,54 @@
+//===- llvm/Codegen/LinkAllCodegenComponents.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This header file pulls in all codegen related passes for tools like lli and
+// llc that need this functionality.
+//
+//===--===//
+
+#ifndef LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H
+#define LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H
+
+#include 

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

2021-11-02 Thread John Ericson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fd2db04d0f2: Use `GNUInstallDirs` to support custom 
installation dirs. -- LLVM (authored by Ericson2314).

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
@@ -323,7 +323,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()
 
@@ -335,7 +335,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
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS 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(LLVM_TOOLS_INSTALL_DIR);
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(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 

[clang] fe364e5 - [NFC] Remove LinkAll*.h

2021-11-02 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-11-02T08:43:17-07:00
New Revision: fe364e5dc78c58a915986d9a44cfd65f919a00c2

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

LOG: [NFC] Remove LinkAll*.h

These were added to prevent functions from being removed by WPO.

But that doesn't make sense, correct WPO will not remove functions we actually 
use.

I noticed these because compiling cc1_main.cpp was pulling in random LLVM pass 
headers.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/tools/driver/cc1_main.cpp
llvm/docs/WritingAnLLVMPass.rst
llvm/include/llvm/module.modulemap
llvm/lib/Analysis/CallPrinter.cpp
llvm/lib/Analysis/DomPrinter.cpp
llvm/lib/Analysis/RegionInfo.cpp
llvm/lib/CodeGen/MachineRegionInfo.cpp
llvm/tools/bugpoint/bugpoint.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/opt/opt.cpp

Removed: 
llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
llvm/include/llvm/LinkAllIR.h
llvm/include/llvm/LinkAllPasses.h



diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index fd3b25ccb3cb1..19273f97c921b 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -27,7 +27,6 @@
 #include "clang/FrontendTool/Utils.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/LinkAllPasses.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"

diff  --git a/llvm/docs/WritingAnLLVMPass.rst b/llvm/docs/WritingAnLLVMPass.rst
index 133775c92dde4..c9955d177036e 100644
--- a/llvm/docs/WritingAnLLVMPass.rst
+++ b/llvm/docs/WritingAnLLVMPass.rst
@@ -1308,11 +1308,6 @@ option.  Registering instruction schedulers is similar 
except use the
 ``RegisterScheduler::FunctionPassCtor`` is significantly 
diff erent from
 ``RegisterRegAlloc::FunctionPassCtor``.
 
-To force the load/linking of your register allocator into the
-:program:`llc`/:program:`lli` tools, add your creator function's global
-declaration to ``Passes.h`` and add a "pseudo" call line to
-``llvm/Codegen/LinkAllCodegenComponents.h``.
-
 Creating new registries
 ---
 

diff  --git a/llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h 
b/llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
deleted file mode 100644
index 81b0025fdddc5..0
--- a/llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//===- llvm/Codegen/LinkAllAsmWriterComponents.h *- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This header file pulls in all assembler writer related passes for tools like
-// llc that need this functionality.
-//
-//===--===//
-
-#ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
-#define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
-
-#include "llvm/IR/BuiltinGCs.h"
-#include 
-
-namespace {
-  struct ForceAsmWriterLinking {
-ForceAsmWriterLinking() {
-  // We must reference the plug-ins in such a way that compilers will not
-  // delete it all as dead code, even with whole program optimization,
-  // yet is effectively a NO-OP. As the compiler isn't smart enough
-  // to know that getenv() never returns -1, this will do the job.
-  if (std::getenv("bar") != (char*) -1)
-return;
-
-  llvm::linkOcamlGCPrinter();
-  llvm::linkErlangGCPrinter();
-
-}
-  } ForceAsmWriterLinking; // Force link by creating a global definition.
-}
-
-#endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H

diff  --git a/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h 
b/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
deleted file mode 100644
index 1b13ff53ac857..0
--- a/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
+++ /dev/null
@@ -1,54 +0,0 @@
-//===- llvm/Codegen/LinkAllCodegenComponents.h --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This header file pulls in all codegen related passes for tools like lli and
-// llc that need this functionality.
-//

[PATCH] D112971: [NFC] Remove LinkAll*.h

2021-11-02 Thread Arthur Eubanks 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 rGfe364e5dc78c: [NFC] Remove LinkAll*.h (authored by aeubanks).
Herald added a subscriber: awarzynski.

Changed prior to commit:
  https://reviews.llvm.org/D112971?vs=383924=384126#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112971

Files:
  clang/tools/driver/cc1_main.cpp
  llvm/docs/WritingAnLLVMPass.rst
  llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
  llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
  llvm/include/llvm/LinkAllIR.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/module.modulemap
  llvm/lib/Analysis/CallPrinter.cpp
  llvm/lib/Analysis/DomPrinter.cpp
  llvm/lib/Analysis/RegionInfo.cpp
  llvm/lib/CodeGen/MachineRegionInfo.cpp
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -35,8 +35,6 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/InitializePasses.h"
-#include "llvm/LinkAllIR.h"
-#include "llvm/LinkAllPasses.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
@@ -52,6 +50,7 @@
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 #include "llvm/Transforms/IPO/WholeProgramDevirt.h"
Index: llvm/tools/lli/lli.cpp
===
--- llvm/tools/lli/lli.cpp
+++ llvm/tools/lli/lli.cpp
@@ -18,7 +18,6 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/CommandFlags.h"
-#include "llvm/CodeGen/LinkAllCodegenComponents.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
 #include "llvm/ExecutionEngine/Interpreter.h"
Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -17,8 +17,6 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/CodeGen/CommandFlags.h"
-#include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
-#include "llvm/CodeGen/LinkAllCodegenComponents.h"
 #include "llvm/CodeGen/MIRParser/MIRParser.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
Index: llvm/tools/bugpoint/bugpoint.cpp
===
--- llvm/tools/bugpoint/bugpoint.cpp
+++ llvm/tools/bugpoint/bugpoint.cpp
@@ -19,8 +19,6 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/LegacyPassNameParser.h"
 #include "llvm/InitializePasses.h"
-#include "llvm/LinkAllIR.h"
-#include "llvm/LinkAllPasses.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
@@ -28,8 +26,10 @@
 #include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/Valgrind.h"
+#include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 
Index: llvm/lib/CodeGen/MachineRegionInfo.cpp
===
--- llvm/lib/CodeGen/MachineRegionInfo.cpp
+++ llvm/lib/CodeGen/MachineRegionInfo.cpp
@@ -136,10 +136,6 @@
 INITIALIZE_PASS_END(MachineRegionInfoPass, DEBUG_TYPE,
 "Detect single entry single exit regions", true, true)
 
-// Create methods available outside of this file, to use them
-// "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
-// the link time optimization.
-
 namespace llvm {
 
 FunctionPass *createMachineRegionInfoPass() {
Index: llvm/lib/Analysis/RegionInfo.cpp
===
--- llvm/lib/Analysis/RegionInfo.cpp
+++ llvm/lib/Analysis/RegionInfo.cpp
@@ -166,10 +166,6 @@
 INITIALIZE_PASS_END(RegionInfoPass, "regions",
 "Detect single entry single exit regions", true, true)
 
-// Create methods available outside of this file, to use them
-// "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
-// the link time optimization.
-
 namespace llvm {
 
   FunctionPass *createRegionInfoPass() {
Index: llvm/lib/Analysis/DomPrinter.cpp
===
--- llvm/lib/Analysis/DomPrinter.cpp
+++ 

[PATCH] D112768: [ARM] implement support for TLS register based stack protector

2021-11-02 Thread Ard Biesheuvel via Phabricator via cfe-commits
ardb updated this revision to Diff 384116.
ardb added a comment.

- add diagnostics to the frontend and asserts to the backend to ensure that the 
TLS stack protector is only used on target subarchs that implement the hardware 
TLS register to begin with
- ensure that the offset parameter is not omitted, as the default is INT_MAX 
which is out of bounds


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112768

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-protector-guard.c
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMInstrInfo.cpp
  llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
  llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
  llvm/test/CodeGen/ARM/stack-guard-tls.ll

Index: llvm/test/CodeGen/ARM/stack-guard-tls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/stack-guard-tls.ll
@@ -0,0 +1,38 @@
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
+; RUN: llc %t/a2.ll -mtriple=armv7-unknown-linux-gnueabihf -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-SMALL %s
+; RUN: llc %t/a2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-SMALL %s
+; RUN: llc %t/b2.ll -mtriple=armv7-unknown-linux-gnueabihf -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-LARGE %s
+; RUN: llc %t/b2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -o - | \
+; RUN: FileCheck --check-prefixes=CHECK,CHECK-LARGE %s
+
+;--- main.ll
+declare void @baz(i32*)
+
+define void @foo(i64 %t) sspstrong {
+  %vla = alloca i32, i64 %t, align 4
+  call void @baz(i32* nonnull %vla)
+  ret void
+}
+!llvm.module.flags = !{!1, !2}
+!1 = !{i32 2, !"stack-protector-guard", !"tls"}
+
+;--- a.ll
+!2 = !{i32 2, !"stack-protector-guard-offset", i32 1296}
+
+;--- b.ll
+!2 = !{i32 2, !"stack-protector-guard-offset", i32 4296}
+
+; CHECK: mrc p15, #0, [[REG1:r[0-9]+]], c13, c0, #3
+; CHECK-SMALL-NEXT: ldr{{(\.w)?}} [[REG1]], {{\[}}[[REG1]], #1296]
+; CHECK-LARGE-NEXT: add{{(\.w)?}} [[REG1]], [[REG1]], #4096
+; CHECK-LARGE-NEXT: ldr{{(\.w)?}} [[REG1]], {{\[}}[[REG1]], #200]
+; CHECK: bl baz
+; CHECK: mrc p15, #0, [[REG2:r[0-9]+]], c13, c0, #3
+; CHECK-SMALL-NEXT: ldr{{(\.w)?}} [[REG2]], {{\[}}[[REG2]], #1296]
+; CHECK-LARGE-NEXT: add{{(\.w)?}} [[REG2]], [[REG2]], #4096
+; CHECK-LARGE-NEXT: ldr{{(\.w)?}} [[REG2]], {{\[}}[[REG2]], #200]
Index: llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
===
--- llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
+++ llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
@@ -250,6 +250,13 @@
 void Thumb2InstrInfo::expandLoadStackGuard(
 MachineBasicBlock::iterator MI) const {
   MachineFunction  = *MI->getParent()->getParent();
+  Module  = *MF.getFunction().getParent();
+
+  if (M.getStackProtectorGuard() == "tls") {
+expandLoadStackGuardBase(MI, ARM::t2MRC, ARM::t2LDRi12);
+return;
+  }
+
   const GlobalValue *GV =
   cast((*MI->memoperands_begin())->getValue());
 
Index: llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
===
--- llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
+++ llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
@@ -135,6 +135,11 @@
 MachineBasicBlock::iterator MI) const {
   MachineFunction  = *MI->getParent()->getParent();
   const TargetMachine  = MF.getTarget();
+  Module  = *MF.getFunction().getParent();
+
+  assert(M.getStackProtectorGuard() != "tls" &&
+ "TLS stack protector not supported for Thumb1 targets");
+
   if (TM.isPositionIndependent())
 expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_pcrel, ARM::tLDRi);
   else
Index: llvm/lib/Target/ARM/ARMInstrInfo.cpp
===
--- llvm/lib/Target/ARM/ARMInstrInfo.cpp
+++ llvm/lib/Target/ARM/ARMInstrInfo.cpp
@@ -95,6 +95,12 @@
   MachineFunction  = *MI->getParent()->getParent();
   const ARMSubtarget  = MF.getSubtarget();
   const TargetMachine  = MF.getTarget();
+  Module  = *MF.getFunction().getParent();
+
+  if (M.getStackProtectorGuard() == "tls") {
+expandLoadStackGuardBase(MI, ARM::MRC, ARM::LDRi12);
+return;
+  }
 
   const GlobalValue *GV =
   cast((*MI->memoperands_begin())->getValue());
Index: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
===
--- llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -4891,40 +4891,70 @@
   MachineBasicBlock  = *MI->getParent();
   DebugLoc DL = MI->getDebugLoc();
   Register Reg = MI->getOperand(0).getReg();
-  const GlobalValue *GV =
-  cast((*MI->memoperands_begin())->getValue());
-  bool IsIndirect = Subtarget.isGVIndirectSymbol(GV);
   MachineInstrBuilder 

[PATCH] D106823: [analyzer][solver] Iterate to a fixpoint during symbol simplification with constants

2021-11-02 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 384122.
martong added a comment.

- Add essay about complexity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106823

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/expr-inspection-printState-eq-classes.c
  clang/test/Analysis/symbol-simplification-disequality-info.cpp
  
clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
  clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
  clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp

Index: clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   2>&1 | FileCheck %s
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint. This should be done after TWO iterations.
+
+void clang_analyzer_printState();
+
+void test(int a, int b, int c, int d) {
+  if (a + b + c != d)
+return;
+  if (c + b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "(((reg_$0) + (reg_$1)) + (reg_$2)) != (reg_$3)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:   { "symbol": "(reg_$2) + (reg_$1)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "((reg_$0) + (reg_$1)) + (reg_$2)", "reg_$3" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Simplification starts here.
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:   "constraints": [
+  // CHECK-NEXT:{ "symbol": "(reg_$0) != (reg_$3)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:{ "symbol": "reg_$1", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:{ "symbol": "reg_$2", "range": "{ [0, 0] }" }
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "equivalence_classes": [
+  // CHECK-NEXT:[ "(reg_$0) != (reg_$3)" ],
+  // CHECK-NEXT:[ "reg_$0", "reg_$3" ],
+  // CHECK-NEXT:[ "reg_$2" ]
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "disequality_info": null,
+
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
Index: clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   2>&1 | FileCheck %s
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint. This should be done after one iteration.
+
+void clang_analyzer_printState();
+
+void test(int a, int b, int c) {
+  if (a + b != c)
+return;
+  clang_analyzer_printState();
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "((reg_$0) + (reg_$1)) != (reg_$2)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "(reg_$0) + (reg_$1)", "reg_$2" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Simplification starts here.
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:"constraints": [
+  // CHECK-NEXT: { "symbol": "(reg_$0) != (reg_$2)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT: { "symbol": "reg_$1", "range": "{ [0, 0] }" }
+  // CHECK-NEXT:   ],
+  // CHECK-NEXT:   "equivalence_classes": [
+  // CHECK-NEXT: [ "(reg_$0) != (reg_$2)" ],
+  // CHECK-NEXT: [ "reg_$0", "reg_$2" ]
+  // CHECK-NEXT:   ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c);
+  return;
+}
Index: clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint.
+
+void clang_analyzer_warnIfReached();
+
+void test_contradiction(int a, int b, int c, int d, int x) {
+  if (a + b + c != d)
+return;
+  if (a == d)
+return;
+  if (b + c != 0)
+return;
+  clang_analyzer_warnIfReached(); 

[PATCH] D112914: Misleading identifier detection

2021-11-02 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 384118.
serge-sans-paille added a comment.

Minor typos


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

https://reviews.llvm.org/D112914

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp
  clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-misleading-identifier.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-misleading-identifier.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misleading-identifier.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s misc-misleading-identifier %t
+
+#include 
+
+// CHECK-MESSAGES: :[[@LINE+1]]:1: warning: identifier has right-to-left codepoints
+short int א = (short int)0;
+// CHECK-MESSAGES: :[[@LINE+1]]:1: warning: identifier has right-to-left codepoints
+short int ג = (short int)12345;
+
+int main() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:5: warning: identifier has right-to-left codepoints
+  int א = ג; // a local variable, set to zero?
+  printf("ג is %d\n", ג);
+  printf("א is %d\n", א);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - misc-misleading-identifier
+
+misc-misleading-identifier
+==
+
+Finds identifiers that contain Unicode characters with right-to-left direction,
+which can be confusing as they may change the understanding of a whole statement
+line, as described in `Trojan Source `_.
+
+An example of such misleading code follows:
+
+.. code-block:: c
+
+#include 
+
+short int א = (short int)0;
+short int ג = (short int)12345;
+
+int main() {
+  int א = ג; // a local variable, set to zero?
+  printf("ג is %d\n", ג);
+  printf("א is %d\n", א);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -211,6 +211,7 @@
`llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
+   `misc-misleading-identifier `_,
`misc-misplaced-const `_,
`misc-new-delete-overloads `_,
`misc-no-recursion `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,12 +94,15 @@
   Reports identifiers whose names are too short. Currently checks local
   variables and function parameters only.
 
-
 - New :doc:`readability-data-pointer ` check.
 
   Finds cases where code could use ``data()`` rather than the address of the
   element at index 0 in a container.
 
+- New :doc:`misc-misleading-identifier ` check.
+
+  Reports identifier with unicode right-to-left characters.
+
 New check aliases
 ^
 
Index: clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
@@ -0,0 +1,32 @@
+//===--- MisleadingIdentifierCheck.h - clang-tidy *- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MisleadingIdentifierCheck : public ClangTidyCheck {
+public:
+  MisleadingIdentifierCheck(StringRef Name, ClangTidyContext *Context);
+  ~MisleadingIdentifierCheck();
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
Index: clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp
===
--- /dev/null
+++ 

[PATCH] D106823: [analyzer][solver] Iterate to a fixpoint during symbol simplification with constants

2021-11-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1699-1701
+  ProgramStateRef OldState;
+  do {
+OldState = State;

steakhal wrote:
> IMO we should have a `llvm::Statistic` here, tracking the maximum iteration 
> count to reach the fixed point and an average iteration count.
We can't do this once we reach the fixpoint with recursive `assume` calls.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1732
+  if (!State)
+return false;
+}

steakhal wrote:
> I'd love to see a coverage report of the tests you add with this patch.
Ok, I am going to check the coverage and add the missing cases.



Comment at: clang/test/Analysis/expr-inspection-printState-eq-classes.c:11
 return;
-  if (b != 0)
+  if (a != c)
 return;

steakhal wrote:
> Why do you need to change this?
We don't need it, I removed.



Comment at: 
clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp:16
+return;
+  if (c + b != 0)
+return;

steakhal wrote:
> Is it important to have this instead of `b + c`?
No, I changed it to `b+c` as you suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106823

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


[PATCH] D106823: [analyzer][solver] Iterate to a fixpoint during symbol simplification with constants

2021-11-02 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 384117.
martong marked 3 inline comments as done.
martong added a comment.

- Reach the fixpoint by recursively calling `State->assume` on the simplified 
symbol.
- Address review nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106823

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/expr-inspection-printState-eq-classes.c
  clang/test/Analysis/symbol-simplification-disequality-info.cpp
  
clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
  clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
  clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp

Index: clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   2>&1 | FileCheck %s
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint. This should be done after TWO iterations.
+
+void clang_analyzer_printState();
+
+void test(int a, int b, int c, int d) {
+  if (a + b + c != d)
+return;
+  if (c + b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "(((reg_$0) + (reg_$1)) + (reg_$2)) != (reg_$3)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:   { "symbol": "(reg_$2) + (reg_$1)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "((reg_$0) + (reg_$1)) + (reg_$2)", "reg_$3" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Simplification starts here.
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:   "constraints": [
+  // CHECK-NEXT:{ "symbol": "(reg_$0) != (reg_$3)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:{ "symbol": "reg_$1", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:{ "symbol": "reg_$2", "range": "{ [0, 0] }" }
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "equivalence_classes": [
+  // CHECK-NEXT:[ "(reg_$0) != (reg_$3)" ],
+  // CHECK-NEXT:[ "reg_$0", "reg_$3" ],
+  // CHECK-NEXT:[ "reg_$2" ]
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "disequality_info": null,
+
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
Index: clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   2>&1 | FileCheck %s
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint. This should be done after one iteration.
+
+void clang_analyzer_printState();
+
+void test(int a, int b, int c) {
+  if (a + b != c)
+return;
+  clang_analyzer_printState();
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "((reg_$0) + (reg_$1)) != (reg_$2)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "(reg_$0) + (reg_$1)", "reg_$2" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Simplification starts here.
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:"constraints": [
+  // CHECK-NEXT: { "symbol": "(reg_$0) != (reg_$2)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT: { "symbol": "reg_$1", "range": "{ [0, 0] }" }
+  // CHECK-NEXT:   ],
+  // CHECK-NEXT:   "equivalence_classes": [
+  // CHECK-NEXT: [ "(reg_$0) != (reg_$2)" ],
+  // CHECK-NEXT: [ "reg_$0", "reg_$2" ]
+  // CHECK-NEXT:   ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c);
+  return;
+}
Index: clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint.
+
+void clang_analyzer_warnIfReached();
+
+void test_contradiction(int a, int b, int c, int d, int x) {
+  if (a 

[PATCH] D112453: [Sema] When dereferencing a pointer of dependent type, infer the result type.

2021-11-02 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

Ping ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112453

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


[PATCH] D112491: Add `LambdaCapture`-related matchers.

2021-11-02 Thread James King via Phabricator via cfe-commits
jcking1034 updated this revision to Diff 384114.
jcking1034 added a comment.

Update documentation for `capturesVar` matcher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112491

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -563,26 +563,6 @@
   objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x";
 }
 
-TEST(Matcher, HasAnyCapture) {
-  auto HasCaptureX = lambdaExpr(hasAnyCapture(varDecl(hasName("x";
-  EXPECT_TRUE(matches("void f() { int x = 3; [x](){}; }", HasCaptureX));
-  EXPECT_TRUE(matches("void f() { int x = 3; [](){}; }", HasCaptureX));
-  EXPECT_TRUE(notMatches("void f() { [](){}; }", HasCaptureX));
-  EXPECT_TRUE(notMatches("void f() { int z = 3; [](){}; }", HasCaptureX));
-  EXPECT_TRUE(
-  notMatches("struct a { void f() { [this](){}; }; };", HasCaptureX));
-}
-
-TEST(Matcher, CapturesThis) {
-  auto HasCaptureThis = lambdaExpr(hasAnyCapture(cxxThisExpr()));
-  EXPECT_TRUE(
-  matches("struct a { void f() { [this](){}; }; };", HasCaptureThis));
-  EXPECT_TRUE(notMatches("void f() { [](){}; }", HasCaptureThis));
-  EXPECT_TRUE(notMatches("void f() { int x = 3; [x](){}; }", HasCaptureThis));
-  EXPECT_TRUE(notMatches("void f() { int x = 3; [](){}; }", HasCaptureThis));
-  EXPECT_TRUE(notMatches("void f() { int z = 3; [](){}; }", HasCaptureThis));
-}
-
 TEST(Matcher, MatchesMethodsOnLambda) {
   StringRef Code = R"cpp(
 struct A {
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2237,6 +2237,65 @@
  varDecl(hasName("ss"), hasTypeLoc(elaboratedTypeLoc();
 }
 
+TEST_P(ASTMatchersTest, LambdaCaptureTest) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(matches("int main() { int cc; auto f = [cc](){ return cc; }; }",
+  lambdaExpr(hasAnyCapture(lambdaCapture();
+}
+
+TEST_P(ASTMatchersTest, LambdaCaptureTest_BindsToCaptureOfVarDecl) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  auto matcher = lambdaExpr(
+  hasAnyCapture(lambdaCapture(capturesVar(varDecl(hasName("cc"));
+  EXPECT_TRUE(matches("int main() { int cc; auto f = [cc](){ return cc; }; }",
+  matcher));
+  EXPECT_TRUE(matches("int main() { int cc; auto f = [](){ return cc; }; }",
+  matcher));
+  EXPECT_TRUE(
+  matches("int main() { int cc; auto f = [=](){ return cc; }; }", matcher));
+  EXPECT_TRUE(
+  matches("int main() { int cc; auto f = [&](){ return cc; }; }", matcher));
+}
+
+TEST_P(ASTMatchersTest, LambdaCaptureTest_BindsToCaptureWithInitializer) {
+  if (!GetParam().isCXX14OrLater()) {
+return;
+  }
+  auto matcher = lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(
+  varDecl(hasName("cc"), hasInitializer(integerLiteral(equals(1;
+  EXPECT_TRUE(
+  matches("int main() { auto lambda = [cc = 1] {return cc;}; }", matcher));
+  EXPECT_TRUE(
+  matches("int main() { int cc = 2; auto lambda = [cc = 1] {return cc;}; }",
+  matcher));
+}
+
+TEST_P(ASTMatchersTest, LambdaCaptureTest_DoesNotBindToCaptureOfVarDecl) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  auto matcher = lambdaExpr(
+  hasAnyCapture(lambdaCapture(capturesVar(varDecl(hasName("cc"));
+  EXPECT_FALSE(matches("int main() { auto f = [](){ return 5; }; }", matcher));
+  EXPECT_FALSE(matches("int main() { int xx; auto f = [xx](){ return xx; }; }",
+   matcher));
+}
+
+TEST_P(ASTMatchersTest,
+   LambdaCaptureTest_DoesNotBindToCaptureWithInitializerAndDifferentName) {
+  if (!GetParam().isCXX14OrLater()) {
+return;
+  }
+  EXPECT_FALSE(matches(
+  "int main() { auto lambda = [xx = 1] {return xx;}; }",
+  lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(varDecl(
+  hasName("cc"), hasInitializer(integerLiteral(equals(1));
+}
+
 TEST(ASTMatchersTestObjC, ObjCMessageExpr) {
   // Don't find ObjCMessageExpr where none are present.
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

[PATCH] D112913: Misleading bidirectional detection

2021-11-02 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 384111.
serge-sans-paille added a comment.

- recover from failed utf8 decoding
- doc and release note updated
- clang-formatting
- more examples / testing


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

https://reviews.llvm.org/D112913

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
  clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-misleading-bidirectional.rst
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/test/clang-tidy/checkers/misc-misleading-bidirectional.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-misleading-bidirectional.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misleading-bidirectional.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s misc-misleading-bidirectional %t
+
+void func(void) {
+  int admin = 0;
+  /*‮ }⁦if(admin)⁩ ⁦ begin*/
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comment contains misleading bidirectional Unicode characters [misc-misleading-bidirectional]
+  const char msg[] = "‮⁦if(admin)⁩ ⁦tes";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: string literal contains misleading bidirectional Unicode characters [misc-misleading-bidirectional]
+}
+
+void all_fine(void) {
+  char valid[] = "some‮valid‬sequence";
+  /* EOL ends bidi‮ sequence
+   * end it's fine to do so.
+   * EOL ends ⁧isolate too
+   */
+}
+
+int invalid_utf_8(void) {
+  bool isAdmin = false;
+
+  // the comment below contains an invalid utf8 character, but should still be
+  // processed.
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:5: warning: comment contains misleading bidirectional Unicode characters [misc-misleading-bidirectional]
+  /*€‮ } ⁦if (isAdmin)⁩ ⁦ begin admins only */
+  return 1;
+  /* end admins only ‮ { ⁦*/
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: comment contains misleading bidirectional Unicode characters [misc-misleading-bidirectional]
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -34,7 +34,7 @@
 
 
 def write_file(file_name, text):
-  with open(file_name, 'w') as f:
+  with open(file_name, 'w', encoding='utf-8') as f:
 f.write(text)
 f.truncate()
 
@@ -82,7 +82,7 @@
   if resource_dir is not None:
 clang_extra_args.append('-resource-dir=%s' % resource_dir)
 
-  with open(input_file_name, 'r') as input_file:
+  with open(input_file_name, 'r', encoding="utf-8") as input_file:
 input_text = input_file.read()
 
   check_fixes_prefixes = []
Index: clang-tools-extra/docs/clang-tidy/checks/misc-misleading-bidirectional.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misleading-bidirectional.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - misc-misleading-bidirectional
+
+misc-misleading-bidirectional
+=
+
+Warn about unterminated bidirectional unicode sequence, detecting potential attack
+as described in the `Trojan Source `_ attack.
+
+Example:
+
+.. code-block:: c++
+
+#include 
+
+int main() {
+bool isAdmin = false;
+/*‮ } ⁦if (isAdmin)⁩ ⁦ begin admins only */
+std::cout << "You are an admin.\n";
+/* end admins only ‮ { ⁦*/
+return 0;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -211,6 +211,7 @@
`llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
+   `misc-misleading-bidirectional `_,
`misc-misplaced-const `_,
`misc-new-delete-overloads `_,
`misc-no-recursion `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -100,6 +100,11 @@
   Finds cases where code could use ``data()`` rather than the address of the
   element at index 0 in a container.
 
+- New :doc:`misc-misleading-bidirectional ` check.
+
+  Inspect string literal and comments for unterminated bidirectional Unicode
+  characters.
+
 New check aliases
 ^
 
Index: 

[PATCH] D111866: [RISCV] Support Zfhmin extension

2021-11-02 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.
Herald added a subscriber: luke957.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1153
bool ForCodeSize) const {
-  if (VT == MVT::f16 && !Subtarget.hasStdExtZfh())
+  if (VT == MVT::f16 && !Subtarget.hasStdExtZfhmin() &&
+  !Subtarget.hasStdExtZfh())

This could equivalently just be `  if (VT == MVT::f16 && 
!Subtarget.hasStdExtZfhmin())`, right?



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1177
+  if (VT == MVT::f16 && Subtarget.hasStdExtF() &&
+  !Subtarget.hasStdExtZfhmin() && !Subtarget.hasStdExtZfh())
 return MVT::f32;

This could just be `!Subtarget.hasStdExtZfhmin()`?



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1189
+  if (VT == MVT::f16 && Subtarget.hasStdExtF() &&
+  !Subtarget.hasStdExtZfhmin() && !Subtarget.hasStdExtZfh())
 return 1;

This could just be `Subtarget.hasStdExtZfhmin()`?



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1396
   case MVT::f16:
-if (!Subtarget.hasStdExtZfh())
+if (!Subtarget.hasStdExtZfhmin() && !Subtarget.hasStdExtZfh())
   return false;

This could just be `!Subtarget.hasStdExtZfhmin()`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111866

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


[PATCH] D108451: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

2021-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5880c835bdbe: [Sema] Avoid crash in CheckEnumConstant with 
contains-error expressions (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108451

Files:
  clang/lib/Sema/SemaDecl.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
@@ -143,3 +143,11 @@
 void crash1() { fun(); }
 void crash2() { constexpr int s = fun(); }
 } // namespace test12
+
+namespace test13 {
+enum Circular { // expected-note {{not complete until the closing 
'}'}}
+  Circular_A = Circular(1), // expected-error {{'test13::Circular' is an 
incomplete type}}
+};
+// Enumerators can be evaluated (they evaluate as zero, but we don't care).
+static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error 
{{static_assert failed}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17813,7 +17813,8 @@
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -143,3 +143,11 @@
 void crash1() { fun(); }
 void crash2() { constexpr int s = fun(); }
 } // namespace test12
+
+namespace test13 {
+enum Circular { // expected-note {{not complete until the closing '}'}}
+  Circular_A = Circular(1), // expected-error {{'test13::Circular' is an incomplete type}}
+};
+// Enumerators can be evaluated (they evaluate as zero, but we don't care).
+static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error {{static_assert failed}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17813,7 +17813,8 @@
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5880c83 - [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

2021-11-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-11-02T15:35:53+01:00
New Revision: 5880c835bdbe50542a19c3e4065d1536db711443

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

LOG: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

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

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8228292a3153a..d9844f18e1cf9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -17813,7 +17813,8 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl 
*Enum,
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed

diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp 
b/clang/test/SemaCXX/recovery-expr-type.cpp
index 15b83e50387f7..2fdbd0d3b6c30 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -143,3 +143,11 @@ int fun(int *foo = no_such_function()); // expected-error 
{{undeclared identifie
 void crash1() { fun(); }
 void crash2() { constexpr int s = fun(); }
 } // namespace test12
+
+namespace test13 {
+enum Circular { // expected-note {{not complete until the closing 
'}'}}
+  Circular_A = Circular(1), // expected-error {{'test13::Circular' is an 
incomplete type}}
+};
+// Enumerators can be evaluated (they evaluate as zero, but we don't care).
+static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error 
{{static_assert failed}}
+}



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


[PATCH] D112647: [clang-apply-replacements] Correctly handle relative paths

2021-11-02 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a subscriber: alexfh.
avogelsgesang added a comment.

>> Those relative paths are meant to be resolved relative to the corresponding 
>> build directory.
>
> Is this behavior documented somewhere?

I couldn't find this documented anywhere. My assumption is based on behavior 
which I observed from clang-tidy. Without this patch, `clang-apply-fixes` 
failed to apply the changes exported by `clang-tidy --export-fixes` due to its 
inability to find some source files referred to through relative paths

It seems the `clang::tooling::Diagnostic::BuildDirectory` was introduced in 
https://reviews.llvm.org/D26137. Maybe @alexfh who reviewed that patch can 
provide some more context here?




Comment at: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp:159
 // automatically canonicalized.
+auto  = SM.getFileManager().getFileSystemOpts().WorkingDir;
+auto PrevWorkingDir = WorkingDir;

ymandel wrote:
> Why are you capturing this as a reference? This is a subtle and IMO error 
> prone pattern, since it's not obvious in the code below that you're mutating 
> a deeply nested element of the filesystem.  Can  you instead use a local 
> variable and just set this right before you need it?
> Why are you capturing this as a reference?

Mostly to keep the code shorter. Otherwise, I would have to write

```
auto PrevWorkingDir = SM.getFileManager().getFileSystemOpts().WorkingDir;
if (buildDir)
  SM.getFileManager().getFileSystemOpts().WorkingDir = *buildDir;
// [...]
WorkingDir = SM.getFileManager().getFileSystemOpts().WorkingDir;
```

which isn't really DRY.

> Can you instead use a local variable and just set this right before you need 
> it?

I think I don't understand the alternative you are proposing here. Can you 
provide an example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112647

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


[PATCH] D112914: Misleading identifier detection

2021-11-02 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D112914#3102728 , @carlosgalvezp 
wrote:

> Ok! I don't really know what applies when you take //part// of a file, so 
> I'll leave that up to people who know. I don't know how to remove the 
> "Requested changes" from here so I'll just remove myself from reviewer.

That's a valid question, but I guess that using spec content is ok... not 100% 
sure though.

> PS: I don't know what AKAIU means, nor can I find the answer in Google :)

I meant AFAIU, I'm so skilled I can make typo in acronyms :-)


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

https://reviews.llvm.org/D112914

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I note now that asserts build fails for it: https://godbolt.org/z/r738hGoKf

Should this be reverted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

So I've noticed in my downstream that this fires in the cpu-dispatch.c codegen 
test, though it doesn't seem to catch it here?  I'm not sure how this happens, 
but from your description, it SEEMS like this case 
https://godbolt.org/z/nejWhbsxa should cause this error.

That said, the cpuspecific/cpudispatch multiviersioning takes advantage of the 
resolver not being implemented (and being linked in later!) in order to 
implement some parts of it. So I'm not sure the 'resolver requires a 
definition' is a valid check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

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


[libclc] 6fd2db0 - Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-11-02 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2021-11-02T10:23:30-04:00
New Revision: 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73

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

LOG: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

This is a new draft of D28234. I previously did the unorthodox thing of
pushing to it when I wasn't the original author, but since this version

- Uses `GNUInstallDirs`, rather than mimics it, as the original author
  was hesitant to do but others requested.

- Is much broader, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I am using this patch (and many back-ports) as the basis of
https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It
looked like people were generally on board in D28234, but I make note of
this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM
already has some partial support for these sorts of things. For example
`LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not
quite clear yet what to do about those, we are holding off on changing
libdirs and `compiler-rt`. for this initial PR.

---

On the advice of @lebedev.ri, I am splitting this up a bit per
subproject, starting with LLVM. To allow it to be more easily reviewed. This 
and the subsequent patch must be landed together, as this will not build alone. 
But the rest can be landed on their own.

Reviewed By: compnerd

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

Added: 


Modified: 
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

Removed: 




diff  --git a/clang/tools/scan-build/CMakeLists.txt 
b/clang/tools/scan-build/CMakeLists.txt
index ec0702d76f184..74334e53c9b18 100644
--- a/clang/tools/scan-build/CMakeLists.txt
+++ b/clang/tools/scan-build/CMakeLists.txt
@@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
+add_custom_command(OUTPUT 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"
COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
- ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
+ "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
+list(APPEND Depends 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")
 install(PROGRAMS man/${ManPage}
-DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
 COMPONENT scan-build)
   endforeach()
 

diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index ec39ea63f2d02..e90e0fd852012 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -183,8 +183,8 @@ endif()
 
 # pkg-config file
 configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
${CMAKE_INSTALL_DATADIR}/pkgconfig )
-install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 
)
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
"${CMAKE_INSTALL_DATADIR}/pkgconfig" )
+install( DIRECTORY generic/include/clc DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}" )
 
 if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_use_default STATIC
@@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_disable STATIC
generic/lib/subnormal_disable.ll )
install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-   DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+   

[clang] 6fd2db0 - Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-11-02 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2021-11-02T10:23:30-04:00
New Revision: 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73

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

LOG: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

This is a new draft of D28234. I previously did the unorthodox thing of
pushing to it when I wasn't the original author, but since this version

- Uses `GNUInstallDirs`, rather than mimics it, as the original author
  was hesitant to do but others requested.

- Is much broader, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I am using this patch (and many back-ports) as the basis of
https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It
looked like people were generally on board in D28234, but I make note of
this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM
already has some partial support for these sorts of things. For example
`LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not
quite clear yet what to do about those, we are holding off on changing
libdirs and `compiler-rt`. for this initial PR.

---

On the advice of @lebedev.ri, I am splitting this up a bit per
subproject, starting with LLVM. To allow it to be more easily reviewed. This 
and the subsequent patch must be landed together, as this will not build alone. 
But the rest can be landed on their own.

Reviewed By: compnerd

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

Added: 


Modified: 
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

Removed: 




diff  --git a/clang/tools/scan-build/CMakeLists.txt 
b/clang/tools/scan-build/CMakeLists.txt
index ec0702d76f184..74334e53c9b18 100644
--- a/clang/tools/scan-build/CMakeLists.txt
+++ b/clang/tools/scan-build/CMakeLists.txt
@@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
+add_custom_command(OUTPUT 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"
COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
- ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
+ "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
+list(APPEND Depends 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")
 install(PROGRAMS man/${ManPage}
-DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
 COMPONENT scan-build)
   endforeach()
 

diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index ec39ea63f2d02..e90e0fd852012 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -183,8 +183,8 @@ endif()
 
 # pkg-config file
 configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
${CMAKE_INSTALL_DATADIR}/pkgconfig )
-install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 
)
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
"${CMAKE_INSTALL_DATADIR}/pkgconfig" )
+install( DIRECTORY generic/include/clc DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}" )
 
 if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_use_default STATIC
@@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_disable STATIC
generic/lib/subnormal_disable.ll )
install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-   DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+   

[PATCH] D108451: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

2021-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, and sorry for sitting on this so long.

Addressed comments. I think the failing windows bots were implicit 
`-fms-extensions` or so that sometimes makes diagnosis more lazy. Moving the 
test to recovery-expr-type.cpp should take care of this as that test case 
specifies `-triple`. But waiting for the windows bot to finish before landing.




Comment at: clang/test/Sema/enum.cpp:8-9
+// When initializers contain errors, enumerators are non-type-dependent zeros.
+static_assert(Circular_A != 0, ""); // expected-error {{static_assert failed}}
+static_assert(Circular_B != 0, ""); // expected-error {{static_assert failed}}

aaron.ballman wrote:
> Should we be static asserting this? It seems like emergent behavior more than 
> something we intentionally want anyone to rely on.
Yeah, the thing we're testing is that we can const-evaluate these, and it 
neither crashes nor propagates dependence further. The static_assert checks the 
latter.

Replaced with a static assert that isn't sensitive tot he actual value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108451

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2021-11-02 Thread wangpc via Phabricator via cfe-commits
pcwang-thead updated this revision to Diff 384089.
pcwang-thead added a comment.

Makes required changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  clang/unittests/StaticAnalyzer/CallEventTest.cpp
  clang/www/cxx_status.html
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp

Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -9,10 +9,8 @@
 // test sized operator delete replacement.
 
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
-
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// XFAIL: clang-12, clang-13
+// XFAIL: apple-clang-13
 
 #include 
 #include 
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -9,10 +9,8 @@
 // test sized operator delete[] replacement.
 
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
-
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// XFAIL: clang-12, clang-13
+// XFAIL: apple-clang-13
 
 #include 
 #include 
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -578,12 +578,11 @@
 
 
 
-(7): In Clang 3.7 and later, sized deallocation is only enabled
-if the user passes the -fsized-deallocation flag. The user must
-supply definitions of the sized deallocation functions, either by providing them
-explicitly or by using a C++ standard library that does. libstdc++
-added these functions in version 5.0, and libc++ added them in
-version 3.7.
+(7): The user must supply definitions of the sized deallocation
+functions, either by providing them explicitly or by using a C++ standard library
+that does. libstdc++ added these functions in version 5.0, and
+libc++ added them in version 3.7. The user can also use the
+-fno-sized-deallocation option to disable sized deallocation.
 
 
 
Index: clang/unittests/StaticAnalyzer/CallEventTest.cpp
===
--- clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -81,7 +81,7 @@
 }
   )",
  Diags));
-  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
+  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 2\n");
 }
 
 } // namespace
Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
-// RUN: %clang_cc1 

[PATCH] D108451: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

2021-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 384084.
sammccall marked 3 inline comments as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108451

Files:
  clang/lib/Sema/SemaDecl.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
@@ -143,3 +143,11 @@
 void crash1() { fun(); }
 void crash2() { constexpr int s = fun(); }
 } // namespace test12
+
+namespace test13 {
+enum Circular { // expected-note {{not complete until the closing 
'}'}}
+  Circular_A = Circular(1), // expected-error {{'test13::Circular' is an 
incomplete type}}
+};
+// Enumerators can be evaluated (they evaluate as zero, but we don't care).
+static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error 
{{static_assert failed}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17813,7 +17813,8 @@
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -143,3 +143,11 @@
 void crash1() { fun(); }
 void crash2() { constexpr int s = fun(); }
 } // namespace test12
+
+namespace test13 {
+enum Circular { // expected-note {{not complete until the closing '}'}}
+  Circular_A = Circular(1), // expected-error {{'test13::Circular' is an incomplete type}}
+};
+// Enumerators can be evaluated (they evaluate as zero, but we don't care).
+static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error {{static_assert failed}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17813,7 +17813,8 @@
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112001: [Clang] Add min/max reduction builtins.

2021-11-02 Thread Florian Hahn 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 rG7999355106fb: [Clang] Add min/max reduction builtins. 
(authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112001

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-reduction-math.c
  clang/test/Sema/builtins-reduction-math.c

Index: clang/test/Sema/builtins-reduction-math.c
===
--- /dev/null
+++ clang/test/Sema/builtins-reduction-math.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+typedef unsigned unsigned4 __attribute__((ext_vector_type(4)));
+
+struct Foo {
+  char *p;
+};
+
+void test_builtin_reduce_max(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_max(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_max(v, v);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_max();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_max(i);
+  // expected-error@-1 {{1st argument must be a vector type (was 'int')}}
+}
+
+void test_builtin_reduce_min(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_min(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_min(v, v);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_min();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_min(i);
+  // expected-error@-1 {{1st argument must be a vector type (was 'int')}}
+}
Index: clang/test/CodeGen/builtins-reduction-math.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-reduction-math.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef short int si8 __attribute__((ext_vector_type(8)));
+typedef unsigned int u4 __attribute__((ext_vector_type(4)));
+
+__attribute__((address_space(1))) float4 vf1_as_one;
+
+void test_builtin_reduce_max(float4 vf1, si8 vi1, u4 vu1) {
+  // CHECK-LABEL: define void @test_builtin_reduce_max(
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1]])
+  float r1 = __builtin_reduce_max(vf1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_max(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_max(vu1);
+
+  // CHECK:  [[VF1_AS1:%.+]] = load <4 x float>, <4 x float> addrspace(1)* @vf1_as_one, align 16
+  // CHECK-NEXT: [[RDX1:%.+]] = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1_AS1]])
+  // CHECK-NEXT: fpext float [[RDX1]] to double
+  const double r4 = __builtin_reduce_max(vf1_as_one);
+
+  // CHECK:  [[CVI1:%.+]] = load <8 x i16>, <8 x i16>* %cvi1, align 16
+  // CHECK-NEXT: [[RDX2:%.+]] = call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[CVI1]])
+  // CHECK-NEXT: sext i16 [[RDX2]] to i64
+  const si8 cvi1 = vi1;
+  unsigned long long r5 = __builtin_reduce_max(cvi1);
+}
+
+void test_builtin_reduce_min(float4 vf1, si8 vi1, u4 vu1) {
+  // CHECK-LABEL: define void @test_builtin_reduce_min(
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call float @llvm.vector.reduce.fmin.v4f32(<4 x float> [[VF1]])
+  float r1 = __builtin_reduce_min(vf1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_min(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_min(vu1);
+
+  // CHECK:  [[VF1_AS1:%.+]] = load <4 x float>, <4 x float> addrspace(1)* @vf1_as_one, align 16
+  // CHECK-NEXT: [[RDX1:%.+]] = call float 

[clang] 7999355 - [Clang] Add min/max reduction builtins.

2021-11-02 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-11-02T15:01:42+01:00
New Revision: 7999355106fb2fcc8de243d2e34b4b73ae4f3d2f

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

LOG: [Clang] Add min/max reduction builtins.

This patch implements __builtin_reduce_max and __builtin_reduce_min as
specified in D111529.

The order of operations does not matter for min or max reductions and
they can be directly lowered to the corresponding
llvm.vector.reduce.{fmin,fmax,umin,umax,smin,smax} intrinsic calls.

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGen/builtins-reduction-math.c
clang/test/Sema/builtins-reduction-math.c

Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 7d331a86126f1..b05777889e79a 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -646,6 +646,8 @@ BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
 BUILTIN(__builtin_elementwise_abs, "v.", "nct")
 BUILTIN(__builtin_elementwise_max, "v.", "nct")
 BUILTIN(__builtin_elementwise_min, "v.", "nct")
+BUILTIN(__builtin_reduce_max, "v.", "nct")
+BUILTIN(__builtin_reduce_min, "v.", "nct")
 
 BUILTIN(__builtin_matrix_transpose, "v.", "nFt")
 BUILTIN(__builtin_matrix_column_major_load, "v.", "nFt")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d37c8e9266e9b..a67ef684f1e5c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11313,7 +11313,7 @@ def err_builtin_invalid_arg_type: Error <
   "%ordinal0 argument must be a "
   "%select{vector, integer or floating point type|matrix|"
"pointer to a valid matrix element type|"
-   "signed integer or floating point type}1 (was %2)">;
+   "signed integer or floating point type|vector type}1 (was %2)">;
 
 def err_builtin_matrix_disabled: Error<
   "matrix types extension is disabled. Pass -fenable-matrix to enable it">;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 11e157bc7d731..909328b164d5c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12732,6 +12732,7 @@ class Sema final {
 
   bool SemaBuiltinElementwiseMath(CallExpr *TheCall);
   bool SemaBuiltinElementwiseMathOneArg(CallExpr *TheCall);
+  bool SemaBuiltinReduceMath(CallExpr *TheCall);
 
   // Matrix builtin handling.
   ExprResult SemaBuiltinMatrixTranspose(CallExpr *TheCall,

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 501b0e3c34436..fab21e5b588a5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3145,6 +3145,44 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_reduce_max: {
+auto GetIntrinsicID = [](QualType QT, llvm::Type *IrTy) {
+  if (IrTy->isIntOrIntVectorTy()) {
+if (auto *VecTy = QT->getAs())
+  QT = VecTy->getElementType();
+if (QT->isSignedIntegerType())
+  return llvm::Intrinsic::vector_reduce_smax;
+else
+  return llvm::Intrinsic::vector_reduce_umax;
+  }
+  return llvm::Intrinsic::vector_reduce_fmax;
+};
+Value *Op0 = EmitScalarExpr(E->getArg(0));
+Value *Result = Builder.CreateUnaryIntrinsic(
+GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
+"rdx.min");
+return RValue::get(Result);
+  }
+
+  case Builtin::BI__builtin_reduce_min: {
+auto GetIntrinsicID = [](QualType QT, llvm::Type *IrTy) {
+  if (IrTy->isIntOrIntVectorTy()) {
+if (auto *VecTy = QT->getAs())
+  QT = VecTy->getElementType();
+if (QT->isSignedIntegerType())
+  return llvm::Intrinsic::vector_reduce_smin;
+else
+  return llvm::Intrinsic::vector_reduce_umin;
+  }
+  return llvm::Intrinsic::vector_reduce_fmin;
+};
+Value *Op0 = EmitScalarExpr(E->getArg(0));
+Value *Result = Builder.CreateUnaryIntrinsic(
+GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
+"rdx.min");
+return RValue::get(Result);
+  }
+
   case Builtin::BI__builtin_matrix_transpose: {
 const auto *MatrixTy = 
E->getArg(0)->getType()->getAs();
 Value *MatValue = EmitScalarExpr(E->getArg(0));

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 

[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-02 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

> WDYT about detecting QT headers specifically? It seems hacky, but I don't see 
> a way out of this that doesn't involve hardcoding some filenames. Are they in 
> a directory like `"qt-11/QFoo"` that we can recognize? Even Q followed by 
> another capital letter might be a good enough heuristic.
> (The docs suggest it's just `` but the docs also say to use angle 
> brackets so I'm not sure whether to believe them)

The headers are, as far as I can tell, always located in a directory whose name 
starts with "Qt". This parent directory is also in the include path, so e.g. to 
get access to QString, which is located under QtCore/, you'd typically just 
write:

  #include 

This is the recommended, documented way of pulling in headers.
Though you could also write:

  #include 

as the parent parent directory is also in the list of include paths.

Looking at the code, it seems we have access to the parent directory, so we 
could do that name check (which I suppose has less potential for false 
positives than checking the file name).
For framework builds, the directory would be "Headers", which also seems safe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 384070.
MyDeveloperDay added a comment.
Herald added a subscriber: mgorny.

Move BraceInserter into its own file and tests

Add experimental support for "Remove"


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

https://reviews.llvm.org/D95168

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BraceInserter.cpp
  clang/lib/Format/BraceInserter.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/unittests/Format/BraceInserterTests.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -72,7 +72,10 @@
 EXPECT_EQ(Expected.str(), format(Expected, Style))
 << "Expected code is not stable";
 EXPECT_EQ(Expected.str(), format(Code, Style));
-if (Style.Language == FormatStyle::LK_Cpp) {
+// clang::format::internal::reformat does not run any of the options that
+// modify code for ObjC
+if (Style.Language == FormatStyle::LK_Cpp &&
+Style.AutomaticBraces == FormatStyle::BIS_Leave) {
   // Objective-C++ is a superset of C++, so everything checked for C++
   // needs to be checked for Objective-C++ as well.
   FormatStyle ObjCStyle = Style;
@@ -18758,6 +18761,16 @@
   CHECK_PARSE("IndentExternBlock: false", IndentExternBlock,
   FormatStyle::IEBS_NoIndent);
 
+  Style.AutomaticBraces = FormatStyle::BIS_Leave;
+  CHECK_PARSE("AutomaticBraces: Always", AutomaticBraces,
+  FormatStyle::BIS_Always);
+  CHECK_PARSE("AutomaticBraces: WrapLikely", AutomaticBraces,
+  FormatStyle::BIS_WrapLikely);
+  CHECK_PARSE("AutomaticBraces: Leave", AutomaticBraces,
+  FormatStyle::BIS_Leave);
+  CHECK_PARSE("AutomaticBraces: Remove", AutomaticBraces,
+  FormatStyle::BIS_Remove);
+
   Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
   CHECK_PARSE("BitFieldColonSpacing: Both", BitFieldColonSpacing,
   FormatStyle::BFCS_Both);
@@ -22396,7 +22409,6 @@
   "}";
   EXPECT_EQ(Code, format(Code, Style));
 }
-
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/unittests/Format/CMakeLists.txt
===
--- clang/unittests/Format/CMakeLists.txt
+++ clang/unittests/Format/CMakeLists.txt
@@ -3,6 +3,7 @@
   )
 
 add_clang_unittest(FormatTests
+  BraceInserterTests.cpp
   CleanupTest.cpp
   FormatTest.cpp
   FormatTestComments.cpp
Index: clang/unittests/Format/BraceInserterTests.cpp
===
--- /dev/null
+++ clang/unittests/Format/BraceInserterTests.cpp
@@ -0,0 +1,432 @@
+//===- unittest/Format/BraceInserterTest.cpp - brace insertion unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "../Tooling/ReplacementTest.h"
+#include "FormatTestUtils.h"
+
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "brace-inserter-test"
+
+using clang::tooling::ReplacementTest;
+using clang::tooling::toReplacements;
+using testing::ScopedTrace;
+
+namespace clang {
+namespace format {
+namespace {
+
+class BraceInserterTest : public ::testing::Test {
+protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
+  std::string format(llvm::StringRef Code,
+ const FormatStyle  = getLLVMStyle(),
+ StatusCheck CheckComplete = SC_ExpectComplete) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(0, Code.size()));
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", );
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
+return getStyleWithColumns(getLLVMStyle(), ColumnLimit);
+  }

[PATCH] D112889: [analyzer] Dump checker name if multiple checkers evaluate the same call

2021-11-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Committed with the requested changes.




Comment at: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:679
+#ifndef NDEBUG
+  if (evaluated && evaluatorChecker.hasValue()) {
+const auto dump = [](const CallEvent ) -> std::string {

martong wrote:
> Optional implicitly converts to `bool` and IMHO this way it is easier to read 
> the code.
I guess it's up to personal taste.
I'm okay either way, but I more frequently stick to the explicit way of 
checking this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112889

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


[PATCH] D112889: [analyzer] Dump checker name if multiple checkers evaluate the same call

2021-11-02 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
steakhal marked 2 inline comments as done.
Closed by commit rG9b5c9c469d90: [analyzer] Dump checker name if multiple 
checkers evaluate the same call (authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D112889?vs=383659=384067#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112889

Files:
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp

Index: clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
@@ -0,0 +1,58 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class EvalCallBase : public Checker {
+  const CallDescription Foo = {"foo", 0};
+
+public:
+  bool evalCall(const CallEvent , CheckerContext ) const {
+return Call.isCalled(Foo);
+  }
+};
+
+class EvalCallFoo1 : public EvalCallBase {};
+class EvalCallFoo2 : public EvalCallBase {};
+void addEvalFooCheckers(AnalysisASTConsumer ,
+AnalyzerOptions ) {
+  AnOpts.CheckersAndPackages = {{"test.EvalFoo1", true},
+{"test.EvalFoo2", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry ) {
+Registry.addChecker("test.EvalFoo1", "EmptyDescription",
+  "EmptyDocsUri");
+Registry.addChecker("test.EvalFoo2", "EmptyDescription",
+  "EmptyDocsUri");
+  });
+}
+} // namespace
+
+TEST(EvalCall, DetectConflictingEvalCalls) {
+#ifdef NDEBUG
+  GTEST_SKIP() << "This test is only available for debug builds.";
+#endif
+  const std::string Code = R"code(
+void foo();
+void top() {
+  foo(); // crash
+}
+  )code";
+  constexpr auto Regex =
+  "The 'foo\\(\\)' call has been already evaluated by the test\\.EvalFoo1 "
+  "checker, while the test\\.EvalFoo2 checker also tried to evaluate the "
+  "same call\\. At most one checker supposed to evaluate a call\\.";
+  ASSERT_DEATH(runCheckerOnCode(Code), Regex);
+}
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -8,6 +8,7 @@
   BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
+  ConflictingEvalCallsTest.cpp
   FalsePositiveRefutationBRVisitorTest.cpp
   NoStateChangeFuncVisitorTest.cpp
   ParamRegionTest.cpp
Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include 
 #include 
 
@@ -655,7 +656,7 @@
 ExprEngine ,
 const EvalCallOptions ) {
   for (auto *const Pred : Src) {
-bool anyEvaluated = false;
+Optional evaluatorChecker;
 
 ExplodedNodeSet checkDst;
 NodeBuilder B(Pred, checkDst, Eng.getBuilderContext());
@@ -674,10 +675,26 @@
 CheckerContext C(B, Eng, Pred, L);
 evaluated = EvalCallChecker(Call, C);
   }
-  assert(!(evaluated && anyEvaluated)
- && "There are more than one checkers evaluating the call");
+#ifndef NDEBUG
+  if (evaluated && evaluatorChecker) {
+const auto toString = [](const CallEvent ) -> std::string {
+  std::string Buf;
+  llvm::raw_string_ostream OS(Buf);
+  Call.dump(OS);
+  OS.flush();
+  return Buf;
+};
+std::string AssertionMessage = llvm::formatv(
+"The '{0}' call has been already evaluated by the {1} checker, "
+"while the {2} checker also tried to evaluate the same 

[clang] 9b5c9c4 - [analyzer] Dump checker name if multiple checkers evaluate the same call

2021-11-02 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-11-02T14:42:14+01:00
New Revision: 9b5c9c469d90227251d9da9108ee7985ba415f2b

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

LOG: [analyzer] Dump checker name if multiple checkers evaluate the same call

Previously, if accidentally multiple checkers `eval::Call`-ed the same
`CallEvent`, in debug builds the analyzer detected this and crashed
with the message stating this. Unfortunately, the message did not state
the offending checkers violating this invariant.
This revision addresses this by printing a more descriptive message
before aborting.

Reviewed By: martong

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

Added: 
clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
clang/unittests/StaticAnalyzer/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp 
b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 180fa970a3543..43ffcc8f13174 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -411,7 +411,6 @@ void CallEvent::dump(raw_ostream ) const {
   ASTContext  = getState()->getStateManager().getContext();
   if (const Expr *E = getOriginExpr()) {
 E->printPretty(Out, nullptr, Ctx.getPrintingPolicy());
-Out << "\n";
 return;
   }
 

diff  --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp 
b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
index e09399a83589e..94287b7992dd9 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include 
 #include 
 
@@ -655,7 +656,7 @@ void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet 
,
 ExprEngine ,
 const EvalCallOptions ) {
   for (auto *const Pred : Src) {
-bool anyEvaluated = false;
+Optional evaluatorChecker;
 
 ExplodedNodeSet checkDst;
 NodeBuilder B(Pred, checkDst, Eng.getBuilderContext());
@@ -674,10 +675,26 @@ void 
CheckerManager::runCheckersForEvalCall(ExplodedNodeSet ,
 CheckerContext C(B, Eng, Pred, L);
 evaluated = EvalCallChecker(Call, C);
   }
-  assert(!(evaluated && anyEvaluated)
- && "There are more than one checkers evaluating the call");
+#ifndef NDEBUG
+  if (evaluated && evaluatorChecker) {
+const auto toString = [](const CallEvent ) -> std::string {
+  std::string Buf;
+  llvm::raw_string_ostream OS(Buf);
+  Call.dump(OS);
+  OS.flush();
+  return Buf;
+};
+std::string AssertionMessage = llvm::formatv(
+"The '{0}' call has been already evaluated by the {1} checker, "
+"while the {2} checker also tried to evaluate the same call. At "
+"most one checker supposed to evaluate a call.",
+toString(Call), evaluatorChecker->getName(),
+EvalCallChecker.Checker->getCheckerName());
+llvm_unreachable(AssertionMessage.c_str());
+  }
+#endif
   if (evaluated) {
-anyEvaluated = true;
+evaluatorChecker = EvalCallChecker.Checker->getCheckerName();
 Dst.insert(checkDst);
 #ifdef NDEBUG
 break; // on release don't check that no other checker also evals.
@@ -686,7 +703,7 @@ void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet 
,
 }
 
 // If none of the checkers evaluated the call, ask ExprEngine to handle it.
-if (!anyEvaluated) {
+if (!evaluatorChecker) {
   NodeBuilder B(Pred, Dst, Eng.getBuilderContext());
   Eng.defaultEvalCall(B, Pred, Call, CallOpts);
 }

diff  --git a/clang/unittests/StaticAnalyzer/CMakeLists.txt 
b/clang/unittests/StaticAnalyzer/CMakeLists.txt
index 985edf4db3408..810cf75400d79 100644
--- a/clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ b/clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_unittest(StaticAnalysisTests
   BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
+  ConflictingEvalCallsTest.cpp
   FalsePositiveRefutationBRVisitorTest.cpp
   NoStateChangeFuncVisitorTest.cpp
   ParamRegionTest.cpp

diff  --git a/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp 
b/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
new file mode 100644
index 0..405a59ffab1b3
--- /dev/null
+++ b/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp
@@ -0,0 +1,58 @@

  1   2   >