[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap updated this revision to Diff 348736.
gergap added a comment.

remove `continue` statement from AlignTokenSequence as requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14881,6 +14881,7 @@
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
   Alignment.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
+  Alignment.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("float const a = 5;\n"
"int oneTwoThree = 123;",
Alignment);
@@ -14916,8 +14917,8 @@
   verifyFormat("int  oneTwoThree{0}; // comment\n"
"unsigned oneTwo; // comment",
Alignment);
-  verifyFormat("unsigned int *  a;\n"
-   "int *   b;\n"
+  verifyFormat("unsigned int   *a;\n"
+   "int*b;\n"
"unsigned int Const *c;\n"
"unsigned int const *d;\n"
"unsigned int Const &e;\n"
@@ -15039,9 +15040,11 @@
"  doublebar();\n"
"};\n",
Alignment);
+
+  // PAS_Right
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
 "  int const i   = 1;\n"
-"  int * j   = 2;\n"
+"  int  *j   = 2;\n"
 "  int   big = 1;\n"
 "\n"
 "  unsigned oneTwoThree = 123;\n"
@@ -15062,6 +15065,140 @@
"int ll=1;\n"
"}",
Alignment));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int **j   = 2, ***k;\n"
+"  int  &k   = i;\n"
+"  int &&l   = i + j;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int **j=2,***k;\n"
+   "int &k=i;\n"
+   "int &&l=i+j;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   Alignment));
+
+  // PAS_Left
+  FormatStyle AlignmentLeft = Alignment;
+  AlignmentLeft.PointerAlignment = FormatStyle::PAS_Left;
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int*  j   = 2;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int *j=2;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   AlignmentLeft));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int** j   = 2;\n"
+"  int&  k   = i;\n"
+"  int&& l   = i + j;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int **j=2;\n"
+   "int &k=i;\n"
+   "int &&l=i+j;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   AlignmentLeft));
+  // PAS_M

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-31 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a comment.

In D101140#2786870 , @jrtc27 wrote:

> In D101140#2786844 , @wingo wrote:
>
>> In D101140#2786777 , @jrtc27 wrote:
>>
>>> Is it just me or does having a backend-specific type in target-independent 
>>> code feel wrong? It feels like there should be a space for target-specific 
>>> TargetStackIDs...
>>
>> Hoo, good question.  More support for target-specific handling of stack IDs 
>> would be great.  However in this case the concept is not purely 
>> wasm-specific; I can imagine other targets that might have a similar 
>> treatment of locals (if we had a .net target, or a jvm target, or so).  The 
>> idea is that there is a separate stack consisting of named locals that may 
>> not be addressable by pointers to main memory.  In earlier drafts of this 
>> patch the name was more generic ("Object", then "Managed") but you know, our 
>> words in this area are quite overloaded.  So instead I went with something 
>> quite specific (WasmLocal) to avoid the general question -- but I do think 
>> the concept is not specific, even if it doesn't apply to any other target 
>> currently in tree.  WDYT?
>
> Well, except all the logic for it is in the backend, only the parser and the 
> definition are in target-independent code, so even if another backend were to 
> reuse it it would have its own completely separate logic for it, and thus 
> there's no benefit to reusing a shared name for the thing over each target 
> defining its own? Or would some of the code in the wasm backend be refactored 
> out into CodeGen?

This is the case for all `TargetStackID` enumerated values except 
`TargetStackID::Default` -- `ScalableVector` and `SGPRSpill` have 0 uses 
outside target backends, though the ScalableVector name is used in RISC-V and 
AMDGPU.  `NoAlloc` has one mention outside the target backends but no real 
logic.  Still, as a reader who hacks neither on RISC-V nor AMDGPU  I find it 
useful that they share the same stack ID definition for scalable vectors -- 
lets me compare things a bit easier.

If there is a change to be made in this area (moving these enumerated values 
elsewhere) it would have to be in a followup I think and would need 
consultation with the other backends that use these values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-31 Thread Andy Wingo 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 rGbf35f4af51cd: [WebAssembly][CodeGen] IR support for 
WebAssembly local variables (authored by wingo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,87 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+; We have a set of tests in which we set a local and then reload the
+; local.  If the load immediately follows the set, the DAG combiner will
+; infer that the reloaded value is the same value that was set, which
+; isn't what we want to test.  To inhibit this optimization, we include
+; an opaque call between the store and the load.
+declare void @inhibit_store_to_load_forwarding()
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i32, %i32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 1
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ store float %arg, %f32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s --check-prefix=CHECKCG
+; RUN: llc -mtriple=wasm32-unknown-unknown -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECKISEL
+
+%f32_cell = type float addrspace(1)*
+
+; CHECKISEL-LABEL: name: ir_local_f32
+; CHECKISEL:   stack:
+; CHECKISEL:   id: 0, name: retval, type: default, offset: 1, size: 1, alignment: 4,
+; CHECKISEL-NEXT:  s

[clang] 818338a - [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via cfe-commits

Author: Abbas Sabra
Date: 2021-05-31T10:44:53+02:00
New Revision: 818338add77411f5e9713247ea66142f332ef350

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

LOG: [clang] Add support for the "abstract" contextual keyword of MSVC

https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

Differential revision: https://reviews.llvm.org/D102517

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 07c4eb261aac1..c9efc4b454968 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1786,6 +1786,7 @@ class CXXRecordDecl : public RecordDecl {
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;
   }
+  void markAbstract() { data().Abstract = true; }
 };
 
 /// Store information needed for an explicit specifier.

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index f6a4fbb1e04c8..8544607673c3e 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1086,6 +1086,7 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">;
 def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">;
 def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">;
 def MicrosoftSealed : DiagGroup<"microsoft-sealed">;
+def MicrosoftAbstract : DiagGroup<"microsoft-abstract">;
 def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">;
 def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">;
 def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">;
@@ -1123,7 +1124,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // Warnings group for warnings about Microsoft extensions.
 def Microsoft : DiagGroup<"microsoft",
 [MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude,
- MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed,
+ MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract,
  MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl,
  MicrosoftMutableReference, MicrosoftPureDefinition,
  MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall,

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 97cb7020f3452..b13c382c16ebc 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -922,10 +922,16 @@ def err_override_control_interface : Error<
 def ext_ms_sealed_keyword : ExtWarn<
   "'sealed' keyword is a Microsoft extension">,
   InGroup;
+def ext_ms_abstract_keyword : ExtWarn<
+  "'abstract' keyword is a Microsoft extension">,
+  InGroup;
 
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
+def err_duplicate_class_virt_specifier : Error<
+  "class already marked '%0'">;
+
 def err_duplicate_virt_specifier : Error<
   "class member already marked '%0'">;
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e3e6509b025e5..c32ae6d2cf406 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -114,6 +114,7 @@ class Parser : public CodeCompletionHandler {
   /// Contextual keywords for Microsoft extensions.
   IdentifierInfo *Ident__except;
   mutable IdentifierInfo *Ident_sealed;
+  mutable IdentifierInfo *Ident_abstract;
 
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
@@ -2913,6 +2914,7 @@ class Parser : public CodeCompletionHandler {
   SourceLocation FriendLoc);
 
   bool isCXX11FinalKeyword() const;
+  bool isClassCompatibleKeyword() const;
 
   /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
   /// enter a new C++ declarator scope and exit it when the function is

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 3b16295941e48..423f4f4ee7b7c 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -2620,7 +2620,8 @@ class VirtSp

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg 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 rG818338add774: [clang] Add support for the 
"abstract" contextual keyword of MSVC (authored by AbbasSabra, 
committed by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp

Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -462,6 +462,77 @@
 virtual ~SealedDestructor() sealed; // expected-warning {{class with destructor marked 'sealed' cannot be inherited from}}
 };
 
+// expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+class AbstractClass abstract {
+  int i;
+};
+
+// expected-error@+1 {{variable type 'AbstractClass' is an abstract class}}
+AbstractClass abstractInstance;
+
+// expected-warning@+4 {{abstract class is marked 'sealed'}}
+// expected-note@+3 {{'AbstractAndSealedClass' declared here}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
+class AbstractAndSealedClass abstract sealed {}; // Does no really make sense, but allowed
+
+// expected-error@+1 {{variable type 'AbstractAndSealedClass' is an abstract class}}
+AbstractAndSealedClass abstractAndSealedInstance;
+// expected-error@+1 {{base 'AbstractAndSealedClass' is marked 'sealed'}}
+class InheritFromAbstractAndSealed : AbstractAndSealedClass {};
+
+#if __cplusplus <= 199711L
+// expected-warning@+4 {{'final' keyword is a C++11 extension}}
+// expected-warning@+3 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-error@+1 {{class already marked 'final'}}
+class TooManyVirtSpecifiers1 final final {};
+#if __cplusplus <= 199711L
+// expected-warning@+4 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+2 {{'sealed' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'sealed'}}
+class TooManyVirtSpecifiers2 final sealed {};
+#if __cplusplus <= 199711L
+// expected-warning@+6 {{'final' keyword is a C++11 extension}}
+// expected-warning@+5 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+3 {{abstract class is marked 'final'}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'final'}}
+class TooManyVirtSpecifiers3 final abstract final {};
+#if __cplusplus <= 199711L
+// expected-warning@+6 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+4 {{abstract class is marked 'final'}}
+// expected-warning@+3 {{'abstract' keyword is a Microsoft extension}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'abstract'}}
+class TooManyVirtSpecifiers4 abstract final abstract {};
+
+class Base {
+  virtual void i();
+};
+class AbstractFunctionInClass : public Base {
+  // expected-note@+2 {{unimplemented pure virtual method 'f' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void f() abstract;
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  void g() abstract; // expected-error {{'g' is not virtual and cannot be declared pure}}
+  // expected-note@+2 {{unimplemented pure virtual method 'h' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void h() abstract = 0; // expected-error {{class member already marked 'abstract'}}
+#if __cplusplus <= 199711L
+  // expected-warning@+4 {{'override' keyword is a C++11 extension}}
+#endif
+  // expected-note@+2 {{unimplemented pure virtual method 'i' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void i() abstract override;
+};
+
+// expected-error@+1 {{variable type 'AbstractFunctionInClass' is an abstract class}}
+AbstractFunctionInClass abstractFunctionInClassInstance;
+
 void AfterClassBody() {
   // expected-warning@+1 {{attribute 'deprecated' is ignored, place it after "struct" to apply attribute to type declaration}}
   struct D {} __declspec(deprecated);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16456,6 +16456,7 @@
 void Sema::Ac

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Pushed as 
http://github.com/llvm/llvm-project/commit/818338add77411f5e9713247ea66142f332ef350


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

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


[PATCH] D103387: [clangd] Fix feature modules to drop diagnostics

2021-05-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 348747.
kadircet added a comment.

Get rid of LastDiagWasSuppressed state in StoreDiags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103387

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp

Index: clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "Annotations.h"
 #include "FeatureModule.h"
 #include "Selection.h"
 #include "TestTU.h"
@@ -53,6 +54,37 @@
   EXPECT_EQ(Actual->get()->id(), TweakID);
 }
 
+TEST(FeatureModulesTest, SuppressDiags) {
+  struct DiagModifierModule final : public FeatureModule {
+struct Listener : public FeatureModule::ASTListener {
+  void sawDiagnostic(const clang::Diagnostic &Info,
+ clangd::Diag &Diag) override {
+Diag.Severity = DiagnosticsEngine::Ignored;
+  }
+};
+std::unique_ptr astListeners() override {
+  return std::make_unique();
+};
+  };
+  FeatureModuleSet FMS;
+  FMS.add(std::make_unique());
+
+  Annotations Code("[[test]]; /* error-ok */");
+  TestTU TU;
+  TU.Code = Code.code().str();
+
+  {
+auto AST = TU.build();
+EXPECT_THAT(*AST.getDiagnostics(), testing::Not(testing::IsEmpty()));
+  }
+
+  TU.FeatureModules = &FMS;
+  {
+auto AST = TU.build();
+EXPECT_THAT(*AST.getDiagnostics(), testing::IsEmpty());
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -171,7 +171,6 @@
   SourceManager *OrigSrcMgr = nullptr;
 
   llvm::DenseSet> IncludedErrorLocations;
-  bool LastPrimaryDiagnosticWasSuppressed = false;
 };
 
 /// Determine whether a (non-clang-tidy) diagnostic is suppressed by config.
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -727,44 +727,37 @@
 // Handle the new main diagnostic.
 flushLastDiag();
 
-if (Adjuster) {
+// FIXME: Merge with feature modules.
+if (Adjuster)
   DiagLevel = Adjuster(DiagLevel, Info);
-  if (DiagLevel == DiagnosticsEngine::Ignored) {
-LastPrimaryDiagnosticWasSuppressed = true;
-return;
-  }
-}
-LastPrimaryDiagnosticWasSuppressed = false;
 
 LastDiag = Diag();
 FillDiagBase(*LastDiag);
 LastDiagLoc.emplace(Info.getLocation(), Info.getSourceManager());
 LastDiagOriginallyError = OriginallyError;
 
+if (DiagCB)
+  DiagCB(Info, *LastDiag);
 if (!Info.getFixItHints().empty())
   AddFix(true /* try to invent a message instead of repeating the diag */);
 if (Fixer) {
-  auto ExtraFixes = Fixer(DiagLevel, Info);
+  auto ExtraFixes = Fixer(LastDiag->Severity, Info);
   LastDiag->Fixes.insert(LastDiag->Fixes.end(), ExtraFixes.begin(),
  ExtraFixes.end());
 }
-if (DiagCB)
-  DiagCB(Info, *LastDiag);
   } else {
 // Handle a note to an existing diagnostic.
-
-// If a diagnostic was suppressed due to the suppression filter,
-// also suppress notes associated with it.
-if (LastPrimaryDiagnosticWasSuppressed) {
-  return;
-}
-
 if (!LastDiag) {
   assert(false && "Adding a note without main diagnostic");
   IgnoreDiagnostics::log(DiagLevel, Info);
   return;
 }
 
+// If a diagnostic was suppressed due to the suppression filter,
+// also suppress notes associated with it.
+if (LastDiag->Severity == DiagnosticsEngine::Ignored)
+  return;
+
 if (!Info.getFixItHints().empty()) {
   // A clang note with fix-it is not a separate diagnostic in clangd. We
   // attach it as a Fix to the main diagnostic instead.
@@ -789,7 +782,7 @@
 LastDiag.reset();
   });
 
-  if (isExcluded(*LastDiag))
+  if (LastDiag->Severity == DiagnosticsEngine::Ignored || isExcluded(*LastDiag))
 return;
   // Move errors that occur from headers into main file.
   if (!LastDiag->InsideMainFile && LastDiagLoc && LastDiagOriginallyError) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-31 Thread Andy Wingo via Phabricator via cfe-commits
wingo reopened this revision.
wingo added a comment.
This revision is now accepted and ready to land.

Yarrrgh, broke the shared library build.  Fix incoming...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[clang] 37b530a - [clang] NFC: split HeaderMapTest to have re-usable header map implementation for testing

2021-05-31 Thread Dmitry Polukhin via cfe-commits

Author: Dmitry Polukhin
Date: 2021-05-31T01:57:36-07:00
New Revision: 37b530a2ea8bdc28a22a3f8ca701455fb7febdea

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

LOG: [clang] NFC: split HeaderMapTest to have re-usable header map 
implementation for testing

NFC changes required for https://reviews.llvm.org/D103142

Test Plan: check-clang

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

Added: 
clang/unittests/Lex/HeaderMapTestUtils.h

Modified: 
clang/unittests/Lex/HeaderMapTest.cpp

Removed: 




diff  --git a/clang/unittests/Lex/HeaderMapTest.cpp 
b/clang/unittests/Lex/HeaderMapTest.cpp
index c18ce79ef58f0..4220edb2908e0 100644
--- a/clang/unittests/Lex/HeaderMapTest.cpp
+++ b/clang/unittests/Lex/HeaderMapTest.cpp
@@ -6,89 +6,17 @@
 //
 //===--===//
 
-#include "clang/Basic/CharInfo.h"
-#include "clang/Lex/HeaderMap.h"
-#include "clang/Lex/HeaderMapTypes.h"
+#include "HeaderMapTestUtils.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/Support/SwapByteOrder.h"
 #include "gtest/gtest.h"
-#include 
 #include 
 
 using namespace clang;
 using namespace llvm;
+using namespace clang::test;
 
 namespace {
 
-// Lay out a header file for testing.
-template  struct MapFile {
-  HMapHeader Header;
-  HMapBucket Buckets[NumBuckets];
-  unsigned char Bytes[NumBytes];
-
-  void init() {
-memset(this, 0, sizeof(MapFile));
-Header.Magic = HMAP_HeaderMagicNumber;
-Header.Version = HMAP_HeaderVersion;
-Header.NumBuckets = NumBuckets;
-Header.StringsOffset = sizeof(Header) + sizeof(Buckets);
-  }
-
-  void swapBytes() {
-using llvm::sys::getSwappedBytes;
-Header.Magic = getSwappedBytes(Header.Magic);
-Header.Version = getSwappedBytes(Header.Version);
-Header.NumBuckets = getSwappedBytes(Header.NumBuckets);
-Header.StringsOffset = getSwappedBytes(Header.StringsOffset);
-  }
-
-  std::unique_ptr getBuffer() const {
-return MemoryBuffer::getMemBuffer(
-StringRef(reinterpret_cast(this), sizeof(MapFile)),
-"header",
-/* RequresNullTerminator */ false);
-  }
-};
-
-// The header map hash function.
-static inline unsigned getHash(StringRef Str) {
-  unsigned Result = 0;
-  for (char C : Str)
-Result += toLowercase(C) * 13;
-  return Result;
-}
-
-template  struct FileMaker {
-  FileTy &File;
-  unsigned SI = 1;
-  unsigned BI = 0;
-  FileMaker(FileTy &File) : File(File) {}
-
-  unsigned addString(StringRef S) {
-assert(SI + S.size() + 1 <= sizeof(File.Bytes));
-std::copy(S.begin(), S.end(), File.Bytes + SI);
-auto OldSI = SI;
-SI += S.size() + 1;
-return OldSI;
-  }
-  void addBucket(unsigned Hash, unsigned Key, unsigned Prefix, unsigned 
Suffix) {
-assert(!(File.Header.NumBuckets & (File.Header.NumBuckets - 1)));
-unsigned I = Hash & (File.Header.NumBuckets - 1);
-do {
-  if (!File.Buckets[I].Key) {
-File.Buckets[I].Key = Key;
-File.Buckets[I].Prefix = Prefix;
-File.Buckets[I].Suffix = Suffix;
-++File.Header.NumEntries;
-return;
-  }
-  ++I;
-  I &= File.Header.NumBuckets - 1;
-} while (I != (Hash & (File.Header.NumBuckets - 1)));
-llvm_unreachable("no empty buckets");
-  }
-};
-
 TEST(HeaderMapTest, checkHeaderEmpty) {
   bool NeedsSwap;
   ASSERT_FALSE(HeaderMapImpl::checkHeader(
@@ -98,7 +26,7 @@ TEST(HeaderMapTest, checkHeaderEmpty) {
 }
 
 TEST(HeaderMapTest, checkHeaderMagic) {
-  MapFile<1, 1> File;
+  HMapFileMock<1, 1> File;
   File.init();
   File.Header.Magic = 0;
   bool NeedsSwap;
@@ -106,7 +34,7 @@ TEST(HeaderMapTest, checkHeaderMagic) {
 }
 
 TEST(HeaderMapTest, checkHeaderReserved) {
-  MapFile<1, 1> File;
+  HMapFileMock<1, 1> File;
   File.init();
   File.Header.Reserved = 1;
   bool NeedsSwap;
@@ -114,7 +42,7 @@ TEST(HeaderMapTest, checkHeaderReserved) {
 }
 
 TEST(HeaderMapTest, checkHeaderVersion) {
-  MapFile<1, 1> File;
+  HMapFileMock<1, 1> File;
   File.init();
   ++File.Header.Version;
   bool NeedsSwap;
@@ -122,7 +50,7 @@ TEST(HeaderMapTest, checkHeaderVersion) {
 }
 
 TEST(HeaderMapTest, checkHeaderValidButEmpty) {
-  MapFile<1, 1> File;
+  HMapFileMock<1, 1> File;
   File.init();
   bool NeedsSwap;
   ASSERT_TRUE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
@@ -134,7 +62,7 @@ TEST(HeaderMapTest, checkHeaderValidButEmpty) {
 }
 
 TEST(HeaderMapTest, checkHeader3Buckets) {
-  MapFile<3, 1> File;
+  HMapFileMock<3, 1> File;
   ASSERT_EQ(3 * sizeof(HMapBucket), sizeof(File.Buckets));
 
   File.init();
@@ -144,7 +72,7 @@ TEST(HeaderMapTest, checkHeader3Buckets) {
 
 TEST(HeaderMapTest, checkHeader0Buckets) {
   // Create with 1 bucket to avoid 0-sized arrays.
-  MapFile<1, 1> File;
+  HMapFileMock<1, 1> File;
   File.init();

[PATCH] D103229: [clang] NFC: split HeaderMapTest to have re-usable header map implementation for testing

2021-05-31 Thread Dmitry Polukhin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37b530a2ea8b: [clang] NFC: split HeaderMapTest to have 
re-usable header map implementation… (authored by DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103229

Files:
  clang/unittests/Lex/HeaderMapTest.cpp
  clang/unittests/Lex/HeaderMapTestUtils.h

Index: clang/unittests/Lex/HeaderMapTestUtils.h
===
--- /dev/null
+++ clang/unittests/Lex/HeaderMapTestUtils.h
@@ -0,0 +1,100 @@
+//===- unittests/Lex/HeaderMapTestUtils.h - HeaderMap utils ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_UNITTESTS_LEX_HEADERMAPTESTUTILS_H
+#define LLVM_CLANG_UNITTESTS_LEX_HEADERMAPTESTUTILS_H
+
+#include "clang/Basic/CharInfo.h"
+#include "clang/Lex/HeaderMap.h"
+#include "clang/Lex/HeaderMapTypes.h"
+#include "llvm/Support/SwapByteOrder.h"
+#include 
+
+namespace clang {
+namespace test {
+
+// Lay out a header file for testing.
+template  struct HMapFileMock {
+  HMapHeader Header;
+  HMapBucket Buckets[NumBuckets];
+  unsigned char Bytes[NumBytes];
+
+  void init() {
+memset(this, 0, sizeof(HMapFileMock));
+Header.Magic = HMAP_HeaderMagicNumber;
+Header.Version = HMAP_HeaderVersion;
+Header.NumBuckets = NumBuckets;
+Header.StringsOffset = sizeof(Header) + sizeof(Buckets);
+  }
+
+  void swapBytes() {
+using llvm::sys::getSwappedBytes;
+Header.Magic = getSwappedBytes(Header.Magic);
+Header.Version = getSwappedBytes(Header.Version);
+Header.NumBuckets = getSwappedBytes(Header.NumBuckets);
+Header.StringsOffset = getSwappedBytes(Header.StringsOffset);
+  }
+
+  std::unique_ptr getBuffer() {
+return llvm::MemoryBuffer::getMemBuffer(
+StringRef(reinterpret_cast(this), sizeof(HMapFileMock)),
+"header",
+/* RequresNullTerminator */ false);
+  }
+};
+
+template  struct HMapFileMockMaker {
+  FileTy &File;
+  unsigned SI = 1;
+  unsigned BI = 0;
+  HMapFileMockMaker(FileTy &File) : File(File) {}
+
+  unsigned addString(StringRef S) {
+assert(SI + S.size() + 1 <= sizeof(File.Bytes));
+std::copy(S.begin(), S.end(), File.Bytes + SI);
+auto OldSI = SI;
+SI += S.size() + 1;
+return OldSI;
+  }
+
+  void addBucket(StringRef Str, unsigned Key, unsigned Prefix,
+ unsigned Suffix) {
+addBucket(getHash(Str), Key, Prefix, Suffix);
+  }
+
+  void addBucket(unsigned Hash, unsigned Key, unsigned Prefix,
+ unsigned Suffix) {
+assert(!(File.Header.NumBuckets & (File.Header.NumBuckets - 1)));
+unsigned I = Hash & (File.Header.NumBuckets - 1);
+do {
+  if (!File.Buckets[I].Key) {
+File.Buckets[I].Key = Key;
+File.Buckets[I].Prefix = Prefix;
+File.Buckets[I].Suffix = Suffix;
+++File.Header.NumEntries;
+return;
+  }
+  ++I;
+  I &= File.Header.NumBuckets - 1;
+} while (I != (Hash & (File.Header.NumBuckets - 1)));
+llvm_unreachable("no empty buckets");
+  }
+
+  // The header map hash function.
+  static unsigned getHash(StringRef Str) {
+unsigned Result = 0;
+for (char C : Str)
+  Result += toLowercase(C) * 13;
+return Result;
+  }
+};
+
+} // namespace test
+} // namespace clang
+
+#endif
Index: clang/unittests/Lex/HeaderMapTest.cpp
===
--- clang/unittests/Lex/HeaderMapTest.cpp
+++ clang/unittests/Lex/HeaderMapTest.cpp
@@ -6,89 +6,17 @@
 //
 //===--===//
 
-#include "clang/Basic/CharInfo.h"
-#include "clang/Lex/HeaderMap.h"
-#include "clang/Lex/HeaderMapTypes.h"
+#include "HeaderMapTestUtils.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/Support/SwapByteOrder.h"
 #include "gtest/gtest.h"
-#include 
 #include 
 
 using namespace clang;
 using namespace llvm;
+using namespace clang::test;
 
 namespace {
 
-// Lay out a header file for testing.
-template  struct MapFile {
-  HMapHeader Header;
-  HMapBucket Buckets[NumBuckets];
-  unsigned char Bytes[NumBytes];
-
-  void init() {
-memset(this, 0, sizeof(MapFile));
-Header.Magic = HMAP_HeaderMagicNumber;
-Header.Version = HMAP_HeaderVersion;
-Header.NumBuckets = NumBuckets;
-Header.StringsOffset = sizeof(Header) + sizeof(Buckets);
-  }
-
-  void swapBytes() {
-using llvm::sys::getSwappedBytes;
-Header.Magic = getSwappedBytes(Header.Magic);
-Header.Version = getSwappedBytes(Header.Version);
-Header.NumBuckets = getSwappedBytes(Header.NumBuckets);
-Header.StringsOffset = getSwappedBytes(Header.StringsOff

[PATCH] D103286: [clang-format] Add PPIndentWidth option

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap marked 3 inline comments as done.
gergap added a comment.

I fixed the review findings and changed the behavior to be better backwards 
compatible by using PPIndentWidth=-1 by default.
This value defaults to IndentWidth now.




Comment at: clang/unittests/Format/FormatTest.cpp:3447
+   style);
+}
+

MyDeveloperDay wrote:
> can you add a test
> 
> ```
> #ifdef X
>void foo() {
>...
>}
> #endif
> ```
> 
> its unclear if PPIndentWidth affects code in #ifdef or just # preprocessor 
> instructions
It does not affect the code. It works in the same way as IndentWidth.
I updated the test cases now to verify this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

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


[PATCH] D103286: [clang-format] Add PPIndentWidth option

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap updated this revision to Diff 348753.
gergap marked an inline comment as done.
gergap added a comment.

fix review findings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3431,6 +3431,48 @@
   verifyFormat("a\f\\");
 }
 
+TEST_F(FormatTest, IndentsPPDirectiveWithPPIndentWidth) {
+  FormatStyle style = getChromiumStyle(FormatStyle::LK_Cpp);
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef __linux__\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n"
+   "#define FOO\n"
+   "#endif\n"
+   "void bar() {\n"
+   "int y = 0;\n"
+   "}\n",
+   style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef __linux__\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n"
+   "# define FOO foo\n"
+   "#endif\n"
+   "void bar() {\n"
+   "int y = 0;\n"
+   "}\n",
+   style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_BeforeHash;
+  verifyFormat("#ifdef __linux__\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n"
+   " #define FOO foo\n"
+   "#endif\n"
+   "void bar() {\n"
+   "int y = 0;\n"
+   "}\n",
+   style);
+}
+
 TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {
   verifyFormat("#define A(BB)", getLLVMStyleWithColumns(13));
   verifyFormat("#define A( \\\nBB)", getLLVMStyleWithColumns(12));
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -57,7 +57,9 @@
 while (IndentForLevel.size() <= Line.Level)
   IndentForLevel.push_back(-1);
 if (Line.InPPDirective) {
-  Indent = Line.Level * Style.IndentWidth + AdditionalIndent;
+  unsigned IndentWidth =
+  (Style.PPIndentWidth >= 0) ? Style.PPIndentWidth : Style.IndentWidth;
+  Indent = Line.Level * IndentWidth + AdditionalIndent;
 } else {
   IndentForLevel.resize(Line.Level + 1);
   Indent = getIndent(IndentForLevel, Line.Level);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -664,6 +664,7 @@
 IO.mapOptional("PenaltyIndentedWhitespace",
Style.PenaltyIndentedWhitespace);
 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
+IO.mapOptional("PPIndentWidth", Style.PPIndentWidth);
 IO.mapOptional("RawStringFormats", Style.RawStringFormats);
 IO.mapOptional("ReflowComments", Style.ReflowComments);
 IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
@@ -1021,6 +1022,7 @@
   LLVMStyle.IndentRequires = false;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
+  LLVMStyle.PPIndentWidth = -1;
   LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2659,6 +2659,19 @@
   /// Pointer and reference alignment style.
   PointerAlignmentStyle PointerAlignment;
 
+  /// The number of columns to use for indentation of preprocessor statements.
+  /// When set to -1 this defaults to IndentWidth for backwards compatibility.
+  /// \code
+  ///PPIndentWidth: 1
+  ///
+  ///#ifdef __linux__
+  ///# define FOO
+  ///#else
+  ///# define BAR
+  ///#endif
+  /// \endcode
+  signed PPIndentWidth;
+
   /// See documentation of ``RawStringFormats``.
   struct RawStringFormat {
 /// The language of this raw string.
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2615,6 +2615,20 @@
 }
  }
 
+**PPIndentWidth** (``unsigned``)
+  The number of columns to use for indentation of preprocessor statements.
+  When set to -1 this def

[PATCH] D75041: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

2021-05-31 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Bump. 🙂 This is the last part that's still unreviewed and also the most complex.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-31 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 348758.
wingo added a comment.

Fix shared-library build by moving util function to WebAssemblyFrameLowering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,87 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+; We have a set of tests in which we set a local and then reload the
+; local.  If the load immediately follows the set, the DAG combiner will
+; infer that the reloaded value is the same value that was set, which
+; isn't what we want to test.  To inhibit this optimization, we include
+; an opaque call between the store and the load.
+declare void @inhibit_store_to_load_forwarding()
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i32, %i32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 1
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ store float %arg, %f32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s --check-prefix=CHECKCG
+; RUN: llc -mtriple=wasm32-unknown-unknown -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECKISEL
+
+%f32_cell = type float addrspace(1)*
+
+; CHECKISEL-LABEL: name: ir_local_f32
+; CHECKISEL:   stack:
+; CHECKISEL:   id: 0, name: retval, type: default, offset: 1, size: 1, alignment: 4,
+; CHECKISEL-NEXT:  stack-id: wasm-local
+
+; CHECKCG-LABEL: ir_local_f32:
+; CHECKCG-NEXT: .functype ir_local_f32 (f32) -> (f32)
+; CHECKCG-NEXT: .local f32
+; CHECKCG-NEXT: local.get 0
+; CHECKCG-NEXT: local.set 1
+
+define float @ir_local_f32

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-31 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a comment.

Quick r? to @tlively -- OK with having the new util function in 
WebAssemblyFrameLowering?  It didn't work to have it in the utils library 
because the function needs the vtable of WebAssemblyFunctionInfo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D103377: [clangd] Add ability to change storage directory of index files

2021-05-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> I mainly added this because I am doing profiling of indexing and needed a way 
> for multiple instances of index files not to conflict with each other.

If this is solely for testing purposes, can't you make use of 
`--compile-commands-dir` instead? You'll also need to copy your 
compile_commands.json into that directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103377

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


[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-05-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 348759.
cor3ntin added a comment.

Add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103380

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
  clang/test/SemaCXX/anonymous-struct.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4";>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this 
typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given 
name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not 
C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage 
purposes by this typedef declaration}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+template  struct Nothing {};
+
+template 
+concept True = [] { return true; }();
+
+static_assert(True);
+
+static_assert(sizeof([] { return 0; }));
+static_assert(sizeof([] { return 0; }()));
+
+void f()  noexcept(noexcept([] { return 0; }()));
+
+using a = decltype([] { return 0; });
+using b = decltype([] { return 0; }());
+using c = decltype([]() noexcept(noexcept([] { return 0; }())) { return 0; });
+using d = decltype(sizeof([] { return 0; }));
+
+
+Nothing<[]() { return 0; }()> nothing;
+
+
+template 
+auto g(T) -> decltype([]() { T::invalid; } ());
+auto e = g(0); // expected-error{{no matching function for call}}
+// expected-note@-2 {{substitution failure}}
\ No newline at end of file
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16657,8 +16657,10 @@
 
   if (!Rec.Lambdas.empty()) {
 using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
-if (Rec.ExprContext == ExpressionKind::EK_TemplateArgument || 
Rec.isUnevaluated() ||
-(Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17)) {
+if (!getLangOpts().CPlusPlus20 &&
+(Rec.ExprContext == ExpressionKind::EK_TemplateArgument ||
+ Rec.isUnevaluated() ||
+ (Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17))) {
   unsigned D;
   if (Rec.isUnevaluated()) {
 // C++11 [expr.prim.lambda]p2:
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -41,9 +41,12 @@
   LHS = BO->getLHS();
   RHS = BO->getRHS();
 } else if (auto *OO = dyn_cast(E)) {
-  Op = OO->getOperator();
-  LHS = OO->getArg(0);
-  RHS = OO->getArg(1);
+  // If OO is not || or && it might not have exactly 2 arguments
+  if (OO->getNumArgs() == 2) {
+Op = OO->getOperator();
+LHS = OO->getArg(0);
+RHS = OO->getArg(1);
+  }
 }
   }
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4";>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not C-compati

[PATCH] D103386: [PowerPC] Fix x86 vector intrinsics wrapper compilation under C++

2021-05-31 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for fixing this.




Comment at: clang/lib/Headers/ppc_wrappers/xmmintrin.h:31
use vector SIMD operations. We recommend this for new applications. */
 #error "Please read comment above.  Use -DNO_WARN_X86_INTRINSICS to disable 
this error."
 #endif

I agree that it would be good to get rid of the extra space. :)



Comment at: clang/test/CodeGen/ppc-xmmintrin.c:1433
 test_prefetch() {
-  _mm_prefetch(ms, i);
+  _mm_prefetch(ms, (enum _mm_hint)i);
 }

I am not sure if this file has any tests that use the actual enumerators rather 
than an integer, but it seems like we should.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103386

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


[clang] a723ca3 - fix broken clang tests after 7161bb87c914

2021-05-31 Thread Juneyoung Lee via cfe-commits

Author: Juneyoung Lee
Date: 2021-05-31T19:25:14+09:00
New Revision: a723ca32af896d99058672a43fe457ba155a23b2

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

LOG: fix broken clang tests after  7161bb87c914

Added: 


Modified: 
clang/test/CodeGen/X86/avx-shuffle-builtins.c
clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
clang/test/CodeGen/aarch64-neon-vcmla.c
clang/test/CodeGen/arm-bf16-getset-intrinsics.c
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx-shuffle-builtins.c 
b/clang/test/CodeGen/X86/avx-shuffle-builtins.c
index b1cd2c63ecf01..c921a1ec0c5e4 100644
--- a/clang/test/CodeGen/X86/avx-shuffle-builtins.c
+++ b/clang/test/CodeGen/X86/avx-shuffle-builtins.c
@@ -67,7 +67,7 @@ __m128
 test_mm_broadcast_ss(float const *__a) {
   // CHECK-LABEL: test_mm_broadcast_ss
   // CHECK: insertelement <4 x float> {{.*}}, i32 0
-  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> undef, <4 x i32> 
zeroinitializer
+  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> poison, <4 x i32> 
zeroinitializer
   return _mm_broadcast_ss(__a);
 }
 
@@ -75,7 +75,7 @@ __m256d
 test_mm256_broadcast_sd(double const *__a) {
   // CHECK-LABEL: test_mm256_broadcast_sd
   // CHECK: insertelement <4 x double> {{.*}}, i32 0
-  // CHECK: shufflevector <4 x double> {{.*}}, <4 x double> undef, <4 x i32> 
zeroinitializer
+  // CHECK: shufflevector <4 x double> {{.*}}, <4 x double> poison, <4 x i32> 
zeroinitializer
   return _mm256_broadcast_sd(__a);
 }
 
@@ -83,7 +83,7 @@ __m256
 test_mm256_broadcast_ss(float const *__a) {
   // CHECK-LABEL: test_mm256_broadcast_ss
   // CHECK: insertelement <8 x float> {{.*}}, i32 0
-  // CHECK: shufflevector <8 x float> {{.*}}, <8 x float> undef, <8 x i32> 
zeroinitializer
+  // CHECK: shufflevector <8 x float> {{.*}}, <8 x float> poison, <8 x i32> 
zeroinitializer
   return _mm256_broadcast_ss(__a);
 }
 

diff  --git a/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c 
b/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
index 27b3b345544c4..fc4ed1d3b10c9 100644
--- a/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
@@ -16,7 +16,7 @@ bfloat16x4_t test_vcreate_bf16(uint64_t a) {
 // CHECK-LABEL: @test_vdup_n_bf16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <4 x bfloat> undef, bfloat 
[[V:%.*]], i32 0
-// CHECK-NEXT:[[VECINIT3_I:%.*]] = shufflevector <4 x bfloat> 
[[VECINIT_I]], <4 x bfloat> undef, <4 x i32> zeroinitializer
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = shufflevector <4 x bfloat> 
[[VECINIT_I]], <4 x bfloat> poison, <4 x i32> zeroinitializer
 // CHECK-NEXT:ret <4 x bfloat> [[VECINIT3_I]]
 //
 bfloat16x4_t test_vdup_n_bf16(bfloat16_t v) {
@@ -26,7 +26,7 @@ bfloat16x4_t test_vdup_n_bf16(bfloat16_t v) {
 // CHECK-LABEL: @test_vdupq_n_bf16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <8 x bfloat> undef, bfloat 
[[V:%.*]], i32 0
-// CHECK-NEXT:[[VECINIT7_I:%.*]] = shufflevector <8 x bfloat> 
[[VECINIT_I]], <8 x bfloat> undef, <8 x i32> zeroinitializer
+// CHECK-NEXT:[[VECINIT7_I:%.*]] = shufflevector <8 x bfloat> 
[[VECINIT_I]], <8 x bfloat> poison, <8 x i32> zeroinitializer
 // CHECK-NEXT:ret <8 x bfloat> [[VECINIT7_I]]
 //
 bfloat16x8_t test_vdupq_n_bf16(bfloat16_t v) {
@@ -98,8 +98,8 @@ bfloat16x4_t test_vget_low_bf16(bfloat16x8_t a) {
 
 // CHECK-LABEL: @test_vget_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <4 x bfloat> [[V:%.*]], 
i32 1
-// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <4 x bfloat> [[V:%.*]], 
i32 1
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vget_lane_bf16(bfloat16x4_t v) {
   return vget_lane_bf16(v, 1);
@@ -107,8 +107,8 @@ bfloat16_t test_vget_lane_bf16(bfloat16x4_t v) {
 
 // CHECK-LABEL: @test_vgetq_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <8 x bfloat> [[V:%.*]], 
i32 7
-// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+// CHECK-NEXT:[[VGETQ_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], 
i32 7
+// CHECK-NEXT:ret bfloat [[VGETQ_LANE]]
 //
 bfloat16_t test_vgetq_lane_bf16(bfloat16x8_t v) {
   return vgetq_lane_bf16(v, 7);
@@ -116,8 +116,8 @@ bfloat16_t test_vgetq_lane_bf16(bfloat16x8_t v) {
 
 // CHECK-LABEL: @test_vset_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x bfloat> [[V:%.*]], bfloat 
[[A:%.*]], i32 1
-// CHECK-NEXT:ret <4 x bfloat> [[TMP0]]
+// CHECK-NEXT:[[VSET_LANE:%.*]] = insertelement <4 x bfloat> [[V:%.*]], 
bfloat [[A:%.*]], i32 1
+// CHECK-NEXT:ret 

[PATCH] D103393: [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

2021-05-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Context: https://github.com/clangd/clangd/pull/783


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103393

Files:
  clang-tools-extra/clangd/index/remote/README.md


Index: clang-tools-extra/clangd/index/remote/README.md
===
--- clang-tools-extra/clangd/index/remote/README.md
+++ clang-tools-extra/clangd/index/remote/README.md
@@ -35,7 +35,7 @@
 
 ```bash
 # Get source code.
-$ git clone -b v1.33.2 https://github.com/grpc/grpc
+$ git clone -b v1.36.3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init
 # Choose directory where you want gRPC installation to live.


Index: clang-tools-extra/clangd/index/remote/README.md
===
--- clang-tools-extra/clangd/index/remote/README.md
+++ clang-tools-extra/clangd/index/remote/README.md
@@ -35,7 +35,7 @@
 
 ```bash
 # Get source code.
-$ git clone -b v1.33.2 https://github.com/grpc/grpc
+$ git clone -b v1.36.3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init
 # Choose directory where you want gRPC installation to live.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103393: [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

2021-05-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

I don't really know if we should do this before the buildbot update so I just 
wanted to know your opinion @kadircet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103393

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


[PATCH] D103395: PR45879: Keep evaluated expression in LValue object

2021-05-31 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added a reviewer: rsmith.
sepavloff requested review of this revision.
Herald added a project: clang.

Class LValue keeps result of lvalue evaluation. In some analyses it is
also necessary to have access to the original expression. This change
adds new member to LValue to keep the expression and initializes this
member when an lvalue is evaluated using LValueExprEvaluator.

With this change LHS expression becomes available in
HandleUnionActiveMemberChange and it becomes possible to fix PR45879.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103395

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1447,3 +1447,11 @@
   constexpr bool b = [a = S(), b = S()] { return a.p == b.p; }();
   static_assert(!b);
 }
+
+namespace PR45879 {
+struct Base {
+  int m;
+};
+struct Derived : Base {};
+constexpr int k = ((Base{} = Derived{}), 0);
+} // namespace PR45879
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1534,6 +1534,7 @@
 APValue::LValueBase Base;
 CharUnits Offset;
 SubobjectDesignator Designator;
+const Expr *LExpr = nullptr;
 bool IsNullPtr : 1;
 bool InvalidBase : 1;
 
@@ -1542,6 +1543,7 @@
 const CharUnits &getLValueOffset() const { return Offset; }
 SubobjectDesignator &getLValueDesignator() { return Designator; }
 const SubobjectDesignator &getLValueDesignator() const { return 
Designator;}
+const Expr *getExpr() const { return LExpr; }
 bool isNullPointer() const { return IsNullPtr;}
 
 unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
@@ -1579,6 +1581,8 @@
   Offset = CharUnits::fromQuantity(0);
   InvalidBase = BInvalid;
   Designator = SubobjectDesignator(getType(B));
+  if (!LExpr)
+LExpr = B.dyn_cast();
   IsNullPtr = false;
 }
 
@@ -6077,8 +6081,11 @@
 if (!handleTrivialCopy(Info, MD->getParamDecl(0), Args[0], RHSValue,
MD->getParent()->isUnion()))
   return false;
+const Expr *LHS = This->getExpr();
+if (!LHS)
+  return false;
 if (Info.getLangOpts().CPlusPlus20 && MD->isTrivial() &&
-!HandleUnionActiveMemberChange(Info, Args[0], *This))
+!HandleUnionActiveMemberChange(Info, LHS, *This))
   return false;
 if (!handleAssignment(Info, Args[0], *This, MD->getThisType(),
   RHSValue))
@@ -8039,6 +8046,11 @@
   LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
 LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
+  bool evaluate(const Expr *E) {
+Result.LExpr = E;
+return Visit(E);
+  }
+
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
 
@@ -8100,7 +8112,7 @@
   assert(!E->isValueDependent());
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
  E->getType()->isVoidType() || isa(E));
-  return LValueExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
+  return LValueExprEvaluator(Info, Result, InvalidBaseOK).evaluate(E);
 }
 
 bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
@@ -8571,6 +8583,8 @@
   : ExprEvaluatorBaseTy(info), Result(Result),
 InvalidBaseOK(InvalidBaseOK) {}
 
+  bool evaluate(const Expr *E) { return Visit(E); }
+
   bool Success(const APValue &V, const Expr *E) {
 Result.setFrom(Info.Ctx, V);
 return true;
@@ -8680,7 +8694,7 @@
 bool InvalidBaseOK) {
   assert(!E->isValueDependent());
   assert(E->isRValue() && E->getType()->hasPointerRepresentation());
-  return PointerExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
+  return PointerExprEvaluator(Info, Result, InvalidBaseOK).evaluate(E);
 }
 
 bool PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1447,3 +1447,11 @@
   constexpr bool b = [a = S(), b = S()] { return a.p == b.p; }();
   static_assert(!b);
 }
+
+namespace PR45879 {
+struct Base {
+  int m;
+};
+struct Derived : Base {};
+constexpr int k = ((Base{} = Derived{}), 0);
+} // namespace PR45879
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1534,6 +1534,7 @@
 APValue::LValueBase Base;
 CharUnits Offset;
 SubobjectDesignator Design

[PATCH] D101429: PR45879: Use LValue object to evaluate active union members

2021-05-31 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff abandoned this revision.
sepavloff added a comment.

Alternative implementation in in https://reviews.llvm.org/D103395.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101429

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


[clang] 8006ac7 - fix test for symlinked clang c1ee4fb5af49a

2021-05-31 Thread Mikhail Goncharov via cfe-commits

Author: Mikhail Goncharov
Date: 2021-05-31T13:29:33+02:00
New Revision: 8006ac7fe449e272385b85db80d22c924ab61d3a

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

LOG: fix test for symlinked clang c1ee4fb5af49a

Added: 


Modified: 
clang/test/Driver/avr-toolchain.c

Removed: 




diff  --git a/clang/test/Driver/avr-toolchain.c 
b/clang/test/Driver/avr-toolchain.c
index b9ca1777a7d6..692063dc2c34 100644
--- a/clang/test/Driver/avr-toolchain.c
+++ b/clang/test/Driver/avr-toolchain.c
@@ -3,7 +3,7 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target avr 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr"
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | 
FileCheck -check-prefix CC1A %s
+// RUN: %clang %s -### -no-canonical-prefixes -target avr --sysroot 
%S/Inputs/basic_avr_tree 2>&1 | FileCheck -check-prefix CC1A %s
 // CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" 
{{".*avr/include"}}
 
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck -check-prefix CC1B %s



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


[PATCH] D103401: [OpenCL] Add support of __opencl_c_generic_address_space feature macro

2021-05-31 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: ldrumm, kerbowa, yaxunl, nhaehnle, jvesely.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103401

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/test/CodeGenOpenCL/address-spaces-conversions.cl
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl

Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 
 /* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to
 *  different address spaces, mainly described in Sections 6.5.5 and 6.5.6.
@@ -17,6 +20,8 @@
 *  case), and __constant, that should cover all program paths for CL address
 *  space conversions used in initialisations, assignments, casts, comparisons
 *  and arithmetic operations.
+*
+*  OpenCLC v3.0 supports generic address if __opencl_c_generic_address_space feature is supported
 */
 
 #ifdef GENERIC
Index: clang/test/CodeGenOpenCL/overload.cl
===
--- clang/test/CodeGenOpenCL/overload.cl
+++ clang/test/CodeGenOpenCL/overload.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s
+// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s
 
 typedef short short4 __attribute__((ext_vector_type(4)));
 
Index: clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
+++ clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
@@ -5,6 +5,18 @@
 // RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL2.0 %s -emit-llvm -o - | FileCheck %s
 
+// RUN: %clang_cc1 -triple r600 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn---opencl -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-ext=+__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn---opencl -cl-ext=+__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-ext=+__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple r600 -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn---opencl -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-ext=+cl_khr_fp64,+__opencl_c

[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2021-05-31 Thread Jeroen Van Antwerpen via Phabricator via cfe-commits
Jeroen added a comment.

In D14484#2788953 , @FStefanni wrote:

> Hi,
>
> in case of any doubt: yet it is of interest.
> 6 years old means only that it has not been "fixed" in the meanwhile...
>
> Please consider that there are not many code formatters for C++, since it is 
> quite a complex language (and a lot of different formatting conventions!).
> So we are just waiting to have integrated the formatting rules that we need.
>
> Regards.

Feel free to revive my patch, I'll be very happy to finally start using this.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D103377: [clangd] Add ability to change storage directory of index files

2021-05-31 Thread Christopher Rhodes via Phabricator via cfe-commits
crr0004 added a comment.

Strictly speaking you could, assuming you have a compile database and it's okay 
to have copies or symlinks of the database.

I would have probably done that if I had realised I could.

That does speak to another issue though; moving the compile database to move 
the index files is not very intuitive. We could improve the help text around 
compile commands to explain fully the implications of the file which might help.

I really just wanted direct control of where the index files go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103377

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


[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

Thank you very much. :)
Do you have commit access, or do you need someone to land it? If the latter 
please state name and email for the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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


[PATCH] D103286: [clang-format] Add PPIndentWidth option

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

Looks good to me, I would just change the wording a bit. Could you please also 
add a entry in the ReleaseNotes.rst?




Comment at: clang/include/clang/Format/Format.h:2663
+  /// The number of columns to use for indentation of preprocessor statements.
+  /// When set to -1 this defaults to IndentWidth for backwards compatibility.
+  /// \code

Not only backwards compatibility, but you can always choose to match those two.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

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


[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

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

Forgot about that: Please add an entry in the ReleaseNotes.rst, I can imagine 
there are some people out there waiting for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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


[PATCH] D103377: [clangd] Add ability to change storage directory of index files

2021-05-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> Strictly speaking you could, assuming you have a compile database and it's 
> okay to have copies or symlinks of the database.

Well you wouldn't have index shards without a compilation database anyway 
though.

> That does speak to another issue though; moving the compile database to move 
> the index files is not very intuitive. We could improve the help text around 
> compile commands to explain fully the implications of the file which might 
> help.

I am not sure if this is something that is interesting to the average user. 
Hence we've only documented in the designs 
 and the code:

  Before indexing each file, the index checks for a cached *.idx file on disk. 
After indexing, it writes this file. This avoids reindexing on startup if 
nothing changed since last time.
  These files are located in .cache/clangd/index/ next to 
compile_commands.json. For headers with no CDB, such as the standard library, 
they are in clangd/index under the
  user’s cache directory ($XDG_CACHE_HOME, DARWIN_USER_CACHE_DIR, or 
%LocalAppData%).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103377

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


[libunwind] 2fc05fd - [libunwind] fix -Wc++98-compat-extra-semi without _LIBUNWIND_HIDE_SYMBOLS

2021-05-31 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-05-31T08:54:53-04:00
New Revision: 2fc05fdc156fab5a7a7ef1d5b7d217ffa766d86f

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

LOG: [libunwind] fix -Wc++98-compat-extra-semi without _LIBUNWIND_HIDE_SYMBOLS

Added: 


Modified: 
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/config.h b/libunwind/src/config.h
index 5b860dc3632c5..2ab9d2f5e0c99 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -72,14 +72,14 @@
 
 #if defined(__APPLE__)
 #if defined(_LIBUNWIND_HIDE_SYMBOLS)
-#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name)
+#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name);
 #else
 #define _LIBUNWIND_ALIAS_VISIBILITY(name)
 #endif
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) 
\
   __asm__(".globl " SYMBOL_NAME(aliasname));   
\
   __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); 
\
-  _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname));
+  _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname))
 #elif defined(__ELF__)
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) 
\
   extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname
\



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


[PATCH] D103393: [clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

2021-05-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

I think we should wait for build bot update on this one too. Otherwise we might 
miss some breakages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103393

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-05-31 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@NoQ
This solution only intends to make correct calculations whenever cast occures. 
We can mark this as //alpha// or add an argument flag to turn cast reasoning 
on/off, or we can even disable any part of this patch with argument settings.

> But this still requires //massive// testing, a lot more than a typical 
> constraint solver patch; extraordinary claims require extraordinary evidence.

What kind of tests do you think we need?

> If it works out though, it might be the best thing to happen to the static 
> analyzer in years.

Thank you. I appreciate your possitive evaluation.

> With `SymbolCast`s in place our equations become much more complicated and 
> therefore the constraint solver becomes much more likely to produce false 
> positives in cases where it previously erred on the side of false negatives.
>
> Another thing to test is our ability to explain bug paths.

My proposition is to design and describe a paper of:

- what cases shall be considered as erroneous and be reported;
- what cases shall be ignored or considered as exceptions (i.e. static_cast);
- what wordings shall we use in reports;
- how paths of those reports shall look like;
- //your options;//

> But in practice there may be other reasons to use a larger integer type, such 
> as API requirements (eg., how `isascii()` accepts an `int` but only uses 266 
> values).

IMO this is great when we tell user that he/she should make sure of the value 
bounds before passing the arguments to such APIs.

> There's also the usual problem of overflow being impossible specifically on 
> the current path; in this case we have to make sure that an appropriate 
> `assert()` would actually suppress the warning (i.e., the constraint solver 
> would be able to correctly solve the assert condition as well).

For example, this test easily passes.

  void test(int x) {
assert(0 < x && x < 42);
char c = x;
clang_analyzer_eval(c <= 0); // expected-warning {{FALSE}}
clang_analyzer_eval(c >= 42); // expected-warning {{FALSE}}
  }

Or you meant some other cases?

> __
> *In this case it's interesting as a control flow dependency of the bug 
> location; it sounds like without @Szelethus's control flow dependency 
> tracking this advancement would have been virtually impossible.

Can this tracking mechanism be adjusted then?

In the end, should we go further with this patch and make more adjustments in 
CSA or reject it in view of your concerns?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103096

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


[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D101921#2786245 , @MaskRay wrote:

> Because of `new MCObjectFileInfo`, we cannot use a forward declaration 
> (incomplete class) to replace `#include "llvm/MC/MCObjectFileInfo.h"` in 
> `TargetRegistry.h`.
>
> I thought about moving `TargetRegistry.{h,cpp}` from Support to Target. 
> However, it doesn't work because Bitcode/Object call 
> `TargetRegistry::lookupTarget` and Bitcode/Object are lower than Target.
>
> @compnerd @dblaikie @mehdi_amini Do you have suggestions on fixing the 
> layering?

Looks like a big patch and a bit hard for me to page in all the context. Could 
you summarize the layering constraints/what headers/types/functions are in 
which libraries and why they are there/what constrains them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101921

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


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

2021-05-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri resigned from this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Removing from queue - i don't expect to review this.
Looks like this has been reverted twice now, presumably llvm stage 2/linux 
kernel/chrome
should be enough of a coverage to be sure there isn't any obvious 
false-positives this time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[clang] c36ff64 - Revert "[clang] Add support for the "abstract" contextual keyword of MSVC"

2021-05-31 Thread Mikhail Goncharov via cfe-commits

Author: Mikhail Goncharov
Date: 2021-05-31T15:34:20+02:00
New Revision: c36ff6424f249d3e2005fb0589337452cd7ddad3

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

LOG: Revert "[clang] Add support for the "abstract" contextual keyword of MSVC"

This reverts commit 818338add77411f5e9713247ea66142f332ef350.

Tests fail under sanitizer: 
https://lab.llvm.org/buildbot/#/builders/5/builds/8150

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index c9efc4b454968..07c4eb261aac1 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1786,7 +1786,6 @@ class CXXRecordDecl : public RecordDecl {
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;
   }
-  void markAbstract() { data().Abstract = true; }
 };
 
 /// Store information needed for an explicit specifier.

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 8544607673c3e..f6a4fbb1e04c8 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1086,7 +1086,6 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">;
 def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">;
 def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">;
 def MicrosoftSealed : DiagGroup<"microsoft-sealed">;
-def MicrosoftAbstract : DiagGroup<"microsoft-abstract">;
 def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">;
 def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">;
 def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">;
@@ -1124,7 +1123,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // Warnings group for warnings about Microsoft extensions.
 def Microsoft : DiagGroup<"microsoft",
 [MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude,
- MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract,
+ MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed,
  MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl,
  MicrosoftMutableReference, MicrosoftPureDefinition,
  MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall,

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index b13c382c16ebc..97cb7020f3452 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -922,16 +922,10 @@ def err_override_control_interface : Error<
 def ext_ms_sealed_keyword : ExtWarn<
   "'sealed' keyword is a Microsoft extension">,
   InGroup;
-def ext_ms_abstract_keyword : ExtWarn<
-  "'abstract' keyword is a Microsoft extension">,
-  InGroup;
 
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
-def err_duplicate_class_virt_specifier : Error<
-  "class already marked '%0'">;
-
 def err_duplicate_virt_specifier : Error<
   "class member already marked '%0'">;
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index c32ae6d2cf406..e3e6509b025e5 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -114,7 +114,6 @@ class Parser : public CodeCompletionHandler {
   /// Contextual keywords for Microsoft extensions.
   IdentifierInfo *Ident__except;
   mutable IdentifierInfo *Ident_sealed;
-  mutable IdentifierInfo *Ident_abstract;
 
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
@@ -2914,7 +2913,6 @@ class Parser : public CodeCompletionHandler {
   SourceLocation FriendLoc);
 
   bool isCXX11FinalKeyword() const;
-  bool isClassCompatibleKeyword() const;
 
   /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
   /// enter a new C++ declarator scope and exit it when the function is

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 423f4f4ee7b7c..3b16295941e48 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -2620,8 +2620,7 @@ class VirtSpecifiers {
 VS_Final = 2,
 VS_Sealed = 4,
 // Represents the __final keyword, which is

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Mikhail Goncharov via Phabricator via cfe-commits
goncharov added a comment.

Sorry, had to revert it as this fails under sanitizer : 
https://lab.llvm.org/buildbot/#/builders/5/builds/8150


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

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


[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap updated this revision to Diff 348791.
gergap added a comment.

update release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14881,6 +14881,7 @@
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
   Alignment.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
+  Alignment.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("float const a = 5;\n"
"int oneTwoThree = 123;",
Alignment);
@@ -14916,8 +14917,8 @@
   verifyFormat("int  oneTwoThree{0}; // comment\n"
"unsigned oneTwo; // comment",
Alignment);
-  verifyFormat("unsigned int *  a;\n"
-   "int *   b;\n"
+  verifyFormat("unsigned int   *a;\n"
+   "int*b;\n"
"unsigned int Const *c;\n"
"unsigned int const *d;\n"
"unsigned int Const &e;\n"
@@ -15039,9 +15040,11 @@
"  doublebar();\n"
"};\n",
Alignment);
+
+  // PAS_Right
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
 "  int const i   = 1;\n"
-"  int * j   = 2;\n"
+"  int  *j   = 2;\n"
 "  int   big = 1;\n"
 "\n"
 "  unsigned oneTwoThree = 123;\n"
@@ -15062,6 +15065,140 @@
"int ll=1;\n"
"}",
Alignment));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int **j   = 2, ***k;\n"
+"  int  &k   = i;\n"
+"  int &&l   = i + j;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int **j=2,***k;\n"
+   "int &k=i;\n"
+   "int &&l=i+j;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   Alignment));
+
+  // PAS_Left
+  FormatStyle AlignmentLeft = Alignment;
+  AlignmentLeft.PointerAlignment = FormatStyle::PAS_Left;
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int*  j   = 2;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int *j=2;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   AlignmentLeft));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int** j   = 2;\n"
+"  int&  k   = i;\n"
+"  int&& l   = i + j;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int **j=2;\n"
+   "int &k=i;\n"
+   "int &&l=i+j;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   AlignmentLeft));
+  // PAS_Middle
+  Forma

[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap added a comment.

In D103245#2789423 , 
@HazardyKnusperkeks wrote:

> Thank you very much. :)
> Do you have commit access, or do you need someone to land it? If the latter 
> please state name and email for the commit.

I started working on this just a few days ago, so I guess not ;-)
Would you please land this for me?

author: "Gerhard Gappmeier "


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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


[PATCH] D103286: [clang-format] Add PPIndentWidth option

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap updated this revision to Diff 348794.
gergap added a comment.

changed wording as requested and updated release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3431,6 +3431,48 @@
   verifyFormat("a\f\\");
 }
 
+TEST_F(FormatTest, IndentsPPDirectiveWithPPIndentWidth) {
+  FormatStyle style = getChromiumStyle(FormatStyle::LK_Cpp);
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef __linux__\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n"
+   "#define FOO\n"
+   "#endif\n"
+   "void bar() {\n"
+   "int y = 0;\n"
+   "}\n",
+   style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef __linux__\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n"
+   "# define FOO foo\n"
+   "#endif\n"
+   "void bar() {\n"
+   "int y = 0;\n"
+   "}\n",
+   style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_BeforeHash;
+  verifyFormat("#ifdef __linux__\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n"
+   " #define FOO foo\n"
+   "#endif\n"
+   "void bar() {\n"
+   "int y = 0;\n"
+   "}\n",
+   style);
+}
+
 TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {
   verifyFormat("#define A(BB)", getLLVMStyleWithColumns(13));
   verifyFormat("#define A( \\\nBB)", getLLVMStyleWithColumns(12));
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -57,7 +57,9 @@
 while (IndentForLevel.size() <= Line.Level)
   IndentForLevel.push_back(-1);
 if (Line.InPPDirective) {
-  Indent = Line.Level * Style.IndentWidth + AdditionalIndent;
+  unsigned IndentWidth =
+  (Style.PPIndentWidth >= 0) ? Style.PPIndentWidth : Style.IndentWidth;
+  Indent = Line.Level * IndentWidth + AdditionalIndent;
 } else {
   IndentForLevel.resize(Line.Level + 1);
   Indent = getIndent(IndentForLevel, Line.Level);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -664,6 +664,7 @@
 IO.mapOptional("PenaltyIndentedWhitespace",
Style.PenaltyIndentedWhitespace);
 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
+IO.mapOptional("PPIndentWidth", Style.PPIndentWidth);
 IO.mapOptional("RawStringFormats", Style.RawStringFormats);
 IO.mapOptional("ReflowComments", Style.ReflowComments);
 IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
@@ -1021,6 +1022,7 @@
   LLVMStyle.IndentRequires = false;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
+  LLVMStyle.PPIndentWidth = -1;
   LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2659,6 +2659,20 @@
   /// Pointer and reference alignment style.
   PointerAlignmentStyle PointerAlignment;
 
+  /// The number of columns to use for indentation of preprocessor statements.
+  /// When set to -1 (default) ``IndentWidth`` is used also for preprocessor
+  /// statements.
+  /// \code
+  ///PPIndentWidth: 1
+  ///
+  ///#ifdef __linux__
+  ///# define FOO
+  ///#else
+  ///# define BAR
+  ///#endif
+  /// \endcode
+  signed PPIndentWidth;
+
   /// See documentation of ``RawStringFormats``.
   struct RawStringFormat {
 /// The language of this raw string.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -228,6 +228,9 @@
 - Option ``IndentAccessModifiers`` has been added to be able to give access
   modifiers their own indentation level inside records.
 
+- Option ``PPIn

[PATCH] D103286: [clang-format] Add PPIndentWidth option

2021-05-31 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap added a comment.

@HazardyKnusperkeks could you please land this for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

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


[PATCH] D103131: support debug info for alias variable

2021-05-31 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

> Mixed feelings - somewhat in favor of "do the thing that's probably already 
> fairly tested/known to work" (GCC's thing). But open to the idea that that 
> approach has problems, for sure.

"Known to work" for whom?  gdb, sure, because gcc/gdb cooperate on many things. 
 I'll have to check with my debugger guys whether this would work for us; and 
I'll just reiterate that it's certainly not what the DWARF spec suggests should 
be done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D102723: [HIP] Tighten checks in hip-include-path.hip test case

2021-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

It seems we cannot introduce `ROOT` by line 19 since it is not used in other 
lines in situations where working directories have sym links.

Instead, we just change `{{.*}}clang/` to `{{.*}}/lib/clang/` in other lines. 
Hopefully this will still work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102723

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


[PATCH] D103080: [CMake] Ignore arm_*.h for non-ARM build

2021-05-31 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls added a comment.

I'm wondering what the rationale for this change is.
If there is a good rationale for this; wouldn't it need to be applied to all 
target-specific header files, not only the Arm-specific header files?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103080

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


[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 348806.
AbbasSabra added a comment.

Updating D102517 : [clang]Fix 
use-of-uninitialized-value detected by the sanitizer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp

Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -462,6 +462,77 @@
 virtual ~SealedDestructor() sealed; // expected-warning {{class with destructor marked 'sealed' cannot be inherited from}}
 };
 
+// expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+class AbstractClass abstract {
+  int i;
+};
+
+// expected-error@+1 {{variable type 'AbstractClass' is an abstract class}}
+AbstractClass abstractInstance;
+
+// expected-warning@+4 {{abstract class is marked 'sealed'}}
+// expected-note@+3 {{'AbstractAndSealedClass' declared here}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
+class AbstractAndSealedClass abstract sealed {}; // Does no really make sense, but allowed
+
+// expected-error@+1 {{variable type 'AbstractAndSealedClass' is an abstract class}}
+AbstractAndSealedClass abstractAndSealedInstance;
+// expected-error@+1 {{base 'AbstractAndSealedClass' is marked 'sealed'}}
+class InheritFromAbstractAndSealed : AbstractAndSealedClass {};
+
+#if __cplusplus <= 199711L
+// expected-warning@+4 {{'final' keyword is a C++11 extension}}
+// expected-warning@+3 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-error@+1 {{class already marked 'final'}}
+class TooManyVirtSpecifiers1 final final {};
+#if __cplusplus <= 199711L
+// expected-warning@+4 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+2 {{'sealed' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'sealed'}}
+class TooManyVirtSpecifiers2 final sealed {};
+#if __cplusplus <= 199711L
+// expected-warning@+6 {{'final' keyword is a C++11 extension}}
+// expected-warning@+5 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+3 {{abstract class is marked 'final'}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'final'}}
+class TooManyVirtSpecifiers3 final abstract final {};
+#if __cplusplus <= 199711L
+// expected-warning@+6 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+4 {{abstract class is marked 'final'}}
+// expected-warning@+3 {{'abstract' keyword is a Microsoft extension}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'abstract'}}
+class TooManyVirtSpecifiers4 abstract final abstract {};
+
+class Base {
+  virtual void i();
+};
+class AbstractFunctionInClass : public Base {
+  // expected-note@+2 {{unimplemented pure virtual method 'f' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void f() abstract;
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  void g() abstract; // expected-error {{'g' is not virtual and cannot be declared pure}}
+  // expected-note@+2 {{unimplemented pure virtual method 'h' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void h() abstract = 0; // expected-error {{class member already marked 'abstract'}}
+#if __cplusplus <= 199711L
+  // expected-warning@+4 {{'override' keyword is a C++11 extension}}
+#endif
+  // expected-note@+2 {{unimplemented pure virtual method 'i' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void i() abstract override;
+};
+
+// expected-error@+1 {{variable type 'AbstractFunctionInClass' is an abstract class}}
+AbstractFunctionInClass abstractFunctionInClassInstance;
+
 void AfterClassBody() {
   // expected-warning@+1 {{attribute 'deprecated' is ignored, place it after "struct" to apply attribute to type declaration}}
   struct D {} __declspec(deprecated);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16436,6 +16436,7 @@
 void Sema::ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagD

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra added a comment.

In D102517#2789450 , @goncharov wrote:

> Sorry, had to revert it as this fails under sanitizer : 
> https://lab.llvm.org/buildbot/#/builders/5/builds/8150

Thanks!

I missed adding "Ident_abstract" in the Parser initialize function. Should be 
fixed now.  CC: @hans


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-31 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1561
+  return nullptr;
+
+ConstraintMap CM = getConstraintMap(State);

vsavchenko wrote:
> Also I think we can introduce a simple, but efficient optimization of kicking 
> off the simplification process only when `Constraint` is a constant.
Yes, good point.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1562-1578
+ConstraintMap CM = getConstraintMap(State);
+for (auto const &C : CM) {
+  const SymbolRef &ParentSym = C.first;
+  SValBuilder &SVB = getSValBuilder();
+
+  SVal SimplifiedParentVal =
+  SVB.simplifySVal(State, SVB.makeSymbolVal(ParentSym));

vsavchenko wrote:
> I tried to cover it in the comment to another patch.  This solution includes 
> a lot of extra work and it will lose equality/disequality information for 
> simplified expressions, and I think it's safe to say that if `a == b` then 
> `simplify(a) == b`.
> 
> Let's start with `getConstraintMap`.  It is a completely artificial data 
> structure (and function) that exists for Z3 refutation.  It's not what we 
> keep in the state and it has a lot of duplicated constraints.  If we have an 
> equivalence class `{a, b, c, d, e, f}`, we store only one constraint for all 
> of them (thus when we update the class, or one of the members receives a new 
> constraint, we can update all of them).  `getConstraintMap` returns a map 
> where `a`, `b`, `c`, `d`, `e`, and `f` are mapped to the same constraint.  
> It's not **super** bad, but it's extra work constructing this map and then 
> processing it.
> 
> Another, and more important aspect is that when you `setConstraint`, you lose 
> information that this symbol is equal/disequal to other symbols.  One example 
> here would be a situation where `x + y == z`, and we find out that `y == 0`, 
> we should update equivalence class `{x + y, z}` to be a class `{x, z}`.  In 
> order to do this, you need to update two maps: `ClassMap` (it's mapping `x + 
> y` to `{x + y, z}`) and `ClassMembers` (it's mapping `{x + y, z}` to `x + y` 
> and `z`).
> 
> Similar example can be made with `x + y != z`, but updating `ClassMap` and 
> `ClassMembers` will fix it.  And you don't even need to touch the actual 
> mapping with the actual constraints.
Absolutely, great findings!

I think the most straightforward and consistent implementation of updating 
`ClassMap` and `ClassMembers` is to directly use the `merge` method. I.e. we 
can merge the simplified symbol (as a trivial eq class) to the existing 
equivalence class. Using `merge`, however, would not remove the non-simplified 
original symbol. But this might not be a problem; rather it is a necessity (as 
the child patch demonstrates) it might be very useful if we can find the symbol 
(without simplification, i.e. as written) in the `ConstraintRange` map. Do you 
see any drawbacks of reusing `merge` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-31 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 348808.
martong marked an inline comment as done.
martong added a comment.

- Merge the simplified symbol to the old class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/find-binop-constraints.cpp

Index: clang/test/Analysis/find-binop-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/find-binop-constraints.cpp
@@ -0,0 +1,115 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_eval(bool);
+
+int test_legacy_behavior(int x, int y) {
+  if (y != 0)
+return 0;
+  if (x + y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return y / (x + y);  // expected-warning{{Division by zero}}
+}
+
+int test_rhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (x != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_and_rhs_further_constrained(int x, int y) {
+  if (x % y != 1)
+return 0;
+  if (x != 1)
+return 0;
+  if (y != 2)
+return 0;
+  clang_analyzer_eval(x % y == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 2); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_commutativity(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(y + x == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_binop_when_height_is_2_r(int a, int x, int y, int z) {
+  switch (a) {
+  case 1: {
+if (x + y + z != 0)
+  return 0;
+if (z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 2: {
+if (x + y + z != 0)
+  return 0;
+if (y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 3: {
+if (x + y + z != 0)
+  return 0;
+if (x != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 4: {
+if (x + y + z != 0)
+  return 0;
+if (x + y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 5: {
+if (z != 0)
+  return 0;
+if (x + y + z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+if (y != 0)
+  return 0;
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+break;
+  }
+
+  }
+  return 0;
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1552,7 +1552,34 @@
 
   LLVM_NODISCARD inline ProgramStateRef
   setConstraint(ProgramStateRef State, SymbolRef Sym, RangeSet Constraint) {
-return setConstraint(State, EquivalenceClass::find(State, Sym), Constraint);
+assert(State);
+
+State = setConstraint(State, EquivalenceClass::find(State, Sym), Constraint);
+if (!State)
+  return nullptr;
+
+if (!Constraint.getConcreteValue())
+  return State;
+
+// Simplify existing constraints.
+SValBuilder &SVB = getSValBuilder();
+ConstraintRangeTy Constraints = State->get();
+for (std::pair ClassConstraint : Constraints) {
+  EquivalenceClass Class = ClassConstraint.first;
+  SymbolSet ClassMembers = Class.getClassMembers(State);
+  for (const SymbolRef &MemberSym : ClassMembers) {
+SVal SimplifiedMemberVal =
+SVB.simplifySVal(State, SVB.makeSymbolVal(MemberSym));
+Symbol

[PATCH] D90188: Add support for attribute 'using_if_exists'

2021-05-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 348810.
ldionne added a comment.
Herald added a project: clang.

Rebase onto `main`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90188

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Parser/using-if-exists-attr.cpp
  clang/test/SemaCXX/attr-deprecated.cpp
  clang/test/SemaCXX/using-if-exists.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6466,6 +6466,7 @@
   case Decl::Concept:
   case Decl::LifetimeExtendedTemporary:
   case Decl::RequiresExprBody:
+  case Decl::UnresolvedUsingIfExists:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/test/SemaCXX/using-if-exists.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-if-exists.cpp
@@ -0,0 +1,218 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -verify
+
+#define UIE __attribute__((using_if_exists))
+
+namespace test_basic {
+namespace NS {}
+
+using NS::x UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}}
+x usex(); // expected-error{{reference to unresolved using declaration}}
+
+using NotNS::x UIE; // expected-error{{use of undeclared identifier 'NotNS'}}
+
+using NS::NotNS::x UIE; // expected-error{{no member named 'NotNS' in namespace 'test_basic::NS'}}
+} // test_basic
+
+namespace test_redecl {
+namespace NS {}
+
+using NS::x UIE;
+using NS::x UIE;
+
+namespace NS1 {}
+namespace NS2 {}
+namespace NS3 {
+int A(); // expected-note{{target of using declaration}}
+struct B {}; // expected-note{{target of using declaration}}
+int C(); // expected-note{{conflicting declaration}}
+struct D {}; // expected-note{{conflicting declaration}}
+}
+
+using NS1::A UIE;
+using NS2::A UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}} expected-note{{conflicting declaration}}
+using NS3::A UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}}
+int i = A(); // expected-error{{reference to unresolved using declaration}}
+
+using NS1::B UIE;
+using NS2::B UIE; // expected-note{{conflicting declaration}} expected-note{{using declaration annotated with 'using_if_exists' here}}
+using NS3::B UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}}
+B myB; // expected-error{{reference to unresolved using declaration}}
+
+using NS3::C UIE;
+using NS2::C UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}} expected-note{{target of using declaration}}
+int j = C();
+
+using NS3::D UIE;
+using NS2::D UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}} expected-note{{target of using declaration}}
+D myD;
+} // test_redecl
+
+namespace test_dependent {
+template 
+struct S : B {
+  using B::mf UIE; // expected-note 3 {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}}
+};
+
+struct BaseEmpty {
+};
+struct BaseNonEmpty {
+  void mf();
+  typedef int mt;
+};
+
+template 
+struct UseCtor : Base {
+  using Base::Base UIE; // expected-error{{'using_if_exists' attribute cannot be applied to an inheriting constructor}}
+};
+struct BaseCtor {};
+
+void f() {
+  S empty;
+  S nonempty;
+  empty.mf(); // expected-error {{reference to unresolved using declaration}}
+  nonempty.mf();
+  (&empty)->mf(); // expected-error {{reference to unresolved using declaration}}
+  (&nonempty)->mf();
+
+  S::mt y; // expected-error {{reference to unresolved using declaration}}
+  S::mt z;
+
+  S::mf(); // expected-error {{reference to unresolved using declaration}}
+
+  UseCtor usector;
+}
+
+template 
+struct Implicit : B {
+  using B::mf UIE; // expected-note {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note 2 {{using declaration annotated with 'using_if_exists' here}}
+
+  void use() {

[PATCH] D102723: [HIP] Tighten checks in hip-include-path.hip test case

2021-05-31 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In D102723#2789537 , @yaxunl wrote:

> It seems we cannot introduce `ROOT` by line 19 since it is not used in other 
> lines in situations where working directories have sym links.
>
> Instead, we just change `{{.*}}clang/` to `{{.*}}/lib/clang/` in other lines. 
> Hopefully this will still work.

Ok. That probably works.

A bit surprised though. I found checks using InstalledDir in other test cases 
such as clang/test/Friver/stdlibxx-isystem.cpp, so I figured it would be safe 
to use that also in this test case. So I wonder how other tests that captures 
InstalledDir could work for the symlink-bots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102723

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

That's awesome, just a few stylistic tweaks and tests and we are to land!




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1561-1562
+
+if (!Constraint.getConcreteValue())
+  return State;
+

I think we need a comment why we care about this early exit.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1564
+
+// Simplify existing constraints.
+SValBuilder &SVB = getSValBuilder();

Here I also think that we need to give more context to the readers, so they 
understand what simplification you are talking about here.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1566-1569
+ConstraintRangeTy Constraints = State->get();
+for (std::pair ClassConstraint : Constraints) {
+  EquivalenceClass Class = ClassConstraint.first;
+  SymbolSet ClassMembers = Class.getClassMembers(State);

You don't actually use constraints here, so (let me write it in python) instead 
of:
```
[update(classMap[class]) for class, constraint in constraints.items()]
```
you can use
```
[update(members) for class, members in classMap.items()]
```



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1575
+if (SimplifiedMemberSym && MemberSym != SimplifiedMemberSym) {
+  // Add the newly simplified symbol to the equivalence class.
+  State =

It would be great if we provide some justification why we do merge here.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1562-1578
+ConstraintMap CM = getConstraintMap(State);
+for (auto const &C : CM) {
+  const SymbolRef &ParentSym = C.first;
+  SValBuilder &SVB = getSValBuilder();
+
+  SVal SimplifiedParentVal =
+  SVB.simplifySVal(State, SVB.makeSymbolVal(ParentSym));

martong wrote:
> vsavchenko wrote:
> > I tried to cover it in the comment to another patch.  This solution 
> > includes a lot of extra work and it will lose equality/disequality 
> > information for simplified expressions, and I think it's safe to say that 
> > if `a == b` then `simplify(a) == b`.
> > 
> > Let's start with `getConstraintMap`.  It is a completely artificial data 
> > structure (and function) that exists for Z3 refutation.  It's not what we 
> > keep in the state and it has a lot of duplicated constraints.  If we have 
> > an equivalence class `{a, b, c, d, e, f}`, we store only one constraint for 
> > all of them (thus when we update the class, or one of the members receives 
> > a new constraint, we can update all of them).  `getConstraintMap` returns a 
> > map where `a`, `b`, `c`, `d`, `e`, and `f` are mapped to the same 
> > constraint.  It's not **super** bad, but it's extra work constructing this 
> > map and then processing it.
> > 
> > Another, and more important aspect is that when you `setConstraint`, you 
> > lose information that this symbol is equal/disequal to other symbols.  One 
> > example here would be a situation where `x + y == z`, and we find out that 
> > `y == 0`, we should update equivalence class `{x + y, z}` to be a class 
> > `{x, z}`.  In order to do this, you need to update two maps: `ClassMap` 
> > (it's mapping `x + y` to `{x + y, z}`) and `ClassMembers` (it's mapping `{x 
> > + y, z}` to `x + y` and `z`).
> > 
> > Similar example can be made with `x + y != z`, but updating `ClassMap` and 
> > `ClassMembers` will fix it.  And you don't even need to touch the actual 
> > mapping with the actual constraints.
> Absolutely, great findings!
> 
> I think the most straightforward and consistent implementation of updating 
> `ClassMap` and `ClassMembers` is to directly use the `merge` method. I.e. we 
> can merge the simplified symbol (as a trivial eq class) to the existing 
> equivalence class. Using `merge`, however, would not remove the 
> non-simplified original symbol. But this might not be a problem; rather it is 
> a necessity (as the child patch demonstrates) it might be very useful if we 
> can find the symbol (without simplification, i.e. as written) in the 
> `ConstraintRange` map. Do you see any drawbacks of reusing `merge` here?
Oh, that's actually even better!

If we consider the following example.
Let `a + b == c` and `a == d` be known and `b == 0` to be a new constraint. 
Then your approach will help us to figure out that `c == d`.

So, you found a great way!

I think that we should still add the test cases I briefly described in my 
previous comment and that one from above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1576-1577
+  // Add the newly simplified symbol to the equivalence class.
+  State =
+  Class.merge(this->getBasicVals(), F, State,
+  EquivalenceClass::find(State, SimplifiedMemberSym));

Uh-oh, almost let yet another null-state bug to happen!  During this iteration, 
`State` can become null, so we need to check for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

I had another thought, `merge` is usually called in situations when we found 
out that two symbols should be marked equal (and checked that it's possible to 
begin with), which is not true in your case.

If we update my case from before, we can get: `a + b == c` and `a != c` as 
given, and `b == 0` as a new constraint. In this situation, you will merge 
classes `{a + b, c}` and `{a}`, which contradicts our existing equality 
information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-05-31 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb accepted this revision.
cjdb added a comment.
This revision is now accepted and ready to land.

LGTM, but I'm neither a Clang nor core expert (and I'm not a maintainer), so 
please wait for others' approval.




Comment at: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp:8
+
+static_assert(True);
+

Nit: please move this under line 3.



Comment at: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp:21
+
+Nothing<[]() { return 0; }()> nothing;
+

Nit: please move this under line 3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103380

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


[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-05-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 348828.
cor3ntin added a comment.

Cleanup tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103380

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
  clang/test/SemaCXX/anonymous-struct.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4";>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this 
typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given 
name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not 
C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage 
purposes by this typedef declaration}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+template  struct Nothing {};
+Nothing<[]() { return 0; }()> nothing;
+
+template 
+concept True = [] { return true; }();
+static_assert(True);
+
+static_assert(sizeof([] { return 0; }));
+static_assert(sizeof([] { return 0; }()));
+
+void f()  noexcept(noexcept([] { return 0; }()));
+
+using a = decltype([] { return 0; });
+using b = decltype([] { return 0; }());
+using c = decltype([]() noexcept(noexcept([] { return 0; }())) { return 0; });
+using d = decltype(sizeof([] { return 0; }));
+
+
+
+template 
+auto g(T) -> decltype([]() { T::invalid; } ());
+auto e = g(0); // expected-error{{no matching function for call}}
+// expected-note@-2 {{substitution failure}}
\ No newline at end of file
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16657,8 +16657,10 @@
 
   if (!Rec.Lambdas.empty()) {
 using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
-if (Rec.ExprContext == ExpressionKind::EK_TemplateArgument || 
Rec.isUnevaluated() ||
-(Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17)) {
+if (!getLangOpts().CPlusPlus20 &&
+(Rec.ExprContext == ExpressionKind::EK_TemplateArgument ||
+ Rec.isUnevaluated() ||
+ (Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17))) {
   unsigned D;
   if (Rec.isUnevaluated()) {
 // C++11 [expr.prim.lambda]p2:
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -41,9 +41,12 @@
   LHS = BO->getLHS();
   RHS = BO->getRHS();
 } else if (auto *OO = dyn_cast(E)) {
-  Op = OO->getOperator();
-  LHS = OO->getArg(0);
-  RHS = OO->getArg(1);
+  // If OO is not || or && it might not have exactly 2 arguments
+  if (OO->getNumArgs() == 2) {
+Op = OO->getOperator();
+LHS = OO->getArg(0);
+RHS = OO->getArg(1);
+  }
 }
   }
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4";>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not C-compatible d

[clang] 116179c - Re-commit [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via cfe-commits

Author: Abbas Sabra
Date: 2021-05-31T18:45:26+02:00
New Revision: 116179c2ee5213f2ae8f07a400ac98f0c995b3d3

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

LOG: Re-commit [clang] Add support for the "abstract" contextual keyword of MSVC

https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

This re-commits 818338add77411f5e9713247ea66142f332ef350 with added
initialization of Parser::Ident_abstract.

Differential revision: https://reviews.llvm.org/D102517

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 07c4eb261aac..c9efc4b45496 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1786,6 +1786,7 @@ class CXXRecordDecl : public RecordDecl {
   static bool classofKind(Kind K) {
 return K >= firstCXXRecord && K <= lastCXXRecord;
   }
+  void markAbstract() { data().Abstract = true; }
 };
 
 /// Store information needed for an explicit specifier.

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index f6a4fbb1e04c..8544607673c3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1086,6 +1086,7 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">;
 def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">;
 def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">;
 def MicrosoftSealed : DiagGroup<"microsoft-sealed">;
+def MicrosoftAbstract : DiagGroup<"microsoft-abstract">;
 def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">;
 def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">;
 def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">;
@@ -1123,7 +1124,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
 // Warnings group for warnings about Microsoft extensions.
 def Microsoft : DiagGroup<"microsoft",
 [MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude,
- MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed,
+ MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract,
  MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl,
  MicrosoftMutableReference, MicrosoftPureDefinition,
  MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall,

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 97cb7020f345..b13c382c16eb 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -922,10 +922,16 @@ def err_override_control_interface : Error<
 def ext_ms_sealed_keyword : ExtWarn<
   "'sealed' keyword is a Microsoft extension">,
   InGroup;
+def ext_ms_abstract_keyword : ExtWarn<
+  "'abstract' keyword is a Microsoft extension">,
+  InGroup;
 
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
+def err_duplicate_class_virt_specifier : Error<
+  "class already marked '%0'">;
+
 def err_duplicate_virt_specifier : Error<
   "class member already marked '%0'">;
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e3e6509b025e..c32ae6d2cf40 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -114,6 +114,7 @@ class Parser : public CodeCompletionHandler {
   /// Contextual keywords for Microsoft extensions.
   IdentifierInfo *Ident__except;
   mutable IdentifierInfo *Ident_sealed;
+  mutable IdentifierInfo *Ident_abstract;
 
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
@@ -2913,6 +2914,7 @@ class Parser : public CodeCompletionHandler {
   SourceLocation FriendLoc);
 
   bool isCXX11FinalKeyword() const;
+  bool isClassCompatibleKeyword() const;
 
   /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
   /// enter a new C++ declarator scope and exit it when the function is

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 3b16295941

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG116179c2ee52: Re-commit [clang] Add support for the 
"abstract" contextual keyword of MSVC (authored by AbbasSabra, 
committed by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp

Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -462,6 +462,77 @@
 virtual ~SealedDestructor() sealed; // expected-warning {{class with destructor marked 'sealed' cannot be inherited from}}
 };
 
+// expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+class AbstractClass abstract {
+  int i;
+};
+
+// expected-error@+1 {{variable type 'AbstractClass' is an abstract class}}
+AbstractClass abstractInstance;
+
+// expected-warning@+4 {{abstract class is marked 'sealed'}}
+// expected-note@+3 {{'AbstractAndSealedClass' declared here}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
+class AbstractAndSealedClass abstract sealed {}; // Does no really make sense, but allowed
+
+// expected-error@+1 {{variable type 'AbstractAndSealedClass' is an abstract class}}
+AbstractAndSealedClass abstractAndSealedInstance;
+// expected-error@+1 {{base 'AbstractAndSealedClass' is marked 'sealed'}}
+class InheritFromAbstractAndSealed : AbstractAndSealedClass {};
+
+#if __cplusplus <= 199711L
+// expected-warning@+4 {{'final' keyword is a C++11 extension}}
+// expected-warning@+3 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-error@+1 {{class already marked 'final'}}
+class TooManyVirtSpecifiers1 final final {};
+#if __cplusplus <= 199711L
+// expected-warning@+4 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+2 {{'sealed' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'sealed'}}
+class TooManyVirtSpecifiers2 final sealed {};
+#if __cplusplus <= 199711L
+// expected-warning@+6 {{'final' keyword is a C++11 extension}}
+// expected-warning@+5 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+3 {{abstract class is marked 'final'}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'final'}}
+class TooManyVirtSpecifiers3 final abstract final {};
+#if __cplusplus <= 199711L
+// expected-warning@+6 {{'final' keyword is a C++11 extension}}
+#endif
+// expected-warning@+4 {{abstract class is marked 'final'}}
+// expected-warning@+3 {{'abstract' keyword is a Microsoft extension}}
+// expected-warning@+2 {{'abstract' keyword is a Microsoft extension}}
+// expected-error@+1 {{class already marked 'abstract'}}
+class TooManyVirtSpecifiers4 abstract final abstract {};
+
+class Base {
+  virtual void i();
+};
+class AbstractFunctionInClass : public Base {
+  // expected-note@+2 {{unimplemented pure virtual method 'f' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void f() abstract;
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  void g() abstract; // expected-error {{'g' is not virtual and cannot be declared pure}}
+  // expected-note@+2 {{unimplemented pure virtual method 'h' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void h() abstract = 0; // expected-error {{class member already marked 'abstract'}}
+#if __cplusplus <= 199711L
+  // expected-warning@+4 {{'override' keyword is a C++11 extension}}
+#endif
+  // expected-note@+2 {{unimplemented pure virtual method 'i' in 'AbstractFunctionInClass'}}
+  // expected-warning@+1 {{'abstract' keyword is a Microsoft extension}}
+  virtual void i() abstract override;
+};
+
+// expected-error@+1 {{variable type 'AbstractFunctionInClass' is an abstract class}}
+AbstractFunctionInClass abstractFunctionInClassInstance;
+
 void AfterClassBody() {
   // expected-warning@+1 {{attribute 'deprecated' is ignored, place it after "struct" to apply attribute to type declaration}}
   struct D {} __declspec(deprecated);
Index: clang/lib/Sema/SemaDecl.cpp

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-31 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D102517#2789593 , @AbbasSabra 
wrote:

> In D102517#2789450 , @goncharov 
> wrote:
>
>> Sorry, had to revert it as this fails under sanitizer : 
>> https://lab.llvm.org/buildbot/#/builders/5/builds/8150
>
> Thanks!
>
> I missed adding "Ident_abstract" in the Parser initialize function. Should be 
> fixed now.  CC: @hans

Thanks for the quick fix! Re-landed as 116179c2ee5213f2ae8f07a400ac98f0c995b3d3 
. I'll try 
to keep an eye on that buildbot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

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


[PATCH] D102723: [HIP] Tighten checks in hip-include-path.hip test case

2021-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D102723#2789610 , @bjope wrote:

> In D102723#2789537 , @yaxunl wrote:
>
>> It seems we cannot introduce `ROOT` by line 19 since it is not used in other 
>> lines in situations where working directories have sym links.
>>
>> Instead, we just change `{{.*}}clang/` to `{{.*}}/lib/clang/` in other 
>> lines. Hopefully this will still work.
>
> Ok. That probably works.
>
> A bit surprised though. I found checks using InstalledDir in other test cases 
> such as clang/test/Friver/stdlibxx-isystem.cpp, so I figured it would be safe 
> to use that also in this test case. So I wonder how other tests that captures 
> InstalledDir could work for the symlink-bots.

That test uses --ccc-install-dir `%t/bin` to specify installed directory. 
`%t/bin` is expanded to real path. However, it seems not working on windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102723

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


[clang] c0b3071 - [PowerPC] Fix x86 vector intrinsics wrapper compilation under C++

2021-05-31 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2021-06-01T01:19:12+08:00
New Revision: c0b3071833a80121a5a7ca9ea54fd59a59806acc

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

LOG: [PowerPC] Fix x86 vector intrinsics wrapper compilation under C++

Reviewed By: nemanjai

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

Added: 


Modified: 
clang/lib/Headers/ppc_wrappers/xmmintrin.h
clang/test/CodeGen/ppc-xmmintrin.c

Removed: 




diff  --git a/clang/lib/Headers/ppc_wrappers/xmmintrin.h 
b/clang/lib/Headers/ppc_wrappers/xmmintrin.h
index 0f429fa04081..0e45b96769f8 100644
--- a/clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ b/clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -28,7 +28,7 @@
Most SSE scalar float intrinsic operations can be performed more
efficiently as C language float scalar operations or optimized to
use vector SIMD operations. We recommend this for new applications. */
-#error "Please read comment above.  Use -DNO_WARN_X86_INTRINSICS to disable 
this error."
+#error "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable 
this error."
 #endif
 
 #ifndef _XMMINTRIN_H_INCLUDED
@@ -62,14 +62,13 @@
 
 /* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components.  */
-typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef vector float __m128 __attribute__((__may_alias__));
 
 /* Unaligned version of the same type.  */
-typedef float __m128_u __attribute__ ((__vector_size__ (16), __may_alias__,
-  __aligned__ (1)));
+typedef vector float __m128_u __attribute__((__may_alias__, __aligned__(1)));
 
 /* Internal data types for implementing the intrinsics.  */
-typedef float __v4sf __attribute__ ((__vector_size__ (16)));
+typedef vector float __v4sf;
 
 /* Create an undefined vector.  */
 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))

diff  --git a/clang/test/CodeGen/ppc-xmmintrin.c 
b/clang/test/CodeGen/ppc-xmmintrin.c
index e9466b32257f..32a5e5a7cdaf 100644
--- a/clang/test/CodeGen/ppc-xmmintrin.c
+++ b/clang/test/CodeGen/ppc-xmmintrin.c
@@ -3,8 +3,12 @@
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
 #include 
 
@@ -1426,7 +1430,7 @@ test_mul() {
 
 void __attribute__((noinline))
 test_prefetch() {
-  _mm_prefetch(ms, i);
+  _mm_prefetch(ms, _MM_HINT_NTA);
 }
 
 // CHECK-LABEL: @test_prefetch



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


[PATCH] D103386: [PowerPC] Fix x86 vector intrinsics wrapper compilation under C++

2021-05-31 Thread Qiu Chaofan 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 rGc0b3071833a8: [PowerPC] Fix x86 vector intrinsics wrapper 
compilation under C++ (authored by qiucf, committed by ecnelises).

Changed prior to commit:
  https://reviews.llvm.org/D103386?vs=348726&id=348835#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103386

Files:
  clang/lib/Headers/ppc_wrappers/xmmintrin.h
  clang/test/CodeGen/ppc-xmmintrin.c


Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -3,8 +3,12 @@
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
 #include 
 
@@ -1426,7 +1430,7 @@
 
 void __attribute__((noinline))
 test_prefetch() {
-  _mm_prefetch(ms, i);
+  _mm_prefetch(ms, _MM_HINT_NTA);
 }
 
 // CHECK-LABEL: @test_prefetch
Index: clang/lib/Headers/ppc_wrappers/xmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -28,7 +28,7 @@
Most SSE scalar float intrinsic operations can be performed more
efficiently as C language float scalar operations or optimized to
use vector SIMD operations. We recommend this for new applications. */
-#error "Please read comment above.  Use -DNO_WARN_X86_INTRINSICS to disable 
this error."
+#error "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable 
this error."
 #endif
 
 #ifndef _XMMINTRIN_H_INCLUDED
@@ -62,14 +62,13 @@
 
 /* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components.  */
-typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef vector float __m128 __attribute__((__may_alias__));
 
 /* Unaligned version of the same type.  */
-typedef float __m128_u __attribute__ ((__vector_size__ (16), __may_alias__,
-  __aligned__ (1)));
+typedef vector float __m128_u __attribute__((__may_alias__, __aligned__(1)));
 
 /* Internal data types for implementing the intrinsics.  */
-typedef float __v4sf __attribute__ ((__vector_size__ (16)));
+typedef vector float __v4sf;
 
 /* Create an undefined vector.  */
 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))


Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -3,8 +3,12 @@
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
 #include 
 
@@ -1426,7 +1430,7 @@
 
 void __attribute__((noinline))
 test_prefetch() {
-  _mm_prefetch(ms, i);
+  _mm_prefetch(ms, _MM_HINT_NTA);
 }
 
 // CHECK-LABEL: @test_prefetch
Index: clang/lib/Headers/ppc_wrappers/xmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -28,7 +28,7 @@
Most SSE scalar float intrinsic operations can be performed more
efficien

[PATCH] D88084: [clang-format] Changed default styles BraceWrappping bool table to directly use variables

2021-05-31 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added a comment.

@MyDeveloperDay

This patch was merged upstream a long time ago, how do I close it here on 
Phabricator? thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88084

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


[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-05-31 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 created this revision.
MarcusJohnson91 created this object with visibility "All Users".
MarcusJohnson91 added a project: clang.
Herald added a subscriber: martong.
Herald added a reviewer: aaron.ballman.
MarcusJohnson91 requested review of this revision.
Herald added a project: clang-tools-extra.

Also added support for the `%l16(c|s)` and `%l32(c|s)` conversion specifier for 
char16_t and char32_t types in C and C++, which should soon be accepted by ISO 
WG14.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103426

Files:
  clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/FormatString.h
  clang/include/clang/AST/Type.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/OSLog.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaFixItUtils.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/test/Sema/format-strings-c90.c
  clang/test/Sema/format-strings-darwin.c
  clang/test/Sema/format-strings-int-typedefs.c
  clang/test/Sema/format-strings-ms.c
  clang/test/Sema/format-strings-non-iso.c
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings-scanf.c
  clang/test/Sema/string-plus-char.c
  clang/test/SemaCXX/format-strings-0x.cpp
  clang/test/SemaCXX/format-strings.cpp

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -7,7 +7,10 @@
 extern "C" {
 extern int scanf(const char *restrict, ...);
 extern int printf(const char *restrict, ...);
+extern int wscanf(const char *restrict, ...);
+extern int wprintf(const char *restrict, ...);
 extern int vprintf(const char *restrict, va_list);
+extern int vwprintf(const char *restrict, va_list);
 }
 
 void f(char **sp, float *fp) {
@@ -17,13 +20,24 @@
 #else
   // expected-warning@-4 {{format specifies type 'float *' but the argument has type 'char **'}}
 #endif
+  
+  scanf("%as", sp);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{'a' length modifier is not supported by ISO C}}
+#else
+  // expected-warning@-4 {{format specifies type 'float *' but the argument has type 'wchar_t **'}}
+#endif
 
   printf("%a", 1.0);
   scanf("%afoobar", fp);
+  
+  wprintf("%a", 1.0);
+  wscanf("%afoobar", fp);
 }
 
 void g() {
   printf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
+  wprintf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
 }
 
 // Test that we properly handle format_idx on C++ members.
@@ -76,7 +90,7 @@
   va_start(ap,fmt);
   const char * const format = fmt;
   vprintf(format, ap); // no-warning
-
+  
   const char *format2 = fmt;
   vprintf(format2, ap); // expected-warning{{format string is not a string literal}}
 
Index: clang/test/SemaCXX/format-strings-0x.cpp
===
--- clang/test/SemaCXX/format-strings-0x.cpp
+++ clang/test/SemaCXX/format-strings-0x.cpp
@@ -3,33 +3,53 @@
 extern "C" {
 extern int scanf(const char *restrict, ...);
 extern int printf(const char *restrict, ...);
+extern int wscanf(const wchar_t *restrict, ...);
 }
 
 void f(char **sp, float *fp) {
   scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+  wscanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'wchar_t **'}}
 
   printf("%p", sp); // expected-warning{{format specifies type 'void *' but the argument has type 'char **'}}
+  wprintf("%p", sp); // expected-warning{{format specifies type 'void *' but the argument has type 'wchar_t **'}}
   scanf("%p", sp);  // expected-warning{{format specifies type 'void **' but the argument has type 'char **'}}
+  wscanf("%p", sp);  // expected-warning{{format specifies type 'void **' but the argument has type 'wchar_t **'}}
 
   printf("%a", 1.0);
   scanf("%afoobar", fp);
+  wprintf("%a", 1.0);
+  wscanf("%afoobar", fp);
   printf(nullptr);
   printf(*sp); // expected-warning {{not a string literal}}
   // expected-note@-1{{treat the string as an argument to avoid this}}
+  wprintf(*sp); // expected

[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D91630#2787438 , @thakis wrote:

> This is breaking check-clang everywhere, eg 
> https://lab.llvm.org/buildbot/#/builders/109/builds/15757
>
> Please run tests before landing, or failing that watch the bots after 
> committing.
>
> Reverted in f63adf5b67f7a25b15f81d3a1a207aba4f226dc4 
>  for now.

Sorry about that, I thought the pre-commit CI here on Phabricator had passed 
those tests successfully. The only failures I was seeing were related to 
`clang-format`. I'm not sure what happened. Anyway, thanks for reverting, I'll 
take a look at this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

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


[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 348859.
ldionne added a comment.

Rebase onto `main`. I want to trigger CI again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp

Index: clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -pedantic -triple x86_64-apple-macos11 -std=c++20 -fsyntax-only -verify %s
+
+static_assert(__has_extension(cxx_attributes_on_using_declarations), "");
+
+namespace NS { typedef int x; }
+
+[[clang::annotate("foo")]] using NS::x; // expected-warning{{ISO C++ does not allow an attribute list to appear here}}
+
+
+[[deprecated]] using NS::x;// expected-warning {{'deprecated' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+using NS::x [[deprecated]];// expected-warning {{'deprecated' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+using NS::x __attribute__((deprecated));   // expected-warning {{'deprecated' currently has no effect on using-declarations}}
+using NS::x __attribute__((availability(macos,introduced=1))); // expected-warning {{'availability' currently has no effect on using-declarations}}
+
+[[clang::availability(macos,introduced=1)]] using NS::x; // expected-warning {{'availability' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+
+// expected-warning@+1 3 {{ISO C++ does not allow an attribute list to appear here}}
+[[clang::annotate("A")]] using NS::x [[clang::annotate("Y")]], NS::x [[clang::annotate("Z")]];
+
+template 
+struct S : T {
+  [[deprecated]] using typename T::x; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+  [[deprecated]] using T::y;  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+
+  using typename T::z [[deprecated]]; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+  using T::a [[deprecated]];  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+};
+
+struct Base {};
+
+template 
+struct DepBase1 : B {
+  using B::B [[]];
+
+};
+template 
+struct DepBase2 : B {
+  using B::B __attribute__(());
+};
+
+DepBase1 db1;
+DepBase2 db2;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -131,12 +131,12 @@
 [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
 [[]] asm(""); // expected-error {{an attribute list cannot appear here}}
 
-[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
+[[]] using ns::i;
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
 namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}}
 
-using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
+using[[]] alignas(4)[[]] ns::i;  // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to variables, data members and tag types}} expected-warning {{ISO C++}}
 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
 
 void bad_attributes_in_do_while() {
@@ -157,7 +157,16 @@
 [[]] using T = int; // expected-error {{an attribute list cannot appear here}}
 using T [[]] = int; // ok
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
+using ns::i [[]], ns::i [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
+struct using_in_struct_base {
+  typedef int i, j, k, l;
+};
+str

[clang] f0e10cc - [HIP] Relax checks in hip-include-path.hip test case again

2021-05-31 Thread Bjorn Pettersson via cfe-commits

Author: Bjorn Pettersson
Date: 2021-05-31T22:40:21+02:00
New Revision: f0e10cc91bc40fb5c0698846f0a324d4658f54c7

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

LOG: [HIP] Relax checks in hip-include-path.hip test case again

The tightened checks from commit 722c39fef5ab6 did not work
fully for buildbots using symlinks in repo paths. This patch
is not fully reverting 722c39fef5ab6, as we still match that
there is a "/lib" somewhere in the path before "/clang/".

So this is once again a bit fragile in case someone would put
their repo in a base directory, for example, named
 "/scratch/lib/foo/clang/llvm-project/". But it is atleast a
bit better than the original checks (avoiding the problem that
commit 722c39fef5ab6 was solving).

Added: 


Modified: 
clang/test/Driver/hip-include-path.hip

Removed: 




diff  --git a/clang/test/Driver/hip-include-path.hip 
b/clang/test/Driver/hip-include-path.hip
index 7c728a4c95fd6..dce42f58fdf5e 100644
--- a/clang/test/Driver/hip-include-path.hip
+++ b/clang/test/Driver/hip-include-path.hip
@@ -16,40 +16,36 @@
 // RUN:   -std=c++11 --rocm-path=%S/Inputs/rocm -nogpuinc -nogpulib %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=COMMON,CLANG,NOHIP %s
 
-// COMMON: InstalledDir: [[ROOT:[^"]*]]/bin
-
 // COMMON-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
-// CLANG-SAME: "-internal-isystem" 
"[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
-// NOCLANG-NOT: "[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
+// CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
+// NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
 // HIP-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include"
 // NOHIP-NOT: "{{.*}}Inputs/rocm/include"
 // HIP-SAME: "-include" "__clang_hip_runtime_wrapper.h"
 // NOHIP-NOT: "-include" "__clang_hip_runtime_wrapper.h"
 // skip check of standard C++ include path
-// CLANG-SAME: "-internal-isystem" 
"[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include"
-// NOCLANG-NOT: "[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
 
 // COMMON-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
-// CLANG-SAME: "-internal-isystem" 
"[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
-// NOCLANG-NOT: "[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
+// CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
+// NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
 // HIP-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include"
 // NOHIP-NOT: "{{.*}}Inputs/rocm/include"
 // HIP-SAME: "-include" "__clang_hip_runtime_wrapper.h"
 // NOHIP-NOT: "-include" "__clang_hip_runtime_wrapper.h"
 // skip check of standard C++ include path
-// CLANG-SAME: "-internal-isystem" 
"[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include"
-// NOCLANG-NOT: "[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
 
 // RUN: %clang -c -### -target x86_64-unknown-linux-gnu --cuda-gpu-arch=gfx900 
\
 // RUN:   -std=c++11 --rocm-path=%S/Inputs/rocm -nogpulib %s 2>&1 \
 // RUN:   --hip-version=3.5 | FileCheck -check-prefixes=ROCM35 %s
 
-// ROCM35: InstalledDir: [[ROOT:[^"]*]]/bin
-
 // ROCM35-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
-// ROCM35-NOT: "[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
-// ROCM35-SAME: "-internal-isystem" "[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}"
+// ROCM35-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
+// ROCM35-SAME: "-internal-isystem" "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}"
 // ROCM35-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include"
 // ROCM35-NOT: "-include" "__clang_hip_runtime_wrapper.h"
 // skip check of standard C++ include path
-// ROCM35-SAME: "-internal-isystem" 
"[[ROOT]]/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// ROCM35-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"



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


[PATCH] D102723: [HIP] Tighten checks in hip-include-path.hip test case

2021-05-31 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

I relaxed the checks a bit again here: https://reviews.llvm.org/rGf0e10cc91bc4
But it looks like the workers here (https://lab.llvm.org/staging/#/workers/109) 
are paused so hard to tell if it helped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102723

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


[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 348861.
ldionne added a comment.

Fix embarrassingly obvious oversight when I applied Aaron's feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp

Index: clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -pedantic -triple x86_64-apple-macos11 -std=c++20 -fsyntax-only -verify %s
+
+static_assert(__has_extension(cxx_attributes_on_using_declarations), "");
+
+namespace NS { typedef int x; }
+
+[[clang::annotate("foo")]] using NS::x; // expected-warning{{ISO C++ does not allow an attribute list to appear here}}
+
+
+[[deprecated]] using NS::x;// expected-warning {{'deprecated' currently has no effect on a using declaration}} expected-warning{{ISO C++ does not allow}}
+using NS::x [[deprecated]];// expected-warning {{'deprecated' currently has no effect on a using declaration}} expected-warning{{ISO C++ does not allow}}
+using NS::x __attribute__((deprecated));   // expected-warning {{'deprecated' currently has no effect on a using declaration}}
+using NS::x __attribute__((availability(macos,introduced=1))); // expected-warning {{'availability' currently has no effect on a using declaration}}
+
+[[clang::availability(macos,introduced=1)]] using NS::x; // expected-warning {{'availability' currently has no effect on a using declaration}} expected-warning{{ISO C++ does not allow}}
+
+// expected-warning@+1 3 {{ISO C++ does not allow an attribute list to appear here}}
+[[clang::annotate("A")]] using NS::x [[clang::annotate("Y")]], NS::x [[clang::annotate("Z")]];
+
+template 
+struct S : T {
+  [[deprecated]] using typename T::x; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on a using declaration}}
+  [[deprecated]] using T::y;  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on a using declaration}}
+
+  using typename T::z [[deprecated]]; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on a using declaration}}
+  using T::a [[deprecated]];  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on a using declaration}}
+};
+
+struct Base {};
+
+template 
+struct DepBase1 : B {
+  using B::B [[]];
+
+};
+template 
+struct DepBase2 : B {
+  using B::B __attribute__(());
+};
+
+DepBase1 db1;
+DepBase2 db2;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -131,12 +131,12 @@
 [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
 [[]] asm(""); // expected-error {{an attribute list cannot appear here}}
 
-[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
+[[]] using ns::i;
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
 namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}}
 
-using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
+using[[]] alignas(4)[[]] ns::i;  // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to variables, data members and tag types}} expected-warning {{ISO C++}}
 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
 
 void bad_attributes_in_do_while() {
@@ -157,7 +157,16 @@
 [[]] using T = int; // expected-error {{an attribute list cannot appear here}}
 using T [[]] = int; // ok
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
+using ns::i [[]], ns::i [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
+struct using_in_struct_base {
+  t

[PATCH] D100782: [PowerPC] Improve f32 to i32 bitcast code gen

2021-05-31 Thread Albion Fung 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 rGdb26cd30b6dd: [PowerPC] Improve f32 to i32 bitcast code gen 
(authored by Conanap).

Changed prior to commit:
  https://reviews.llvm.org/D100782?vs=343969&id=348862#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100782

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/aix-p9-xxinsertw-xxextractuw.ll
  llvm/test/CodeGen/PowerPC/aix-vec_insert_elt.ll
  llvm/test/CodeGen/PowerPC/bitcasts-direct-move.ll
  llvm/test/CodeGen/PowerPC/p9-xxinsertw-xxextractuw.ll
  llvm/test/CodeGen/PowerPC/scalar_vector_test_4.ll
  llvm/test/CodeGen/PowerPC/vec_insert_elt.ll

Index: llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
===
--- llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
+++ llvm/test/CodeGen/PowerPC/vec_insert_elt.ll
@@ -200,21 +200,19 @@
 ; CHECK-LABEL: testFloat1:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:xscvdpspn vs0, f1
-; CHECK-NEXT:extsw r3, r6
-; CHECK-NEXT:slwi r3, r3, 2
-; CHECK-NEXT:xxsldwi vs0, vs0, vs0, 3
-; CHECK-NEXT:mffprwz r4, f0
-; CHECK-NEXT:vinswrx v2, r3, r4
+; CHECK-NEXT:extsw r4, r6
+; CHECK-NEXT:slwi r4, r4, 2
+; CHECK-NEXT:mffprwz r3, f0
+; CHECK-NEXT:vinswrx v2, r4, r3
 ; CHECK-NEXT:blr
 ;
 ; CHECK-BE-LABEL: testFloat1:
 ; CHECK-BE:   # %bb.0: # %entry
 ; CHECK-BE-NEXT:xscvdpspn vs0, f1
-; CHECK-BE-NEXT:extsw r3, r6
-; CHECK-BE-NEXT:slwi r3, r3, 2
-; CHECK-BE-NEXT:xxsldwi vs0, vs0, vs0, 3
-; CHECK-BE-NEXT:mffprwz r4, f0
-; CHECK-BE-NEXT:vinswlx v2, r3, r4
+; CHECK-BE-NEXT:extsw r4, r6
+; CHECK-BE-NEXT:slwi r4, r4, 2
+; CHECK-BE-NEXT:mffprwz r3, f0
+; CHECK-BE-NEXT:vinswlx v2, r4, r3
 ; CHECK-BE-NEXT:blr
 ;
 ; CHECK-P9-LABEL: testFloat1:
@@ -346,7 +344,6 @@
 ; CHECK-LABEL: testFloatImm1:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:xscvdpspn vs0, f1
-; CHECK-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-NEXT:xxinsertw v2, vs0, 12
 ; CHECK-NEXT:xxinsertw v2, vs0, 4
 ; CHECK-NEXT:blr
@@ -354,7 +351,6 @@
 ; CHECK-BE-LABEL: testFloatImm1:
 ; CHECK-BE:   # %bb.0: # %entry
 ; CHECK-BE-NEXT:xscvdpspn vs0, f1
-; CHECK-BE-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-BE-NEXT:xxinsertw v2, vs0, 0
 ; CHECK-BE-NEXT:xxinsertw v2, vs0, 8
 ; CHECK-BE-NEXT:blr
@@ -362,7 +358,6 @@
 ; CHECK-P9-LABEL: testFloatImm1:
 ; CHECK-P9:   # %bb.0: # %entry
 ; CHECK-P9-NEXT:xscvdpspn vs0, f1
-; CHECK-P9-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-P9-NEXT:xxinsertw v2, vs0, 0
 ; CHECK-P9-NEXT:xxinsertw v2, vs0, 8
 ; CHECK-P9-NEXT:blr
@@ -393,11 +388,9 @@
 ; CHECK-P9:   # %bb.0: # %entry
 ; CHECK-P9-NEXT:lfs f0, 0(r5)
 ; CHECK-P9-NEXT:xscvdpspn vs0, f0
-; CHECK-P9-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-P9-NEXT:xxinsertw v2, vs0, 0
 ; CHECK-P9-NEXT:lfs f0, 4(r5)
 ; CHECK-P9-NEXT:xscvdpspn vs0, f0
-; CHECK-P9-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-P9-NEXT:xxinsertw v2, vs0, 8
 ; CHECK-P9-NEXT:blr
 entry:
@@ -439,11 +432,9 @@
 ; CHECK-P9-NEXT:li r3, 1
 ; CHECK-P9-NEXT:rldic r3, r3, 38, 25
 ; CHECK-P9-NEXT:xscvdpspn vs0, f0
-; CHECK-P9-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-P9-NEXT:xxinsertw v2, vs0, 0
 ; CHECK-P9-NEXT:lfsx f0, r5, r3
 ; CHECK-P9-NEXT:xscvdpspn vs0, f0
-; CHECK-P9-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; CHECK-P9-NEXT:xxinsertw v2, vs0, 8
 ; CHECK-P9-NEXT:blr
 entry:
@@ -738,3 +729,26 @@
   ret <2 x double> %vecins
 }
 
+define dso_local <4 x float> @testInsertDoubleToFloat(<4 x float> %a, double %b) local_unnamed_addr #0 {
+; CHECK-LABEL: testInsertDoubleToFloat:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xscvdpsp f0, f1
+; CHECK-NEXT:xxinsertw v2, vs0, 8
+; CHECK-NEXT:blr
+;
+; CHECK-BE-LABEL: testInsertDoubleToFloat:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:xscvdpsp f0, f1
+; CHECK-BE-NEXT:xxinsertw v2, vs0, 4
+; CHECK-BE-NEXT:blr
+;
+; CHECK-P9-LABEL: testInsertDoubleToFloat:
+; CHECK-P9:   # %bb.0: # %entry
+; CHECK-P9-NEXT:xscvdpsp f0, f1
+; CHECK-P9-NEXT:xxinsertw v2, vs0, 4
+; CHECK-P9-NEXT:blr
+entry:
+  %conv = fptrunc double %b to float
+  %vecins = insertelement <4 x float> %a, float %conv, i32 1
+  ret <4 x float> %vecins
+}
Index: llvm/test/CodeGen/PowerPC/scalar_vector_test_4.ll
===
--- llvm/test/CodeGen/PowerPC/scalar_vector_test_4.ll
+++ llvm/test/CodeGen/PowerPC/scalar_vector_test_4.ll
@@ -216,7 +216,6 @@
 ; P9LE:   # %bb.0: # %entry
 ; P9LE-NEXT:lfs f0, 0(r3)
 ; P9LE-NEXT:xscvdpspn vs0, f0
-; P9LE-NEXT:xxsldwi vs0, vs0, vs0, 3
 ; P9LE-NEXT:xxinsertw v2, vs0, 12
 ; P9LE-NEXT:blr
 ;
@@ -224,7 +223,6 @@
 ; P9BE:

[PATCH] D88084: [clang-format] Changed default styles BraceWrappping bool table to directly use variables

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

Under "Related Objects" you can add the commit, so that one can navigate to it.

And as action there is "Close Revision", which marks this as done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88084

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


[PATCH] D103319: [analyzer] Use Optional as a return type of StoreManager::castRegion

2021-05-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D103319#2788304 , @ASDenysPetrov 
wrote:

> WDYT?

Fair point!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103319

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


[PATCH] D103080: [CMake] Ignore arm_*.h for non-ARM build

2021-05-31 Thread lin.sun via Phabricator via cfe-commits
sunlin added a comment.

Hi @kristof.beyls The  original `lib/clang/12.0.1/include` is about total ~10M, 
and the `arm*.h` take about ~5M. Ignore these unused header files will save the 
developers who work on the low storage device.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103080

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


[PATCH] D102582: [RISCV] Report an error when ABI mismatch with target-abi module flag.

2021-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 348870.
khchen added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Revert to previous revision Diff 347356 and add empty module flag could be 
empty in test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102582

Files:
  clang/test/CodeGen/RISCV/riscv-metadata.c
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/test/CodeGen/RISCV/module-target-abi-tests.ll
  llvm/test/CodeGen/RISCV/module-target-abi.ll
  llvm/test/CodeGen/RISCV/module-target-abi2.ll

Index: llvm/test/CodeGen/RISCV/module-target-abi2.ll
===
--- llvm/test/CodeGen/RISCV/module-target-abi2.ll
+++ /dev/null
@@ -1,27 +0,0 @@
-; RUN: llc -mtriple=riscv32 < %s 2>&1 \
-; RUN:   | FileCheck -check-prefix=DEFAULT %s
-; RUN: not --crash llc -mtriple=riscv32 -target-abi ilp32 < %s 2>&1 \
-; RUN:   | FileCheck -check-prefix=RV32IF-ILP32 %s
-; RUN: llc -mtriple=riscv32 -target-abi ilp32f < %s 2>&1 \
-; RUN:   | FileCheck -check-prefix=RV32IF-ILP32F %s
-; RUN: llc -mtriple=riscv32 -filetype=obj < %s | llvm-readelf -h - | FileCheck -check-prefixes=FLAGS %s
-
-; RV32IF-ILP32: -target-abi option != target-abi module flag
-
-; FLAGS: Flags: 0x0
-; // this should be "Flags :0x2, single-float ABI", it will be fixed later.
-
-define float @foo(i32 %a) nounwind #0 {
-; DEFAULT: # %bb.0:
-; DEFAULT-NEXT: fcvt.s.w fa0, a0
-; DEFAULT-NEXT: ret
-; RV32IF-ILP32F: # %bb.0:
-; RV32IF-ILP32F: fcvt.s.w fa0, a0
-; RV32IF-ILP32F: ret
-  %conv = sitofp i32 %a to float
-  ret float %conv
-}
-
-attributes #0 = { "target-features"="+f"}
-!llvm.module.flags = !{!0}
-!0 = !{i32 1, !"target-abi", !"ilp32f"}
Index: llvm/test/CodeGen/RISCV/module-target-abi.ll
===
--- llvm/test/CodeGen/RISCV/module-target-abi.ll
+++ /dev/null
@@ -1,24 +0,0 @@
-; RUN: llc -mtriple=riscv32 < %s 2>&1 \
-; RUN:   | FileCheck -check-prefix=DEFAULT %s
-; RUN: llc -mtriple=riscv32 -target-abi ilp32 < %s 2>&1 \
-; RUN:   | FileCheck -check-prefix=RV32IF-ILP32 %s
-; RUN: not --crash llc -mtriple=riscv32 -target-abi ilp32f < %s 2>&1 \
-; RUN:   | FileCheck -check-prefix=RV32IF-ILP32F %s
-; RUN: llc -mtriple=riscv32 -filetype=obj < %s | llvm-readelf -h - | FileCheck -check-prefixes=FLAGS %s
-
-; RV32IF-ILP32F: -target-abi option != target-abi module flag
-
-; FLAGS: Flags: 0x0
-
-define float @foo(i32 %a) nounwind #0 {
-; DEFAULT: # %bb.0:
-; DEFAULT: fmv.x.w a0, ft0
-; RV32IF-ILP32: # %bb.0:
-; RV32IF-ILP32: fmv.x.w a0, ft0
-  %conv = sitofp i32 %a to float
-  ret float %conv
-}
-
-attributes #0 = { "target-features"="+f"}
-!llvm.module.flags = !{!0}
-!0 = !{i32 1, !"target-abi", !"ilp32"}
Index: llvm/test/CodeGen/RISCV/module-target-abi-tests.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/module-target-abi-tests.ll
@@ -0,0 +1,35 @@
+; This test is designed to run with different target-abi module flags.
+;
+; Default RV32 ABI is ilp32 for empty target-abi option and module flag, so the result is correct.
+; RUN: cat %s > %t.emptyabi
+; RUN: echo '!0 = !{i32 1, !"target-abi", !""}' >> %t.emptyabi
+; RUN: llc -mtriple=riscv32 < %t.emptyabi -o /dev/null
+; RUN: llc -mtriple=riscv32 -target-abi ilp32 < %t.emptyabi -o /dev/null
+; RUN: not llc -mtriple=riscv32 -target-abi ilp32f < %t.emptyabi -o /dev/null 2>&1 \
+; RUN:   | FileCheck -check-prefix=DEFAULT-RV32-ILP32F %t.emptyabi
+;
+; Default RV32 ABI is ilp32 which equals target-abi module flag, so the result is correct.
+; RUN: cat %s > %t.ilp32abi
+; RUN: echo '!0 = !{i32 1, !"target-abi", !"ilp32"}' >> %t.ilp32abi
+; RUN: llc -mtriple=riscv32 < %t.ilp32abi -o /dev/null
+; RUN: not llc -mtriple=riscv32 -target-abi ilp32f < %t.ilp32abi -o /dev/null 2>&1 \
+; RUN:   | FileCheck -check-prefix=DEFAULT-RV32-ILP32F %t.ilp32abi
+
+; DEFAULT-RV32-ILP32F: error: Mismatched ABIs. Current ABI is 'ilp32f', but IR target-abi module flag is 'ilp32'.
+
+; Default RV32 ABI is ilp32 which mismatch with target-abi module flag ilp32f.
+; RUN: cat %s > %t.ilp32fabi
+; RUN: echo '!0 = !{i32 1, !"target-abi", !"ilp32f"}' >> %t.ilp32fabi
+; RUN: not llc -mtriple=riscv32 < %t.ilp32fabi -o /dev/null
+; RUN: not llc -mtriple=riscv32 -target-abi ilp32 < %t.ilp32fabi -o /dev/null 2>&1 \
+; RUN:   | FileCheck -check-prefix=RV32-ILP32F %t.ilp32fabi
+
+; RV32-ILP32F: Mismatched ABIs. Current ABI is 'ilp32', but IR target-abi module flag is 'ilp32f'.
+
+define float @foo(i32 %a) nounwind #0 {
+  %conv = sitofp i32 %a to float
+  ret float %conv
+}
+
+attributes #0 = { "target-features"="+f"}
+!llvm.module.flags = !{!0}
Index: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

[PATCH] D99645: [flang][driver] Add debug options not requiring semantic checks

2021-05-31 Thread Gamel Alomaisi via Phabricator via cfe-commits
walli99 added a comment.

انت


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99645

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-31 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.

In D101140#2789199 , @wingo wrote:

> Quick r? to @tlively -- OK with having the new util function in 
> WebAssemblyFrameLowering?  It didn't work to have it in the utils library 
> because the function needs the vtable of WebAssemblyFunctionInfo.

Yes, this sounds reasonable to me.

And regarding the target-specific additions to target-independent code, this 
addition also seems similar to how we have target-specific MVTs in the 
target-independent MVT list. Being able to add names (but usually not logic) 
for target-specific concepts to target-independent namespaces makes it much 
simpler to handle target-independent and target-specific things in a uniform 
way in the backends.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D103434: [analyzer] Allow visitors to run callbacks on completion

2021-05-31 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD created this revision.
RedDocMD added reviewers: NoQ, vsavchenko, xazax.hun, teemperor.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware.
RedDocMD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch introduces the concept of *Stoppable* visitors, ie, a
visitor that must perform some task when it runs out of nodes on which
it has work to do.
Initially, the `ReturnVisitor` is being made *stoppable*, thus allowing
it to run callbacks on completion. These callbacks are meant to be
supplied from `trackExpressionValue`.
Thus, this patch will also allow `trackExpressionValue` to recieve a
callback to run when it is done tracking.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103434

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -320,6 +320,22 @@
   return P;
 }
 
+//===--===//
+// Implementation of StoppableBugReporterVisitor
+//===--===//
+
+StoppableBugReporterVisitor::~StoppableBugReporterVisitor() {
+  assert(Stopped && "Stoppable visitor not stopped in its lifetime");
+}
+
+void StoppableBugReporterVisitor::Stop(const ExplodedNode *Curr,
+   BugReporterContext &BRC,
+   PathSensitiveBugReport &BR) {
+  assert(!Stopped && "Stop() can be called only once in visitor's lifetime");
+  Stopped = true;
+  OnStop(Curr, BRC, BR);
+}
+
 //===--===//
 // Implementation of NoStoreFuncVisitor.
 //===--===//
@@ -876,6 +892,9 @@
 
 namespace {
 
+using VisitorCallback = llvm::function_ref;
+
 /// Emits an extra note at the return statement of an interesting stack frame.
 ///
 /// The returned value is marked as an interesting value, and if it's null,
@@ -883,7 +902,7 @@
 ///
 /// This visitor is intended to be used when another visitor discovers that an
 /// interesting value comes from an inlined function call.
-class ReturnVisitor : public BugReporterVisitor {
+class ReturnVisitor : public StoppableBugReporterVisitor {
   const StackFrameContext *CalleeSFC;
   enum {
 Initial,
@@ -895,12 +914,14 @@
   bool ShouldInvalidate = true;
   AnalyzerOptions& Options;
   bugreporter::TrackingKind TKind;
+  VisitorCallback Callback;
 
 public:
   ReturnVisitor(const StackFrameContext *Frame, bool Suppressed,
-AnalyzerOptions &Options, bugreporter::TrackingKind TKind)
-  : CalleeSFC(Frame), EnableNullFPSuppression(Suppressed),
-Options(Options), TKind(TKind) {}
+AnalyzerOptions &Options, bugreporter::TrackingKind TKind,
+VisitorCallback &&Callback = nullptr)
+  : CalleeSFC(Frame), EnableNullFPSuppression(Suppressed), Options(Options),
+TKind(TKind), Callback(Callback) {}
 
   static void *getTag() {
 static int Tag = 0;
@@ -913,6 +934,13 @@
 ID.AddBoolean(EnableNullFPSuppression);
   }
 
+  void OnStop(const ExplodedNode *Curr, BugReporterContext &BRC,
+  PathSensitiveBugReport &BR) const override {
+if (Callback) {
+  Callback(Curr, BRC, BR);
+}
+  }
+
   /// Adds a ReturnVisitor if the given statement represents a call that was
   /// inlined.
   ///
@@ -1123,6 +1151,10 @@
 else
   BR.markInteresting(CalleeSFC);
 
+// Since we know that no other notes will be emitted subsequently by this
+// visitor.
+Stop(N, BRC, BR);
+
 return EventPiece;
   }
 
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -85,6 +85,26 @@
 const PathSensitiveBugReport &BR);
 };
 
+/// StoppableBugReporterVisitor is a special type of visitor that is known to
+/// not have any useful work to do after it reaches a certain node in its
+/// traversal. When it does reach that node, the \ref Stop method must be
+/// called. This in turn calls the \ref OnStop method (which must be overriden
+/// in the sub-class). Note that such visitors *must* be stopped exactly once.
+class StoppableBugReporterVisitor : public BugReporterVisitor {
+  /// This method is run once the \ref Stop meth

[PATCH] D103434: [analyzer] Allow visitors to run callbacks on completion

2021-05-31 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

**Note: This patch is only partially done.**

The following things are still left:

- `trackExpressionValue` must receive a callback
- The callback must be passed to a visitor (`ReturnVisitor` for now)
- Tests to verify that `ReturnVisitor` actually does what we intend it to do 
(call the callback at the right place).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103434

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


[clang-tools-extra] 0be2657 - [clangd] Type hints for variables with 'auto' type

2021-05-31 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2021-06-01T02:21:02-04:00
New Revision: 0be2657c2f486ffc006a037684cb658f4bf6cf11

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

LOG: [clangd] Type hints for variables with 'auto' type

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

Added: 


Modified: 
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 3880273f85908..9fbce419edd2f 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -22,11 +22,16 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   InlayHintVisitor(std::vector &Results, ParsedAST &AST)
   : Results(Results), AST(AST.getASTContext()),
 MainFileID(AST.getSourceManager().getMainFileID()),
-Resolver(AST.getHeuristicResolver()) {
+Resolver(AST.getHeuristicResolver()),
+TypeHintPolicy(this->AST.getPrintingPolicy()) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
 MainFileBuf = Invalid ? StringRef{} : Buf;
+
+TypeHintPolicy.SuppressScope = true; // keep type names short
+TypeHintPolicy.AnonymousTagLocations =
+false; // do not print lambda locations
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
@@ -67,6 +72,26 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 return true;
   }
 
+  bool VisitVarDecl(VarDecl *D) {
+// Do not show hints for the aggregate in a structured binding.
+// In the future, we may show hints for the individual bindings.
+if (isa(D))
+  return true;
+
+if (auto *AT = D->getType()->getContainedAutoType()) {
+  if (!D->getType()->isDependentType()) {
+// Our current approach is to place the hint on the variable
+// and accordingly print the full type
+// (e.g. for `const auto& x = 42`, print `const int&`).
+// Alternatively, we could place the hint on the `auto`
+// (and then just print the type deduced for the `auto`).
+addInlayHint(D->getLocation(), InlayHintKind::TypeHint,
+ ": " + D->getType().getAsString(TypeHintPolicy));
+  }
+}
+return true;
+  }
+
   // FIXME: Handle RecoveryExpr to try to hint some invalid calls.
 
 private:
@@ -278,6 +303,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   FileID MainFileID;
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
+  PrintingPolicy TypeHintPolicy;
 };
 
 std::vector inlayHints(ParsedAST &AST) {

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 71a89ccdc587d..06dbdaebb9a46 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1314,6 +1314,8 @@ llvm::json::Value toJSON(InlayHintKind K) {
   switch (K) {
   case InlayHintKind::ParameterHint:
 return "parameter";
+  case InlayHintKind::TypeHint:
+return "type";
   }
   llvm_unreachable("Unknown clang.clangd.InlayHintKind");
 }

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index f0d46ab8a0105..3f6ce566ef2f4 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1500,9 +1500,14 @@ enum class InlayHintKind {
   /// which shows the name of the corresponding parameter.
   ParameterHint,
 
+  /// The hint corresponds to information about a deduced type.
+  /// An example of a type hint is a hint in this position:
+  ///auto var ^ = expr;
+  /// which shows the deduced type of the variable.
+  TypeHint,
+
   /// Other ideas for hints that are not currently implemented:
   ///
-  /// * Type hints, showing deduced types.
   /// * Chaining hints, showing the types of intermediate expressions
   ///   in a chain of function calls.
   /// * Hints indicating implicit conversions or implicit constructor calls.

diff  --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp 
b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
index 3cf1c6d70c0d3..026479275a472 100644
--- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -15,14 +15,19 @@
 
 namespace clang {
 namespace clangd {
+
+std::ostream &operator<<(std::ostream &Stream, const InlayHint &Hint) {
+  return Stream << Hint.label;
+}
+
 namespace {
 
 using ::testing::UnorderedElementsAre;
 
-std::vector parameterHints(ParsedAST &AST) {
+std::vector hintsOfKind(ParsedAST &AST, InlayHintKind Kind) {
   std::vector Result;
   for (

[PATCH] D102148: [clangd] Type hints for variables with 'auto' type

2021-05-31 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0be2657c2f48: [clangd] Type hints for variables with 
'auto' type (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102148

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -15,14 +15,19 @@
 
 namespace clang {
 namespace clangd {
+
+std::ostream &operator<<(std::ostream &Stream, const InlayHint &Hint) {
+  return Stream << Hint.label;
+}
+
 namespace {
 
 using ::testing::UnorderedElementsAre;
 
-std::vector parameterHints(ParsedAST &AST) {
+std::vector hintsOfKind(ParsedAST &AST, InlayHintKind Kind) {
   std::vector Result;
   for (auto &Hint : inlayHints(AST)) {
-if (Hint.kind == InlayHintKind::ParameterHint)
+if (Hint.kind == Kind)
   Result.push_back(Hint);
   }
   return Result;
@@ -31,6 +36,11 @@
 struct ExpectedHint {
   std::string Label;
   std::string RangeName;
+
+  friend std::ostream &operator<<(std::ostream &Stream,
+  const ExpectedHint &Hint) {
+return Stream << Hint.RangeName << ": " << Hint.Label;
+  }
 };
 
 MATCHER_P2(HintMatcher, Expected, Code, "") {
@@ -39,17 +49,29 @@
 }
 
 template 
-void assertParameterHints(llvm::StringRef AnnotatedSource,
-  ExpectedHints... Expected) {
+void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
   Annotations Source(AnnotatedSource);
   TestTU TU = TestTU::withCode(Source.code());
-  TU.ExtraArgs.push_back("-std=c++11");
+  TU.ExtraArgs.push_back("-std=c++14");
   auto AST = TU.build();
 
-  EXPECT_THAT(parameterHints(AST),
+  EXPECT_THAT(hintsOfKind(AST, Kind),
   UnorderedElementsAre(HintMatcher(Expected, Source)...));
 }
 
+template 
+void assertParameterHints(llvm::StringRef AnnotatedSource,
+  ExpectedHints... Expected) {
+  assertHints(InlayHintKind::ParameterHint, AnnotatedSource, Expected...);
+}
+
+template 
+void assertTypeHints(llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
+  assertHints(InlayHintKind::TypeHint, AnnotatedSource, Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -376,6 +398,119 @@
ExpectedHint{"timeout_millis: ", "timeout_millis"});
 }
 
+TEST(TypeHints, Smoke) {
+  assertTypeHints(R"cpp(
+auto $waldo[[waldo]] = 42;
+  )cpp",
+  ExpectedHint{": int", "waldo"});
+}
+
+TEST(TypeHints, Decorations) {
+  assertTypeHints(R"cpp(
+int x = 42;
+auto* $var1[[var1]] = &x;
+auto&& $var2[[var2]] = x;
+const auto& $var3[[var3]] = x;
+  )cpp",
+  ExpectedHint{": int *", "var1"},
+  ExpectedHint{": int &", "var2"},
+  ExpectedHint{": const int &", "var3"});
+}
+
+TEST(TypeHints, DecltypeAuto) {
+  assertTypeHints(R"cpp(
+int x = 42;
+int& y = x;
+decltype(auto) $z[[z]] = y;
+  )cpp",
+  ExpectedHint{": int &", "z"});
+}
+
+TEST(TypeHints, NoQualifiers) {
+  assertTypeHints(R"cpp(
+namespace A {
+  namespace B {
+struct S1 {};
+S1 foo();
+auto $x[[x]] = foo();
+
+struct S2 {
+  template 
+  struct Inner {};
+};
+S2::Inner bar();
+auto $y[[y]] = bar();
+  }
+}
+  )cpp",
+  ExpectedHint{": S1", "x"}, ExpectedHint{": Inner", "y"});
+}
+
+TEST(TypeHints, Lambda) {
+  // Do not print something overly verbose like the lambda's location.
+  // Show hints for init-captures (but not regular captures).
+  assertTypeHints(R"cpp(
+void f() {
+  int cap = 42;
+  auto $L[[L]] = [cap, $init[[init]] = 1 + 1](int a) { 
+return a + cap + init; 
+  };
+}
+  )cpp",
+  ExpectedHint{": (lambda)", "L"},
+  ExpectedHint{": int", "init"});
+}
+
+TEST(TypeHints, StructuredBindings) {
+  // FIXME: Not handled yet.
+  // To handle it, we could print:
+  //  - the aggregate type next to the 'auto', or
+  //  - the individual types inside the brackets
+  // The latter is probably more useful.
+  assertTypeHints(R"cpp(
+struct Point {
+  int x;
+  int y;
+};
+Point foo();
+auto [x, y] = foo();
+  )cpp");
+}
+
+TEST(TypeHints, ReturnTypeDeduction) {
+  // FIXME: Not handled yet.
+  // This test is currently here mostly because a naive implementation
+  // might have us print something not super helpful like the functi

[PATCH] D103195: Add matchers for gtest's ASSERT_THAT, EXPECT_THAT, ON_CALL and EXPECT_CALL

2021-05-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

a few more nits, the code looks good to me now. As discussed with @ymandel 
offline, we should be aware of that before moving forward to this direction -- 
this patch will likely have the gtest-versioning issue.




Comment at: clang/lib/ASTMatchers/GtestMatchers.cpp:134
+// A ON_CALL or EXPECT_CALL macro expands to different AST structures depending
+// on whether the mock method has arguments or not. For example,
+// `ON_CALL(mock, TwoParamMethod)` is expanded to

I think `For example, ...` words are implementation details, should move to the 
corresponding `switch case` below.



Comment at: clang/lib/ASTMatchers/GtestMatchers.cpp:41
   }
-  llvm_unreachable("Unhandled GtestCmp enum");
 }

zhaomo wrote:
> hokein wrote:
> > why remove this `llvm_unreachable`? I think this is a common practice in 
> > LLVM.
> ymandel@ suggested me removing it as the switch covers all the possible 
> values of the enum.
either seems fine to me (this is just a coding style), I think the problem is 
that we have inconsistencies in the patch - e.g. on Line95, `default: 
llvm_unreachable`, we should stick with one style.



Comment at: clang/lib/ASTMatchers/GtestMatchers.cpp:104
+static internal::BindableMatcher
+gtestComparisonInternal(MacroType Macro, GtestCmp Cmp, StatementMatcher Left,
+StatementMatcher Right) {

hokein wrote:
> As the function creates an AST matcher to match the gtest method, 'd rename 
> the function name like `gtestComparisonIMatcher`, the same to following 
> functions.
this comment seems undone.


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

https://reviews.llvm.org/D103195

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