[PATCH] D96853: [clang][AVR] Support variable decorator '__flash'

2021-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 333659.

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

https://reviews.llvm.org/D96853

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/avr-flash.c


Index: clang/test/CodeGen/avr-flash.c
===
--- /dev/null
+++ clang/test/CodeGen/avr-flash.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+
+int foo(int i, int j) {
+  static __flash int b[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 
'const' is needed for variables in address space '__flash'}}
+  return b[j] + b[i];
+}
Index: clang/test/CodeGen/address-space-avr.c
===
--- clang/test/CodeGen/address-space-avr.c
+++ clang/test/CodeGen/address-space-avr.c
@@ -1,12 +1,21 @@
 // RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
 
-// Test that function declarations in nonzero address spaces without prototype
-// are called correctly.
+// CHECK: @var0 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @bar.var2 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @var1 {{.*}} addrspace(1) constant [3 x i16]
 
 // CHECK: define{{.*}} void @bar() addrspace(1)
-// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to 
void (i16) addrspace(1)*)(i16 3)
+// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to 
void (i16) addrspace(1)*)
 // CHECK: declare void @foo(...) addrspace(1)
+
+__flash const int var0[] = {999, 888, 777};
+__flash static const int var1[] = {111, 222, 333};
+
+int i;
+
 void foo();
-void bar(void) {
-   foo(3);
+
+void bar() {
+  static __flash const int var2[] = {555, 666, 777};
+  foo(var1[i]);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
@@ -8032,6 +8033,19 @@
   AVRTargetCodeGenInfo(CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
+  LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
+  const VarDecl *D) const override {
+// Check if a global/static variable is defined within address space 1
+// but not constant.
+LangAS AS = D->getType().getAddressSpace();
+if (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 1 &&
+!D->getType().isConstQualified())
+  CGM.getDiags().Report(D->getLocation(),
+diag::err_qualifier_with_address_space)
+  << 0 << 0 << "__flash";
+return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
+  }
+
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override {
 if (GV->isDeclaration())
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -308,6 +308,7 @@
   Builder.defineMacro("__AVR");
   Builder.defineMacro("__AVR__");
   Builder.defineMacro("__ELF__");
+  Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
 
   if (!this->CPU.empty()) {
 auto It = llvm::find_if(
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2991,6 +2991,9 @@
   "parameter may not be qualified with an address space">;
 def err_field_with_address_space : Error<
   "field may not be qualified with an address space">;
+def err_qualifier_with_address_space : Error<
+  "qualifier '%select{const|volatile}0' is %select{needed|invalid}0 "
+  "for variables in address space '%2'">;
 def err_compound_literal_with_address_space : Error<
   "compound literal in function scope may not be qualified with an address 
space">;
 def err_address_space_mismatch_templ_inst : Error<


Index: clang/test/CodeGen/avr-flash.c
===
--- /dev/null
+++ clang/test/CodeGen/avr-flash.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+
+int foo(int i, int j) {
+  static __flash int b[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash'}}
+  return b[j] + b[i];
+}
Index: clang/test/CodeGen/address-space-avr.c
=

[PATCH] D99407: [clang][ItaniumMangle] Check SizeExpr for DependentSizedArrayType (PR49478)

2021-03-27 Thread Tommy Chiang via Phabricator via cfe-commits
oToToT added inline comments.



Comment at: clang/test/AST/ast-dump-array-json.cpp:6
+
+// CHECK: "mangledName": "_ZN1A4TestE",
+// CHECK: "mangledName": "_ZN1A4TestE",

rsmith wrote:
> oToToT wrote:
> > yaxunl wrote:
> > > I am not sure if this test tests the code you change since the mangled 
> > > variable name does not encode type.
> > I think this test my code. Or, at least, this test will trigger a runtime 
> > error in the latest clang without this patch when mangling `A::Test`.
> > 
> > Also, maybe I could try construct a test to mangle variable with element 
> > type if needed.
> > 
> > WDYT?
> I would like to see a test that verifies the `A_` mangling is produced.
Ah, you're right! After some investigation, I found that this `CHECK` in the 
test doesn't really check my patch.
This test only ensure that clang won't get runtime error when handling this 
file.

However, I can't find any clever way to construct a test like this to ensure 
the output of `CXXNameMangler::mangleType(const DependentSizedArrayType *)`. 
(It is called here only for checking ABI tags, so I guess no output will be 
displayed).

I will try replace this test with a unittest to check the output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99407

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


[PATCH] D99151: [RISCV][Clang] Add RVV vleff intrinsic functions.

2021-03-27 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle16ff.c:9
+// RUN:   -target-feature +experimental-zfh -target-feature +m 
-fallow-half-arguments-and-returns -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+

jrtc27 wrote:
> jrtc27 wrote:
> > craig.topper wrote:
> > > jrtc27 wrote:
> > > > khchen wrote:
> > > > > nit: skip the temporary file and remove +experimental-zfh and 
> > > > > -fallow-half-arguments-and-returns.
> > > > Can we please stop putting ASM tests in Clang, and if they really are 
> > > > needed, splitting them out into their own files separate from the IR 
> > > > tests?
> > > For more background, this approach was copied from AArch64 SVE where they 
> > > said this was beneficial to catch warnings from TypeSize's implicit 
> > > conversion to uint64_t.
> > You can have the ASM tests in a separate .test file though so you can still 
> > run the IR tests without the backend if there's value in having the 
> > end-to-end tests
> (well s/tests/RUN lines/)
IMO, this is also useful to catch mismatch in generated IR intrinsic with 
backend because we have `llvm_any_ty` type in intrinsic IR . In the downstream 
we met the same bug several time which generated intrinsic from builtin can not 
be selected in backend, and it 
was passed the builtin->IR test because we didn't have ASM test.

Do you mean we need to add the IR tests which are generated by clang builtin?
Currently we have the IR tests but they are generated by a script, do you mean 
we need to overwrite them? 
BTW, they are a little different to IR generated by builtin, for example:
https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/RISCV/rvv/vadd-rv32.ll
IR intrinsic is `llvm.riscv.vadd.nxv1i8.nxv1i8` in RV32 and RV64
https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
IR intrinsic is `llvm.riscv.vadd.nxv1i8.nxv1i8.i32` in RV32, 
`llvm.riscv.vadd.nxv1i8.nxv1i8.i64`  in RV64.

I don't like to add too much IR tests, so I'm OK to remove ASM test. But in the 
future, reviewer maybe need to verify the generated IR can generate asm without 
any error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99151

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


[PATCH] D99455: [AST] Store regular ValueDecl* in BindingDecl

2021-03-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: riccibruno, rsmith.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We were always storing a regular ValueDecl* as decomposition declaration
and haven't been using the opportunity to initialize it lazily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99455

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


Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -3177,12 +3177,6 @@
   return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr);
 }
 
-ValueDecl *BindingDecl::getDecomposedDecl() const {
-  ExternalASTSource *Source =
-  Decomp.isOffset() ? getASTContext().getExternalSource() : nullptr;
-  return cast_or_null(Decomp.get(Source));
-}
-
 VarDecl *BindingDecl::getHoldingVar() const {
   Expr *B = getBinding();
   if (!B)
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -3817,7 +3817,7 @@
 /// DecompositionDecl of type 'int (&)[3]'.
 class BindingDecl : public ValueDecl {
   /// The declaration that this binding binds to part of.
-  LazyDeclPtr Decomp;
+  ValueDecl *Decomp;
   /// The binding represented by this declaration. References to this
   /// declaration are effectively equivalent to this expression (except
   /// that it is only evaluated once at the point of declaration of the
@@ -3843,7 +3843,7 @@
 
   /// Get the decomposition declaration that this binding represents a
   /// decomposition of.
-  ValueDecl *getDecomposedDecl() const;
+  ValueDecl *getDecomposedDecl() const { return Decomp; }
 
   /// Get the variable (if any) that holds the value of evaluating the binding.
   /// Only present for user-defined bindings for tuple-like types.


Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -3177,12 +3177,6 @@
   return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr);
 }
 
-ValueDecl *BindingDecl::getDecomposedDecl() const {
-  ExternalASTSource *Source =
-  Decomp.isOffset() ? getASTContext().getExternalSource() : nullptr;
-  return cast_or_null(Decomp.get(Source));
-}
-
 VarDecl *BindingDecl::getHoldingVar() const {
   Expr *B = getBinding();
   if (!B)
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -3817,7 +3817,7 @@
 /// DecompositionDecl of type 'int (&)[3]'.
 class BindingDecl : public ValueDecl {
   /// The declaration that this binding binds to part of.
-  LazyDeclPtr Decomp;
+  ValueDecl *Decomp;
   /// The binding represented by this declaration. References to this
   /// declaration are effectively equivalent to this expression (except
   /// that it is only evaluated once at the point of declaration of the
@@ -3843,7 +3843,7 @@
 
   /// Get the decomposition declaration that this binding represents a
   /// decomposition of.
-  ValueDecl *getDecomposedDecl() const;
+  ValueDecl *getDecomposedDecl() const { return Decomp; }
 
   /// Get the variable (if any) that holds the value of evaluating the binding.
   /// Only present for user-defined bindings for tuple-like types.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-03-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D99426#2653949 , @MaskRay wrote:

> In D99426#2653869 , 
> @abhina.sreeskantharajan wrote:
>
>> In D99426#2653725 , @MaskRay wrote:
>>
>>> This touches a lot of files. I am a bit worried that it would not be easy 
>>> for a contributor to know OF_TextWithCRLF is needed to make SystemZ happy.
>>>
 On SystemZ we need to open text files in text mode,
>>>
>>> Why can't it be served without CRLF translation?
>>
>> So this is a quick summary of the problem we're facing: 
>> On SystemZ, we can accept both OF_Text or OF_TextWithCRLF, it makes no 
>> difference. However, there are many text files that are marked as 
>> binary/OF_None to suppress CRLF translation on Windows. (e.g. patches like 
>> this one 
>> https://reviews.llvm.org/rGe78a7a0ecddc747129512fabf4836e22d1805f00). On 
>> SystemZ we need the text files to be marked as text and have made patches in 
>> the past to do so (e.g. https://reviews.llvm.org/D67696). These efforts are 
>> conflicting with each other, so Reid suggested this solution where we create 
>> a new flag that will set text mode and turn on CRLF translation on Windows 
>> platform. Then we will be able to mark all remaining text files with OF_Text 
>> and not turn on CRLF translation for Windows.
>>
>> I agree this patch is touching a lot of files,  I can maybe do the opposite 
>> and create a flag called OF_TextWithoutCRLF. I'm open to any new solutions 
>> to this problem.
>
> Hmm. I am still confused after seeting 
> rGe78a7a0ecddc747129512fabf4836e22d1805f00 
>  (does 
> it imply that using OF_None on Windows is fine?)
> If `OF_None` is used on SystemZ, does that regress functionality?

On Windows, OF_None suppresses CRLF translation and OF_Text will allow CRLF 
translation. On SystemZ it does regress functionality by causing file encoding 
issues. z/OS uses a file's text/binary mode to determine whether to perform 
translation to the system encoding EBCDIC if needed. (On binary files, no 
translation should be performed)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99005: [clang] WIP: Implement P2266

2021-03-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Data points: I've run this new Clang in `-std=c++2b` mode over my employer's 
(medium-sized, not too crazy) C++17 codebase, and also built Clang with Clang. 
Neither one required any source-code changes to deal with p2266. (The C++17 
codebase did need about 10 identical changes to fix up ambiguous `operator==` 
overloads for C++20.)

Could we get someone to check out the Bloomberg codebase?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

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


[clang] bb88a5a - [clang][cli] Round-trip cc1 arguments in assert builds

2021-03-27 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-03-27T17:24:03+01:00
New Revision: bb88a5aeee6839caf2f09cd025099d63c15bfb11

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

LOG: [clang][cli] Round-trip cc1 arguments in assert builds

This patch enables cc1 argument round-trip for assert builds. It can be 
disabled by building clang with `-DCLANG_ROUND_TRIP_CC1_ARGS=OFF`.

This will be committed only if we reach consensus in 
https://lists.llvm.org/pipermail/cfe-dev/2021-February/067714.html.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index e4d5dd77c69a..95cdbd8f6663 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -467,7 +467,8 @@ option(CLANG_ENABLE_STATIC_ANALYZER
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." 
OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")



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


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-03-27 Thread Jan Svoboda 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 rGbb88a5aeee68: [clang][cli] Round-trip cc1 arguments in 
assert builds (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97462

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -467,7 +467,8 @@
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." 
OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -467,7 +467,8 @@
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-option(CLANG_ROUND_TRIP_CC1_ARGS "Round-trip command line arguments in -cc1." OFF)
+option(CLANG_ROUND_TRIP_CC1_ARGS
+  "Round-trip command line arguments in -cc1." ${LLVM_ENABLE_ASSERTIONS})
 
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99456: [C++2b] Support size_t literals

2021-03-27 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev created this revision.
AntonBikineev added a reviewer: rsmith.
AntonBikineev requested review of this revision.
Herald added a project: clang.

This adds support for C++2b z/uz suffixes for size_t literals (P0330).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99456

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/size_t-literal.cpp
  clang/test/SemaCXX/size_t-literal.cpp

Index: clang/test/SemaCXX/size_t-literal.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/size_t-literal.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -std=c++2b -Werror=c++2b-extensions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -Werror=c++2b-extensions -fsyntax-only -verify %s
+
+typedef __SIZE_TYPE__ size_t;
+// Assume ptrdiff_t is the signed integer type corresponding to size_t.
+typedef __PTRDIFF_TYPE__ ssize_t;
+
+template 
+struct is_same { static constexpr bool value = false; };
+
+template 
+struct is_same { static constexpr bool value = true; };
+
+#if __cplusplus >= 202101L
+//  expected-no-diagnostics
+#endif
+
+void SSizeT() {
+  auto a1 = 1z;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a2 = 1Z;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+}
+
+void SizeT() {
+  auto a1 = 1uz;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a2 = 1uZ;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a3 = 1Uz;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a4 = 1UZ;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a5 = 1zu;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a6 = 1Zu;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a7 = 1zU;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a8 = 1ZU;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+}
Index: clang/test/Lexer/size_t-literal.cpp
===
--- /dev/null
+++ clang/test/Lexer/size_t-literal.cpp
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify -ferror-limit=0 %s
+
+void ValidSuffix() {
+  // Decimal literals.
+  {
+auto a1 = 1z;
+auto a2 = 1Z;
+
+auto a3 = 1uz;
+auto a4 = 1uZ;
+auto a5 = 1Uz;
+auto a6 = 1UZ;
+
+auto a7 = 1zu;
+auto a8 = 1Zu;
+auto a9 = 1zU;
+auto a10 = 1ZU;
+
+auto a11 = 1'2z;
+auto a12 = 1'2Z;
+  }
+  // Hexadecimal literals.
+  {
+auto a1 = 0x1z;
+auto a2 = 0x1Z;
+
+auto a3 = 0x1uz;
+auto a4 = 0x1uZ;
+auto a5 = 0x1Uz;
+auto a6 = 0x1UZ;
+
+auto a7 = 0x1zu;
+auto a8 = 0x1Zu;
+auto a9 = 0x1zU;
+auto a10 = 0x1ZU;
+
+auto a11 = 0x1'2z;
+auto a12 = 0x1'2Z;
+  }
+  // Binary literals.
+  {
+auto a1 = 0b1z;
+auto a2 = 0b1Z;
+
+auto a3 = 0b1uz;
+auto a4 = 0b1uZ;
+auto a5 = 0b1Uz;
+auto a6 = 0b1UZ;
+
+auto a7 = 0b1zu;
+auto a8 = 0b1Zu;
+auto a9 = 0b1zU;
+auto a10 = 0b1ZU;
+
+auto a11 = 0b1'1z;
+auto a12 = 0b1'1Z;
+  }
+  // Octal literals.
+  {
+auto a1 = 01z;
+auto a2 = 01Z;
+
+auto a3 = 01uz;
+auto a4 = 01uZ;
+auto a5 = 01Uz;
+auto a6 = 01UZ;
+
+auto a7 = 01zu;
+auto a8 = 01Zu;
+auto a9 = 01zU;
+auto a10 = 01ZU;
+
+auto a11 = 0'1z;
+auto a12 = 0'1Z;
+  }
+}
+
+void InvalidSuffix() {
+  // Long.
+  {
+auto a1 = 1lz; // expected-error {{invalid suffix}}
+auto a2 = 1lZ; // expected-error {{invalid suffix}}
+auto a3 = 1Lz; // expected-error {{invalid suffix}}
+auto a4 = 1LZ; // expected-error {{invalid suffix}}
+
+auto a5 = 1zl; // expected-error {{invalid suffix}}
+auto a6 = 1Zl; // expected-error {{invalid suffix}}
+auto a7 = 1zL; // expected-error {{invalid suffix}}
+auto a8 = 1ZL; // expected-erro

[PATCH] D97513: Add ConfigVersion.cmake files

2021-03-27 Thread Alex Reinking via Phabricator via cfe-commits
alexreinking updated this revision to Diff 333677.
alexreinking added a comment.

Use PACKAGE_VERSION instead


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

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -67,10 +67,17 @@
 
 # PollyConfig holds the target definitions and general settings, PollyExports
 # the imported locations
+include(CMakePackageConfigHelpers)
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 
 file(GENERATE
   OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
@@ -120,6 +127,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 file(GENERATE OUTPUT
   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}
   CONTENT "${POLLY_EXPORTS}")
@@ -128,6 +140,7 @@
   install(
 FILES
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
+"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake"
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
 endif ()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -5,6 +5,7 @@
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
   include(HandleLLVMOptions)
   include(AddLLVM)
@@ -48,6 +49,14 @@
 set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+# Compute the Polly version from the LLVM version.
+string(REGEX MATCH "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?" POLLY_VERSION ${PACKAGE_VERSION})
+message(STATUS "Polly version: ${POLLY_VERSION}")
+
+set(POLLY_VERSION_MAJOR "${CMAKE_MATCH_1}")
+set(POLLY_VERSION_MINOR "${CMAKE_MATCH_2}")
+set(POLLY_VERSION_PATCH "${CMAKE_MATCH_4}")  # Using 4 instead of 3 skips the dot before the patch number.
+
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   ${CMAKE_MODULE_PATH}
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -17,6 +17,8 @@
 get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
 # Generate MlirConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(MLIR_CONFIG_EXPORTS_FILE "\${MLIR_CMAKE_DIR}/MLIRTargets.cmake")
@@ -28,6 +30,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${mlir_cmake_builddir}/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
 set(MLIR_CONFIG_EXPORTS_FILE)
@@ -63,6 +70,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CODE)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
@@ -80,6 +92,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
+${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfigVersion.cmake
 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
 COMPONENT mlir-cmake-exports)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -23,6 +23,8 @@
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
 "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 endif()
 
 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
@@ -33,6 +35,14 @@
 set(MLIR_INCLUDE_DIR ${

[PATCH] D99458: [clang-format] Fix east const pointer alignment of operators

2021-03-27 Thread Nico Rieck via Phabricator via cfe-commits
nrieck created this revision.
nrieck requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes left pointer alignment after pointer qualifiers of
operators. Currently "operator void const*()" is formatted with a space between
const and pointer despite setting PointerAlignment to Left.

AFAICS this has been broken since clang-format 10.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99458

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12731,6 +12731,27 @@
   verifyQualifierSpaces("void * const *x = NULL;", PAS_Right, SAPQ_Both);
   verifyQualifierSpaces("void * const * x = NULL;", PAS_Middle, SAPQ_Both);
 
+  verifyQualifierSpaces("Foo::operator void const*();", PAS_Left, SAPQ_Default);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Right,
+SAPQ_Default);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Middle,
+SAPQ_Default);
+
+  verifyQualifierSpaces("Foo::operator void const*();", PAS_Left, SAPQ_Before);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Right,
+SAPQ_Before);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Middle,
+SAPQ_Before);
+
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Left, SAPQ_After);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Right, SAPQ_After);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Middle,
+SAPQ_After);
+
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Left, SAPQ_Both);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Right, SAPQ_Both);
+  verifyQualifierSpaces("Foo::operator void const *();", PAS_Middle, SAPQ_Both);
+
 #undef verifyQualifierSpaces
 
   FormatStyle Spaces = getLLVMStyle();
@@ -18639,6 +18660,10 @@
   verifyFormat("Foo::operator void **();", Style);
   verifyFormat("Foo::operator void *&();", Style);
   verifyFormat("Foo::operator void *&&();", Style);
+  verifyFormat("Foo::operator void const *();", Style);
+  verifyFormat("Foo::operator void const **();", Style);
+  verifyFormat("Foo::operator void const *&();", Style);
+  verifyFormat("Foo::operator void const *&&();", Style);
   verifyFormat("Foo::operator()(void *);", Style);
   verifyFormat("Foo::operator*(void *);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -18660,6 +18685,7 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator void const &();", Style);
   verifyFormat("Foo::operator()(void &);", Style);
   verifyFormat("Foo::operator&(void &);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -18668,6 +18694,7 @@
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator void const &&();", Style);
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::operator&&();", Style);
@@ -18688,6 +18715,11 @@
   verifyFormat("Foo::operator void*();", Style);
   verifyFormat("Foo::operator void**();", Style);
   verifyFormat("Foo::operator void*&();", Style);
+  verifyFormat("Foo::operator void*&&();", Style);
+  verifyFormat("Foo::operator void const*();", Style);
+  verifyFormat("Foo::operator void const**();", Style);
+  verifyFormat("Foo::operator void const*&();", Style);
+  verifyFormat("Foo::operator void const*&&();", Style);
   verifyFormat("Foo::operator/*comment*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
@@ -18709,6 +18741,7 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator void const&();", Style);
   verifyFormat("Foo::operator/*comment*/ void&();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
@@ -18719,6 +18752,7 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator void const&&();", Style);
   verifyFormat("Foo::operator/*comment*/ void&&();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
@@ -18754,6 +18788,7 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator void const &();", Style);
   verify

[PATCH] D99433: [Matrix] Including __builtin_matrix_multiply_add for the matrix type extension.

2021-03-27 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

FYI I filed https://bugs.llvm.org/show_bug.cgi?id=49738 and 
https://bugs.llvm.org/show_bug.cgi?id=49739 for improving fast-math handling in 
the lowering pass and support for `pargma fp`, in case you are interested.

@everton.constantino out of curiosity, what architecture are you focused on and 
what matrix sizes? I have a few performance improvements lined up for code-gen. 
It might be good to sync up to make sure there's no duplicated work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99433

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


[PATCH] D98296: [clang-tidy] Simplify readability checks to not need ignoring* matchers

2021-03-27 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp:31
   isMoveAssignmentOperator()),
-isDefaulted(), unless(isImplicit()), isDeleted(),
-unless(isInstantiated()))
+isDefaulted(), isDeleted())
   .bind("method-decl"),

Please rebase, this check has since been removed from clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98296

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


[PATCH] D99360: [OpenMP][WIP] Add standard notes for ELF offload images

2021-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> It might make sense to do the llvm-readobj portions of this patch in a 
> separate review, since they are somewhat independent.

+1. Patches touching BinaryFormat/llvm-readobj/yaml2obj/etc part and others 
(MC/CodeGen/etc) are often required to do 
BinaryFormat/llvm-readobj/yaml2obj/etc separately.
The part is usually very loosely connected with the MC/CodeGen/etc part code.

> Decide how to test the LLVM ELF implementation of ELF light, since I expect 
> the upstream builds will use libelf implementation.

Does the current code use both llvm/Object and libelf? First, for in-tree 
components we exclusively use llvm/Object - there should be no dependency on 
the external libelf.
Having two implementations can make llvm/Object API refactoring difficult. 
Other contributors will not know that an libelf implementation (a different 
configuration) exists and can break the libelf implementation.




Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:327
+  // Look for llvm-objcopy.exe as well.
+  ObjcopyPathOrErr = sys::findProgramByName("llvm-objcopy.exe");
+  if (!ObjcopyPathOrErr) {

`sys::findProgramByName` tests the filename with an `.exe` suffix appended, no 
need to duplicate it in application code.



Comment at: openmp/libomptarget/plugins/common/elf_common/elf_light.cpp:47
+//for 64-bit ELFs produced by LLVM.
+typedef struct {
+  uint32_t n_namesz; // Length of note's name.

C++ does not require the use sites to prepend `struct` so `typedef struct` is 
not used by convention.


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

https://reviews.llvm.org/D99360

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


[PATCH] D99456: [C++2b] Support size_t literals

2021-03-27 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev updated this revision to Diff 333681.
AntonBikineev added a comment.

Fix failing tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99456

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/size_t-literal.cpp
  clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
  clang/test/SemaCXX/size_t-literal.cpp

Index: clang/test/SemaCXX/size_t-literal.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/size_t-literal.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -std=c++2b -Werror=c++2b-extensions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -Werror=c++2b-extensions -fsyntax-only -verify %s
+
+typedef __SIZE_TYPE__ size_t;
+// Assume ptrdiff_t is the signed integer type corresponding to size_t.
+typedef __PTRDIFF_TYPE__ ssize_t;
+
+template 
+struct is_same { static constexpr bool value = false; };
+
+template 
+struct is_same { static constexpr bool value = true; };
+
+#if __cplusplus >= 202101L
+//  expected-no-diagnostics
+#endif
+
+void SSizeT() {
+  auto a1 = 1z;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a2 = 1Z;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+}
+
+void SizeT() {
+  auto a1 = 1uz;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a2 = 1uZ;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a3 = 1Uz;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a4 = 1UZ;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a5 = 1zu;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a6 = 1Zu;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a7 = 1zU;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+
+  auto a8 = 1ZU;
+#if __cplusplus < 202101L
+  // expected-error@-2 {{size_t suffix for literals is a C++2b extension}}
+#endif
+  static_assert(is_same::value);
+}
Index: clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
===
--- clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
+++ clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
@@ -34,7 +34,7 @@
 string s = "foo"s;
 char error = 'x's; // expected-error {{invalid suffix}} expected-error {{expected ';'}}
 
-int _1z = 1z; // expected-error {{invalid suffix}}
+int _1y = 1y; // expected-error {{invalid suffix}}
 int _1b = 1b; // expected-error {{invalid digit}}
 
 complex cf1 = 1if, cf2 = 2.if, cf3 = 0x3if;
Index: clang/test/Lexer/size_t-literal.cpp
===
--- /dev/null
+++ clang/test/Lexer/size_t-literal.cpp
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+void ValidSuffix() {
+  // Decimal literals.
+  {
+auto a1 = 1z;
+auto a2 = 1Z;
+
+auto a3 = 1uz;
+auto a4 = 1uZ;
+auto a5 = 1Uz;
+auto a6 = 1UZ;
+
+auto a7 = 1zu;
+auto a8 = 1Zu;
+auto a9 = 1zU;
+auto a10 = 1ZU;
+
+auto a11 = 1'2z;
+auto a12 = 1'2Z;
+  }
+  // Hexadecimal literals.
+  {
+auto a1 = 0x1z;
+auto a2 = 0x1Z;
+
+auto a3 = 0x1uz;
+auto a4 = 0x1uZ;
+auto a5 = 0x1Uz;
+auto a6 = 0x1UZ;
+
+auto a7 = 0x1zu;
+auto a8 = 0x1Zu;
+auto a9 = 0x1zU;
+auto a10 = 0x1ZU;
+
+auto a11 = 0x1'2z;
+auto a12 = 0x1'2Z;
+  }
+  // Binary literals.
+  {
+auto a1 = 0b1z;
+auto a2 = 0b1Z;
+
+auto a3 = 0b1uz;
+auto a4 = 0b1uZ;
+auto a5 = 0b1Uz;
+auto a6 = 0b1UZ;
+
+auto a7 = 0b1zu;
+auto a8 = 0b1Zu;
+auto a9 = 0b1zU;
+auto a10 = 0b1ZU;
+
+auto a11 = 0b1'1z;
+auto a12 = 0b1'1Z;
+  }
+  // Octal literals.
+  {
+auto a1 = 01z;
+auto a2 = 01Z;
+
+auto a3 = 01uz;
+auto a4 = 01uZ;
+auto a5 = 01Uz;
+auto a6 = 01UZ;
+
+auto a7 = 01zu;
+auto a8 = 01Zu;
+auto a9 = 01zU;
+auto a10

[PATCH] D99151: [RISCV][Clang] Add RVV vleff intrinsic functions.

2021-03-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle16ff.c:9
+// RUN:   -target-feature +experimental-zfh -target-feature +m 
-fallow-half-arguments-and-returns -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+

khchen wrote:
> jrtc27 wrote:
> > jrtc27 wrote:
> > > craig.topper wrote:
> > > > jrtc27 wrote:
> > > > > khchen wrote:
> > > > > > nit: skip the temporary file and remove +experimental-zfh and 
> > > > > > -fallow-half-arguments-and-returns.
> > > > > Can we please stop putting ASM tests in Clang, and if they really are 
> > > > > needed, splitting them out into their own files separate from the IR 
> > > > > tests?
> > > > For more background, this approach was copied from AArch64 SVE where 
> > > > they said this was beneficial to catch warnings from TypeSize's 
> > > > implicit conversion to uint64_t.
> > > You can have the ASM tests in a separate .test file though so you can 
> > > still run the IR tests without the backend if there's value in having the 
> > > end-to-end tests
> > (well s/tests/RUN lines/)
> IMO, this is also useful to catch mismatch in generated IR intrinsic with 
> backend because we have `llvm_any_ty` type in intrinsic IR . In the 
> downstream we met the same bug several time which generated intrinsic from 
> builtin can not be selected in backend, and it 
> was passed the builtin->IR test because we didn't have ASM test.
> 
> Do you mean we need to add the IR tests which are generated by clang builtin?
> Currently we have the IR tests but they are generated by a script, do you 
> mean we need to overwrite them? 
> BTW, they are a little different to IR generated by builtin, for example:
> https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/RISCV/rvv/vadd-rv32.ll
> IR intrinsic is `llvm.riscv.vadd.nxv1i8.nxv1i8` in RV32 and RV64
> https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
> IR intrinsic is `llvm.riscv.vadd.nxv1i8.nxv1i8.i32` in RV32, 
> `llvm.riscv.vadd.nxv1i8.nxv1i8.i64`  in RV64.
> 
> I don't like to add too much IR tests, so I'm OK to remove ASM test. But in 
> the future, reviewer maybe need to verify the generated IR can generate asm 
> without any error.
I'm conflicted on this.

Given how the IR intrinsics are making heavy use of any_ty we lose a lot of 
type checking in the intrinsic creation. We've had multiple case where the 
intrinsics the types the frontend generated were different than what the 
backend tests were testing. So from that perspective, the end-to-end tests have 
value.

I don't really like the idea of having two copies of every test. Maybe we could 
have multiple test files that use a common Input file?

I'm not completely convinced it is important to be able to test the IR gen 
without the backend being built. The most likely changes that would cause the 
-emit-llvm tests to fail or need to be updated are changes to RISCV specific 
code in the .td file, our tablegen backend, or CGBuiltin.cpp. I would expect a 
RISCV developer touching those files to be compiling the RISCV backend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99151

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


[PATCH] D97513: Add ConfigVersion.cmake files

2021-03-27 Thread Alex Reinking via Phabricator via cfe-commits
alexreinking updated this revision to Diff 333683.
alexreinking added a comment.

Drop *ConfigVersion.cmake files from `CMakeFiles` tree


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

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -67,10 +67,17 @@
 
 # PollyConfig holds the target definitions and general settings, PollyExports
 # the imported locations
+include(CMakePackageConfigHelpers)
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 
 file(GENERATE
   OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
@@ -128,6 +135,7 @@
   install(
 FILES
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
+"${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
 endif ()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -5,6 +5,7 @@
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
   include(HandleLLVMOptions)
   include(AddLLVM)
@@ -48,6 +49,14 @@
 set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+# Compute the Polly version from the LLVM version.
+string(REGEX MATCH "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?" POLLY_VERSION ${PACKAGE_VERSION})
+message(STATUS "Polly version: ${POLLY_VERSION}")
+
+set(POLLY_VERSION_MAJOR "${CMAKE_MATCH_1}")
+set(POLLY_VERSION_MINOR "${CMAKE_MATCH_2}")
+set(POLLY_VERSION_PATCH "${CMAKE_MATCH_4}")  # Using 4 instead of 3 skips the dot before the patch number.
+
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   ${CMAKE_MODULE_PATH}
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -17,6 +17,8 @@
 get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
 # Generate MlirConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(MLIR_CONFIG_EXPORTS_FILE "\${MLIR_CMAKE_DIR}/MLIRTargets.cmake")
@@ -28,6 +30,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${mlir_cmake_builddir}/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
 set(MLIR_CONFIG_EXPORTS_FILE)
@@ -80,6 +87,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
+${mlir_cmake_builddir}/MLIRConfigVersion.cmake
 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
 COMPONENT mlir-cmake-exports)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -23,6 +23,8 @@
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
 "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 endif()
 
 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
@@ -33,6 +35,14 @@
 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 set(MLIR_TOOLS_DIR   ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
+# Compute the MLIR version from the LLVM version.
+string(REGEX MATCH "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?" MLIR_VERSION ${PACKAGE_VERSION})
+message(STATUS "MLIR version: ${MLIR_VERSION}")
+
+set(MLIR_VERSION_MAJOR "${CMAKE_MATCH_1}")
+set(MLIR_VERSION_MINOR "${CMAKE_MATCH_2}")
+set(MLIR_VERSION_PATCH "${CMAKE_MATCH_4}")  # Using 4 instead of 3 skips the dot before the patch number.
+
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
 include(AddMLIR)
Index: lld/cmake/modules/CMakeLists.txt
===
--- lld/cmake/modules/CMakeLists.txt
+++ lld/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}

[PATCH] D97513: Add ConfigVersion.cmake files

2021-03-27 Thread Alex Reinking via Phabricator via cfe-commits
alexreinking updated this revision to Diff 333687.
alexreinking added a comment.

Remove unused version variables (that were used in a previous revision)


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

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -67,10 +67,17 @@
 
 # PollyConfig holds the target definitions and general settings, PollyExports
 # the imported locations
+include(CMakePackageConfigHelpers)
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 
 file(GENERATE
   OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
@@ -128,6 +135,7 @@
   install(
 FILES
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
+"${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
 endif ()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -5,6 +5,7 @@
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
   include(HandleLLVMOptions)
   include(AddLLVM)
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -17,6 +17,8 @@
 get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
 # Generate MlirConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(MLIR_CONFIG_EXPORTS_FILE "\${MLIR_CMAKE_DIR}/MLIRTargets.cmake")
@@ -28,6 +30,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${mlir_cmake_builddir}/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
 set(MLIR_CONFIG_EXPORTS_FILE)
@@ -80,6 +87,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
+${mlir_cmake_builddir}/MLIRConfigVersion.cmake
 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
 COMPONENT mlir-cmake-exports)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -23,6 +23,8 @@
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
 "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 endif()
 
 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
Index: lld/cmake/modules/CMakeLists.txt
===
--- lld/cmake/modules/CMakeLists.txt
+++ lld/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)
 
 # Generate LLDConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(LLD_CONFIG_CMAKE_DIR "${lld_cmake_builddir}")
 set(LLD_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(LLD_CONFIG_EXPORTS_FILE "${lld_cmake_builddir}/LLDTargets.cmake")
@@ -23,6 +25,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
   ${lld_cmake_builddir}/LLDConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${lld_cmake_builddir}/LLDConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(LLD_CONFIG_CMAKE_DIR)
 set(LLD_CONFIG_LLVM_CMAKE_DIR)
 set(LLD_CONFIG_EXPORTS_FILE)
@@ -59,6 +66,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
+${lld_cmake_builddir}/LLDConfigVersion.cmake
 DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
 COMPONENT lld-cmake-exports)
 
Index: flang/cmake/modules/CMakeLists.txt
===
--- flang/cmake/modules/CMakeLists.txt
+++ flang/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)
 
 # Generate FlangConfig.cmake for the build tree.
+incl

[PATCH] D97513: Add ConfigVersion.cmake files

2021-03-27 Thread Alex Reinking via Phabricator via cfe-commits
alexreinking updated this revision to Diff 333688.
alexreinking added a comment.

Update & wrap commit message


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

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -67,10 +67,17 @@
 
 # PollyConfig holds the target definitions and general settings, PollyExports
 # the imported locations
+include(CMakePackageConfigHelpers)
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 
 file(GENERATE
   OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
@@ -128,6 +135,7 @@
   install(
 FILES
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
+"${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
 endif ()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -5,6 +5,7 @@
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
   include(HandleLLVMOptions)
   include(AddLLVM)
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -17,6 +17,8 @@
 get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
 # Generate MlirConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(MLIR_CONFIG_EXPORTS_FILE "\${MLIR_CMAKE_DIR}/MLIRTargets.cmake")
@@ -28,6 +30,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${mlir_cmake_builddir}/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
 set(MLIR_CONFIG_EXPORTS_FILE)
@@ -80,6 +87,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
+${mlir_cmake_builddir}/MLIRConfigVersion.cmake
 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
 COMPONENT mlir-cmake-exports)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -23,6 +23,8 @@
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
 "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 endif()
 
 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
Index: lld/cmake/modules/CMakeLists.txt
===
--- lld/cmake/modules/CMakeLists.txt
+++ lld/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)
 
 # Generate LLDConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(LLD_CONFIG_CMAKE_DIR "${lld_cmake_builddir}")
 set(LLD_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(LLD_CONFIG_EXPORTS_FILE "${lld_cmake_builddir}/LLDTargets.cmake")
@@ -23,6 +25,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
   ${lld_cmake_builddir}/LLDConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${lld_cmake_builddir}/LLDConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(LLD_CONFIG_CMAKE_DIR)
 set(LLD_CONFIG_LLVM_CMAKE_DIR)
 set(LLD_CONFIG_EXPORTS_FILE)
@@ -59,6 +66,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
+${lld_cmake_builddir}/LLDConfigVersion.cmake
 DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
 COMPONENT lld-cmake-exports)
 
Index: flang/cmake/modules/CMakeLists.txt
===
--- flang/cmake/modules/CMakeLists.txt
+++ flang/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)
 
 # Generate FlangConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(FLANG

[PATCH] D99458: [clang-format] Fix east const pointer alignment of operators

2021-03-27 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. But please wait for @mydeveloperday's review too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99458

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


[PATCH] D99458: [clang-format] Fix east const pointer alignment of operators

2021-03-27 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2958
 // Space between the type and the * in:
 //   operator void*()
 //   operator char*()

Nit: you might add `operator void const/volatile*()` to the list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99458

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


[PATCH] D97513: Add ConfigVersion.cmake files

2021-03-27 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: flang/cmake/modules/CMakeLists.txt:15
 # Generate FlangConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+

Instead of including this multiple times, please add it to `AddLLVM.cmake`. 
That file is used in project top-level builds too and it already contains other 
includes needed in the build. It is installed, but only for the purpose of 
building other parts of LLVM, so it's not a concern for third parties either 
(It is not included by `LLVMConfig.cmake`).


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

https://reviews.llvm.org/D97513

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


[PATCH] D97513: [CMake] Add ConfigVersion.cmake files

2021-03-27 Thread Alex Reinking via Phabricator via cfe-commits
alexreinking updated this revision to Diff 333690.
alexreinking retitled this revision from "Add ConfigVersion.cmake 
files" to "[CMake] Add ConfigVersion.cmake files".
alexreinking added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As requested, move instances of `include(CMakePackageConfigHelpers)` to 
`AddLLVM.cmake`.


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

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -71,6 +71,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 
 file(GENERATE
   OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
@@ -128,6 +133,7 @@
   install(
 FILES
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
+"${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
 endif ()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -5,6 +5,7 @@
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
   include(HandleLLVMOptions)
   include(AddLLVM)
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -28,6 +28,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${mlir_cmake_builddir}/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
 set(MLIR_CONFIG_EXPORTS_FILE)
@@ -80,6 +85,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
+${mlir_cmake_builddir}/MLIRConfigVersion.cmake
 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
 COMPONENT mlir-cmake-exports)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -23,6 +23,8 @@
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
 "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 endif()
 
 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -128,7 +128,6 @@
   @ONLY)
 
 # Generate LLVMConfigVersion.cmake for build tree (later copied to install tree).
-include(CMakePackageConfigHelpers)
 write_basic_package_version_file(
   "${llvm_cmake_builddir}/LLVMConfigVersion.cmake"
   VERSION "${PACKAGE_VERSION}"
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1,6 +1,7 @@
 include(LLVMProcessSources)
 include(LLVM-Config)
 include(DetermineGCCCompatible)
+include(CMakePackageConfigHelpers)
 
 function(llvm_update_compile_flags name)
   get_property(sources TARGET ${name} PROPERTY SOURCES)
Index: lld/cmake/modules/CMakeLists.txt
===
--- lld/cmake/modules/CMakeLists.txt
+++ lld/cmake/modules/CMakeLists.txt
@@ -23,6 +23,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
   ${lld_cmake_builddir}/LLDConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${lld_cmake_builddir}/LLDConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(LLD_CONFIG_CMAKE_DIR)
 set(LLD_CONFIG_LLVM_CMAKE_DIR)
 set(LLD_CONFIG_EXPORTS_FILE)
@@ -59,6 +64,7 @@
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
+${lld_cmake_builddir}/LLDConfigVersion.cmake
 DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
 COMPONENT lld-cmake-exports)
 
Index: flang/cmake/modules/CMakeLists.txt
==

[PATCH] D97513: [CMake] Add ConfigVersion.cmake files

2021-03-27 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

I'll commit this on Wednesday if none of the other reviewers object by then.


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

https://reviews.llvm.org/D97513

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


[clang] c61ae6e - Deduplicate branches and adjust comment [NFC]

2021-03-27 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-03-27T23:08:43+01:00
New Revision: c61ae6e6d597984e6ff7d012dce4dfd59c05d792

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

LOG: Deduplicate branches and adjust comment [NFC]

Currently we want to allow calling non-const methods even when only a
shared lock is held, because -Wthread-safety-reference is already quite
sensitive and not all code is const-correct. Even if it is, this might
require users to add std::as_const around the implicit object argument.

See D52395 for a discussion.

Fixes PR46963.

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 21583e92c72d..84e0e91f597f 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -2051,15 +2051,11 @@ void BuildLockset::VisitCallExpr(const CallExpr *Exp) {
 
 if (ME && MD) {
   if (ME->isArrow()) {
-if (MD->isConst())
-  checkPtAccess(CE->getImplicitObjectArgument(), AK_Read);
-else // FIXME -- should be AK_Written
-  checkPtAccess(CE->getImplicitObjectArgument(), AK_Read);
+// Should perhaps be AK_Written if !MD->isConst().
+checkPtAccess(CE->getImplicitObjectArgument(), AK_Read);
   } else {
-if (MD->isConst())
-  checkAccess(CE->getImplicitObjectArgument(), AK_Read);
-else // FIXME -- should be AK_Written
-  checkAccess(CE->getImplicitObjectArgument(), AK_Read);
+// Should perhaps be AK_Written if !MD->isConst().
+checkAccess(CE->getImplicitObjectArgument(), AK_Read);
   }
 }
 



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


[PATCH] D98296: [clang-tidy] Simplify readability checks to not need ignoring* matchers

2021-03-27 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 333696.
steveire added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98296

Files:
  clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
  clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
  clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.h
  clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
  clang-tools-extra/clang-tidy/readability/NamedParameterCheck.h
  clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
  clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.h
  clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.h
  clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.h
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
  clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.h

Index: clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
===
--- clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
+++ clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
@@ -28,6 +28,9 @@
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 
 private:
   template 
Index: clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -196,12 +196,11 @@
   // Sadly, we can't check whether the literal has suffix or not.
   // E.g. i32 suffix still results in 'BuiltinType::Kind::Int'.
   // And such an info is not stored in the *Literal itself.
-  Finder->addMatcher(traverse(TK_AsIs,
+  Finder->addMatcher(
   stmt(eachOf(integerLiteral().bind(IntegerLiteralCheck::Name),
   floatLiteral().bind(FloatingLiteralCheck::Name)),
unless(anyOf(hasParent(userDefinedLiteral()),
-hasAncestor(isImplicit()),
-hasAncestor(substNonTypeTemplateParmExpr()),
+hasAncestor(substNonTypeTemplateParmExpr(),
   this);
 }
 
Index: clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
===
--- clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
+++ clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h
@@ -26,6 +26,9 @@
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 
 private:
   const bool PreferResetCall;
Index: clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
@@ -39,17 +39,14 @@
   Finder->addMatcher(
   cxxDeleteExpr(
   unless(isInTemplateInstantiation()),
-  has(expr(ignoringParenImpCasts(
-  cxxMemberCallExpr(
-  callee(
-  memberExpr(hasObjectExpression(allOf(
- unless(isTypeDependent()),
- anyOf(hasType(UniquePtrWithDefaultDelete),
-   hasType(pointsTo(
-  

[clang] 19e4569 - [Driver] Remove an unneeded multiarch library path which ends with ../../..

2021-03-27 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-27T15:46:06-07:00
New Revision: 19e45696f5a58b8609c057257ed3645aee6f4a7d

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

LOG: [Driver] Remove an unneeded multiarch library path which ends with ../../..

Neither vanilla nor Debian GCC has the patch, which usually duplicates 
$sysroot/usr/lib.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/env.c
clang/test/Driver/gcc-toolchain.cpp
clang/test/Driver/linux-cross.cpp
clang/test/Driver/linux-ld.c
clang/test/Driver/mips-reduced-toolchain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2c3707012ef5..28560e76fd7c 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2872,11 +2872,6 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
 addPathIfExists(
 D, LibPath + "/../" + GCCTriple.str() + "/lib" + Multilib.osSuffix(),
 Paths);
-
-// See comments above on the multilib variant for details of why this is
-// only included from within the sysroot.
-if (StringRef(LibPath).startswith(SysRoot))
-  addPathIfExists(D, LibPath, Paths);
   }
 }
 

diff  --git a/clang/test/Driver/env.c b/clang/test/Driver/env.c
index 0371bc91c4a3..eef3d0de5a2d 100644
--- a/clang/test/Driver/env.c
+++ b/clang/test/Driver/env.c
@@ -23,6 +23,5 @@
 // CHECK-LD-32: 
"{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0{{/|}}crtbegin.o"
 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
 // CHECK-LD-32: 
"-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
-// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
 // CHECK-LD-32: "-L[[SYSROOT]]/lib"
 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib"

diff  --git a/clang/test/Driver/gcc-toolchain.cpp 
b/clang/test/Driver/gcc-toolchain.cpp
index 287aa2cb694d..7cdba0841b8c 100644
--- a/clang/test/Driver/gcc-toolchain.cpp
+++ b/clang/test/Driver/gcc-toolchain.cpp
@@ -26,7 +26,6 @@
 // CHECK-SAME: "{{[^"]*}}/usr/lib/gcc/x86_64-linux-gnu/4.8{{/|}}crtbegin.o"
 // CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8"
 /// On x86_64, there is an extra 
usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu but we should not 
test it.
-// CHECK-SAME: "-L[[TOOLCHAIN]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.."
 
 /// Test we don't detect GCC installation under -B.
 // RUN: %clangxx %s -### --sysroot= 2>&1 \

diff  --git a/clang/test/Driver/linux-cross.cpp 
b/clang/test/Driver/linux-cross.cpp
index 3b34d27b1a97..1e9e227a1623 100644
--- a/clang/test/Driver/linux-cross.cpp
+++ b/clang/test/Driver/linux-cross.cpp
@@ -19,7 +19,6 @@
 // DEBIAN_X86_64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
 // DEBIAN_X86_64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
 /// /usr/x86_64-linux-gnu does not exist, so there is no 
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib.
-// DEBIAN_X86_64-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../.."
 /// -ccc-install-dir is not within sysroot. No bin/../lib.
 /// $sysroot/lib and $sysroot/usr/lib. Fallback when GCC installation is 
unavailable.
 // DEBIAN_X86_64-SAME: {{^}} "-L[[SYSROOT]]/lib"
@@ -44,7 +43,6 @@
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
 // DEBIAN_X86_64_M32-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
-// DEBIAN_X86_64_M32-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../.."
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 
@@ -67,7 +65,6 @@
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/aarch64-linux-gnu"
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
 // DEBIAN_AARCH64-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/lib"
-// DEBIAN_AARCH64-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../.."
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index db8c27b37720..75cf2f365704 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -11,7 +11,6 @@
 // CHECK-LD-32: 
"{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0{{/|}}crtbegin.o"
 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
 // CHECK-LD-32: 
"-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
-// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
 // CHECK-L

[PATCH] D99459: [OpenMP] Implement '#pragma omp unroll'. WIP.

2021-03-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added projects: OpenMP, clang.
Herald added subscribers: dexonsmith, martong, arphaman, zzheng, guansong, 
yaxunl.
Meinersbur requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added a project: LLVM.

Implementation of the unroll directive introduced in OpenMP 5.1. Follows the 
approach from D76342  for the tile directive 
(i.e. AST-based, not using the OpenMPIRBuilder). Tries to use 
`llvm.loop.unroll.*` metadata where possible, but has to fall back to an AST 
representation of the outer loop if the partially unrolled generated loop is 
associated with another directive (because it needs to compute the number of 
iterations).

This is work in progress, tests and some diagnostics are still missing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99459

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/unroll_ast_print.cpp
  clang/test/OpenMP/unroll_codegen.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -69,6 +69,8 @@
   let flangClass = "OmpObjectList";
 }
 def OMPC_Sizes: Clause<"sizes"> { let clangClass = "OMPSizesClause"; }
+def OMPC_Full: Clause<"full"> { let clangClass = "OMPFullClause"; }
+def OMPC_Partial: Clause<"partial"> { let clangClass = "OMPPartialClause"; }
 def OMPC_FirstPrivate : Clause<"firstprivate"> {
   let clangClass = "OMPFirstprivateClause";
   let flangClass = "OmpObjectList";
@@ -381,6 +383,12 @@
 VersionedClause,
   ];
 }
+def OMP_Unroll : Directive<"unroll"> {
+  let allowedOnceClauses = [
+VersionedClause,
+VersionedClause,
+  ];
+}
 def OMP_For : Directive<"for"> {
   let allowedClauses = [
 VersionedClause,
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -651,6 +651,9 @@
   case Stmt::OMPTileDirectiveClass:
 K = CXCursor_OMPTileDirective;
 break;
+  case Stmt::OMPUnrollDirectiveClass:
+K = CXCursor_OMPUnrollDirective;
+break;
   case Stmt::OMPForDirectiveClass:
 K = CXCursor_OMPForDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2045,6 +2045,7 @@
   void VisitOMPParallelDirective(const OMPParallelDirective *D);
   void VisitOMPSimdDirective(const OMPSimdDirective *D);
   void VisitOMPTileDirective(const OMPTileDirective *D);
+  void VisitOMPUnrollDirective(const OMPUnrollDirective *D);
   void VisitOMPForDirective(const OMPForDirective *D);
   void VisitOMPForSimdDirective(const OMPForSimdDirective *D);
   void VisitOMPSectionsDirective(const OMPSectionsDirective *D);
@@ -2219,10 +2220,27 @@
 }
 
 void OMPClauseEnqueue::VisitOMPSizesClause(const OMPSizesClause *C) {
-  for (auto E : C->getSizesRefs())
+  for (Expr* E : C->getSizesRefs())
 Visitor->AddStmt(E);
 }
 
+
+
+
+
+void OMPClauseEnqueue::VisitOMPFullClause(const OMPFullClause *C) {}
+
+
+void OMPClauseEnqueue::VisitOMPPartialClause(const OMPPartialClause *C) {
+  Visitor->AddStmt(C->getFactor());
+}
+
+
+
+
+
+
+
 void OMPClauseEnqueue::VisitOMPAllocatorClause(const OMPAllocatorClause *C) {
   Visitor->AddStmt(C->getAllocator());
 }
@@ -2872,6 +2890,12 @@
   VisitOMPLoopBasedDirective(D);
 }
 
+
+void EnqueueVisitor::VisitOMPUnrollDirective(const OMPUnrollDirective *D) {
+  VisitOMPLoopBasedDirective(D);
+}
+
+
 void EnqueueVisitor::VisitOMPForDirective(const OMPForDirective *D) {
   VisitOMPLoopDirective(D);
 }
@@ -5550,6 +5574,8 @@
 return cxstring::createRef("OMPSimdDirective");
   case CXCursor_OMPTileDirective:
 

[clang] 87a9f42 - [Driver] Remove an incorrect library path for multilib

2021-03-27 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-27T16:36:21-07:00
New Revision: 87a9f42fc1cb8c6484a9625619b6202abcb2f9a7

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

LOG: [Driver] Remove an incorrect library path for multilib

This is incorrect (adding a path with unrelated libraries) but benign in 
practice because previous paths take precedence.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/cross-linux.c
clang/test/Driver/linux-cross.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 28560e76fd7c..15be200655dc 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2852,19 +2852,7 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
 const std::string &SysRoot,
 const std::string &OSLibDir,
 path_list &Paths) {
-  // Try walking via the GCC triple path in case of biarch or multiarch GCC
-  // installations with strange symlinks.
   if (GCCInstallation.isValid()) {
-// Add the 'other' biarch variant path
-Multilib BiarchSibling;
-if (GCCInstallation.getBiarchSibling(BiarchSibling)) {
-  addPathIfExists(
-  D, GCCInstallation.getInstallPath() + BiarchSibling.gccSuffix(),
-  Paths);
-}
-
-// See comments above on the multilib variant for details of why this is
-// included even from outside the sysroot.
 const std::string &LibPath =
 std::string(GCCInstallation.getParentLibPath());
 const llvm::Triple &GCCTriple = GCCInstallation.getTriple();

diff  --git a/clang/test/Driver/cross-linux.c b/clang/test/Driver/cross-linux.c
index 6c2dab260695..f54df697b159 100644
--- a/clang/test/Driver/cross-linux.c
+++ b/clang/test/Driver/cross-linux.c
@@ -63,7 +63,6 @@
 // CHECK-MULTI32-X86-64: "crti.o" 
"[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64{{/|}}crtbegin.o"
 // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/64"
 // CHECK-MULTI32-X86-64: 
"-L[[gcc_install]]/../../../../i386-unknown-linux/lib/../lib64"
-// CHECK-MULTI32-X86-64: "-L[[gcc_install]]"
 // CHECK-MULTI32-X86-64: "-L[[gcc_install]]/../../../../i386-unknown-linux/lib"
 // CHECK-MULTI32-X86-64: "-L[[sysroot]]/lib"
 // CHECK-MULTI32-X86-64: "-L[[sysroot]]/usr/lib"
@@ -82,7 +81,6 @@
 // CHECK-MULTI64-I386: "crti.o" 
"[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]/32{{/|}}crtbegin.o"
 // CHECK-MULTI64-I386: "-L[[gcc_install]]/32"
 // CHECK-MULTI64-I386: 
"-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib/../lib32"
-// CHECK-MULTI64-I386: "-L[[gcc_install]]"
 // CHECK-MULTI64-I386: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib"
 // CHECK-MULTI64-I386: "-L[[sysroot]]/lib"
 // CHECK-MULTI64-I386: "-L[[sysroot]]/usr/lib"

diff  --git a/clang/test/Driver/linux-cross.cpp 
b/clang/test/Driver/linux-cross.cpp
index 1e9e227a1623..e3afb072dab0 100644
--- a/clang/test/Driver/linux-cross.cpp
+++ b/clang/test/Driver/linux-cross.cpp
@@ -42,7 +42,6 @@
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib32"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib32"
-// DEBIAN_X86_64_M32-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 75cf2f365704..f18553e77e42 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -355,7 +355,6 @@
 // CHECK-32-TO-64: 
"-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib64"
 // CHECK-32-TO-64: "-L[[SYSROOT]]/lib/../lib64"
 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64"
-// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
 // CHECK-32-TO-64: 
"-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
 // CHECK-32-TO-64: "-L[[SYSROOT]]/lib"
 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib"
@@ -388,7 +387,6 @@
 // CHECK-64-TO-32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib32"
 // CHECK-64-TO-32: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32"
-// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
 // CHECK-64-TO-32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
 // CHECK-64-TO-32: "-L[[SYSROOT]]/lib"
 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib"
@@ -405,7 +403,6 @@
 // CH

[clang] dcaa029 - [test] Add UNSUPPORTED: system-windows to linux-ld.c

2021-03-27 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-27T16:46:30-07:00
New Revision: dcaa0293c1068cf0b06c4e4304d3290ca3e7d5e3

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

LOG: [test] Add UNSUPPORTED: system-windows to linux-ld.c

We should have a test verifying / \ for Windows but have such a long
test specifically for Linux cross compilation suffer from Windows \
is too troublesome.

Added: 


Modified: 
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index f18553e77e42..7630d5f1324e 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // General tests that ld invocations on Linux targets sane. Note that we use
 // sysroot to make these tests independent of the host system.
 //



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


[PATCH] D99005: [clang] WIP: Implement P2266

2021-03-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 333707.
mizvekov added a comment.

Cleaned up implementation, not WIP anymore, ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b,cxx2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b   -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17   -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17   -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17   -fcxx-exceptions -Wreturn-std-move %s
 
 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
@@ -217,8 +217,8 @@
 }
 
 // But if the return type is a reference type, then moving would be wrong.
-Derived& testRetRef1(Derived&& d) { return d; }
-Base& testRetRef2(Derived&& d) { return d; }
+Derived& testRetRef1(Derived&& d) { return d; } // cxx2b-error {{on-const lvalue reference to type 'Derived' cannot bind to a temporary of type 'Derived'}}
+Base& testRetRef2(Derived&& d) { return d; } // cxx2b-error {{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Derived'}}
 #if __cplusplus >= 201402L
 auto&& testRetRef3(Derived&& d) { return d; }
 decltype(auto) testRetRef4(Derived&& d) { return (d); }
Index: clang/test/SemaCXX/return-stack-addr.cpp
===
--- clang/test/SemaCXX/return-stack-addr.cpp
+++ clang/test/SemaCXX/return-stack-addr.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected   %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected   %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11 %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b  %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx11_20   %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11_20,cxx11 %s
 
 int* ret_local() {
   int x = 1;
@@ -29,7 +29,8 @@
 
 int& ret_local_ref() {
   int x = 1;
-  return x;  // expected-warning {{reference to stack memory}}
+  return x;  // cxx11_20-warning {{reference to stack memory}}
+  // cxx2b-error@-1 {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
 }
 
 int* ret_local_addrOf() {
@@ -154,8 +155,10 @@
   (void) [&]() -> int& { return b; };
   (void) [=]() mutable -> int& { return a; };
   (void) [=]() mutable -> int& { return b; };
-  (void) [&]() -> int& { int a; return a; }; // expected-warning {{reference to stack}}
-  (void) [=]() -> int& { int a; return a; }; // expected-warning {{reference to stack}}
+  (void) [&]() -> int& { int a; return a; }; // cxx11_20-warning {{reference to stack}}
+  // cxx2b-error@-1 {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
+  (void) [=]() -> int& { int a; return a; }; // cxx11_20-warning {{reference to stack}}
+  // cxx2b-error@-1 {{non-c

[PATCH] D95745: Support unwinding from inline assembly

2021-03-27 Thread Amanieu d'Antras via Phabricator via cfe-commits
Amanieu added a comment.

The new operand to InlineAsm needs to be handled in 
llvm/lib/Transforms/Utils/ValueMapper.cpp otherwise you will end up with a bug 
similar to https://bugs.llvm.org/show_bug.cgi?id=45291.

Some tests with other unwinding models such as SJLJ and SEH would be nice.




Comment at: clang/lib/CodeGen/CGStmt.cpp:2522
+  assert(!(HasUnwindClobber && IsGCCAsmGoto) &&
+ "unwind clobber can't be used with asm goto");
+

This should be a compiler error diagnostic in SemaAsmStmt.cpp rather than an 
assert.



Comment at: llvm/lib/AsmParser/LLParser.cpp:5471
(ID.UIntVal >> 1) & 1,
-   (InlineAsm::AsmDialect(ID.UIntVal >> 2)));
+   (InlineAsm::AsmDialect(ID.UIntVal >> 2)),
+   (ID.UIntVal >> 3) & 1);





Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:2857
+  bool IsAlignStack = (Record[0] >> 1) & 1;
+  unsigned AsmDialect = Record[0] >> 2;
+  bool CanThrow = (Record[0] >> 3) & 1;





Comment at: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:2446
+if (!IA->canThrow()) {
+  // Fast path without emitting EH_LABELs.
+

Is this fast path actually useful? The frontend will almost never emit an 
invoke instruction for inline asm that can't unwind.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8347
+Chain = DAG.getEHLabel(getCurSDLoc(), Chain, BeginLabel);
+  }
+

This code is likely to get out of sync with the one in visitInvokable. It would 
be nice to share the code in a single place, but if that is not practical then 
at least add a comment in visitInvokable to remind anyone modifying that code 
to apply the same changes here as well.


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

https://reviews.llvm.org/D95745

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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2021-03-27 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie updated this revision to Diff 333708.
OikawaKirie added a comment.

In D83660#2597025 , @steakhal wrote:

> I'm somewhat bothered that this patch is not landed yet. :|
>
> I made a **crude** mock to trigger the bug using `LD_PRELOAD`. F15707493: 
> LD_PRELOAD-workaround.patch 
> The test reproduces the issue and passes if you apply the fix from this patch.
>
> However, it requires compiling a shared object with the same compiler you 
> used for building clang. I'm using the `c++` compiler, for now.
> I think it's a good starting point.

Simply replace the c++ compiler with `%host_cxx` compiler to compile the mock 
Z3 solver.


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

https://reviews.llvm.org/D83660

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/test/Analysis/z3/D83660.c
  clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c


Index: clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
===
--- /dev/null
+++ clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
@@ -0,0 +1,28 @@
+#include 
+#include 
+
+#include 
+
+// Mock implementation: return UNDEF for the 5th invocation, otherwise it just
+// returns the result of the real invocation.
+Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) {
+  static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver);
+  if (!OriginalFN) {
+OriginalFN = (Z3_lbool (*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT,
+"Z3_solver_check");
+  }
+
+  // Invoke the actual solver.
+  Z3_lbool Result = OriginalFN(c, s);
+
+  // Mock the 5th invocation to return UNDEF.
+  static unsigned int Counter = 0;
+  if (++Counter == 5) {
+fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n");
+return Z3_L_UNDEF;
+  }
+  fprintf(stderr, "Z3_solver_check returns the real value: %s\n",
+  (Result == Z3_L_UNDEF ? "UNDEF"
+: ((Result == Z3_L_TRUE ? "TRUE" : "FALSE";
+  return Result;
+}
Index: clang/test/Analysis/z3/D83660.c
===
--- /dev/null
+++ clang/test/Analysis/z3/D83660.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %host_cxx -shared -fPIC %S/Inputs/MockZ3_solver_check.c -o 
%t/MockZ3_solver_check.so
+//
+// RUN: LD_PRELOAD="%t/MockZ3_solver_check.so" 
  \
+// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer
  \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s -verify 2>&1 | 
FileCheck %s
+//
+// REQUIRES: z3, asserts, shell, system-linux
+//
+// Works only with the z3 constraint manager.
+// expected-no-diagnostics
+
+// CHECK:  Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns the real value: TRUE
+// CHECK-NEXT: Z3_solver_check returns a mocked value: UNDEF
+
+void D83660(int b) {
+  if (b) {
+  }
+  (void)b; // no-crash
+}
Index: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -146,7 +146,7 @@
   Solver->addConstraint(NotExp);
 
   Optional isNotSat = Solver->check();
-  if (!isSat.hasValue() || isNotSat.getValue())
+  if (!isNotSat.hasValue() || isNotSat.getValue())
 return nullptr;
 
   // This is the only solution, store it


Index: clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
===
--- /dev/null
+++ clang/test/Analysis/z3/Inputs/MockZ3_solver_check.c
@@ -0,0 +1,28 @@
+#include 
+#include 
+
+#include 
+
+// Mock implementation: return UNDEF for the 5th invocation, otherwise it just
+// returns the result of the real invocation.
+Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) {
+  static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver);
+  if (!OriginalFN) {
+OriginalFN = (Z3_lbool (*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT,
+"Z3_solver_check");
+  }
+
+  // Invoke the actual solver.
+  Z3_lbool Result = OriginalFN(c, s);
+
+  // Mock the 5th invocation to return UNDEF.
+  static unsigned int Counter = 0;
+  if (++Counter == 5) {
+fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n");
+return Z3_L_UNDEF;
+  }
+  fprintf(stderr, "Z3_solver_check returns the real value: %s\n",
+  (Result == Z3_L_UNDEF ? "UNDEF"
+: ((Result == Z3_L_TRUE ? "TRUE" : "FALSE")