[PATCH] D82787: Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode

2020-06-30 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:649
+  case BO_##NAME:  
\
+if (isSameMethod(::TraverseBin##NAME,  
\
+ ::TraverseBin##NAME)) {   
\

There's only one place that call PostVisitStmt. Could we pull this conditional 
there? It is repeated in every macro. It would make this function much simpler, 
and make clear at call site what is being done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82787



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


[PATCH] D82548: [CodeComplete] Add code completion for `delete` and `default` specifier.

2020-06-30 Thread liu hui via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83fae3f76269: [CodeComplete] Add code completion after 
function equals (authored by lh123).

Changed prior to commit:
  https://reviews.llvm.org/D82548?vs=274496=274685#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82548

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/after-function-equals.cpp

Index: clang/test/CodeCompletion/after-function-equals.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/after-function-equals.cpp
@@ -0,0 +1,47 @@
+struct A {
+  A() = default;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:2:9 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: default
+  // CHECK-CC1-NEXT: COMPLETION: delete
+
+  A(const A &) = default;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:7:18 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: COMPLETION: default
+  // CHECK-CC2-NEXT: COMPLETION: delete
+
+  A(const A &, int) = delete;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:12:23 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // CHECK-CC3-NOT: COMPLETION: default
+  // CHECK-CC3: COMPLETION: delete
+
+  A(A &&);
+
+  A =(const A &) = default;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:29 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+  // CHECK-CC4: COMPLETION: default
+  // CHECK-CC4-NEXT: COMPLETION: delete
+
+  bool operator==(const A &) const = delete;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:38 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+  // CHECK-CC5-NOT: COMPLETION: default
+  // CHECK-CC5: COMPLETION: delete
+
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:38 -std=gnu++20 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // CHECK-CC6: COMPLETION: default
+  // CHECK-CC6-NEXT: COMPLETION: delete
+
+  void test() = delete;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:33:17 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+  // CHECK-CC7-NOT: COMPLETION: default
+  // CHECK-CC7: COMPLETION: delete
+};
+
+A::A(A &&) = default;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:39:14 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: COMPLETION: default
+// CHECK-CC8-NEXT: COMPLETION: delete
+
+void test() = delete;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:44:15 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9-NOT: COMPLETION: default
+// CHECK-CC9: COMPLETION: delete
\ No newline at end of file
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -24,11 +24,13 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Designator.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Overload.h"
@@ -6266,6 +6268,53 @@
 Results.data(), Results.size());
 }
 
+void Sema::CodeCompleteAfterFunctionEquals(Declarator ) {
+  if (!LangOpts.CPlusPlus11)
+return;
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_Other);
+  auto ShouldAddDefault = [, this]() {
+if (!D.isFunctionDeclarator())
+  return false;
+auto  = D.getName();
+if (Id.getKind() == UnqualifiedIdKind::IK_DestructorName)
+  return true;
+// FIXME(liuhui): Ideally, we should check the constructor parameter list to
+// verify that it is the default, copy or move constructor?
+if (Id.getKind() == UnqualifiedIdKind::IK_ConstructorName &&
+D.getFunctionTypeInfo().NumParams <= 1)
+  return true;
+if (Id.getKind() == UnqualifiedIdKind::IK_OperatorFunctionId) {
+  auto Op = Id.OperatorFunctionId.Operator;
+  // FIXME(liuhui): Ideally, we should check the function parameter list to
+  // verify that it is the copy or move assignment?
+  if (Op == 

[PATCH] D82548: [CodeComplete] Add code completion for `delete` and `default` specifier.

2020-06-30 Thread liu hui via Phabricator via cfe-commits
lh123 added a comment.

In D82548#2124546 , @MaskRay wrote:

> Hi, your git commit contains extra Phabricator tags. You can drop 
> `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git 
> commit with the following script:
>
>   arcfilter () {
>   arc amend
>   git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
> /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ 
> {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
>   }
>   
>
> `Reviewed By: ` is considered important by some people. Please keep the tag. 
> (`--date=now` is my personal preference (author dates are usually not useful. 
> Using committer dates can make log almost monotonic in time))
>
> `https://reviews.llvm.org/D80978` contains a git pre-push hook to automate 
> this.


Thanks, should I revert it and recommit it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82548



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


[PATCH] D82548: [CodeComplete] Add code completion for `delete` and `default` specifier.

2020-06-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` 
`Subscribers:` `Tags:` and the text `Summary:` from the git commit with the 
following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. 
(`--date=now` is my personal preference (author dates are usually not useful. 
Using committer dates can make log almost monotonic in time))

`https://reviews.llvm.org/D80978` contains a git pre-push hook to automate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82548



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


[clang] 83fae3f - [CodeComplete] Add code completion after function equals

2020-06-30 Thread via cfe-commits

Author: lh123
Date: 2020-07-01T12:51:25+08:00
New Revision: 83fae3f762699655a4329fe3cf6fd3e2a2617559

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

LOG: [CodeComplete] Add code completion after function equals

Summary:
Provide `default` and `delete` completion after the function equals.

Reviewers: kadircet, sammccall

Tags: #clang

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

Added: 
clang/test/CodeCompletion/after-function-equals.cpp

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 77eda3b25c83..9b82d2c984be 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11996,6 +11996,7 @@ class Sema final {
 
   void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer ,
 bool AfterAmpersand);
+  void CodeCompleteAfterFunctionEquals(Declarator );
 
   void CodeCompleteObjCAtDirective(Scope *S);
   void CodeCompleteObjCAtVisibility(Scope *S);

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f336af6f1abc..c87d240a8206 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1898,46 +1898,52 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclGroup(ParsingDeclSpec ,
   }
 
   // Check to see if we have a function *definition* which must have a body.
-  if (D.isFunctionDeclarator() &&
-  // Look at the next token to make sure that this isn't a function
-  // declaration.  We have to check this because __attribute__ might be the
-  // start of a function definition in GCC-extended K C.
-  !isDeclarationAfterDeclarator()) {
-
-// Function definitions are only allowed at file scope and in C++ classes.
-// The C++ inline method definition case is handled elsewhere, so we only
-// need to handle the file scope definition case.
-if (Context == DeclaratorContext::FileContext) {
-  if (isStartOfFunctionDefinition(D)) {
-if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
-  Diag(Tok, diag::err_function_declared_typedef);
-
-  // Recover by treating the 'typedef' as spurious.
-  DS.ClearStorageClassSpecs();
-}
+  if (D.isFunctionDeclarator()) {
+if (Tok.is(tok::equal) && NextToken().is(tok::code_completion)) {
+  Actions.CodeCompleteAfterFunctionEquals(D);
+  cutOffParsing();
+  return nullptr;
+}
+// Look at the next token to make sure that this isn't a function
+// declaration.  We have to check this because __attribute__ might be the
+// start of a function definition in GCC-extended K C.
+if (!isDeclarationAfterDeclarator()) {
+
+  // Function definitions are only allowed at file scope and in C++ 
classes.
+  // The C++ inline method definition case is handled elsewhere, so we only
+  // need to handle the file scope definition case.
+  if (Context == DeclaratorContext::FileContext) {
+if (isStartOfFunctionDefinition(D)) {
+  if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
+Diag(Tok, diag::err_function_declared_typedef);
+
+// Recover by treating the 'typedef' as spurious.
+DS.ClearStorageClassSpecs();
+  }
 
-Decl *TheDecl =
-  ParseFunctionDefinition(D, ParsedTemplateInfo(), );
-return Actions.ConvertDeclToDeclGroup(TheDecl);
-  }
+  Decl *TheDecl = ParseFunctionDefinition(D, ParsedTemplateInfo(),
+  );
+  return Actions.ConvertDeclToDeclGroup(TheDecl);
+}
 
-  if (isDeclarationSpecifier()) {
-// If there is an invalid declaration specifier right after the
-// function prototype, then we must be in a missing semicolon case
-// where this isn't actually a body.  Just fall through into the code
-// that handles it as a prototype, and let the top-level code handle
-// the erroneous declspec where it would otherwise expect a comma or
-// semicolon.
+if (isDeclarationSpecifier()) {
+  // If there is an invalid declaration specifier right after the
+  // function prototype, then we must be in a missing semicolon case
+  // where this isn't actually a body.  Just fall through into the code
+  // that handles it as a prototype, and let the top-level code handle
+  // the erroneous declspec where it would otherwise expect a comma or
+  // semicolon.
+} else {
+  Diag(Tok, diag::err_expected_fn_body);
+  SkipUntil(tok::semi);
+

[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-06-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 274680.
amyk edited the summary of this revision.
amyk added a parent revision: D82576: [PowerPC][Power10] Implement low-order 
Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests.
amyk added a comment.

Rebase patch, remove MC tests from this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82609

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
  llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
@@ -73,3 +73,49 @@
   %tr = trunc <4 x i64> %shr to <4 x i32>
   ret <4 x i32> %tr
 }
+
+; Test the vector multiply high intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vmulhsw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhsw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <4 x i32> @test_vmulhuw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhuw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhuw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <2 x i64> @test_vmulhsd_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhsd_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
+
+define <2 x i64> @test_vmulhud_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhud_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhud v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
Index: llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
@@ -46,3 +46,49 @@
   %div = sdiv <4 x i32> %a, %b
   ret <4 x i32> %div
 }
+
+; Test the vector divide extended intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vdiveuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vdivesd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vdivesw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vdivesw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdivesw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %div
+}
+
+define <4 x i32> @test_vdiveuw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vdiveuw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdiveuw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <4 x i32> @llvm.ppc.altivec.vdiveuw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %div
+}
+
+define <2 x i64> @test_vdivesd(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vdivesd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdivesd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <2 x i64> @llvm.ppc.altivec.vdivesd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %div
+}
+
+define <2 x i64> @test_vdiveud(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vdiveud:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdiveud v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %div
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -849,13 +849,21 @@
 "vdivud $vD, $vA, $vB", IIC_VecGeneral,
 [(set v2i64:$vD, (udiv v2i64:$vA, v2i64:$vB))]>;
   def VDIVESW : VXForm_1<907, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- 

[PATCH] D82576: [PowerPC][Power10] Implement low-order Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests

2020-06-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 274679.
amyk edited the summary of this revision.
amyk added a parent revision: D82584: [PowerPC][Power10] Exploit the High Order 
Vector Multiply Instructions on Power10.
amyk added a comment.

Rebased patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82576

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -8,11 +8,73 @@
 vector signed char vsca;
 vector unsigned char vuca, vucb, vucc;
 vector unsigned short vusa, vusb, vusc;
+vector signed int vsia, vsib;
 vector unsigned int vuia, vuib, vuic;
+vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
 vector unsigned __int128 vui128a, vui128b, vui128c;
 unsigned int uia;
 
+vector signed long long test_vec_mul_sll(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mul_ull(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vulla, vullb);
+}
+
+vector signed int test_vec_div_si(void) {
+  // CHECK: sdiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vsia, vsib);
+}
+
+vector unsigned int test_vec_div_ui(void) {
+  // CHECK: udiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vuia, vuib);
+}
+
+vector signed long long test_vec_div_sll(void) {
+  // CHECK: sdiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_div_ull(void) {
+  // CHECK: udiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vulla, vullb);
+}
+
+vector signed int test_vec_mod_si(void) {
+  // CHECK: srem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vsia, vsib);
+}
+
+vector unsigned int test_vec_mod_ui(void) {
+  // CHECK: urem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vuia, vuib);
+}
+
+vector signed long long test_vec_mod_sll(void) {
+  // CHECK: srem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mod_ull(void) {
+  // CHECK: urem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vulla, vullb);
+}
+
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
   // CHECK-NEXT: ret <2 x i64>
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -16881,6 +16881,28 @@
   return __builtin_altivec_vctzdm(__a, __b);
 }
 
+/* vec_mod */
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_mod(vector signed int __a, vector signed int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_mod(vector unsigned int __a, vector unsigned int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_mod(vector signed long long __a, vector signed long long __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
+  return __a % __b;
+}
+
 #endif /* __POWER10_VECTOR__ */
 
 #undef __ATTRS_o_ai
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82930: [HIP] Fix rocm detection

2020-06-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, arsenm.
Herald added subscribers: kerbowa, nhaehnle, wdng, jvesely.

Do not detect device library by default in rocm detector. Only detect device 
library in HIP toolchain.

Detect rocm path by version file in host toolchains.

Also added detecting rocm version and printing rocm installation path and 
version with -v.

Fixed include path and device library detection for ROCm 3.5.


https://reviews.llvm.org/D82930

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/ROCm.h
  clang/test/Driver/Inputs/rocm/bin/.hipVersion

Index: clang/test/Driver/Inputs/rocm/bin/.hipVersion
===
--- /dev/null
+++ clang/test/Driver/Inputs/rocm/bin/.hipVersion
@@ -0,0 +1,4 @@
+# Auto-generated by cmake
+HIP_VERSION_MAJOR=3
+HIP_VERSION_MINOR=6
+HIP_VERSION_PATCH=20214-a2917cd
Index: clang/lib/Driver/ToolChains/ROCm.h
===
--- clang/lib/Driver/ToolChains/ROCm.h
+++ clang/lib/Driver/ToolChains/ROCm.h
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/VersionTuple.h"
 
 namespace clang {
 namespace driver {
@@ -38,11 +39,17 @@
 }
   };
 
+
   const Driver 
   bool IsValid = false;
-  // RocmVersion Version = RocmVersion::UNKNOWN;
+  // The version string in Major.Minor.Path format.
+  std::string DetectedVersion;
+  // Version containing major and minor.
+  llvm::VersionTuple VersionMajorMinor;
+  // Version containing patch.
+  std::string VersionPatch;
   SmallString<0> InstallPath;
-  // SmallString<0> BinPath;
+  SmallString<0> BinPath;
   SmallString<0> LibPath;
   SmallString<0> LibDevicePath;
   SmallString<0> IncludePath;
@@ -75,6 +82,7 @@
   mutable llvm::SmallSet ArchsWithBadVersion;
 
   void scanLibDevicePath();
+  void ParseHIPVersionFile(llvm::StringRef V);
 
 public:
   RocmInstallationDetector(const Driver , const llvm::Triple ,
@@ -163,6 +171,8 @@
 
   void AddHIPIncludeArgs(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const;
+
+  void detectDeviceLibrary(const llvm::opt::ArgList );
 };
 
 } // end namespace driver
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -805,6 +805,7 @@
 
 void MSVCToolChain::printVerboseInfo(raw_ostream ) const {
   CudaInstallation.print(OS);
+  RocmInstallation.print(OS);
 }
 
 // Windows SDKs and VC Toolchains group their contents into subdirectories based
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2656,6 +2656,7 @@
   // Print the information about how we detected the GCC installation.
   GCCInstallation.print(OS);
   CudaInstallation.print(OS);
+  RocmInstallation.print(OS);
 }
 
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList ) const {
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -89,6 +89,25 @@
   }
 }
 
+void RocmInstallationDetector::ParseHIPVersionFile(llvm::StringRef V) {
+  SmallVector VersionParts;
+  V.split(VersionParts, '\n');
+  unsigned Major;
+  unsigned Minor;
+  for (auto Part : VersionParts) {
+auto Splits = Part.split('=');
+if (Splits.first == "HIP_VERSION_MAJOR")
+  Splits.second.getAsInteger(0, Major);
+else if (Splits.first == "HIP_VERSION_MINOR")
+  Splits.second.getAsInteger(0, Minor);
+else if (Splits.first == "HIP_VERSION_PATCH")
+  VersionPatch = Splits.second.str();
+  }
+  VersionMajorMinor = llvm::VersionTuple(Major, Minor);
+  DetectedVersion =
+  (Twine(Major) + "." + Twine(Minor) + "." + VersionPatch).str();
+}
+
 RocmInstallationDetector::RocmInstallationDetector(
 const Driver , const llvm::Triple ,
 const llvm::opt::ArgList )
@@ -133,6 +152,33 @@
 Candidates.emplace_back(D.SysRoot + "/opt/rocm");
   }
 
+  auto  = D.getVFS();
+
+  for (const auto  : Candidates) {
+InstallPath = Candidate.Path;
+if (InstallPath.empty() || !FS.exists(InstallPath))
+  continue;
+
+llvm::sys::path::append(BinPath, InstallPath, "bin");
+llvm::sys::path::append(IncludePath, InstallPath, "include");
+llvm::sys::path::append(LibPath, InstallPath, "lib");
+
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(BinPath + "/.hipVersion");
+if (!VersionFile)
+  continue;
+
+ParseHIPVersionFile((*VersionFile)->getBuffer());
+IsValid = true;
+return;
+  }
+  IsValid = false;
+}
+
+void 

[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-06-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked an inline comment as done.
amyk added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:108
+   signed char *__c) {
+  // CHECK-BE: store i8 %{{.+}}, i8* %{{.+}}, align 1
+  // CHECK-LE: store i8 %{{.+}}, i8* %{{.+}}, align 1

lei wrote:
> I don't see a run line above that uses `CHECK-BE|CHECK-LE`.  Since all these 
> look the same, did you mean to use the default `CHECK`?
You're right - unfortunately in the previous tests that use 
`CHECK-BE`/`CHECK-LE` that were committed, I did not realize that I forgot to 
upstream the appropriate RUN lines... If it is okay, I can add them into this 
patch when I update it. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467



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


[PATCH] D82822: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-06-30 Thread Anchu Rajendran S via Phabricator via cfe-commits
anchu-rajendran accepted this revision.
anchu-rajendran added a comment.
This revision is now accepted and ready to land.

LGTM :). Thanks!




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1543
+OMPBuilder->getOrCreateIdent(SrcLocStr));
+  }
 

Nit: I think its better to add comments on the implicit assumptions in clang 
code / on why initializations here is not required if OMPIRBuilder is not used. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82822



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


[PATCH] D82431: [PowerPC][Power10] Implement Test LSB by Byte Builtins in LLVM/Clang

2020-06-30 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei added a comment.

LGTM thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82431



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


[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-06-30 Thread Lei Huang via Phabricator via cfe-commits
lei requested changes to this revision.
lei added a comment.
This revision now requires changes to proceed.

Please move encoding tests to ppc64-encoding-ISA31.[txt|s].




Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:108
+   signed char *__c) {
+  // CHECK-BE: store i8 %{{.+}}, i8* %{{.+}}, align 1
+  // CHECK-LE: store i8 %{{.+}}, i8* %{{.+}}, align 1

I don't see a run line above that uses `CHECK-BE|CHECK-LE`.  Since all these 
look the same, did you mean to use the default `CHECK`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467



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


[PATCH] D81836: [PowerPC][Power10] Implement Vector Permute Builtins in LLVM/Clang

2020-06-30 Thread Biplob Mishra via Phabricator via cfe-commits
biplmish updated this revision to Diff 274670.
biplmish added a comment.

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

https://reviews.llvm.org/D81836

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-permute-ops.ll

Index: llvm/test/CodeGen/PowerPC/p10-permute-ops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-permute-ops.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -mcpu=pwr10 \
+; RUN:   -ppc-vsr-nums-as-vr -mtriple=powerpc64le-unknown-unknown < %s | FileCheck %s
+
+; RUN: llc -verify-machineinstrs -ppc-asm-full-reg-names -mcpu=pwr10 \
+; RUN:   -ppc-vsr-nums-as-vr -mtriple=powerpc64-unknown-unknown < %s | FileCheck %s
+
+define <16 x i8> @testXXPERMX(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) {
+; CHECK-LABEL: testXXPERMX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxpermx v2, v2, v3, v4, 1
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.vsx.xxpermx(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c, i32 1)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.vsx.xxpermx(<16 x i8>, <16 x i8>, <16 x i8>, i32 immarg)
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -733,6 +733,14 @@
IIC_VecGeneral, []>;
 }
 
+let Predicates = [PrefixInstrs] in {
+  def : Pat<(v16i8 
+(int_ppc_vsx_xxpermx v16i8:$A, v16i8:$B, v16i8:$C , timm:$D)),
+(COPY_TO_REGCLASS (XXPERMX (COPY_TO_REGCLASS $A, VSRC),
+(COPY_TO_REGCLASS $B, VSRC), (COPY_TO_REGCLASS $C, VSRC), $D),
+VSRC)>;
+}
+
 let Predicates = [IsISA3_1] in {
   def VSLDBI : VNForm_VTAB5_SD3<22, 0, (outs vrrc:$VRT),
 (ins vrrc:$VRA, vrrc:$VRB, u3imm:$SH),
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1007,6 +1007,12 @@
 def int_ppc_vsx_xxgenpcvdm :
   PowerPC_VSX_Intrinsic<"xxgenpcvdm", [llvm_v2i64_ty],
 [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>;
+
+// P10 VSX Vector permute extended.
+def  int_ppc_vsx_xxpermx: GCCBuiltin<"__builtin_vsx_xxpermx">,
+ Intrinsic<[llvm_v16i8_ty],
+   [llvm_v16i8_ty,llvm_v16i8_ty,llvm_v16i8_ty,llvm_i32_ty],
+   [IntrNoMem, ImmArg>]>;
 }
 
 //===--===//
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -5,12 +5,17 @@
 
 #include 
 
-vector signed char vsca;
+vector signed char vsca, vscb;
 vector unsigned char vuca, vucb, vucc;
+vector signed short vssa, vssb;
 vector unsigned short vusa, vusb, vusc;
+vector signed int vsia, vsib;
 vector unsigned int vuia, vuib, vuic;
+vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
 vector unsigned __int128 vui128a, vui128b, vui128c;
+vector float vfa, vfb;
+vector double vda, vdb;
 unsigned int uia;
 
 vector unsigned long long test_vpdepd(void) {
@@ -146,3 +151,71 @@
   // CHECK-NEXT: ret <2 x i64>
   return vec_cnttzm(vulla, vullb);
 }
+
+vector signed char test_vec_permx_sc(void) {
+  // CHECK: @llvm.ppc.vsx.xxpermx(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_permx(vsca, vscb, vucc, 0);
+}
+
+vector unsigned char test_vec_permx_uc(void) {
+  // CHECK: @llvm.ppc.vsx.xxpermx(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_permx(vuca, vucb, vucc, 1);
+}
+
+vector signed short test_vec_permx_ss(void) {
+  // CHECK: @llvm.ppc.vsx.xxpermx(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32
+  // CHECK-NEXT: bitcast <16 x i8> %{{.*}} to <8 x i16>
+  // CHECK-NEXT: ret <8 x i16>
+  return vec_permx(vssa, vssb, vucc, 2);
+}
+
+vector unsigned short test_vec_permx_us(void) {
+  // CHECK: @llvm.ppc.vsx.xxpermx(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32
+  // CHECK-NEXT: bitcast <16 x i8> %{{.*}} to <8 x i16>
+  // CHECK-NEXT: ret <8 x i16>
+  return vec_permx(vusa, vusb, vucc, 3);
+}
+
+vector signed int test_vec_permx_si(void) {
+  // CHECK: @llvm.ppc.vsx.xxpermx(<16 x i8> %{{.+}}, <16 x i8> %{{.+}}, <16 x i8> %{{.+}}, i32
+  // CHECK-NEXT: 

[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-06-30 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
lxfind added reviewers: lewissbaker, modocache, junparser.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, source-based coverage analysis does not work properly for coroutine.
This patch adds processing of coroutine body and co_return in the coverage 
analysis, so that we can handle them properly.
For coroutine body, we should only look at the actual function body and ignore 
the compiler-generated things; for co_return, we need to terminate the region 
similar to return statement.
Added a test, and confirms that it now works properly. (without this patch, the 
statement after the if statement will be treated wrongly)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82928

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> 

[PATCH] D82562: Implement AVX ABI Warning/error

2020-06-30 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM other than that one minor.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:2515
+  SourceLocation CallLoc,
+  llvm::StringMap ,
+  llvm::StringMap , QualType Ty,

const the maps here too?


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

https://reviews.llvm.org/D82562



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


[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-06-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 274672.
amyk added a comment.

Update the patch to place MC tests into appropriate files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -360,3 +360,15 @@
 # CHECK-BE: xvtlsbb 1, 7  # encoding: [0xf0,0x82,0x3f,0x6c]
 # CHECK-LE: xvtlsbb 1, 7  # encoding: [0x6c,0x3f,0x82,0xf0]
 xvtlsbb 1, 7
+# CHECK-BE: stxvrbx 32, 3, 1  # encoding: [0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1  # encoding: [0x1b,0x09,0x03,0x7c]
+stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1  # encoding: [0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1  # encoding: [0x5b,0x09,0x23,0x7c]
+stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1  # encoding: [0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1  # encoding: [0x9b,0x09,0x43,0x7c]
+stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1  # encoding: [0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1  # encoding: [0xdb,0x09,0x63,0x7c]
+stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -233,3 +233,15 @@
 
 # CHECK: xvtlsbb 1, 7
 0xf0 0x82 0x3f 0x6c
+
+# CHECK: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -33,3 +33,113 @@
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 0)
   ret i32 %0
 }
+
+define void @vec_xst_trunc_sc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_sc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_uc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_uc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_ss(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_ss:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_us(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_us:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_si(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_si:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 2
+; CHECK-NEXT:stxvrwx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <4 x i32>
+  %conv = extractelement <4 x i32> %0, i32 0
+  %add.ptr = getelementptr inbounds i32, i32* %__ptr, i64 %__offset
+  store i32 %conv, i32* %add.ptr, align 4
+  ret void
+}
+
+define void 

[PATCH] D71491: [ubsan] Check implicit casts in ObjC for-in statements

2020-06-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Thank you, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71491



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


[PATCH] D82431: [PowerPC][Power10] Implement Test LSB by Byte Builtins in LLVM/Clang

2020-06-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 274667.
amyk added a comment.

Update patch to:

- place MC tests in correct files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82431

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -357,3 +357,6 @@
 # CHECK-BE: vsrdbi 2, 3, 4, 5 # encoding: [0x10,0x43,0x23,0x56]
 # CHECK-LE: vsrdbi 2, 3, 4, 5 # encoding: [0x56,0x23,0x43,0x10]
 vsrdbi 2, 3, 4, 5
+# CHECK-BE: xvtlsbb 1, 7  # encoding: [0xf0,0x82,0x3f,0x6c]
+# CHECK-LE: xvtlsbb 1, 7  # encoding: [0x6c,0x3f,0x82,0xf0]
+xvtlsbb 1, 7
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -230,3 +230,6 @@
 
 # CHECK: vsrdbi 2, 3, 4, 5
 0x10 0x43 0x23 0x56
+
+# CHECK: xvtlsbb 1, 7
+0xf0 0x82 0x3f 0x6c
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These test cases aims to test the builtins for the Power10 VSX vector
+; instructions introduced in ISA 3.1.
+
+declare i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8>, i1)
+
+define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> %vuca) {
+; CHECK-LABEL: test_vec_test_lsbb_all_ones:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtlsbb cr0, v2
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:srwi r3, r3, 31
+; CHECK-NEXT:extsw r3, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 1)
+  ret i32 %0
+}
+
+define signext i32 @test_vec_test_lsbb_all_zeros(<16 x i8> %vuca) {
+; CHECK-LABEL: test_vec_test_lsbb_all_zeros:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtlsbb cr0, v2
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:rlwinm r3, r3, 3, 31, 31
+; CHECK-NEXT:extsw r3, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 0)
+  ret i32 %0
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -356,6 +356,25 @@
   let Inst{63} = XT{5};
 }
 
+// [PO BF / XO2 B XO BX /]
+class XX2_BF3_XO5_XB6_XO9 opcode, bits<5> xo2, bits<9> xo, dag OOL,
+  dag IOL, string asmstr, InstrItinClass itin,
+  list pattern>
+  : I {
+  bits<3> BF;
+  bits<6> XB;
+
+  let Pattern = pattern;
+
+  let Inst{6-8}   = BF;
+  let Inst{9-10}  = 0;
+  let Inst{11-15} = xo2;
+  let Inst{16-20} = XB{4-0};
+  let Inst{21-29} = xo;
+  let Inst{30}= XB{5};
+  let Inst{31}= 0;
+}
+
 multiclass MLS_DForm_R_SI34_RTA5_MEM_p opcode, dag OOL, dag IOL,
dag PCRel_IOL, string asmstr,
InstrItinClass itin> {
@@ -809,6 +828,8 @@
  "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
  [(set v16i8:$vD,
(int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
+   def XVTLSBB : XX2_BF3_XO5_XB6_XO9<60, 2, 475, (outs crrc:$BF), (ins vsrc:$XB),
+ "xvtlsbb $BF, $XB", IIC_VecGeneral, []>;
 }
 
 // Anonymous Patterns //
@@ -821,4 +842,8 @@
 (v4i32 (COPY_TO_REGCLASS (XXGENPCVWM $VRB, imm:$IMM), VRRC))>;
   def : Pat<(v2i64 (int_ppc_vsx_xxgenpcvdm v2i64:$VRB, imm:$IMM)),
 (v2i64 (COPY_TO_REGCLASS (XXGENPCVDM $VRB, imm:$IMM), VRRC))>;
+  def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, -1)),
+(EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_lt)>;
+  def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 0)),
+(EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_eq)>;
 }
Index: 

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-30 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:86
+
+HasStrictFP = true;
   }

nemanjai wrote:
> I don't think we need this for now. Close is not quite there. @steven.zhang I 
> would prefer that we initially turn this off and only flip it on once the 
> support is complete.
> Also, is the support that is currently under development for both 32 and 64 
> bit architectures? If it is 64 bit only, then we can enable it only there 
> once it is done.
Yes, it hasn't been finished yet. Agree that we can turn on it later when it is 
done.


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

https://reviews.llvm.org/D80952



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


[PATCH] D78655: [CUDA][HIP] Let lambda be host device by default

2020-06-30 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added inline comments.



Comment at: clang/test/SemaCUDA/lambda.cu:27
+
+kernel<<<1,1>>>([&](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in 
device or host device lambda function}}

Will this still produce diagnostics when the lambda is explicitly `__device__`? 
Maybe you could add a test case for that.

```
kernel<<<1,1>>>([&]() __device__ { hd(b); });
```


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

https://reviews.llvm.org/D78655



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


[clang] 4eff2be - [c++20] consteval functions don't get vtable slots.

2020-06-30 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-30T18:22:09-07:00
New Revision: 4eff2beefb2b655fc02d35de235fc86d72d05755

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

LOG: [c++20] consteval functions don't get vtable slots.

For the Itanium C++ ABI, this implements the rule added in
https://github.com/itanium-cxx-abi/cxx-abi/pull/83

For the MS C++ ABI, this implements the direction that seemed most
plausible based on personal correspondence with MSVC developers, but is
subject to change as they decide their ABI rule.

Added: 
clang/test/CodeGenCXX/vtable-consteval.cpp

Modified: 
clang/include/clang/AST/VTableBuilder.h
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/AST/VTableBuilder.cpp
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/include/clang/AST/VTableBuilder.h 
b/clang/include/clang/AST/VTableBuilder.h
index e6557e438919..241dd13f903e 100644
--- a/clang/include/clang/AST/VTableBuilder.h
+++ b/clang/include/clang/AST/VTableBuilder.h
@@ -354,6 +354,9 @@ class VTableContextBase {
   }
 
   bool IsMicrosoftABI;
+
+  /// Determine whether this function should be assigned a vtable slot.
+  static bool hasVtableSlot(const CXXMethodDecl *MD);
 };
 
 class ItaniumVTableContext : public VTableContextBase {

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 3d5f785e943e..b44957a35279 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/VTableBuilder.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/Format.h"
@@ -2568,9 +2569,11 @@ 
MicrosoftRecordLayoutBuilder::layoutNonVirtualBases(const CXXRecordDecl *RD) {
   // information about the bases, such as required alignment and the presence 
of
   // zero sized members.
   const ASTRecordLayout *PreviousBaseLayout = nullptr;
+  bool HasPolymorphicBaseClass = false;
   // Iterate through the bases and lay out the non-virtual ones.
   for (const CXXBaseSpecifier  : RD->bases()) {
 const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+HasPolymorphicBaseClass |= BaseDecl->isPolymorphic();
 const ASTRecordLayout  = Context.getASTRecordLayout(BaseDecl);
 // Mark and skip virtual bases.
 if (Base.isVirtual()) {
@@ -2594,11 +2597,23 @@ 
MicrosoftRecordLayoutBuilder::layoutNonVirtualBases(const CXXRecordDecl *RD) {
 layoutNonVirtualBase(RD, BaseDecl, BaseLayout, PreviousBaseLayout);
   }
   // Figure out if we need a fresh VFPtr for this class.
-  if (!PrimaryBase && RD->isDynamicClass())
-for (CXXRecordDecl::method_iterator i = RD->method_begin(),
-e = RD->method_end();
- !HasOwnVFPtr && i != e; ++i)
-  HasOwnVFPtr = i->isVirtual() && i->size_overridden_methods() == 0;
+  if (RD->isPolymorphic()) {
+if (!HasPolymorphicBaseClass)
+  // This class introduces polymorphism, so we need a vftable to store the
+  // RTTI information.
+  HasOwnVFPtr = true;
+else if (!PrimaryBase) {
+  // We have a polymorphic base class but can't extend its vftable. Add a
+  // new vfptr if we would use any vftable slots.
+  for (CXXMethodDecl *M : RD->methods()) {
+if (MicrosoftVTableContext::hasVtableSlot(M) &&
+M->size_overridden_methods() == 0) {
+  HasOwnVFPtr = true;
+  break;
+}
+  }
+}
+  }
   // If we don't have a primary base then we have a leading object that could
   // itself lead with a zero-sized object, something we track.
   bool CheckLeadingLayout = !PrimaryBase;
@@ -2993,7 +3008,8 @@ void MicrosoftRecordLayoutBuilder::computeVtorDispSet(
   llvm::SmallPtrSet BasesWithOverriddenMethods;
   // Seed the working set with our non-destructor, non-pure virtual methods.
   for (const CXXMethodDecl *MD : RD->methods())
-if (MD->isVirtual() && !isa(MD) && !MD->isPure())
+if (MicrosoftVTableContext::hasVtableSlot(MD) &&
+!isa(MD) && !MD->isPure())
   Work.insert(MD);
   while (!Work.empty()) {
 const CXXMethodDecl *MD = *Work.begin();

diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 013ebe23ec91..f5865ce96b64 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -408,7 +408,7 @@ void FinalOverriders::dump(raw_ostream , BaseSubobject 
Base,
 
   // Now dump the overriders for this base subobject.
   for (const auto *MD : RD->methods()) {
-if (!MD->isVirtual())
+if (!VTableContextBase::hasVtableSlot(MD))
   continue;
 MD = MD->getCanonicalDecl();
 
@@ -486,8 +486,8 @@ static bool 

[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-06-30 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Can we just use `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` 
 instead?  I'm 
a little wary of introducing a new way to do conditional compilation since 
fuzzers that don't use sancov can't rely on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82926



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


[PATCH] D82924: [clang-tidy] fix cppcoreguidelines-init-variables with catch variables

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 274654.
njames93 added a comment.
Herald added a subscriber: wuzish.

Remove unneeded include


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82924

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing -fexceptions
 
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
   for (char c : r) {
   }
 }
+
+void catch_variable_decl() {
+  // Expect no warning given here.
+  try {
+  } catch (int X) {
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -42,6 +42,7 @@
   Finder->addMatcher(
   varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
   isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+  unless(hasParent(cxxCatchStmt())),
   optionally(hasParent(declStmt(hasParent(
   
cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))),
   unless(equalsBoundNode(BadDecl)))


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing -fexceptions
 
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
   for (char c : r) {
   }
 }
+
+void catch_variable_decl() {
+  // Expect no warning given here.
+  try {
+  } catch (int X) {
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -42,6 +42,7 @@
   Finder->addMatcher(
   varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
   isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+  unless(hasParent(cxxCatchStmt())),
   optionally(hasParent(declStmt(hasParent(
   cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))),
   unless(equalsBoundNode(BadDecl)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-06-30 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 274656.
hctim added a comment.

Changed the filename and fixed up the inverted test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82926

Files:
  clang/include/clang/Basic/Features.def
  clang/test/Lexer/has_feature_fuzzing_coverage.cpp


Index: clang/test/Lexer/has_feature_fuzzing_coverage.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_fuzzing_coverage.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer-no-link %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+
+#if __has_feature(fuzzing_coverage)
+int FuzzingCoverageEnabled();
+#else
+int FuzzingCoverageDisabled();
+#endif
+
+// CHECK-NONE: FuzzingCoverageDisabled
+// CHECK-ENABLED: FuzzingCoverageEnabled
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -49,6 +49,9 @@
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
+FEATURE(fuzzing_coverage,
+LangOpts.Sanitize.hasOneOf(SanitizerKind::Fuzzer |
+   SanitizerKind::FuzzerNoLink))
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)
 FEATURE(attribute_availability, true)


Index: clang/test/Lexer/has_feature_fuzzing_coverage.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_fuzzing_coverage.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer-no-link %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+
+#if __has_feature(fuzzing_coverage)
+int FuzzingCoverageEnabled();
+#else
+int FuzzingCoverageDisabled();
+#endif
+
+// CHECK-NONE: FuzzingCoverageDisabled
+// CHECK-ENABLED: FuzzingCoverageEnabled
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -49,6 +49,9 @@
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
+FEATURE(fuzzing_coverage,
+LangOpts.Sanitize.hasOneOf(SanitizerKind::Fuzzer |
+   SanitizerKind::FuzzerNoLink))
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)
 FEATURE(attribute_availability, true)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82924: [clang-tidy] fix cppcoreguidelines-init-variables with catch variables

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 274655.
njames93 added a comment.

New line at end of file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82924

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing -fexceptions
 
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
   for (char c : r) {
   }
 }
+
+void catch_variable_decl() {
+  // Expect no warning given here.
+  try {
+  } catch (int X) {
+  }
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -42,6 +42,7 @@
   Finder->addMatcher(
   varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
   isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+  unless(hasParent(cxxCatchStmt())),
   optionally(hasParent(declStmt(hasParent(
   
cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))),
   unless(equalsBoundNode(BadDecl)))


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing -fexceptions
 
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
   for (char c : r) {
   }
 }
+
+void catch_variable_decl() {
+  // Expect no warning given here.
+  try {
+  } catch (int X) {
+  }
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -42,6 +42,7 @@
   Finder->addMatcher(
   varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
   isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+  unless(hasParent(cxxCatchStmt())),
   optionally(hasParent(declStmt(hasParent(
   cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))),
   unless(equalsBoundNode(BadDecl)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82924: [clang-tidy] fix cppcoreguidelines-init-variables with catch variables

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, gribozavr2.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.

Ignore catch statement var decls.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82924

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing -fexceptions
 
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
   for (char c : r) {
   }
 }
+
+void catch_variable_decl() {
+  // Expect no warning given here.
+  try {
+  } catch (int X) {
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -9,6 +9,7 @@
 #include "InitVariablesCheck.h"
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/StmtCXX.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -42,6 +43,7 @@
   Finder->addMatcher(
   varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
   isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+  unless(hasParent(cxxCatchStmt())),
   optionally(hasParent(declStmt(hasParent(
   
cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))),
   unless(equalsBoundNode(BadDecl)))


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing -fexceptions
 
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
   for (char c : r) {
   }
 }
+
+void catch_variable_decl() {
+  // Expect no warning given here.
+  try {
+  } catch (int X) {
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -9,6 +9,7 @@
 #include "InitVariablesCheck.h"
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/StmtCXX.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -42,6 +43,7 @@
   Finder->addMatcher(
   varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
   isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+  unless(hasParent(cxxCatchStmt())),
   optionally(hasParent(declStmt(hasParent(
   cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))),
   unless(equalsBoundNode(BadDecl)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82926: [libfuzzer] [clang] Add __has_feature(fuzzing_coverage)

2020-06-30 Thread Mitch Phillips via Phabricator via cfe-commits
hctim created this revision.
hctim added reviewers: morehouse, Dor1s.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Probably a useful feature for checking whether a file was built with
-fsanitize=fuzzer or -fsanitize=fuzzer-no-link.

N.B. __has_feature(fuzzing_coverage) doesn't cover instances where users
manually specify -fsanitize-coverage=... (even if the flags are
identical to ToT -fsanitize=fuzzer-no-link). IMHO this is WAI -
-fsanitize=fuzzer-no-link is not a stable set of flags and people that
want sancov for fuzzing should use fuzzer-no-link.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82926

Files:
  clang/include/clang/Basic/Features.def
  clang/test/Lexer/has_feature_libfuzzer.cpp


Index: clang/test/Lexer/has_feature_libfuzzer.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_libfuzzer.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer-no-link %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+
+#if __has_feature(fuzzing_coverage)
+int FuzzingCoverageEnabled();
+#else
+int FuzzingCoverageDisabled();
+#endif
+
+// CHECK-NONE: FuzzingCoverageEnabled
+// CHECK-ENABLED: FuzzingCoverageDisabled
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -49,6 +49,9 @@
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
+FEATURE(fuzzing_coverage,
+LangOpts.Sanitize.hasOneOf(SanitizerKind::Fuzzer |
+   SanitizerKind::FuzzerNoLink))
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)
 FEATURE(attribute_availability, true)


Index: clang/test/Lexer/has_feature_libfuzzer.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_libfuzzer.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+// RUN: %clang_cc1 -E -fsanitize=fuzzer-no-link %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-ENABLED %s
+
+#if __has_feature(fuzzing_coverage)
+int FuzzingCoverageEnabled();
+#else
+int FuzzingCoverageDisabled();
+#endif
+
+// CHECK-NONE: FuzzingCoverageEnabled
+// CHECK-ENABLED: FuzzingCoverageDisabled
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -49,6 +49,9 @@
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
+FEATURE(fuzzing_coverage,
+LangOpts.Sanitize.hasOneOf(SanitizerKind::Fuzzer |
+   SanitizerKind::FuzzerNoLink))
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)
 FEATURE(attribute_availability, true)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-06-30 Thread Ellis Hoag via Phabricator via cfe-commits
ellis marked an inline comment as done.
ellis added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:125
+CheckFactories.registerCheck(
+"bugprone-no-escape");
 CheckFactories.registerCheck(

Not sure if we want to lint this line because it was generated by 
`clang-tidy/add_new_check.py` and every other `registerCheck` line is formatted 
in the same way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D82921: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods

2020-06-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gribozavr2 added reviewers: rsmith, sammccall, ymandel, aaron.ballman.
gribozavr updated this revision to Diff 274643.
gribozavr added a comment.

Removed obsolete comments.


This feature was only used in two places, but contributed a non-trivial
amount to the complexity of RecursiveASTVisitor, and was buggy (see my
recent patches where I was fixing the bugs that I noticed). I don't
think the convenience benefit of this feature is worth the complexity.

This change reduces the size of the `clang` binary by 38 KB (0.2%) in
release mode, and by 7 MB (0.3%) in debug mode. The `clang-tidy` binary
is reduced by 205 KB (0.3%) in release mode, and by 5 MB (0.4%) in debug
mode. I don't think these code size improvements are significant enough
to justify this change on its own (for me, the primary motivation is
reducing code complexity), but they I think are a side-effect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82921

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -403,622 +403,40 @@
 }
 )cpp";
 
-  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
-  // individual operators as subclasses, for which it calls their Traverse
-  // methods.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::No), Code,
   R"txt(
 WalkUpFromStmt CompoundStmt
 WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(3)
-)txt"));
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
-  R"txt(
-WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CompoundStmt
-)txt"));
-}
-
-TEST(RecursiveASTVisitor,
- StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
-  class RecordingVisitor : public RecordingVisitorBase {
-  public:
-RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
-
-bool TraverseUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::TraverseUnaryOperator(UO);
-  });
-  return true;
-}
-
-bool WalkUpFromStmt(Stmt *S) {
-  recordCallback(__func__, S,
- [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
-  return true;
-}
-
-bool WalkUpFromExpr(Expr *E) {
-  recordCallback(__func__, E,
- [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
-  return true;
-}
-
-bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
-  });
-  return true;
-}
-  };
-
-  StringRef Code = R"cpp(
-void test() {
-  1;
-  -2;
-  3;
-}
-)cpp";
-
-  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
-  // individual operators as subclasses, for which it calls their Traverse
-  // methods.
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::No), Code,
-  R"txt(
-WalkUpFromStmt CompoundStmt
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromExpr IntegerLiteral(2)
-  WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromExpr IntegerLiteral(3)
-  WalkUpFromStmt IntegerLiteral(3)
-)txt"));
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
-  R"txt(
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromExpr IntegerLiteral(2)
-  WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromExpr IntegerLiteral(3)
-  WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CompoundStmt
-)txt"));
-}
-
-TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromUnaryOperator) {
-  class RecordingVisitor : public RecordingVisitorBase {
-  public:
-RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
-
-bool WalkUpFromStmt(Stmt *S) {
-  

[PATCH] D82921: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods

2020-06-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 274643.
gribozavr added a comment.

Removed obsolete comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82921

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -403,622 +403,40 @@
 }
 )cpp";
 
-  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
-  // individual operators as subclasses, for which it calls their Traverse
-  // methods.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::No), Code,
   R"txt(
 WalkUpFromStmt CompoundStmt
 WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(3)
-)txt"));
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
-  R"txt(
-WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CompoundStmt
-)txt"));
-}
-
-TEST(RecursiveASTVisitor,
- StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
-  class RecordingVisitor : public RecordingVisitorBase {
-  public:
-RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
-
-bool TraverseUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::TraverseUnaryOperator(UO);
-  });
-  return true;
-}
-
-bool WalkUpFromStmt(Stmt *S) {
-  recordCallback(__func__, S,
- [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
-  return true;
-}
-
-bool WalkUpFromExpr(Expr *E) {
-  recordCallback(__func__, E,
- [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
-  return true;
-}
-
-bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
-  });
-  return true;
-}
-  };
-
-  StringRef Code = R"cpp(
-void test() {
-  1;
-  -2;
-  3;
-}
-)cpp";
-
-  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
-  // individual operators as subclasses, for which it calls their Traverse
-  // methods.
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::No), Code,
-  R"txt(
-WalkUpFromStmt CompoundStmt
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromExpr IntegerLiteral(2)
-  WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromExpr IntegerLiteral(3)
-  WalkUpFromStmt IntegerLiteral(3)
-)txt"));
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
-  R"txt(
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromExpr IntegerLiteral(2)
-  WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromExpr IntegerLiteral(3)
-  WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CompoundStmt
-)txt"));
-}
-
-TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromUnaryOperator) {
-  class RecordingVisitor : public RecordingVisitorBase {
-  public:
-RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
-
-bool WalkUpFromStmt(Stmt *S) {
-  recordCallback(__func__, S,
- [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
-  return true;
-}
-
-bool WalkUpFromExpr(Expr *E) {
-  recordCallback(__func__, E,
- [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
-  return true;
-}
-
-bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
-  });
-  return true;
-}
-  };
-
-  StringRef Code = R"cpp(
-void test() {
-  1;
-  -2;
-  3;
-}
-)cpp";
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::No), Code,
-  R"txt(
-WalkUpFromStmt CompoundStmt
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromUnaryOperator 

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-06-30 Thread Johel Ernesto Guerrero Peña via Phabricator via cfe-commits
JohelEGP added a comment.

  constexpr plane(const plane& other) noexcept(
  (detail::default_allocator_is_nothrow &&
   std::is_nothrow_copy_constructible_v)) requires(std::copyable)
: plane{to1d(other), other.sz.w}
  {
  }

Without the parentheses in trailing requires-clauses, all code following the 
constructor initializer list is further indented.


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

https://reviews.llvm.org/D79773



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


[PATCH] D82642: [clangd] Run formatting operations asynchronously.

2020-06-30 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked 2 inline comments as done.
Closed by commit rGffa63dde8e97: [clangd] Run formatting operations 
asynchronously. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82642

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -44,6 +44,9 @@
 Position Pos, StringRef NewName,
 const clangd::RenameOptions );
 
+llvm::Expected
+runFormatFile(ClangdServer , PathRef File, StringRef Code);
+
 std::string runDumpAST(ClangdServer , PathRef File);
 
 llvm::Expected>
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -105,6 +105,13 @@
   return std::move(*Result);
 }
 
+llvm::Expected
+runFormatFile(ClangdServer , PathRef File, StringRef Code) {
+  llvm::Optional> Result;
+  Server.formatFile(File, Code, capture(Result));
+  return std::move(*Result);
+}
+
 std::string runDumpAST(ClangdServer , PathRef File) {
   llvm::Optional Result;
   Server.dumpAST(File, capture(Result));
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -878,7 +878,7 @@
   FS.Files[Path] = Code;
   runAddDocument(Server, Path, Code);
 
-  auto Replaces = Server.formatFile(Code, Path);
+  auto Replaces = runFormatFile(Server, Path, Code);
   EXPECT_TRUE(static_cast(Replaces));
   auto Changed = tooling::applyAllReplacements(Code, *Replaces);
   EXPECT_TRUE(static_cast(Changed));
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -247,18 +247,17 @@
   Callback CB);
 
   /// Run formatting for \p Rng inside \p File with content \p Code.
-  llvm::Expected formatRange(StringRef Code,
-PathRef File, Range Rng);
+  void formatRange(PathRef File, StringRef Code, Range Rng,
+   Callback CB);
 
   /// Run formatting for the whole \p File with content \p Code.
-  llvm::Expected formatFile(StringRef Code,
-   PathRef File);
+  void formatFile(PathRef File, StringRef Code,
+  Callback CB);
 
   /// Run formatting after \p TriggerText was typed at \p Pos in \p File with
   /// content \p Code.
-  llvm::Expected> formatOnType(StringRef Code,
- PathRef File, Position Pos,
- StringRef TriggerText);
+  void formatOnType(PathRef File, StringRef Code, Position Pos,
+StringRef TriggerText, Callback> CB);
 
   /// Test the validity of a rename operation.
   void prepareRename(PathRef File, Position Pos,
@@ -323,11 +322,9 @@
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
 private:
-  /// FIXME: This stats several files to find a .clang-format file. I/O can be
-  /// slow. Think of a way to cache this.
-  llvm::Expected
-  formatCode(llvm::StringRef Code, PathRef File,
- ArrayRef Ranges);
+  void formatCode(PathRef File, llvm::StringRef Code,
+  ArrayRef Ranges,
+  Callback CB);
 
   const ThreadsafeFS 
 
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -296,40 +296,46 @@
 std::move(Action));
 }
 
-llvm::Expected
-ClangdServer::formatRange(llvm::StringRef Code, PathRef File, Range Rng) {
+void ClangdServer::formatRange(PathRef File, llvm::StringRef Code, Range Rng,
+   Callback CB) {
   llvm::Expected Begin = positionToOffset(Code, Rng.start);
   if (!Begin)
-return Begin.takeError();
+return CB(Begin.takeError());
   llvm::Expected End = positionToOffset(Code, Rng.end);
   if (!End)
-return End.takeError();
-  return formatCode(Code, File, {tooling::Range(*Begin, *End - *Begin)});
+

[PATCH] D82436: [clangd] Implement textDocument/foldingRange

2020-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:967
+  URIForFile FileURI = Params.textDocument.uri;
+  Server->foldingRanges(
+  Params.textDocument.uri.file(),

one we fix the signature, you should just be able to pass the callback through.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:969
+  Params.textDocument.uri.file(),
+  [FileURI, Reply = std::move(Reply)](
+  llvm::Expected> Items) mutable {

unused capture (and variable)



Comment at: clang-tools-extra/clangd/ClangdLSPServer.h:90
 Callback);
+  void onFoldingRange(const FoldingRangeParams &, Callback);
   void onCodeAction(const CodeActionParams &, Callback);

this should return (as callback) vector.
You got unlucky: it's sandwiched between onDocumentSymbol and onCodeAction 
which both have to be dynamically typed as they return different structures 
depending on capabilities.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:281
+  Range.startCharacter = Symbol.range.start.character;
+  Range.endLine = Symbol.range.end.line;
+  Range.endCharacter = Symbol.range.end.character;

How useful are folding ranges when symbols start/end on the same line? Do we 
really want to emit them?



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:297
+llvm::Expected> getFoldingRanges(ParsedAST ) {
+  auto DocumentSymbols = collectDocSymbols(AST);
+  std::vector Result;

I'm not sure whether this is the right foundation, vs RecursiveASTVisitor.
How would we generalize to compoundstmts etc without RAV, and if we do use RAV 
for those, why would we still use getDocSymbols for anythnig?



Comment at: clang-tools-extra/clangd/FindSymbols.h:50
 
+/// Retrieves folding ranges using Document Symbols in the "main file" section
+/// of given AST.

"using Document Symbols" seems like an implementation detail here, I'd keep it 
out of the first line at least.

Maybe separate out explicitly in a second line: Currently this includes the 
ranges of multi-line symbols (functions etc)



Comment at: clang-tools-extra/clangd/FindSymbols.h:52
+/// of given AST.
+llvm::Expected> getFoldingRanges(ParsedAST );
+

This seems like a surprising place to find this function - it only really makes 
sense when considering the current implementation (which will presumably grow).
I think it'd be a more natural fit in SemanticSelection, maybe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82436



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-30 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 274636.
nickdesaulniers added a comment.

- fix documentation double negation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: !DIEnumerator(name: "BAZ"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+class ;
+enum class ;
+
+// NODBG-NOT: ;
+// NODBG-NOT: ;
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,60 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: !DIEnumerator(name: "BAR"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "baz"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "y"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "w"
+
+// Check that debug info is not emitted for the typedef, struct, enum, and
+// union when -fno-eliminate-unused-debug-types and -g are not set. 

[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-06-30 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Your patch definitely fixes the symptoms of the bug. I just want to make sure 
that we aren't covering some logic error with a bandaid as it would be harder 
to find out the root cause once we land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-06-30 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

Please move encoding tests to `ppc64-encoding-ISA31.[txt|s]`.




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:13792
+  if ((LD->getValueType(0) != MVT::i128) ||
+  (LD->getExtensionType() != ISD::ZEXTLOAD) || (!ValidLDType))
+return SDValue();

nit: check ValidLDType first:
```
if (! ValidLDType || (LD->getValueType(0) != MVT::i128) ||
(LD->getExtensionType() != ISD::ZEXTLOAD) ||)
```



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.h:528
+/// Allows utilization of the Load VSX Vector Rightmost Instructions.
+LXVRZX
   };

nit: This shouldn't matter to code gen, but it would be nice to have this 
defined closer to other similar instructions. Maybe after `LXVD2X`?



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:225
+def PPClxvrzx : SDNode<"PPCISD::LXVRZX", SDT_PPCLXVRZX,
+[SDNPHasChain, SDNPMayLoad]>;
+

nit: indentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502



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


[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-06-30 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 274634.
aelitashen added a comment.

Make LLDB take care of the directory delimiter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Option/Arg.h"
@@ -433,6 +434,30 @@
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int num_modules = lldb::SBTarget::GetNumModulesFromEvent(event);
+  for (int i = 0; i < num_modules; i++) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+auto module_event = CreateEventObject("module");
+llvm::json::Value module_value = CreateModule(module);
+llvm::json::Object body;
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
+  body.try_emplace("reason", "new");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  body.try_emplace("reason", "removed");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  body.try_emplace("reason", "changed");
+}
+body.try_emplace("module", module_value);
+module_event.try_emplace("body", std::move(body));
+g_vsc.SendJSON(llvm::json::Value(std::move(module_event)));
+  }
+}
   } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -354,6 +354,11 @@
 lldb::SBTarget::eBroadcastBitBreakpointChanged);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded |
+  lldb::SBTarget::eBroadcastBitModulesUnloaded |
+  lldb::SBTarget::eBroadcastBitSymbolsLoaded);
   }
 }
 
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "VSCodeForward.h"
+#include "lldb/API/SBModule.h"
 
 namespace lldb_vscode {
 
@@ -237,6 +238,16 @@
  llvm::Optional request_path = llvm::None,
  llvm::Optional request_line = llvm::None);
 
+/// Converts a LLDB module to a VS Code DAP module for use in "modules" events.
+///
+/// \param[in] module
+/// A LLDB module object to convert into a JSON value
+///
+/// \return
+/// A "Module" JSON object with that follows the formal JSON
+/// definition outlined by Microsoft.
+llvm::json::Value CreateModule(lldb::SBModule );
+
 /// Create a "Event" JSON object using \a event_name as the event name
 ///
 /// \param[in] event_name
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,29 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateModule(lldb::SBModule ) {
+  llvm::json::Object object;
+  if (!module.IsValid())
+return llvm::json::Value(std::move(object));
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace("name", std::string(module.GetFileSpec().GetFilename()));
+  char module_path_arr[PATH_MAX];
+  module.GetFileSpec().GetPath(module_path_arr, sizeof(module_path_arr));
+  std::string module_path(module_path_arr);
+  

[clang] b6c4903 - A constexpr virtual function is implicitly inline so should never be a

2020-06-30 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-30T16:07:50-07:00
New Revision: b6c490349d1524aefeb1c4a686411f860e6a3555

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

LOG: A constexpr virtual function is implicitly inline so should never be a
key function.

Added: 
clang/test/CodeGenCXX/vtable-constexpr.cpp

Modified: 
clang/lib/AST/RecordLayoutBuilder.cpp

Removed: 




diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 028e82a5df4d..3d5f785e943e 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2107,7 +2107,7 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext 
,
 if (MD->isImplicit())
   continue;
 
-if (MD->isInlineSpecified())
+if (MD->isInlineSpecified() || MD->isConstexpr())
   continue;
 
 if (MD->hasInlineBody())

diff  --git a/clang/test/CodeGenCXX/vtable-constexpr.cpp 
b/clang/test/CodeGenCXX/vtable-constexpr.cpp
new file mode 100644
index ..e398a9e5835d
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-constexpr.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o - -triple %itanium_abi_triple | 
FileCheck %s --implicit-check-not=DoNotEmit
+
+// constexpr virtual functions can be called at runtime and go in the vtable as
+// normal. But they are implicitly inline so are never the key function.
+
+struct DoNotEmit {
+  virtual constexpr void f();
+};
+constexpr void DoNotEmit::f() {}
+
+// CHECK-DAG: @_ZTV1B = {{.*}} constant { [3 x i8*] } { {{.*}} null, {{.*}} 
@_ZTI1B {{.*}} @_ZN1B1fEv
+struct B {
+  // CHECK-DAG: define {{.*}} @_ZN1B1fEv
+  virtual constexpr void f() {}
+};
+B b;
+
+struct CBase {
+  virtual constexpr void f(); // not key function
+};
+
+// CHECK-DAG: @_ZTV1C = {{.*}} constant {{.*}} null, {{.*}} @_ZTI1C {{.*}} 
@_ZN1C1fEv
+struct C : CBase {
+  void f(); // key function
+};
+// CHECK-DAG: define {{.*}} @_ZN1C1fEv
+void C::f() {}



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


[clang-tools-extra] ffa63dd - [clangd] Run formatting operations asynchronously.

2020-06-30 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-07-01T00:52:08+02:00
New Revision: ffa63dde8e97a34b8914a151556551f74d4227e7

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

LOG: [clangd] Run formatting operations asynchronously.

Summary:
They don't need ASTs or anything, so they should still run immediately.

These were sync for historical reasons (they predate clangd having a pervasive
threading model). This worked ok as they were "cheap".
Aside for consistency, there are a couple of reasons to make them async:
 - they do IO (finding .clang-format) so aren't trivially cheap
 - having TUScheduler involved in running these tasks means we can use it as
   an injection point for configuration.
   (TUScheduler::run will need to learn about which file is being operated on,
   but that's an easy change).
 - adding the config system adds more potential IO, too

Reviewers: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 93f2746bb6f0..1d794b1898c7 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -879,7 +879,8 @@ void ClangdLSPServer::onDocumentOnTypeFormatting(
 "onDocumentOnTypeFormatting called for non-added file",
 ErrorCode::InvalidParams));
 
-  Reply(Server->formatOnType(Code->Contents, File, Params.position, 
Params.ch));
+  Server->formatOnType(File, Code->Contents, Params.position, Params.ch,
+   std::move(Reply));
 }
 
 void ClangdLSPServer::onDocumentRangeFormatting(
@@ -892,12 +893,15 @@ void ClangdLSPServer::onDocumentRangeFormatting(
 "onDocumentRangeFormatting called for non-added file",
 ErrorCode::InvalidParams));
 
-  auto ReplacementsOrError =
-  Server->formatRange(Code->Contents, File, Params.range);
-  if (ReplacementsOrError)
-Reply(replacementsToEdits(Code->Contents, ReplacementsOrError.get()));
-  else
-Reply(ReplacementsOrError.takeError());
+  Server->formatRange(
+  File, Code->Contents, Params.range,
+  [Code = Code->Contents, Reply = std::move(Reply)](
+  llvm::Expected Result) mutable {
+if (Result)
+  Reply(replacementsToEdits(Code, Result.get()));
+else
+  Reply(Result.takeError());
+  });
 }
 
 void ClangdLSPServer::onDocumentFormatting(
@@ -910,11 +914,14 @@ void ClangdLSPServer::onDocumentFormatting(
 "onDocumentFormatting called for non-added file",
 ErrorCode::InvalidParams));
 
-  auto ReplacementsOrError = Server->formatFile(Code->Contents, File);
-  if (ReplacementsOrError)
-Reply(replacementsToEdits(Code->Contents, ReplacementsOrError.get()));
-  else
-Reply(ReplacementsOrError.takeError());
+  Server->formatFile(File, Code->Contents,
+ [Code = Code->Contents, Reply = std::move(Reply)](
+ llvm::Expected Result) mutable 
{
+   if (Result)
+ Reply(replacementsToEdits(Code, Result.get()));
+   else
+ Reply(Result.takeError());
+ });
 }
 
 /// The functions constructs a flattened view of the DocumentSymbol hierarchy.

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 6c7255c96963..b33d53699405 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -296,40 +296,46 @@ void ClangdServer::signatureHelp(PathRef File, Position 
Pos,
 std::move(Action));
 }
 
-llvm::Expected
-ClangdServer::formatRange(llvm::StringRef Code, PathRef File, Range Rng) {
+void ClangdServer::formatRange(PathRef File, llvm::StringRef Code, Range Rng,
+   Callback CB) {
   llvm::Expected Begin = positionToOffset(Code, Rng.start);
   if (!Begin)
-return Begin.takeError();
+return CB(Begin.takeError());
   llvm::Expected End = positionToOffset(Code, Rng.end);
   if (!End)
-return End.takeError();
-  return formatCode(Code, File, {tooling::Range(*Begin, *End - *Begin)});
+return CB(End.takeError());
+  formatCode(File, Code, {tooling::Range(*Begin, *End - *Begin)},
+ std::move(CB));
 }
 
-llvm::Expected

[PATCH] D82642: [clangd] Run formatting operations asynchronously.

2020-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 4 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:900
+  llvm::Expected Result) mutable {
+if (Result)
+  Reply(replacementsToEdits(Code, Result.get()));

kbobyrev wrote:
> `Reply(Result ? replacementsToEdits(...) : Result.takeError())` may be 
> shorter, but up to you, maybe this looks more readable.
Sadly it doesn't compile... the usual thing about not being able to determine a 
common type for the two expressions, and C++ doesn't infer it from the type 
that's required in the context.



Comment at: clang-tools-extra/clangd/ClangdServer.h:326
 private:
-  /// FIXME: This stats several files to find a .clang-format file. I/O can be
-  /// slow. Think of a way to cache this.

kbobyrev wrote:
> Is this no longer true?
It's still true that we do IO and it might be nice to cache it.
However this same IO (to get the formatstyle) also now happens in lots of other 
places too (without comments), and the only reason this one was especially bad 
is that it happened on the main thread (which is no longer true).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82642



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-30 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2155
+
+Emit debug info for types that are unused but defined by the program.
+

I think this description goes counter to how other options are described, which 
basically is about the positive form of the option.   If that's the case, this 
wants to be something more like "Suppress (or emit) debug info ..."



Comment at: clang/include/clang/Driver/Options.td:927
+defm eliminate_unused_debug_types : OptOutFFlag<"eliminate-unused-debug-types",
+  "Emit ", "Do not emit ", " debug info for defined but unused types">;
 def femit_all_decls : Flag<["-"], "femit-all-decls">, Group, 
Flags<[CC1Option]>,

The positive form of the option suppresses info, so "Emit " and "Do not emit " 
are reversed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-30 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

@ABataev , I'm considering emitting an extra dimension for a non-contiguous 
descriptor to support stride in this patch (stride = 1 in array section is just 
a special case for computing stride, however, the formula computing stride do 
not change). Do you think I should do it in this patch?

Computing of stride after support stride in array section:

  int arr[5][5][5];
  #pragma omp target update to(arr[0:2:2][1:2:1][0:2:2]
  
  D0: { offset = 0, count = 1, stride = 4 } 
  // offset, count, dimension size always be 0, 1, 1 for this extra 
dimension, stride is the unit size
  D1: { offset = 0, count = 2, stride = 4 * 1 * 2 = 8 }
// stride = unit size * (production of dimension size of D0) * D1.stride = 4 * 
1 * 2 = 8
  D2: { offset = 0, count = 1, stride = 4 * (1 * 5) * 1 = 20  } // 
stride = unit size * (production of dimension size of D0, D1) * D2.stride = 4 * 
5 * 1 = 20
  D3: { offset = 0, count = 2, stride = 4 * (1 * 5 * 5) * 2 = 200 }  // 
stride = unit size * (production of dimension size of D0, D1, D2) * D3.stride = 
4 * 25 * 2 = 200

For the case in this patch (stride = 1), we can use the same formula for 
computing stride with extra dimension:

  int arr[5][5][5];
  #pragma omp target update to(arr[0:2][1:2][0:2]
  
  D0: { offset = 0, count = 1, stride = 4 } 
 // offset, count, dimension size always be 0, 1, 1 for this extra 
dimension, stride is the unit size
  D1: { offset = 0, count = 2, stride = 4 * 1 * 1 = 4 }
// stride = unit size * (production of dimension size of D0) * D1.stride = 4 * 
1 * 1 = 4
  D2: { offset = 0, count = 1, stride = 4 * (1 * 5) * 1 = 20  }// 
stride = unit size * (production of dimension size of D0, D1) * D2.stride = 4 * 
5 * 1 = 20
  D3: { offset = 0, count = 2, stride = 4 * (1 * 5 * 5) * 1 = 100 } // 
stride = unit size * (production of dimension size of D0, D1, D2) * D3.stride = 
4 * 25 * 1 = 100

The extra dimension does not affect the runtime implementation at all since 
runtime will try to merge inner dimensions if they are contiguous. Take the 
above case for example (arr[0:2][1:2][0:2]):
The product of count and stride for D0 is 4 which is the same as the stride of 
D1 , therefore, runtime just ignores D0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-06-30 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen marked 3 inline comments as done.
aelitashen added inline comments.



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:337-340
+std::string(module.GetFileSpec().GetFilename()));
+  std::string module_path = std::string(module.GetFileSpec().GetDirectory()) +
+"/" +
+std::string(module.GetFileSpec().GetFilename());

clayborg wrote:
> Let LLDB take care of the directory delimiter. Otherwise this will be bad on 
> windows:
> ```
> char module_path[PATH_MAX];
> module.GetFileSpec().GetPath(module_path, sizeof(module_path));
> ```
> 
This piece of code will make path unreadable in the log, and cause the modules 
view cannot be displayed properly.



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:344-346
+std::string symbol_path =
+std::string(module.GetSymbolFileSpec().GetDirectory()) + "/" +
+std::string(module.GetSymbolFileSpec().GetFilename());

clayborg wrote:
> Let LLDB take care of the directory delimiter. Otherwise this will be bad on 
> windows:
> 
> ```
> char symbol_path[PATH_MAX];
> module.GetSymbolFileSpec().GetPath(module_path, sizeof(symbol_path));
> ```
> 
Same reason as above.



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:349-350
+  }
+  std::string loaded_addr = std::to_string(
+  module.GetObjectFileHeaderAddress().GetLoadAddress(g_vsc.target));
+  object.try_emplace("addressRange", loaded_addr);

clayborg wrote:
> We need to make sure the address returned is valid and we want the string 
> value to be in hex. Are we sure std::to_string() will create a hex number? If 
> not we can use sprintf:
> 
> ```
> uint64_t load_addr = 
> module.GetObjectFileHeaderAddress().GetLoadAddress(g_vsc.target);
> if (load_addr != LLDB_INVALID_ADDRESS) {
>   char load_addr_str[64];
>   snprintf(load_addr_str, sizeof(load_addr_str), "0x%016" PRIx64, load_addr);
>   object.try_emplace("addressRange", load_addr_str);
> }
> ```
Decimal to Hex conversion is done in the IDE, not sure if we need to move it 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477



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


[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:65
+if (F.HasUnrecognizedCondition)
+  Conditions.push_back([&](const Params &) { return false; });
+

hokein wrote:
> sammccall wrote:
> > hokein wrote:
> > > I think if this case happened, we might just bail out directly -- adding 
> > > the regex conditions seems unnecessary, we never execute them on Line 127 
> > > (but we might still need computing the regex for diagnostics).
> > > 
> > > and I'm not sure the motivation of using `vector` for `Conditions` and 
> > > `Apply`, it looks like Apply is just 1 element (if we do the bailout for 
> > > conditions, `Conditions` will be at most 1 element).
> > > 
> > > I feel like using a single unique_function for `Conditions` and `Apply` 
> > > might be a better fit with `Fragment`. There is a comment in 
> > > `ConfigFragment.h`:
> > > 
> > > >  Each separate condition must match (combined with AND).
> > > >  When one condition has multiple values, any may match (combined with 
> > > > OR).
> > >  
> > > so my reading is that:
> > > 
> > > - `Fragment` and `CompiledFragment` is a 1:1 mapping
> > > - A `Fragment::Condition` represents a single condition, so the AND match 
> > > applies for different `Fragment`s, which is in ConfigProvider?
> > > - A single condition can have multiple values (`PathMatch`), we use OR 
> > > match
> > > 
> > > Is that correct?
> > > I think if this case happened, we might just bail out directly -- adding 
> > > the regex conditions seems unnecessary, we never execute them on Line 127 
> > > (but we might still need computing the regex for diagnostics).
> > >
> > > and I'm not sure the motivation of using vector for Conditions and Apply, 
> > > it looks like Apply is just 1 element (if we do the bailout for 
> > > conditions, Conditions will be at most 1 element).
> > 
> > So the explanation for both of these things is that this file is going to 
> > grow a lot, and in particular these sections handling PathMatch etc are 
> > going to occur again and again, so we need a scalable pattern. I've 
> > deliberately limited the scope of the first patchset to only support one 
> > condition, one setting to apply etc, but you have to imagine there are 
> > likely to be 5 conditions and maybe 25 settings.
> > 
> > So with that in mind:
> >  - yes, actually saving the conditions isn't necessary, but we do need to 
> > evaluate them for side-effects (diagnostics) and it's simpler not to keep 
> > track of them. Optimizing performance of broken configs is not a big win :-)
> >  - it's marginally simpler to have only one Apply function, but much 
> > simpler if separate parts of compile() can push settings independently. 
> > Same goes for condition in fact...
> > 
> > > Fragment and CompiledFragment is a 1:1 mapping
> > 
> > Yes. I think this is somewhere where the naming is helpful at least :-)
> > 
> > > A Fragment::Condition represents a single condition, so the AND match 
> > > applies for different Fragments, which is in ConfigProvider?
> > 
> > The AND match applies to the multiple Conditions in a single 
> > CompiledFragment. Each fragment only considers its own conditions. 
> > So given:
> > ```
> > If:
> >   Platform: win
> >   PathMatch: [foo1/.*, foo2/.*]
> > CompileFlags:
> >   Add: -foo
> > ---
> > CompileFlags:
> >   Add: -bar
> > ```
> > 
> > We end up with... one Provider, suppling two CompiledFragments (each 
> > compiled from a separate Fragment).
> > 
> > The first CompiledFragment has two Conditions, conceptually:
> >  - `Params.Platform == "win"`
> >  - `Regex("foo1/.*").matches(Params.File) || 
> > Regex("foo2/.*").matches(Params.File)`
> > 
> > The second CompiledFragment has no Conditions. Each fragment has one Apply 
> > function.
> > 
> > The CompiledFragments are applied independently. They each consider their 
> > own Conditions, ANDing them together.
> > 
> > So CompiledFragment #1 checks both conditions. If any fails, it bails out. 
> > Otherwise it runs its Apply function, adding `-foo`.
> > 
> > Then CompiledFragment #2 runs. It has no conditions, so never bails out. It 
> > adds `-bar`.
> oh, thanks for the explanation, this helps me a lot to understand the code.
> 
> so the member `Condition` in `Fragment` will be enhanced to something like 
> `std::vector Conditions` in the future? If so, can we defer that for 
> `CompiledFragment` as well? 
> 
> 
> Since `Fragment` and `CompiledFragment` is 1:1 mapping, I think it is 
> important to keep their implementation aligned, it'd help a lot for readers 
> to understand the code. The condition logic (AND, OR) is subtle and 
> complicated,  I was reading this part of code back and forth, still inferred 
> it in an incorrect way.
> so the member Condition in Fragment will be enhanced to something like 
> std::vector Conditions in the future?

Ah, not quite...
Fragment is supposed to closely follow the YAML format, which is:
`If: { 

[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 274623.
sammccall marked 13 inline comments as done.
sammccall added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82612

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigTesting.h
  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
@@ -8,14 +8,13 @@
 
 #include "Annotations.h"
 #include "ConfigFragment.h"
-#include "Matchers.h"
+#include "ConfigTesting.h"
 #include "Protocol.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include "gtest/internal/gtest-internal.h"
 
 namespace clang {
 namespace clangd {
@@ -36,55 +35,6 @@
   return false;
 }
 
-Position toPosition(llvm::SMLoc L, const llvm::SourceMgr ) {
-  auto LineCol = SM.getLineAndColumn(L);
-  Position P;
-  P.line = LineCol.first - 1;
-  P.character = LineCol.second - 1;
-  return P;
-}
-
-Range toRange(llvm::SMRange R, const llvm::SourceMgr ) {
-  return Range{toPosition(R.Start, SM), toPosition(R.End, SM)};
-}
-
-struct CapturedDiags {
-  std::function callback() {
-return [this](const llvm::SMDiagnostic ) {
-  Diagnostics.emplace_back();
-  Diag  = Diagnostics.back();
-  Out.Message = D.getMessage().str();
-  Out.Kind = D.getKind();
-  Out.Pos.line = D.getLineNo() - 1;
-  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
-  if (!D.getRanges().empty()) {
-const auto  = D.getRanges().front();
-Out.Rng.emplace();
-Out.Rng->start.line = Out.Rng->end.line = Out.Pos.line;
-Out.Rng->start.character = R.first;
-Out.Rng->end.character = R.second;
-  }
-};
-  }
-  struct Diag {
-std::string Message;
-llvm::SourceMgr::DiagKind Kind;
-Position Pos;
-llvm::Optional Rng;
-
-friend void PrintTo(const Diag , std::ostream *OS) {
-  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
-  << D.Message << "@" << llvm::to_string(D.Pos);
-}
-  };
-  std::vector Diagnostics;
-};
-
-MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
-MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
-MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
-MATCHER_P(DiagRange, R, "") { return arg.Rng == R; }
-
 TEST(ParseYAML, SyntacticForms) {
   CapturedDiags Diags;
   const char *YAML = R"yaml(
@@ -101,8 +51,8 @@
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_EQ(Results.size(), 2u);
-  EXPECT_FALSE(Results.front().Condition.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.front().Condition.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
+  EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
   EXPECT_THAT(Results.front().CompileFlags.Add,
   ElementsAre(Val("foo"), Val("bar")));
 
@@ -120,7 +70,7 @@
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_EQ(Results.size(), 1u);
   ASSERT_NE(Results.front().Source.Manager, nullptr);
-  EXPECT_EQ(toRange(Results.front().Condition.PathMatch.front().Range,
+  EXPECT_EQ(toRange(Results.front().If.PathMatch.front().Range,
 *Results.front().Source.Manager),
 YAML.range());
 }
@@ -140,7 +90,7 @@
 
   ASSERT_THAT(
   Diags.Diagnostics,
-  ElementsAre(AllOf(DiagMessage("Unknown Condition key UnknownCondition"),
+  ElementsAre(AllOf(DiagMessage("Unknown If key UnknownCondition"),
 DiagKind(llvm::SourceMgr::DK_Warning),
 DiagPos(YAML.range().start), DiagRange(YAML.range())),
   AllOf(DiagMessage("Unexpected token. Expected Key, Flow "
@@ -150,7 +100,7 @@
 
   ASSERT_EQ(Results.size(), 2u);
   EXPECT_THAT(Results.front().CompileFlags.Add, ElementsAre(Val("first")));
-  EXPECT_TRUE(Results.front().Condition.HasUnrecognizedCondition);
+  EXPECT_TRUE(Results.front().If.HasUnrecognizedCondition);
   EXPECT_THAT(Results.back().CompileFlags.Add, IsEmpty());
 }
 
Index: clang-tools-extra/clangd/unittests/ConfigTesting.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigTesting.h
@@ -0,0 +1,77 @@
+//===-- 

[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-06-30 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 274622.
ellis added a comment.

Add double backtick to doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s bugprone-no-escape %t
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_time_s *dispatch_time_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
+
+extern dispatch_queue_t queue;
+
+void test_noescape_attribute(__attribute__((noescape)) int *p, int *q) {
+  dispatch_async(queue, ^{
+*p = 123;
+// CHECK-MESSAGES: :[[@LINE-2]]:25: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+// CHECK-MESSAGES: :[[@LINE-4]]:30: note: the 'noescape' attribute is declared here.
+  });
+
+  dispatch_after(456, queue, ^{
+*p = 789;
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+  });
+
+  dispatch_async(queue, ^{
+*q = 0;
+// CHECK-MESSAGES-NOT: :[[@LINE-2]]:25: warning: pointer 'q' with attribute 'noescape' is captured by an asynchronously-executed block
+  });
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
`bugprone-multiple-statement-macro `_,
+   `bugprone-no-escape `_, "Yes"
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - bugprone-no-escape
+
+bugprone-no-escape
+==
+
+Finds pointers with the ``noescape`` attribute that are captured by an
+asynchronously-executed block. The block arguments in ``dispatch_async()`` and
+``dispatch_after()`` are guaranteed to escape, so it is an error if a pointer with the
+``noescape`` attribute is captured by one of these blocks.
+
+The following is an example of an invalid use of the ``noescape`` attribute.
+
+  .. code-block:: objc
+void foo(__attribute__((noescape)) int *p) {
+  dispatch_async(queue, ^{
+*p = 123;
+  });
+});
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@
   result of a memory allocation function (``malloc()``, ``calloc()``,
   ``realloc()``, ``alloca()``) instead of its argument.
 
+- New :doc:`bugprone-no-escape
+  ` check.
+
+  Finds pointers with the ``noescape`` attribute that are captured by an
+  asynchronously-executed block.
+
 - New :doc:`bugprone-spuriously-wake-up-functions
   ` check.
 
@@ -201,14 +207,14 @@
   Now checks ``std::basic_string_view`` by default.
 
 - Improved :doc:`readability-else-after-return
-  ` check now supports a 
+  ` check now supports a
   `WarnOnConditionVariables` option to control whether to refactor condition
   variables where possible.
 
 - Improved :doc:`readability-identifier-naming
   ` check.
 
-  Now able to rename member references in class template definitions with 
+  Now able to rename member references in class template definitions with
   explicit access.
 
 - Improved :doc:`readability-qualified-auto
Index: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
@@ -0,0 +1,36 @@
+//===--- NoEscapeCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under 

[clang] 89a0c40 - [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-30 Thread Cyndy Ishida via cfe-commits

Author: Zixu Wang
Date: 2020-06-30T13:57:47-07:00
New Revision: 89a0c4066b0e70edd257e30d7189f303e26251a0

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

LOG: [clang][diagnostics] Add '-Wundef-prefix' warning option

Summary:
Add an `-Wundef-prefix=,...` option, which is similar to `-Wundef`, 
but only give warnings for undefined macros with the given prefixes.

Reviewers: ributzka, steven_wu, cishida, bruno, arphaman, rsmith

Reviewed By: ributzka, arphaman

Subscribers: riccibruno, dexonsmith, cfe-commits

Tags: #clang

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

This patch was authored by Zixu Wang 

Added: 
clang/test/Preprocessor/warn-macro-undef.c

Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/DiagnosticOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/PPExpressions.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index fa07e9ae76c8..9cb06cf5b5e1 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -312,6 +312,9 @@ def pp_macro_not_used : Warning<"macro is not used">, 
DefaultIgnore,
 def warn_pp_undef_identifier : Warning<
   "%0 is not defined, evaluates to 0">,
   InGroup>, DefaultIgnore;
+def warn_pp_undef_prefix : Warning<
+  "%0 is not defined, evaluates to 0">,
+  InGroup>, DefaultIgnore;
 def warn_pp_ambiguous_macro : Warning<
   "ambiguous expansion of macro %0">, InGroup;
 def note_pp_ambiguous_macro_chosen : Note<

diff  --git a/clang/include/clang/Basic/DiagnosticOptions.h 
b/clang/include/clang/Basic/DiagnosticOptions.h
index 3e3c4e50a9e0..7fbe534c5994 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.h
+++ b/clang/include/clang/Basic/DiagnosticOptions.h
@@ -98,6 +98,10 @@ class DiagnosticOptions : public 
RefCountedBase{
   /// prefixes removed.
   std::vector Warnings;
 
+  /// The list of prefixes from -Wundef-prefix=... used to generate warnings
+  /// for undefined macros.
+  std::vector UndefPrefixes;
+
   /// The list of -R... options used to alter the diagnostic mappings, with the
   /// prefixes removed.
   std::vector Remarks;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index eca822c6afa3..d030468514c3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -483,6 +483,9 @@ def Wnonportable_cfstrings : Joined<["-"], 
"Wnonportable-cfstrings">, Group,
   HelpText<"Pass the comma separated arguments in  to the preprocessor">,
   MetaVarName<"">, Group;
+def Wundef_prefix_EQ : CommaJoined<["-"], "Wundef-prefix=">, 
Group,
+  Flags<[CC1Option, CoreOption, HelpHidden]>, MetaVarName<"">,
+  HelpText<"Enable warnings for undefined macros with a prefix in the comma 
separated list ">;
 def Wwrite_strings : Flag<["-"], "Wwrite-strings">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def Wno_write_strings : Flag<["-"], "Wno-write-strings">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def W_Joined : Joined<["-"], "W">, Group, Flags<[CC1Option, 
CoreOption]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8bd248c95030..e12931a5a1b4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1688,6 +1688,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions , 
ArgList ,
   }
   Opts.MessageLength =
   getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
+
+  Opts.UndefPrefixes = Args.getAllArgValues(OPT_Wundef_prefix_EQ);
+
   addDiagnosticArgs(Args, OPT_W_Group, OPT_W_value_Group, Opts.Warnings);
   addDiagnosticArgs(Args, OPT_R_Group, OPT_R_value_Group, Opts.Remarks);
 

diff  --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index e5ec2b99f507..7a158a31490d 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -15,7 +15,6 @@
 //
 
//===--===//
 
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -26,9 +25,12 @@
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -251,8 +253,24 @@ 

[PATCH] D82392: [CodeGen] Add public function to emit C++ destructor call.

2020-06-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@rjmccall I updated this patch to introduce the function 
`getCXXDestructorImplicitParam` instead. This should be closer to D79942 
. It seems like there is never more than one 
implicit parameter so, I just have it return a single `llvm::Value*`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82392



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


[PATCH] D78655: [CUDA][HIP] Let lambda be host device by default

2020-06-30 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Sema/SemaCUDA.cpp:750
 
+bool Sema::CUDACheckLambdaCapture(CXXMethodDecl *Callee,
+  const sema::Capture ) {

What does the return value mean? We don't seem to check it anyways.  If we 
don't care about the result, perhaps the function should be void.
If we do, then it would be good to document its purpose and returned values 
and, probably, rename it to better indicate what is it it's supposed to check.



Comment at: clang/lib/Sema/SemaLambda.cpp:1783
+
+  if (LangOpts.CUDA && LangOpts.CUDAIsDevice)
+CUDACheckLambdaCapture(CallOperator, From);

I would expect Sema-level diags to be produced during both host and device 
compilation. Some of the diags for HD may need to be postponed until after 
things have been CodeGen'ed, but the checks should happen nevertheless.




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

https://reviews.llvm.org/D78655



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-06-30 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
+
+  Finds pointers with the `noescape` attribute that are captured by an
+  asynchronously-executed block.

Please use double back-ticks for language constructs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-06-30 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 274618.
ellis added a comment.

Applied changes suggested in comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s bugprone-no-escape %t
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_time_s *dispatch_time_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
+
+extern dispatch_queue_t queue;
+
+void test_noescape_attribute(__attribute__((noescape)) int *p, int *q) {
+  dispatch_async(queue, ^{
+*p = 123;
+// CHECK-MESSAGES: :[[@LINE-2]]:25: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+// CHECK-MESSAGES: :[[@LINE-4]]:30: note: the 'noescape' attribute is declared here.
+  });
+
+  dispatch_after(456, queue, ^{
+*p = 789;
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+  });
+
+  dispatch_async(queue, ^{
+*q = 0;
+// CHECK-MESSAGES-NOT: :[[@LINE-2]]:25: warning: pointer 'q' with attribute 'noescape' is captured by an asynchronously-executed block
+  });
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
`bugprone-multiple-statement-macro `_,
+   `bugprone-no-escape `_, "Yes"
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - bugprone-no-escape
+
+bugprone-no-escape
+==
+
+Finds pointers with the ``noescape`` attribute that are captured by an
+asynchronously-executed block. The block arguments in ``dispatch_async()`` and
+``dispatch_after()`` are guaranteed to escape, so it is an error if a pointer with the
+``noescape`` attribute is captured by one of these blocks.
+
+The following is an example of an invalid use of the ``noescape`` attribute.
+
+  .. code-block:: objc
+void foo(__attribute__((noescape)) int *p) {
+  dispatch_async(queue, ^{
+*p = 123;
+  });
+});
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@
   result of a memory allocation function (``malloc()``, ``calloc()``,
   ``realloc()``, ``alloca()``) instead of its argument.
 
+- New :doc:`bugprone-no-escape
+  ` check.
+
+  Finds pointers with the `noescape` attribute that are captured by an
+  asynchronously-executed block.
+
 - New :doc:`bugprone-spuriously-wake-up-functions
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
@@ -0,0 +1,36 @@
+//===--- NoEscapeCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Block arguments in `dispatch_async()` and `dispatch_after()` are 

[PATCH] D82392: [CodeGen] Add public function to emit C++ destructor call.

2020-06-30 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 274616.
zoecarver added a comment.

- Remove `emitCXXDestructorCall` and add `getCXXDestructorImplicitParam`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82392

Files:
  clang/include/clang/CodeGen/CodeGenABITypes.h
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CodeGenABITypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -259,6 +259,12 @@
bool ForVirtualBase,
bool Delegating) override;
 
+  llvm::Value *getCXXDestructorImplicitParam(CodeGenFunction ,
+ const CXXDestructorDecl *DD,
+ CXXDtorType Type,
+ bool ForVirtualBase,
+ bool Delegating) override;
+
   void EmitDestructorCall(CodeGenFunction , const CXXDestructorDecl *DD,
   CXXDtorType Type, bool ForVirtualBase,
   bool Delegating, Address This,
@@ -1577,6 +1583,12 @@
   return AddedStructorArgs::suffix({{MostDerivedArg, getContext().IntTy}});
 }
 
+llvm::Value *MicrosoftCXXABI::getCXXDestructorImplicitParam(
+CodeGenFunction , const CXXDestructorDecl *DD, CXXDtorType Type,
+bool ForVirtualBase, bool Delegating) {
+  return nullptr;
+}
+
 void MicrosoftCXXABI::EmitDestructorCall(CodeGenFunction ,
  const CXXDestructorDecl *DD,
  CXXDtorType Type, bool ForVirtualBase,
@@ -1603,8 +1615,11 @@
 BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
   }
 
+  llvm::Value *Implicit =
+  getCXXDestructorImplicitParam(CGF, DD, Type, ForVirtualBase,
+Delegating); // = nullptr
   CGF.EmitCXXDestructorCall(GD, Callee, This.getPointer(), ThisTy,
-/*ImplicitParam=*/nullptr,
+/*ImplicitParam=*/Implicit,
 /*ImplicitParamTy=*/QualType(), nullptr);
   if (BaseDtorEndBB) {
 // Complete object handler should continue to be the remaining
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -228,6 +228,12 @@
bool ForVirtualBase,
bool Delegating) override;
 
+  llvm::Value *getCXXDestructorImplicitParam(CodeGenFunction ,
+ const CXXDestructorDecl *DD,
+ CXXDtorType Type,
+ bool ForVirtualBase,
+ bool Delegating) override;
+
   void EmitDestructorCall(CodeGenFunction , const CXXDestructorDecl *DD,
   CXXDtorType Type, bool ForVirtualBase,
   bool Delegating, Address This,
@@ -1646,13 +1652,21 @@
   return AddedStructorArgs::prefix({{VTT, VTTTy}});
 }
 
+llvm::Value *ItaniumCXXABI::getCXXDestructorImplicitParam(
+CodeGenFunction , const CXXDestructorDecl *DD, CXXDtorType Type,
+bool ForVirtualBase, bool Delegating) {
+  GlobalDecl GD(DD, Type);
+  return CGF.GetVTTParameter(GD, ForVirtualBase, Delegating);
+}
+
 void ItaniumCXXABI::EmitDestructorCall(CodeGenFunction ,
const CXXDestructorDecl *DD,
CXXDtorType Type, bool ForVirtualBase,
bool Delegating, Address This,
QualType ThisTy) {
   GlobalDecl GD(DD, Type);
-  llvm::Value *VTT = CGF.GetVTTParameter(GD, ForVirtualBase, Delegating);
+  llvm::Value *VTT =
+  getCXXDestructorImplicitParam(CGF, DD, Type, ForVirtualBase, Delegating);
   QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
 
   CGCallee Callee;
Index: clang/lib/CodeGen/CodeGenABITypes.cpp
===
--- clang/lib/CodeGen/CodeGenABITypes.cpp
+++ clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -115,3 +115,16 @@
  const FieldDecl *FD) {
   return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
 }
+
+llvm::Value *CodeGen::getCXXDestructorImplicitParam(
+CodeGenModule , llvm::BasicBlock *InsertBlock,
+llvm::BasicBlock::iterator InsertPoint, const CXXDestructorDecl *D,
+CXXDtorType Type, bool 

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Layout/aix-double-struct-member.cpp:2
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \
+// RUN:   FileCheck %s

My build with this patch also hits cases where the preferred alignment is 
increased to 8, but the offset of the associated member is not 8-byte aligned:
```
extern "C" int printf(const char *, ...);
struct A0 {};
struct Y : A0 {
  double mem;
};
struct Z : A0 {
  Y y;
};
extern char alignz[__alignof__(Z)];
extern char alignz[8];
int main(void) {
  Z z;
  printf("%td\n",
 _cast(z.y) - _cast(z));
}
```
```
*** Dumping AST Record Layout
 0 | struct Z
 0 |   struct A0 (base) (empty)
 4 |   struct Y y
 4 | struct A0 (base) (empty)
 4 | double mem
   | [sizeof=16, dsize=12, align=4, preferredalign=8,
   |  nvsize=12, nvalign=4, preferrednvalign=8]
```




Comment at: clang/test/Layout/aix-double-struct-member.cpp:237
+
+namespace tes8 {
+// Test how #pragma pack and align attribute interacts with AIX alignment.

Typo: s/tes8/test8/;



Comment at: clang/test/Layout/aix-double-struct-member.cpp:347
+
+} // namespace tes8

Same comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-06-30 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Thanks Petr, LGTM


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

https://reviews.llvm.org/D79219



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


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-30 Thread Cyndy Ishida via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89a0c4066b0e: [clang][diagnostics] Add 
-Wundef-prefix warning option (authored by zixuw, committed by 
cishida).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify=undef
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify=undef-prefix
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A,BC -verify=both
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify=undef-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef-prefix -Wundef-prefix=A,BC -verify=undef-prefix-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -Wundef-prefix=A,BC -verify=both-error
+
+extern int x;
+
+#if AB // #1
+#endif
+// undef-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// both-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// both-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+
+#if B // #2
+#endif
+// undef-warning@#2 {{'B' is not defined, evaluates to 0}}
+// no warning for undef-prefix
+// both-warning@#2 {{'B' is not defined, evaluates to 0}}
+// undef-error-error@#2 {{'B' is not defined, evaluates to 0}}
+// no error for undef-prefix
+// both-error-error@#2 {{'B' is not defined, evaluates to 0}}
+
+#define BC 0
+#if BC // no warning/error
+#endif
+
+#undef BC
+#if BC // #3
+#endif
+// undef-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// both-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// both-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+
+// Test that #pragma-enabled 'Wundef' can override 'Wundef-prefix'
+#pragma clang diagnostic error "-Wundef"
+
+#if C // #4
+#endif
+// undef-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-prefix-error@#4 {{'C' is not defined, evaluates to 0}}
+// both-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-error-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#4 {{'C' is not defined, evaluates to 0}}
+// both-error-error@#4 {{'C' is not defined, evaluates to 0}}
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -15,7 +15,6 @@
 //
 //===--===//
 
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -26,9 +25,12 @@
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -251,8 +253,24 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
+if (ValueLive) {
   PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+
+  const DiagnosticsEngine  = PP.getDiagnostics();
+  // If 'Wundef' is enabled, do not emit 'undef-prefix' diagnostics.
+  if (DiagEngine.isIgnored(diag::warn_pp_undef_identifier,
+   PeekTok.getLocation())) {
+const std::vector UndefPrefixes =
+DiagEngine.getDiagnosticOptions().UndefPrefixes;
+const StringRef IdentifierName = II->getName();
+if (llvm::any_of(UndefPrefixes,
+ [](const std::string ) {
+   return IdentifierName.startswith(Prefix);
+ }))
+  PP.Diag(PeekTok, diag::warn_pp_undef_prefix)
+  << AddFlagValue{llvm::join(UndefPrefixes, ",")} << II;
+  }

[PATCH] D82882: [ASTImporter] Fix AST import crash for a friend decl

2020-06-30 Thread Vince Bridgers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecae672ac2ac: [ASTImporter] Fix AST import crash for a 
friend decl (authored by vabridgers, committed by einvbri 
vince.a.bridg...@ericsson.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82882

Files:
  clang/lib/AST/ASTImporterLookupTable.cpp


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -45,7 +45,11 @@
   LT.add(RTy->getAsCXXRecordDecl());
 else if (const auto *SpecTy = dyn_cast(Ty))
   LT.add(SpecTy->getAsCXXRecordDecl());
-else if (isa(Ty)) {
+else if (const auto *SubstTy =
+ dyn_cast(Ty)) {
+  if (SubstTy->getAsCXXRecordDecl())
+LT.add(SubstTy->getAsCXXRecordDecl());
+} else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
 } else {


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -45,7 +45,11 @@
   LT.add(RTy->getAsCXXRecordDecl());
 else if (const auto *SpecTy = dyn_cast(Ty))
   LT.add(SpecTy->getAsCXXRecordDecl());
-else if (isa(Ty)) {
+else if (const auto *SubstTy =
+ dyn_cast(Ty)) {
+  if (SubstTy->getAsCXXRecordDecl())
+LT.add(SubstTy->getAsCXXRecordDecl());
+} else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ecae672 - [ASTImporter] Fix AST import crash for a friend decl

2020-06-30 Thread via cfe-commits

Author: Vince Bridgers
Date: 2020-06-30T15:57:01-05:00
New Revision: ecae672ac2ac42bc15bdc794cc56ddccadec9e4f

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

LOG: [ASTImporter] Fix AST import crash for a friend decl

Summary:
Running CTU testing, we found that VisitFriendDecl in
ASTImporterLookup.cpp was not handling a particular non-dependent case,
so we reached the llvm_unreachable case.

The FriendDecl and QualType not handled were:

(gdb) p D->dump()
FriendDecl 0x75cf1958
< <>, 'nlohmann::basic_json, bool, long long, unsigned long long, double,
   std::allocator, adl_serializer, std::vector>>':'nlohmann::basic_json, bool, long long, unsigned long
   long, double, std::allocator, adl_serializer, std::vector>>'

(gdb) p Ty->dump()
SubstTemplateTypeParmType 0x75cf0df0 'class
nlohmann::basic_json, _Bool, long long, unsigned long long, double,
   std::allocator, adl_serializer, class std::vector > >' sugar
|-TemplateTypeParmType 0x7643ea40 'BasicJsonType' dependent depth 0
index 0
| `-TemplateTypeParm 0x7643e9e8 'BasicJsonType'
`-RecordType 0x1012ad20 'class nlohmann::basic_json, _Bool, long long, unsigned
long long, double, std::allocator, adl_serializer, class
std::vector > >'
  `-ClassTemplateSpecialization 0x1012ab68 'basic_json'

Reviewers: martong, a.sidorin

Reviewed By: martong

Subscribers: kristof.beyls, rnkovacs, teemperor, cfe-commits, dkrupp

Tags: #clang

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

Added: 


Modified: 
clang/lib/AST/ASTImporterLookupTable.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporterLookupTable.cpp 
b/clang/lib/AST/ASTImporterLookupTable.cpp
index 7390329d4ed8..4d6fff8f3419 100644
--- a/clang/lib/AST/ASTImporterLookupTable.cpp
+++ b/clang/lib/AST/ASTImporterLookupTable.cpp
@@ -45,7 +45,11 @@ struct Builder : RecursiveASTVisitor {
   LT.add(RTy->getAsCXXRecordDecl());
 else if (const auto *SpecTy = dyn_cast(Ty))
   LT.add(SpecTy->getAsCXXRecordDecl());
-else if (isa(Ty)) {
+else if (const auto *SubstTy =
+ dyn_cast(Ty)) {
+  if (SubstTy->getAsCXXRecordDecl())
+LT.add(SubstTy->getAsCXXRecordDecl());
+} else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
 } else {



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


[PATCH] D82806: [AIX] Static init support for template specialization and inline variable

2020-06-30 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L abandoned this revision.
Xiangling_L added a comment.

Abandon this revision to keep separable C++ initialization  as it is and will 
handle them in the backend later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82806



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


[PATCH] D78655: [CUDA][HIP] Let lambda be host device by default

2020-06-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 274589.
yaxunl retitled this revision from "[CUDA][HIP] Let non-caputuring lambda be 
host device" to "[CUDA][HIP] Let lambda be host device by default".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Added diagnostics for capturing host variables on device lambda and made lambda 
host device by default.


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

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=com %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcuda-is-device -verify=com,dev %s
+
+#include "Inputs/cuda.h"
+
+auto global_lambda = [] () { return 123; };
+
+template
+__global__ void kernel(F f) { f(); }
+// dev-note@-1 6{{called by 'kernel<(lambda}}
+
+__host__ __device__ void hd(int x);
+
+class A {
+  int b;
+public:
+  void test() {
+[=](){ hd(b); }();
+
+[&](){ hd(b); }();
+
+kernel<<<1,1>>>([](){ hd(0); });
+
+kernel<<<1,1>>>([=](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&](){
+  auto f = [&]{ hd(b); };
+  // dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+  f();
+});
+  }
+};
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // com-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  [&](){ hd(b); }();
+
+  [=, ](){ hd(b); }();
+
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>([](){ hd(0); });
+
+  kernel<<<1,1>>>([=](){ hd(b); });
+
+  kernel<<<1,1>>>([b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){ hd(b); });
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([=, ](){ hd(b); });
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([&, b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){
+  auto f = [&]{ hd(b); };
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+  f();
+  });
+
+  return 0;
+}
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+  dim3 blockDim, void **args,
+  size_t sharedMem,
+  hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,7 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+#endif
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN_CAPTURE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_capturevEUlvE_EvT_\00"
+// HOST: @[[KERN_RESOLVE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_resolvevEUlvE_EvT_\00"
+
+// Check 

[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added subscribers: Eugene.Zelenko, njames93.
njames93 added a comment.

Please override `isLanguageVersionSupported` to restrict this check to just 
running on ObjectiveC translation units.




Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:33
+  Result.Nodes.getNodeAs("arg-block");
+  const auto *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl();
+  for (const auto CapturedVar : EscapingBlockDecl->captures()) {

Don't use `auto` here as type isn't spelled out explicitly in the initializer.



Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:34
+  const auto *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl();
+  for (const auto CapturedVar : EscapingBlockDecl->captures()) {
+const VarDecl *Var = CapturedVar.getVariable();

Ditto, also could this be a reference to avoid an unnecessary copy?



Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:38
+  diag(MatchedEscapingBlock->getBeginLoc(),
+   "Pointer '%0' with attribute 'noescape' is captured by an "
+   "asynchronously-executed block")

Convention is warnings start with a lower case letter, same goes for the note 
below.



Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:40
+   "asynchronously-executed block")
+  << Var->getName();
+  diag(Var->getBeginLoc(), "The 'noescape' attribute is declared here.",

You can get rid of `->getName()` and just pass `Var`, The diagnostics builder 
has a special case for `const NamedDecl*`



Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m:25
+*q = 0;
+// CHECK-MESSAGES-NOT: ::[@LINE-2]:{{[0-9]*}}: warning: {{.*}} 
[bugprone-no-escape]
+  });

Be explicit about the column number and warning message. You don't need to 
include the diagnostic name though.
Also the macro should be `[[@LINE-2]]`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:65
+if (F.HasUnrecognizedCondition)
+  Conditions.push_back([&](const Params &) { return false; });
+

sammccall wrote:
> hokein wrote:
> > I think if this case happened, we might just bail out directly -- adding 
> > the regex conditions seems unnecessary, we never execute them on Line 127 
> > (but we might still need computing the regex for diagnostics).
> > 
> > and I'm not sure the motivation of using `vector` for `Conditions` and 
> > `Apply`, it looks like Apply is just 1 element (if we do the bailout for 
> > conditions, `Conditions` will be at most 1 element).
> > 
> > I feel like using a single unique_function for `Conditions` and `Apply` 
> > might be a better fit with `Fragment`. There is a comment in 
> > `ConfigFragment.h`:
> > 
> > >  Each separate condition must match (combined with AND).
> > >  When one condition has multiple values, any may match (combined with OR).
> >  
> > so my reading is that:
> > 
> > - `Fragment` and `CompiledFragment` is a 1:1 mapping
> > - A `Fragment::Condition` represents a single condition, so the AND match 
> > applies for different `Fragment`s, which is in ConfigProvider?
> > - A single condition can have multiple values (`PathMatch`), we use OR match
> > 
> > Is that correct?
> > I think if this case happened, we might just bail out directly -- adding 
> > the regex conditions seems unnecessary, we never execute them on Line 127 
> > (but we might still need computing the regex for diagnostics).
> >
> > and I'm not sure the motivation of using vector for Conditions and Apply, 
> > it looks like Apply is just 1 element (if we do the bailout for conditions, 
> > Conditions will be at most 1 element).
> 
> So the explanation for both of these things is that this file is going to 
> grow a lot, and in particular these sections handling PathMatch etc are going 
> to occur again and again, so we need a scalable pattern. I've deliberately 
> limited the scope of the first patchset to only support one condition, one 
> setting to apply etc, but you have to imagine there are likely to be 5 
> conditions and maybe 25 settings.
> 
> So with that in mind:
>  - yes, actually saving the conditions isn't necessary, but we do need to 
> evaluate them for side-effects (diagnostics) and it's simpler not to keep 
> track of them. Optimizing performance of broken configs is not a big win :-)
>  - it's marginally simpler to have only one Apply function, but much simpler 
> if separate parts of compile() can push settings independently. Same goes for 
> condition in fact...
> 
> > Fragment and CompiledFragment is a 1:1 mapping
> 
> Yes. I think this is somewhere where the naming is helpful at least :-)
> 
> > A Fragment::Condition represents a single condition, so the AND match 
> > applies for different Fragments, which is in ConfigProvider?
> 
> The AND match applies to the multiple Conditions in a single 
> CompiledFragment. Each fragment only considers its own conditions. 
> So given:
> ```
> If:
>   Platform: win
>   PathMatch: [foo1/.*, foo2/.*]
> CompileFlags:
>   Add: -foo
> ---
> CompileFlags:
>   Add: -bar
> ```
> 
> We end up with... one Provider, suppling two CompiledFragments (each compiled 
> from a separate Fragment).
> 
> The first CompiledFragment has two Conditions, conceptually:
>  - `Params.Platform == "win"`
>  - `Regex("foo1/.*").matches(Params.File) || 
> Regex("foo2/.*").matches(Params.File)`
> 
> The second CompiledFragment has no Conditions. Each fragment has one Apply 
> function.
> 
> The CompiledFragments are applied independently. They each consider their own 
> Conditions, ANDing them together.
> 
> So CompiledFragment #1 checks both conditions. If any fails, it bails out. 
> Otherwise it runs its Apply function, adding `-foo`.
> 
> Then CompiledFragment #2 runs. It has no conditions, so never bails out. It 
> adds `-bar`.
oh, thanks for the explanation, this helps me a lot to understand the code.

so the member `Condition` in `Fragment` will be enhanced to something like 
`std::vector Conditions` in the future? If so, can we defer that for 
`CompiledFragment` as well? 


Since `Fragment` and `CompiledFragment` is 1:1 mapping, I think it is important 
to keep their implementation aligned, it'd help a lot for readers to understand 
the code. The condition logic (AND, OR) is subtle and complicated,  I was 
reading this part of code back and forth, still inferred it in an incorrect way.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:40
+
+struct Impl {
+  std::vector> Conditions;

nit: I'd use a more verbose name, `CompiledFragmentImpl`.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:46
+  if (!C(P)) {
+dlog("config::Fragment {0}: condition not met", this);
+return false;

maybe `Impl::applying config ...` to allow 

[PATCH] D82908: [SVE] ACLE: Fix builtins for svdup_lane_bf16 and svcvtnt_bf16_f32_x

2020-06-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added a reviewer: fpetrogalli.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: clang.

bfloat16 variants of svdup_lane were missing, and svcvtnt_bf16_x
was implemented incorrectly (it takes an operand for the inactive
lanes)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82908

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup-bfloat.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1262,6 +1262,11 @@
   if (!InGuard.empty())
 OS << "#endif  //" << InGuard << "\n";
 
+  OS << "#if defined(__ARM_FEATURE_SVE_BF16)\n";
+  OS << "#define svcvtnt_bf16_x  svcvtnt_bf16_m\n";
+  OS << "#define svcvtnt_bf16_f32_x  svcvtnt_bf16_f32_m\n";
+  OS << "#endif /*__ARM_FEATURE_SVE_BF16 */\n\n";
+
   OS << "#if defined(__ARM_FEATURE_SVE2)\n";
   OS << "#define svcvtnt_f16_x  svcvtnt_f16_m\n";
   OS << "#define svcvtnt_f16_f32_x  svcvtnt_f16_f32_m\n";
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup-bfloat.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup-bfloat.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup-bfloat.c
@@ -51,3 +51,13 @@
   // expected-warning@+1 {{implicit declaration of function 'svdup_n_bf16_x'}}
   return SVE_ACLE_FUNC(svdup, _n, _bf16_x, )(pg, op);
 }
+
+svbfloat16_t test_svdup_lane_bf16(svbfloat16_t data, uint16_t index)
+{
+  // CHECK-LABEL: test_svdup_lane_bf16
+  // CHECK: %[[DUP:.*]] = call  
@llvm.aarch64.sve.dup.x.nxv8i16(i16 %index)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.tbl.nxv8bf16( %data,  
%[[DUP]])
+  // CHECK: ret  %[[INTRINSIC]]
+  // expected-warning@+1 {{implicit declaration of function 'svdup_lane_bf16'}}
+  return SVE_ACLE_FUNC(svdup_lane,_bf16,,)(data, index);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
@@ -10,18 +10,18 @@
 #define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
 #endif
 
-svbfloat16_t test_svcvtnt_bf16_f32_x(svbool_t pg, svfloat32_t op) {
+svbfloat16_t test_svcvtnt_bf16_f32_x(svbfloat16_t even, svbool_t pg, 
svfloat32_t op) {
   // CHECK-LABEL: test_svcvtnt_bf16_f32_x
   // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
-  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.fcvtnt.bf16f32( undef,  
%[[PG]],  %op)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.fcvtnt.bf16f32( %even,  
%[[PG]],  %op)
   // CHECK: ret  %[[INTRINSIC]]
-  return SVE_ACLE_FUNC(svcvtnt_bf16, _f32, _x, )(pg, op);
+  return SVE_ACLE_FUNC(svcvtnt_bf16, _f32, _x, )(even, pg, op);
 }
 
-svbfloat16_t test_svcvtnt_bf16_f32_m(svbfloat16_t inactive, svbool_t pg, 
svfloat32_t op) {
+svbfloat16_t test_svcvtnt_bf16_f32_m(svbfloat16_t even, svbool_t pg, 
svfloat32_t op) {
   // CHECK-LABEL: test_svcvtnt_bf16_f32_m
   // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
-  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.fcvtnt.bf16f32( %inactive,  %[[PG]],  %op)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.fcvtnt.bf16f32( %even,  
%[[PG]],  %op)
   // CHECK: ret  %[[INTRINSIC]]
-  return SVE_ACLE_FUNC(svcvtnt_bf16, _f32, _m, )(inactive, pg, op);
+  return SVE_ACLE_FUNC(svcvtnt_bf16, _f32, _m, )(even, pg, op);
 }
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -1110,7 +1110,7 @@
 
 let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
   defm SVCVT_BF16_F32   : SInstCvtMXZ<"svcvt_bf16[_f32]",  "ddPM", "dPM", "b", 
 "aarch64_sve_fcvt_bf16f32">;
-  defm SVCVTNT_BF16_F32 : SInstCvtMX<"svcvtnt_bf16[_f32]", "ddPM", "dPM", "b", 
 "aarch64_sve_fcvtnt_bf16f32">;
+  def SVCVTNT_BF16_F32 : SInst<"svcvtnt_bf16[_f32]", "ddPM", "b",  MergeOp1, 
"aarch64_sve_fcvtnt_bf16f32", [IsOverloadNone]>;
 }
 
 // svcvt_s##_f64
@@ -1204,6 +1204,11 @@
 // instruction such as DUP (indexed) if the lane index fits the range of the
 // instruction's immediate.
 def SVDUP_LANE   : SInst<"svdup_lane[_{d}]",  "ddL",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_tbl">;
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVDUP_LANE_BF16 :
+   SInst<"svdup_lane[_{d}]",  "ddL",  "b",   
MergeNone, "aarch64_sve_tbl">;
+}
+
 def SVDUPQ_LANE  : SInst<"svdupq_lane[_{d}]", "ddn",  

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-30 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.

As far as I'm concerned, this is fine for now. We can remove these once all 
in-tree target have implemented their support.
LGTM but maybe give a couple of days for others to chime in.




Comment at: clang/lib/Basic/Targets/PPC.h:86
+
+HasStrictFP = true;
   }

I don't think we need this for now. Close is not quite there. @steven.zhang I 
would prefer that we initially turn this off and only flip it on once the 
support is complete.
Also, is the support that is currently under development for both 32 and 64 bit 
architectures? If it is 64 bit only, then we can enable it only there once it 
is done.


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

https://reviews.llvm.org/D80952



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-30 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7046-7049
+/// Signal that the runtime library should use args as an array of
+/// descriptor_dim pointers and use args_size as dims. Used when we have
+/// non-contiguous list items in target update directive
+OMP_MAP_DESCRIPTOR = 0x800,

ABataev wrote:
> cchen wrote:
> > ABataev wrote:
> > > I'm not sure about the value of this flag. If I do recall it correctly, 
> > > this value might be used for something different by XL compiler, for 
> > > example. Maybe use some other value, maybe high bits? It is a kind of 
> > > service flag, not data mapping attribute, so better to move it to high 
> > > bits (the bit before OMP_MAP_MEMBER_OF maybe?).
> > Hi @ABataev, is there any place I can find which value has been used for 
> > lower bits (like 0x800, 0x1000)?
> I rather doubt. You can try to ask @kkwli0 
We are using 0x800.  I think your current choice should be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 274591.
njames93 added a comment.

Added best guess support for parsing RegexFlags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82706

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/ASTMatchers/ASTMatchersMacros.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  llvm/include/llvm/Support/Regex.h
  llvm/lib/Support/Regex.cpp

Index: llvm/lib/Support/Regex.cpp
===
--- llvm/lib/Support/Regex.cpp
+++ llvm/lib/Support/Regex.cpp
@@ -26,7 +26,7 @@
 
 Regex::Regex() : preg(nullptr), error(REG_BADPAT) {}
 
-Regex::Regex(StringRef regex, unsigned Flags) {
+Regex::Regex(StringRef regex, RegexFlags Flags) {
   unsigned flags = 0;
   preg = new llvm_regex();
   preg->re_endp = regex.end();
@@ -39,6 +39,9 @@
   error = llvm_regcomp(preg, regex.data(), flags|REG_PEND);
 }
 
+Regex::Regex(StringRef regex, unsigned Flags)
+: Regex(regex, static_cast(Flags)) {}
+
 Regex::Regex(Regex &) {
   preg = regex.preg;
   error = regex.error;
Index: llvm/include/llvm/Support/Regex.h
===
--- llvm/include/llvm/Support/Regex.h
+++ llvm/include/llvm/Support/Regex.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_SUPPORT_REGEX_H
 #define LLVM_SUPPORT_REGEX_H
 
+#include "llvm/ADT/BitmaskEnum.h"
 #include 
 
 struct llvm_regex;
@@ -26,20 +27,22 @@
 
   class Regex {
   public:
-enum {
-  NoFlags=0,
+enum RegexFlags : unsigned {
+  NoFlags = 0,
   /// Compile for matching that ignores upper/lower case distinctions.
-  IgnoreCase=1,
+  IgnoreCase = 1,
   /// Compile for newline-sensitive matching. With this flag '[^' bracket
   /// expressions and '.' never match newline. A ^ anchor matches the
   /// null string after any newline in the string in addition to its normal
   /// function, and the $ anchor matches the null string before any
   /// newline in the string in addition to its normal function.
-  Newline=2,
+  Newline = 2,
   /// By default, the POSIX extended regular expression (ERE) syntax is
   /// assumed. Pass this flag to turn on basic regular expressions (BRE)
   /// instead.
-  BasicRegex=4
+  BasicRegex = 4,
+
+  LLVM_MARK_AS_BITMASK_ENUM(BasicRegex)
 };
 
 Regex();
@@ -47,7 +50,8 @@
 ///
 /// \param Regex - referenced string is no longer needed after this
 /// constructor does finish.  Only its compiled form is kept stored.
-Regex(StringRef Regex, unsigned Flags = NoFlags);
+Regex(StringRef Regex, RegexFlags Flags = NoFlags);
+Regex(StringRef Regex, unsigned Flags);
 Regex(const Regex &) = delete;
 Regex =(Regex regex) {
   std::swap(preg, regex.preg);
Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -259,6 +259,15 @@
   EXPECT_TRUE(matches("unsigned X = sizeof(int);", MStmt));
   EXPECT_FALSE(matches("unsigned X = alignof(int);", MStmt));
 
+  Code =
+  R"query(namedDecl(matchesName("^::[ABC]*$", "IgnoreCase | BasicRegex")))query";
+  llvm::Optional MatchesName(
+  Parser::parseMatcherExpression(Code, nullptr, nullptr, ));
+  EXPECT_EQ("", Error.toStringFull());
+  M = MatchesName->unconditionalConvertTo();
+  EXPECT_TRUE(matches("unsigned AAACCBB;", M));
+  EXPECT_TRUE(matches("unsigned aaaccbb;", M));
+
   Code = "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))";
   EXPECT_TRUE(!Parser::parseMatcherExpression(Code, ).hasValue());
   EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
@@ -348,6 +357,26 @@
 "1:14: Incorrect type for arg 1. (Expected = string) != (Actual = "
 "String)",
 ParseMatcherWithError(R"query(decl(hasAttr("unrelated")))query"));
+  EXPECT_EQ(
+  "1:1: Error parsing argument 1 for matcher namedDecl.\n"
+  "1:11: Error building matcher matchesName.\n"
+  "1:33: Unknown value 'Ignorecase' for arg 2; did you mean 'IgnoreCase'",
+  ParseMatcherWithError(
+  R"query(namedDecl(matchesName("[ABC]*", "Ignorecase")))query"));
+  EXPECT_EQ(
+  "1:1: Error parsing argument 1 for matcher namedDecl.\n"
+  "1:11: Error building matcher matchesName.\n"
+  "1:33: Incorrect type for arg 2. (Expected = string) != (Actual = "
+  "String)",
+  

[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-06-30 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/test/Driver/aix-toolchain-include.cpp:8
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL32-INCLUDE %s
+// CHECK-INTERNAL32-INCLUDE: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL32-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"

I don't think we need a separate check prefix for 32/64-bit cases, just the RUN 
statements. Since the expected output is the same they can share the same 
prefix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added reviewers: john.brawn, nikic.
efriedma added subscribers: nikic, john.brawn.
efriedma added a comment.

I'm not sure what the status is of constrained fp on arm/aarch64; some patches 
went in, but I'm not sure what sort of testing was done.  @john.brawn @nikic ?

Otherwise, I think this patch makes sense.


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

https://reviews.llvm.org/D80952



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


[PATCH] D82731: [X86] Move frontend CPU feature initialization to a look up table based implementation.

2020-06-30 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3537939cda86: [X86] Move frontend CPU feature initialization 
to a look up table based… (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D82731?vs=274161=274586#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82731

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/include/llvm/Support/X86TargetParser.h
  llvm/lib/Support/X86TargetParser.cpp

Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -19,134 +19,339 @@
 
 namespace {
 
+/// Container class for CPU features.
+/// This is a constexpr reimplementation of a subset of std::bitset. It would be
+/// nice to use std::bitset directly, but it doesn't support constant
+/// initialization.
+class FeatureBitset {
+  static constexpr unsigned NUM_FEATURE_WORDS =
+  (X86::CPU_FEATURE_MAX + 31) / 32;
+
+  // This cannot be a std::array, operator[] is not constexpr until C++17.
+  uint32_t Bits[NUM_FEATURE_WORDS] = {};
+
+public:
+  constexpr FeatureBitset() = default;
+  constexpr FeatureBitset(std::initializer_list Init) {
+for (auto I : Init)
+  set(I);
+  }
+
+  constexpr FeatureBitset (unsigned I) {
+uint32_t NewBits = Bits[I / 32] | (uint32_t(1) << (I % 32));
+Bits[I / 32] = NewBits;
+return *this;
+  }
+
+  constexpr bool operator[](unsigned I) const {
+uint32_t Mask = uint32_t(1) << (I % 32);
+return (Bits[I / 32] & Mask) != 0;
+  }
+
+  constexpr FeatureBitset operator&(const FeatureBitset ) const {
+FeatureBitset Result;
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  Result.Bits[I] = Bits[I] & RHS.Bits[I];
+return Result;
+  }
+
+  constexpr FeatureBitset operator|(const FeatureBitset ) const {
+FeatureBitset Result;
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  Result.Bits[I] = Bits[I] | RHS.Bits[I];
+return Result;
+  }
+
+  constexpr FeatureBitset operator~() const {
+FeatureBitset Result;
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  Result.Bits[I] = ~Bits[I];
+return Result;
+  }
+};
+
 struct ProcInfo {
   StringLiteral Name;
   X86::CPUKind Kind;
   unsigned KeyFeature;
-  bool Is64Bit;
+  FeatureBitset Features;
 };
 
 } // end anonymous namespace
 
-#define PROC_64_BIT true
-#define PROC_32_BIT false
+#define X86_FEATURE(ENUM, STRING)  \
+  static constexpr FeatureBitset Feature##ENUM = {X86::FEATURE_##ENUM};
+#include "llvm/Support/X86TargetParser.def"
+
+// Pentium with MMX.
+static constexpr FeatureBitset FeaturesPentiumMMX =
+FeatureX87 | FeatureCMPXCHG8B | FeatureMMX;
+
+// Pentium 2 and 3.
+static constexpr FeatureBitset FeaturesPentium2 =
+FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR;
+static constexpr FeatureBitset FeaturesPentium3 = FeaturesPentium2 | FeatureSSE;
+
+// Pentium 4 CPUs
+static constexpr FeatureBitset FeaturesPentium4 =
+FeaturesPentium3 | FeatureSSE2;
+static constexpr FeatureBitset FeaturesPrescott =
+FeaturesPentium4 | FeatureSSE3;
+static constexpr FeatureBitset FeaturesNocona =
+FeaturesPrescott | FeatureEM64T | FeatureCMPXCHG16B;
+
+// Basic 64-bit capable CPU.
+static constexpr FeatureBitset FeaturesX86_64 = FeaturesPentium4 | FeatureEM64T;
+
+// Intel Core CPUs
+static constexpr FeatureBitset FeaturesCore2 =
+FeaturesNocona | FeatureSAHF | FeatureSSSE3;
+static constexpr FeatureBitset FeaturesPenryn = FeaturesCore2 | FeatureSSE4_1;
+static constexpr FeatureBitset FeaturesNehalem =
+FeaturesPenryn | FeaturePOPCNT | FeatureSSE4_2;
+static constexpr FeatureBitset FeaturesWestmere =
+FeaturesNehalem | FeaturePCLMUL;
+static constexpr FeatureBitset FeaturesSandyBridge =
+FeaturesWestmere | FeatureAVX | FeatureXSAVE | FeatureXSAVEOPT;
+static constexpr FeatureBitset FeaturesIvyBridge =
+FeaturesSandyBridge | FeatureF16C | FeatureFSGSBASE | FeatureRDRND;
+static constexpr FeatureBitset FeaturesHaswell =
+FeaturesIvyBridge | FeatureAVX2 | FeatureBMI | FeatureBMI2 | FeatureFMA |
+FeatureINVPCID | FeatureLZCNT | FeatureMOVBE;
+static constexpr FeatureBitset FeaturesBroadwell =
+FeaturesHaswell | FeatureADX | FeaturePRFCHW | FeatureRDSEED;
+
+// Intel Knights Landing and Knights Mill
+// Knights Landing has feature parity with Broadwell.
+static constexpr FeatureBitset FeaturesKNL =
+FeaturesBroadwell | FeatureAES | FeatureAVX512F | FeatureAVX512CD |
+FeatureAVX512ER | FeatureAVX512PF | FeaturePREFETCHWT1;
+static constexpr FeatureBitset FeaturesKNM =
+FeaturesKNL | FeatureAVX512VPOPCNTDQ;
+
+// Intel Skylake processors.
+static constexpr 

[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-06-30 Thread Ellis Hoag via Phabricator via cfe-commits
ellis created this revision.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.
ellis added a reviewer: clang-tools-extra.

The block arguments in `dispatch_async()` and `dispatch_after()` are
guaranteed to escape. If those blocks capture any pointers with the
`noescape` attribute then it is an error.

Test Plan:
ninja check-clang-tools


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82904

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s bugprone-no-escape %t
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_time_s *dispatch_time_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
+
+extern dispatch_queue_t queue;
+
+void test_noescape_attribute(__attribute__((noescape)) int *p, int *q) {
+  dispatch_async(queue, ^{
+*p = 123;
+// CHECK-MESSAGES: :[[@LINE-2]]:25: warning: Pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+// CHECK-MESSAGES: :[[@LINE-4]]:30: note: The 'noescape' attribute is declared here.
+  });
+
+  dispatch_after(456, queue, ^{
+*p = 789;
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: Pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+  });
+
+  dispatch_async(queue, ^{
+*q = 0;
+// CHECK-MESSAGES-NOT: ::[@LINE-2]:{{[0-9]*}}: warning: {{.*}} [bugprone-no-escape]
+  });
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
`bugprone-multiple-statement-macro `_,
+   `bugprone-no-escape `_, "Yes"
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - bugprone-no-escape
+
+bugprone-no-escape
+==
+
+Finds pointers with the ``noescape`` attribute that are captured by an
+asynchronously-executed block. The block arguments in ``dispatch_async()`` and
+``dispatch_after()`` are guaranteed to escape, so it is an error if a pointer with the
+``noescape`` attribute is captured by one of these blocks.
+
+The following is an example of an invalid use of the ``noescape`` attribute.
+
+  .. code-block:: objc
+void foo(__attribute__((noescape)) int *p) {
+  dispatch_async(queue, ^{
+*p = 123;
+  });
+});
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@
   result of a memory allocation function (``malloc()``, ``calloc()``,
   ``realloc()``, ``alloca()``) instead of its argument.
 
+- New :doc:`bugprone-no-escape
+  ` check.
+
+  Finds pointers with the `noescape` attribute that are captured by an
+  asynchronously-executed block.
+
 - New :doc:`bugprone-spuriously-wake-up-functions
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
@@ -0,0 +1,36 @@
+//===--- NoEscapeCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H
+
+#include 

[PATCH] D82568: [clang][CrossTU] Invalidate parent map after get cross TU definition.

2020-06-30 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

Ok, I checked and it seems the parent map context is used only by the AST 
matchers, and this is okay because it looks like there is not any storing or 
caching of the parent map objects (the type is never copied).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82568



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


[PATCH] D82824: [clang-tidy] Added option to readability-else-after-return

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa06a5ed97800: [clang-tidy] Added option to 
readability-else-after-return (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D82824?vs=274473=274569#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82824

Files:
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-cond-var-refactor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-cond-var-refactor.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-no-cond-var-refactor.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s readability-else-after-return %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN: {key: readability-else-after-return.WarnOnConditionVariables, value: false}, \
+// RUN: ]}'
+
+bool foo(int Y) {
+  // Excess scopes are here so that the check would have to opportunity to
+  // refactor the variable out of the condition.
+
+  // Expect warnings here as we don't need to move declaration of 'X' out of the
+  // if condition as its not used in the else.
+  {
+if (int X = Y)
+  return X < 0;
+else
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+  return false;
+  }
+  {
+if (int X = Y; X)
+  return X < 0;
+else
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+  return false;
+  }
+
+  // Expect no warnings for these cases, as even though its safe to move
+  // declaration of 'X' out of the if condition, that has been disabled
+  // by the options.
+  {
+if (int X = Y)
+  return false;
+else
+  return X < 0;
+  }
+  {
+if (int X = Y; X)
+  return false;
+else
+  return X < 0;
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
@@ -59,6 +59,21 @@
   }
 }
 
+Options
+---
+
+.. option:: WarnOnUnfixable
+
+   When `true`, emit a warning for cases where the check can't output a 
+   Fix-It. These can occur with declarations inside the ``else`` branch that
+   would have an extended lifetime if the ``else`` branch was removed.
+   Default value is `true`.
+
+.. option:: WarnOnConditionVariables
+
+   When `true`, the check will attempt to refactor a variable defined inside
+   the condition of the ``if`` statement that is used in the ``else`` branch
+   defining them just before the ``if`` statement. This can only be done if 
+   the ``if`` statement is the last statement in its parents scope.
+   Default value is `true`.
 
-This check helps to enforce this `LLVM Coding Standards recommendation
-`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -200,6 +200,11 @@
 
   Now checks ``std::basic_string_view`` by default.
 
+- Improved :doc:`readability-else-after-return
+  ` check now supports a 
+  `WarnOnConditionVariables` option to control whether to refactor condition
+  variables where possible.
+
 - Improved :doc:`readability-identifier-naming
   ` check.
 
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
@@ -28,6 +28,7 @@
 
 private:
   const bool WarnOnUnfixable;
+  const bool WarnOnConditionVariables;
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -26,6 +26,7 @@
 static const char ThrowStr[] = "throw";
 static const char WarningMessage[] = "do not use 'else' after '%0'";
 static const char WarnOnUnfixableStr[] = "WarnOnUnfixable";
+static const char WarnOnConditionVariablesStr[] = "WarnOnConditionVariables";
 
 const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) {
   

[PATCH] D82431: [PowerPC][Power10] Implement Test LSB by Byte Builtins in LLVM/Clang

2020-06-30 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

encoding tests need to be placed in corresponding `ppc64-encoding-ISA31*` files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82431



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


[PATCH] D82825: [clang-tidy] Added alias llvm-else-after-return.

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D82825#2123186 , @aaron.ballman 
wrote:

> I can see arguments either way on this. Personally, I would not want the 
> check to diagnose this code because that would encourage people to widen the 
> scope and lifetime of `X` or require them to introduce a new compound scope 
> to get the same behavior, and I think that's more problematic than the `else` 
> following a `return`. I am not certain if others feel the same way though.


I'll leave this for a bit before merging and see if anyone else wants a weigh 
in on the default llvm behaviour as this will likely have an effect on other 
contributors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82825



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


[PATCH] D82882: [ASTImporter] Fix AST import crash for a friend decl

2020-06-30 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks Vince, looks good to me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82882



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


[PATCH] D81098: [OpenMP] Upgrade default version of OpenMP to 5.0

2020-06-30 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D81098#2112159 , @ABataev wrote:

> LG


Since this revision landed two tests are failing.

` libomp.env::kmp_set_dispatch_buf.c` and 
`libomp.worksharing/for::kmp_set_dispatch_buf.c`. It was also reported on the 
mailing list 
(http://lists.llvm.org/pipermail/openmp-dev/2020-June/003507.html). Any idea 
how we can fix this quickly? @jdoerfert
 OR maybe this is known and will be taken care later?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81098



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


[PATCH] D82900: [analyzer][Z3-refutation] Add statistics tracking invalidated bug report classes

2020-06-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, xazax.hun, Szelethus, martong.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
whisperity.
Herald added a project: clang.

Counts how many bug report equivalence classes were created and
how many of them were completely invalidated.

In other words how many times avoided emitting diagnostic to the user due to
Z3 refutation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82900

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


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2849,7 +2849,7 @@
 return;
 
   if (!IsSAT.getValue())
-BR.markInvalid("Infeasible constraints", 
EndPathNode->getLocationContext());
+BR.markInvalid(Tag, EndPathNode->getLocationContext());
 }
 
 void FalsePositiveRefutationBRVisitor::addConstraints(
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -82,6 +82,11 @@
 STATISTIC(MaxValidBugClassSize,
   "The maximum number of bug reports in the same equivalence class "
   "where at least one report is valid (not suppressed)");
+STATISTIC(TotalBugReportEquivClasses,
+  "The # of bug report equivalence classes");
+STATISTIC(InvalidatedBugReportEquivClasses,
+  "The # of bug report equivalence classes invalidated due to "
+  "infeasible constraints");
 
 BugReporterVisitor::~BugReporterVisitor() = default;
 
@@ -2403,6 +2408,9 @@
 }
 
 void BugReporter::FlushReports() {
+  // Increment the total bug report equivalence classes processed statistic.
+  TotalBugReportEquivClasses += EQClassesVector.size();
+
   // We need to flush reports in deterministic order to ensure the order
   // of the reports is consistent between runs.
   for (const auto EQ : EQClassesVector)
@@ -2998,6 +3006,16 @@
   std::unique_ptr Diagnostics =
   generateDiagnosticForConsumerMap(report, Consumers, bugReports);
 
+  // Increment the statistic if necessary.
+  const bool IsEQClassInvalidatedByCrosscheck = llvm::all_of(
+  EQ.getReports(), [](const std::unique_ptr ) {
+const auto *Report = dyn_cast(RawReport.get());
+return Report && Report->isInvalidatedByTag(
+ FalsePositiveRefutationBRVisitor::Tag);
+  });
+  if (IsEQClassInvalidatedByCrosscheck)
+++InvalidatedBugReportEquivClasses;
+
   for (auto  : *Diagnostics) {
 PathDiagnosticConsumer *Consumer = P.first;
 std::unique_ptr  = P.second;
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -378,6 +378,8 @@
 public:
   FalsePositiveRefutationBRVisitor();
 
+  static constexpr char *Tag = "Infeasible constraints";
+
   void Profile(llvm::FoldingSetNodeID ) const override;
 
   PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -480,6 +480,14 @@
 Invalidations.insert(std::make_pair(Tag, Data));
   }
 
+  /// Returns whether or not this report was marked invalid by a given Tag.
+  bool isInvalidatedByTag(const void *Tag) const {
+const auto EqByTag = [Tag](const auto ) {
+  return TagAndData.first == Tag;
+};
+return llvm::any_of(Invalidations, EqByTag);
+  }
+
   /// Profile to identify equivalent bug reports for error report coalescing.
   /// Reports are uniqued to ensure that we do not emit multiple diagnostics
   /// for each bug.


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2849,7 +2849,7 @@
 return;
 
   if (!IsSAT.getValue())
-BR.markInvalid("Infeasible constraints", EndPathNode->getLocationContext());
+BR.markInvalid(Tag, EndPathNode->getLocationContext());
 }
 
 void FalsePositiveRefutationBRVisitor::addConstraints(

[PATCH] D82901: [libTooling] Fix `maybeExtendRange` to support `CharRange`s.

2020-06-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a project: clang.
ymandel added a subscriber: gmatute.

Currently, `maybeExtendRange` takes a `CharSourceRange`, but only works
correctly for the `TokenRange` case. This change adds proper support for the
`CharRange` case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82901

Files:
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "TestVisitor.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
@@ -21,9 +23,11 @@
 using llvm::Succeeded;
 using llvm::ValueIs;
 using tooling::getAssociatedRange;
+using tooling::getExtendedRange;
 using tooling::getExtendedText;
 using tooling::getRangeForEdit;
 using tooling::getText;
+using tooling::maybeExtendRange;
 using tooling::validateEditRange;
 
 namespace {
@@ -52,7 +56,7 @@
  arg.getBegin() == R.getBegin() && arg.getEnd() == R.getEnd();
 }
 
-MATCHER_P2(EqualsAnnotatedRange, SM, R, "") {
+MATCHER_P2(EqualsAnnotatedRange, Context, R, "") {
   if (arg.getBegin().isMacroID()) {
 *result_listener << "which starts in a macro";
 return false;
@@ -62,15 +66,13 @@
 return false;
   }
 
-  unsigned Begin = SM->getFileOffset(arg.getBegin());
-  unsigned End = SM->getFileOffset(arg.getEnd());
+  CharSourceRange Range = Lexer::getAsCharRange(
+  arg, Context->getSourceManager(), Context->getLangOpts());
+  unsigned Begin = Context->getSourceManager().getFileOffset(Range.getBegin());
+  unsigned End = Context->getSourceManager().getFileOffset(Range.getEnd());
 
-  *result_listener << "which is [" << Begin << ",";
-  if (arg.isTokenRange()) {
-*result_listener << End << "]";
-return Begin == R.Begin && End + 1 == R.End;
-  }
-  *result_listener << End << ")";
+  *result_listener << "which is a " << (arg.isTokenRange() ? "Token" : "Char")
+   << " range [" << Begin << "," << End << ")";
   return Begin == R.Begin && End == R.End;
 }
 
@@ -84,11 +86,13 @@
 // Base class for visitors that expect a single match corresponding to a
 // specific annotated range.
 template  class AnnotatedCodeVisitor : public TestVisitor {
-  llvm::Annotations Code;
+protected:
   int MatchCount = 0;
+  llvm::Annotations Code;
 
 public:
   AnnotatedCodeVisitor() : Code("$r[[]]") {}
+  // Helper for tests of `getAssociatedRange`.
   bool VisitDeclHelper(Decl *Decl) {
 // Only consider explicit declarations.
 if (Decl->isImplicit())
@@ -96,8 +100,7 @@
 
 ++MatchCount;
 EXPECT_THAT(getAssociatedRange(*Decl, *this->Context),
-EqualsAnnotatedRange(>Context->getSourceManager(),
- Code.range("r")))
+EqualsAnnotatedRange(this->Context, Code.range("r")))
 << Code.code();
 return true;
   }
@@ -183,6 +186,45 @@
   Visitor.runOver("int foo() { return foo() + 3; }");
 }
 
+TEST(SourceCodeTest, maybeExtendRange_TokenRange) {
+  struct ExtendTokenRangeVisitor
+  : AnnotatedCodeVisitor {
+bool VisitCallExpr(CallExpr *CE) {
+  ++MatchCount;
+  EXPECT_THAT(getExtendedRange(*CE, tok::TokenKind::semi, *Context),
+  EqualsAnnotatedRange(Context, Code.range("r")));
+  return true;
+}
+  };
+
+  ExtendTokenRangeVisitor Visitor;
+  // Extends to include semicolon.
+  Visitor.runOverAnnotated("void f(int x, int y) { $r[[f(x, y);]] }");
+  // Does not extend to include semicolon.
+  Visitor.runOverAnnotated(
+  "int f(int x, int y) { if (0) return $r[[f(x, y)]] + 3; }");
+}
+
+TEST(SourceCodeTest, maybeExtendRange_CharRange) {
+  struct ExtendCharRangeVisitor : AnnotatedCodeVisitor {
+bool VisitCallExpr(CallExpr *CE) {
+  ++MatchCount;
+  CharSourceRange Call = Lexer::getAsCharRange(CE->getSourceRange(),
+   Context->getSourceManager(),
+   Context->getLangOpts());
+  EXPECT_THAT(maybeExtendRange(Call, tok::TokenKind::semi, *Context),
+  EqualsAnnotatedRange(Context, Code.range("r")));
+  return true;
+}
+  };
+  ExtendCharRangeVisitor Visitor;
+  // Extends to include semicolon.
+  Visitor.runOverAnnotated("void f(int x, int y) { $r[[f(x, y);]] }");
+  // Does not extend to include semicolon.
+  Visitor.runOverAnnotated(
+  "int f(int x, int y) { if (0) return $r[[f(x, y)]] + 3; }");
+}
+
 TEST(SourceCodeTest, getAssociatedRange) {
   struct VarDeclsVisitor : AnnotatedCodeVisitor {
 

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-30 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D80833#2109172 , @uweigand wrote:

> Hmm, with clang-cl it seems the driver is trying to use this:
>  Target: s390x-pc-windows-msvc
>  which of course doesn't exist.  Not sure what is supposed to be happening 
> here, but it seems that it's falling back on s390x-linux since on s390x, 
> Linux is currently the only supported OS.


I'm seeing some of the tests are setting the target explicitly `%clang_cl 
--target=x86_64-windows-msvc`. Would that work on your machine? Or should I do 
`UNSUPPORTED: s390x` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D82832: Correctly generate invert xor value for Binary Atomics of int size > 64

2020-06-30 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

Nice find!


Repository:
  rC Clang

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

https://reviews.llvm.org/D82832



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


[PATCH] D82898: [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added a comment.
Herald added a subscriber: wuzish.

I've not added any specific unit tests for this, Don't think there would be 
much gained from them.
The init-variables and isolate-declaration checks do a good enough job of 
demonstrating the fix is working. 
If needs must specific checks will be added.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp:16
+}
\ No newline at end of file


I'll sort that out next diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82898



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


[PATCH] D82898: [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, gribozavr2, hokein.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.

Handle insertion fix-its when removing incompatible errors by introducting a 
new EventType `ET_Insert`
This has lower prioirty than End events, but higher than begin.
Idea being If an insert is at the same place as a begin event, the insert 
should be processed first to reduce unnecessary conflicts.
Likewise if its at the same place as an end event, process the end event first 
for the same reason.

This also fixes https://bugs.llvm.org/show_bug.cgi?id=46511.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82898

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s 
cppcoreguidelines-init-variables,readability-isolate-declaration %t
+
+void foo() {
+  int A, B, C;
+  // CHECK-MESSAGES-DAG: :[[@LINE-1]]:7: warning: variable 'A' is not 
initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-2]]:10: warning: variable 'B' is not 
initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-3]]:13: warning: variable 'C' is not 
initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-4]]:3: warning: multiple declarations in a 
single statement reduces readability
+
+  // Only the isolate declarations fix-it should be applied
+
+  //  CHECK-FIXES: int A;
+  // CHECK-FIXES-NEXT: int B;
+  // CHECK-FIXES-NEXT: int C;
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -590,6 +590,7 @@
 // An event can be either the begin or the end of an interval.
 enum EventType {
   ET_Begin = 1,
+  ET_Insert = 0,
   ET_End = -1,
 };
 
@@ -623,6 +624,8 @@
   //   disallowing the first one.
   if (Type == ET_Begin)
 Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
+  else if (Type == ET_Insert)
+Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
   else
 Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
 }
@@ -669,12 +672,13 @@
 unsigned Begin = Replace.getOffset();
 unsigned End = Begin + Replace.getLength();
 const std::string  = std::string(Replace.getFilePath());
-// FIXME: Handle empty intervals, such as those from insertions.
-if (Begin == End)
-  continue;
 auto  = FileEvents[FilePath];
-Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
-Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+if (Begin == End) {
+  Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
+} else {
+  Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
+  Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+}
   }
 }
   }
@@ -686,6 +690,11 @@
 llvm::sort(Events);
 int OpenIntervals = 0;
 for (const auto  : Events) {
+  if (Event.Type == Event::ET_Insert) {
+if (OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+continue;
+  }
   if (Event.Type == Event::ET_End)
 --OpenIntervals;
   // This has to be checked after removing the interval from the count if 
it


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables,readability-isolate-declaration %t
+
+void foo() {
+  int A, B, C;
+  // CHECK-MESSAGES-DAG: :[[@LINE-1]]:7: warning: variable 'A' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-2]]:10: warning: variable 'B' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-3]]:13: warning: variable 'C' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+
+  // Only the isolate declarations fix-it should be applied
+
+  //  CHECK-FIXES: int A;
+  // CHECK-FIXES-NEXT: int B;
+  // CHECK-FIXES-NEXT: int C;
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

[PATCH] D82887: [ARM] Add Cortex-A77 Support for Clang and LLVM

2020-06-30 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

In D82887#2123364 , @dmgreen wrote:

> Please make sure the switch in AArch64Subtarget::initializeProperties has an 
> entry too.
>
> Do you happen to know the cpu id for host.cpp?


do you mean the CPU part number used in e.g Host.cpp? then chasing the GCC link 
above points to 0xd0d which is also what is also in the TRM 
https://developer.arm.com/documentation/10/0101


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82887



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


[PATCH] D82882: [ASTImporter] Fix AST import crash for a friend decl

2020-06-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 274542.
vabridgers added a comment.

fix pre-merge checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82882

Files:
  clang/lib/AST/ASTImporterLookupTable.cpp


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -45,7 +45,11 @@
   LT.add(RTy->getAsCXXRecordDecl());
 else if (const auto *SpecTy = dyn_cast(Ty))
   LT.add(SpecTy->getAsCXXRecordDecl());
-else if (isa(Ty)) {
+else if (const auto *SubstTy =
+ dyn_cast(Ty)) {
+  if (SubstTy->getAsCXXRecordDecl())
+LT.add(SubstTy->getAsCXXRecordDecl());
+} else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
 } else {


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -45,7 +45,11 @@
   LT.add(RTy->getAsCXXRecordDecl());
 else if (const auto *SpecTy = dyn_cast(Ty))
   LT.add(SpecTy->getAsCXXRecordDecl());
-else if (isa(Ty)) {
+else if (const auto *SubstTy =
+ dyn_cast(Ty)) {
+  if (SubstTy->getAsCXXRecordDecl())
+LT.add(SubstTy->getAsCXXRecordDecl());
+} else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82889: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-06-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:416
+if (!Queue && getDerived().shouldTraversePostOrder())  
\
+  TRY_TO(WalkUpFromUnary##NAME(S));
\
 return true;   
\

As a review aid, compare the implementation of this function with the 
definition of the DEF_TRAVERSE_STMT macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82889



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


[PATCH] D82874: Add diagnostic option backing field for -fansi-escape-codes

2020-06-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 274541.
dang added a comment.

Move the call to `UseANSIEscapeCodes` to `CreateFromArgs`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82874

Files:
  clang/include/clang/Basic/DiagnosticOptions.def
  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
@@ -1599,8 +1599,6 @@
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
   Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option);
 
-  llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
-
   // Default behavior is to not to show note include stacks.
   Opts.ShowNoteIncludeStack = false;
   if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
@@ -3665,6 +3663,10 @@
   }
 
   Success &= Res.parseSimpleArgs(Args, Diags);
+
+  llvm::sys::Process::UseANSIEscapeCodes(
+  Res.DiagnosticOpts->UseANSIEscapeCodes);
+
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -901,7 +901,8 @@
   Flags<[CoreOption, DriverOption]>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, 
Group;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
-  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">;
+  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">,
+  MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "0">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
   MetaVarName<"">;
Index: clang/include/clang/Basic/DiagnosticOptions.def
===
--- clang/include/clang/Basic/DiagnosticOptions.def
+++ clang/include/clang/Basic/DiagnosticOptions.def
@@ -65,6 +65,7 @@
 ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for 
diagnostics:
 
 DIAGOPT(ShowColors, 1, 0)   /// Show diagnostics with ANSI color sequences.
+DIAGOPT(UseANSIEscapeCodes, 1, 0)
 ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1,
  Ovl_All)/// Overload candidates to show.
 DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1599,8 +1599,6 @@
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
   Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option);
 
-  llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
-
   // Default behavior is to not to show note include stacks.
   Opts.ShowNoteIncludeStack = false;
   if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
@@ -3665,6 +3663,10 @@
   }
 
   Success &= Res.parseSimpleArgs(Args, Diags);
+
+  llvm::sys::Process::UseANSIEscapeCodes(
+  Res.DiagnosticOpts->UseANSIEscapeCodes);
+
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -901,7 +901,8 @@
   Flags<[CoreOption, DriverOption]>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
-  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">;
+  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">,
+  MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "0">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation comment block command">,
   MetaVarName<"">;
Index: clang/include/clang/Basic/DiagnosticOptions.def
===
--- clang/include/clang/Basic/DiagnosticOptions.def
+++ clang/include/clang/Basic/DiagnosticOptions.def

[PATCH] D82874: Add diagnostic option backing field for -fansi-escape-codes

2020-06-30 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with the fix I mentioned.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3629
 #undef MERGE_ASSIGN_VALUE
+  llvm::sys::Process::UseANSIEscapeCodes(DiagnosticOpts->UseANSIEscapeCodes);
   return true;

This should probably be moved out so that this function only parses args and 
doesn't modify outside state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82874



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


[PATCH] D82623: [sve][acle] Enable feature macros for SVE ACLE extensions.

2020-06-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM with comment addressed.




Comment at: clang/lib/Basic/Targets/AArch64.cpp:325
+  if ((FPU & SveMode) && HasMatmulInt8)
+Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_INT8", "1");
+

It seems `HasMatmulInt8` is the same as `HasMatMul`, please reuse that instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82623



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


[PATCH] D82887: [ARM] Add Cortex-A77 Support for Clang and LLVM

2020-06-30 Thread Dave Green via Phabricator via cfe-commits
dmgreen added reviewers: dmgreen, ostannard, SjoerdMeijer.
dmgreen added a comment.

Please make sure the switch in AArch64Subtarget::initializeProperties has an 
entry too.

Do you happen to know the cpu id for host.cpp?




Comment at: clang/test/Driver/aarch64-cpus.c:729
 
+// RUN: %clang -target aarch64 -mcpu=cortex-a77  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A77 %s
+// CORTEX-A77: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a77"

Can you move this test up to next to the other cpus.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:128
+AARCH64_CPU_NAME("cortex-a77", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_FP16 | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD 
| AArch64::AEK_SSBS))
 AARCH64_CPU_NAME("neoverse-e1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,

Format this line - it's getting a bit long. It also would be good to make it 
consistent with the lines above.



Comment at: llvm/include/llvm/Support/ARMTargetParser.def:296
+ARM_CPU_NAME("cortex-a77", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
+(ARM::AEK_FP16 | ARM::AEK_DOTPROD) )
 ARM_CPU_NAME("neoverse-n1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,

Little bit of extra whitespace



Comment at: llvm/lib/Target/AArch64/AArch64.td:954
 def : ProcessorModel<"neoverse-n1", CortexA57Model, [ProcNeoverseN1]>;
+def : ProcessorModel<"cortex-a77", CortexA57Model, [HasV8_2aOps,
+FeatureFPARMv8,

Please add a ProcA77 and sort this next to the A76



Comment at: llvm/lib/Target/ARM/ARM.td:1226
  FeatureDotProd]>;
+def : ProcNoItin<"cortex-a77",  [ARMv82a,
+ FeatureHWDivThumb,

Whitespace here. And Adding a ProcA77 for consistency?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82887



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


[PATCH] D82891: [clangd] Fix race in FileIndex that sometimes temporarily lost updates.

2020-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

FileIndex was built out of threadsafe components, so update() didn't have data
races, but wasn't actually correct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82891

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -22,6 +22,7 @@
 #include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
+#include "support/Threading.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexSymbol.h"
@@ -509,6 +510,31 @@
   EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("b")));
 }
 
+// Verifies that concurrent calls to updateMain don't "lose" any updates.
+TEST(FileIndexTest, Threadsafety) {
+  FileIndex M;
+  Notification Go;
+
+  constexpr int Count = 10;
+  {
+// Set up workers to concurrently call updateMain() with separate files.
+AsyncTaskRunner Pool;
+for (unsigned I = 0; I < Count; ++I) {
+  auto TU = TestTU::withCode(llvm::formatv("int xxx{0};", I).str());
+  TU.Filename = llvm::formatv("x{0}.c", I).str();
+  Pool.runAsync(TU.Filename, [&, Filename(testPath(TU.Filename)),
+  AST(TU.build())]() mutable {
+Go.wait();
+M.updateMain(Filename, AST);
+  });
+}
+// On your marks, get set...
+Go.notify();
+  }
+
+  EXPECT_THAT(runFuzzyFind(M, "xxx"), ::testing::SizeIs(Count));
+}
+
 TEST(FileShardedIndexTest, Sharding) {
   auto AHeaderUri = URI::create(testPath("a.h")).toString();
   auto BHeaderUri = URI::create(testPath("b.h")).toString();
Index: clang-tools-extra/clangd/index/Symbol.h
===
--- clang-tools-extra/clangd/index/Symbol.h
+++ clang-tools-extra/clangd/index/Symbol.h
@@ -186,7 +186,8 @@
   const_iterator end() const { return Symbols.end(); }
   const_iterator find(const SymbolID ) const;
 
-  size_t size() const { return Symbols.size(); }
+  using size_type = size_t;
+  size_type size() const { return Symbols.size(); }
   bool empty() const { return Symbols.empty(); }
   // Estimates the total memory usage.
   size_t bytes() const {
Index: clang-tools-extra/clangd/index/FileIndex.h
===
--- clang-tools-extra/clangd/index/FileIndex.h
+++ clang-tools-extra/clangd/index/FileIndex.h
@@ -81,9 +81,11 @@
   /// The index keeps the slabs alive.
   /// Will count Symbol::References based on number of references in the main
   /// files, while building the index with DuplicateHandling::Merge option.
+  /// Version is populated with an increasing sequence counter.
   std::unique_ptr
   buildIndex(IndexType,
- DuplicateHandling DuplicateHandle = DuplicateHandling::PickOne);
+ DuplicateHandling DuplicateHandle = DuplicateHandling::PickOne,
+ unsigned *Version = nullptr);
 
 private:
   struct RefSlabAndCountReferences {
@@ -92,6 +94,7 @@
   };
   mutable std::mutex Mutex;
 
+  unsigned Version = 0;
   llvm::StringMap> SymbolsSnapshot;
   llvm::StringMap RefsSnapshot;
   llvm::StringMap> RelatiosSnapshot;
@@ -136,6 +139,12 @@
   // (Note that symbols *only* in the main file are not indexed).
   FileSymbols MainFileSymbols;
   SwapIndex MainFileIndex;
+
+  // While both the FileIndex and SwapIndex are threadsafe, we need to track
+  // versions to ensure that we don't overwrite newer indexes with older ones.
+  std::mutex UpdateIndexMu;
+  unsigned MainIndexVersion = 0;
+  unsigned PreambleIndexVersion = 0;
 };
 
 using SlabTuple = std::tuple;
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -248,7 +248,8 @@
 }
 
 std::unique_ptr
-FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle) {
+FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
+unsigned *Version) {
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;
@@ -264,6 +265,10 @@
 }
 for (const auto  : RelatiosSnapshot)
   RelationSlabs.push_back(FileAndRelations.second);
+
+++this->Version;
+if (Version)
+  *Version = this->Version;
   }
   std::vector AllSymbols;
   std::vector SymsStorage;
@@ -390,12 +395,23 @@
 

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-30 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/debugify-each-original.c:9
+
+// RUN: rm -rf %t.json
+// RUN: %clang -g -Xclang -fenable-debugify-each-original \

I think this is redundant?


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

https://reviews.llvm.org/D82547



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a subscriber: kkwli0.
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7046-7049
+/// Signal that the runtime library should use args as an array of
+/// descriptor_dim pointers and use args_size as dims. Used when we have
+/// non-contiguous list items in target update directive
+OMP_MAP_DESCRIPTOR = 0x800,

cchen wrote:
> ABataev wrote:
> > I'm not sure about the value of this flag. If I do recall it correctly, 
> > this value might be used for something different by XL compiler, for 
> > example. Maybe use some other value, maybe high bits? It is a kind of 
> > service flag, not data mapping attribute, so better to move it to high bits 
> > (the bit before OMP_MAP_MEMBER_OF maybe?).
> Hi @ABataev, is there any place I can find which value has been used for 
> lower bits (like 0x800, 0x1000)?
I rather doubt. You can try to ask @kkwli0 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D82824: [clang-tidy] Added option to readability-else-after-return

2020-06-30 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 once the documentation nit is fixed up.




Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:193
   if (checkConditionVarUsageInElse(If) != nullptr) {
+if (!WarnOnConditionVariables)
+  return;

njames93 wrote:
> aaron.ballman wrote:
> > njames93 wrote:
> > > aaron.ballman wrote:
> > > > Would it make sense to hoist this into the previous `if` statement so 
> > > > we don't bother checking the condition var use in the first place if 
> > > > we're just going to ignore the results?
> > > That wouldn't work, we need to see if there is a condition variable that 
> > > needs refactoring first before we can disregard it, Or am I missing 
> > > something?
> > I was suggesting:
> > ```
> > if (WarnOnConditionVariables && checkConditionVarUsageInElse(If)) {
> >  ...
> > }
> > if (WarnOnConditionVariables && checkInitDeclUsageInElse(If) {
> > ...
> > }
> > ```
> > The effect is that we don't bother checking for the situations we weren't 
> > going to warn about anyway. But maybe I'm the one missing something?
> I think you may be this time. The reason being those `if` statements have a 
> `return` at the end. If I followed how you have it layed out, those returns 
> would never hit regardless of whether there was a condition variable that 
> needed handling or not.
Oh! So you're talking about the case where `IsLastInScope` and 
`WarnOnUnfixable` are both `false`, okay I see that now. I think the logic 
could still be rearranged to avoid doing work you're just going to immediately 
throw away, but I don't think it's critical (or really needed for this patch).



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst:74
+
+   When `true`, The check will attempt to refactor a variable defined inside
+   the condition of the ``if`` statement that is used in the ``else`` branch.

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > The -> the
> > > 
> > > I'm a bit unclear on what "attempt to refactor" means -- I sort of 
> > > understand it to mean that if this option is true then the check will not 
> > > produce a fix-it for variables defined inside the condition of the if 
> > > statement that is used in the else branch, but will produce a diagnostic. 
> > > However, the check behavior seems to also remove the diagnostic in this 
> > > case (not just the fix-it), so I'm not certain I'm reading this right.
> > Good spot, the check behaviour is also removing the diagnostic as well as 
> > the fix it.
> > That behaviour should probably be changed to removing the Fix-It when this 
> > option is `false`, but then diagnostic behaviour should follow what 
> > `WarnOnUnfixable` dictates.
> I think that makes sense. Then the option can be renamed to remove the 
> "Refactor" bit and probably be something more like `WarnOnConditionVariables` 
> or something?
Still have to fix the capitalization issues with `The` and `Emit`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82824



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


[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

2020-06-30 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D82845#2123283 , 
@baloghadamsoftware wrote:

> In D82845#2122984 , @balazske wrote:
>
> > I checked it with simple debug print, the `LeakedSyms` will contain 2 items 
> > with different `StreamOpenNode`. So I think these should be independent 
> > problem reports for the bug reporter.
>
>
> I wonder whether you can report two bugs on the same error node.


I recall that i did something similar in UninitializedObjectChecker when the 
option NotesAsWarnings is true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845



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


[PATCH] D82824: [clang-tidy] Added option to readability-else-after-return

2020-06-30 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/readability/ElseAfterReturnCheck.cpp:193
   if (checkConditionVarUsageInElse(If) != nullptr) {
+if (!WarnOnConditionVariables)
+  return;

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > Would it make sense to hoist this into the previous `if` statement so we 
> > > don't bother checking the condition var use in the first place if we're 
> > > just going to ignore the results?
> > That wouldn't work, we need to see if there is a condition variable that 
> > needs refactoring first before we can disregard it, Or am I missing 
> > something?
> I was suggesting:
> ```
> if (WarnOnConditionVariables && checkConditionVarUsageInElse(If)) {
>  ...
> }
> if (WarnOnConditionVariables && checkInitDeclUsageInElse(If) {
> ...
> }
> ```
> The effect is that we don't bother checking for the situations we weren't 
> going to warn about anyway. But maybe I'm the one missing something?
I think you may be this time. The reason being those `if` statements have a 
`return` at the end. If I followed how you have it layed out, those returns 
would never hit regardless of whether there was a condition variable that 
needed handling or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82824



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


[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

2020-06-30 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D82845#2122984 , @balazske wrote:

> I checked it with simple debug print, the `LeakedSyms` will contain 2 items 
> with different `StreamOpenNode`. So I think these should be independent 
> problem reports for the bug reporter.


I wonder whether you can report two bugs on the same error node.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-30 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

bumping for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-30 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7046-7049
+/// Signal that the runtime library should use args as an array of
+/// descriptor_dim pointers and use args_size as dims. Used when we have
+/// non-contiguous list items in target update directive
+OMP_MAP_DESCRIPTOR = 0x800,

ABataev wrote:
> I'm not sure about the value of this flag. If I do recall it correctly, this 
> value might be used for something different by XL compiler, for example. 
> Maybe use some other value, maybe high bits? It is a kind of service flag, 
> not data mapping attribute, so better to move it to high bits (the bit before 
> OMP_MAP_MEMBER_OF maybe?).
Hi @ABataev, is there any place I can find which value has been used for lower 
bits (like 0x800, 0x1000)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D82767: clang-format: Explicitly use python3

2020-06-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D82767#2123024 , @compnerd wrote:

> While I really like this idea of migrating the scripts to python3, I believe 
> that the current plan is to allow until December for users to migrate, so 
> this might be a bit premature :-(.


Is this documented somewhere? I think that every script being broken by default 
on all new distributions is a big problem. It's been 12 years, and python 2 has 
been EOL since January. I don't see why downstream projects would still be 
holding on dropping python 2


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

https://reviews.llvm.org/D82767



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


[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments

2020-06-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1952
 
+std::shared_ptr createAndVerifyRegex(StringRef Regex,
+  llvm::Regex::RegexFlags 
Flags,

njames93 wrote:
> aaron.ballman wrote:
> > Is there a reason this needs to be a shared pointer as opposed to a unique 
> > pointer that gets moved into the class owning it?
> It has to be shared ownership for the polymorphic matchers to enable reuse of 
> `PolymorphicMatcherWithParam1`.  When a matcher or type `T` is required from 
> a `PolymorphicMatcherWithParam1` it creates a copy of the Param. As you can't 
> copy from a `unique_ptr`, a `shared_ptr` makes sense.
Drat, but reasonable, thanks for the explanation.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp:126
+  Flag |= llvm::Regex::IgnoreCase;
+else if (OrFlag == "NewLine")
+  Flag |= llvm::Regex::Newline;

njames93 wrote:
> aaron.ballman wrote:
> > This makes me think we want to do a case insensitive comparison rather than 
> > an exact case match. Personally, I would always write `NewLine` as the 
> > string literal, but I could easily see someone writing `Newline` to match 
> > the spelling of the RegEx flag and being surprised it doesn't work. WDYT?
> That could work, or I implement the `ArgTypeTraits::getBestGuess` to handle 
> small issues like that. Would be a little trickier than the other cases as It 
> would need to support `|`. WDYT?
Hmm, I don't have a firm opinion but am slightly leaning towards implementing 
`getBestGuess` and using the more strict spellings based purely on personal 
preference.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:745
+  bool isVariadic() const override { return true; }
+  unsigned getNumArgs() const override { return 0; }
+

njames93 wrote:
> aaron.ballman wrote:
> > I may be misunderstanding this, but it seems suspicious that `getNumArgs()` 
> > returns 0 but `getArgKinds()` suggests at least one argument. Is that 
> > intentional?
> It was my understanding that when `isVariadic()` returns true, `getNumArgs()` 
> is not used. I could change it to return 1, but that wouldn't be any more 
> correct than it is now, nor would it have any functional change.
Ah, so the real issue is that `getNumArgs()` is pure virtual, which forces us 
to ask these sort of silly questions. Good to know, I'm fine with `0`, I was 
just surprised.



Comment at: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp:379
+  ParseMatcherWithError(
+  R"query(namedDecl(matchesName("[ABC]*", "IgnoreCase | 
Basicregex")))query"));
 }

njames93 wrote:
> aaron.ballman wrote:
> > Should we have a failure for something like `IgnoreCase | NoFlags` ?
> I'm against that, its perfectly legal in non dynamic matchers land to write 
> `matchesName("[ABC]*", IgnoreCase | NoFlags)` Even if it is a little 
> redundant.
Okay, fine by me. I only brought it up because it seems like a very confused 
user and we have the opportunity to diagnose (due to the dynamic nature here as 
opposed to the static nature of C++ using bitwise OR directly).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82706



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


[PATCH] D82889: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-06-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gribozavr2 added reviewers: eduucaldas, ymandel, rsmith.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82889

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -606,14 +606,13 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -675,7 +674,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -684,6 +682,9 @@
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryMinus UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -996,8 +997,6 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1005,6 +1004,7 @@
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1067,7 +1067,6 @@
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAdd.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1078,6 +1077,9 @@
 WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromExpr IntegerLiteral(3)
 WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromBinAdd BinaryOperator(+)
+WalkUpFromExpr BinaryOperator(+)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
@@ -1396,8 +1398,6 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // CompoundAssignOperator(+=).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1405,6 +1405,7 @@
 TraverseBinAddAssign CompoundAssignOperator(+=)
   WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1470,7 +1471,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAddAssign.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1481,6 +1481,9 @@
 WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromBinAddAssign CompoundAssignOperator(+=)
+WalkUpFromExpr CompoundAssignOperator(+=)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -412,6 +412,8 @@
 if (!getDerived().shouldTraversePostOrder())   \
   TRY_TO(WalkUpFromUnary##NAME(S));\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  \
+if (!Queue && getDerived().shouldTraversePostOrder())  \
+  TRY_TO(WalkUpFromUnary##NAME(S));\
 return true;   \
   }\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   \
@@ -433,6 +435,8 @@
   

  1   2   3   >