[PATCH] D93008: [clang][cli] Do not marshall only CC1Option flags in BoolOption

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: dexonsmith, Bigcheese.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

We cannot be sure whether a flag is CC1Option inside the definition of 
BoolOption. This occurs when CC1Option is added like so:

  let Flags = [CC1Option] in {
defm xxx : BoolOption<...>;
  }

because the `let yyy in {...}` is applied after all the xxx record is fully 
declared.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93008

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -173,10 +173,10 @@
 
 // Marshalling info for booleans. Applied to the flag setting keypath to false.
 class MarshallingInfoBooleanFlag
+ code other_value, code other_name>
   : MarshallingInfoFlag {
   code Normalizer = "makeBooleanOptionNormalizer("#value#", "#other_value#", OPT_"#other_name#")";
-  code Denormalizer = "makeBooleanOptionDenormalizer("#value#", \""#other_spelling#"\")";
+  code Denormalizer = "makeBooleanOptionDenormalizer("#value#")";
 }
 
 // Mixins for additional marshalling attributes.
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -233,6 +233,55 @@
   Not(Contains(StrEq("-fexperimental-new-pass-manager";
 }
 
+// Boolean option that gets the CC1Option flag from a let statement (which
+// happens applied **after** the record is defined):
+//
+//   let Flags = [CC1Option] in {
+// defm option : BoolOption<...>;
+//   }
+
+TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().DebugPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdebug-pass-manager";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
+}
+
+TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentPos) {
+  const char *Args[] = {"-fdebug-pass-manager"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().DebugPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdebug-pass-manager")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
+}
+
+TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNeg) {
+  const char *Args[] = {"-fno-debug-pass-manager"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().DebugPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdebug-pass-manager";
+}
+
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
   const char *Args[] = {"-fmodules-strict-context-hash"};
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -197,12 +197,11 @@
   };
 }
 
-static auto makeBooleanOptionDenormalizer(bool Value,
-  const char *OtherSpelling) {
-  return [Value, OtherSpelling](
- SmallVectorImpl &Args, const char *Spelling,
- CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
-Args.push_back(KeyPath == Value ? Spelling : OtherSpelling);
+static auto makeBooleanOptionDenormalizer(bool Value) {
+  return [Value](SmallVectorImpl &Args, const char *Spelling,
+ CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
+if (KeyPath == Value)
+  Args.push_back(Spelling);
   };
 }
 
@@ -853,10 +852,6 @@
 }
   }
 
-  Opts.DebugPassManager =
-  Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
-   /* Default */ false);
-
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
 if (Name == "Accelerate")
Index: clang/include/clang/Driver/Options.td
=

[PATCH] D92969: [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

2020-12-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/AST/ExprConstant.cpp:5147
+  EvaluateDependentExpr(RetExpr, Info);
+  return ESR_Failed;
+}

this deserves a comment: // We know we returned, but we don't know what the 
value is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92969

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


[PATCH] D92996: [VE] Remove -faddrsig and -fnoaddrsig tests

2020-12-10 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Thank you for additional suggestions.  I'll make next patch like "optimize 
ve-toolchain.c and .cpp."  Thank you so much!




Comment at: clang/test/Driver/ve-toolchain.cpp:72
 
 // RUN: %clangxx -### -target ve %s 2>&1 | FileCheck 
-check-prefix=DEFINITARRAY %s
 // DEFINITARRAY: clang{{.*}} "-cc1"

MaskRay wrote:
> Most newer toolchains default to -fuse-init-array. There is probably very 
> little value testing -f[no-]use-init-array
That's make sense.  I'll remove that in next patch.



Comment at: clang/test/Driver/ve-toolchain.cpp:112
 
 // RUN: %clangxx -### -target ve --stdlib=c++ %s 2>&1 | \
 // RUN:FileCheck -check-prefix=LINK %s

MaskRay wrote:
> Such tests should use `--sysroot` and a fake tree (see 
> `Inputs/basic_*_tree`), otherwise clang may find the toolchain under /usr
Thanks!  I'll try to add that one too in next patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92996

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


[PATCH] D92837: [X86] Support tilezero intrinsic and c interface for AMX.

2020-12-10 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 310786.
LuoYuanke added a comment.

Address Pengfei's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92837

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86PreTileConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll

Index: llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+amx-tile -verify-machineinstrs | FileCheck %s
+
+define void @test_amx(i8* %pointer, i8* %base, i64 %stride) {
+; CHECK-LABEL: test_amx:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:movb $1, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $8, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $8, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $8, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $8, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $8, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $8, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:ldtilecfg -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $8, %ax
+; CHECK-NEXT:tilezero %tmm0
+; CHECK-NEXT:tileloadd (%rsi,%rdx), %tmm1
+; CHECK-NEXT:tileloadd (%rsi,%rdx), %tmm2
+; CHECK-NEXT:tdpbssd %tmm2, %tmm1, %tmm0
+; CHECK-NEXT:tilestored %tmm0, (%rdi,%rdx)
+; CHECK-NEXT:tilerelease
+; CHECK-NEXT:retq
+  %c = call x86_amx @llvm.x86.tilezero.internal(i16 8, i16 8)
+  %a = call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 8, i8* %base, i64 %stride)
+  %b = call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 8, i8* %base, i64 %stride)
+  %d = call x86_amx @llvm.x86.tdpbssd.internal(i16 8, i16 8, i16 8, x86_amx %c, x86_amx %a, x86_amx %b)
+  call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* %pointer, i64 %stride, x86_amx %d)
+
+  ret void
+}
+
+declare x86_amx @llvm.x86.tilezero.internal(i16, i16)
+declare x86_amx @llvm.x86.tileloadd64.internal(i16, i16, i8*, i64)
+declare x86_amx @llvm.x86.tdpbssd.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
+declare void @llvm.x86.tilestored64.internal(i16, i16, i8*, i64, x86_amx)
Index: llvm/lib/Target/X86/X86RegisterInfo.td
===
--- llvm/lib/Target/X86/X86RegisterInfo.td
+++ llvm/lib/Target/X86/X86RegisterInfo.td
@@ -639,7 +639,7 @@
 let CopyCost = -1 in // Don't allow copying of tile registers
 def TILE : RegisterClass<"X86", [x86amx], 8192,
  (sequence "TMM%u", 0, 7)> {let Size = 8192;}
-def TILECFG : RegisterClass<"X86", [v512i1], 512, (add TMMCFG)> {
+def TILECFG : RegisterClass<"X86", [untyped], 512, (add TMMCFG)> {
   let CopyCost = -1;  // Don't allow copying of tile config registers.
   let isAllocatable = 1;
   let Size = 512;
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
===
--- llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -873,6 +873,7 @@
   // We only collect the tile shape that is defined.
   case X86::PTILELOADDV:
   case X86::PTDPBSSDV:
+  case X86::PTILEZEROV:
 MachineOperand &MO1 = MI->getOperand(1);
 MachineOperand &MO2 = MI->getOperand(2);
 ShapeT Shape(&MO1, &MO2, MRI);
Index: llvm/lib/Target/X86/X86PreTileConfig.cpp
===
--- llvm/lib/Target/X86/X86PreTileConfig.cpp
+++ llvm/lib/Target/X86/X86PreTileConfig.cpp
@@ -132,6 +132,7 @@
 llvm_unreachable("Unexpected machine instruction on tile");
   case X86::PTILELOADDV:
   case X86::PTDPBSSDV:
+  case X86::PTILEZEROV:
 MachineOperand &MO1 = const_cast(MI.getOperand(1));
 MachineOperand &MO2 = const_cast(MI.getOperand(2));
 ShapeT Shape(&MO1, &MO2, MRI);
@@ -230,6 +231,7 @@
   case X86::PTILELOADDV:
   case X86::PTILESTOREDV:
   case X86::PTDPBSSDV:
+  case X86::PTILEZEROV:
 unsigned NumOperands = MI.getNumOperands();
 MI.RemoveOperand(NumOperands - 1);
 MI.addOperand(MF, MachineOperand::CreateReg(CFG, false));
Index: llvm/lib/Target/X86/X86InstrAMX.td
===
--- llvm/lib/Target/X86/X86InstrAMX.td
+++ llvm/lib/Target/X86/X86InstrAMX.td
@@ -62,6 +62,9 @@
 def PTILESTOREDV : PseudoI<(outs), (ins GR16:$src1,
 GR16:$src2, opaquemem:$src3,
 TILE:$src4, TILECFG:$cfg), []>;
+def PTILEZEROV : 

[clang] a053929 - [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

2020-12-10 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-12-10T10:12:15+01:00
New Revision: a0539298540e49cb734c7b82f93572ab46bf9b00

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

LOG: [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

When the evaluator encounters an error-dependent returnstmt, before this patch
it returned a ESR_Returned without setting the result, the callsides think this
is a successful execution, and try to access the Result which causes the crash.

The fix is to always return failed as we don't know the result of the
error-dependent return stmt.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constexpr-function-recovery-crash.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fc1d2cd7757e..0865b8b85138 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5142,8 +5142,11 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, 
EvalInfo &Info,
   case Stmt::ReturnStmtClass: {
 const Expr *RetExpr = cast(S)->getRetValue();
 FullExpressionRAII Scope(Info);
-if (RetExpr && RetExpr->isValueDependent())
-  return EvaluateDependentExpr(RetExpr, Info) ? ESR_Returned : ESR_Failed;
+if (RetExpr && RetExpr->isValueDependent()) {
+  EvaluateDependentExpr(RetExpr, Info);
+  // We know we returned, but we don't know what the value is.
+  return ESR_Failed;
+}
 if (RetExpr &&
 !(Result.Slot
   ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)

diff  --git a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp 
b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
index 48a0d97619e4..94be9a12bc66 100644
--- a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
+++ b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -66,3 +66,6 @@ template constexpr int f(int y) { // expected-note 
{{candidate template i
 constexpr int test9(int x) {
   return f<1>(f(1)); // expected-error {{no matching function for call to 
'f'}}
 }
+
+constexpr int test10() { return undef(); } // expected-error {{use of 
undeclared identifier 'undef'}}
+static_assert(test10() <= 1, "should not crash"); // expected-error 
{{static_assert expression is not an integral constant expression}}



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


[PATCH] D92969: [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

2020-12-10 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rGa0539298540e: [AST] Fix a constexpr-evaluator crash on 
error-dependent returnstmt. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D92969?vs=310651&id=310791#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92969

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp


Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -66,3 +66,6 @@
 constexpr int test9(int x) {
   return f<1>(f(1)); // expected-error {{no matching function for call to 
'f'}}
 }
+
+constexpr int test10() { return undef(); } // expected-error {{use of 
undeclared identifier 'undef'}}
+static_assert(test10() <= 1, "should not crash"); // expected-error 
{{static_assert expression is not an integral constant expression}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5142,8 +5142,11 @@
   case Stmt::ReturnStmtClass: {
 const Expr *RetExpr = cast(S)->getRetValue();
 FullExpressionRAII Scope(Info);
-if (RetExpr && RetExpr->isValueDependent())
-  return EvaluateDependentExpr(RetExpr, Info) ? ESR_Returned : ESR_Failed;
+if (RetExpr && RetExpr->isValueDependent()) {
+  EvaluateDependentExpr(RetExpr, Info);
+  // We know we returned, but we don't know what the value is.
+  return ESR_Failed;
+}
 if (RetExpr &&
 !(Result.Slot
   ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)


Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -66,3 +66,6 @@
 constexpr int test9(int x) {
   return f<1>(f(1)); // expected-error {{no matching function for call to 'f'}}
 }
+
+constexpr int test10() { return undef(); } // expected-error {{use of undeclared identifier 'undef'}}
+static_assert(test10() <= 1, "should not crash"); // expected-error {{static_assert expression is not an integral constant expression}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5142,8 +5142,11 @@
   case Stmt::ReturnStmtClass: {
 const Expr *RetExpr = cast(S)->getRetValue();
 FullExpressionRAII Scope(Info);
-if (RetExpr && RetExpr->isValueDependent())
-  return EvaluateDependentExpr(RetExpr, Info) ? ESR_Returned : ESR_Failed;
+if (RetExpr && RetExpr->isValueDependent()) {
+  EvaluateDependentExpr(RetExpr, Info);
+  // We know we returned, but we don't know what the value is.
+  return ESR_Failed;
+}
 if (RetExpr &&
 !(Result.Slot
   ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93008: [clang][cli] Do not marshall only CC1Option flags in BoolOption

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 310792.
jansvoboda11 added a comment.

Fix comment typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93008

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -173,10 +173,10 @@
 
 // Marshalling info for booleans. Applied to the flag setting keypath to false.
 class MarshallingInfoBooleanFlag
+ code other_value, code other_name>
   : MarshallingInfoFlag {
   code Normalizer = "makeBooleanOptionNormalizer("#value#", "#other_value#", OPT_"#other_name#")";
-  code Denormalizer = "makeBooleanOptionDenormalizer("#value#", \""#other_spelling#"\")";
+  code Denormalizer = "makeBooleanOptionDenormalizer("#value#")";
 }
 
 // Mixins for additional marshalling attributes.
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -233,6 +233,55 @@
   Not(Contains(StrEq("-fexperimental-new-pass-manager";
 }
 
+// Boolean option that gets the CC1Option flag from a let statement (which
+// is applied **after** the record is defined):
+//
+//   let Flags = [CC1Option] in {
+// defm option : BoolOption<...>;
+//   }
+
+TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().DebugPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdebug-pass-manager";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
+}
+
+TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentPos) {
+  const char *Args[] = {"-fdebug-pass-manager"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().DebugPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdebug-pass-manager")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
+}
+
+TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNeg) {
+  const char *Args[] = {"-fno-debug-pass-manager"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().DebugPassManager);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdebug-pass-manager";
+}
+
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
   const char *Args[] = {"-fmodules-strict-context-hash"};
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -197,12 +197,11 @@
   };
 }
 
-static auto makeBooleanOptionDenormalizer(bool Value,
-  const char *OtherSpelling) {
-  return [Value, OtherSpelling](
- SmallVectorImpl &Args, const char *Spelling,
- CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
-Args.push_back(KeyPath == Value ? Spelling : OtherSpelling);
+static auto makeBooleanOptionDenormalizer(bool Value) {
+  return [Value](SmallVectorImpl &Args, const char *Spelling,
+ CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
+if (KeyPath == Value)
+  Args.push_back(Spelling);
   };
 }
 
@@ -853,10 +852,6 @@
 }
   }
 
-  Opts.DebugPassManager =
-  Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
-   /* Default */ false);
-
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
 if (Name == "Accelerate")
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -325,10 +325,6 @@
   string Spelling
 = prefix#!cond(flag.Polarity.Value : "", true : "no-")#spelling;
 
-  // Does the flag have CC1Option?
-  bit IsCC1 = !not(!empty(!filter(opt_flag, flag.OptionFlags,
-  !eq(opt_flag, CC1Option;
-
   //

[PATCH] D92930: [Clang] Add vcmla and rotated variants for Arm ACLE.

2020-12-10 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 310799.
fhahn added a comment.

Loop over rotation variants.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92930

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-vcmla.c

Index: clang/test/CodeGen/aarch64-neon-vcmla.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-neon-vcmla.c
@@ -0,0 +1,146 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon \
+// RUN:-target-feature +v8.3a \
+// RUN:-target-feature +fullfp16 \
+// RUN:-disable-O0-optnone -emit-llvm -o - %s | opt -S -O1 | FileCheck %s
+#include 
+
+// CHECK-LABEL: @test_vcmla_f16(
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 x half> %acc, <4 x half> %lhs, <4 x half> %rhs)
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_f16(float16x4_t acc, float16x4_t lhs, float16x4_t rhs) {
+  return vcmla_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_f32(
+// CHECK: [[RES:%.*]] = call <2 x float> @llvm.aarch64.neon.vcmla.rot0.v2f32(<2 x float> %acc, <2 x float> %lhs, <2 x float> %rhs)
+// CHECK: ret <2 x float> [[RES]]
+float32x2_t test_vcmla_f32(float32x2_t acc, float32x2_t lhs, float32x2_t rhs) {
+  return vcmla_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_f16(
+// CHECK: [[RES:%.*]] = call <8 x half> @llvm.aarch64.neon.vcmla.rot0.v8f16(<8 x half> %acc, <8 x half> %lhs, <8 x half> %rhs)
+// CHECK: ret <8 x half> [[RES]]
+float16x8_t test_vcmlaq_f16(float16x8_t acc, float16x8_t lhs, float16x8_t rhs) {
+  return vcmlaq_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_f32(
+// CHECK: [[RES:%.*]] = call <4 x float> @llvm.aarch64.neon.vcmla.rot0.v4f32(<4 x float> %acc, <4 x float> %lhs, <4 x float> %rhs)
+// CHECK: ret <4 x float> [[RES]]
+float32x4_t test_vcmlaq_f32(float32x4_t acc, float32x4_t lhs, float32x4_t rhs) {
+  return vcmlaq_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_f64(
+// CHECK: [[RES:%.*]] = call <2 x double> @llvm.aarch64.neon.vcmla.rot0.v2f64(<2 x double> %acc, <2 x double> %lhs, <2 x double> %rhs)
+// CHECK: ret <2 x double> [[RES]]
+float64x2_t test_vcmlaq_f64(float64x2_t acc, float64x2_t lhs, float64x2_t rhs) {
+  return vcmlaq_f64(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_rot90_f16(
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot90.v4f16(<4 x half> %acc, <4 x half> %lhs, <4 x half> %rhs)
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_rot90_f16(float16x4_t acc, float16x4_t lhs, float16x4_t rhs) {
+  return vcmla_rot90_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_rot90_f32(
+// CHECK: [[RES:%.*]] = call <2 x float> @llvm.aarch64.neon.vcmla.rot90.v2f32(<2 x float> %acc, <2 x float> %lhs, <2 x float> %rhs)
+// CHECK: ret <2 x float> [[RES]]
+float32x2_t test_vcmla_rot90_f32(float32x2_t acc, float32x2_t lhs, float32x2_t rhs) {
+  return vcmla_rot90_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_rot90_f16(
+// CHECK: [[RES:%.*]] = call <8 x half> @llvm.aarch64.neon.vcmla.rot90.v8f16(<8 x half> %acc, <8 x half> %lhs, <8 x half> %rhs)
+// CHECK: ret <8 x half> [[RES]]
+float16x8_t test_vcmlaq_rot90_f16(float16x8_t acc, float16x8_t lhs, float16x8_t rhs) {
+  return vcmlaq_rot90_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_rot90_f32(
+// CHECK: [[RES:%.*]] = call <4 x float> @llvm.aarch64.neon.vcmla.rot90.v4f32(<4 x float> %acc, <4 x float> %lhs, <4 x float> %rhs)
+// CHECK: ret <4 x float> [[RES]]
+float32x4_t test_vcmlaq_rot90_f32(float32x4_t acc, float32x4_t lhs, float32x4_t rhs) {
+  return vcmlaq_rot90_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_rot90_f64(
+// CHECK: [[RES:%.*]] = call <2 x double> @llvm.aarch64.neon.vcmla.rot90.v2f64(<2 x double> %acc, <2 x double> %lhs, <2 x double> %rhs)
+// CHECK: ret <2 x double> [[RES]]
+float64x2_t test_vcmlaq_rot90_f64(float64x2_t acc, float64x2_t lhs, float64x2_t rhs) {
+  return vcmlaq_rot90_f64(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_rot180_f16(
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot180.v4f16(<4 x half> %acc, <4 x half> %lhs, <4 x half> %rhs)
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_rot180_f16(float16x4_t acc, float16x4_t lhs, float16x4_t rhs) {
+  return vcmla_rot180_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_rot180_f32(
+// CHECK: [[RES:%.*]] = call <2 x float> @llvm.aarch64.neon.vcmla.rot180.v2f32(<2 x float> %acc, <2 x float> %lhs, <2 x float> %rhs)
+// CHECK: ret <2 x float> [[RES]]
+float32x2_t test_vcmla_rot180_f32(float32x2_t acc, float32x2_t lhs, float32x2_t rhs) {
+  return vcmla_rot180_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_rot180_f16(
+// CHECK: [[RES:%.*]] = call <8 x half> @llvm.aarch64.neon.vcmla.rot180.v8f16(<8 x half> %acc, 

[PATCH] D91927: [X86] Add x86_amx type for intel AMX.

2020-12-10 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 310800.
LuoYuanke added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

Files:
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/utils/TableGen/CodeGenTarget.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -248,7 +248,8 @@
   IIT_V128 = 47,
   IIT_BF16 = 48,
   IIT_STRUCT9 = 49,
-  IIT_V256 = 50
+  IIT_V256 = 50,
+  IIT_AMX  = 51
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -276,6 +277,7 @@
   case MVT::token: return Sig.push_back(IIT_TOKEN);
   case MVT::Metadata: return Sig.push_back(IIT_METADATA);
   case MVT::x86mmx: return Sig.push_back(IIT_MMX);
+  case MVT::x86amx: return Sig.push_back(IIT_AMX);
   // MVT::OtherVT is used to mean the empty struct type here.
   case MVT::Other: return Sig.push_back(IIT_EMPTYSTRUCT);
   // MVT::isVoid is used to represent varargs here.
Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -76,6 +76,7 @@
   case MVT::f128: return "MVT::f128";
   case MVT::ppcf128:  return "MVT::ppcf128";
   case MVT::x86mmx:   return "MVT::x86mmx";
+  case MVT::x86amx:   return "MVT::x86amx";
   case MVT::Glue: return "MVT::Glue";
   case MVT::isVoid:   return "MVT::isVoid";
   case MVT::v1i1: return "MVT::v1i1";
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -8,18 +8,104 @@
 @buf = dso_local global [1024 x i8] zeroinitializer, align 16
 @buf2 = dso_local global [1024 x i8] zeroinitializer, align 16
 
+define dso_local void @test_amx_store(<256 x i32>* %in, i16 %m, i16 %n, i8 *%buf, i64 %s) #2 {
+; CHECK-LABEL: @test_amx_store(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[T0:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[M:%.*]], i16 [[N:%.*]], i8* [[BUF:%.*]], i64 [[S:%.*]]) [[ATTR3:#.*]]
+; CHECK-NEXT:[[ADDR:%.*]] = bitcast <256 x i32>* [[IN:%.*]] to x86_amx*
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast x86_amx* [[ADDR]] to i8*
+; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[M]], i16 [[N]], i8* [[TMP0]], i64 64, x86_amx [[T0]])
+; CHECK-NEXT:ret void
+;
+entry:
+  %t0 = call x86_amx @llvm.x86.tileloadd64.internal(i16 %m, i16 %n, i8* %buf, i64 %s) #3
+  %addr = bitcast <256 x i32>* %in to x86_amx*
+  store x86_amx %t0, x86_amx* %addr, align 64
+  ret void
+}
+
+define dso_local void @test_amx_load(<256 x i32>* %in, i16 %m, i16 %n, i8 *%buf, i64 %s) #2 {
+; CHECK-LABEL: @test_amx_load(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[T0:%.*]] = bitcast <256 x i32>* [[IN:%.*]] to x86_amx*
+; CHECK-NEXT:[[TMP0:%.*]] = bitcast x86_amx* [[T0]] to i8*
+; CHECK-NEXT:[[TMP1:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[M:%.*]], i16 [[N:%.*]], i8* [[TMP0]], i64 64)
+; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[M]], i16 [[N]], i8* [[BUF:%.*]], i64 [[S:%.*]], x86_amx [[TMP1]]) [[ATTR3]]
+; CHECK-NEXT:ret void
+;
+entry:
+  %t0 = bitcast <256 x i32>* %in to x86_amx*
+  %t1 = load x86_amx, x86_amx* %t0, align 64
+  call void @llvm.x86.tilestored64.internal(i16 %m, i16 %n, i8* %buf, i64 %s, x86_amx %t1) #3
+  ret void
+}
+
+; test bitcast x86_amx to <256 x i32>
+define dso_local void @test_user_empty(i16 %m, i16 %n, i8 *%buf, i64 %s) #2 {
+; CHECK-LABEL: @test_user_empty(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[T1:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[M:%.*

[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-10 Thread sameeran joshi via Phabricator via cfe-commits
sameeranjoshi added a comment.

Thanks for patch, a few queries below.

Are the tests in clang which are related to flang failing at 
https://reviews.llvm.org/B81474?




Comment at: flang/include/flang/Frontend/FrontendActions.h:29
 
+class SyntaxOnlyAction : public FrontendAction {
+  void ExecuteAction() override;

Do you think following a pattern here for mapping with `enum ActionKind` would 
be better?
something like `ParseSyntaxOnlyAction` ?



Comment at: flang/include/flang/Frontend/FrontendOptions.h:1
 //===- FrontendOptions.h *- C -*-===//
 //

C++ ?



Comment at: flang/lib/Frontend/FrontendActions.cpp:96
+  semantics.EmitMessages(ci.semaOutputStream());
+}

What happens in case one of the stages in the pipeline fails?
Where is the error recovery done for e.g if parsing fails ?



Comment at: flang/unittests/Frontend/PrintPreprocessedTest.cpp:121
+
+  // 4. Executre the ParseSyntaxOnly action
+  bool success = ExecuteCompilerInvocation(&compInst);

Execute


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92854

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


[PATCH] D93014: [Clang] Add AArch64 VCMLA LANE variants.

2020-12-10 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: SjoerdMeijer, dmgreen, t.p.northover.
Herald added subscribers: danielkiss, kristof.beyls.
fhahn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds the LANE variants for VCMLA on AArch64 as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

Based on a patch by Tim Northover.

[1] https://developer.arm.com/documentation/ihi0073/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93014

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/test/CodeGen/aarch64-neon-vcmla.c
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -1690,14 +1690,18 @@
 
 std::pair Intrinsic::DagEmitter::emitDagDupTyped(DagInit *DI) {
   assert_with_loc(DI->getNumArgs() == 2, "dup_typed() expects two arguments");
-  std::pair A =
-  emitDagArg(DI->getArg(0), std::string(DI->getArgNameStr(0)));
   std::pair B =
   emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
   assert_with_loc(B.first.isScalar(),
   "dup_typed() requires a scalar as the second argument");
+  Type T;
+  if (StringInit *SI = dyn_cast(DI->getArg(0))) {
+T = Type::fromTypedefName(SI->getAsUnquotedString());
+assert_with_loc(!T.isVoid(), "Unknown typedef");
+  } else
+T = emitDagArg(DI->getArg(0), std::string(DI->getArgNameStr(0))).first;
 
-  Type T = A.first;
+ 
   assert_with_loc(T.isVector(), "dup_typed() used but target type is scalar!");
   std::string S = "(" + T.str() + ") {";
   for (unsigned I = 0; I < T.getNumElements(); ++I) {
Index: clang/test/CodeGen/aarch64-neon-vcmla.c
===
--- clang/test/CodeGen/aarch64-neon-vcmla.c
+++ clang/test/CodeGen/aarch64-neon-vcmla.c
@@ -144,3 +144,83 @@
 float64x2_t test_vcmlaq_rot270_f64(float64x2_t acc, float64x2_t lhs, float64x2_t rhs) {
   return vcmlaq_rot270_f64(acc, lhs, rhs);
 }
+
+// CHECK-LABEL: @test_vcmla_lane_f16(
+// CHECK: [[CPLX:%.*]] = bitcast <4 x half> %rhs to <2 x i32>
+// CHECK: [[DUP:%.*]] = shufflevector <2 x i32> [[CPLX]], <2 x i32> undef, <2 x i32> 
+// CHECK: [[DUP_FLT:%.*]] = bitcast <2 x i32> [[DUP]] to <4 x half>
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 x half> %acc, <4 x half> %lhs, <4 x half> [[DUP_FLT]])
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_lane_f16(float16x4_t acc, float16x4_t lhs, float16x4_t rhs) {
+  return vcmla_lane_f16(acc, lhs, rhs, 1);
+}
+
+// ACLE says this exists, but it won't map to a single instruction if lane > 1.
+// CHECK-LABEL: @test_vcmla_laneq_f16(
+// CHECK: [[CPLX:%.*]] = bitcast <8 x half> %rhs to <4 x i32>
+// CHECK: [[DUP:%.*]] = shufflevector <4 x i32> [[CPLX]], <4 x i32> undef, <2 x i32> 
+// CHECK: [[DUP_FLT:%.*]] = bitcast <2 x i32> [[DUP]] to <4 x half>
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 x half> %acc, <4 x half> %lhs, <4 x half> [[DUP_FLT]])
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_laneq_f16(float16x4_t acc, float16x4_t lhs, float16x8_t rhs) {
+  return vcmla_laneq_f16(acc, lhs, rhs, 3);
+}
+
+// CHECK-LABEL: @test_vcmlaq_lane_f16(
+// CHECK: [[CPLX:%.*]] = bitcast <4 x half> %rhs to <2 x i32>
+// CHECK: [[DUP:%.*]] = shufflevector <2 x i32> [[CPLX]], <2 x i32> undef, <4 x i32> 
+// CHECK: [[DUP_FLT:%.*]] = bitcast <4 x i32> [[DUP]] to <8 x half>
+// CHECK: [[RES:%.*]] = call <8 x half> @llvm.aarch64.neon.vcmla.rot0.v8f16(<8 x half> %acc, <8 x half> %lhs, <8 x half> [[DUP_FLT]])
+// CHECK: ret <8 x half> [[RES]]
+float16x8_t test_vcmlaq_lane_f16(float16x8_t acc, float16x8_t lhs, float16x4_t rhs) {
+  return vcmlaq_lane_f16(acc, lhs, rhs, 1);
+}
+
+// CHECK-LABEL: @test_vcmlaq_laneq_f16(
+// CHECK: [[CPLX:%.*]] = bitcast <8 x half> %rhs to <4 x i32>
+// CHECK: [[DUP:%.*]] = shufflevector <4 x i32> [[CPLX]], <4 x i32> undef, <4 x i32> 
+// CHECK: [[DUP_FLT:%.*]] = bitcast <4 x i32> [[DUP]] to <8 x half>
+// CHECK: [[RES:%.*]] = call <8 x half> @llvm.aarch64.neon.vcmla.rot0.v8f16(<8 x half> %acc, <8 x half> %lhs, <8 x half> [[DUP_FLT]])
+// CHECK: ret <8 x half> [[RES]]
+float16x8_t test_vcmlaq_laneq_f16(float16x8_t acc, float16x8_t lhs, float16x8_t rhs) {
+  return vcmlaq_laneq_f16(acc, lhs, rhs, 3);
+}
+
+// CHECK-LABEL: @test_vcmla_lane_f32(
+// CHECK: [[RES:%.*]] = call <2 x float> @llvm.aarch64.neon.vcmla.rot0.v2f32(<2 x float> %acc, <2 x float> %lhs, <2 x float> %rhs)
+// CHECK: ret <2 x float> [[RES]]
+float32x2_t test_vcmla_lane_f32(float32x2_t acc, float32x2_t lhs, float32x2_t rhs) {
+  return vcmla_lane_f32(acc, lhs, rhs, 0);
+}
+
+// ACLE says this exists, but it won't map to a single instruction if lane > 1.
+// CHECK-LABEL: @test_vcmla_laneq_f32(
+// CHECK: [[CPLX:%.*]] = bitcast <4 x 

[PATCH] D93017: [AMDGPU] Add missing targets to amdgpu-features.cl

2020-12-10 Thread Tony Tye via Phabricator via cfe-commits
t-tye created this revision.
t-tye added a reviewer: kzhuravl.
Herald added subscribers: kerbowa, tpr, dstuttard, yaxunl, nhaehnle, jvesely.
t-tye requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93017

Files:
  clang/test/CodeGenOpenCL/amdgpu-features.cl


Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -7,7 +7,18 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx602 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX602 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx700 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX700 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx701 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX701 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx702 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX702 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx703 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX703 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx704 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX704 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx705 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX705 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx801 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX801 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx802 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX802 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx803 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX803 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx805 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX805 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx810 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX810 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx900 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX900 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx902 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX902 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx904 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX904 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx906 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX906 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx908 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX908 %s


Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -7,7 +7,18 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX601 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx602 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX602 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx700 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX700 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx701 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX701 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx702 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX702 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx703 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX703 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx704 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX704 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx705 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX705 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx801 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX801 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx802 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX802 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx803 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX803 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx805 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX805 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx810 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX810 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx900 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX900 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx902 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX902 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx904 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX904 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx906 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX906 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx908 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX908 %s
___
cfe-commits m

[PATCH] D93018: [AMDGPU] Add missing targets to target-invalid-cpu-note.c

2020-12-10 Thread Tony Tye via Phabricator via cfe-commits
t-tye created this revision.
t-tye added a reviewer: kzhuravl.
Herald added subscribers: tpr, dstuttard, yaxunl.
t-tye requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93018

Files:
  clang/test/Misc/target-invalid-cpu-note.c


Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -73,9 +73,9 @@
 
 // RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix R600
 // R600: error: unknown target CPU 'not-a-cpu'
-// R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780, 
-// R600-SAME: rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar, 
-// R600-SAME: palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts, 
+// R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780,
+// R600-SAME: rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar,
+// R600-SAME: palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts,
 // R600-SAME: caicos, aruba, cayman, turks
 
 
@@ -83,9 +83,11 @@
 // AMDGCN: error: unknown target CPU 'not-a-cpu'
 // AMDGCN: note: valid target CPU values are: gfx600, tahiti, gfx601, 
pitcairn, verde,
 // AMDGCN-SAME: gfx602, hainan, oland, gfx700, kaveri, gfx701, hawaii, gfx702,
-// AMDGCN-SAME: gfx703, kabini, mullins, gfx704, bonaire, gfx705, gfx801, 
carrizo, 
+// AMDGCN-SAME: gfx703, kabini, mullins, gfx704, bonaire, gfx705, gfx801, 
carrizo,
 // AMDGCN-SAME: gfx802, iceland, tonga, gfx803, fiji, polaris10, polaris11,
-// AMDGCN-SAME: gfx805, tongapro, gfx810, stoney, gfx900, gfx902
+// AMDGCN-SAME: gfx805, tongapro, gfx810, stoney, gfx900, gfx902, gfx904, 
gfx906,
+// AMDGCN-SAME: gfx908, gfx909, gfx90c, gfx1010, gfx1011, gfx1012, gfx1030, 
gfx1031,
+// AMDGCN-SAME: gfx1032, gfx1033
 
 // RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix WEBASM
 // WEBASM: error: unknown target CPU 'not-a-cpu'


Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -73,9 +73,9 @@
 
 // RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600
 // R600: error: unknown target CPU 'not-a-cpu'
-// R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780, 
-// R600-SAME: rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar, 
-// R600-SAME: palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts, 
+// R600: note: valid target CPU values are: r600, rv630, rv635, r630, rs780,
+// R600-SAME: rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar,
+// R600-SAME: palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts,
 // R600-SAME: caicos, aruba, cayman, turks
 
 
@@ -83,9 +83,11 @@
 // AMDGCN: error: unknown target CPU 'not-a-cpu'
 // AMDGCN: note: valid target CPU values are: gfx600, tahiti, gfx601, pitcairn, verde,
 // AMDGCN-SAME: gfx602, hainan, oland, gfx700, kaveri, gfx701, hawaii, gfx702,
-// AMDGCN-SAME: gfx703, kabini, mullins, gfx704, bonaire, gfx705, gfx801, carrizo, 
+// AMDGCN-SAME: gfx703, kabini, mullins, gfx704, bonaire, gfx705, gfx801, carrizo,
 // AMDGCN-SAME: gfx802, iceland, tonga, gfx803, fiji, polaris10, polaris11,
-// AMDGCN-SAME: gfx805, tongapro, gfx810, stoney, gfx900, gfx902
+// AMDGCN-SAME: gfx805, tongapro, gfx810, stoney, gfx900, gfx902, gfx904, gfx906,
+// AMDGCN-SAME: gfx908, gfx909, gfx90c, gfx1010, gfx1011, gfx1012, gfx1030, gfx1031,
+// AMDGCN-SAME: gfx1032, gfx1033
 
 // RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix WEBASM
 // WEBASM: error: unknown target CPU 'not-a-cpu'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-10 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
Herald added a subscriber: rnkovacs.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

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


[PATCH] D92990: [clangd] Provide suggestions with invalid config keys

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 310814.
njames93 added a comment.

Fix lit test failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92990

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/test/config.test
  clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -113,7 +113,7 @@
 
   ASSERT_THAT(
   Diags.Diagnostics,
-  ElementsAre(AllOf(DiagMessage("Unknown If key UnknownCondition"),
+  ElementsAre(AllOf(DiagMessage("Unknown If key 'UnknownCondition'"),
 DiagKind(llvm::SourceMgr::DK_Warning),
 DiagPos(YAML.range("unknown").start),
 DiagRange(YAML.range("unknown"))),
Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -79,6 +79,12 @@
   Unknown: 42
 )yaml";
 
+const char *AddFooWithTypoErr = R"yaml(
+CompileFlags:
+  Add: foo
+  Removr: 42
+)yaml";
+
 const char *AddBarBaz = R"yaml(
 CompileFlags:
   Add: bar
@@ -95,7 +101,7 @@
   auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
   auto Cfg = P->getConfig(Params(), Diags.callback());
   EXPECT_THAT(Diags.Diagnostics,
-  ElementsAre(DiagMessage("Unknown CompileFlags key Unknown")));
+  ElementsAre(DiagMessage("Unknown CompileFlags key 'Unknown'")));
   EXPECT_THAT(Diags.Files, ElementsAre(testPath("foo.yaml")));
   EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
   Diags.clear();
@@ -105,6 +111,16 @@
   EXPECT_THAT(Diags.Files, IsEmpty());
   EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
 
+  FS.Files["foo.yaml"] = AddFooWithTypoErr;
+  Cfg = P->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  ElementsAre(DiagMessage(
+  "Unknown CompileFlags key 'Removr'; did you mean 'Remove'?")));
+  EXPECT_THAT(Diags.Files, ElementsAre(testPath("foo.yaml")));
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
+  Diags.clear();
+
   FS.Files["foo.yaml"] = AddBarBaz;
   Cfg = P->getConfig(Params(), Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "New config, no errors";
@@ -143,7 +159,7 @@
 
   Cfg = P->getConfig(ABCParams, Diags.callback());
   EXPECT_THAT(Diags.Diagnostics,
-  ElementsAre(DiagMessage("Unknown CompileFlags key Unknown")));
+  ElementsAre(DiagMessage("Unknown CompileFlags key 'Unknown'")));
   // FIXME: fails on windows: paths have mixed slashes like C:\a/b\c.yaml
   EXPECT_THAT(Diags.Files,
   ElementsAre(testPath("a/foo.yaml"), testPath("a/b/c/foo.yaml")));
@@ -178,7 +194,7 @@
   FS.Files["foo.yaml"] = AddFooWithErr;
   auto Cfg = P->getConfig(StaleOK, Diags.callback());
   EXPECT_THAT(Diags.Diagnostics,
-  ElementsAre(DiagMessage("Unknown CompileFlags key Unknown")));
+  ElementsAre(DiagMessage("Unknown CompileFlags key 'Unknown'")));
   EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
   Diags.clear();
 
Index: clang-tools-extra/clangd/test/config.test
===
--- clang-tools-extra/clangd/test/config.test
+++ clang-tools-extra/clangd/test/config.test
@@ -19,7 +19,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"message": "Unknown Config key Foo",
+# CHECK-NEXT:"message": "Unknown Config key 'Foo'",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
 # CHECK-NEXT:"character": 3,
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -167,6 +167,7 @@
 return;
   }
   llvm::SmallSet Seen;
+  llvm::SmallVector, 0> UnknownKeys;
   // We *must* consume all items, even on error, or the parser will assert.
   for (auto &KV : llvm::cast(N)) {
 auto *K = KV.getKey();
@@ -198,9 +199,62 @@
 Warn = UnknownHandler(
 Located(**Key, K->getSourceRange()), *Value);
   if (Warn)
-Outer->warning("Unknown " + Description + " key " + **Key, *K);
+UnknownKeys.push_back(std::move(*Key));
 }
   }
+  if (!UnknownKeys.empty())
+warnUnknownKeys(UnknownKeys, getUnseenKeys(Seen));
+}
+
+  private:
+llvm::SmallVector
+getUnseenKeys(const ll

[clang] 254677e - [clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks text

2020-12-10 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-12-10T11:06:48Z
New Revision: 254677e9ed4e705c1138166dc8053edad8ee7ed3

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

LOG: [clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks 
text

Fix spelling mistake
Leave space after `.` and before beginning of next sentence
Reword it slightly to try and make it more readable.
Ensure RST is updated correctly (it generated a change)

Reviewed By: HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Tooling/Inclusions/IncludeStyle.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 55d706fe..239c9177bec2 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1713,11 +1713,11 @@ the configuration (without a prefix: ``Auto``).
   always need to be first.
 
   There is a third and optional field ``SortPriority`` which can used while
-  ``IncludeBloks = IBS_Regroup`` to define the priority in which ``#includes``
-  should be ordered, and value of ``Priority`` defines the order of
-  ``#include blocks`` and also enables to group ``#includes`` of 
diff erent
-  priority for order.``SortPriority`` is set to the value of ``Priority``
-  as default if it is not assigned.
+  ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  ``#includes`` should be ordered. The value of ``Priority`` defines the
+  order of ``#include blocks`` and also allows the grouping of ``#includes``
+  of 
diff erent priority. ``SortPriority`` is set to the value of
+  ``Priority`` as default if it is not assigned.
 
   Each regular expression can be marked as case sensitive with the field
   ``CaseSensitive``, per default it is not.

diff  --git a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h 
b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
index 89b0d4635251..4caaf4121f15 100644
--- a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -89,12 +89,11 @@ struct IncludeStyle {
   /// always need to be first.
   ///
   /// There is a third and optional field ``SortPriority`` which can used while
-  /// ``IncludeBloks = IBS_Regroup`` to define the priority in which
-  /// ``#includes`` should be ordered, and value of ``Priority`` defines the
-  /// order of
-  /// ``#include blocks`` and also enables to group ``#includes`` of 
diff erent
-  /// priority for order.``SortPriority`` is set to the value of ``Priority``
-  /// as default if it is not assigned.
+  /// ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  /// ``#includes`` should be ordered. The value of ``Priority`` defines the
+  /// order of ``#include blocks`` and also allows the grouping of 
``#includes``
+  /// of 
diff erent priority. ``SortPriority`` is set to the value of
+  /// ``Priority`` as default if it is not assigned.
   ///
   /// Each regular expression can be marked as case sensitive with the field
   /// ``CaseSensitive``, per default it is not.



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


[PATCH] D92822: [clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks text

2020-12-10 Thread MyDeveloperDay 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 rG254677e9ed4e: [clang-format] [NFC] Fix spelling and 
grammatical errors in IncludeBlocks text (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92822

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Tooling/Inclusions/IncludeStyle.h


Index: clang/include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -89,12 +89,11 @@
   /// always need to be first.
   ///
   /// There is a third and optional field ``SortPriority`` which can used while
-  /// ``IncludeBloks = IBS_Regroup`` to define the priority in which
-  /// ``#includes`` should be ordered, and value of ``Priority`` defines the
-  /// order of
-  /// ``#include blocks`` and also enables to group ``#includes`` of different
-  /// priority for order.``SortPriority`` is set to the value of ``Priority``
-  /// as default if it is not assigned.
+  /// ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  /// ``#includes`` should be ordered. The value of ``Priority`` defines the
+  /// order of ``#include blocks`` and also allows the grouping of 
``#includes``
+  /// of different priority. ``SortPriority`` is set to the value of
+  /// ``Priority`` as default if it is not assigned.
   ///
   /// Each regular expression can be marked as case sensitive with the field
   /// ``CaseSensitive``, per default it is not.
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1713,11 +1713,11 @@
   always need to be first.
 
   There is a third and optional field ``SortPriority`` which can used while
-  ``IncludeBloks = IBS_Regroup`` to define the priority in which ``#includes``
-  should be ordered, and value of ``Priority`` defines the order of
-  ``#include blocks`` and also enables to group ``#includes`` of different
-  priority for order.``SortPriority`` is set to the value of ``Priority``
-  as default if it is not assigned.
+  ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  ``#includes`` should be ordered. The value of ``Priority`` defines the
+  order of ``#include blocks`` and also allows the grouping of ``#includes``
+  of different priority. ``SortPriority`` is set to the value of
+  ``Priority`` as default if it is not assigned.
 
   Each regular expression can be marked as case sensitive with the field
   ``CaseSensitive``, per default it is not.


Index: clang/include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -89,12 +89,11 @@
   /// always need to be first.
   ///
   /// There is a third and optional field ``SortPriority`` which can used while
-  /// ``IncludeBloks = IBS_Regroup`` to define the priority in which
-  /// ``#includes`` should be ordered, and value of ``Priority`` defines the
-  /// order of
-  /// ``#include blocks`` and also enables to group ``#includes`` of different
-  /// priority for order.``SortPriority`` is set to the value of ``Priority``
-  /// as default if it is not assigned.
+  /// ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  /// ``#includes`` should be ordered. The value of ``Priority`` defines the
+  /// order of ``#include blocks`` and also allows the grouping of ``#includes``
+  /// of different priority. ``SortPriority`` is set to the value of
+  /// ``Priority`` as default if it is not assigned.
   ///
   /// Each regular expression can be marked as case sensitive with the field
   /// ``CaseSensitive``, per default it is not.
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1713,11 +1713,11 @@
   always need to be first.
 
   There is a third and optional field ``SortPriority`` which can used while
-  ``IncludeBloks = IBS_Regroup`` to define the priority in which ``#includes``
-  should be ordered, and value of ``Priority`` defines the order of
-  ``#include blocks`` and also enables to group ``#includes`` of different
-  priority for order.``SortPriority`` is set to the value of ``Priority``
-  as default if it is not assigned.
+  ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  ``#includes`` should be ordered. The value of ``Priority`` defines the
+  order of ``#include blocks`` and also allows the grouping of ``#in

[clang] 7b2d62f - [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-10 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-12-10T11:13:22Z
New Revision: 7b2d62fd7f7befda2ce327d25075b0aac9bc6780

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

LOG: [clang-format] PR42434 Remove preprocessor and pragma lines from 
ObjectiveC guess

clang-format see the `disable:` in   __pragma(warning(disable:)) as ObjectiveC 
method call

Remove any line starting with `#` or __pragma line from being part of the 
ObjectiveC guess

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

Reviewed By: curdeius, krasimir

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a3f740ff8692..4263f7b47e7c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First && (Line->First->TokenText.startswith("#") ||
+  Line->First->TokenText == "__pragma" ||
+  Line->First->TokenText == "_Pragma"))
+continue;
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e897402e502a..d3ea5c2b5880 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@ TEST_F(FormatTest, GuessLanguageWithCaret) {
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:



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


[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-10 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b2d62fd7f7b: [clang-format] PR42434 Remove preprocessor and 
pragma lines from ObjectiveC… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92922

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First && (Line->First->TokenText.startswith("#") ||
+  Line->First->TokenText == "__pragma" ||
+  Line->First->TokenText == "_Pragma"))
+continue;
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First && (Line->First->TokenText.startswith("#") ||
+  Line->First->TokenText == "__pragma" ||
+  Line->First->TokenText == "_Pragma"))
+continue;
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92753: [clang-format] Add IndentPragma style to eliminate common clang-format off scenario

2020-12-10 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
MyDeveloperDay marked an inline comment as done.
Closed by commit rGe9e6e3b34a8e: [clang-format] Add IndentPragma style to 
eliminate common clang-format off… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92753

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14116,6 +14116,7 @@
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL(IndentPragmas);
   CHECK_PARSE_BOOL(IndentRequires);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
@@ -17571,6 +17572,129 @@
"struct constant;",
Style);
 }
+
+TEST_F(FormatTest, IndentPragmas) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_None;
+
+  Style.IndentPragmas = false;
+  verifyFormat("#pragma once", Style);
+  verifyFormat("#pragma omp simd\n"
+   "for (int i = 0; i < 10; i++) {\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "#pragma omp simd\n"
+   "  for (int i = 0; i < 10; i++) {\n"
+   "  }\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "// outer loop\n"
+   "#pragma omp simd\n"
+   "  for (int k = 0; k < 10; k++) {\n"
+   "// inner loop\n"
+   "#pragma omp simd\n"
+   "for (int j = 0; j < 10; j++) {\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  verifyFormat("void foo() {\n"
+   "// outer loop\n"
+   "#if 1\n"
+   "#pragma omp simd\n"
+   "  for (int k = 0; k < 10; k++) {\n"
+   "// inner loop\n"
+   "#pragma omp simd\n"
+   "for (int j = 0; j < 10; j++) {\n"
+   "}\n"
+   "  }\n"
+   "#endif\n"
+   "}",
+   Style);
+
+  Style.IndentPragmas = true;
+  verifyFormat("#pragma once", Style);
+  verifyFormat("#pragma omp simd\n"
+   "for (int i = 0; i < 10; i++) {\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  #pragma omp simd\n"
+   "  for (int i = 0; i < 10; i++) {\n"
+   "  }\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  #pragma omp simd\n"
+   "  for (int i = 0; i < 10; i++) {\n"
+   "#pragma omp simd\n"
+   "for (int j = 0; j < 10; j++) {\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  verifyFormat("void foo() {\n"
+   "  #pragma omp simd\n"
+   "  for (...) {\n"
+   "#pragma omp simd\n"
+   "for (...) {\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+
+  verifyFormat("void foo() {\n"
+   "# pragma omp simd\n"
+   "  for (int i = 0; i < 10; i++) {\n"
+   "#   pragma omp simd\n"
+   "for (int j = 0; j < 10; j++) {\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  verifyFormat("void foo() {\n"
+   "#if 1\n"
+   "# pragma omp simd\n"
+   "  for (int k = 0; k < 10; k++) {\n"
+   "#   pragma omp simd\n"
+   "for (int j = 0; j < 10; j++) {\n"
+   "}\n"
+   "  }\n"
+   "#endif\n"
+   "}",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_BeforeHash;
+  EXPECT_EQ("void foo() {\n"
+"#if 1\n"
+"  #pragma omp simd\n"
+"  for (int k = 0; k < 10; k++) {\n"
+"#pragma omp simd\n"
+"for (int j = 0; j < 10; j++) {\n"
+"}\n"
+"  }\n"
+"#endif\n"
+"}",
+format("void foo() {\n"
+   "#if 1\n"
+   "  #pragma omp simd\n"
+   "  for (int k = 0; k < 10; k++) {\n"
+   "#pragm

[clang] e9e6e3b - [clang-format] Add IndentPragma style to eliminate common clang-format off scenario

2020-12-10 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-12-10T11:17:33Z
New Revision: e9e6e3b34a8e0857a274df51aac27e88c1de402b

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

LOG: [clang-format] Add IndentPragma style to eliminate common clang-format off 
scenario

A quick search of github.com, shows one common scenario for excessive use of 
//clang-format off/on is the indentation of #pragma's, especially around the 
areas of loop optimization or OpenMP

This revision aims to help that by introducing an `IndentPragmas` style, the 
aim of which is to keep the pragma at the current level of scope

```
for (int i = 0; i < 5; i++) {
// clang-format off
#pragma HLS UNROLL
// clang-format on
for (int j = 0; j < 5; j++) {
// clang-format off
#pragma HLS UNROLL
// clang-format on
 
```

can become

```
for (int i = 0; i < 5; i++) {
#pragma HLS UNROLL
for (int j = 0; j < 5; j++) {
#pragma HLS UNROLL

```

This revision also support working alongside the `IndentPPDirective` of 
`BeforeHash` and `AfterHash` (see unit tests for examples)

Reviewed By: curdeius

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 239c9177bec2..f63ed168f099 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1917,6 +1917,30 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+**IndentPragmas** (``bool``)
+  Indent pragmas
+
+  When ``false``, pragmas are flushed left or follow IndentPPDirectives.
+  When ``true``, pragmas are indented to the current scope level.
+
+  .. code-block:: c++
+
+false:  true:
+#pragma once   vs   #pragma once
+void foo() {void foo() {
+#pragma omp simd  #pragma omp simd
+  for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+#pragma omp simd#pragma omp simd
+for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+}   }
+#if 1   #if 1
+#pragma omp simd#pragma omp simd
+for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+}   }
+#endif  #endif
+  }   }
+}   }
+
 **IndentRequires** (``bool``)
   Indent the requires clause in a template
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6e304630fbdc..d8ed27687b63 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1528,6 +1528,29 @@ struct FormatStyle {
   /// \endcode
   bool IndentGotoLabels;
 
+  /// Indent pragmas
+  ///
+  /// When ``false``, pragmas are flushed left or follow IndentPPDirectives.
+  /// When ``true``, pragmas are indented to the current scope level.
+  /// \code
+  ///   false:  true:
+  ///   #pragma once   vs   #pragma once
+  ///   void foo() {void foo() {
+  ///   #pragma omp simd  #pragma omp simd
+  /// for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+  ///   #pragma omp simd#pragma omp simd
+  ///   for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+  ///   }   }
+  ///   #if 1   #if 1
+  ///   #pragma omp simd#pragma omp simd
+  ///   for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+  ///   }   }
+  ///   #endif  #endif
+  /// }   }
+  ///   }   }
+  /// \endcode
+  bool IndentPragmas;
+
   /// Options for indenting preprocessor directives.
   enum PPDirectiveIndentStyle {
 /// Does not indent any directives.
@@ -2494,6 +2517,7 @@ struct FormatStyle {
IndentCaseLabels == R.IndentCaseLabels &&
  

[PATCH] D92221: Don't delete default constructor of PathDiagnosticConsumerOptions

2020-12-10 Thread Moritz Sichert via Phabricator via cfe-commits
MoritzS added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92221

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


[clang] 95616a0 - [clang-format] NFC Add release note for IndentPragmas

2020-12-10 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-12-10T11:24:12Z
New Revision: 95616a033c16146b55352c5fb93af82e00422920

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

LOG: [clang-format] NFC Add release note for IndentPragmas

Add additional release note to announce new clang-format option added during 
{D92753}

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7d68cdb99b48..ef7903e16f7f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -272,13 +272,15 @@ clang-format
 };
 
 
-- Experimental Support in clang-format for concepts has been improved, to 
+- Experimental Support in clang-format for concepts has been improved, to
   aid this the follow options have been added
 
 - Option ``IndentRequires`` has been added to indent the ``requires`` keyword
   in templates.
 - Option ``BreakBeforeConceptDeclarations`` has been added to aid the 
formatting of concepts.
 
+- Option ``IndentPragmas`` has been added to allow #pragma to indented with 
the current scope level. This is especially useful when using #pragma to mark 
OpenMP sections of code.
+
 
 libclang
 



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


[PATCH] D92990: [clangd] Provide suggestions with invalid config keys

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Adding in support for fix-its(at least in vscode) didn't seem to work. The 
language server there doesn't seem to send the `textDocument/codeAction` 
message to the server for the `.clangd` file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92990

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


[clang-tools-extra] bedf3a0 - [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-12-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-10T11:34:57Z
New Revision: bedf3a0f507113bb09acaa317c533d85fe52518a

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

LOG: [clang-tidy][NFC] Use moves instead of copies when constructing 
OptionsProviders.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 950a64f4c274..1de1b1baccb5 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -195,14 +195,13 @@ DefaultOptionsProvider::getRawOptions(llvm::StringRef 
FileName) {
 }
 
 ConfigOptionsProvider::ConfigOptionsProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &ConfigOptions,
-const ClangTidyOptions &OverrideOptions,
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions ConfigOptions, ClangTidyOptions OverrideOptions,
 llvm::IntrusiveRefCntPtr FS)
-: FileOptionsBaseProvider(GlobalOptions, DefaultOptions, OverrideOptions,
-  FS),
-  ConfigOptions(ConfigOptions) {}
+: FileOptionsBaseProvider(std::move(GlobalOptions),
+  std::move(DefaultOptions),
+  std::move(OverrideOptions), std::move(FS)),
+  ConfigOptions(std::move(ConfigOptions)) {}
 
 std::vector
 ConfigOptionsProvider::getRawOptions(llvm::StringRef FileName) {
@@ -227,24 +226,25 @@ ConfigOptionsProvider::getRawOptions(llvm::StringRef 
FileName) {
 }
 
 FileOptionsBaseProvider::FileOptionsBaseProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions OverrideOptions,
 llvm::IntrusiveRefCntPtr VFS)
-: DefaultOptionsProvider(GlobalOptions, DefaultOptions),
-  OverrideOptions(OverrideOptions), FS(std::move(VFS)) {
+: DefaultOptionsProvider(std::move(GlobalOptions),
+ std::move(DefaultOptions)),
+  OverrideOptions(std::move(OverrideOptions)), FS(std::move(VFS)) {
   if (!FS)
 FS = llvm::vfs::getRealFileSystem();
   ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration);
 }
 
 FileOptionsBaseProvider::FileOptionsBaseProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
-const FileOptionsBaseProvider::ConfigFileHandlers &ConfigHandlers)
-: DefaultOptionsProvider(GlobalOptions, DefaultOptions),
-  OverrideOptions(OverrideOptions), ConfigHandlers(ConfigHandlers) {}
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions OverrideOptions,
+FileOptionsBaseProvider::ConfigFileHandlers ConfigHandlers)
+: DefaultOptionsProvider(std::move(GlobalOptions),
+ std::move(DefaultOptions)),
+  OverrideOptions(std::move(OverrideOptions)),
+  ConfigHandlers(std::move(ConfigHandlers)) {}
 
 void FileOptionsBaseProvider::addRawFileOptions(
 llvm::StringRef AbsolutePath, std::vector &CurOptions) {
@@ -286,20 +286,20 @@ void FileOptionsBaseProvider::addRawFileOptions(
 }
 
 FileOptionsProvider::FileOptionsProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions OverrideOptions,
 llvm::IntrusiveRefCntPtr VFS)
-: FileOptionsBaseProvider(GlobalOptions, DefaultOptions, OverrideOptions,
-  VFS){}
+: FileOptionsBaseProvider(std::move(GlobalOptions),
+  std::move(DefaultOptions),
+  std::move(OverrideOptions), std::move(VFS)) {}
 
 FileOptionsProvider::FileOptionsProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
-const FileOptionsBaseProvider::ConfigFileHandlers &ConfigHandlers)
-: FileOptionsBaseProvider(GlobalOptions, DefaultOptions, OverrideOptions,
-  ConfigHandlers) {}
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions Overr

[PATCH] D92267: [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbedf3a0f5071: [clang-tidy][NFC] Use moves instead of copies 
when constructing… (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92267

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -318,9 +318,9 @@
 parseConfiguration(Configuration);
 if (ParsedConfig)
   return std::make_unique(
-  GlobalOptions,
+  std::move(GlobalOptions),
   ClangTidyOptions::getDefaults().merge(DefaultOptions, 0),
-  *ParsedConfig, OverrideOptions, std::move(FS));
+  std::move(*ParsedConfig), std::move(OverrideOptions), std::move(FS));
 llvm::errs() << "Error: invalid configuration specified.\n"
  << ParsedConfig.getError().message() << "\n";
 return nullptr;
@@ -347,8 +347,9 @@
   if (Config.getNumOccurrences() > 0)
 return LoadConfig(Config);
 
-  return std::make_unique(GlobalOptions, DefaultOptions,
-OverrideOptions, std::move(FS));
+  return std::make_unique(
+  std::move(GlobalOptions), std::move(DefaultOptions),
+  std::move(OverrideOptions), std::move(FS));
 }
 
 llvm::IntrusiveRefCntPtr
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -173,9 +173,10 @@
 /// returns the same options for all files.
 class DefaultOptionsProvider : public ClangTidyOptionsProvider {
 public:
-  DefaultOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions,
- const ClangTidyOptions &Options)
-  : GlobalOptions(GlobalOptions), DefaultOptions(Options) {}
+  DefaultOptionsProvider(ClangTidyGlobalOptions GlobalOptions,
+ ClangTidyOptions Options)
+  : GlobalOptions(std::move(GlobalOptions)),
+DefaultOptions(std::move(Options)) {}
   const ClangTidyGlobalOptions &getGlobalOptions() override {
 return GlobalOptions;
   }
@@ -187,7 +188,7 @@
 };
 
 class FileOptionsBaseProvider : public DefaultOptionsProvider {
-public:
+protected:
   // A pair of configuration file base name and a function parsing
   // configuration from text in the corresponding format.
   typedef std::pair(
@@ -213,16 +214,15 @@
   /// take precedence over ".clang-tidy" if both reside in the same directory.
   typedef std::vector ConfigFileHandlers;
 
-  FileOptionsBaseProvider(
-  const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &OverrideOptions,
-  llvm::IntrusiveRefCntPtr FS = nullptr);
+  FileOptionsBaseProvider(ClangTidyGlobalOptions GlobalOptions,
+  ClangTidyOptions DefaultOptions,
+  ClangTidyOptions OverrideOptions,
+  llvm::IntrusiveRefCntPtr FS);
 
-  FileOptionsBaseProvider(const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &OverrideOptions,
-  const ConfigFileHandlers &ConfigHandlers);
+  FileOptionsBaseProvider(ClangTidyGlobalOptions GlobalOptions,
+  ClangTidyOptions DefaultOptions,
+  ClangTidyOptions OverrideOptions,
+  ConfigFileHandlers ConfigHandlers);
 
 protected:
   void addRawFileOptions(llvm::StringRef AbsolutePath,
@@ -243,10 +243,8 @@
 class ConfigOptionsProvider : public FileOptionsBaseProvider {
 public:
   ConfigOptionsProvider(
-  const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &ConfigOptions,
-  const ClangTidyOptions &OverrideOptions,
+  ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+  ClangTidyOptions ConfigOptions, ClangTidyOptions OverrideOptions,
   llvm::IntrusiveRefCntPtr FS = nullptr);
   std::vector getRawOptions(llvm::StringRef FileName) override;
 
@@ -275,9 +273,8 @@
   /// If any of the \param OverrideOptions fields are set, they will override
   /// whatever options are read from the configuration file.
   FileOptionsProvider(
-  const ClangTidyGlobalOptions &GlobalOptions,
-  const ClangTidyOptions &DefaultOptions,
-  const ClangTidyOptions &OverrideOptions,
+  

[PATCH] D88394: [Driver][M68k] (Patch 8/8) Add driver support for M68k

2020-12-10 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.

LGTM too, thanks!


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

https://reviews.llvm.org/D88394

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


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-10 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM created this revision.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
MarkMurrayARM requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch upstreams support for the Arm-v8 Cortex-A78C
processor for AArch64 and ARM.

In detail:

- Adding cortex-a78c as cpu option for aarch64 and arm targets in clang
- Adding Cortex-A78C CPU name and ProcessorModel in llvm

Details of the CPU can be found here:
https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93022

Files:
  clang/test/Driver/aarch64-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ARMBuildAttributes.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 
 using namespace llvm;
@@ -40,10 +41,19 @@
   pass &= ARM::getFPUName(FPUKind).equals(ExpectedFPU);
 
   uint64_t ExtKind = ARM::getDefaultExtensions(CPUName, AK);
-  if (ExtKind > 1 && (ExtKind & ARM::AEK_NONE))
+  if (ExtKind > 1 && (ExtKind & ARM::AEK_NONE)) {
 pass &= ((ExtKind ^ ARM::AEK_NONE) == ExpectedFlags);
-  else
+if (!pass)
+  std::cout << "ExpectedFlags = 0x" << std::hex << ExpectedFlags
+<< " do not equal ExtKind = 0x" << std::hex << ExtKind
+<< "in the ARM::AEK_NONE case. " << std::endl;
+  }
+  else {
 pass &= (ExtKind == ExpectedFlags);
+if (!pass)
+  std::cout << "ExpectedFlags = 0x" << std::hex << ExpectedFlags
+<< " do not equal ExtKind = 0x" << std::hex << ExtKind << std::endl;
+  }
   pass &= ARM::getCPUAttr(AK).equals(CPUAttr);
 
   return pass;
@@ -268,6 +278,13 @@
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
  ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_SEC | ARM::AEK_MP |
+ ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
+ ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+
   EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
  ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
  ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
@@ -334,7 +351,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 91;
+static constexpr unsigned NumARMCPUArchs = 92;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -800,11 +817,20 @@
   bool pass = AArch64::getArchName(AK).equals(ExpectedArch);
 
   uint64_t ExtKind = AArch64::getDefaultExtensions(CPUName, AK);
-  if (ExtKind > 1 && (ExtKind & AArch64::AEK_NONE))
+  if (ExtKind > 1 && (ExtKind & AArch64::AEK_NONE)) {
 pass &= ((ExtKind ^ AArch64::AEK_NONE) == ExpectedFlags);
-  else
+if (!pass)
+  std::cout << "ExpectedFlags = 0x" << std::hex << ExpectedFlags
+<< " do not equal ExtKind = 0x" << std::hex << ExtKind
+<< "in the ARM::AEK_NONE case. " << std::endl;
+  }
+  else {
 pass &= (ExtKind == ExpectedFlags);
-
+if (!pass) {
+  std::cout << "ExpectedFlags = 0x" << std::hex << ExpectedFlags
+<< " do not equal ExtKind = 0x" << std::hex << ExtKind << std::endl;
+}
+  }
   pass &= AArch64::getCPUAttr(AK).equals(CPUAttr);
 
   return pass;
@@ -893,6 +919,12 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS,
   "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_RAS | AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+  AArch64::AEK_FP | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_RDM,
+  "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
   "neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
   AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
@@ -1063,7 +1095,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 45;
+static constexpr unsigned NumAArch64CPUArchs = 46;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/ARM/ARMSubtarget.h
=

[PATCH] D93023: Replace deprecated %T in 2 tests.

2020-12-10 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added a reviewer: MaskRay.
abidh added a project: clang.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, lenary, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.
abidh requested review of this revision.
Herald added a subscriber: cfe-commits.

In D91442 , @MaskRay commented about a failure 
that he is seeing. As per his suggestion, I have replaced %T with %t. Patterns 
needs a little adjustment to match this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93023

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,25 +11,25 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv64-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/testroot-riscv64-baremetal-nogcc/bin
+// RUN: ln -s %clang %t/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%t/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%t/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: %t/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN:--gcc-toolchain=%t/testroot-riscv64-baremetal-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN: %t/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,25 +11,25 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-/

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-12-10 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2444399 , @MaskRay wrote:

> This change has been failing on my machine for the past two weeks.
>
> `riscv32-toolchain-extra.c` and `riscv64-toolchain-extra.c` are not hermit. I 
> have installed `/usr/lib/gcc-cross/riscv64-linux-gnu/10` 
> (gcc-10-riscv64-linux-gnu and its dependencies) on my machine and the test 
> will find some directories relative to 
> `/usr/lib/gcc-cross/riscv64-linux-gnu/10`. I think `--sysroot` is required 
> for such tests.
>
> `%T` is a deprecated lit feature. Please do something like `rm -rf %t; mkdir 
> %t` instead.

Hi MaskRay,
Thanks for reporting this issue. I don't fully understand how test is finding 
directories relative to some other location. But I have opened 
https://reviews.llvm.org/D93023 to replace %T with %t as you suggested. Please 
have a look and see if this fixes your issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91442

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


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-10 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: llvm/unittests/Support/TargetParserTest.cpp:833
+}
+  }
   pass &= AArch64::getCPUAttr(AK).equals(CPUAttr);

I assume this was left in from debugging, if not it should be its own change.
(considering this file is already using gtest, you could refactor to ASSERT_EQ 
the flags and get the messages for free)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-10 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:673-686
+def ProcA78C : SubtargetFeature<"cortex-a78c", "ARMProcFamily",
+"CortexA78C",
+"Cortex-A78C ARM processors", [
+HasV8_2aOps,
+FeatureCrypto,
+FeatureFPARMv8,
+FeatureFuseAES,

According to the TRM at https://developer.arm.com/documentation/102226/0001 
Cortex-A78C also supports Pointer Authetication and the Flag Manipulation 
instructions as well (CFINV, RMIF etc). I think this feature set doesn't 
reflect that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: llvm/unittests/Support/TargetParserTest.cpp:47
+if (!pass)
+  std::cout << "ExpectedFlags = 0x" << std::hex << ExpectedFlags
+<< " do not equal ExtKind = 0x" << std::hex << ExtKind

I suggest using LLVM I/O facilities instead of std::cout and stderr instead of 
stdout. E.g.
```
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Format.h"
//...
errs() << "ExpectedFlags = " << format_hex(ExpectedFlags, 8) <<
//...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


[PATCH] D92986: [clangd][NFC] Remove unnecessary vector.

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

Ah, I see now, thanks for the follow-up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92986

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


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TestTU.cpp:190
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
+  llvm::SmallVector Components;
   QName.split(Components, "::");

kbobyrev wrote:
> njames93 wrote:
> > A follow up refractor, this doesn't strictly need to be stored in a vector. 
> Could you please elaborate? I don't really understand this comment.
(D92986 for context)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[clang-tools-extra] ee02e20 - [clangd] NFC: Use SmallVector where possible

2020-12-10 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-12-10T13:36:49+01:00
New Revision: ee02e20c0817745c47ea9be8e26e9a49afc9a7fd

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

LOG: [clangd] NFC: Use SmallVector where possible

SmallVector with default size is now the recommended version (D92522).

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/FileDistance.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Markup.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
clang-tools-extra/clangd/unittests/TestIndex.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index d1702b2d25b6..d3615e23b0d6 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -258,7 +258,7 @@ std::string printTemplateSpecializationArgs(const NamedDecl 
&ND) {
   // TemplateArgumentTypeLocs, they only have TemplateArgumentTypes. So we
   // create a new argument location list from TypeSourceInfo.
   auto STL = TSI->getTypeLoc().getAs();
-  llvm::SmallVector ArgLocs;
+  llvm::SmallVector ArgLocs;
   ArgLocs.reserve(STL.getNumArgs());
   for (unsigned I = 0; I < STL.getNumArgs(); ++I)
 ArgLocs.push_back(STL.getArgLoc(I));

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f6210a43b34e..96cbd8806ff6 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -367,7 +367,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
 for (unsigned ID = 1 /*Skip INVALID */; ID < DriverID::LastOption; ++ID) {
   if (PrevAlias[ID] || ID == DriverID::OPT_Xclang)
 continue; // Not canonical, or specially handled.
-  llvm::SmallVector Rules;
+  llvm::SmallVector Rules;
   // Iterate over each alias, to add rules for parsing it.
   for (unsigned A = ID; A != DriverID::OPT_INVALID; A = NextAlias[A]) {
 if (Prefixes[A] == nullptr) // option groups.

diff  --git a/clang-tools-extra/clangd/CompileCommands.h 
b/clang-tools-extra/clangd/CompileCommands.h
index 3efd80026cf6..2ba17a0e6c0d 100644
--- a/clang-tools-extra/clangd/CompileCommands.h
+++ b/clang-tools-extra/clangd/CompileCommands.h
@@ -92,7 +92,7 @@ class ArgStripper {
   static llvm::ArrayRef rulesFor(llvm::StringRef Arg);
   const Rule *matchingRule(llvm::StringRef Arg, unsigned Mode,
unsigned &ArgCount) const;
-  llvm::SmallVector Rules;
+  llvm::SmallVector Rules;
   std::deque Storage; // Store strings not found in option table.
 };
 

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 846c6a170b38..b1189e286826 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -137,7 +137,7 @@ struct FragmentCompiler {
 llvm::StringRef EnumName;
 const Located &Input;
 llvm::Optional Result;
-llvm::SmallVector ValidValues;
+llvm::SmallVector ValidValues;
 
   public:
 EnumSwitch(llvm::StringRef EnumName, const Located &In,

diff  --git a/clang-tools-extra/clangd/FileDistance.cpp 
b/clang-tools-extra/clangd/FileDistance.cpp
index 584c64d077e1..e1cead329189 100644
--- a/clang-tools-extra/clangd/FileDistance.cpp
+++ b/clang-tools-extra/clangd/FileDistance.cpp
@@ -58,8 +58,7 @@ const llvm::hash_code FileDistance::RootHash =
 FileDistance::FileDistance(llvm::StringMap Sources,
const FileDistanceOptions &Opts)
 : Opts(Opts) {
-  llvm::DenseMap>
-  DownEdges;
+  llvm::DenseMap> 
DownEdges;
   // Compute the best distance following only up edges.
   // Keep track of down edges, in case we can use them to improve on this.
   for (const auto &S : Sources) {
@@ -118,7 +117,7 @@ File

[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-10 Thread Kirill Bobyrev 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 rGee02e20c0817: [clangd] NFC: Use SmallVector where 
possible (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/FileDistance.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/support/Markup.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang-tools-extra/clangd/unittests/TestIndex.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Index: clang-tools-extra/clangd/unittests/support/TraceTests.cpp
===
--- clang-tools-extra/clangd/unittests/support/TraceTests.cpp
+++ clang-tools-extra/clangd/unittests/support/TraceTests.cpp
@@ -154,7 +154,7 @@
   std::vector outputLines() {
 // Deliberately don't flush output stream, the tracer should do that.
 // This is important when clangd crashes.
-llvm::SmallVector Lines;
+llvm::SmallVector Lines;
 llvm::StringRef(Output).split(Lines, "\r\n");
 return {Lines.begin(), Lines.end()};
   }
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,7 +187,7 @@
 }
 
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
+  llvm::SmallVector Components;
   QName.split(Components, "::");
 
   auto &Ctx = AST.getASTContext();
Index: clang-tools-extra/clangd/unittests/TestIndex.cpp
===
--- clang-tools-extra/clangd/unittests/TestIndex.cpp
+++ clang-tools-extra/clangd/unittests/TestIndex.cpp
@@ -29,7 +29,7 @@
 
 static std::string replace(llvm::StringRef Haystack, llvm::StringRef Needle,
llvm::StringRef Repl) {
-  llvm::SmallVector Parts;
+  llvm::SmallVector Parts;
   Haystack.split(Parts, Needle);
   return llvm::join(Parts, Repl);
 }
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -208,7 +208,7 @@
 }
 
 static std::string strip(llvm::StringRef Arg, llvm::StringRef Argv) {
-  llvm::SmallVector Parts;
+  llvm::SmallVector Parts;
   llvm::SplitString(Argv, Parts);
   std::vector Args = {Parts.begin(), Parts.end()};
   ArgStripper S;
Index: clang-tools-extra/clangd/support/Markup.cpp
===
--- clang-tools-extra/clangd/support/Markup.cpp
+++ clang-tools-extra/clangd/support/Markup.cpp
@@ -215,7 +215,7 @@
 
 // Trims the input and concatenates whitespace blocks into a single ` `.
 std::string canonicalizeSpaces(llvm::StringRef Input) {
-  llvm::SmallVector Words;
+  llvm::SmallVector Words;
   llvm::SplitString(Input, Words);
   return llvm::join(Words, " ");
 }
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -202,7 +202,7 @@
 struct ParsedBinaryOperator {
   BinaryOperatorKind Kind;
   SourceLocation ExprLoc;
-  llvm::SmallVector SelectedOperands;
+  llvm::SmallVector SelectedOperands;
 
   // If N is a binary operator, populate this and return true.
   bool parse(const SelectionTree::Node &N) {
Index: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -480,7 +480,7 @@
 const tooling::Replacement DeleteFuncBody(SM, DefRange->getBegin(),
   SourceLen, "");
 
-llvm::SmallVector, 2>

[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

2020-12-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri commandeered this revision.
lebedev.ri edited reviewers, added: nikic; removed: lebedev.ri.
lebedev.ri added a comment.

@mstorsjo please can you be more specific what kind of tests are starting to 
fail?
Do those tests just check that the code compiled into an identical assembly?

I reduced `vc1_block-aarch64.c`, and got:

  ; ModuleID = 'input.ll'
  source_filename = "vc1_block-aarch64.c"
  target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
  target triple = "aarch64-w64-windows-gnu"
  
  define i1 @barney(i8 %arg, i8 %arg9) {
  bb:
%tmp = sext i8 %arg to i32
%tmp10 = icmp slt i32 %tmp, 0
%tmp11 = sub nsw i32 0, %tmp
%tmp12 = select i1 %tmp10, i32 %tmp11, i32 %tmp
%tmp13 = shl nuw nsw i32 %tmp12, 1
%tmp14 = zext i8 %arg9 to i32
%tmp15 = add nuw nsw i32 %tmp13, %tmp14
%tmp16 = icmp slt i32 %tmp15, 2
ret i1 %tmp16
  }
  
  declare i32 @eggs()

which used to get optimized into

  ; ModuleID = ''
  source_filename = "vc1_block-aarch64.c"
  target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
  target triple = "aarch64-w64-windows-gnu"
  
  define i1 @barney(i8 %arg, i8 %arg9) {
  bb:
%tmp = sext i8 %arg to i32
%tmp10 = icmp slt i32 %tmp, 0
%tmp11 = sub nsw i32 0, %tmp
%tmp12 = select i1 %tmp10, i32 %tmp11, i32 %tmp
%tmp13 = shl nuw nsw i32 %tmp12, 1
%tmp14 = zext i8 %arg9 to i32
%tmp15 = add nuw nsw i32 %tmp13, %tmp14
%tmp16 = icmp slt i32 %tmp15, 2
ret i1 %tmp16
  }
  
  declare i32 @eggs()

and is now optimized into

  ; ModuleID = ''
  source_filename = "vc1_block-aarch64.c"
  target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
  target triple = "aarch64-w64-windows-gnu"
  
  define i1 @barney(i8 %arg, i8 %arg9) {
  bb:
%tmp = sext i8 %arg to i32
%0 = call i32 @llvm.abs.i32(i32 %tmp, i1 true)
%tmp13 = shl nuw nsw i32 %0, 1
%tmp14 = zext i8 %arg9 to i32
%tmp15 = add nuw nsw i32 %tmp13, %tmp14
%tmp16 = icmp ult i32 %tmp15, 2
ret i1 %tmp16
  }
  
  declare i32 @eggs()
  
  ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
  declare i32 @llvm.abs.i32(i32, i1 immarg) #0
  
  attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }

which is not a miscompile:

  $ /repositories/alive2/build-Clang-release/alive-tv old.ll new.ll
  
  
  define i1 @barney(i8 %arg, i8 %arg9) {
  %bb:
%tmp = sext i8 %arg to i32
%tmp10 = icmp slt i32 %tmp, 0
%tmp11 = sub nsw i32 0, %tmp
%tmp12 = select i1 %tmp10, i32 %tmp11, i32 %tmp
%tmp13 = shl nsw nuw i32 %tmp12, 1
%tmp14 = zext i8 %arg9 to i32
%tmp15 = add nsw nuw i32 %tmp13, %tmp14
%tmp16 = icmp slt i32 %tmp15, 2
ret i1 %tmp16
  }
  =>
  define i1 @barney(i8 %arg, i8 %arg9) {
  %bb:
%tmp = sext i8 %arg to i32
%0 = abs i32 %tmp, 1
%tmp13 = shl nsw nuw i32 %0, 1
%tmp14 = zext i8 %arg9 to i32
%tmp15 = add nsw nuw i32 %tmp13, %tmp14
%tmp16 = icmp ult i32 %tmp15, 2
ret i1 %tmp16
  }
  Transformation seems to be correct!
  
  Summary:
1 correct transformations
0 incorrect transformations
0 Alive2 errors

The original assembly was:

  .text
  .file   "vc1_block-aarch64.c"
  .def barney;
  .scl2;
  .type   32;
  .endef
  .globl  barney  // -- Begin function barney
  .p2align2
  barney: // @barney
  // %bb.0:   // %bb
  sxtbw8, w0
  cmp w8, #0  // =0
  cnegw8, w8, mi
  lsl w8, w8, #1
  add w8, w8, w1, uxtb
  cmp w8, #2  // =2
  csetw0, lt
  ret
  // -- End function

and new one is

  .text
  .file   "vc1_block-aarch64.c"
  .def barney;
  .scl2;
  .type   32;
  .endef
  .globl  barney  // -- Begin function barney
  .p2align2
  barney: // @barney
  // %bb.0:   // %bb
  sxtbw8, w0
  cmp w8, #0  // =0
  cnegw8, w8, mi
  lsl w8, w8, #1
  add w8, w8, w1, uxtb
  cmp w8, #2  // =2
  csetw0, lo
  ret
  // -- End function

with diff being

  $ diff old.s new.s 
  17c17
  <   csetw0, lt
  ---
  >   csetw0, lo


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

https://reviews.llvm.org/D87188

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


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TestTU.cpp:190
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
+  llvm::SmallVector Components;
   QName.split(Components, "::");

kbobyrev wrote:
> kbobyrev wrote:
> > njames93 wrote:
> > > A follow up refractor, this doesn't strictly need to be stored in a 
> > > vector. 
> > Could you please elaborate? I don't really understand this comment.
> (D92986 for context)
sigh, sorry, I forgot to remove it before pushing :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[PATCH] D93024: [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh.
Herald added subscribers: usaxena95, kadircet, arphaman, xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Using a MemoryBufferRef, If there is an error parsing, we can point the user to 
the location of the file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93024

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -72,10 +72,11 @@
 
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
-  parseConfiguration("Checks: \"-*,misc-*\"\n"
- "HeaderFilterRegex: \".*\"\n"
- "AnalyzeTemporaryDtors: true\n"
- "User: some.user");
+  parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
+   "HeaderFilterRegex: \".*\"\n"
+   "AnalyzeTemporaryDtors: true\n"
+   "User: some.user",
+   "Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
   EXPECT_EQ(".*", *Options->HeaderFilterRegex);
@@ -83,7 +84,8 @@
 }
 
 TEST(ParseConfiguration, MergeConfigurations) {
-  llvm::ErrorOr Options1 = parseConfiguration(R"(
+  llvm::ErrorOr Options1 =
+  parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check1,check2"
   HeaderFilterRegex: "filter1"
   AnalyzeTemporaryDtors: true
@@ -91,9 +93,11 @@
   ExtraArgs: ['arg1', 'arg2']
   ExtraArgsBefore: ['arg-before1', 'arg-before2']
   UseColor: false
-  )");
+  )",
+   "Options1"));
   ASSERT_TRUE(!!Options1);
-  llvm::ErrorOr Options2 = parseConfiguration(R"(
+  llvm::ErrorOr Options2 =
+  parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check3,check4"
   HeaderFilterRegex: "filter2"
   AnalyzeTemporaryDtors: false
@@ -101,7 +105,8 @@
   ExtraArgs: ['arg3', 'arg4']
   ExtraArgsBefore: ['arg-before3', 'arg-before4']
   UseColor: true
-  )");
+  )",
+   "Options2"));
   ASSERT_TRUE(!!Options2);
   ClangTidyOptions Options = Options1->merge(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -41,7 +41,8 @@
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(*Data))
+if (auto Parsed = tidy::parseConfiguration(
+llvm::MemoryBufferRef(*Data, path(
   Value = std::make_shared(
   std::move(*Parsed));
 else
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -312,10 +312,11 @@
   if (UseColor.getNumOccurrences() > 0)
 OverrideOptions.UseColor = UseColor;
 
-  auto LoadConfig = [&](StringRef Configuration)
-  -> std::unique_ptr {
+  auto LoadConfig =
+  [&](StringRef Configuration,
+  StringRef Source) -> std::unique_ptr {
 llvm::ErrorOr ParsedConfig =
-parseConfiguration(Configuration);
+parseConfiguration(MemoryBufferRef(Configuration, Source));
 if (ParsedConfig)
   return std::make_unique(
   std::move(GlobalOptions),
@@ -334,18 +335,18 @@
 }
 
 llvm::ErrorOr> Text =
-llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+llvm::MemoryBuffer::getFile(ConfigFile);
 if (std::error_code EC = Text.getError()) {
   llvm::errs() << "Error: can't read config-file '" << ConfigFile
<< "': " << EC.message() << "\n";
   return nullptr;
 }
 
-return LoadConfig((*Text)->getBuffer());
+return LoadConfig((*Text)->getBuffer(), ConfigFile);
   }
 
   if (Config.getNumOccurrences() > 0)
-return LoadConfig(Config);
+return LoadConfig(Config, "");
 
   return std::make_unique(
   std::move(GlobalOptions), std::move(DefaultOptions),
Index: clang-to

[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D92600#2443716 , @tmroeder wrote:

> @aaron.ballman It looks like those template tests fail on x64 windows; this 
> is a problem that came up with D58292  as 
> well. It ended up getting rolled back because template-based tests failed on 
> windows, and I had to remove the tests and resubmit.
>
> I'm not sure what the right way is to fix these tests: skip them on Windows? 
> If so, then can you please tell me how to do that?

Looking at the changes you made, I'm not certain why one test would work and 
one test would fail -- however, the usual issue with template tests on Windows 
is that the default behavior on Windows is to match the MSVC template behavior 
and so you sometimes need to pass `-fno-delayed-template-parsing` to those 
tests to get the same behavior as on other platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

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


[clang] 2315e98 - [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-10 Thread Peter Waller via cfe-commits

Author: Peter Waller
Date: 2020-12-10T12:43:14Z
New Revision: 2315e9874c92bf625ec84a5f45a4fa28bfbc16ce

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

LOG: [AArch64][Driver][SVE] Push missing SVE feature error from driver to 
frontend

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is 
not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

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

Added: 
clang/test/Sema/arm-vector-types-support.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Driver/aarch64-sve-vector-bits.c

Removed: 
clang/test/Sema/neon-vector-types-support.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8ca176d3bb43..0e85be8f058b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -534,9 +534,6 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' 
along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 
-def err_drv_invalid_sve_vector_bits : Error<
-  "'-msve-vector-bits' is not supported without SVE enabled">;
-
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 97773d35a694..363bcc1d383d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2843,7 +2843,8 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_attribute_unsupported
-: Error<"%0 attribute is not supported for this target">;
+: Error<"%0 attribute is not supported on targets missing %1;"
+" specify an appropriate -march= or -mcpu=">;
 // The err_*_attribute_argument_not_int are separate because they're used by
 // VerifyIntegerConstantExpression.
 def err_aligned_attribute_argument_not_int : Error<

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 0fc531b8c3a0..fca6d95d361b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -381,12 +381,6 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve-vector-bits= flag is valid only if SVE is enabled.
-  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
-if (!HasSve)
-  D.Diag(diag::err_drv_invalid_sve_vector_bits);
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fbdbfbc9f8ec..6485bebc0e8e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7799,7 +7799,8 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7842,7 +7843,7 @@ static void HandleArmSveVectorBitsTypeAttr(QualType 
&CurType, ParsedAttr &Attr,
Sem

[PATCH] D92487: [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-10 Thread Peter Waller 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 rG2315e9874c92: [AArch64][Driver][SVE] Push missing SVE 
feature error from driver to frontend (authored by peterwaller-arm).
Herald added a subscriber: NickHung.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92487

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Driver/aarch64-sve-vector-bits.c
  clang/test/Sema/arm-vector-types-support.c
  clang/test/Sema/neon-vector-types-support.c

Index: clang/test/Sema/neon-vector-types-support.c
===
--- clang/test/Sema/neon-vector-types-support.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
-
-typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported for this target}}
-typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported for this target}}
Index: clang/test/Sema/arm-vector-types-support.c
===
--- /dev/null
+++ clang/test/Sema/arm-vector-types-support.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
+
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}}
Index: clang/test/Driver/aarch64-sve-vector-bits.c
===
--- clang/test/Driver/aarch64-sve-vector-bits.c
+++ clang/test/Driver/aarch64-sve-vector-bits.c
@@ -22,21 +22,6 @@
 // CHECK-2048: "-msve-vector-bits=2048"
 // CHECK-SCALABLE-NOT: "-msve-vector-bits=
 
-// Bail out if -msve-vector-bits is specified without SVE enabled
-// -
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=128 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=256 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=512 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=1024 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=2048 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-
-// CHECK-NO-SVE-ERROR: error: '-msve-vector-bits' is not supported without SVE enabled
-
 // Error out if an unsupported value is passed to -msve-vector-bits.
 // -
 // RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7799,7 +7799,8 @@
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7842,7 +7843,7 @@
Sema &S) {
   // Target must have SVE.
   if (!S.Context.getTargetInfo().hasFeature("sve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr << "'sve'";
 Attr.setInvalid();
 return;
   }
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -381,12 +381,6 @@
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool

[PATCH] D92220: [clangd] Add support for static fields in rename

2020-12-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:630
   )cpp",
+  R"cpp(
+template  struct Foo { static T Variable; };

hokein wrote:
> hmm, looks like these two tests are already working at head (without the 
> patch).
You're right, thanks for spotting it 😆 I'm quite confused, though, I was pretty 
sure it didn't work before. Maybe I did something wrong, I don't know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92220

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


[PATCH] D92715: [Clang][RISCV] Define RISC-V V builtin types

2020-12-10 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D92715#2443376 , @craig.topper 
wrote:

> Can we discuss this patch in tomorrows RISC-V meeting? @jrtc27 @kito-cheng  
> @khchen @liaolucy

I've added it to the agenda


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

https://reviews.llvm.org/D92715

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


[PATCH] D92956: Fix https://bugs.llvm.org/show_bug.cgi?id=48011

2020-12-10 Thread z via Phabricator via cfe-commits
fanfuqiang updated this revision to Diff 310847.
fanfuqiang added a comment.

update testcase take advise of reviewers.
fix conflict testcase fail,  less warnning only for 
`hasNonTrivialCopyConstructor` .


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

https://reviews.llvm.org/D92956

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
  clang/test/SemaCXX/warn-range-loop-analysis.cpp


Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -29,6 +29,13 @@
   operator int();
 };
 
+struct ID1 {
+  // Small trivally copy constructor, but no trivally copy assignment 
+  // operator.
+  ID1(ID1 const&) = default;
+  ID1& operator=(ID1 const& other) { return *this; }
+};
+
 // Testing notes:
 // test0 checks that the full text of the warnings and notes is correct.  The
 //   rest of the tests checks a smaller portion of the text.
@@ -455,6 +462,13 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
 
+void test11() {
+  Container C;
+
+  for (const ID1 x : C) {}
+  // No warning
+}
+
 template 
 void test_template_function() {
   // In a template instantiation the diagnostics should not be emitted for
Index: clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
@@ -55,8 +55,6 @@
 int b;
   };
 
-  // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const 
Record'}}
-  // expected-note@+2 {{use reference type 'const Record &' to prevent 
copying}}
   Record records[8];
   for (const auto r : records)
 (void)r;
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2855,8 +2855,14 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
+  const CXXRecordDecl *ClassDecl = nullptr;
+  if (const auto *RT = VariableType->getAs()) {
+ClassDecl = dyn_cast(RT->getDecl());
+  }
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
+   // Fix https://bugs.llvm.org/show_bug.cgi?id=48011
+   (ClassDecl && !ClassDecl->hasNonTrivialCopyConstructor()) ||
hasTrivialABIAttr(VariableType)))
 return;
 


Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -29,6 +29,13 @@
   operator int();
 };
 
+struct ID1 {
+  // Small trivally copy constructor, but no trivally copy assignment 
+  // operator.
+  ID1(ID1 const&) = default;
+  ID1& operator=(ID1 const& other) { return *this; }
+};
+
 // Testing notes:
 // test0 checks that the full text of the warnings and notes is correct.  The
 //   rest of the tests checks a smaller portion of the text.
@@ -455,6 +462,13 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
 
+void test11() {
+  Container C;
+
+  for (const ID1 x : C) {}
+  // No warning
+}
+
 template 
 void test_template_function() {
   // In a template instantiation the diagnostics should not be emitted for
Index: clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
@@ -55,8 +55,6 @@
 int b;
   };
 
-  // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const Record'}}
-  // expected-note@+2 {{use reference type 'const Record &' to prevent copying}}
   Record records[8];
   for (const auto r : records)
 (void)r;
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2855,8 +2855,14 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
+  const CXXRecordDecl *ClassDecl = nullptr;
+  if (const auto *RT = VariableType->getAs()) {
+ClassDecl = dyn_cast(RT->getDecl());
+  }
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
+   // Fix https://bugs.llvm.org/show_bug.cgi?id=48011
+   (ClassDecl && !ClassDecl->hasNonTrivialCopyConstructor()) ||
hasTrivialABIAttr(Varia

[clang] 99ad078 - [AArch64] Cortex-R82: remove crypto

2020-12-10 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-12-10T12:54:51Z
New Revision: 99ad078b91ed601cd19c75a44106a4f86bfa1a41

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

LOG: [AArch64] Cortex-R82: remove crypto

Remove target features crypto for Cortex-R82, because it doesn't have any, and
add LSE which was missing while we are at it.
This also removes crypto from the v8-R architecture description because that
aligns better with GCC and so far none of the R-cores have implemented crypto,
so is probably a more sensible default.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index fca6d95d361b..13e4cac292d0 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -317,8 +317,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   NoCrypto = true;
   }
 
-  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd ||
-  std::find(ItBegin, ItEnd, "+v8r") != ItEnd) {
+  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd) {
 if (HasCrypto && !NoCrypto) {
   // Check if we have NOT disabled an algorithm with something like:
   //   +crypto, -algorithm

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index f0b01f519a85..178098197d53 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -240,7 +240,7 @@
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" 
"+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" 
"-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
 // CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/include/llvm/Support/AArch64TargetParser.def
index 7625f5a6f6ab..34b6f72d4621 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -51,14 +51,14 @@ AARCH64_ARCH("armv8.6-a", ARMV8_6A, "8.6-A", "v8.6a",
   AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
   AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
   AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM))
+// For v8-R, we do not enable crypto and align with GCC that enables a more
+// minimal set of optional architecture extensions.
 AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r",
  ARMBuildAttrs::CPUArch::v8_R, FK_CRYPTO_NEON_FP_ARMV8,
- (AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS|
-  AArch64::AEK_CRYPTO  | AArch64::AEK_SM4  | AArch64::AEK_SHA3|
-  AArch64::AEK_SHA2| AArch64::AEK_AES  | AArch64::AEK_DOTPROD |
-  AArch64::AEK_FP  | AArch64::AEK_SIMD | AArch64::AEK_FP16|
-  AArch64::AEK_FP16FML | AArch64::AEK_RAS  | AArch64::AEK_RCPC|
-  AArch64::AEK_SB))
+   

[PATCH] D91994: [AArch64] Cortex-R82: remove crypto

2020-12-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99ad078b91ed: [AArch64] Cortex-R82: remove crypto (authored 
by SjoerdMeijer).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91994

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -903,12 +903,11 @@
   "8.4-A"));
   EXPECT_TRUE(testAArch64CPU(
  "cortex-r82", "armv8-r", "crypto-neon-fp-armv8",
-  AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS|
-  AArch64::AEK_CRYPTO  | AArch64::AEK_SM4  | AArch64::AEK_SHA3|
-  AArch64::AEK_SHA2| AArch64::AEK_AES  | AArch64::AEK_DOTPROD |
-  AArch64::AEK_FP  | AArch64::AEK_SIMD | AArch64::AEK_FP16|
-  AArch64::AEK_FP16FML | AArch64::AEK_RAS  | AArch64::AEK_RCPC|
-  AArch64::AEK_SB, "8-R"));
+  AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS |
+  AArch64::AEK_DOTPROD | AArch64::AEK_FP   | AArch64::AEK_SIMD |
+  AArch64::AEK_FP16| AArch64::AEK_FP16FML | AArch64::AEK_RAS |
+  AArch64::AEK_RCPC| AArch64::AEK_LSE  | AArch64::AEK_SB,
+  "8-R"));
   EXPECT_TRUE(testAArch64CPU(
   "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
@@ -1118,6 +1117,12 @@
 AArch64::ArchKind::INVALID, "ras"));
   EXPECT_TRUE(testAArch64Extension("cortex-a55",
 AArch64::ArchKind::INVALID, "ras"));
+  EXPECT_TRUE(testAArch64Extension("cortex-a55",
+AArch64::ArchKind::INVALID, "fp16"));
+  EXPECT_FALSE(testAArch64Extension("cortex-a55",
+AArch64::ArchKind::INVALID, "fp16fml"));
+  EXPECT_TRUE(testAArch64Extension("cortex-a55",
+AArch64::ArchKind::INVALID, "dotprod"));
   EXPECT_FALSE(testAArch64Extension("cortex-a57",
 AArch64::ArchKind::INVALID, "ras"));
   EXPECT_FALSE(testAArch64Extension("cortex-a72",
@@ -1126,6 +1131,22 @@
 AArch64::ArchKind::INVALID, "ras"));
   EXPECT_TRUE(testAArch64Extension("cortex-a75",
 AArch64::ArchKind::INVALID, "ras"));
+  EXPECT_TRUE(testAArch64Extension("cortex-a75",
+AArch64::ArchKind::INVALID, "fp16"));
+  EXPECT_FALSE(testAArch64Extension("cortex-a75",
+AArch64::ArchKind::INVALID, "fp16fml"));
+  EXPECT_TRUE(testAArch64Extension("cortex-a75",
+   AArch64::ArchKind::INVALID, "dotprod"));
+  EXPECT_TRUE(testAArch64Extension("cortex-r82",
+   AArch64::ArchKind::INVALID, "ras"));
+  EXPECT_TRUE(testAArch64Extension("cortex-r82",
+   AArch64::ArchKind::INVALID, "fp16"));
+  EXPECT_TRUE(testAArch64Extension("cortex-r82",
+   AArch64::ArchKind::INVALID, "fp16fml"));
+  EXPECT_TRUE(testAArch64Extension("cortex-r82",
+   AArch64::ArchKind::INVALID, "dotprod"));
+  EXPECT_TRUE(testAArch64Extension("cortex-r82",
+   AArch64::ArchKind::INVALID, "lse"));
   EXPECT_FALSE(testAArch64Extension("cyclone",
 AArch64::ArchKind::INVALID, "ras"));
   EXPECT_FALSE(testAArch64Extension("exynos-m3",
@@ -1168,18 +1189,6 @@
AArch64::ArchKind::INVALID, "profile"));
   EXPECT_FALSE(testAArch64Extension("saphira",
 AArch64::ArchKind::INVALID, "fp16"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a55",
-AArch64::ArchKind::INVALID, "fp16"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a55",
-AArch64::ArchKind::INVALID, "fp16fml"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a55",
-AArch64::ArchKind::INVALID, "dotprod"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a75",
-AArch64::ArchKind::INVALID, "fp16"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a75",
-AArch64::ArchKind::INVALID, "fp16fml"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a75",
-AArch64::ArchKind::INVALID, "dotprod"));
   EXPECT_FALSE(testAArch64Extension("thunderx2t99",
   

[PATCH] D92006: Refactoring the attrubute plugin example to fit the new API

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Thanks for the changes, LGTM!




Comment at: clang/test/Frontend/plugin-attribute.cpp:1
-// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o 
- 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
-// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm 
-DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// RUN: split-file %s %t
+// RUN: %clang -cc1 -load %llvmshlibdir/Attribute%pluginext -fsyntax-only 
-ast-dump -verify %t/good_attr.cpp | FileCheck %s

psionic12 wrote:
> aaron.ballman wrote:
> > I am unfamiliar with this construct -- is there a reason to do this as 
> > opposed to making two separate files with separate content (these are 
> > testing fundamentally different things)?
> I just followed the suggestion from [[ 
> https://llvm.org/docs/TestingGuide.html#extra-files | this ]], the document 
> suggest that if the testing files are small, considered to put them in a 
> single file, and use the split-file command. I think the testing 
> infrastructure treat this as two files when testing.
Huh... we have exactly one other test case using this construct, which explains 
why I've never heard of it. :-D Thank you for pointing out that documentation.

I think it's usually best to keep test files focused on what they're testing, 
and this tests two different things (AST node attachment and semantic 
diagnostics) so my natural inclination is to have two separate files. But this 
provides the same test coverage, so I'd say we can leave it as-is until there's 
some other reason to split it up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92006

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


[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

2020-12-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D87188#2445414 , @lebedev.ri wrote:

> @mstorsjo please can you be more specific what kind of tests are starting to 
> fail?
> Do those tests just check that the code compiled into an identical assembly?

No, it's video/audio decoding tests, and after that change specific reference 
input samples produce a different output hash than before.

I can retry the change (I see that the patch is recently rebased and hopefully 
still should apply on the latest main version) soon and see if I can pinpoint 
what's going wrong any closer than before.


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

https://reviews.llvm.org/D87188

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


[PATCH] D92935: Introduce support for PowerPC devices with an Embedded Floating-point APU version 2 (efpu2)

2020-12-10 Thread Michael Kiausch via Phabricator via cfe-commits
kiausch updated this revision to Diff 310853.
kiausch added a comment.

fixed format errors


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

https://reviews.llvm.org/D92935

Files:
  clang/include/clang/Driver/Options.td
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/efpu2.ll

Index: llvm/test/CodeGen/PowerPC/efpu2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/efpu2.ll
@@ -0,0 +1,1141 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+efpu2 |  FileCheck %s
+
+; Single tests 
+; identical to tests in spe.ll
+
+declare float @llvm.fabs.float(float)
+define float @test_float_abs(float %a) #0 {
+; CHECK-LABEL: test_float_abs:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsabs 3, 3
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call float @llvm.fabs.float(float %a)
+ret float %0
+}
+
+define float @test_fnabs(float %a) #0 {
+; CHECK-LABEL: test_fnabs:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsnabs 3, 3
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call float @llvm.fabs.float(float %a)
+%sub = fsub float -0.00e+00, %0
+ret float %sub
+}
+
+define float @test_fdiv(float %a, float %b) {
+; CHECK-LABEL: test_fdiv:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsdiv 3, 3, 4
+; CHECK-NEXT:blr
+entry:
+  %v = fdiv float %a, %b
+  ret float %v
+
+}
+
+define float @test_fmul(float %a, float %b) {
+; CHECK-LABEL: test_fmul:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsmul 3, 3, 4
+; CHECK-NEXT:blr
+  entry:
+  %v = fmul float %a, %b
+  ret float %v
+}
+
+define float @test_fadd(float %a, float %b) {
+; CHECK-LABEL: test_fadd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsadd 3, 3, 4
+; CHECK-NEXT:blr
+  entry:
+  %v = fadd float %a, %b
+  ret float %v
+}
+
+define float @test_fsub(float %a, float %b) {
+; CHECK-LABEL: test_fsub:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efssub 3, 3, 4
+; CHECK-NEXT:blr
+  entry:
+  %v = fsub float %a, %b
+  ret float %v
+}
+
+define float @test_fneg(float %a) {
+; CHECK-LABEL: test_fneg:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:efsneg 3, 3
+; CHECK-NEXT:blr
+  entry:
+  %v = fsub float -0.0, %a
+  ret float %v
+}
+
+; todo
+define float @test_dtos(double %a) {
+; CHECK-LABEL: test_dtos:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mflr 0
+; CHECK-NEXT:stw 0, 4(1)
+; CHECK-NEXT:stwu 1, -16(1)
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset lr, 4
+; CHECK-NEXT:bl __truncdfsf2
+; CHECK-NEXT:lwz 0, 20(1)
+; CHECK-NEXT:addi 1, 1, 16
+; CHECK-NEXT:mtlr 0
+; CHECK-NEXT:blr
+  entry:
+  %v = fptrunc double %a to float
+  ret float %v
+}
+
+define i32 @test_fcmpgt(float %a, float %b) {
+; CHECK-LABEL: test_fcmpgt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stwu 1, -16(1)
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:efscmpgt 0, 3, 4
+; CHECK-NEXT:ble 0, .LBB8_2
+; CHECK-NEXT:  # %bb.1: # %tr
+; CHECK-NEXT:li 3, 1
+; CHECK-NEXT:b .LBB8_3
+; CHECK-NEXT:  .LBB8_2: # %fa
+; CHECK-NEXT:li 3, 0
+; CHECK-NEXT:  .LBB8_3: # %ret
+; CHECK-NEXT:stw 3, 12(1)
+; CHECK-NEXT:lwz 3, 12(1)
+; CHECK-NEXT:addi 1, 1, 16
+; CHECK-NEXT:blr
+  entry:
+  %r = alloca i32, align 4
+  %c = fcmp ogt float %a, %b
+  br i1 %c, label %tr, label %fa
+tr:
+  store i32 1, i32* %r, align 4
+  br label %ret
+fa:
+  store i32 0, i32* %r, align 4
+  br label %ret
+ret:
+  %0 = load i32, i32* %r, align 4
+  ret i32 %0
+}
+
+define i32 @test_fcmpugt(float %a, float %b) {
+; CHECK-LABEL: test_fcmpugt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stwu 1, -16(1)
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:efscmpeq 0, 4, 4
+; CHECK-NEXT:bc 4, 1, .LBB9_4
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:efscmpeq 0, 3, 3
+; CHECK-NEXT:bc 4, 1, .LBB9_4
+; CHECK-NEXT:  # %bb.2: # %entry
+; CHECK-NEXT:efscmpgt 0, 3, 4
+; CHECK-NEXT:bc 12, 1, .LBB9_4
+; CHECK-NEXT:  # %bb.3: # %fa
+; CHECK-NEXT:li 3, 0
+; CHECK-NEXT:b .LBB9_5
+; CHECK-NEXT:  .LBB9_4: # %tr
+; CHECK-NEXT:li 3, 1
+; CHECK-NEXT:  .LBB9_5: # %ret
+; CHECK-NEXT:stw 3, 12(1)
+; CHECK-NEXT:lwz 3, 12(1)
+; CHECK-NEXT:addi 1, 1, 16
+; CHECK-NEXT:blr
+  entry:
+  %r = alloca i32, align 4
+  %c = fcmp ugt float %a, %b
+  br i1 %c, label %tr, label %fa
+tr:
+  store i32 1, i32* %r, align 4
+  br label %ret
+fa:
+  store i32 0, i32* %r, align 4
+  br label %ret
+ret:
+  %0 = load i32, i32* %r, align 4
+  ret i32 %0
+}
+
+define i32 @test_fcmple(float %a, float %b) {
+; CHECK-LABEL: test_fcmple:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stwu 1,

[PATCH] D93027: [clang] Remove `-triple` from the invocations of `flang-new -fc1`

2020-12-10 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added subscribers: usaxena95, kadircet.
awarzynski requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This is just a small change in the Flang tool within libclangDriver.
Currently it passes `-triple` when calling `flang-new -fc1` for various
driver Jobs. Eventually these Jobs will require a triple, but currently
Flang doesn't support code-generation. As a consequence, `flang-new
-fc1` doesn't support `-triple.`

This hasn't been a problem as the affected Jobs aren't implemented or
used. However, we will be adding support for them in the near future.
However, while there is no code-generation, `-triple` is not required
and should remain unsupported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93027

Files:
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/flang.f90
  clang/test/Driver/flang/flang_ucase.F90


Index: clang/test/Driver/flang/flang_ucase.F90
===
--- clang/test/Driver/flang/flang_ucase.F90
+++ clang/test/Driver/flang/flang_ucase.F90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck 
--check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 
Index: clang/test/Driver/flang/flang.f90
===
--- clang/test/Driver/flang/flang.f90
+++ clang/test/Driver/flang/flang.f90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck 
--check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -40,8 +40,6 @@
 else
   CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(JA)) {
-CmdArgs.push_back("-triple");
-CmdArgs.push_back(Args.MakeArgString(TripleStr));
 if (JA.getType() == types::TY_Nothing) {
   CmdArgs.push_back("-fsyntax-only");
 } else if (JA.getType() == types::TY_AST) {


Index: clang/test/Driver/flang/flang_ucase.F90
===
--- clang/test/Driver/flang/flang_ucase.F90
+++ clang/test/Driver/flang/flang_ucase.F90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 
Index: clang/test/Driver/flang/flang.f90
===
--- clang/test/Driver/flang/flang.f90
+++ clang/test/Driver/flang/flang.f90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -40,8 +40,6 @@
 else
   CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(JA)) {
-CmdArgs.push_back("-triple");
-CmdArgs.push_back(Args.MakeArgString(TripleStr));
 if (JA.getType() == types::TY_Nothing) {
   CmdArgs.push_back("-fsyntax-only");
 } else if (JA.getType() == types::TY_AST) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

2020-12-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 310855.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Partial rebase (without updating test coverage)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87188

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Index: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1048,89 +1048,28 @@
   return &Sel;
 }
 
-/// There are many select variants for each of ABS/NABS.
-/// In matchSelectPattern(), there are different compare constants, compare
-/// predicates/operands and select operands.
-/// In isKnownNegation(), there are different formats of negated operands.
-/// Canonicalize all these variants to 1 pattern.
-/// This makes CSE more likely.
 static Instruction *canonicalizeAbsNabs(SelectInst &Sel, ICmpInst &Cmp,
 InstCombinerImpl &IC) {
   if (!Cmp.hasOneUse() || !isa(Cmp.getOperand(1)))
 return nullptr;
 
-  // Choose a sign-bit check for the compare (likely simpler for codegen).
-  // ABS:  (X hasOneUse() || (RHS->hasNUses(2) && CmpUsesNegatedOp)))
-  return nullptr;
-
-  // Create the canonical compare: icmp slt LHS 0.
-  if (!CmpCanonicalized) {
-Cmp.setPredicate(ICmpInst::ICMP_SLT);
-Cmp.setOperand(1, ConstantInt::getNullValue(Cmp.getOperand(0)->getType()));
-if (CmpUsesNegatedOp)
-  Cmp.setOperand(0, LHS);
-  }
-
-  // Create the canonical RHS: RHS = sub (0, LHS).
-  if (!RHSCanonicalized) {
-assert(RHS->hasOneUse() && "RHS use number is not right");
-RHS = IC.Builder.CreateNeg(LHS);
-if (TVal == LHS) {
-  // Replace false value.
-  IC.replaceOperand(Sel, 2, RHS);
-  FVal = RHS;
-} else {
-  // Replace true value.
-  IC.replaceOperand(Sel, 1, RHS);
-  TVal = RHS;
-}
-  }
-
-  // If the select operands do not change, we're done.
-  if (SPF == SelectPatternFlavor::SPF_NABS) {
-if (TVal == LHS)
-  return &Sel;
-assert(FVal == LHS && "Unexpected results from matchSelectPattern");
-  } else {
-if (FVal == LHS)
-  return &Sel;
-assert(TVal == LHS && "Unexpected results from matchSelectPattern");
-  }
-
-  // We are swapping the select operands, so swap the metadata too.
-  Sel.swapValues();
-  Sel.swapProfMetadata();
-  return &Sel;
+  return IC.replaceInstUsesWith(Sel, Abs);
 }
 
 /// If we have a select with an equality comparison, then we know the value in
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92920: [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D92920#2443748 , @njames93 wrote:

> In D92920#2443578 , @aaron.ballman 
> wrote:
>
>> Nothing is calling the new `parseConfigurationWithDiags()`, is that 
>> intentional? Also, is there a way to add test coverage for the change?
>
> Yes it is intentional, the idea is for programs embedding clang-tidy to use 
> this interface if they wish to handle diagnostics from parsing themselves.

Ahh, I see, thank you for the explanation.

> Tests could be added

I think they should be added.




Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:400
+DiagCallback Handler) {
+  llvm::yaml::Input Input(Config, nullptr, Handler ? diagHandlerImpl : nullptr,
+  &Handler);

njames93 wrote:
> aaron.ballman wrote:
> > Would it make sense to require `Handler` to be nonnull with an assertion?
> Wasn't sure which way to go with that one, happy to use an assert if you 
> think it's a good idea
Now that I understand the use for this change better, I think the code is good 
as-is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92920

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


[PATCH] D93024: [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93024

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


[PATCH] D92992: [clang-tidy] Add make_unique_for_overwrite/make_shared_for_overwrite check.

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm definitely of the opinion this should be an option in the 
`modernize-make-(shared|unique)` check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92992

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


[PATCH] D92994: Remove references to the ast_type_traits namespace

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp:95
 for (const auto *Arg : CallExpr->arguments()) {
-  if (StartArg-- > 0) 
-   continue;
-  if (const clang::CallExpr* Sub =
+  if (StartArg-- > 0)
+continue;

It looks like some unrelated clang-format changes that should probably be 
separated out from this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92994

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


[PATCH] D93029: [clangd] Find relations in Dex exploration tool.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93029

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id or -name.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << S << " defined at: " << S.Definition << "\n";
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 //===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id or -name.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << S << " defined at: " << S.Definition << "\n";
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93029: [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 310861.
usaxena95 added a comment.

Update error message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93029

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << S << " defined at: " << S.Definition << "\n";
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 //===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << S << " defined at: " << S.Definition << "\n";
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-10 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:673-686
+def ProcA78C : SubtargetFeature<"cortex-a78c", "ARMProcFamily",
+"CortexA78C",
+"Cortex-A78C ARM processors", [
+HasV8_2aOps,
+FeatureCrypto,
+FeatureFPARMv8,
+FeatureFuseAES,

ktkachov wrote:
> According to the TRM at https://developer.arm.com/documentation/102226/0001 
> Cortex-A78C also supports Pointer Authetication and the Flag Manipulation 
> instructions as well (CFINV, RMIF etc). I think this feature set doesn't 
> reflect that?
ktkachov: FeaturePA?




Comment at: llvm/unittests/Support/TargetParserTest.cpp:833
+}
+  }
   pass &= AArch64::getCPUAttr(AK).equals(CPUAttr);

DavidSpickett wrote:
> I assume this was left in from debugging, if not it should be its own change.
> (considering this file is already using gtest, you could refactor to 
> ASSERT_EQ the flags and get the messages for free)
I like the idea of ASSERT_EQ, but I need the numbers to be in hex.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


[PATCH] D92956: Fix range-loop-analysis checks for trivial copyability

2020-12-10 Thread z via Phabricator via cfe-commits
fanfuqiang updated this revision to Diff 310865.
fanfuqiang marked 2 inline comments as done.
fanfuqiang added a comment.

update testcase take advise of reviewers.
fix conflict testcase fail, less warnning only for hasNonTrivialCopyConstructor 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92956

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
  clang/test/SemaCXX/warn-range-loop-analysis.cpp


Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -29,6 +29,13 @@
   operator int();
 };
 
+struct ID1 {
+  // Small trivally copy constructor, but no trivally copy assignment 
+  // operator.
+  ID1(ID1 const&) = default;
+  ID1& operator=(ID1 const& other) { return *this; }
+};
+
 // Testing notes:
 // test0 checks that the full text of the warnings and notes is correct.  The
 //   rest of the tests checks a smaller portion of the text.
@@ -455,6 +462,14 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
 
+void test11() {
+  Container C;
+
+  for (const ID1 x : C) {}
+  // No warning
+}
+
+
 template 
 void test_template_function() {
   // In a template instantiation the diagnostics should not be emitted for
Index: clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
@@ -55,8 +55,6 @@
 int b;
   };
 
-  // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const 
Record'}}
-  // expected-note@+2 {{use reference type 'const Record &' to prevent 
copying}}
   Record records[8];
   for (const auto r : records)
 (void)r;
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2855,8 +2855,14 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
+  const CXXRecordDecl *ClassDecl = nullptr;
+  if (const auto *RT = VariableType->getAs()) {
+ClassDecl = dyn_cast(RT->getDecl());
+  }
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
+   // Fix https://bugs.llvm.org/show_bug.cgi?id=48011
+   (ClassDecl && !ClassDecl->hasNonTrivialCopyConstructor()) ||
hasTrivialABIAttr(VariableType)))
 return;
 


Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -29,6 +29,13 @@
   operator int();
 };
 
+struct ID1 {
+  // Small trivally copy constructor, but no trivally copy assignment 
+  // operator.
+  ID1(ID1 const&) = default;
+  ID1& operator=(ID1 const& other) { return *this; }
+};
+
 // Testing notes:
 // test0 checks that the full text of the warnings and notes is correct.  The
 //   rest of the tests checks a smaller portion of the text.
@@ -455,6 +462,14 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
 
+void test11() {
+  Container C;
+
+  for (const ID1 x : C) {}
+  // No warning
+}
+
+
 template 
 void test_template_function() {
   // In a template instantiation the diagnostics should not be emitted for
Index: clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
@@ -55,8 +55,6 @@
 int b;
   };
 
-  // expected-warning@+3 {{loop variable 'r' creates a copy from type 'const Record'}}
-  // expected-note@+2 {{use reference type 'const Record &' to prevent copying}}
   Record records[8];
   for (const auto r : records)
 (void)r;
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2855,8 +2855,14 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
+  const CXXRecordDecl *ClassDecl = nullptr;
+  if (const auto *RT = VariableType->getAs()) {
+ClassDecl = dyn_cast(RT->getDecl());
+  }
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
+   // Fix https://bugs.llvm.org/show_bug.cgi?id=48011
+   (ClassD

[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I wouldn't worry much about the `ASTMerge` tests, those are mostly legacy and 
not actively used nowadays. (At one point we were thinking even to remove them 
because we could got rid of the `ASTMergeAction` which is exclusively used for 
testing.)
The main test infrastructure for the ASTImporter is in the `unittests`. Those 
tests are exercised even with `-fdelayed-template-parsing` and with 
`-fms-compatibility`. So I am fine with marking the ASTMerge tests with XFAIL 
on windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

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


[PATCH] D93031: Enable fexec-charset option

2020-12-10 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, dang, hiraditya, mgorny.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch enables the fexec-charset option to control the execution charset of 
string literals. It sets the default internal charset, system charset, and 
execution charset for z/OS and UTF-8 for all other platforms. 
This patch depends on https://reviews.llvm.org/D88741


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/LiteralTranslator.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/LiteralTranslator.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1023,6 +1023,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -390,6 +390,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,8 +209,8 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=iso8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-VALID-INPUT-CHARSET %s
+// CHECK-VALID-INPUT-CHARSET-NOT: error: invalid value 'iso8859-1' in '-fexec-charset=iso8859-1'
 
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,10 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
-//
+// /execution-charset: should not warn on character sets.
+// RUN: %clang_cl /execution-charset:iso8859-1 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-iso8859-1 %s
+// execution-charset-iso8859-1-NOT: invalid value 'iso8859-1' in '/execution-charset:iso8859-1'
+
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
Index: clang/test/CodeGen/systemz-charset.c
===
--- /dev/null
+++ clang/test/CodeGen/systemz-charset.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple s390x-none-zos -fexec-charset IBM-1047 -o - | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -target s390x-ibm-zos -o - | FileCheck %s
+
+char *UpperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+// CHECK: c"\C1\C2\C3\C4\C5\C6\C7\C8\C9\D1\D2\D3\D4\D5\D6\D7\D8\D9\E2\E3\E4\E5\E6\E7\E8\E9\00"
+
+char *LowerCaseLetters = "abcdefghijklmnopqrstuvwxyz";
+//CHECK: c"\81\82\83\84\85

[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-10 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: llvm/unittests/Support/TargetParserTest.cpp:833
+}
+  }
   pass &= AArch64::getCPUAttr(AK).equals(CPUAttr);

MarkMurrayARM wrote:
> DavidSpickett wrote:
> > I assume this was left in from debugging, if not it should be its own 
> > change.
> > (considering this file is already using gtest, you could refactor to 
> > ASSERT_EQ the flags and get the messages for free)
> I like the idea of ASSERT_EQ, but I need the numbers to be in hex.
(assuming llvm's copy of GTest supports it)
https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#using-a-predicate-formatter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


[PATCH] D92962: [ASTImporter] Fix import of a typedef that has an attribute

2020-12-10 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 310869.
martong added a comment.

- Check the attribute in the test as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92962

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6085,6 +6085,24 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, CTAD,
 DefaultTestValuesForRunOptions, );
 
+TEST_P(ASTImporterOptionSpecificTestBase, TypedefWithAttribute) {
+  Decl *TU = getTuDecl(
+  R"(
+  namespace N {
+typedef int X __attribute__((annotate("A")));
+  }
+  )",
+  Lang_CXX17, "input.cc");
+  auto *FromD =
+  FirstDeclMatcher().match(TU, typedefDecl(hasName("X")));
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);
+  ASSERT_EQ(ToD->getAttrs().size(), 1);
+  auto *ToAttr = dyn_cast(ToD->getAttrs()[0]);
+  ASSERT_TRUE(ToAttr);
+  EXPECT_EQ(ToAttr->getAnnotation(), "A");
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -264,16 +264,6 @@
 
 void InitializeImportedDecl(Decl *FromD, Decl *ToD) {
   ToD->IdentifierNamespace = FromD->IdentifierNamespace;
-  if (FromD->hasAttrs())
-for (const Attr *FromAttr : FromD->getAttrs()) {
-  // FIXME: Return of the error here is not possible until store of
-  // import errors is implemented.
-  auto ToAttrOrErr = import(FromAttr);
-  if (ToAttrOrErr)
-ToD->addAttr(*ToAttrOrErr);
-  else
-llvm::consumeError(ToAttrOrErr.takeError());
-}
   if (FromD->isUsed())
 ToD->setIsUsed();
   if (FromD->isImplicit())
@@ -8328,6 +8318,15 @@
   // Make sure that ImportImpl registered the imported decl.
   assert(ImportedDecls.count(FromD) != 0 && "Missing call to MapImported?");
 
+  if (FromD->hasAttrs())
+for (const Attr *FromAttr : FromD->getAttrs()) {
+  auto ToAttrOrErr = Import(FromAttr);
+  if (ToAttrOrErr)
+ToD->addAttr(*ToAttrOrErr);
+  else
+return ToAttrOrErr.takeError();
+}
+
   // Notify subclasses.
   Imported(FromD, ToD);
 


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6085,6 +6085,24 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, CTAD,
 DefaultTestValuesForRunOptions, );
 
+TEST_P(ASTImporterOptionSpecificTestBase, TypedefWithAttribute) {
+  Decl *TU = getTuDecl(
+  R"(
+  namespace N {
+typedef int X __attribute__((annotate("A")));
+  }
+  )",
+  Lang_CXX17, "input.cc");
+  auto *FromD =
+  FirstDeclMatcher().match(TU, typedefDecl(hasName("X")));
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);
+  ASSERT_EQ(ToD->getAttrs().size(), 1);
+  auto *ToAttr = dyn_cast(ToD->getAttrs()[0]);
+  ASSERT_TRUE(ToAttr);
+  EXPECT_EQ(ToAttr->getAnnotation(), "A");
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -264,16 +264,6 @@
 
 void InitializeImportedDecl(Decl *FromD, Decl *ToD) {
   ToD->IdentifierNamespace = FromD->IdentifierNamespace;
-  if (FromD->hasAttrs())
-for (const Attr *FromAttr : FromD->getAttrs()) {
-  // FIXME: Return of the error here is not possible until store of
-  // import errors is implemented.
-  auto ToAttrOrErr = import(FromAttr);
-  if (ToAttrOrErr)
-ToD->addAttr(*ToAttrOrErr);
-  else
-llvm::consumeError(ToAttrOrErr.takeError());
-}
   if (FromD->isUsed())
 ToD->setIsUsed();
   if (FromD->isImplicit())
@@ -8328,6 +8318,15 @@
   // Make sure that ImportImpl registered the imported decl.
   assert(ImportedDecls.count(FromD) != 0 && "Missing call to MapImported?");
 
+  if (FromD->hasAttrs())
+for (const Attr *FromAttr : FromD->getAttrs()) {
+  auto ToAttrOrErr = Import(FromAttr);
+  if (ToAttrOrErr)
+ToD->addAttr(*ToAttrOrErr);
+  else
+return ToAttrOrErr.takeError();
+}
+
   // Notify subclasses.
   Imported(FromD, ToD);
 
___
cfe-commits mailing list
cfe-com

[PATCH] D92962: [ASTImporter] Fix import of a typedef that has an attribute

2020-12-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:6098
+  FirstDeclMatcher().match(TU, typedefDecl(hasName("X")));
+  auto *ToD = Import(FromD, Lang_CXX17);
+  ASSERT_TRUE(ToD);

shafik wrote:
> We can't check the attribute is present?
Yes, good point. I've update with some more checks. Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92962

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


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 310870.
jansvoboda11 added a comment.

Rebase, use BoolOption


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -311,9 +311,11 @@
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
+
   CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument;
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
+  CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
@@ -903,22 +905,9 @@
   Opts.setDebuggerTuning(static_cast(Val));
   }
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
-  Opts.DebugColumnInfo = !Args.hasArg(OPT_gno_column_info);
-  Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
-  Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
-  Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
-  Opts.VirtualFunctionElimination =
-  Args.hasArg(OPT_fvirtual_function_elimination);
-  Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
   Opts.SplitDwarfFile = std::string(Args.getLastArgValue(OPT_split_dwarf_file));
   Opts.SplitDwarfOutput =
   std::string(Args.getLastArgValue(OPT_split_dwarf_output));
-  Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
-  Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
-  Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
-  Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
-  Opts.ForceDwarfFrameSection = Args.hasArg(OPT_fforce_dwarf_frame);
 
   for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
@@ -926,13 +915,6 @@
 {std::string(Split.first), std::string(Split.second)});
   }
 
-  if (const Arg *A =
-  Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
-Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
-
-  Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
-  Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
-
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
   llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64,
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
@@ -943,29 +925,12 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
-  Opts.ValueTrackingVariableLocations =
-  Args.hasArg(OPT_fexperimental_debug_variable_locations);
-
-  Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
-  Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
-  Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
-  Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
-  Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
-OPT_fuse_register_sized_bitfield_access);
-  Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
-  Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
-  Opts.FineGrainedBitfieldAccesses =
-  Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
-   OPT_fno_fine_grained_bitfield_accesses, false);
   Opts.DwarfDebugFlags =
   std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
   Opts.RecordCommandLine =
   std::string(Args.getLastArgValue(OPT_record_command_line));
-  Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
-  Opts.NoCommon = !Args.hasArg(OPT_fcommon);
-  Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
   Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
 Args.hasArg(OPT_ffreestanding));
@@ -974,26 +939,17 @@
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
(Opts.OptimizationLevel > 1));
-  Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
-  Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.SampleProfileFile =
   std::string(Args.getLastArgValue(OPT

[PATCH] D92977: [clangd] Improve hover and goToDefinition on auto and dectype

2020-12-10 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 310872.
qchateau added a comment.

Fix unittests and behavior

I've fixed the failing unittests, added some more
to test the new behavior, and fixed some bugs in
the new code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92977

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -624,6 +624,140 @@
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// auto builtin type (not supported)
+au^to x = 42;
+  )cpp",
+
+  R"cpp(// auto on lambda
+auto x = [[[]]]{};
+au^to y = x;
+  )cpp",
+
+  R"cpp(// auto on struct
+namespace ns1 {
+struct [[S1]] {};
+} // namespace ns1
+
+au^to x = ns1::S1{};
+  )cpp",
+
+  R"cpp(// decltype on struct
+namespace ns1 {
+struct [[S1]] {};
+} // namespace ns1
+
+ns1::S1 i;
+decl^type(i) j;
+  )cpp",
+
+  R"cpp(// decltype(auto) on struct
+namespace ns1 {
+struct [[S1]] {};
+} // namespace ns1
+
+ns1::S1 i;
+ns1::S1& j = i;
+decl^type(auto) k = j;
+  )cpp",
+
+  R"cpp(// auto on template class
+template class [[Foo]] {};
+
+au^to x = Foo();
+  )cpp",
+
+  R"cpp(// auto on template class with forward declared class
+template class [[Foo]] {};
+class X;
+
+au^to x = Foo();
+  )cpp",
+
+  R"cpp(// auto on specialized template class
+template class Foo {};
+template<> class [[Foo]] {};
+
+au^to x = Foo();
+  )cpp",
+
+  R"cpp(// auto on initializer list.
+namespace std
+{
+  template
+  class [[initializer_list]] {};
+}
+
+au^to i = {1,2};
+  )cpp",
+
+  R"cpp(// auto function return with trailing type
+struct [[Bar]] {};
+au^to test() -> decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// decltype in trailing return type
+struct [[Bar]] {};
+auto test() -> decl^type(Bar()) {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// auto in function return
+struct [[Bar]] {};
+au^to test() {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// auto& in function return
+struct [[Bar]] {};
+au^to& test() {
+  static Bar x;
+  return x;
+}
+  )cpp",
+
+  R"cpp(// auto* in function return
+struct [[Bar]] {};
+au^to* test() {
+  Bar* x;
+  return x;
+}
+  )cpp",
+
+  R"cpp(// const auto& in function return
+struct [[Bar]] {};
+const au^to& test() {
+  static Bar x;
+  return x;
+}
+  )cpp",
+
+  R"cpp(// decltype(auto) in function return
+struct [[Bar]] {};
+decl^type(auto) test() {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// decltype of function with trailing return type.
+struct [[Bar]] {};
+auto test() -> decltype(Bar()) {
+  return Bar();
+}
+void foo() {
+  decl^type(test()) i = test();
+}
+  )cpp",
+
+  R"cpp(// auto on alias
+struct [[cls]] {};
+typedef cls cls_type;
+au^to y = cls_type();
+  )cpp",
+
   R"cpp(// Override specifier jumps to overridden method
 class Y { virtual void $decl[[a]]() = 0; };
 class X : Y { void a() ^override {} };
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -388,6 +388,9 @@
[](HoverInfo &HI) {
  HI.Name = "(lambda)";
  HI.Kind = index::SymbolKind::Class;
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Definition = "class {}";
}},
   // auto on template instantiation
   {R"cpp(
@@ -399,6 +402,8 @@
[](HoverInfo &HI) {
  HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
+ HI.NamespaceScope = "";
+ HI.Definition = "template <> class Foo {}";
}},
   // auto on specialized template
   {R"cpp(
@@ -411,6 +416,8 @@
[](HoverInfo &HI) {
  HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
+ HI.NamespaceScope = "";
+ HI.Definition = "template <> class Foo {}";
}},
 
   // macro
@@ -584,

[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

This is now ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D91979#2444327 , @jdoerfert wrote:

> In D91979#2440554 , @aaron.ballman 
> wrote:
>
>> Thank you for your patience with the delays getting to your review! Along 
>> with the documentation question, one line of thinking I'm also not clear on 
>> is whether this should be a type-based attribute rather than a 
>> declaration-based attribute. For instance, if you want to write an 
>> assumption about the parameters to a function, those are not in scope for a 
>> declaration attribute but are for a type attribute.
>
> I would like to see that, in our last proposal of something similar we 
> suggested to add something like `__attribute__((arg_attr(3, "nofree")))` 
> which would translate to the `nofree` IR attribute for argument 3. I can also 
> envision a type based assumption attribute but I feel a declaration one will 
> be needed nevertheless. We'll also add expression assumptions as they are 
> required by OpenMP and generally useful. The "payload" of the assume 
> attribute will then be a union, similar to the `AlignedAttribute`.

I want to make sure we're on the same page with this.

If the assumption is a unit of information that applies to a single parameter, 
then the attribute should be written on the parameter itself rather than using 
positional information. e.g., `void func(int i [[clang::whatever]]);` is 
preferable to `void func(int i) [[clang::whatever(1)]];` By writing the 
attribute directly on the parameter, we remove confusion over things like "are 
parameter indexes one-based or zero-based?" and "does the implicit 'this' 
parameter count?".

If the assumption is unit of information that applies to the function but 
involves one or more parameters, then writing the attribute *might* makes sense 
as a type attribute. e.g., `void func(int i, int j) [[clang::whatever(i < j)]];`

It sounds to me like we may wind up with both kinds of situations, which is 
fine.

>> But also, it seems like this assumption information is something that would 
>> be useful to carry around as part of the function's identity. For instance, 
>> would users want to be able to make a call through a function pointer and 
>> have the same set of assumptions conveyed to the backend?
>
> Like other IR attributes, if you can go from the function pointer to a (set 
> of) declaration(s) you can use the attributes from that declaration. I don't 
> think this is any different than other function attributes, e.g., `readnone` 
> in this aspect.

But what about the behavior the user sees? e.g., should the user be alerted to 
this being a potentially bad thing?

  void func(int *ip) [[clang::assume(ip != 0)]];
  void other_func(int *ip); // No assumptions about ip
  int *get_ip(); // May return null
  
  ...
  void (*fp)(int *);
  
  if (rand() % 10 == 0)
fp = other_func;
  else
fp = func; // Should we warn about this?
  
  fp(get_ip()); // This could do bad things if fp == func because get_ip() may 
return null




Comment at: clang/include/clang/Basic/Attr.td:3482
+  let Spellings = [Clang<"assume">];
+  let Subjects = SubjectList<[Function]>;
+  let InheritEvenIfAlreadyPresent = 1;

Should this be supported on ObjCMethod declarations as well?



Comment at: clang/include/clang/Basic/AttrDocs.td:3930
+analysis and optimization passes can assume the "assumption" to hold.
+This is similar to :ref:`__builtin_assume ` but 
instead of an
+expression that can be assumed to be non-zero, the assumption is expressed as

wrap to 80-col



Comment at: clang/include/clang/Basic/AttrDocs.td:3940
+
+While LLVM plugins might utilize more assumption strings, the default LLVM
+optimization passes are aware of the following assumptions:





Comment at: clang/include/clang/Basic/AttrDocs.td:3950
+The OpenMP standard defines the meaning of OpenMP assumptions ("omp_XYZ" is
+spelled "XYZ" in the OpenMP standard).
+

Can you link to that standard here so users don't have to hunt for it?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:742
   "the argument to %0 has side effects that will be discarded">,
-  InGroup>;
+  InGroup;
+def warn_assume_attribute_string_unknown : Warning<

This changes behavior for users because `-Wno-assume` now needs to be spelled 
`-Wno-assumption` -- I think we may want to keep the diagnostics for the 
assumption attribute separate from the diagnostics for builtin assume.

For instance, I think the assumption attribute warnings will all wind up 
leading to an ignored attribute, so perhaps the new grouping should be under 
the existing ignored attributes group.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:744
+def warn_assume_attribute_string_unknown : Warning<
+  "the assumption string '%0' is 

[PATCH] D88905: [Clang] Allow "ext_vector_type" applied to Booleans

2020-12-10 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.

AFAIK all comments were addressed. Could you have another look at/LGTM this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88905

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


[PATCH] D93029: [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp:304
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << S << " defined at: " << S.Definition << "\n";
+});

I think dumping the whole symbol (  `toYAML(S)`) will give us more useful 
information


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93029

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping


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

https://reviews.llvm.org/D92577

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


[PATCH] D93027: [clang] Remove `-triple` from the invocations of `flang-new -fc1`

2020-12-10 Thread sameeran joshi via Phabricator via cfe-commits
sameeranjoshi accepted this revision.
sameeranjoshi added a comment.
This revision is now accepted and ready to land.

Thanks for extracting it from D92854 .
I think the tests in D92854  were failing for 
the same reason.
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93027

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


[PATCH] D93024: [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG34d2688a50f2: [clang-tidy] Use a MemoryBufferRef when 
parsing configuration files. (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93024

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -72,10 +72,11 @@
 
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
-  parseConfiguration("Checks: \"-*,misc-*\"\n"
- "HeaderFilterRegex: \".*\"\n"
- "AnalyzeTemporaryDtors: true\n"
- "User: some.user");
+  parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
+   "HeaderFilterRegex: \".*\"\n"
+   "AnalyzeTemporaryDtors: true\n"
+   "User: some.user",
+   "Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
   EXPECT_EQ(".*", *Options->HeaderFilterRegex);
@@ -83,7 +84,8 @@
 }
 
 TEST(ParseConfiguration, MergeConfigurations) {
-  llvm::ErrorOr Options1 = parseConfiguration(R"(
+  llvm::ErrorOr Options1 =
+  parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check1,check2"
   HeaderFilterRegex: "filter1"
   AnalyzeTemporaryDtors: true
@@ -91,9 +93,11 @@
   ExtraArgs: ['arg1', 'arg2']
   ExtraArgsBefore: ['arg-before1', 'arg-before2']
   UseColor: false
-  )");
+  )",
+   "Options1"));
   ASSERT_TRUE(!!Options1);
-  llvm::ErrorOr Options2 = parseConfiguration(R"(
+  llvm::ErrorOr Options2 =
+  parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check3,check4"
   HeaderFilterRegex: "filter2"
   AnalyzeTemporaryDtors: false
@@ -101,7 +105,8 @@
   ExtraArgs: ['arg3', 'arg4']
   ExtraArgsBefore: ['arg-before3', 'arg-before4']
   UseColor: true
-  )");
+  )",
+   "Options2"));
   ASSERT_TRUE(!!Options2);
   ClangTidyOptions Options = Options1->merge(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -41,7 +41,8 @@
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(*Data))
+if (auto Parsed = tidy::parseConfiguration(
+llvm::MemoryBufferRef(*Data, path(
   Value = std::make_shared(
   std::move(*Parsed));
 else
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -312,10 +312,11 @@
   if (UseColor.getNumOccurrences() > 0)
 OverrideOptions.UseColor = UseColor;
 
-  auto LoadConfig = [&](StringRef Configuration)
-  -> std::unique_ptr {
+  auto LoadConfig =
+  [&](StringRef Configuration,
+  StringRef Source) -> std::unique_ptr {
 llvm::ErrorOr ParsedConfig =
-parseConfiguration(Configuration);
+parseConfiguration(MemoryBufferRef(Configuration, Source));
 if (ParsedConfig)
   return std::make_unique(
   std::move(GlobalOptions),
@@ -334,18 +335,18 @@
 }
 
 llvm::ErrorOr> Text =
-llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+llvm::MemoryBuffer::getFile(ConfigFile);
 if (std::error_code EC = Text.getError()) {
   llvm::errs() << "Error: can't read config-file '" << ConfigFile
<< "': " << EC.message() << "\n";
   return nullptr;
 }
 
-return LoadConfig((*Text)->getBuffer());
+return LoadConfig((*Text)->getBuffer(), ConfigFile);
   }
 
   if (Config.getNumOccurrences() > 0)
-return LoadConfig(Config);
+return LoadConfig(Config, "");
 
   return std::make_unique(
   std::move(GlobalOptions), std::move(DefaultOptions),
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
==

[clang-tools-extra] 34d2688 - [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

2020-12-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-10T14:52:45Z
New Revision: 34d2688a50f23b4b15bdeab054e28e033ece9363

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

LOG: [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

Using a MemoryBufferRef, If there is an error parsing, we can point the user to 
the location of the file.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 1de1b1baccb5..f17ef716d60f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -360,7 +360,7 @@ FileOptionsBaseProvider::tryReadConfigFile(StringRef 
Directory) {
 if ((*Text)->getBuffer().empty())
   continue;
 llvm::ErrorOr ParsedOptions =
-ConfigHandler.second((*Text)->getBuffer());
+ConfigHandler.second({(*Text)->getBuffer(), ConfigFile});
 if (!ParsedOptions) {
   if (ParsedOptions.getError())
 llvm::errs() << "Error parsing " << ConfigFile << ": "
@@ -380,7 +380,8 @@ std::error_code parseLineFilter(StringRef LineFilter,
   return Input.error();
 }
 
-llvm::ErrorOr parseConfiguration(StringRef Config) {
+llvm::ErrorOr
+parseConfiguration(llvm::MemoryBufferRef Config) {
   llvm::yaml::Input Input(Config);
   ClangTidyOptions Options;
   Input >> Options;

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index b4a00f68d6cf..e7cd89951ff9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -192,7 +192,7 @@ class FileOptionsBaseProvider : public 
DefaultOptionsProvider {
   // A pair of configuration file base name and a function parsing
   // configuration from text in the corresponding format.
   typedef std::pair(
- llvm::StringRef)>>
+ llvm::MemoryBufferRef)>>
   ConfigFileHandler;
 
   /// Configuration file handlers listed in the order of priority.
@@ -308,7 +308,8 @@ std::error_code parseLineFilter(llvm::StringRef LineFilter,
 
 /// Parses configuration from JSON and returns \c ClangTidyOptions or an
 /// error.
-llvm::ErrorOr parseConfiguration(llvm::StringRef Config);
+llvm::ErrorOr
+parseConfiguration(llvm::MemoryBufferRef Config);
 
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index beef79e17769..2748fd9f74a5 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -312,10 +312,11 @@ static std::unique_ptr 
createOptionsProvider(
   if (UseColor.getNumOccurrences() > 0)
 OverrideOptions.UseColor = UseColor;
 
-  auto LoadConfig = [&](StringRef Configuration)
-  -> std::unique_ptr {
+  auto LoadConfig =
+  [&](StringRef Configuration,
+  StringRef Source) -> std::unique_ptr {
 llvm::ErrorOr ParsedConfig =
-parseConfiguration(Configuration);
+parseConfiguration(MemoryBufferRef(Configuration, Source));
 if (ParsedConfig)
   return std::make_unique(
   std::move(GlobalOptions),
@@ -334,18 +335,18 @@ static std::unique_ptr 
createOptionsProvider(
 }
 
 llvm::ErrorOr> Text =
-llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+llvm::MemoryBuffer::getFile(ConfigFile);
 if (std::error_code EC = Text.getError()) {
   llvm::errs() << "Error: can't read config-file '" << ConfigFile
<< "': " << EC.message() << "\n";
   return nullptr;
 }
 
-return LoadConfig((*Text)->getBuffer());
+return LoadConfig((*Text)->getBuffer(), ConfigFile);
   }
 
   if (Config.getNumOccurrences() > 0)
-return LoadConfig(Config);
+return LoadConfig(Config, "");
 
   return std::make_unique(
   std::move(GlobalOptions), std::move(DefaultOptions),

diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index f51ac91aaf36..730a402b5df1 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -41,7 +41,8 @@ class DotClangTidyCache : private FileCache {
 [this](l

[clang-tools-extra] a0cf2b8 - [clangd][NFC] Remove unnecessary vector.

2020-12-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-10T14:59:17Z
New Revision: a0cf2b8f712e0bca9185d77cf1def8160f165548

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

LOG: [clangd][NFC] Remove unnecessary vector.

As pointed out in D92788.

Reviewed By: kbobyrev

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/TestTU.cpp 
b/clang-tools-extra/clangd/unittests/TestTU.cpp
index 27019403ae85..3b1130444671 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,9 +187,6 @@ const Symbol &findSymbol(const SymbolSlab &Slab, 
llvm::StringRef QName) {
 }
 
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
-  QName.split(Components, "::");
-
   auto &Ctx = AST.getASTContext();
   auto LookupDecl = [&Ctx](const DeclContext &Scope,
llvm::StringRef Name) -> const NamedDecl & {
@@ -200,11 +197,13 @@ const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef 
QName) {
   };
 
   const DeclContext *Scope = Ctx.getTranslationUnitDecl();
-  for (auto NameIt = Components.begin(), End = Components.end() - 1;
-   NameIt != End; ++NameIt) {
-Scope = &cast(LookupDecl(*Scope, *NameIt));
+
+  StringRef Cur, Rest;
+  for (std::tie(Cur, Rest) = QName.split("::"); !Rest.empty();
+   std::tie(Cur, Rest) = Rest.split("::")) {
+Scope = &cast(LookupDecl(*Scope, Cur));
   }
-  return LookupDecl(*Scope, Components.back());
+  return LookupDecl(*Scope, Cur);
 }
 
 const NamedDecl &findDecl(ParsedAST &AST,



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


[PATCH] D92986: [clangd][NFC] Remove unnecessary vector.

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0cf2b8f712e: [clangd][NFC] Remove unnecessary vector. 
(authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D92986?vs=310729&id=310879#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92986

Files:
  clang-tools-extra/clangd/unittests/TestTU.cpp


Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,9 +187,6 @@
 }
 
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
-  QName.split(Components, "::");
-
   auto &Ctx = AST.getASTContext();
   auto LookupDecl = [&Ctx](const DeclContext &Scope,
llvm::StringRef Name) -> const NamedDecl & {
@@ -200,11 +197,13 @@
   };
 
   const DeclContext *Scope = Ctx.getTranslationUnitDecl();
-  for (auto NameIt = Components.begin(), End = Components.end() - 1;
-   NameIt != End; ++NameIt) {
-Scope = &cast(LookupDecl(*Scope, *NameIt));
+
+  StringRef Cur, Rest;
+  for (std::tie(Cur, Rest) = QName.split("::"); !Rest.empty();
+   std::tie(Cur, Rest) = Rest.split("::")) {
+Scope = &cast(LookupDecl(*Scope, Cur));
   }
-  return LookupDecl(*Scope, Components.back());
+  return LookupDecl(*Scope, Cur);
 }
 
 const NamedDecl &findDecl(ParsedAST &AST,


Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,9 +187,6 @@
 }
 
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
-  QName.split(Components, "::");
-
   auto &Ctx = AST.getASTContext();
   auto LookupDecl = [&Ctx](const DeclContext &Scope,
llvm::StringRef Name) -> const NamedDecl & {
@@ -200,11 +197,13 @@
   };
 
   const DeclContext *Scope = Ctx.getTranslationUnitDecl();
-  for (auto NameIt = Components.begin(), End = Components.end() - 1;
-   NameIt != End; ++NameIt) {
-Scope = &cast(LookupDecl(*Scope, *NameIt));
+
+  StringRef Cur, Rest;
+  for (std::tie(Cur, Rest) = QName.split("::"); !Rest.empty();
+   std::tie(Cur, Rest) = Rest.split("::")) {
+Scope = &cast(LookupDecl(*Scope, Cur));
   }
-  return LookupDecl(*Scope, Components.back());
+  return LookupDecl(*Scope, Cur);
 }
 
 const NamedDecl &findDecl(ParsedAST &AST,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91893: [clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:92
+  // to reference it and avoid the copy.
+  if (!isa(T) && !isa(T))
+return true;





Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp:492
+  Orig.nonConstMethod();
+}

Making sure I understand properly, if you were calling `Orig.constMethod()` 
then the diagnostic should be triggered, correct? Assuming so, having those 
test cases would be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91893

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


[PATCH] D92967: Tooling: Migrate some tests to FileEntryRef, NFC

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D92967

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


[PATCH] D92968: Frontend: Migrate to FileEntryRef in TextDiagnosticTest, NFC

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92968

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


[clang] a7b2847 - [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-10 Thread via cfe-commits

Author: Valentin Clement
Date: 2020-12-10T10:19:09-05:00
New Revision: a7b2847216b4f7a84ef75461fd47a5adfbb63e27

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

LOG: [openmp] Remove clause from OMPKinds.def and use OMP.td info

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for 
the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros 
previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 65319a19728b..6eceb526ca4c 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index ea3da8d90c5b..92123ed2a32a 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,8 +147,9 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 NKI_NumberOfKinds
   };
 
@@ -205,8 +206,9 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index cc6d3a93ba09..57ba4fa5510f 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,20 +7758,22 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
-  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
+  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
+#define CLAUSE_NO_CLASS(Enum, Str) 
\
   case llvm::omp::Clause::Enum:
\
 break;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 default:
   break;
 }
@@ -78

[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-10 Thread Valentin Clement 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 rGa7b2847216b4: [openmp] Remove clause from OMPKinds.def and 
use OMP.td info (authored by clementval).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92955

Files:
  clang/include/clang/AST/ASTFwd.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/TableGen/DirectiveEmitter.h
  llvm/test/TableGen/directive2.td
  llvm/utils/TableGen/DirectiveEmitter.cpp

Index: llvm/utils/TableGen/DirectiveEmitter.cpp
===
--- llvm/utils/TableGen/DirectiveEmitter.cpp
+++ llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -645,6 +645,72 @@
   GenerateFlangClauseUnparse(DirLang, OS);
 }
 
+void GenerateClauseClassMacro(const DirectiveLanguage &DirLang,
+  raw_ostream &OS) {
+  // Generate macros style information for legacy code in clang
+  IfDefScope Scope("GEN_CLANG_CLAUSE_CLASS", OS);
+
+  OS << "\n";
+
+  OS << "#ifndef CLAUSE\n";
+  OS << "#define CLAUSE(Enum, Str, Implicit)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_CLASS\n";
+  OS << "#define CLAUSE_CLASS(Enum, Str, Class)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_NO_CLASS\n";
+  OS << "#define CLAUSE_NO_CLASS(Enum, Str)\n";
+  OS << "#endif\n";
+  OS << "\n";
+  OS << "#define __CLAUSE(Name, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, #Name, Class)\n";
+  OS << "#define __CLAUSE_NO_CLASS(Name)\\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, #Name)\n";
+  OS << "#define __IMPLICIT_CLAUSE_CLASS(Name, Str, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, Str, Class)\n";
+  OS << "#define __IMPLICIT_CLAUSE_NO_CLASS(Name, Str)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, Str)\n";
+  OS << "\n";
+
+  for (const auto &R : DirLang.getClauses()) {
+Clause C{R};
+if (C.getClangClass().empty()) { // NO_CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_NO_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\")\n";
+  } else {
+OS << "__CLAUSE_NO_CLASS(" << C.getFormattedName() << ")\n";
+  }
+} else { // CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\", " << C.getClangClass() << ")\n";
+  } else {
+OS << "__CLAUSE(" << C.getFormattedName() << ", " << C.getClangClass()
+   << ")\n";
+  }
+}
+  }
+
+  OS << "\n";
+  OS << "#undef __IMPLICIT_CLAUSE_NO_CLASS\n";
+  OS << "#undef __IMPLICIT_CLAUSE_CLASS\n";
+  OS << "#undef __CLAUSE\n";
+  OS << "#undef CLAUSE_NO_CLASS\n";
+  OS << "#undef CLAUSE_CLASS\n";
+  OS << "#undef CLAUSE\n";
+}
+
 // Generate the implemenation section for the enumeration in the directive
 // language.
 void EmitDirectivesGen(RecordKeeper &Records, raw_ostream &OS) {
@@ -653,6 +719,8 @@
 return;
 
   EmitDirectivesFlangImpl(DirLang, OS);
+
+  GenerateClauseClassMacro(DirLang, OS);
 }
 
 // Generate the implemenation for the enumeration in the directive
Index: llvm/test/TableGen/directive2.td
===
--- llvm/test/TableGen/directive2.td
+++ llvm/test/TableGen/directive2.td
@@ -23,10 +23,15 @@
   let isValueList = 1;
 }
 def TDLC_ClauseC : Clause<"clausec"> {
+  let clangClass = "ClauseC";
   let flangClassValue = "Name";
   let defaultValue = "*";
   let isValueOptional = 1;
 }
+def TDLC_ClauseD : Clause<"claused"> {
+  let clangClass = "ClauseD";
+  let isImplicit = 1;
+}
 
 def TDL_DirA : Directive<"dira"> {
   let allowedClauses = [
@@ -53,9 +58,10 @@
 // CHECK-NEXT:TDLC_clausea,
 // CHECK-NEXT:TDLC_clauseb,
 // CHECK-NEXT:TDLC_clausec,
+// CHECK-NEXT:TDLC_claused,
 // CH

[PATCH] D92179: [clang-tidy] Catch more unwanted implicit conversions in performance-implicit-conversion-in-loop

2020-12-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp:39
+CheckFactories.registerCheck(
+"performance-implicit-conversion");
 CheckFactories.registerCheck(

This check has been around since at least 2016 -- are we sure we want to rename 
it? @alexfh -- is this a case where we should leave the old check name as an 
alias?

Also, as we generalize the check, it starts to be a question of whether this 
should be in the frontend under one of the  `-Wconversion` flags (or a new one).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92179

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


[PATCH] D92971: clang-import-test: Clean up error output for files that cannot be found

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92971

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


[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/include/clang/AST/ASTTypeTraits.h:152
+#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 NKI_NumberOfKinds

Now we're even including the `cpp.inc` file in .h files. Please consider 
following the more regular way of doing .td stuff I've outlined in D83636.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92955

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


[PATCH] D92975: Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D92975

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


[PATCH] D92983: SourceManager: Migrate to FileEntryRef in getOrCreateContentCache, NFC

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

This LGTM, but it'd be nice to apply the formatting suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92983

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


[PATCH] D92984: SourceManager: Change getOrCreateFileID API to take FileEntryRef, NFC

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

This LGTM, but it'd be nice to apply the formatting suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92984

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


[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

And a less philosophical comment: This causes a bunch of 
Wcovered-switch-default warnings:

../../clang/include/clang/AST/OpenMPClause.h::5: warning: default label in 
switch which covers all enumeration values [-Wcovered-switch-default]
../../clang/include/clang/AST/RecursiveASTVisitor.h:2962:3: warning: default 
label in switch which covers all enumeration values [-Wcovered-switch-default]

(and possibly more).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92955

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


[clang] 456c885 - Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

2020-12-10 Thread via cfe-commits

Author: clementval
Date: 2020-12-10T10:34:59-05:00
New Revision: 456c885df369f1e94d60da2658055b21c88e471d

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

LOG: Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

This reverts commit a7b2847216b4f7a84ef75461fd47a5adfbb63e27.

failing buildbot on warnings

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 6eceb526ca4c..65319a19728b 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 92123ed2a32a..ea3da8d90c5b 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,9 +147,8 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -206,9 +205,8 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 57ba4fa5510f..cc6d3a93ba09 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,22 +7758,20 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) 
\
-  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
+  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) 
\
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define CLAUSE_NO_CLASS(Enum, Str) 
\
+#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
   case llvm::omp::Clause::Enum:
\
 break;
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 default:
   break;
 }
@@ -7806,9 +7804,9 @@ class OMPClausePrinter final : public 
OMPClauseVisitor {
   OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
   : OS(OS), Policy(Policy) {}
 
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class)  

[PATCH] D92531: Reapply "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"

2020-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Left one question.




Comment at: clang/lib/Basic/SourceManager.cpp:567
+  if (IR.ContentsEntry->isNamedPipe())
+(void)IR.getBufferOrNone(Diag, getFileManager(), SourceLocation());
+

What's the reason behind duplicating the logic here instead of calling 
`createFileID` with `const FileEntry *SourceFile`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92531

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


[PATCH] D91893: [clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

2020-12-10 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 310888.
flx added a comment.

Added positive variants of new tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91893

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tools-extra/clang-tidy/utils/Matchers.h
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -476,3 +476,35 @@
   auto Copy = Orig.reference();
   Update(Copy);
 }
+
+void negativeCopiedFromReferenceToModifiedVar() {
+  ExpensiveToCopyType Orig;
+  const auto &Ref = Orig;
+  const auto NecessaryCopy = Ref;
+  Orig.nonConstMethod();
+}
+
+void positiveCopiedFromReferenceToConstVar() {
+  ExpensiveToCopyType Orig;
+  const auto &Ref = Orig;
+  const auto UnnecessaryCopy = Ref;
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: local copy 'UnnecessaryCopy' of
+  // CHECK-FIXES: const auto& UnnecessaryCopy = Ref;
+  Orig.constMethod();
+}
+
+void negativeCopiedFromGetterOfReferenceToModifiedVar() {
+  ExpensiveToCopyType Orig;
+  const auto &Ref = Orig.reference();
+  const auto NecessaryCopy = Ref.reference();
+  Orig.nonConstMethod();
+}
+
+void positiveCopiedFromGetterOfReferenceToConstVar() {
+  ExpensiveToCopyType Orig;
+  const auto &Ref = Orig.reference();
+  auto UnnecessaryCopy = Ref.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'UnnecessaryCopy' is
+  // CHECK-FIXES: const auto& UnnecessaryCopy = Ref.reference();
+  Orig.constMethod();
+}
Index: clang-tools-extra/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -43,6 +43,12 @@
   return referenceType(pointee(qualType(isConstQualified(;
 }
 
+// Returns QualType matcher for pointers to const.
+AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isPointerToConst) {
+  using namespace ast_matchers;
+  return pointerType(pointee(qualType(isConstQualified(;
+}
+
 AST_MATCHER_P(NamedDecl, matchesAnyListedName, std::vector,
   NameList) {
   return llvm::any_of(NameList, [&Node](const std::string &Name) {
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -58,7 +58,7 @@
   SmallPtrSet DeclRefs;
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
-  qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
+  qualType(anyOf(matchers::isReferenceToConst(),
  unless(anyOf(referenceType(), pointerType(),
   substTemplateTypeParmType();
   auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
@@ -71,6 +71,20 @@
   Matches =
   match(findAll(cxxConstructExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
+  // References and pointers to const assignments.
+  Matches =
+  match(findAll(declStmt(
+has(varDecl(hasType(qualType(matchers::isReferenceToConst())),
+hasInitializer(ignoringImpCasts(DeclRefToVar)),
+Stmt, Context);
+  extractNodesByIdTo(Matches, "declRef", DeclRefs);
+  Matches =
+  match(findAll(declStmt(has(varDecl(
+hasType(qualType(matchers::isPointerToConst())),
+hasInitializer(ignoringImpCasts(unaryOperator(
+hasOperatorName("&"), hasUnaryOperand(DeclRefToVar,
+Stmt, Context);
+  extractNodesByIdTo(Matches, "declRef", DeclRefs);
   return DeclRefs;
 }
 
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -19,6 +19,14 @@
 namespace performance {
 namespace {
 
+using namespace ::clang::ast_matchers;
+using llvm::StringRef;
+using utils::decl_ref_expr::isOnlyUsedAsConst;
+
+static constexpr StringRef ObjectArgId = "objectArg";
+static constexpr StringRef InitFunctionCallId = "initFunctionCall";
+static constexpr StringRef OldVarDeclId = "oldVarDecl";
+
 void recordFixes(const VarDecl &Var, ASTContext &Context,
  DiagnosticBu

[PATCH] D91893: [clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

2020-12-10 Thread Felix Berger via Phabricator via cfe-commits
flx marked an inline comment as done.
flx added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp:492
+  Orig.nonConstMethod();
+}

aaron.ballman wrote:
> Making sure I understand properly, if you were calling `Orig.constMethod()` 
> then the diagnostic should be triggered, correct? Assuming so, having those 
> test cases would be useful.
Your understanding is correct. I validated the positive cases with the existing 
tests from lines 104 and 112, but those didn't have any further references to 
the original variable. I agree it's easier to understand when the negative and 
positive cases are grouped together.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91893

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


[PATCH] D93029: [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 310893.
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Addressed comments. Ready to land.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93029

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 //===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92920: [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 310894.
njames93 added a comment.
Herald added a subscriber: mgorny.

Added test cases.
Added assert to ensure Handler is valid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92920

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -2,6 +2,9 @@
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -122,6 +125,65 @@
   ASSERT_TRUE(Options.UseColor.hasValue());
   EXPECT_TRUE(*Options.UseColor);
 }
+namespace {
+
+struct Diag {
+  Diag(const llvm::SMDiagnostic &D)
+  : Message(D.getMessage()), Kind(D.getKind()) {
+Pos = D.getLoc().getPointer() -
+  D.getSourceMgr()
+  ->getMemoryBuffer(
+  D.getSourceMgr()->FindBufferContainingLoc(D.getLoc()))
+  ->getBufferStart();
+  }
+  std::string Message;
+  llvm::SourceMgr::DiagKind Kind;
+  size_t Pos;
+
+  friend void PrintTo(const Diag &D, std::ostream *OS) {
+*OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
+<< D.Message << "@" << llvm::to_string(D.Pos);
+  }
+};
+
+MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
+MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
+MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
+} // namespace
+
+using ::testing::AllOf;
+using ::testing::ElementsAre;
+
+TEST(ParseConfiguration, CollectDiags) {
+  std::vector Diags;
+  auto ParseWithDiags = [&](llvm::StringRef Buffer) {
+Diags.clear();
+return parseConfigurationWithDiags(
+llvm::MemoryBufferRef(Buffer, "Options"),
+[&](const llvm::SMDiagnostic &D) { Diags.push_back(D); });
+  };
+  // For some reason the YAML parser records an unknown key error at the value,
+  // not the key.
+  llvm::Annotations Options(R"(
+Check: ^llvm-include-order
+  )");
+  llvm::ErrorOr ParsedOpt = ParseWithDiags(Options.code());
+  EXPECT_TRUE(!ParsedOpt);
+  EXPECT_THAT(Diags,
+  testing::ElementsAre(AllOf(DiagMessage("unknown key 'Check'"),
+ DiagKind(llvm::SourceMgr::DK_Error),
+ DiagPos(Options.point();
+
+  Options = llvm::Annotations(R"(
+UseColor: ^NotABool
+  )");
+  ParsedOpt = ParseWithDiags(Options.code());
+  EXPECT_TRUE(!ParsedOpt);
+  EXPECT_THAT(Diags,
+  testing::ElementsAre(AllOf(DiagMessage("invalid boolean"),
+ DiagKind(llvm::SourceMgr::DK_Error),
+ DiagPos(Options.point();
+}
 
 namespace {
 class TestCheck : public ClangTidyCheck {
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TestingSupport
   )
 
 get_filename_component(CLANG_LINT_SOURCE_DIR
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
@@ -311,6 +312,11 @@
 llvm::ErrorOr
 parseConfiguration(llvm::MemoryBufferRef Config);
 
+using DiagCallback = llvm::function_ref;
+
+llvm::ErrorOr
+parseConfigurationWithDiags(llvm::MemoryBufferRef Config, DiagCallback Handler);
+
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
 #inclu

[PATCH] D92920: [clang-tidy] Add a diagnostic callback to parseConfiguration

2020-12-10 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:400
+DiagCallback Handler) {
+  llvm::yaml::Input Input(Config, nullptr, Handler ? diagHandlerImpl : nullptr,
+  &Handler);

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > Would it make sense to require `Handler` to be nonnull with an assertion?
> > Wasn't sure which way to go with that one, happy to use an assert if you 
> > think it's a good idea
> Now that I understand the use for this change better, I think the code is 
> good as-is.
Whoops, just changed it to assert


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92920

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


[PATCH] D93029: [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Utkarsh Saxena 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 rG4ce242a163c3: [clangd] Find relations in Dex exploration 
tool. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93029

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 //===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 4ce242a - [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2020-12-10T16:54:03+01:00
New Revision: 4ce242a163c3b98385a5cb949a7e6b1e1ae7eb83

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

LOG: [clangd] Find relations in Dex exploration tool.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index d7da330e2ed0..49f16e72be92 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@ class Refs : public Command {
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@ struct {
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 



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


[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-10 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D92955#2445815 , @thakis wrote:

> And a less philosophical comment: This causes a bunch of 
> Wcovered-switch-default warnings:
>
> ../../clang/include/clang/AST/OpenMPClause.h::5: warning: default label 
> in switch which covers all enumeration values [-Wcovered-switch-default]
> ../../clang/include/clang/AST/RecursiveASTVisitor.h:2962:3: warning: default 
> label in switch which covers all enumeration values [-Wcovered-switch-default]
>
> (and possibly more).

Yeah just saw that and reverted the patch. I'll rework a bit the patch to 
include your suggestion from D83636 . MLIR is 
doing it this way so I'm fine with doing it the other way as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92955

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


  1   2   3   >