[PATCH] D63316: [clangd] Include the diagnostics's code when comparing diagnostics

2019-06-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Could you also add a lit test for the case you mentioned in the github issue?

You can find pointers in clang-tools-extra/clangd/test/diagnostics.test and 
clang-tools-extra/clangd/test/fixits-codeaction.test




Comment at: clang-tools-extra/clangd/Protocol.h:654
   bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const {
-return std::tie(LHS.range, LHS.message) < std::tie(RHS.range, RHS.message);
+return std::tie(LHS.code, LHS.range, LHS.message) <
+   std::tie(RHS.code, RHS.range, RHS.message);

could you rather put `code` after range and message so that we somewhat 
preserve the ordering. I am not sure if it is used anywhere but looks like we 
are using an ordered container(std::map) to store these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63316



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


[PATCH] D58880: [clangd] Type hierarchy subtypes

2019-06-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM with a few small comments.

Thanks for implementing this awesome feature!




Comment at: clang-tools-extra/clangd/FindSymbols.cpp:42
 
+llvm::Optional symbolToLocation(const Symbol &Sym,
+  llvm::StringRef HintPath) {

let's rather return an llvm::Expected and propagate the error 
messages in the error then log in the caller site



Comment at: clang-tools-extra/clangd/FindSymbols.h:21
 class ParsedAST;
+struct Symbol;
 class SymbolIndex;

let's rather `#include "Symbol.h"`



Comment at: clang-tools-extra/clangd/XRefs.cpp:1052
+  PathRef TUPath) {
+  // TODO: Pass in ClangdServer::WorkspaceRoot as a HintPath.
+  StringRef HintPath;

this part looks a little messed up ?

 I suppose you wanted to propagate TUPath to symbolToLocation right?



Comment at: clang-tools-extra/clangd/XRefs.h:139
 getTypeHierarchy(ParsedAST &AST, Position Pos, int Resolve,
- TypeHierarchyDirection Direction);
+ TypeHierarchyDirection Direction, PathRef TUPath = PathRef{},
+ const SymbolIndex *Index = nullptr);

I believe TUPath is not used if Index is nullptr, maybe replace those two?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58880



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


[PATCH] D62839: [clangd] Index API and implementations for relations

2019-06-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62839



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


[PATCH] D60523: [clang] Don't segfault on incorrect using directive (PR41400)

2019-06-14 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363360: [clang] Don't segfault on incorrect using 
directive (PR41400) (authored by Tyker, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60523?vs=194552&id=204720#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60523

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/using-decl-1.cpp


Index: cfe/trunk/test/SemaCXX/using-decl-1.cpp
===
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp
@@ -396,3 +396,10 @@
   using N::Y;
   using N::Z;
 }
+
+// expected-error@+5 {{requires a qualified name}}
+// expected-error@+4 {{expected ';'}}
+// expected-error@+3 {{expected '}'}}
+// expected-note@+2 {{to match this '{'}}
+// expected-error@+1 {{expected ';'}}
+template struct S { using S
\ No newline at end of file
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -90,7 +90,7 @@
   // When naming a constructor as a member of a dependent context (eg, in a
   // friend declaration or an inherited constructor declaration), form an
   // unresolved "typename" type.
-  if (CurClass->isDependentContext() && !EnteringContext) {
+  if (CurClass->isDependentContext() && !EnteringContext && SS.getScopeRep()) {
 QualType T = Context.getDependentNameType(ETK_None, SS.getScopeRep(), &II);
 return ParsedType::make(T);
   }


Index: cfe/trunk/test/SemaCXX/using-decl-1.cpp
===
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp
@@ -396,3 +396,10 @@
   using N::Y;
   using N::Z;
 }
+
+// expected-error@+5 {{requires a qualified name}}
+// expected-error@+4 {{expected ';'}}
+// expected-error@+3 {{expected '}'}}
+// expected-note@+2 {{to match this '{'}}
+// expected-error@+1 {{expected ';'}}
+template struct S { using S
\ No newline at end of file
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -90,7 +90,7 @@
   // When naming a constructor as a member of a dependent context (eg, in a
   // friend declaration or an inherited constructor declaration), form an
   // unresolved "typename" type.
-  if (CurClass->isDependentContext() && !EnteringContext) {
+  if (CurClass->isDependentContext() && !EnteringContext && SS.getScopeRep()) {
 QualType T = Context.getDependentNameType(ETK_None, SS.getScopeRep(), &II);
 return ParsedType::make(T);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363056 - [RISCV][NFC] Add missing test files for D54091

2019-06-14 Thread Lewis Revill via cfe-commits
Author: lewis-revill
Date: Tue Jun 11 05:49:15 2019
New Revision: 363056

URL: http://llvm.org/viewvc/llvm-project?rev=363056&view=rev
Log:
[RISCV][NFC] Add missing test files for D54091

Added:
cfe/trunk/test/CodeGen/riscv-inline-asm.c
cfe/trunk/test/Sema/inline-asm-validate-riscv.c

Added: cfe/trunk/test/CodeGen/riscv-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/riscv-inline-asm.c?rev=363056&view=auto
==
--- cfe/trunk/test/CodeGen/riscv-inline-asm.c (added)
+++ cfe/trunk/test/CodeGen/riscv-inline-asm.c Tue Jun 11 05:49:15 2019
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple riscv32 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V specific inline assembly constraints.
+
+void test_I() {
+// CHECK-LABEL: define void @test_I()
+// CHECK: call void asm sideeffect "", "I"(i32 2047)
+  asm volatile ("" :: "I"(2047));
+// CHECK: call void asm sideeffect "", "I"(i32 -2048)
+  asm volatile ("" :: "I"(-2048));
+}
+
+void test_J() {
+// CHECK-LABEL: define void @test_J()
+// CHECK: call void asm sideeffect "", "J"(i32 0)
+  asm volatile ("" :: "J"(0));
+}
+
+void test_K() {
+// CHECK-LABEL: define void @test_K()
+// CHECK: call void asm sideeffect "", "K"(i32 31)
+  asm volatile ("" :: "K"(31));
+// CHECK: call void asm sideeffect "", "K"(i32 0)
+  asm volatile ("" :: "K"(0));
+}

Added: cfe/trunk/test/Sema/inline-asm-validate-riscv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline-asm-validate-riscv.c?rev=363056&view=auto
==
--- cfe/trunk/test/Sema/inline-asm-validate-riscv.c (added)
+++ cfe/trunk/test/Sema/inline-asm-validate-riscv.c Tue Jun 11 05:49:15 2019
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple riscv32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -fsyntax-only -verify %s
+
+void I(int i) {
+  static const int BelowMin = -2049;
+  static const int AboveMax = 2048;
+  asm volatile ("" :: "I"(i)); // expected-error{{constraint 'I' expects an 
integer constant expression}}
+  asm volatile ("" :: "I"(BelowMin)); // expected-error{{value '-2049' out of 
range for constraint 'I'}}
+  asm volatile ("" :: "I"(AboveMax)); // expected-error{{value '2048' out of 
range for constraint 'I'}}
+}
+
+void J(int j) {
+  static const int BelowMin = -1;
+  static const int AboveMax = 1;
+  asm volatile ("" :: "J"(j)); // expected-error{{constraint 'J' expects an 
integer constant expression}}
+  asm volatile ("" :: "J"(BelowMin)); // expected-error{{value '-1' out of 
range for constraint 'J'}}
+  asm volatile ("" :: "J"(AboveMax)); // expected-error{{value '1' out of 
range for constraint 'J'}}
+}
+
+void K(int k) {
+  static const int BelowMin = -1;
+  static const int AboveMax = 32;
+  asm volatile ("" :: "K"(k)); // expected-error{{constraint 'K' expects an 
integer constant expression}}
+  asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of 
range for constraint 'K'}}
+  asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of 
range for constraint 'K'}}
+}


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


r363055 - [RISCV] Add inline asm constraints I, J & K for RISC-V

2019-06-14 Thread Lewis Revill via cfe-commits
Author: lewis-revill
Date: Tue Jun 11 05:44:01 2019
New Revision: 363055

URL: http://llvm.org/viewvc/llvm-project?rev=363055&view=rev
Log:
[RISCV] Add inline asm constraints I, J & K for RISC-V

This allows the constraints I, J & K to be used in inline asm for
RISC-V, with the following semantics (equivalent to GCC):

I: Any 12-bit signed immediate.
J: Integer zero only.
K: Any 5-bit unsigned immediate.

See the GCC definitions here:
https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html

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


Modified:
cfe/trunk/lib/Basic/Targets/RISCV.cpp
cfe/trunk/lib/Basic/Targets/RISCV.h

Modified: cfe/trunk/lib/Basic/Targets/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.cpp?rev=363055&r1=363054&r2=363055&view=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp Tue Jun 11 05:44:01 2019
@@ -39,6 +39,26 @@ ArrayRef RISCVT
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+bool RISCVTargetInfo::validateAsmConstraint(
+const char *&Name, TargetInfo::ConstraintInfo &Info) const {
+  switch (*Name) {
+  default:
+return false;
+  case 'I':
+// A 12-bit signed immediate.
+Info.setRequiresImmediate(-2048, 2047);
+return true;
+  case 'J':
+// Integer zero.
+Info.setRequiresImmediate(0);
+return true;
+  case 'K':
+// A 5-bit unsigned immediate for CSR access instructions.
+Info.setRequiresImmediate(0, 31);
+return true;
+  }
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");

Modified: cfe/trunk/lib/Basic/Targets/RISCV.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.h?rev=363055&r1=363054&r2=363055&view=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.h (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.h Tue Jun 11 05:44:01 2019
@@ -61,9 +61,7 @@ public:
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &Info) const override {
-return false;
-  }
+ TargetInfo::ConstraintInfo &Info) const override;
 
   bool hasFeature(StringRef Feature) const override;
 


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


[PATCH] D54091: [RISCV] Add inline asm constraints I, J & K for RISC-V

2019-06-14 Thread Lewis Revill via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363055: [RISCV] Add inline asm constraints I, J & K for 
RISC-V (authored by lewis-revill, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54091?vs=203367&id=204043#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54091

Files:
  cfe/trunk/lib/Basic/Targets/RISCV.cpp
  cfe/trunk/lib/Basic/Targets/RISCV.h


Index: cfe/trunk/lib/Basic/Targets/RISCV.cpp
===
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp
@@ -39,6 +39,26 @@
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+bool RISCVTargetInfo::validateAsmConstraint(
+const char *&Name, TargetInfo::ConstraintInfo &Info) const {
+  switch (*Name) {
+  default:
+return false;
+  case 'I':
+// A 12-bit signed immediate.
+Info.setRequiresImmediate(-2048, 2047);
+return true;
+  case 'J':
+// Integer zero.
+Info.setRequiresImmediate(0);
+return true;
+  case 'K':
+// A 5-bit unsigned immediate for CSR access instructions.
+Info.setRequiresImmediate(0, 31);
+return true;
+  }
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -61,9 +61,7 @@
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &Info) const override {
-return false;
-  }
+ TargetInfo::ConstraintInfo &Info) const override;
 
   bool hasFeature(StringRef Feature) const override;
 


Index: cfe/trunk/lib/Basic/Targets/RISCV.cpp
===
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp
@@ -39,6 +39,26 @@
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+bool RISCVTargetInfo::validateAsmConstraint(
+const char *&Name, TargetInfo::ConstraintInfo &Info) const {
+  switch (*Name) {
+  default:
+return false;
+  case 'I':
+// A 12-bit signed immediate.
+Info.setRequiresImmediate(-2048, 2047);
+return true;
+  case 'J':
+// Integer zero.
+Info.setRequiresImmediate(0);
+return true;
+  case 'K':
+// A 5-bit unsigned immediate for CSR access instructions.
+Info.setRequiresImmediate(0, 31);
+return true;
+  }
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -61,9 +61,7 @@
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &Info) const override {
-return false;
-  }
+ TargetInfo::ConstraintInfo &Info) const override;
 
   bool hasFeature(StringRef Feature) const override;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363360 - [clang] Don't segfault on incorrect using directive (PR41400)

2019-06-14 Thread Gauthier Harnisch via cfe-commits
Author: tyker
Date: Fri Jun 14 01:25:52 2019
New Revision: 363360

URL: http://llvm.org/viewvc/llvm-project?rev=363360&view=rev
Log:
[clang] Don't segfault on incorrect using directive (PR41400)

Summary:
this is a bugfixe for [[ https://bugs.llvm.org/show_bug.cgi?id=41400 | PR41400 
]]

added nullptr check at the relevent place and test

Reviewers: rsmith, riccibruno

Reviewed By: rsmith

Subscribers: jkooker, jkorous, riccibruno, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/using-decl-1.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=363360&r1=363359&r2=363360&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun 14 01:25:52 2019
@@ -90,7 +90,7 @@ ParsedType Sema::getConstructorName(Iden
   // When naming a constructor as a member of a dependent context (eg, in a
   // friend declaration or an inherited constructor declaration), form an
   // unresolved "typename" type.
-  if (CurClass->isDependentContext() && !EnteringContext) {
+  if (CurClass->isDependentContext() && !EnteringContext && SS.getScopeRep()) {
 QualType T = Context.getDependentNameType(ETK_None, SS.getScopeRep(), &II);
 return ParsedType::make(T);
   }

Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=363360&r1=363359&r2=363360&view=diff
==
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Fri Jun 14 01:25:52 2019
@@ -396,3 +396,10 @@ namespace tag_vs_var {
   using N::Y;
   using N::Z;
 }
+
+// expected-error@+5 {{requires a qualified name}}
+// expected-error@+4 {{expected ';'}}
+// expected-error@+3 {{expected '}'}}
+// expected-note@+2 {{to match this '{'}}
+// expected-error@+1 {{expected ';'}}
+template struct S { using S
\ No newline at end of file


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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2019-06-14 Thread Guillaume Racicot via Phabricator via cfe-commits
gracicot added a comment.

Will this option also work with dangling braces from initializers?

I have some code that looks like this:

  return some_type_with_a_long_name{
  get_param_number_one(),
  get_param_number_two()
  };

Clang format will put the brace at the end of the line:

  return some_type_with_a_long_name{
  get_param_number_one(),
  get_param_number_two()};

I would like to keep the style of the first snippet.


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

https://reviews.llvm.org/D33029



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


[PATCH] D54295: [RISCV] Add inline asm constraint A for RISC-V

2019-06-14 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 204512.
lewis-revill retitled this revision from "[WIP, RISCV] Add inline asm 
constraint A for RISC-V" to "[RISCV] Add inline asm constraint A for RISC-V".
Herald added subscribers: Jim, benna, psnobl.

Repository:
  rC Clang

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

https://reviews.llvm.org/D54295

Files:
  lib/Basic/Targets/RISCV.cpp
  test/CodeGen/riscv-inline-asm.c


Index: test/CodeGen/riscv-inline-asm.c
===
--- test/CodeGen/riscv-inline-asm.c
+++ test/CodeGen/riscv-inline-asm.c
@@ -26,3 +26,9 @@
 // CHECK: call void asm sideeffect "", "K"(i32 0)
   asm volatile ("" :: "K"(0));
 }
+
+void test_A(int *p) {
+// CHECK-LABEL: define void @test_A(i32* %p)
+// CHECK: call void asm sideeffect "", "*A"(i32* %p)
+  asm volatile("" :: "A"(*p));
+}
Index: lib/Basic/Targets/RISCV.cpp
===
--- lib/Basic/Targets/RISCV.cpp
+++ lib/Basic/Targets/RISCV.cpp
@@ -56,6 +56,10 @@
 // A 5-bit unsigned immediate for CSR access instructions.
 Info.setRequiresImmediate(0, 31);
 return true;
+  case 'A':
+// An address that is held in a general-purpose register.
+Info.setAllowsMemory();
+return true;
   }
 }
 


Index: test/CodeGen/riscv-inline-asm.c
===
--- test/CodeGen/riscv-inline-asm.c
+++ test/CodeGen/riscv-inline-asm.c
@@ -26,3 +26,9 @@
 // CHECK: call void asm sideeffect "", "K"(i32 0)
   asm volatile ("" :: "K"(0));
 }
+
+void test_A(int *p) {
+// CHECK-LABEL: define void @test_A(i32* %p)
+// CHECK: call void asm sideeffect "", "*A"(i32* %p)
+  asm volatile("" :: "A"(*p));
+}
Index: lib/Basic/Targets/RISCV.cpp
===
--- lib/Basic/Targets/RISCV.cpp
+++ lib/Basic/Targets/RISCV.cpp
@@ -56,6 +56,10 @@
 // A 5-bit unsigned immediate for CSR access instructions.
 Info.setRequiresImmediate(0, 31);
 return true;
+  case 'A':
+// An address that is held in a general-purpose register.
+Info.setAllowsMemory();
+return true;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63072: [clang] Fixing incorrect implicit deduction guides (PR41549)

2019-06-14 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363361: [clang] Fixing incorrect implicit deduction guides 
(PR41549) (authored by Tyker, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63072?vs=203862&id=204721#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63072

Files:
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -2052,6 +2052,12 @@
 
 void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
   SourceLocation Loc) {
+  if (CXXRecordDecl *DefRecord =
+  cast(Template->getTemplatedDecl())->getDefinition()) {
+TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate();
+Template = DescribedTemplate ? DescribedTemplate : Template;
+  }
+
   DeclContext *DC = Template->getDeclContext();
   if (DC->isDependentContext())
 return;
Index: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -489,6 +489,21 @@
 }
 #pragma clang diagnostic pop
 
+namespace PR41549 {
+
+template  struct umm;
+
+template 
+struct umm {
+  umm(H h = 0, P p = 0);
+};
+
+template  struct umm;
+
+umm m(1);
+
+}
+
 #else
 
 // expected-no-diagnostics


Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -2052,6 +2052,12 @@
 
 void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
   SourceLocation Loc) {
+  if (CXXRecordDecl *DefRecord =
+  cast(Template->getTemplatedDecl())->getDefinition()) {
+TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate();
+Template = DescribedTemplate ? DescribedTemplate : Template;
+  }
+
   DeclContext *DC = Template->getDeclContext();
   if (DC->isDependentContext())
 return;
Index: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -489,6 +489,21 @@
 }
 #pragma clang diagnostic pop
 
+namespace PR41549 {
+
+template  struct umm;
+
+template 
+struct umm {
+  umm(H h = 0, P p = 0);
+};
+
+template  struct umm;
+
+umm m(1);
+
+}
+
 #else
 
 // expected-no-diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61790: [C++20] add Basic consteval specifier

2019-06-14 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363362: [C++20] add Basic consteval specifier (authored by 
Tyker, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61790?vs=203725&id=204723#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61790

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/Specifiers.h
  cfe/trunk/include/clang/Basic/TokenKinds.def
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/lib/AST/TextNodeDumper.cpp
  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Parse/ParseTentative.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
  cfe/trunk/test/SemaCXX/cxx2a-compat.cpp
  cfe/trunk/test/SemaCXX/cxx2a-consteval.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp

Index: cfe/trunk/include/clang/AST/DeclBase.h
===
--- cfe/trunk/include/clang/AST/DeclBase.h
+++ cfe/trunk/include/clang/AST/DeclBase.h
@@ -1500,7 +1500,9 @@
 uint64_t IsExplicitlyDefaulted : 1;
 uint64_t HasImplicitReturnZero : 1;
 uint64_t IsLateTemplateParsed : 1;
-uint64_t IsConstexpr : 1;
+
+/// Kind of contexpr specifier as defined by ConstexprSpecKind.
+uint64_t ConstexprKind : 2;
 uint64_t InstantiationIsPending : 1;
 
 /// Indicates if the function uses __try.
@@ -1528,7 +1530,7 @@
   };
 
   /// Number of non-inherited bits in FunctionDeclBitfields.
-  enum { NumFunctionDeclBits = 24 };
+  enum { NumFunctionDeclBits = 25 };
 
   /// Stores the bits used by CXXConstructorDecl. If modified
   /// NumCXXConstructorDeclBits and the accessor
@@ -1545,7 +1547,7 @@
 /// exactly 64 bits and thus the width of NumCtorInitializers
 /// will need to be shrunk if some bit is added to NumDeclContextBitfields,
 /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields.
-uint64_t NumCtorInitializers : 24;
+uint64_t NumCtorInitializers : 23;
 uint64_t IsInheritingConstructor : 1;
 
 /// Whether this constructor has a trail-allocated explicit specifier.
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -1861,7 +1861,7 @@
   FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
-   bool isConstexprSpecified);
+   ConstexprSpecKind ConstexprKind);
 
   using redeclarable_base = Redeclarable;
 
@@ -1891,29 +1891,24 @@
   using redeclarable_base::getMostRecentDecl;
   using redeclarable_base::isFirstDecl;
 
-  static FunctionDecl *Create(ASTContext &C, DeclContext *DC,
-  SourceLocation StartLoc, SourceLocation NLoc,
-  DeclarationName N, QualType T,
-  TypeSourceInfo *TInfo,
-  StorageClass SC,
-  bool isInlineSpecified = false,
-  bool hasWrittenPrototype = true,
-  bool isConstexprSpecified = false) {
+  static FunctionDecl *
+  Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation NLoc, DeclarationName N, QualType T,
+ TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = false,
+ bool hasWrittenPrototype = true,
+ ConstexprSpecKind ConstexprKind = CSK_unspecified) {
 DeclarationNameInfo NameInfo(N, NLoc);
-return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo,
-SC,
+return FunctionDe

[PATCH] D63323: [clangd] Don't maintain a list of c-family extensions in vscode extension.

2019-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

There is no need to maintain this list by ourself, vscode already
provides this feature.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63323

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -72,18 +72,19 @@
 // having a corresponding 'onLanguage:...' activation event in 
package.json.
 // However, VSCode does not have CUDA as a supported language yet, so we
 // cannot add a corresponding activationEvent for CUDA files and clangd 
will
-// *not* load itself automatically on '.cu' files. When any of the files
-// with other extensions are open, clangd will load itself and will also
-// work on '.cu' files.
-const filePattern: string = '**/*.{' +
-['cpp', 'c', 'cc', 'cu', 'cxx', 'c++', 'm', 'mm',
-'h', 'hh', 'hpp', 'hxx', 'inc'].join()
-+ '}';
+// *not* load itself automatically on '.cu' files.
+const cudaFilePattern: string = '**/*.{' +['cu'].join()+ '}';
 const clientOptions: vscodelc.LanguageClientOptions = {
-// Register the server for C/C++ files
-documentSelector: [{ scheme: 'file', pattern: filePattern }],
+// Register the server for c-family and cuda files.
+documentSelector: [
+{ scheme: 'file', language: 'c' },
+{ scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'objective-c'},
+{ scheme: 'file', language: 'objective-cpp'},
+{ scheme: 'file', pattern: cudaFilePattern },
+],
 synchronize: !syncFileEvents ? undefined : {
-fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
+// FIXME: send sync file events when clangd provides implemenatations.
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -72,18 +72,19 @@
 // having a corresponding 'onLanguage:...' activation event in package.json.
 // However, VSCode does not have CUDA as a supported language yet, so we
 // cannot add a corresponding activationEvent for CUDA files and clangd will
-// *not* load itself automatically on '.cu' files. When any of the files
-// with other extensions are open, clangd will load itself and will also
-// work on '.cu' files.
-const filePattern: string = '**/*.{' +
-['cpp', 'c', 'cc', 'cu', 'cxx', 'c++', 'm', 'mm',
-'h', 'hh', 'hpp', 'hxx', 'inc'].join()
-+ '}';
+// *not* load itself automatically on '.cu' files.
+const cudaFilePattern: string = '**/*.{' +['cu'].join()+ '}';
 const clientOptions: vscodelc.LanguageClientOptions = {
-// Register the server for C/C++ files
-documentSelector: [{ scheme: 'file', pattern: filePattern }],
+// Register the server for c-family and cuda files.
+documentSelector: [
+{ scheme: 'file', language: 'c' },
+{ scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'objective-c'},
+{ scheme: 'file', language: 'objective-cpp'},
+{ scheme: 'file', pattern: cudaFilePattern },
+],
 synchronize: !syncFileEvents ? undefined : {
-fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
+// FIXME: send sync file events when clangd provides implemenatations.
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart created this revision.
Blackhart created this object with edit policy "Only User: Blackhart (Thomas 
Manceau)".
Blackhart added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.

This patch will:

- replace all occurrence of the C "memcpy" function by "std::copy".
- reorder its arguments.
- insert the "algorithm" headers if needed.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D63324

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h

Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
@@ -0,0 +1,49 @@
+//===--- ReplaceMemcpyByStdCopy.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_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Replace the C memcpy function by std::copy
+class ReplaceMemcpyByStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options);
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyByStdCopy.cpp - 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
+//
+//===--===//
+
+#include "ReplaceMemcpyByStdCopy.h"
+#include "../utils/OptionsUtils.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyByStdCopy::ReplaceMemcpyByStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
+
+void ReplaceMemcpyByStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyByStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+  // Only register the preprocessor callbacks for C++; the functionality
+  // currently does not provide any benefit to other languages, despite being
+  // benign.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter = llvm::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyByStdCopy::check(cons

Re: [PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Roman Lebedev via cfe-commits
On Fri, Jun 14, 2019 at 12:48 PM Thomas Manceau via Phabricator via
cfe-commits  wrote:
>
> Blackhart created this revision.

> Blackhart created this object with edit policy "Only User: Blackhart (Thomas 
> Manceau)".
You might want to unset that :)

> Blackhart added a project: clang-tools-extra.
> Herald added subscribers: cfe-commits, xazax.hun, mgorny.
> Herald added a project: clang.
>
> This patch will:
>
> - replace all occurrence of the C "memcpy" function by "std::copy".
> - reorder its arguments.
> - insert the "algorithm" headers if needed.
>
>
> Repository:
>   rCTE Clang Tools Extra
>
> https://reviews.llvm.org/D63324
>
> Files:
>   clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
>   clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
>   clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
>   clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63270: [clangd] Add include-mapping for C symbols.

2019-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 204731.
hokein marked 7 inline comments as done.
hokein added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63270

Files:
  clang-tools-extra/clangd/CSymbolMap.inc
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/StdSymbolMap.inc
  clang-tools-extra/clangd/include-mapping/cppreference_parser.py
  clang-tools-extra/clangd/include-mapping/gen_std.py
  clang-tools-extra/clangd/include-mapping/test.py
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -945,7 +945,9 @@
 TEST_F(SymbolCollectorTest, CanonicalSTLHeader) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
-  addSystemHeadersMapping(&Includes);
+  auto Language = LangOptions();
+  Language.CPlusPlus = true;
+  addSystemHeadersMapping(&Includes, Language);
   CollectorOpts.Includes = &Includes;
   runSymbolCollector("namespace std { class string {}; }", /*Main=*/"");
   EXPECT_THAT(Symbols,
Index: clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
===
--- clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
+++ clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
@@ -13,12 +13,24 @@
 namespace clangd {
 namespace {
 
+TEST(CanonicalIncludesTest, CStandardLibrary) {
+  CanonicalIncludes CI;
+  auto Language = LangOptions();
+  Language.C11 = true;
+  addSystemHeadersMapping(&CI, Language);
+  // Usual standard library symbols are mapped correctly.
+  EXPECT_EQ("", CI.mapHeader("path/stdio.h", "printf"));
+}
+
 TEST(CanonicalIncludesTest, CXXStandardLibrary) {
   CanonicalIncludes CI;
-  addSystemHeadersMapping(&CI);
+  auto Language = LangOptions();
+  Language.CPlusPlus = true;
+  addSystemHeadersMapping(&CI, Language);
 
   // Usual standard library symbols are mapped correctly.
   EXPECT_EQ("", CI.mapHeader("path/vector.h", "std::vector"));
+  EXPECT_EQ("", CI.mapHeader("path/stdio.h", "std::printf"));
   // std::move is ambiguous, currently mapped only based on path
   EXPECT_EQ("", CI.mapHeader("libstdc++/bits/move.h", "std::move"));
   EXPECT_EQ("path/utility.h", CI.mapHeader("path/utility.h", "std::move"));
Index: clang-tools-extra/clangd/index/IndexAction.cpp
===
--- clang-tools-extra/clangd/index/IndexAction.cpp
+++ clang-tools-extra/clangd/index/IndexAction.cpp
@@ -126,6 +126,7 @@
   std::unique_ptr
   CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) override {
 CI.getPreprocessor().addCommentHandler(PragmaHandler.get());
+addSystemHeadersMapping(Includes.get(), CI.getLangOpts());
 if (IncludeGraphCallback != nullptr)
   CI.getPreprocessor().addPPCallbacks(
   llvm::make_unique(CI.getSourceManager(), IG));
@@ -194,7 +195,6 @@
 Opts.RefsInHeaders = true;
   }
   auto Includes = llvm::make_unique();
-  addSystemHeadersMapping(Includes.get());
   Opts.Includes = Includes.get();
   return llvm::make_unique(
   std::make_shared(std::move(Opts)), std::move(Includes),
Index: clang-tools-extra/clangd/index/CanonicalIncludes.h
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -84,7 +84,8 @@
 ///   - Compiler extensions, e.g. include/avx512bwintrin.h$ -> 
 /// The mapping is hardcoded and hand-maintained, so it might not cover all
 /// headers.
-void addSystemHeadersMapping(CanonicalIncludes *Includes);
+void addSystemHeadersMapping(CanonicalIncludes *Includes,
+ const LangOptions &Language);
 
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -86,16 +86,25 @@
   return llvm::make_unique(Includes);
 }
 
-void addSystemHeadersMapping(CanonicalIncludes *Includes) {
+void addSystemHeadersMapping(CanonicalIncludes *Includes,
+ const LangOptions &Language) {
   static const std::vector> SymbolMap = {
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
-
-  for (const auto 

[PATCH] D63270: [clangd] Add include-mapping for C symbols.

2019-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/include-mapping/gen_std.py:90
+symbol_index_root = page_root
+parse_pages = [(page_root, "index.html", "")]
+

kadircet wrote:
> maybe we should rather pass some something like "INVALID" as namespace for C 
> symbols?
changed to `None`



Comment at: clang-tools-extra/clangd/include-mapping/gen_std.py:95
 
-  parse_pages =  [
-(cpp_root, "symbol_index.html", "std::"),
-# std sub-namespace symbols have separated pages.
-# We don't index std literal operators (e.g.
-# std::literals::chrono_literals::operator""d), these symbols can't be
-# accessed by std::.
-# FIXME: index std::placeholders symbols, placeholders.html page is
-# different (which contains one entry for _1, _2, ..., _N), we need special
-# handling.
-(symbol_index_root, "chrono.html", "std::chrono::"),
-(symbol_index_root, "filesystem.html", "std::filesystem::"),
-(symbol_index_root, "pmr.html", "std::pmr::"),
-(symbol_index_root, "regex_constants.html", "std::regex_constants::"),
-(symbol_index_root, "this_thread.html", "std::this_thread::"),
-  ]
-
-  symbols = []
-  # Run many workers to process individual symbol pages under the symbol index.
-  # Don't allow workers to capture Ctrl-C.
-  pool = multiprocessing.Pool(
-  initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
-  try:
-for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(GetSymbols(pool, root_dir, page_name, namespace))
-  finally:
-pool.terminate()
-pool.join()
+  symbols = cppreference_parser.GetSymbols(parse_pages)
 

kadircet wrote:
> I believe it is more sensible for this function to take `(args.cppreference, 
> args.language)` and perform the above mentioned logic to generate 
> `parse_pages` from these two internally.
Moving the above logic code to cppreference doesn't simplify the code, I'd 
prefer to keep the `cppreference.py` as simple as possible; and we also use the 
`page_root` after calling this function (line 99).



Comment at: clang-tools-extra/clangd/include-mapping/test.py:1
 #!/usr/bin/env python
 #===- test.py -  -*- python 
-*--===#

kadircet wrote:
> no new tests for c symbol parsing ?
not needed, as we share the same parsing logic and we don't introduce new 
behavior in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63270



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-14 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev created this revision.
anton-afanasyev added reviewers: russell.gallop, lebedev.ri, thakis.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Add `Frontend` time trace entry to `HandleTranslationUnit()` function.
Add test to check all codegen blocks are inside frontend blocks.
Also, change `--time-trace-granularity` option a bit to make sure very small
time blocks are outputed to json-file when using `--time-trace-granularity=0`.

This fixes http://llvm.org/pr41969


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63325

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/Driver/check-time-trace-blocks.cpp
  clang/test/Driver/check-time-trace-blocks.py
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= 
TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-blocks.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import json, sys
+
+events = json.loads(sys.stdin.read())["traceEvents"]
+codegens = filter(lambda x: x["name"] == "CodeGen Function", events)
+frontends = filter(lambda x: x["name"] == "Frontend", events)
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+if not all([any([is_inside(codegen, frontend) for frontend in frontends])
+for codegen in codegens]):
+sys.exit("Not all CodeGen blocks are inside any of Frontend blocks!")
Index: clang/test/Driver/check-time-trace-blocks.cpp
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.cpp
@@ -0,0 +1,7 @@
+// REQUIRES: shell
+// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 -o 
%T/check-time-trace-blocks %s
+// RUN: cat %T/check-time-trace-blocks.json | %python 
%s/check-time-trace-blocks.py
+
+template 
+void foo(T) {}
+void bar() { foo(0); }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -228,6 +229,7 @@
 
 void HandleTranslationUnit(ASTContext &C) override {
   {
+llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
 if (FrontendTimesIsEnabled) {
   LLVMIRGenerationRefCount += 1;


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-blocks.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import json, sys
+
+events = json.loads(sys.stdin.read())["traceEvents"]
+codegens = filter(lambda x: x["name"] == "CodeGen Function", events)
+frontends = filter(lambda x: x["name"] == "Frontend", events)
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+if not all([any([is_inside(codegen, frontend) for frontend in frontends])
+for codegen in codegens]):
+sys.exit("Not all CodeGen blocks are inside any of Frontend blocks!")
Index: clang/test/Driver/check-time-trace-blocks.cpp
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.cpp
@@ -0,0 +1,7 @@
+// REQUIRES: shell
+

[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-14 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev updated this revision to Diff 204738.
anton-afanasyev added a comment.

Small fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/Driver/check-time-trace-blocks.cpp
  clang/test/Driver/check-time-trace-blocks.py
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= 
TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-blocks.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import json, sys
+
+events = json.loads(sys.stdin.read())["traceEvents"]
+codegens = filter(lambda x: x["name"] == "CodeGen Function", events)
+frontends = filter(lambda x: x["name"] == "Frontend", events)
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+if not all([any([is_inside(codegen, frontend) for frontend in frontends])
+for codegen in codegens]):
+sys.exit("Not all CodeGen blocks are inside any of Frontend blocks!")
Index: clang/test/Driver/check-time-trace-blocks.cpp
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.cpp
@@ -0,0 +1,7 @@
+// REQUIRES: shell
+// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 -o 
%T/check-time-trace-blocks %s
+// RUN: cat %T/check-time-trace-blocks.json | %python 
%S/check-time-trace-blocks.py
+
+template 
+void foo(T) {}
+void bar() { foo(0); }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -228,6 +229,7 @@
 
 void HandleTranslationUnit(ASTContext &C) override {
   {
+llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
 if (FrontendTimesIsEnabled) {
   LLVMIRGenerationRefCount += 1;


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-blocks.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import json, sys
+
+events = json.loads(sys.stdin.read())["traceEvents"]
+codegens = filter(lambda x: x["name"] == "CodeGen Function", events)
+frontends = filter(lambda x: x["name"] == "Frontend", events)
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+if not all([any([is_inside(codegen, frontend) for frontend in frontends])
+for codegen in codegens]):
+sys.exit("Not all CodeGen blocks are inside any of Frontend blocks!")
Index: clang/test/Driver/check-time-trace-blocks.cpp
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-blocks.cpp
@@ -0,0 +1,7 @@
+// REQUIRES: shell
+// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 -o %T/check-time-trace-blocks %s
+// RUN: cat %T/check-time-trace-blocks.json | %python %S/check-time-trace-blocks.py
+
+template 
+void foo(T) {}
+void bar() { foo(0); }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/Co

[PATCH] D63270: [clangd] Add include-mapping for C symbols.

2019-06-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/include-mapping/gen_std.py:95
 
-  parse_pages =  [
-(cpp_root, "symbol_index.html", "std::"),
-# std sub-namespace symbols have separated pages.
-# We don't index std literal operators (e.g.
-# std::literals::chrono_literals::operator""d), these symbols can't be
-# accessed by std::.
-# FIXME: index std::placeholders symbols, placeholders.html page is
-# different (which contains one entry for _1, _2, ..., _N), we need special
-# handling.
-(symbol_index_root, "chrono.html", "std::chrono::"),
-(symbol_index_root, "filesystem.html", "std::filesystem::"),
-(symbol_index_root, "pmr.html", "std::pmr::"),
-(symbol_index_root, "regex_constants.html", "std::regex_constants::"),
-(symbol_index_root, "this_thread.html", "std::this_thread::"),
-  ]
-
-  symbols = []
-  # Run many workers to process individual symbol pages under the symbol index.
-  # Don't allow workers to capture Ctrl-C.
-  pool = multiprocessing.Pool(
-  initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
-  try:
-for root_dir, page_name, namespace in parse_pages:
-  symbols.extend(GetSymbols(pool, root_dir, page_name, namespace))
-  finally:
-pool.terminate()
-pool.join()
+  symbols = cppreference_parser.GetSymbols(parse_pages)
 

hokein wrote:
> kadircet wrote:
> > I believe it is more sensible for this function to take 
> > `(args.cppreference, args.language)` and perform the above mentioned logic 
> > to generate `parse_pages` from these two internally.
> Moving the above logic code to cppreference doesn't simplify the code, I'd 
> prefer to keep the `cppreference.py` as simple as possible; and we also use 
> the `page_root` after calling this function (line 99).
i was referring to layering rather than simplicity. as for the accessing 
page_root below, it is to deduce cppreference version, which I believe should 
be handled by cppreference_parser again, but not that important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63270



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


[PATCH] D63323: [clangd] Don't maintain a list of c-family extensions in vscode extension.

2019-06-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

could you also bump the version numbers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63323



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


r363369 - add a missing parenthese in the clang doc

2019-06-14 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Jun 14 04:33:40 2019
New Revision: 363369

URL: http://llvm.org/viewvc/llvm-project?rev=363369&view=rev
Log:
add a missing parenthese in the clang doc

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=363369&r1=363368&r2=363369&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Fri Jun 14 04:33:40 2019
@@ -198,7 +198,7 @@ To bootstrap clang/LLVM with ThinLTO, fo
 
 1. The host compiler_ must be a version of clang that supports ThinLTO.
 #. The host linker_ must support ThinLTO (and in the case of gold, must be
-   `configured with plugins enabled `_.
+   `configured with plugins enabled `_).
 #. Use the following additional `CMake variables
`_
when configuring the bootstrap compiler build:


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


[PATCH] D63299: [Clang] Parse GNU fallthrough attributes

2019-06-14 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added a comment.

isDeclarationStatement() returns true for __attribute__((fallthough)) ;




Comment at: lib/Parse/ParseStmt.cpp:102
   ParsedAttributesWithRange Attrs(AttrFactory);
+  MaybeParseGNUAttributes(Attrs);
   MaybeParseCXX11Attributes(Attrs, nullptr, /*MightBeObjCMessageSend*/ true);

Maybe we check if Tok is kw__attribute and look ahead a few tokens to check if 
attribute name is fallthough in ParseStatementOrDeclarationAfterAttributes.

Now, we always fall into

if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt ||
 (StmtCtx & ParsedStmtContext::AllowDeclarationsInC) !=
 ParsedStmtContext()) &&
isDeclarationStatement()) {
  SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
  DeclGroupPtrTy Decl = ParseDeclaration(DeclaratorContext::BlockContext,
 DeclEnd, Attrs);
  return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D63299



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


[PATCH] D63299: [Clang] Parse GNU fallthrough attributes

2019-06-14 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:102
   ParsedAttributesWithRange Attrs(AttrFactory);
+  MaybeParseGNUAttributes(Attrs);
   MaybeParseCXX11Attributes(Attrs, nullptr, /*MightBeObjCMessageSend*/ true);

xbolva00 wrote:
> Maybe we check if Tok is kw__attribute and look ahead a few tokens to check 
> if attribute name is fallthough in ParseStatementOrDeclarationAfterAttributes.
> 
> Now, we always fall into
> 
> if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt ||
>  (StmtCtx & ParsedStmtContext::AllowDeclarationsInC) !=
>  ParsedStmtContext()) &&
> isDeclarationStatement()) {
>   SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
>   DeclGroupPtrTy Decl = ParseDeclaration(DeclaratorContext::BlockContext,
>  DeclEnd, Attrs);
>   return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
>   }
Then we go to "ParseSimpleDeclaration" -> "ParseDeclarationSpecifier". What is 
quite strange for me, we do not set "Attrs" in ParseSimpleDeclaration from 
DS.getAttributes()..


Repository:
  rC Clang

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

https://reviews.llvm.org/D63299



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


[clang-tools-extra] r363372 - [clangd] Don't maintain a list of c-family extensions in vscode extension.

2019-06-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jun 14 04:56:13 2019
New Revision: 363372

URL: http://llvm.org/viewvc/llvm-project?rev=363372&view=rev
Log:
[clangd] Don't maintain a list of c-family extensions in vscode extension.

Summary:
There is no need to maintain this list by ourself, vscode already
provides this feature.

Reviewers: kadircet

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts?rev=363372&r1=363371&r2=363372&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Fri 
Jun 14 04:56:13 2019
@@ -72,18 +72,19 @@ export function activate(context: vscode
 // having a corresponding 'onLanguage:...' activation event in 
package.json.
 // However, VSCode does not have CUDA as a supported language yet, so we
 // cannot add a corresponding activationEvent for CUDA files and clangd 
will
-// *not* load itself automatically on '.cu' files. When any of the files
-// with other extensions are open, clangd will load itself and will also
-// work on '.cu' files.
-const filePattern: string = '**/*.{' +
-['cpp', 'c', 'cc', 'cu', 'cxx', 'c++', 'm', 'mm',
-'h', 'hh', 'hpp', 'hxx', 'inc'].join()
-+ '}';
+// *not* load itself automatically on '.cu' files.
+const cudaFilePattern: string = '**/*.{' +['cu'].join()+ '}';
 const clientOptions: vscodelc.LanguageClientOptions = {
-// Register the server for C/C++ files
-documentSelector: [{ scheme: 'file', pattern: filePattern }],
+// Register the server for c-family and cuda files.
+documentSelector: [
+{ scheme: 'file', language: 'c' },
+{ scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'objective-c'},
+{ scheme: 'file', language: 'objective-cpp'},
+{ scheme: 'file', pattern: cudaFilePattern },
+],
 synchronize: !syncFileEvents ? undefined : {
-fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
+// FIXME: send sync file events when clangd provides implemenatations.
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output


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


[PATCH] D63323: [clangd] Don't maintain a list of c-family extensions in vscode extension.

2019-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D63323#1543331 , @kadircet wrote:

> could you also bump the version numbers?


We usually bump the version in a separate commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63323



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


[PATCH] D63323: [clangd] Don't maintain a list of c-family extensions in vscode extension.

2019-06-14 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363372: [clangd] Don't maintain a list of c-family 
extensions in vscode extension. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63323?vs=204726&id=204747#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63323

Files:
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -72,18 +72,19 @@
 // having a corresponding 'onLanguage:...' activation event in 
package.json.
 // However, VSCode does not have CUDA as a supported language yet, so we
 // cannot add a corresponding activationEvent for CUDA files and clangd 
will
-// *not* load itself automatically on '.cu' files. When any of the files
-// with other extensions are open, clangd will load itself and will also
-// work on '.cu' files.
-const filePattern: string = '**/*.{' +
-['cpp', 'c', 'cc', 'cu', 'cxx', 'c++', 'm', 'mm',
-'h', 'hh', 'hpp', 'hxx', 'inc'].join()
-+ '}';
+// *not* load itself automatically on '.cu' files.
+const cudaFilePattern: string = '**/*.{' +['cu'].join()+ '}';
 const clientOptions: vscodelc.LanguageClientOptions = {
-// Register the server for C/C++ files
-documentSelector: [{ scheme: 'file', pattern: filePattern }],
+// Register the server for c-family and cuda files.
+documentSelector: [
+{ scheme: 'file', language: 'c' },
+{ scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'objective-c'},
+{ scheme: 'file', language: 'objective-cpp'},
+{ scheme: 'file', pattern: cudaFilePattern },
+],
 synchronize: !syncFileEvents ? undefined : {
-fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
+// FIXME: send sync file events when clangd provides implemenatations.
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
@@ -72,18 +72,19 @@
 // having a corresponding 'onLanguage:...' activation event in package.json.
 // However, VSCode does not have CUDA as a supported language yet, so we
 // cannot add a corresponding activationEvent for CUDA files and clangd will
-// *not* load itself automatically on '.cu' files. When any of the files
-// with other extensions are open, clangd will load itself and will also
-// work on '.cu' files.
-const filePattern: string = '**/*.{' +
-['cpp', 'c', 'cc', 'cu', 'cxx', 'c++', 'm', 'mm',
-'h', 'hh', 'hpp', 'hxx', 'inc'].join()
-+ '}';
+// *not* load itself automatically on '.cu' files.
+const cudaFilePattern: string = '**/*.{' +['cu'].join()+ '}';
 const clientOptions: vscodelc.LanguageClientOptions = {
-// Register the server for C/C++ files
-documentSelector: [{ scheme: 'file', pattern: filePattern }],
+// Register the server for c-family and cuda files.
+documentSelector: [
+{ scheme: 'file', language: 'c' },
+{ scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'objective-c'},
+{ scheme: 'file', language: 'objective-cpp'},
+{ scheme: 'file', pattern: cudaFilePattern },
+],
 synchronize: !syncFileEvents ? undefined : {
-fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
+// FIXME: send sync file events when clangd provides implemenatations.
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv created this revision.
erikjv added reviewers: dlj, cfe-commits.
Herald added a reviewer: EricWF.
Herald added a subscriber: jfb.
Herald added a project: clang.

Dynamic linking against libc++ on Linux was already supported, as is
dynamic and static linking against libstdc++. What was missing is being
able to statically link against libc++. This can be used by applications
that choose to use libc++ instead of libstdc++, but do not (or can not)
require the dynamic libraries of libc++(abi) to be installed.


Repository:
  rC Clang

https://reviews.llvm.org/D63329

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -528,11 +528,14 @@
   if (D.CCCIsCXX() &&
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (ToolChain.ShouldLinkCXXStdlib(Args)) {
-  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+  bool OnlyLibstdcxxStatic = (Args.hasArg(options::OPT_static_libstdcxx) ||
+  Args.hasArg(options::OPT_static_libcxx)) &&
  !Args.hasArg(options::OPT_static);
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bstatic");
   ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
+  if (Args.hasArg(options::OPT_static_libcxx)) // libc++ links against 
libc++abi, so we have to pull that in too.
+CmdArgs.push_back("-lc++abi");
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bdynamic");
 }
@@ -564,6 +567,13 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+  // FIXME: libc++ dynamically links against libpthread, so for static
+  // linking, we need to supply that dependency.
+  if (Args.hasArg(options::OPT_static_libcxx))
+// FIXME: Again, like above, does this really make sense for all GNU
+// toolchains?
+WantPthread = true;
+
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
   if (WantPthread && !isAndroid)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2602,6 +2602,7 @@
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
+def static_libcxx : Flag<["-"], "static-libc++">;
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -528,11 +528,14 @@
   if (D.CCCIsCXX() &&
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (ToolChain.ShouldLinkCXXStdlib(Args)) {
-  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+  bool OnlyLibstdcxxStatic = (Args.hasArg(options::OPT_static_libstdcxx) ||
+  Args.hasArg(options::OPT_static_libcxx)) &&
  !Args.hasArg(options::OPT_static);
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bstatic");
   ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
+  if (Args.hasArg(options::OPT_static_libcxx)) // libc++ links against libc++abi, so we have to pull that in too.
+CmdArgs.push_back("-lc++abi");
   if (OnlyLibstdcxxStatic)
 CmdArgs.push_back("-Bdynamic");
 }
@@ -564,6 +567,13 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+  // FIXME: libc++ dynamically links against libpthread, so for static
+  // linking, we need to supply that dependency.
+  if (Args.hasArg(options::OPT_static_libcxx))
+// FIXME: Again, like above, does this really make sense for all GNU
+// toolchains?
+WantPthread = true;
+
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
   if (WantPthread && !isAndroid)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2602,6 +2602,7 @@
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
+def static_libcxx : Flag<["-"], "static-libc++">;
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ 

[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tests?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63329



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


[PATCH] D63330: [clangd] Add Value field to HoverInfo

2019-06-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Put a symbols value information which is deduced from initializer
expression into HoverInfo struct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63330

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -661,15 +661,16 @@
}},
   // Variable with template type
   {R"cpp(
-  template  class Foo {};
-  Foo [[fo^o]];
+  template  class Foo { public: Foo(int); };
+  Foo [[fo^o]] = Foo(5);
   )cpp",
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = SymbolKind::Variable;
- HI.Definition = "Foo foo";
+ HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
+ HI.Value = "Foo(5)";
}},
   // Implicit template instantiation
   {R"cpp(
@@ -786,6 +787,7 @@
  {std::string("int"), std::string("T"), llvm::None},
  {std::string("bool"), std::string("B"), llvm::None},
  };
+ HI.Value = "&b";
  return HI;
}},
   // Lambda parameter with decltype reference
@@ -850,6 +852,7 @@
  {std::string("int"), std::string("T"), llvm::None},
  {std::string("bool"), std::string("B"), llvm::None},
  };
+ HI.Value = "[&bar](int T, bool B) -> bool {}";
  return HI;
}},
   // Local variable in lambda
@@ -911,6 +914,72 @@
  HI.Name = "MACRO", HI.Kind = SymbolKind::String,
  HI.Definition = "#define MACRO(x, y, z) void foo(x, y, z);";
}},
+
+  // constexprs
+  {R"cpp(
+constexpr int add(int a, int b) { return a + b; }
+int [[b^ar]] = add(1, 2);
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "int bar = add(1, 2)";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "int";
+ HI.NamespaceScope = "";
+ HI.Value = "3";
+   }},
+  {R"cpp(
+int [[b^ar]] = sizeof(char);
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "int bar = sizeof(char)";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "int";
+ HI.NamespaceScope = "";
+ HI.Value = "1";
+   }},
+  {R"cpp(
+template struct Add {
+  static constexpr int result = a + b;
+};
+int [[ba^r]] = Add<1, 2>::result;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "int bar = Add<1, 2>::result";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "int";
+ HI.NamespaceScope = "";
+ HI.Value = "3";
+   }},
+  // FIXME: We should use TypeLoc instead of Decl to extract the concrete
+  // value.
+  {R"cpp(
+template struct Add {
+  static constexpr int result = a + b;
+};
+int bar = Add<1, 2>::[[resu^lt]];
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "result";
+ HI.Definition = "static constexpr int result = a + b";
+ HI.Kind = SymbolKind::Property;
+ HI.Type = "const int";
+ HI.NamespaceScope = "";
+ HI.LocalScope = "Add::";
+   }},
+  {R"cpp(
+const char *[[ba^r]] = "1234";
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "const char *bar = \"1234\"";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "const char *";
+ HI.NamespaceScope = "";
+ HI.Value = "&\"1234\"[0]";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -103,6 +103,8 @@
   llvm::Optional> Parameters;
   /// Set for all templates(function, class, variable).
   llvm::Optional> TemplateParameters;
+  /// Contains the initializer expression or constant folded result.
+  llvm::Optional Value;
 
   /// Produce a user-readable information.
   FormattedString present() const;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -719,6 +719,22 @@
 VD->getType().print(OS, Policy);
   }
 
+  // Fill in value with initializer. Puts evaluated version if possible.
+  if (const auto *Var = dyn_cast

[clang-tools-extra] r363375 - [clangd] Bump vscode-clangd v0.0.14

2019-06-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jun 14 05:11:04 2019
New Revision: 363375

URL: http://llvm.org/viewvc/llvm-project?rev=363375&view=rev
Log:
[clangd] Bump vscode-clangd v0.0.14

CHANGELOG:
- use the vscode-buildin feature to detect language (rather than using
  file extensions), this fixes the extension not working on
  non-standard C++ files (e.g. via files.associations)

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json?rev=363375&r1=363374&r2=363375&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json (original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json Fri Jun 
14 05:11:04 2019
@@ -2,7 +2,7 @@
 "name": "vscode-clangd",
 "displayName": "vscode-clangd",
 "description": "Clang Language Server",
-"version": "0.0.13",
+"version": "0.0.14",
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {


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


r363376 - Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"

2019-06-14 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Jun 14 05:14:58 2019
New Revision: 363376

URL: http://llvm.org/viewvc/llvm-project?rev=363376&view=rev
Log:
Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"

This reverts commit r363242 as it broke some builds with

  make[2]: *** No rule to make target 'ClangOpenCLBuiltinsImpl', needed by
  'tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o'.

Added:
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
  - copied, changed from r363369, cfe/trunk/lib/Sema/OpenCLBuiltins.td
Removed:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
Modified:
cfe/trunk/include/clang/Basic/CMakeLists.txt
cfe/trunk/lib/Sema/CMakeLists.txt
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Fri Jun 14 05:14:58 2019
@@ -41,6 +41,12 @@ clang_tablegen(AttrHasAttributeImpl.inc
   TARGET ClangAttrHasAttributeImpl
   )
 
+clang_tablegen(OpenCLBuiltins.inc
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
+  SOURCE OpenCLBuiltins.td
+  TARGET ClangOpenCLBuiltinsImpl
+  )
+
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
   SOURCE arm_neon.td

Copied: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (from r363369, 
cfe/trunk/lib/Sema/OpenCLBuiltins.td)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?p2=cfe/trunk/include/clang/Basic/OpenCLBuiltins.td&p1=cfe/trunk/lib/Sema/OpenCLBuiltins.td&r1=363369&r2=363376&rev=363376&view=diff
==
(empty)

Modified: cfe/trunk/lib/Sema/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
==
--- cfe/trunk/lib/Sema/CMakeLists.txt (original)
+++ cfe/trunk/lib/Sema/CMakeLists.txt Fri Jun 14 05:14:58 2019
@@ -66,10 +66,3 @@ add_clang_library(clangSema
   clangEdit
   clangLex
   )
-
-clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
-  SOURCE OpenCLBuiltins.td
-  TARGET ClangOpenCLBuiltinsImpl
-  )
-
-set_source_files_properties(SemaLookup.cpp OBJECT_DEPENDS 
ClangOpenCLBuiltinsImpl)

Removed: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=363375&view=auto
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td (removed)
@@ -1,296 +0,0 @@
-//==--- OpenCLBuiltins.td - OpenCL builtin declarations 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file contains TableGen definitions for OpenCL builtin function
-// declarations.  In case of an unresolved function name in OpenCL, Clang will
-// check for a function described in this file when -fdeclare-opencl-builtins
-// is specified.
-//
-//===--===//
-
-//===--===//
-//  Definitions of miscellaneous basic entities.
-//===--===//
-// Versions of OpenCL
-class Version {
-  int Version = _Version;
-}
-def CL10: Version<100>;
-def CL11: Version<110>;
-def CL12: Version<120>;
-def CL20: Version<200>;
-
-// Address spaces
-// Pointer types need to be assigned an address space.
-class AddressSpace {
-  string AddrSpace = _AS;
-}
-def default_as: AddressSpace<"clang::LangAS::Default">;
-def private_as: AddressSpace<"clang::LangAS::opencl_private">;
-def global_as : AddressSpace<"clang::LangAS::opencl_global">;
-def constant_as   : AddressSpace<"clang::LangAS::opencl_constant">;
-def local_as  : AddressSpace<"clang::LangAS::opencl_local">;
-def generic_as: AddressSpace<"clang::LangAS::opencl_generic">;
-
-
-// Qualified Type. Allow to retrieve one ASTContext QualType.
-class QualType {
-  // Name of the field or function in a clang::ASTContext
-  // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
-  string Name = _Name;
-}
-
-// Helper class to store type access qualifiers (volatile, const, ...).
-class Qualifier {
-  string QualName = _QualName;
-}
-
-//===

[PATCH] D63331: [clangd] WIP/RFC: Prototype for semantic highlighting proposal

2019-06-14 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik created this revision.
nik added reviewers: ilya-biryukov, sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
javed.absar, mgorny.
Herald added a project: clang.

TODO: Is the visitor the right approach?
TODO: Add tests
TODO:   Test that only highlightings for main file are returned, but not 
headers.

...as specified at

  https://github.com/microsoft/vscode-languageserver-node/pull/367

See also

  https://github.com/microsoft/vscode-languageserver-node/issues/368

So far, this is an *incomplete* implementation providing highlighting
for identifiers of VarDecl/DeclRefExpr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63331

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/ClangdUnit.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/thirdparty/base64/base64.cpp
  clang-tools-extra/clangd/thirdparty/base64/base64.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -537,8 +537,10 @@
   MockCompilationDatabase CDB(BuildDir, RelPathPrefix);
 
   IgnoreDiagnostics DiagConsumer;
+  HighlightingsConsumer HighlightConsumer;
   MockFSProvider FS;
-  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  ClangdServer Server(CDB, FS, DiagConsumer, HighlightConsumer,
+  ClangdServer::optsForTest());
 
   // Fill the filesystem.
   auto FooCpp = testPath("src/foo.cpp");
@@ -1653,8 +1655,10 @@
 TEST(GoToInclude, All) {
   MockFSProvider FS;
   IgnoreDiagnostics DiagConsumer;
+  HighlightingsConsumer HighlightConsumer;
   MockCompilationDatabase CDB;
-  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  ClangdServer Server(CDB, FS, DiagConsumer, HighlightConsumer,
+  ClangdServer::optsForTest());
 
   auto FooCpp = testPath("foo.cpp");
   const char *SourceContents = R"cpp(
@@ -1728,8 +1732,10 @@
   // good preamble.
   MockFSProvider FS;
   IgnoreDiagnostics DiagConsumer;
+  HighlightingsConsumer HighlightConsumer;
   MockCompilationDatabase CDB;
-  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  ClangdServer Server(CDB, FS, DiagConsumer, HighlightConsumer,
+  ClangdServer::optsForTest());
 
   auto FooCpp = testPath("foo.cpp");
   // The trigger locations must be the same.
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -684,7 +684,9 @@
   } CaptureTUStatus;
   MockFSProvider FS;
   MockCompilationDatabase CDB;
-  ClangdServer Server(CDB, FS, CaptureTUStatus, ClangdServer::optsForTest());
+  HighlightingsConsumer HighlightConsumer;
+  ClangdServer Server(CDB, FS, CaptureTUStatus, HighlightConsumer,
+  ClangdServer::optsForTest());
   Annotations Code("int m^ain () {}");
 
   // We schedule the following tasks in the queue:
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -58,7 +58,8 @@
 class WorkspaceSymbolsTest : public ::testing::Test {
 public:
   WorkspaceSymbolsTest()
-  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {
+  : Server(CDB, FSProvider, DiagConsumer, HighlightConsumer,
+   optsForTests()) {
 // Make sure the test root directory is created.
 FSProvider.Files[testPath("unused")] = "";
 CDB.ExtraClangFlags = {"-xc++"};
@@ -68,6 +69,7 @@
   MockFSProvider FSProvider;
   MockCompilationDatabase CDB;
   IgnoreDiagnostics DiagConsumer;
+  HighlightingsConsumer HighlightConsumer;
   ClangdServer Server;
   int Limit = 0;
 
@@ -321,12 +323,14 @@
 class DocumentSymbolsTest : public ::testing::Test {
 public:
   DocumentSymbolsTest()
-  : Server(CDB, FSProvid

Re: r363376 - Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"

2019-06-14 Thread Nico Weber via cfe-commits
Most builds seem to be happy. Since you're seeing this problem, maybe you
could debug it a bit?

On Fri, Jun 14, 2019 at 8:11 AM Sven van Haastregt via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: svenvh
> Date: Fri Jun 14 05:14:58 2019
> New Revision: 363376
>
> URL: http://llvm.org/viewvc/llvm-project?rev=363376&view=rev
> Log:
> Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"
>
> This reverts commit r363242 as it broke some builds with
>
>   make[2]: *** No rule to make target 'ClangOpenCLBuiltinsImpl', needed by
>   'tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o'.
>
> Added:
> cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
>   - copied, changed from r363369, cfe/trunk/lib/Sema/OpenCLBuiltins.td
> Removed:
> cfe/trunk/lib/Sema/OpenCLBuiltins.td
> Modified:
> cfe/trunk/include/clang/Basic/CMakeLists.txt
> cfe/trunk/lib/Sema/CMakeLists.txt
> cfe/trunk/lib/Sema/SemaLookup.cpp
>
> Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
> +++ cfe/trunk/include/clang/Basic/CMakeLists.txt Fri Jun 14 05:14:58 2019
> @@ -41,6 +41,12 @@ clang_tablegen(AttrHasAttributeImpl.inc
>TARGET ClangAttrHasAttributeImpl
>)
>
> +clang_tablegen(OpenCLBuiltins.inc
> +  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
> +  SOURCE OpenCLBuiltins.td
> +  TARGET ClangOpenCLBuiltinsImpl
> +  )
> +
>  # ARM NEON
>  clang_tablegen(arm_neon.inc -gen-arm-neon-sema
>SOURCE arm_neon.td
>
> Copied: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (from r363369,
> cfe/trunk/lib/Sema/OpenCLBuiltins.td)
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?p2=cfe/trunk/include/clang/Basic/OpenCLBuiltins.td&p1=cfe/trunk/lib/Sema/OpenCLBuiltins.td&r1=363369&r2=363376&rev=363376&view=diff
>
> ==
> (empty)
>
> Modified: cfe/trunk/lib/Sema/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/CMakeLists.txt (original)
> +++ cfe/trunk/lib/Sema/CMakeLists.txt Fri Jun 14 05:14:58 2019
> @@ -66,10 +66,3 @@ add_clang_library(clangSema
>clangEdit
>clangLex
>)
> -
> -clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
> -  SOURCE OpenCLBuiltins.td
> -  TARGET ClangOpenCLBuiltinsImpl
> -  )
> -
> -set_source_files_properties(SemaLookup.cpp OBJECT_DEPENDS
> ClangOpenCLBuiltinsImpl)
>
> Removed: cfe/trunk/lib/Sema/OpenCLBuiltins.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=363375&view=auto
>
> ==
> --- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
> +++ cfe/trunk/lib/Sema/OpenCLBuiltins.td (removed)
> @@ -1,296 +0,0 @@
> -//==--- OpenCLBuiltins.td - OpenCL builtin declarations
> ---===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// Part of the LLVM Project, under the Apache License v2.0 with LLVM
> Exceptions.
> -// See https://llvm.org/LICENSE.txt for license information.
> -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
> -//
>
> -//===--===//
> -//
> -// This file contains TableGen definitions for OpenCL builtin function
> -// declarations.  In case of an unresolved function name in OpenCL, Clang
> will
> -// check for a function described in this file when
> -fdeclare-opencl-builtins
> -// is specified.
> -//
>
> -//===--===//
> -
>
> -//===--===//
> -//  Definitions of miscellaneous basic entities.
>
> -//===--===//
> -// Versions of OpenCL
> -class Version {
> -  int Version = _Version;
> -}
> -def CL10: Version<100>;
> -def CL11: Version<110>;
> -def CL12: Version<120>;
> -def CL20: Version<200>;
> -
> -// Address spaces
> -// Pointer types need to be assigned an address space.
> -class AddressSpace {
> -  string AddrSpace = _AS;
> -}
> -def default_as: AddressSpace<"clang::LangAS::Default">;
> -def private_as: AddressSpace<"clang::LangAS::opencl_private">;
> -def global_as : AddressSpace<"clang::LangAS::opencl_global">;
> -def constant_as   : AddressSpace<"clang::LangAS::opencl_constant">;
> -def local_as  : AddressSpace<"clang::LangAS::opencl_local">;
> -def generic_as: Add

[PATCH] D63331: [clangd] WIP/RFC: Prototype for semantic highlighting proposal

2019-06-14 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Any interest in having the *proposal* implemented?

While there is a client implementation available in the theia ide 
(https://github.com/theia-ide/theia/pull/2332), I have only tested this against 
Qt Creator's client implementation (also work in progress).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63331



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


Re: r363376 - Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"

2019-06-14 Thread Nico Weber via cfe-commits
Nevermind, just saw the discussion on phab. Reverting while debugging is of
course fine.

On Fri, Jun 14, 2019 at 8:26 AM Nico Weber  wrote:

> Most builds seem to be happy. Since you're seeing this problem, maybe you
> could debug it a bit?
>
> On Fri, Jun 14, 2019 at 8:11 AM Sven van Haastregt via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: svenvh
>> Date: Fri Jun 14 05:14:58 2019
>> New Revision: 363376
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=363376&view=rev
>> Log:
>> Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"
>>
>> This reverts commit r363242 as it broke some builds with
>>
>>   make[2]: *** No rule to make target 'ClangOpenCLBuiltinsImpl', needed by
>>   'tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o'.
>>
>> Added:
>> cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
>>   - copied, changed from r363369, cfe/trunk/lib/Sema/OpenCLBuiltins.td
>> Removed:
>> cfe/trunk/lib/Sema/OpenCLBuiltins.td
>> Modified:
>> cfe/trunk/include/clang/Basic/CMakeLists.txt
>> cfe/trunk/lib/Sema/CMakeLists.txt
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
>> +++ cfe/trunk/include/clang/Basic/CMakeLists.txt Fri Jun 14 05:14:58 2019
>> @@ -41,6 +41,12 @@ clang_tablegen(AttrHasAttributeImpl.inc
>>TARGET ClangAttrHasAttributeImpl
>>)
>>
>> +clang_tablegen(OpenCLBuiltins.inc
>> +  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
>> +  SOURCE OpenCLBuiltins.td
>> +  TARGET ClangOpenCLBuiltinsImpl
>> +  )
>> +
>>  # ARM NEON
>>  clang_tablegen(arm_neon.inc -gen-arm-neon-sema
>>SOURCE arm_neon.td
>>
>> Copied: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (from r363369,
>> cfe/trunk/lib/Sema/OpenCLBuiltins.td)
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?p2=cfe/trunk/include/clang/Basic/OpenCLBuiltins.td&p1=cfe/trunk/lib/Sema/OpenCLBuiltins.td&r1=363369&r2=363376&rev=363376&view=diff
>>
>> ==
>> (empty)
>>
>> Modified: cfe/trunk/lib/Sema/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/CMakeLists.txt (original)
>> +++ cfe/trunk/lib/Sema/CMakeLists.txt Fri Jun 14 05:14:58 2019
>> @@ -66,10 +66,3 @@ add_clang_library(clangSema
>>clangEdit
>>clangLex
>>)
>> -
>> -clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
>> -  SOURCE OpenCLBuiltins.td
>> -  TARGET ClangOpenCLBuiltinsImpl
>> -  )
>> -
>> -set_source_files_properties(SemaLookup.cpp OBJECT_DEPENDS
>> ClangOpenCLBuiltinsImpl)
>>
>> Removed: cfe/trunk/lib/Sema/OpenCLBuiltins.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=363375&view=auto
>>
>> ==
>> --- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
>> +++ cfe/trunk/lib/Sema/OpenCLBuiltins.td (removed)
>> @@ -1,296 +0,0 @@
>> -//==--- OpenCLBuiltins.td - OpenCL builtin declarations
>> ---===//
>> -//
>> -// The LLVM Compiler Infrastructure
>> -//
>> -// Part of the LLVM Project, under the Apache License v2.0 with LLVM
>> Exceptions.
>> -// See https://llvm.org/LICENSE.txt for license information.
>> -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
>> -//
>>
>> -//===--===//
>> -//
>> -// This file contains TableGen definitions for OpenCL builtin function
>> -// declarations.  In case of an unresolved function name in OpenCL,
>> Clang will
>> -// check for a function described in this file when
>> -fdeclare-opencl-builtins
>> -// is specified.
>> -//
>>
>> -//===--===//
>> -
>>
>> -//===--===//
>> -//  Definitions of miscellaneous basic entities.
>>
>> -//===--===//
>> -// Versions of OpenCL
>> -class Version {
>> -  int Version = _Version;
>> -}
>> -def CL10: Version<100>;
>> -def CL11: Version<110>;
>> -def CL12: Version<120>;
>> -def CL20: Version<200>;
>> -
>> -// Address spaces
>> -// Pointer types need to be assigned an address space.
>> -class AddressSpace {
>> -  string AddrSpace = _AS;
>> -}
>> -def default_as: AddressSpace<"clang::LangAS::Default">;
>> -def private_as: Addre

[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D62739#1536390 , @yaxunl wrote:

> My concern is that this essentially forcing user to add 
> amdgpu_flat_work_group_size attribute to all kernels that are executed 
> outside of (128,256). Potentially this can cause lots of regressions for 
> existing OpenCL apps. I am not sure if it is feasible to force all OpenCL 
> apps to make this change. Should we do some tests before making this change?


This is already the case. This is just moving it to the frontend. There's no 
user observable change from this patch


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

https://reviews.llvm.org/D62739



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


[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D62739#1536428 , @b-sumner wrote:

> We need to communicate with anyone generating IR to ensure this is being 
> generated before we change the default.  clang is only one of those 
> generators.  This change will also need to be documented in the usage 
> document.


The planned change is to make the backend more conservative, so it shouldn't 
break other frontends


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

https://reviews.llvm.org/D62739



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


r363379 - Revert r363298 "[lit] Disable test on darwin when building shared libs."

2019-06-14 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jun 14 05:58:17 2019
New Revision: 363379

URL: http://llvm.org/viewvc/llvm-project?rev=363379&view=rev
Log:
Revert r363298 "[lit] Disable test on darwin when building shared libs."

It broke running check-lld on mac, see https://reviews.llvm.org/D61697

Modified:
cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp

Modified: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=363379&r1=363378&r2=363379&view=diff
==
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(original)
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp Fri 
Jun 14 05:58:17 2019
@@ -16,7 +16,5 @@
 //
 // ^ -ccc-install-dir passed to unbreak tests on *BSD where
 //   getMainExecutable() relies on real argv[0] being passed
-//
-// UNSUPPORTED: enable_shared
 #include 
 vector v;


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


[PATCH] D63331: [clangd] WIP/RFC: Prototype for semantic highlighting proposal

2019-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added subscribers: jvikstrom, nridge, hokein.
hokein added a comment.

Yeah, we definitely have interest in this feature, and our intern @jvikstrom 
will work on this feature this summer.

You probably missed the discussion 
 on clangd-dev 
mailing list, @nridge also has an unfinished prototype 
 for semantic highlighting.

To avoid multiple people working on the same feature, I think the plan is that 
@jvikstrom will pick up the current stuff, and continue working/improving it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63331



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


[PATCH] D61697: [lit] Disable test on darwin when building shared libs.

2019-06-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I reverted this in r363379 to unbreak check-lld on mac. I think the

  if config.enable_shared:
 features.add("enable_shared")

bit belongs in clang/test/lit.cfg.py, not in llvm/utils/lit/lit/llvm/config.py.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61697



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-14 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I looked at bug path with the Optional. I did not debug into the analyzer but 
my intuition is the following: `DefChainEnd` is interesting. `TerminatedPaths` 
is the control dependency of `DefChainEnd`. And there are probably other things 
that are the control and/or value dependency of `TerminatedPaths` . One trick 
we could try is to limit the number of dependencies we track. For example, we 
could try what happens if we only track the immediate control dependencies of 
the original interesting region/symbol and does not add more control dependency 
recursively.

In case we find limiting the number of dependencies useful, I could imagine a 
user-facing flag like `report-verbosity`. The default one could include only 
the notes we find useful after limiting the tracking. A detailed option could 
add all the notes from the transitive tracking of dependencies. A verbose 
option could remove path pruning as well. This is just random brainstorming :) 
First, we need to so whether non-transitive tracking it is actually improving 
the situation.

I am not sure about assuming `operator bool` being correct. I think we first 
could think about other tricks to limit the tracking (see my idea above) and if 
we fail I would only add such rules as a last resort.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:157
+  /// Conditions we're already tracking.
+  llvm::SmallPtrSet TrackedConditions;
+

Do we need this? I wonder if marking the result of the condition as interesting 
is sufficient.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1850
+
+return const_cast(Node->getLocationContext()
+->getAnalysisDeclContext()->getCFGStmtMap()->getBlock(S));

Why do we need a ptr to non-const CFGBlock?



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1895
+
+  if (ControlDepTree.isControlDependency(OriginB, NB))
+if (const Expr *Condition = getTerminatorCondition(NB))

Maybe this is the worng place to comment, but `isControlDependency` sounds a 
bit weird. How about `isControlDependenent`?


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

https://reviews.llvm.org/D62883



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


[PATCH] D63164: [HIP] Add option to force lambda nameing following ODR in HIP/CUDA.

2019-06-14 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

PING


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63164



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


[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D62739#1543437 , @arsenm wrote:

> In D62739#1536390 , @yaxunl wrote:
>
> > My concern is that this essentially forcing user to add 
> > amdgpu_flat_work_group_size attribute to all kernels that are executed 
> > outside of (128,256). Potentially this can cause lots of regressions for 
> > existing OpenCL apps. I am not sure if it is feasible to force all OpenCL 
> > apps to make this change. Should we do some tests before making this change?
>
>
> This is already the case. This is just moving it to the frontend. There's no 
> user observable change from this patch


I do want to reduce the minimum bound to 1 at least (which is the default for 
graphics shaders), but that's a separate change


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

https://reviews.llvm.org/D62739



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart updated this revision to Diff 204757.

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

https://reviews.llvm.org/D63324

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h

Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
@@ -0,0 +1,49 @@
+//===--- ReplaceMemcpyByStdCopy.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_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Replace the C memcpy function by std::copy
+class ReplaceMemcpyByStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options);
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyByStdCopy.cpp - 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
+//
+//===--===//
+
+#include "ReplaceMemcpyByStdCopy.h"
+#include "../utils/OptionsUtils.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyByStdCopy::ReplaceMemcpyByStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
+
+void ReplaceMemcpyByStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyByStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+  // Only register the preprocessor callbacks for C++; the functionality
+  // currently does not provide any benefit to other languages, despite being
+  // benign.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter = llvm::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyByStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  auto Diag = diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHeader(Diag, MemcpyNode, Resu

[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Missing tests.




Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:120
+} // namespace clang
\ No newline at end of file


please add all the missing newlines



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h:1-2
+//===--- ReplaceMemcpyByStdCopy.h - clang-tidy--*- C++
+//-*-===//
+//

should be something like
```
//===--- ReplaceMemcpyByStdCopy.h - clang-tidy -*- C++-*-===//
```


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

https://reviews.llvm.org/D63324



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


r363390 - AMDGPU: Use AMDGPU toolchain for other OSes

2019-06-14 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jun 14 06:39:57 2019
New Revision: 363390

URL: http://llvm.org/viewvc/llvm-project?rev=363390&view=rev
Log:
AMDGPU: Use AMDGPU toolchain for other OSes

This would need more work to actually support them, but this is less
wrong than the default.

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=363390&r1=363389&r2=363390&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jun 14 06:39:57 2019
@@ -4617,6 +4617,8 @@ const ToolChain &Driver::getToolChain(co
   TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::AMDHSA:
+case llvm::Triple::AMDPAL:
+case llvm::Triple::Mesa3D:
   TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::Win32:

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=363390&r1=363389&r2=363390&view=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Jun 14 06:39:57 2019
@@ -1,6 +1,11 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
+// RUN: %clang -### -g -target amdgcn--amdhsa -mcpu=kaveri %s 2>&1 | FileCheck 
-check-prefix=DWARF_VER %s
+// RUN: %clang -### -target amdgcn-amd-amdpal -x assembler -mcpu=kaveri %s 
2>&1 | FileCheck -check-prefix=AS_LINK %s
+// RUN: %clang -### -g -target amdgcn-amd-amdpal -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=DWARF_VER %s
+// RUN: %clang -### -target amdgcn-mesa-mesa3d -x assembler -mcpu=kaveri %s 
2>&1 | FileCheck -check-prefix=AS_LINK %s
+// RUN: %clang -### -g -target amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=DWARF_VER %s
+
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
 
-// RUN: %clang -### -g -target amdgcn--amdhsa -mcpu=kaveri %s 2>&1 | FileCheck 
-check-prefix=DWARF_VER %s
 // DWARF_VER: "-dwarf-version=5"


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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart updated this revision to Diff 204758.
Blackhart added a comment.
Herald added a subscriber: jsji.

Add missing "override" keywords


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

https://reviews.llvm.org/D63324

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
  mypatch.patch

Index: mypatch.patch
===
--- /dev/null
+++ mypatch.patch
@@ -0,0 +1,378 @@
+commit 62ee7f02e1e236f75226337e1057a4e42f72dfb7
+Author: Thomas Manceau 
+Date:   Wed Jun 12 17:51:14 2019 +0200
+
+[clang-tidy] Replace memcpy by std::copy
+
+diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+index 36193f0a6d1..295d1c4a010 100644
+--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
 b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+@@ -1,47 +1,48 @@
+ set(LLVM_LINK_COMPONENTS support)
+ 
+ add_clang_library(clangTidyModernizeModule
+   AvoidBindCheck.cpp
+   AvoidCArraysCheck.cpp
+   ConcatNestedNamespacesCheck.cpp
+   DeprecatedHeadersCheck.cpp
+   DeprecatedIosBaseAliasesCheck.cpp
+   LoopConvertCheck.cpp
+   LoopConvertUtils.cpp
+   MakeSharedCheck.cpp
+   MakeSmartPtrCheck.cpp
+   MakeUniqueCheck.cpp
+   ModernizeTidyModule.cpp
+   PassByValueCheck.cpp
+   RawStringLiteralCheck.cpp
+   RedundantVoidArgCheck.cpp
+   ReplaceAutoPtrCheck.cpp
++  ReplaceMemcpyByStdCopy.cpp
+   ReplaceRandomShuffleCheck.cpp
+   ReturnBracedInitListCheck.cpp
+   ShrinkToFitCheck.cpp
+   UnaryStaticAssertCheck.cpp
+   UseAutoCheck.cpp
+   UseBoolLiteralsCheck.cpp
+   UseDefaultMemberInitCheck.cpp
+   UseEmplaceCheck.cpp
+   UseEqualsDefaultCheck.cpp
+   UseEqualsDeleteCheck.cpp
+   UseNodiscardCheck.cpp
+   UseNoexceptCheck.cpp
+   UseNullptrCheck.cpp
+   UseOverrideCheck.cpp
+   UseTrailingReturnTypeCheck.cpp
+   UseTransparentFunctorsCheck.cpp
+   UseUncaughtExceptionsCheck.cpp
+   UseUsingCheck.cpp
+ 
+   LINK_LIBS
+   clangAST
+   clangASTMatchers
+   clangBasic
+   clangLex
+   clangTidy
+   clangTidyReadabilityModule
+   clangTidyUtils
+   clangTooling
+   )
+diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+index 6280f9c991e..d665c1c5169 100644
+--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
 b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+@@ -1,129 +1,132 @@
+ //===--- ModernizeTidyModule.cpp - clang-tidy -===//
+ //
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ // See https://llvm.org/LICENSE.txt for license information.
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ //
+ //===--===//
+ 
+ #include "../ClangTidy.h"
+ #include "../ClangTidyModule.h"
+ #include "../ClangTidyModuleRegistry.h"
+ #include "AvoidBindCheck.h"
+ #include "AvoidCArraysCheck.h"
+ #include "ConcatNestedNamespacesCheck.h"
+ #include "DeprecatedHeadersCheck.h"
+ #include "DeprecatedIosBaseAliasesCheck.h"
+ #include "LoopConvertCheck.h"
+ #include "MakeSharedCheck.h"
+ #include "MakeUniqueCheck.h"
+ #include "PassByValueCheck.h"
+ #include "RawStringLiteralCheck.h"
+ #include "RedundantVoidArgCheck.h"
+ #include "ReplaceAutoPtrCheck.h"
++#include "ReplaceMemcpyByStdCopy.h"
+ #include "ReplaceRandomShuffleCheck.h"
+ #include "ReturnBracedInitListCheck.h"
+ #include "ShrinkToFitCheck.h"
+ #include "UnaryStaticAssertCheck.h"
+ #include "UseAutoCheck.h"
+ #include "UseBoolLiteralsCheck.h"
+ #include "UseDefaultMemberInitCheck.h"
+ #include "UseEmplaceCheck.h"
+ #include "UseEqualsDefaultCheck.h"
+ #include "UseEqualsDeleteCheck.h"
+ #include "UseNodiscardCheck.h"
+ #include "UseNoexceptCheck.h"
+ #include "UseNullptrCheck.h"
+ #include "UseOverrideCheck.h"
+ #include "UseTrailingReturnTypeCheck.h"
+ #include "UseTransparentFunctorsCheck.h"
+ #include "UseUncaughtExceptionsCheck.h"
+ #include "UseUsingCheck.h"
+ 
+ using namespace clang::ast_matchers;
+ 
+ namespace clang {
+ namespace tidy {
+ namespace modernize {
+ 
+ class ModernizeModule : public ClangTidyModule {
+ public:
+   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+ CheckFactories.registerCheck("modernize-avoid-bind");
+ CheckFactories.registerCheck("modernize-avoid-c-arrays");
+ CheckFactories.registerCheck(
+ "modernize-concat-nested-namespaces");
+ CheckFactories.registerCheck(
+ "modernize-deprecated-headers");
+ CheckFactories.registerCheck(
+ "modernize-deprecated-ios-base-aliases");
+ CheckFactories.registerCheck("modernize-loop-convert");
+ CheckFactories.reg

[PATCH] D62696: AMDGPU: Use AMDGPU toolchain for other OSes

2019-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r363390


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

https://reviews.llvm.org/D62696



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart updated this revision to Diff 204759.
Blackhart added a comment.

Fix file comments typo


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

https://reviews.llvm.org/D63324

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h

Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
@@ -0,0 +1,48 @@
+//===--- ReplaceMemcpyByStdCopy.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_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Replace the C memcpy function by std::copy
+class ReplaceMemcpyByStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
@@ -0,0 +1,118 @@
+//===--- ReplaceMemcpyByStdCopy.cpp - 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
+//
+//===--===//
+
+#include "ReplaceMemcpyByStdCopy.h"
+#include "../utils/OptionsUtils.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyByStdCopy::ReplaceMemcpyByStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
+
+void ReplaceMemcpyByStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyByStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+  // Only register the preprocessor callbacks for C++; the functionality
+  // currently does not provide any benefit to other languages, despite being
+  // benign.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter = llvm::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyByStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  auto Diag = diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHead

[PATCH] D63329: Allow static linking of libc++ on Linux, just like -static-libstdc++

2019-06-14 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

In D63329#1543407 , @lebedev.ri wrote:

> Tests?


I can add a test, but I'd first like to know if this would be accepted. Test 
would be along the lines of "test/Driver/fuchsia.cpp" line 36, where it tests 
"-static-libstdc++".


Repository:
  rC Clang

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

https://reviews.llvm.org/D63329



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


[PATCH] D59673: [Clang] Harmonize Split DWARF options with llc

2019-06-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

lgtm for the LTO bits. Suggestion below for comment.




Comment at: llvm/include/llvm/LTO/Config.h:92
+  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
+  /// attribute in the skeleton CU.
+  std::string SplitDwarfFile;

Probably needs a comment similar to the one below about being for running 
individual backends directly. Otherwise (for in process ThinLTO) we use the 
DwoDir.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59673



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


[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 204763.
gtbercea added a comment.

- Fix function name.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_enter_data_depend_codegen.cpp
  test/OpenMP/target_exit_data_depend_codegen.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_update_depend_codegen.cpp

Index: test/OpenMP/target_update_depend_codegen.cpp
===
--- test/OpenMP/target_update_depend_codegen.cpp
+++ test/OpenMP/target_update_depend_codegen.cpp
@@ -63,7 +63,7 @@
   // CK1: [[CAP_DEVICE:%.+]] = getelementptr inbounds %struct.anon, %struct.anon* [[CAPTURES:%.+]], i32 0, i32 0
   // CK1: [[DEVICE:%.+]] = load i32, i32* %{{.+}}
   // CK1: store i32 [[DEVICE]], i32* [[CAP_DEVICE]],
-  // CK1: [[RES:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i[[sz]] [[sz]], i[[sz]] 4, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* [[TASK_ENTRY0:@.+]] to i32 (i32, i8*)*))
+  // CK1: [[RES:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i[[sz]] [[sz]], i[[sz]] 4, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* [[TASK_ENTRY0:@.+]] to i32 (i32, i8*)*), i64
   // CK1: [[BC:%.+]] = bitcast i8* [[RES]] to %struct.kmp_task_t_with_privates*
   // CK1: [[TASK_T:%.+]] = getelementptr inbounds %struct.kmp_task_t_with_privates, %struct.kmp_task_t_with_privates* [[BC]], i32 0, i32 0
   // CK1: [[SHAREDS:%.+]] = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* [[TASK_T]], i32 0, i32 0
Index: test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
@@ -133,7 +133,7 @@
   // CHECK:   [[DEV:%.+]] = load i32, i32* [[DEVICE_CAP]],
   // CHECK:   store i32 [[DEV]], i32* [[GEP]],
 
-  // CHECK:   [[TASK:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* [[ID]], i32 [[GTID]], i32 1, i[[SZ]] {{104|52}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* [[TASK_ENTRY1_:@.+]] to i32 (i32, i8*)*))
+  // CHECK:   [[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* [[ID]], i32 [[GTID]], i32 1, i[[SZ]] {{104|52}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* [[TASK_ENTRY1_:@.+]] to i32 (i32, i8*)*), i64
   // CHECK:   [[BC_TASK:%.+]] = bitcast i8* [[TASK]] to [[TASK_TY1_:%.+]]*
   // CHECK:   getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* %{{.+}}, i[[SZ]] 0, i[[SZ]] 0
   // CHECK:   getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* %{{.+}}, i[[SZ]] 0, i[[SZ]] 1
@@ -149,7 +149,7 @@
   // CHECK:   [[DEV:%.+]] = load i32, i32* [[DEVICE_CAP]],
   // CHECK:   store i32 [[DEV]], i32* [[GEP]],
 
-  // CHECK:   [[TASK:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* [[ID]], i32 [[GTID]], i32 1, i[[SZ]] {{56|28}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* [[TASK_ENTRY1__:@.+]] to i32 (i32, i8*)*))
+  // CHECK:   [[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* [[ID]], i32 [[GTID]], i32 1, i[[SZ]] {{56|28}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* [[TASK_ENTRY1__:@.+]] to i32 (i32, i8*)*), i64
   // CHECK:   [[BC_TASK:%.+]] = bitcast i8* [[TASK]] to [[TASK_TY1__:%.+]]*
   // CHECK:   getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* %{{.+}}, i[[SZ]] 0, i[[SZ]] 0
   // CHECK:   getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* %{{.+}}, i[[SZ]] 0, i[[SZ]] 1
Index: test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
@@ -133,7 +133,7 @@
   // CHECK:   [[DEV:%.+]] = load i32, i32* [[DEVICE_CAP]],
   // CHECK:   store i32 [[DEV]], i32* [[GEP]],
 
-  // CHECK:   [[TASK:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* [[ID]], i32 [

[PATCH] D41217: [Concepts] Concept Specialization Expressions

2019-06-14 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 204764.
saar.raz added a comment.

Add support for CSE mangling


Repository:
  rC Clang

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

https://reviews.llvm.org/D41217

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/CMakeLists.txt
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/CodeGenCXX/mangle-concept.cpp
  test/Parser/cxx2a-concept-declaration.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -256,6 +256,7 @@
   case Stmt::BinaryConditionalOperatorClass:
   case Stmt::TypeTraitExprClass:
   case Stmt::CoawaitExprClass:
+  case Stmt::ConceptSpecializationExprClass:
   case Stmt::DependentCoawaitExprClass:
   case Stmt::CoyieldExprClass:
   case Stmt::CXXBindTemporaryExprClass:
Index: test/Parser/cxx2a-concept-declaration.cpp
===
--- test/Parser/cxx2a-concept-declaration.cpp
+++ test/Parser/cxx2a-concept-declaration.cpp
@@ -14,8 +14,6 @@
 // expected-error@-2{{template template parameter requires 'class' after the parameter list}}
 // expected-error@-3{{concept template parameter list must have at least one parameter; explicit specialization of concepts is not allowed}}
 
-template concept C2 = 0.f; // expected-error {{constraint expression must be of type 'bool' but is of type 'float'}}
-
 struct S1 {
   template concept C1 = true; // expected-error {{concept declarations may only appear in global or namespace scope}}
 };
@@ -26,15 +24,15 @@
 
 template
 template
-concept C4 = true; // expected-error {{extraneous template parameter list in concept definition}}
+concept C2 = true; // expected-error {{extraneous template parameter list in concept definition}}
 
-template concept C5 = true; // expected-note {{previous}} expected-note {{previous}}
-int C5; // expected-error {{redefinition}}
-struct C5 {}; // expected-error {{redefinition}}
+template concept C3 = true; // expected-note {{previous}} expected-note {{previous}}
+int C3; // expected-error {{redefinition}}
+struct C3 {}; // expected-error {{redefinition}}
 
-struct C6 {}; // expected-note{{previous definition is here}}
-template concept C6 = true;
-// expected-error@-1{{redefinition of 'C6' as different kind of symbol}}
+struct C4 {}; // expected-note{{previous definition is here}}
+template concept C4 = true;
+// expected-error@-1{{redefinition of 'C4' as different kind of symbol}}
 
 // TODO: Add test to prevent explicit specialization, partial specialization
 // and explicit instantiation of concepts.
@@ -43,31 +41,55 @@
 struct integral_constant { static constexpr T value = v; };
 
 namespace N {
-  template concept C7 = true;
+  template concept C5 = true;
 }
-using N::C7;
+using N::C5;
 
-template  concept C8 = integral_constant::value;
+template  concept C6 = integral_constant::value;
 // expected-error@-1{{use of undeclared identifier 'wor'; did you mean 'word'?}}
 // expected-note@-2{{'word' declared here}}
 
-template concept bool C9 = true;
+template concept bool C7 = true;
 // expected-warning@-1{{ISO C++2a does not permit the 'bool' keyword after 'concept'}}
 
-template<> concept C10 = false;
+template<> concept C8 = false;
 // expected-error@-1{{concept template parameter list must have at least one parameter; explicit specialization of concepts is not allowed}}
 
-template<> concept C9 = false;
+template<> concept C7 = false;
 // expected-error@-1{{name defined in concept definition must be an identifier}}
 
-template concept N::C11 = false;
+template concept N::C9 = false;
 // expected-error@-1{{name defined in concept definition must be an identifier}}
 
 class A { };
 // expected-note@-1{{'A' declared here}}
 
-template concept A::C12 = false;
+template concept A::C10 = false;
 // expected-error@-1{{expected namespace name}}
 
 template concept operator int = false;
 // expected-error@-1{{name defined in concept definition must be an identifier}}
+
+template concept C11 = 2; // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
+template concept C12 = 2 && x; // expected-error {{atomic constra

[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

ABataev wrote:
> Can we use the same function in both modes, with nowait clause and without?
For nowait we need to use the target_task_alloc variant. There are runtimes - 
other than the open source one - for which this function does something 
different.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

gtbercea wrote:
> ABataev wrote:
> > Can we use the same function in both modes, with nowait clause and without?
> For nowait we need to use the target_task_alloc variant. There are runtimes - 
> other than the open source one - for which this function does something 
> different.
Trunk relies only to libomptarget interfaces. Why we should take into account 
some other runtime libraries? Plus, what's so different for async and non-async 
versions of the directive?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-06-14 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In D62739#1543438 , @arsenm wrote:

> In D62739#1536428 , @b-sumner wrote:
>
> > We need to communicate with anyone generating IR to ensure this is being 
> > generated before we change the default.  clang is only one of those 
> > generators.  This change will also need to be documented in the usage 
> > document.
>
>
> The planned change is to make the backend more conservative, so it shouldn't 
> break other frontends


It may not break other frontends, but could cause substantial performance 
regressions.  At a minimum the summary should clearly mention this possibility.


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

https://reviews.llvm.org/D62739



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


[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

ABataev wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > Can we use the same function in both modes, with nowait clause and 
> > > without?
> > For nowait we need to use the target_task_alloc variant. There are runtimes 
> > - other than the open source one - for which this function does something 
> > different.
> Trunk relies only to libomptarget interfaces. Why we should take into account 
> some other runtime libraries? Plus, what's so different for async and 
> non-async versions of the directive?
Async is not yet fully supported in the OpenMP open source runtime but at some 
point it will be. This is the first step towards its support. I'm not sure what 
your objection is. The difference is clear. Device ID must be passed on the 
async version of this call.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

gtbercea wrote:
> ABataev wrote:
> > gtbercea wrote:
> > > ABataev wrote:
> > > > Can we use the same function in both modes, with nowait clause and 
> > > > without?
> > > For nowait we need to use the target_task_alloc variant. There are 
> > > runtimes - other than the open source one - for which this function does 
> > > something different.
> > Trunk relies only to libomptarget interfaces. Why we should take into 
> > account some other runtime libraries? Plus, what's so different for async 
> > and non-async versions of the directive?
> Async is not yet fully supported in the OpenMP open source runtime but at 
> some point it will be. This is the first step towards its support. I'm not 
> sure what your objection is. The difference is clear. Device ID must be 
> passed on the async version of this call.
The difference is not obvious. Why we can't use the same function for sync 
directives? The fact the it has DeviceId parameter is not an argument here. 
What's so special from functional point of view?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart updated this revision to Diff 204768.
Blackhart marked 2 inline comments as done.

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

https://reviews.llvm.org/D63324

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h

Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
@@ -0,0 +1,48 @@
+//===--- ReplaceMemcpyByStdCopy.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_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Replace the C memcpy function by std::copy
+class ReplaceMemcpyByStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
@@ -0,0 +1,115 @@
+//===--- ReplaceMemcpyByStdCopy.cpp - 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
+//
+//===--===//
+
+#include "ReplaceMemcpyByStdCopy.h"
+#include "../utils/OptionsUtils.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyByStdCopy::ReplaceMemcpyByStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
+
+void ReplaceMemcpyByStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyByStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter = llvm::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyByStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  auto Diag = diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHeader(Diag, MemcpyNode, Result.SourceManager);
+}
+
+void ReplaceMemcpyByStdCopy::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IncludeStyle",
+util

[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

ABataev wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > gtbercea wrote:
> > > > ABataev wrote:
> > > > > Can we use the same function in both modes, with nowait clause and 
> > > > > without?
> > > > For nowait we need to use the target_task_alloc variant. There are 
> > > > runtimes - other than the open source one - for which this function 
> > > > does something different.
> > > Trunk relies only to libomptarget interfaces. Why we should take into 
> > > account some other runtime libraries? Plus, what's so different for async 
> > > and non-async versions of the directive?
> > Async is not yet fully supported in the OpenMP open source runtime but at 
> > some point it will be. This is the first step towards its support. I'm not 
> > sure what your objection is. The difference is clear. Device ID must be 
> > passed on the async version of this call.
> The difference is not obvious. Why we can't use the same function for sync 
> directives? The fact the it has DeviceId parameter is not an argument here. 
> What's so special from functional point of view?
When you have multiple device on the same system you have to be able to 
distinguish between then and manage dependencies across these different 
devices. Knowing the device is a crucial first step in handling these 
inter-device dependencies.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D59673: [Clang] Harmonize Split DWARF options with llc

2019-06-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: llvm/include/llvm/LTO/Config.h:92
+  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
+  /// attribute in the skeleton CU.
+  std::string SplitDwarfFile;

tejohnson wrote:
> Probably needs a comment similar to the one below about being for running 
> individual backends directly. Otherwise (for in process ThinLTO) we use the 
> DwoDir.
Sure. Any objections to the following wording?

```
  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
  /// attribute in the skeleton CU. This should generally only be used when
  /// running an individual backend directly via thinBackend(), as otherwise
  /// all objects would use the same .dwo file. Not used as output path.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59673



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-14 Thread KristĂłf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I don't understand why the visibility had to be changed (especially without 
explanation), and unless there's a strong reason for it, I strongly disagree 
with it.


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

https://reviews.llvm.org/D62883



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


[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

gtbercea wrote:
> ABataev wrote:
> > gtbercea wrote:
> > > ABataev wrote:
> > > > gtbercea wrote:
> > > > > ABataev wrote:
> > > > > > Can we use the same function in both modes, with nowait clause and 
> > > > > > without?
> > > > > For nowait we need to use the target_task_alloc variant. There are 
> > > > > runtimes - other than the open source one - for which this function 
> > > > > does something different.
> > > > Trunk relies only to libomptarget interfaces. Why we should take into 
> > > > account some other runtime libraries? Plus, what's so different for 
> > > > async and non-async versions of the directive?
> > > Async is not yet fully supported in the OpenMP open source runtime but at 
> > > some point it will be. This is the first step towards its support. I'm 
> > > not sure what your objection is. The difference is clear. Device ID must 
> > > be passed on the async version of this call.
> > The difference is not obvious. Why we can't use the same function for sync 
> > directives? The fact the it has DeviceId parameter is not an argument here. 
> > What's so special from functional point of view?
> When you have multiple device on the same system you have to be able to 
> distinguish between then and manage dependencies across these different 
> devices. Knowing the device is a crucial first step in handling these 
> inter-device dependencies.
Ok, this is why we need it for async version. But why we can't use for sync 
version?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart updated this revision to Diff 204770.
Blackhart added a comment.

Modernize memcpy only if C++20 is enabled


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

https://reviews.llvm.org/D63324

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h

Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h
@@ -0,0 +1,48 @@
+//===--- ReplaceMemcpyByStdCopy.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_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Replace the C memcpy function by std::copy
+class ReplaceMemcpyByStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_BY_STDCOPY_H
Index: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp
@@ -0,0 +1,115 @@
+//===--- ReplaceMemcpyByStdCopy.cpp - 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
+//
+//===--===//
+
+#include "ReplaceMemcpyByStdCopy.h"
+#include "../utils/OptionsUtils.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyByStdCopy::ReplaceMemcpyByStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
+
+void ReplaceMemcpyByStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus2a)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyByStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
+  if (!getLangOpts().CPlusPlus2a)
+return;
+
+  Inserter = llvm::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyByStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  auto Diag = diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHeader(Diag, MemcpyNode, Result.SourceManager);
+}
+
+void ReplaceMemcpyByStdCopy::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "Inclu

[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D63324#1543607 , @Blackhart wrote:

> Modernize memcpy only if C++20 is enabled


... why?
This is also missing documentation,releasenotes changes.


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

https://reviews.llvm.org/D63324



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


[PATCH] D63335: [HIP] Change kernel stub name again

2019-06-14 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: yaxunl, tra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Prefix kernel stub with `__device_stub__` to avoid potential symbol name 
conflicts in debugger.
- Revise the interface to derive the stub name and simplify the assertion of it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63335

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/kernel-stub-name.cu


Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -10,7 +10,7 @@
 __global__ void kernelfunc() {}
 
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
+// CHECK: call void @[[STUB:__device_stub___Z10kernelfuncIiEvv]]()
 void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
 
 // CHECK: define{{.*}}@[[STUB]]
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1088,13 +1088,10 @@
   const auto *ND = cast(GD.getDecl());
   std::string MangledName = getMangledNameImpl(*this, GD, ND);
 
-  // Postfix kernel stub names with .stub to differentiate them from kernel
-  // names in device binaries. This is to facilitate the debugger to find
-  // the correct symbols for kernels in the device binary.
+  // Derive the kernel stub from CUDA runtime.
   if (auto *FD = dyn_cast(GD.getDecl()))
-if (getLangOpts().HIP && !getLangOpts().CUDAIsDevice &&
-FD->hasAttr())
-  MangledName = MangledName + ".stub";
+if (!getLangOpts().CUDAIsDevice && FD->hasAttr())
+  MangledName = getCUDARuntime().getDeviceStubName(MangledName);
 
   auto Result = Manglings.insert(std::make_pair(MangledName, GD));
   return MangledDeclNames[CanonicalGD] = Result.first->first();
Index: clang/lib/CodeGen/CGCUDARuntime.h
===
--- clang/lib/CodeGen/CGCUDARuntime.h
+++ clang/lib/CodeGen/CGCUDARuntime.h
@@ -15,6 +15,8 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
 #define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
 
+#include "llvm/ADT/StringRef.h"
+
 namespace llvm {
 class Function;
 class GlobalVariable;
@@ -63,6 +65,9 @@
   /// Returns a module cleanup function or nullptr if it's not needed.
   /// Must be called after ModuleCtorFunction
   virtual llvm::Function *makeModuleDtorFunction() = 0;
+
+  /// Construct and return the stub name of a kernel.
+  virtual std::string getDeviceStubName(llvm::StringRef Name) const = 0;
 };
 
 /// Creates an instance of a CUDA runtime class.
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -132,6 +132,8 @@
   llvm::Function *makeModuleCtorFunction() override;
   /// Creates module destructor function
   llvm::Function *makeModuleDtorFunction() override;
+  /// Construct and return the stub name of a kernel.
+  std::string getDeviceStubName(llvm::StringRef Name) const override;
 };
 
 }
@@ -217,10 +219,11 @@
 
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF,
  FunctionArgList &Args) {
-  assert(getDeviceSideName(CGF.CurFuncDecl) == CGF.CurFn->getName() ||
- getDeviceSideName(CGF.CurFuncDecl) + ".stub" == CGF.CurFn->getName() 
||
- CGF.CGM.getContext().getTargetInfo().getCXXABI() !=
- CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI());
+  assert((CGF.CGM.getContext().getAuxTargetInfo() &&
+  (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() !=
+   CGF.CGM.getContext().getTargetInfo().getCXXABI())) ||
+ getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) ==
+ CGF.CurFn->getName());
 
   EmittedKernels.push_back({CGF.CurFn, CGF.CurFuncDecl});
   if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
@@ -780,6 +783,12 @@
   return ModuleDtorFunc;
 }
 
+std::string CGNVCUDARuntime::getDeviceStubName(llvm::StringRef Name) const {
+  if (!CGM.getLangOpts().HIP)
+return Name;
+  return std::move(("__device_stub__" + Name).str());
+}
+
 CGCUDARuntime *CodeGen::CreateNVCUDARuntime(CodeGenModule &CGM) {
   return new CGNVCUDARuntime(CGM);
 }


Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -10,7 +10,7 @@
 __global__ void kernelfunc() {}
 
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
+// CHECK: call void @[[STUB:__device_stub___Z10kernelfuncIiEvv]]()
 void hostfunc(void) { kernelfu

[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D62739#1543578 , @b-sumner wrote:

> In D62739#1543438 , @arsenm wrote:
>
> > In D62739#1536428 , @b-sumner 
> > wrote:
> >
> > > We need to communicate with anyone generating IR to ensure this is being 
> > > generated before we change the default.  clang is only one of those 
> > > generators.  This change will also need to be documented in the usage 
> > > document.
> >
> >
> > The planned change is to make the backend more conservative, so it 
> > shouldn't break other frontends
>
>
> It may not break other frontends, but could cause substantial performance 
> regressions.  At a minimum the summary should clearly mention this 
> possibility.


The summary of the future backend patch will


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

https://reviews.llvm.org/D62739



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Thomas Manceau via Phabricator via cfe-commits
Blackhart added a comment.

In D63324#1543609 , @lebedev.ri wrote:

> In D63324#1543607 , @Blackhart wrote:
>
> > Modernize memcpy only if C++20 is enabled
>
>
> ... why?
>  This is also missing documentation,releasenotes changes.


According with the C++ reference, std::copy is only available since C++20.
There is another std::copy signature available since C++17, but it needs an 
extra parameter. I can implement it also.
https://en.cppreference.com/w/cpp/algorithm/copy

I'm working on the unit tests and I'll make documentation/releasenotes after 
that.

Thanks for reviewing @lebedev.ri ;)


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

https://reviews.llvm.org/D63324



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


[PATCH] D63256: [OpenCL] Split type and macro definitions into opencl-c-base.h

2019-06-14 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

LGTM, except for the `IncludeDefaultHeader` and `DeclareOpenCLBuiltins` logic.




Comment at: lib/Frontend/CompilerInvocation.cpp:2194
 }
+// Include base header file for builtin types and constants.
+if (Opts.DeclareOpenCLBuiltins) {

Can we have the following logic instead? Otherwise `DeclareOpenCLBuiltins` 
implies `IncludeDefaultHeader` which is not always the case.

```
if (Opts.IncludeDefaultHeader) {
  if (Opts.DeclareOpenCLBuiltins) {
PPOpts.Includes.push_back("opencl-c-base.h");
  } else {
PPOpts.Includes.push_back("opencl-c.h");
  }
}
```


Repository:
  rC Clang

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

https://reviews.llvm.org/D63256



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


r363414 - [AMDGPU] Enable the implicit arguments for HIP (CLANG)

2019-06-14 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Jun 14 08:54:47 2019
New Revision: 363414

URL: http://llvm.org/viewvc/llvm-project?rev=363414&view=rev
Log:
[AMDGPU] Enable the implicit arguments for HIP (CLANG)

Enable 48-bytes of implicit arguments for HIP as well. Earlier it was enabled 
for OpenCL. This code is specific to AMDGPU target.

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

Added:
cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=363414&r1=363413&r2=363414&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Jun 14 08:54:47 2019
@@ -7868,7 +7868,8 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   const auto *ReqdWGS = M.getLangOpts().OpenCL ?
 FD->getAttr() : nullptr;
 
-  if (M.getLangOpts().OpenCL && FD->hasAttr() &&
+  if (((M.getLangOpts().OpenCL && FD->hasAttr()) ||
+  (M.getLangOpts().HIP && FD->hasAttr())) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
 

Added: cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu?rev=363414&view=auto
==
--- cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu Fri Jun 14 
08:54:47 2019
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip -o - %s | FileCheck %s
+#include "Inputs/cuda.h"
+
+__global__ void hip_kernel_temp() {
+}
+
+// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="48"


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


[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5122
+NewTask = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_omp_target_task_alloc), AllocArgs);
+  } else {

ABataev wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > gtbercea wrote:
> > > > ABataev wrote:
> > > > > gtbercea wrote:
> > > > > > ABataev wrote:
> > > > > > > Can we use the same function in both modes, with nowait clause 
> > > > > > > and without?
> > > > > > For nowait we need to use the target_task_alloc variant. There are 
> > > > > > runtimes - other than the open source one - for which this function 
> > > > > > does something different.
> > > > > Trunk relies only to libomptarget interfaces. Why we should take into 
> > > > > account some other runtime libraries? Plus, what's so different for 
> > > > > async and non-async versions of the directive?
> > > > Async is not yet fully supported in the OpenMP open source runtime but 
> > > > at some point it will be. This is the first step towards its support. 
> > > > I'm not sure what your objection is. The difference is clear. Device ID 
> > > > must be passed on the async version of this call.
> > > The difference is not obvious. Why we can't use the same function for 
> > > sync directives? The fact the it has DeviceId parameter is not an 
> > > argument here. What's so special from functional point of view?
> > When you have multiple device on the same system you have to be able to 
> > distinguish between then and manage dependencies across these different 
> > devices. Knowing the device is a crucial first step in handling these 
> > inter-device dependencies.
> Ok, this is why we need it for async version. But why we can't use for sync 
> version?
Based on how the runtime is currently structured, nowait functions are separate 
from the synchronous ones. See target vs. target_nowait functions and there are 
many examples like that. The async support is always kept separate from the 
synchronous support at least in terms of entry points in the runtime.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63009



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


[PATCH] D62244: [AMDGPU] Enable the implicit arguments for HIP (CLANG)

2019-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363414: [AMDGPU] Enable the implicit arguments for HIP 
(CLANG) (authored by yaxunl, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62244?vs=203975&id=204777#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62244

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7868,7 +7868,8 @@
   const auto *ReqdWGS = M.getLangOpts().OpenCL ?
 FD->getAttr() : nullptr;
 
-  if (M.getLangOpts().OpenCL && FD->hasAttr() &&
+  if (((M.getLangOpts().OpenCL && FD->hasAttr()) ||
+  (M.getLangOpts().HIP && FD->hasAttr())) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
 
Index: cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
===
--- cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
+++ cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip -o - %s | FileCheck %s
+#include "Inputs/cuda.h"
+
+__global__ void hip_kernel_temp() {
+}
+
+// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="48"


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7868,7 +7868,8 @@
   const auto *ReqdWGS = M.getLangOpts().OpenCL ?
 FD->getAttr() : nullptr;
 
-  if (M.getLangOpts().OpenCL && FD->hasAttr() &&
+  if (((M.getLangOpts().OpenCL && FD->hasAttr()) ||
+  (M.getLangOpts().HIP && FD->hasAttr())) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
 
Index: cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
===
--- cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
+++ cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip -o - %s | FileCheck %s
+#include "Inputs/cuda.h"
+
+__global__ void hip_kernel_temp() {
+}
+
+// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="48"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63108: [OpenMP] Add support for handling declare target to clause when unified memory is required

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D63108



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


[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 204780.
gtbercea added a comment.

- Remove virtual.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -26,42 +26,35 @@
 // CHECK: [[VAR:@.+]] = global double 1.00e+01
 // CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
 
-// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
-// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
 
 // CHECK: [[N_CASTED:%.+]] = alloca i64
 // CHECK: [[SUM_CASTED:%.+]] = alloca i64
 
-// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
-// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [2 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [2 x i8*]
 
 // CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
 // CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
 
-// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
 // CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
-// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 // CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
 
-// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
 // CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
-// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
 // CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
 
-// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 2
-// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
-// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
-// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 2
-// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
-// CHECK: store double* [[VAR]], double** [[BCAST6]]
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 
-// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
-
-// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 2, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
 
 #endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -2667,7 +2667,8 @@
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
-  (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
+  (Stack->hasRequiresDeclWithClause() ||
+   !Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
   SourceLocation ELoc = E->getExprLoc();
Index: lib/CodeGen/CGOpenMPRuntime.h

[PATCH] D41569: [Concepts] Constraint enforcement and diagnostics

2019-06-14 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 204782.
saar.raz added a comment.

Add support for CSE mangling


Repository:
  rC Clang

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

https://reviews.llvm.org/D41569

Files:
  include/clang/AST/ExprCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  include/clang/Sema/SemaConcept.h
  include/clang/Sema/TemplateDeduction.h
  lib/AST/ExprCXX.cpp
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  test/CodeGenCXX/mangle-concept.cpp

Index: test/CodeGenCXX/mangle-concept.cpp
===
--- /dev/null
+++ test/CodeGenCXX/mangle-concept.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify -Wno-return-type -Wno-main -std=c++2a -fconcepts-ts -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
+// expected-no-diagnostics
+
+namespace test1 {
+template  struct S {};
+template  concept C = true;
+template  S> f0() { return S>{}; }
+template S> f0<>();
+// CHECK: void @_ZN5test12f0IiEENS_1SIXL_ZNS_1CIT_EEv()
+}
+
+template  struct S {};
+template  concept C = true;
+template  S> f0() { return S>{}; }
+template S> f0<>();
+// CHECK: void @_Z2f0IiE1SIXL_Z1CIT_v()
\ No newline at end of file
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+namespace class_templates
+{
+  template requires sizeof(T) >= 4 // expected-note {{because 'sizeof(char) >= 4' (1 >= 4) evaluated to false}}
+  struct is_same { static constexpr bool value = false; };
+
+  template requires sizeof(T*) >= 4 && sizeof(T) >= 4
+  struct is_same { static constexpr bool value = true; };
+
+  static_assert(!is_same::value);
+  static_assert(!is_same::value);
+  static_assert(is_same::value);
+  static_assert(is_same::value); // expected-error {{constraints not satisfied for class template 'is_same' [with T = char, U = char]}}
+
+  template
+  struct A { using type = typename T::type; }; // expected-error{{type 'int *' cannot be used prior to '::' because it has no members}}
+
+  template
+  struct B {};
+
+  template requires A::type // expected-note{{in instantiation of template class 'class_templates::A' requested here}}
+   // expected-note@-1{{while substituting template arguments into constraint expression here}}
+  struct B {};
+
+  template requires T{} // expected-error{{atomic constraint must be of type 'bool' (found 'int')}}
+  struct B {};
+
+  static_assert((B{}, true)); // expected-note{{while checking constraint satisfaction for class template partial specialization 'B' required here}}
+  // expected-note@-1{{while checking constraint satisfaction for class template partial specialization 'B' required here}}
+  // expected-note@-2{{during template argument deduction for class template partial specialization 'B' [with T = int *]}}
+  // expected-note@-3{{during template argument deduction for class template partial specialization 'B' [with T = int]}}
+  // expected-note@-4 2{{in instantiation of template class 'class_templates::B' requested here}}
+}
+
+namespace variable_templates
+{
+  template requires sizeof(T) >= 4
+  constexpr bool is_same_v = false;
+
+  template requires sizeof(T*) >= 4 && sizeof(T) >= 4
+  constexpr bool is_same_v = true;
+
+  static_assert(!is_same_v);
+  static_assert(!is_same_v);
+  static_assert(is_same_v);
+
+  template
+  struct A { using type = typename T::type; }; // expected-error{{type 'int *' cannot be used prior to '::' because it has no members}}
+
+  template
+  constexpr bool v1 = false;
+
+  template requires A::type // expected-note{{in instantiation of template class 'variable_templates::A' requested here}}
+   // expected-note@-1{{while substituting template arguments into constraint expression here}}
+  constexpr bool v1 = true;
+
+  template requires T{} // expected-error{{atomic constraint must be of type 'bool' (found 'int')}}
+  constexpr bool v1 = true;
+
+  static_assert(v1); // expected-note{{while checking constraint satisfaction for variable template partial specialization 'v1

[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D63324#1543626 , @Blackhart wrote:

> In D63324#1543609 , @lebedev.ri 
> wrote:
>
> > In D63324#1543607 , @Blackhart 
> > wrote:
> >
> > > Modernize memcpy only if C++20 is enabled
> >
> >
> > ... why?
> >  This is also missing documentation,releasenotes changes.
>
>
> According with the C++ reference, std::copy is only available since C++20.


I don't see it there, can you quote?
https://godbolt.org/z/q2ryJi

> There is another std::copy signature available since C++17, but it needs an 
> extra parameter. I can implement it also.
>  https://en.cppreference.com/w/cpp/algorithm/copy
> 
> I'm working on the unit tests and I'll make documentation/releasenotes after 
> that.
> 
> Thanks for reviewing @lebedev.ri ;)




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

https://reviews.llvm.org/D63324



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


r363415 - Reland: [Remarks] Refactor optimization remarks setup

2019-06-14 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Fri Jun 14 09:20:51 2019
New Revision: 363415

URL: http://llvm.org/viewvc/llvm-project?rev=363415&view=rev
Log:
Reland: [Remarks] Refactor optimization remarks setup

* Add a common function to setup opt-remarks
* Rename common options to the same names
* Add error types to distinguish between file errors and regex errors

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=363415&r1=363414&r2=363415&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Jun 14 09:20:51 2019
@@ -262,35 +262,32 @@ namespace clang {
   Ctx.getDiagnosticHandler();
   Ctx.setDiagnosticHandler(llvm::make_unique(
 CodeGenOpts, this));
-  Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
-  if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
-Ctx.setDiagnosticsHotnessThreshold(
-CodeGenOpts.DiagnosticsHotnessThreshold);
 
-  std::unique_ptr OptRecordFile;
-  if (!CodeGenOpts.OptRecordFile.empty()) {
-std::error_code EC;
-OptRecordFile = llvm::make_unique(
-CodeGenOpts.OptRecordFile, EC, sys::fs::F_None);
-if (EC) {
-  Diags.Report(diag::err_cannot_open_file) <<
-CodeGenOpts.OptRecordFile << EC.message();
-  return;
-}
+  Expected> OptRecordFileOrErr =
+  setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
+   CodeGenOpts.OptRecordPasses,
+   CodeGenOpts.DiagnosticsWithHotness,
+   CodeGenOpts.DiagnosticsHotnessThreshold);
 
-Ctx.setRemarkStreamer(llvm::make_unique(
-CodeGenOpts.OptRecordFile,
-llvm::make_unique(OptRecordFile->os(;
-
-if (!CodeGenOpts.OptRecordPasses.empty())
-  if (Error E = Ctx.getRemarkStreamer()->setFilter(
-  CodeGenOpts.OptRecordPasses))
-Diags.Report(diag::err_drv_optimization_remark_pattern)
-<< toString(std::move(E)) << CodeGenOpts.OptRecordPasses;
-
-if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
-  Ctx.setDiagnosticsHotnessRequested(true);
+  if (Error E = OptRecordFileOrErr.takeError()) {
+handleAllErrors(
+std::move(E),
+[&](const RemarkSetupFileError &E) {
+  Diags.Report(diag::err_cannot_open_file)
+  << CodeGenOpts.OptRecordFile << E.message();
+},
+[&](const RemarkSetupPatternError &E) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << E.message() << CodeGenOpts.OptRecordPasses;
+});
+return;
   }
+  std::unique_ptr OptRecordFile =
+  std::move(*OptRecordFileOrErr);
+
+  if (OptRecordFile &&
+  CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+Ctx.setDiagnosticsHotnessRequested(true);
 
   // Link each LinkModule into our module.
   if (LinkInModules())


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


[PATCH] D41217: [Concepts] Concept Specialization Expressions

2019-06-14 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 204784.
saar.raz added a comment.

Delay support for mangling to later patch (where CSEs are formed instead of 
UnresolvedLookupExprs with dependent args)


Repository:
  rC Clang

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

https://reviews.llvm.org/D41217

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/CMakeLists.txt
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx2a-concept-declaration.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -256,6 +256,7 @@
   case Stmt::BinaryConditionalOperatorClass:
   case Stmt::TypeTraitExprClass:
   case Stmt::CoawaitExprClass:
+  case Stmt::ConceptSpecializationExprClass:
   case Stmt::DependentCoawaitExprClass:
   case Stmt::CoyieldExprClass:
   case Stmt::CXXBindTemporaryExprClass:
Index: test/Parser/cxx2a-concept-declaration.cpp
===
--- test/Parser/cxx2a-concept-declaration.cpp
+++ test/Parser/cxx2a-concept-declaration.cpp
@@ -14,8 +14,6 @@
 // expected-error@-2{{template template parameter requires 'class' after the parameter list}}
 // expected-error@-3{{concept template parameter list must have at least one parameter; explicit specialization of concepts is not allowed}}
 
-template concept C2 = 0.f; // expected-error {{constraint expression must be of type 'bool' but is of type 'float'}}
-
 struct S1 {
   template concept C1 = true; // expected-error {{concept declarations may only appear in global or namespace scope}}
 };
@@ -26,15 +24,15 @@
 
 template
 template
-concept C4 = true; // expected-error {{extraneous template parameter list in concept definition}}
+concept C2 = true; // expected-error {{extraneous template parameter list in concept definition}}
 
-template concept C5 = true; // expected-note {{previous}} expected-note {{previous}}
-int C5; // expected-error {{redefinition}}
-struct C5 {}; // expected-error {{redefinition}}
+template concept C3 = true; // expected-note {{previous}} expected-note {{previous}}
+int C3; // expected-error {{redefinition}}
+struct C3 {}; // expected-error {{redefinition}}
 
-struct C6 {}; // expected-note{{previous definition is here}}
-template concept C6 = true;
-// expected-error@-1{{redefinition of 'C6' as different kind of symbol}}
+struct C4 {}; // expected-note{{previous definition is here}}
+template concept C4 = true;
+// expected-error@-1{{redefinition of 'C4' as different kind of symbol}}
 
 // TODO: Add test to prevent explicit specialization, partial specialization
 // and explicit instantiation of concepts.
@@ -43,31 +41,55 @@
 struct integral_constant { static constexpr T value = v; };
 
 namespace N {
-  template concept C7 = true;
+  template concept C5 = true;
 }
-using N::C7;
+using N::C5;
 
-template  concept C8 = integral_constant::value;
+template  concept C6 = integral_constant::value;
 // expected-error@-1{{use of undeclared identifier 'wor'; did you mean 'word'?}}
 // expected-note@-2{{'word' declared here}}
 
-template concept bool C9 = true;
+template concept bool C7 = true;
 // expected-warning@-1{{ISO C++2a does not permit the 'bool' keyword after 'concept'}}
 
-template<> concept C10 = false;
+template<> concept C8 = false;
 // expected-error@-1{{concept template parameter list must have at least one parameter; explicit specialization of concepts is not allowed}}
 
-template<> concept C9 = false;
+template<> concept C7 = false;
 // expected-error@-1{{name defined in concept definition must be an identifier}}
 
-template concept N::C11 = false;
+template concept N::C9 = false;
 // expected-error@-1{{name defined in concept definition must be an identifier}}
 
 class A { };
 // expected-note@-1{{'A' declared here}}
 
-template concept A::C12 = false;
+template concept A::C10 = false;
 // expected-error@-1{{expected namespace name}}
 
 template concept operator int = false;
 // expected-error@-1{{name defined in concept definition must be an identifier}}
+
+template concept C11 = 2; // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
+template co

[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:1628
+  /// Return whether the unified_shared_memory has been specified.
+  bool hasRequiresUnifiedSharedMemory();
 };

You can make this function const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883



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


[PATCH] D63108: [OpenMP] Add support for handling declare target to clause when unified memory is required

2019-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Will review it next week, when I'm back to work, need to think about it a 
little bit.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63108



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


[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 204795.
arsenm added a comment.

Rebase


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

https://reviews.llvm.org/D62739

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/amdgpu-attrs.cl


Index: test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- test/CodeGenOpenCL/amdgpu-attrs.cl
+++ test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -143,6 +143,10 @@
 // CHECK: define void @a_function() [[A_FUNCTION:#[0-9]+]]
 }
 
+kernel void default_kernel() {
+// CHECK: define amdgpu_kernel void @default_kernel() 
[[DEFAULT_KERNEL_ATTRS:#[0-9]+]]
+}
+
 
 // Make sure this is silently accepted on other targets.
 // X86-NOT: "amdgpu-flat-work-group-size"
@@ -161,20 +165,20 @@
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="48"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="48"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="128,256" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="128,256" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="128,256" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="128,256" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64"
 
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32_NUM_VGPR_64]] = { convergent noinline 
nounwind optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-num-vgpr"="64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="128,256" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="128,256" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
"amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group

[PATCH] D61697: [lit] Disable test on darwin when building shared libs.

2019-06-14 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

In D61697#1543443 , @thakis wrote:

> I reverted this in r363379 to unbreak check-lld on mac. I think the
>
>   if config.enable_shared:
>  features.add("enable_shared")
>   
>
> bit belongs in clang/test/lit.cfg.py, not in 
> llvm/utils/lit/lit/llvm/config.py.


Sorry the breakage, and thanks for the suggestion.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61697



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

This might not be currently ideal recommendation since std::copy produces 
memmove with -O3.


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

https://reviews.llvm.org/D63324



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


[PATCH] D63256: [OpenCL] Split type and macro definitions into opencl-c-base.h

2019-06-14 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 204796.
svenvh added a comment.

Change `IncludeDefaultHeader` and `DeclareOpenCLBuiltins` logic as per 
@asavonic's comments.  Also extend 
`test/SemaOpenCL/fdeclare-opencl-builtins.cl` to test the interplay of both 
options.


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

https://reviews.llvm.org/D63256

Files:
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/opencl-c-base.h
  lib/Headers/opencl-c.h
  test/SemaOpenCL/fdeclare-opencl-builtins.cl

Index: test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -1,12 +1,16 @@
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
 
 // Test the -fdeclare-opencl-builtins option.
 
+// Provide typedefs when invoking clang without -finclude-default-header.
+#ifdef NO_HEADER
 typedef float float4 __attribute__((ext_vector_type(4)));
 typedef int int4 __attribute__((ext_vector_type(4)));
 typedef int int2 __attribute__((ext_vector_type(2)));
 typedef unsigned int uint;
 typedef __SIZE_TYPE__ size_t;
+#endif
 
 kernel void basic_conversion(global float4 *buf, global int4 *res) {
   res[0] = convert_int4(buf[0]);
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -9,6 +9,8 @@
 #ifndef _OPENCL_H_
 #define _OPENCL_H_
 
+#include "opencl-c-base.h"
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
@@ -33,255 +35,6 @@
 #define __purefn __attribute__((pure))
 #define __cnfn __attribute__((const))
 
-// built-in scalar data types:
-
-/**
- * An unsigned 8-bit integer.
- */
-typedef unsigned char uchar;
-
-/**
- * An unsigned 16-bit integer.
- */
-typedef unsigned short ushort;
-
-/**
- * An unsigned 32-bit integer.
- */
-typedef unsigned int uint;
-
-/**
- * An unsigned 64-bit integer.
- */
-typedef unsigned long ulong;
-
-/**
- * The unsigned integer type of the result of the sizeof operator. This
- * is a 32-bit unsigned integer if CL_DEVICE_ADDRESS_BITS
- * defined in table 4.3 is 32-bits and is a 64-bit unsigned integer if
- * CL_DEVICE_ADDRESS_BITS is 64-bits.
- */
-typedef __SIZE_TYPE__ size_t;
-
-/**
- * A signed integer type that is the result of subtracting two pointers.
- * This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS
- * defined in table 4.3 is 32-bits and is a 64-bit signed integer if
- * CL_DEVICE_ADDRESS_BITS is 64-bits.
- */
-typedef __PTRDIFF_TYPE__ ptrdiff_t;
-
-/**
-* A signed integer type with the property that any valid pointer to
-* void can be converted to this type, then converted back to pointer
-* to void, and the result will compare equal to the original pointer.
-*/
-typedef __INTPTR_TYPE__ intptr_t;
-
-/**
-* An unsigned integer type with the property that any valid pointer to
-* void can be converted to this type, then converted back to pointer
-* to void, and the result will compare equal to the original pointer.
-*/
-typedef __UINTPTR_TYPE__ uintptr_t;
-
-// built-in vector data types:
-typedef char char2 __attribute__((ext_vector_type(2)));
-typedef char char3 __attribute__((ext_vector_type(3)));
-typedef char char4 __attribute__((ext_vector_type(4)));
-typedef char char8 __attribute__((ext_vector_type(8)));
-typedef char char16 __attribute__((ext_vector_type(16)));
-typedef uchar uchar2 __attribute__((ext_vector_type(2)));
-typedef uchar uchar3 __attribute__((ext_vector_type(3)));
-typedef uchar uchar4 __attribute__((ext_vector_type(4)));
-typedef uchar uchar8 __attribute__((ext_vector_type(8)));
-typedef uchar uchar16 __attribute__((ext_vector_type(16)));
-typedef short short2 __attribute__((ext_vector_type(2)));
-typedef short short3 __attribute__((ext_vector_type(3)));
-typedef short short4 __attribute__((ext_vector_type(4)));
-typedef short short8 __attribute__((ext_vector_type(8)));
-typedef short short16 __attribute__((ext_vector_type(16)));
-typedef ushort ushort2 __attribute__((ext_vector_type(2)));
-typedef ushort ushort3 __attribute__((ext_vector_type(3)));
-typedef ushort ushort4 __attribute__((ext_vector_type(4)));
-typedef ushort ushort8 __attribute__((ext_vector_type(8)));
-typedef ushort ushort16 __attribute__((ext_vector_type(16)));
-typedef int int2 __attribute__((ext_vector_type(2)));
-typedef int int3 __attribute__((ext_vector_type(3)));
-typedef int int4 __attribute__((ext_vector_type(4)));
-typedef int int8 __attribute__((ext_vector_type(8)));
-typedef int int16 __attribute__((ext_vector_type(16)));
-typedef uin

[PATCH] D59673: [Clang] Harmonize Split DWARF options with llc

2019-06-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/include/llvm/LTO/Config.h:92
+  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
+  /// attribute in the skeleton CU.
+  std::string SplitDwarfFile;

aaronpuchert wrote:
> tejohnson wrote:
> > Probably needs a comment similar to the one below about being for running 
> > individual backends directly. Otherwise (for in process ThinLTO) we use the 
> > DwoDir.
> Sure. Any objections to the following wording?
> 
> ```
>   /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
>   /// attribute in the skeleton CU. This should generally only be used when
>   /// running an individual backend directly via thinBackend(), as otherwise
>   /// all objects would use the same .dwo file. Not used as output path.
> ```
Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59673



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


[PATCH] D63335: [HIP] Change kernel stub name again

2019-06-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Is there particular reason you need to switch to this naming scheme?

One issue with this patch is that demanglers will no longer be able to deal 
with the name. While they do know to ignore .stub suffix, they can't deal with 
`__device_stub_` prefix.
E.g:

  % c++filt __device_stub___Z10kernelfuncIiEvv
  __device_stub___Z10kernelfuncIiEvv
  % c++filt _Z10kernelfuncIiEvv.stub
  void kernelfunc() [clone .stub]






Comment at: clang/lib/CodeGen/CGCUDANV.cpp:222-226
+  assert((CGF.CGM.getContext().getAuxTargetInfo() &&
+  (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() !=
+   CGF.CGM.getContext().getTargetInfo().getCXXABI())) ||
+ getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) ==
+ CGF.CurFn->getName());

I'm not sure I understand what exactly this assertion checks.
The condition appears to be true is host/device ABIs are different OR the name 
of the current function is the same as the (possibly mangled) device-side name 
+ __device_stub_ prefix.

While the first part makes sense, I'm not sure I understand the name comparison 
part.
Could you tell me more and, maybe, add a comment explaining what's going on 
here.



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:789
+return Name;
+  return std::move(("__device_stub__" + Name).str());
+}

I suspect `return "__device_stub__" + Name;` would do. StringRef will convert 
to std::string and copy elision should avoid unnecessary copy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63335



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


[PATCH] D63335: [HIP] Change kernel stub name again

2019-06-14 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added a comment.

it's requested from debugger people. they don't want to the host-side stub 
could match the device-side kernel function name. the previous scheme cannot 
prevent that.




Comment at: clang/lib/CodeGen/CGCUDANV.cpp:222-226
+  assert((CGF.CGM.getContext().getAuxTargetInfo() &&
+  (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() !=
+   CGF.CGM.getContext().getTargetInfo().getCXXABI())) ||
+ getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) ==
+ CGF.CurFn->getName());

tra wrote:
> I'm not sure I understand what exactly this assertion checks.
> The condition appears to be true is host/device ABIs are different OR the 
> name of the current function is the same as the (possibly mangled) 
> device-side name + __device_stub_ prefix.
> 
> While the first part makes sense, I'm not sure I understand the name 
> comparison part.
> Could you tell me more and, maybe, add a comment explaining what's going on 
> here.
The second is to ensure, if, under the same ABI, kernel stub name derived from 
device-side name mangling should be the same the sub name generated from 
host-side, CGF.CurFn->getName() is the mangled named from host compilation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63335



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


[PATCH] D63335: [HIP] Change kernel stub name again

2019-06-14 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:222-226
+  assert((CGF.CGM.getContext().getAuxTargetInfo() &&
+  (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() !=
+   CGF.CGM.getContext().getTargetInfo().getCXXABI())) ||
+ getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) ==
+ CGF.CurFn->getName());

hliao wrote:
> tra wrote:
> > I'm not sure I understand what exactly this assertion checks.
> > The condition appears to be true is host/device ABIs are different OR the 
> > name of the current function is the same as the (possibly mangled) 
> > device-side name + __device_stub_ prefix.
> > 
> > While the first part makes sense, I'm not sure I understand the name 
> > comparison part.
> > Could you tell me more and, maybe, add a comment explaining what's going on 
> > here.
> The second is to ensure, if, under the same ABI, kernel stub name derived 
> from device-side name mangling should be the same the sub name generated from 
> host-side, CGF.CurFn->getName() is the mangled named from host compilation
previous assertion expression gets the same goal, if ABI is different, the stub 
name from device-side should match the stub name from the host-side 
compilation. As we add a dedicated interface to the derive stub name, we could 
simplify the comparison to a single one.
Also, we put the simple condition checking ahead (a common practice) to reduce 
the overhead of string comparison


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63335



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


[PATCH] D63335: [HIP] Change kernel stub name again

2019-06-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D63335#1543845 , @hliao wrote:

> it's requested from debugger people. they don't want to the host-side stub 
> could match the device-side kernel function name. the previous scheme cannot 
> prevent that.


I understand that you want a different name for the stub. My question is why 
the ".stub" suffix was not sufficient and how does having a prefix instead 
helps? Making the name un-demangleable is undesirable, IMO. There should be a 
good reason to justify it.




Comment at: clang/lib/CodeGen/CGCUDANV.cpp:222-226
+  assert((CGF.CGM.getContext().getAuxTargetInfo() &&
+  (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() !=
+   CGF.CGM.getContext().getTargetInfo().getCXXABI())) ||
+ getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) ==
+ CGF.CurFn->getName());

hliao wrote:
> tra wrote:
> > I'm not sure I understand what exactly this assertion checks.
> > The condition appears to be true is host/device ABIs are different OR the 
> > name of the current function is the same as the (possibly mangled) 
> > device-side name + __device_stub_ prefix.
> > 
> > While the first part makes sense, I'm not sure I understand the name 
> > comparison part.
> > Could you tell me more and, maybe, add a comment explaining what's going on 
> > here.
> The second is to ensure, if, under the same ABI, kernel stub name derived 
> from device-side name mangling should be the same the sub name generated from 
> host-side, CGF.CurFn->getName() is the mangled named from host compilation
This definitely needs a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63335



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


[PATCH] D62831: [CodeGen][ObjC] Add attribute "objc_arc_intert" to ObjC globals that are retain-agnostic

2019-06-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Please rename the test.  There's also a typo in the differential title; please 
make sure that doesn't get into the commit message.  Otherwise LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62831



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


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2019-06-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

New check must be mentioned in Release Notes and its documentation provided.




Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:68
+const CallExpr *MemcpyNode) {
+  const auto FunctionNameSourceRange = CharSourceRange::getCharRange(
+  MemcpyNode->getBeginLoc(), MemcpyNode->getArg(0)->getBeginLoc());

Return type could not be deduced from same statement, so please don't use auto.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:76
+ const CallExpr *MemcpyNode) {
+  std::string arg[3];
+

Will be good idea to use std::array and its size instead of numerical constant.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h:26
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;

Should be override and = default. See modernize-use-override and 
modernize-use-equals-default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63324



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


[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-06-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 204806.
gtbercea added a comment.

- Make function const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -26,42 +26,35 @@
 // CHECK: [[VAR:@.+]] = global double 1.00e+01
 // CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
 
-// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
-// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
 
 // CHECK: [[N_CASTED:%.+]] = alloca i64
 // CHECK: [[SUM_CASTED:%.+]] = alloca i64
 
-// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
-// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [2 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [2 x i8*]
 
 // CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
 // CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
 
-// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
 // CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
-// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 // CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
 
-// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
 // CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
-// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
 // CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
 
-// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 2
-// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
-// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
-// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 2
-// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
-// CHECK: store double* [[VAR]], double** [[BCAST6]]
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 
-// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
-
-// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 2, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
 
 #endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -2667,7 +2667,8 @@
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
-  (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
+  (Stack->hasRequiresDeclWithClause() ||
+   !Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
   SourceLocation ELoc = E->getExprLoc();
Index: lib/CodeGen/CGOpenMPRuntime.h
===

r363428 - C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue conversion applied to a member access or similar not-quite-trivial lvalue expression.

2019-06-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun 14 10:46:37 2019
New Revision: 363428

URL: http://llvm.org/viewvc/llvm-project?rev=363428&view=rev
Log:
C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue 
conversion applied to a member access or similar not-quite-trivial lvalue 
expression.

Summary:
When a variable is named in a context where we can't directly emit a
reference to it (because we don't know for sure that it's going to be
defined, or it's from an enclosing function and not captured, or the
reference might not "work" for some reason), we emit a copy of the
variable as a global and use that for the known-to-be-read-only access.

This reinstates r363295, reverted in r363352, with a fix for PR42276:
we now produce a proper name for a non-odr-use reference to a static
constexpr data member. The name .const is used in that
case; such names are reserved to the implementation for cases such as
this and should demangle nicely.

Reviewers: rjmccall

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CXX/basic/basic.def.odr/p2.cpp
cfe/trunk/test/CodeGenCXX/no-odr-use.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/drs/dr20xx.cpp
cfe/trunk/test/CXX/drs/dr21xx.cpp
cfe/trunk/test/CXX/drs/dr23xx.cpp
cfe/trunk/test/CXX/drs/dr6xx.cpp
cfe/trunk/test/CXX/drs/dr7xx.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=363428&r1=363427&r2=363428&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Jun 14 10:46:37 2019
@@ -1077,17 +1077,16 @@ static llvm::Constant *constWithPadding(
   return constant;
 }
 
-static Address createUnnamedGlobalFrom(CodeGenModule &CGM, const VarDecl &D,
-   CGBuilderTy &Builder,
-   llvm::Constant *Constant,
-   CharUnits Align) {
+Address CodeGenModule::createUnnamedGlobalFrom(const VarDecl &D,
+   llvm::Constant *Constant,
+   CharUnits Align) {
   auto FunctionName = [&](const DeclContext *DC) -> std::string {
 if (const auto *FD = dyn_cast(DC)) {
   if (const auto *CC = dyn_cast(FD))
 return CC->getNameAsString();
   if (const auto *CD = dyn_cast(FD))
 return CD->getNameAsString();
-  return CGM.getMangledName(FD);
+  return getMangledName(FD);
 } else if (const auto *OM = dyn_cast(DC)) {
   return OM->getNameAsString();
 } else if (isa(DC)) {
@@ -1095,26 +1094,47 @@ static Address createUnnamedGlobalFrom(C
 } else if (isa(DC)) {
   return "";
 } else {
-  llvm::llvm_unreachable_internal("expected a function or method");
+  llvm_unreachable("expected a function or method");
 }
   };
 
-  auto *Ty = Constant->getType();
-  bool isConstant = true;
-  llvm::GlobalVariable *InsertBefore = nullptr;
-  unsigned AS = CGM.getContext().getTargetAddressSpace(
-  CGM.getStringLiteralAddressSpace());
-  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
-  CGM.getModule(), Ty, isConstant, llvm::GlobalValue::PrivateLinkage,
-  Constant,
-  "__const." + FunctionName(D.getParentFunctionOrMethod()) + "." +
-  D.getName(),
-  InsertBefore, llvm::GlobalValue::NotThreadLocal, AS);
-  GV->setAlignment(Align.getQuantity());
-  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  Address SrcPtr = Address(GV, Align);
-  llvm::Type *BP = llvm::PointerType::getInt8PtrTy(CGM.getLLVMContext(), AS);
+  // Form a simple per-variable cache of these values in case we find we
+  // want to reuse them.
+  llvm::GlobalVariable *&CacheEntry = InitializerConstants[&D];
+  if (!CacheEntry || CacheEntry->getInitializer() != Constant) {
+auto *Ty = Constant->getType();
+bool isConstant = true;
+llvm::GlobalVariable *InsertBefore = nullptr;
+unsigned AS =
+getContext().getTargetAddressSpace(getStringLiteralAddressSpace());
+std::string Name;
+if (D.hasGlobalStorage())
+  Name = getMangledName(&D).str() + ".const";
+else if (const DeclContext *DC = D.getParentFunctionOrMethod())
+  Name = ("__const." + FunctionName(DC) + "." + D.getName()).str();
+else
+  llvm_unreachable("local variable has no parent function or method");
+llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+getModule(), Ty, isConstant, llvm::GlobalValue::PrivateLinkage,
+Constant, Name, InsertBefore, llvm::GlobalValue::NotThreadLocal, AS);
+GV->setAlignment(Align.getQuantity());
+GV->setUnnam

r363430 - Remove unused SK_LValueToRValue initialization step.

2019-06-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun 14 10:46:39 2019
New Revision: 363430

URL: http://llvm.org/viewvc/llvm-project?rev=363430&view=rev
Log:
Remove unused SK_LValueToRValue initialization step.

In addition to being unused and duplicating code, this was also wrong
(it didn't properly mark the operand as being potentially not odr-used).

This reinstates r363340, reverted in r363352.

Modified:
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=363430&r1=363429&r2=363430&view=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Fri Jun 14 10:46:39 2019
@@ -821,9 +821,6 @@ public:
 /// Perform a conversion adding _Atomic to a type.
 SK_AtomicConversion,
 
-/// Perform a load from a glvalue, producing an rvalue.
-SK_LValueToRValue,
-
 /// Perform an implicit conversion sequence.
 SK_ConversionSequence,
 
@@ -1270,12 +1267,6 @@ public:
   /// type.
   void AddAtomicConversionStep(QualType Ty);
 
-  /// Add a new step that performs a load of the given type.
-  ///
-  /// Although the term "LValueToRValue" is conventional, this applies to both
-  /// lvalues and xvalues.
-  void AddLValueToRValueStep(QualType Ty);
-
   /// Add a new step that applies an implicit conversion sequence.
   void AddConversionSequenceStep(const ImplicitConversionSequence &ICS,
  QualType T, bool TopLevelOfInitList = false);

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=363430&r1=363429&r2=363430&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Jun 14 10:46:39 2019
@@ -3282,7 +3282,6 @@ void InitializationSequence::Step::Destr
   case SK_QualificationConversionXValue:
   case SK_QualificationConversionLValue:
   case SK_AtomicConversion:
-  case SK_LValueToRValue:
   case SK_ListInitialization:
   case SK_UnwrapInitList:
   case SK_RewrapInitList:
@@ -3466,15 +3465,6 @@ void InitializationSequence::AddAtomicCo
   Steps.push_back(S);
 }
 
-void InitializationSequence::AddLValueToRValueStep(QualType Ty) {
-  assert(!Ty.hasQualifiers() && "rvalues may not have qualifiers");
-
-  Step S;
-  S.Kind = SK_LValueToRValue;
-  S.Type = Ty;
-  Steps.push_back(S);
-}
-
 void InitializationSequence::AddConversionSequenceStep(
 const ImplicitConversionSequence &ICS, QualType T,
 bool TopLevelOfInitList) {
@@ -7505,7 +7495,6 @@ ExprResult InitializationSequence::Perfo
   case SK_QualificationConversionXValue:
   case SK_QualificationConversionRValue:
   case SK_AtomicConversion:
-  case SK_LValueToRValue:
   case SK_ConversionSequence:
   case SK_ConversionSequenceNoNarrowing:
   case SK_ListInitialization:
@@ -,18 +7766,6 @@ ExprResult InitializationSequence::Perfo
   break;
 }
 
-case SK_LValueToRValue: {
-  assert(CurInit.get()->isGLValue() && "cannot load from a prvalue");
-  // C++ [conv.lval]p3:
-  //   If T is cv std::nullptr_t, the result is a null pointer constant.
-  CastKind CK =
-  Step->Type->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
-  CurInit =
-  ImplicitCastExpr::Create(S.Context, Step->Type, CK, CurInit.get(),
-   /*BasePath=*/nullptr, VK_RValue);
-  break;
-}
-
 case SK_ConversionSequence:
 case SK_ConversionSequenceNoNarrowing: {
   if (const auto *FromPtrType =
@@ -9010,10 +8987,6 @@ void InitializationSequence::dump(raw_os
   OS << "non-atomic-to-atomic conversion";
   break;
 
-case SK_LValueToRValue:
-  OS << "load (lvalue to rvalue)";
-  break;
-
 case SK_ConversionSequence:
   OS << "implicit conversion sequence (";
   S->ICS->dump(); // FIXME: use OS


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


r363429 - PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type

2019-06-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun 14 10:46:38 2019
New Revision: 363429

URL: http://llvm.org/viewvc/llvm-project?rev=363429&view=rev
Log:
PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type
nullptr_t does not access memory.

We now reuse CK_NullToPointer to represent a conversion from a glvalue
of type nullptr_t to a prvalue of nullptr_t where necessary.

This reinstates r363337, reverted in r363352.

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/test/Analysis/nullptr.cpp
cfe/trunk/test/CXX/drs/dr21xx.cpp
cfe/trunk/test/CodeGenCXX/nullptr.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=363429&r1=363428&r2=363429&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Jun 14 10:46:38 2019
@@ -1885,6 +1885,11 @@ ImplicitCastExpr *ImplicitCastExpr::Crea
ExprValueKind VK) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
   void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  // Per C++ [conv.lval]p3, lvalue-to-rvalue conversions on class and
+  // std::nullptr_t have special semantics not captured by CK_LValueToRValue.
+  assert((Kind != CK_LValueToRValue ||
+  !(T->isNullPtrType() || T->getAsCXXRecordDecl())) &&
+ "invalid type for lvalue-to-rvalue conversion");
   ImplicitCastExpr *E =
 new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, VK);
   if (PathSize)

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=363429&r1=363428&r2=363429&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Jun 14 10:46:38 2019
@@ -1352,7 +1352,8 @@ static bool isSimpleZero(const Expr *E,
   // (int*)0 - Null pointer expressions.
   if (const CastExpr *ICE = dyn_cast(E))
 return ICE->getCastKind() == CK_NullToPointer &&
-CGF.getTypes().isPointerZeroInitializable(E->getType());
+   CGF.getTypes().isPointerZeroInitializable(E->getType()) &&
+   !E->HasSideEffects(CGF.getContext());
   // '\0'
   if (const CharacterLiteral *CL = dyn_cast(E))
 return CL->getValue() == 0;

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=363429&r1=363428&r2=363429&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Jun 14 10:46:38 2019
@@ -2148,14 +2148,14 @@ Value *ScalarExprEmitter::VisitCastExpr(
 
   case CK_NullToPointer:
 if (MustVisitNullValue(E))
-  (void) Visit(E);
+  CGF.EmitIgnoredExpr(E);
 
 return CGF.CGM.getNullPointer(cast(ConvertType(DestTy)),
   DestTy);
 
   case CK_NullToMemberPointer: {
 if (MustVisitNullValue(E))
-  (void) Visit(E);
+  CGF.EmitIgnoredExpr(E);
 
 const MemberPointerType *MPT = CE->getType()->getAs();
 return CGF.CGM.getCXXABI().EmitNullMemberPointer(MPT);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=363429&r1=363428&r2=363429&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 14 10:46:38 2019
@@ -635,8 +635,10 @@ ExprResult Sema::DefaultLvalueConversion
   if (E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
 Cleanup.setExprNeedsCleanups(true);
 
-  Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E, nullptr,
- VK_RValue);
+  // C++ [conv.lval]p3:
+  //   If T is cv std::nullptr_t, the result is a null pointer constant.
+  CastKind CK = T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
+  Res = ImplicitCastExpr::Create(Context, T, CK, E, nullptr, VK_RValue);
 
   // C11 6.3.2.1p2:
   //   ... if the lvalue has atomic type, the value has the non-atomic version

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=363429&r1=363428&r2=363429&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Jun 14 10:46:38 2019
@@ -7779,9 +7779,13 @@ ExprResult InitializationSequence::Perfo
 
 case SK_LValueToRValue: {
   as

Re: r363295 - C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue conversion applied to a member access or similar not-quite-trivial lvalue expression.

2019-06-14 Thread Richard Smith via cfe-commits
On Thu, 13 Jun 2019 at 21:02, Nico Weber  wrote:

> Hi,
>
> this made clang segfault on some inputs seen in ANGLE. I filed PR42276
> with a reduced repro and reverted this (and the two dependent changes) in
> r363352 for now.
>

Thanks for the revert and the reduced testcase. Fixed and recommitted as
r363428-r363430.


> Nico
>
> On Thu, Jun 13, 2019 at 2:56 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Thu Jun 13 12:00:16 2019
>> New Revision: 363295
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=363295&view=rev
>> Log:
>> C++ DR712 and others: handle non-odr-use resulting from an
>> lvalue-to-rvalue conversion applied to a member access or similar
>> not-quite-trivial lvalue expression.
>>
>> Summary:
>> When a variable is named in a context where we can't directly emit a
>> reference to it (because we don't know for sure that it's going to be
>> defined, or it's from an enclosing function and not captured, or the
>> reference might not "work" for some reason), we emit a copy of the
>> variable as a global and use that for the known-to-be-read-only access.
>>
>> Reviewers: rjmccall
>>
>> Subscribers: jdoerfert, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D63157
>>
>> Added:
>> cfe/trunk/test/CXX/basic/basic.def.odr/p2.cpp
>> cfe/trunk/test/CodeGenCXX/no-odr-use.cpp
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDecl.cpp
>> cfe/trunk/lib/CodeGen/CGExpr.cpp
>> cfe/trunk/lib/CodeGen/CodeGenModule.h
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/test/CXX/drs/dr20xx.cpp
>> cfe/trunk/test/CXX/drs/dr21xx.cpp
>> cfe/trunk/test/CXX/drs/dr23xx.cpp
>> cfe/trunk/test/CXX/drs/dr6xx.cpp
>> cfe/trunk/test/CXX/drs/dr7xx.cpp
>> cfe/trunk/www/cxx_dr_status.html
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=363295&r1=363294&r2=363295&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu Jun 13 12:00:16 2019
>> @@ -1077,17 +1077,16 @@ static llvm::Constant *constWithPadding(
>>return constant;
>>  }
>>
>> -static Address createUnnamedGlobalFrom(CodeGenModule &CGM, const VarDecl
>> &D,
>> -   CGBuilderTy &Builder,
>> -   llvm::Constant *Constant,
>> -   CharUnits Align) {
>> +Address CodeGenModule::createUnnamedGlobalFrom(const VarDecl &D,
>> +   llvm::Constant *Constant,
>> +   CharUnits Align) {
>>auto FunctionName = [&](const DeclContext *DC) -> std::string {
>>  if (const auto *FD = dyn_cast(DC)) {
>>if (const auto *CC = dyn_cast(FD))
>>  return CC->getNameAsString();
>>if (const auto *CD = dyn_cast(FD))
>>  return CD->getNameAsString();
>> -  return CGM.getMangledName(FD);
>> +  return getMangledName(FD);
>>  } else if (const auto *OM = dyn_cast(DC)) {
>>return OM->getNameAsString();
>>  } else if (isa(DC)) {
>> @@ -1099,22 +1098,39 @@ static Address createUnnamedGlobalFrom(C
>>  }
>>};
>>
>> -  auto *Ty = Constant->getType();
>> -  bool isConstant = true;
>> -  llvm::GlobalVariable *InsertBefore = nullptr;
>> -  unsigned AS = CGM.getContext().getTargetAddressSpace(
>> -  CGM.getStringLiteralAddressSpace());
>> -  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
>> -  CGM.getModule(), Ty, isConstant, llvm::GlobalValue::PrivateLinkage,
>> -  Constant,
>> -  "__const." + FunctionName(D.getParentFunctionOrMethod()) + "." +
>> -  D.getName(),
>> -  InsertBefore, llvm::GlobalValue::NotThreadLocal, AS);
>> -  GV->setAlignment(Align.getQuantity());
>> -  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
>> -
>> -  Address SrcPtr = Address(GV, Align);
>> -  llvm::Type *BP = llvm::PointerType::getInt8PtrTy(CGM.getLLVMContext(),
>> AS);
>> +  // Form a simple per-variable cache of these values in case we find we
>> +  // want to reuse them.
>> +  llvm::GlobalVariable *&CacheEntry = InitializerConstants[&D];
>> +  if (!CacheEntry || CacheEntry->getInitializer() != Constant) {
>> +auto *Ty = Constant->getType();
>> +bool isConstant = true;
>> +llvm::GlobalVariable *InsertBefore = nullptr;
>> +unsigned AS =
>> +
>> getContext().getTargetAddressSpace(getStringLiteralAddressSpace());
>> +llvm::GlobalVariable *GV = new llvm::GlobalVariable(
>> +getModule(), Ty, isConstant, llvm::GlobalValue::PrivateLinkage,
>> +Constant,
>> +"__const." + FunctionName(D.getParentFunctionOrMethod()) + "." +
>> +D.getName(),
>> +InsertBefore, llvm::GlobalValue::NotThreadLocal, AS);
>> +GV->setAlignment(Align.getQuantity())

[PATCH] D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

I did some more digging and found the following differences between PMs for 
each test, and they seem to all differ and can be fixed for different reasons.

**CodeGen/aggregate-assign-call.c**: The new PM on -O1 codegen produces the 
do/while loop differently but still emits the lifetime start/end intrinsics 
around temporary variables, which is what the test checks for. Here we can just 
check for the instructions while ignoring the branches generated.

**CodeGen/arm_acle.c**: A bunch of instructions seem to have been combined into 
a call to `llvm.fshl.i32`, so we just check for those under the new PM.

**CodeGen/available-externally-suppress.c**: `available_externally` was not 
emitted during `-O2 -flto` runs when it should still be retained for link time 
inlining purposes. This can be fixed by checking that we aren't LTOPrelinking 
when adding the `EliminateAvailableExternallyPass`.

**CodeGen/pgo-sample.c [No new fix]**: The test checks that `PruneEH` runs, but 
there doesn’t seem to be a corresponding new PM pass for it. Should there be? 
If there is one then we can just check for that in the debug PM dump.

**CodeGen/x86_64-instrument-functions.c [No new fix]**: This one's a bit 
complicated. The initial problem seems to be that `EntryExitInstrumenterPass` 
was not added into the pipeline to emit `__cyg_profile_func_enter/exit()` 
calls. Adding that to the pipeline seems to instrument correctly now and add 
these calls, but we run into a problem with inlining. `root()` expects 2 calls 
to `__cyg_profile_func_enter` and 2 calls to `__cyg_profile_func_exit` in its 
body,

  ; Function Attrs: nounwind
  define i32 @root(i32 returned %x) #0 {
  entry:
%0 = tail call i8* @llvm.returnaddress(i32 0)
tail call void @__cyg_profile_func_enter(i8* bitcast (i32 (i32)* @root to 
i8*), i8* %0) #2
tail call void @__cyg_profile_func_enter(i8* bitcast (i32 (i32)* @leaf to 
i8*), i8* %0) #2
tail call void @__cyg_profile_func_exit(i8* bitcast (i32 (i32)* @leaf to 
i8*), i8* %0) #2
tail call void @__cyg_profile_func_exit(i8* bitcast (i32 (i32)* @root to 
i8*), i8* %0) #2
ret i32 %x
  }

but we get only 1 call

  ; Function Attrs: norecurse nounwind readnone
  define i32 @root(i32 returned %x) local_unnamed_addr #0 {
  entry:
%0 = call i8* @llvm.returnaddress(i32 0)
call void @__cyg_profile_func_enter(i8* bitcast (i32 (i32)* @root to i8*), 
i8* %0)
%1 = call i8* @llvm.returnaddress(i32 0)
call void @__cyg_profile_func_exit(i8* bitcast (i32 (i32)* @root to i8*), 
i8* %1)
ret i32 %x
  }

I suspect this is due to the `leaf()` being inlined into `root()` even though 
inlining should happen after it. The legacy `EntryExitInstrumenter` pass seems 
to be added to the legacy FunctionPassManager first before all others passes. 
Under the legacy PM, when this pass runs, `root()` should look like:

  ; Function Attrs: nounwind
  define i32 @root(i32 %x) #1 {
  entry:
%x.addr = alloca i32, align 4
store i32 %x, i32* %x.addr, align 4, !tbaa !2
%0 = load i32, i32* %x.addr, align 4, !tbaa !2
%call = call i32 @leaf(i32 %0)  ; this call is not yet inlined
ret i32 %call
  }

but `root()` looks like this in the new PM pass:

  ; Function Attrs: norecurse nounwind readnone
  define i32 @root(i32 returned %x) local_unnamed_addr #1 {
  entry:
ret i32 %x
  }

**CodeGenCXX/auto-var-init.cpp**: Auto var initialization is performed 
differently under new PM than legacy. With initialization for structs with 
default values, the legacy PM will store the stream of 0xAAs, then initialize 
the members with default values in a constructor, whereas the new PM will just 
store the correct value for the whole struct right away without initialization. 
In one case, it seems that ctor function was also inlined. Fixed by check 
accounting for these checks separately.

**CodeGenCXX/conditional-temporaries.cpp**: The new pm seems to be unable to 
statically determine the return value of some functions. For now I just add 
separate checks for the new PM IR.

**CodeGenCXX/member-function-pointer-calls.cpp**: Same as 
`CodeGenCXX/conditional-temporaries.cpp`. In this case, the new PM codegen also 
contains calls to lifetime start/end intrinsics. Perhaps this time it could be 
due to the intrinsics not being optimized out?

**CodeGenObjC/os_log.m**: Legacy test expects argument of `ptrtoint` and some 
functions to be a specific type and argument, though the new PM codegen uses a 
different type and argument which are also valid since 
`@llvm.objc.retainAutoreleasedReturnValue(val)` always returns `val`.

**CodeGenObjCXX/os_log.mm**: A function seems to have been inlined under the 
new PM. Here we just prevent inlining for the new PM run since the test expects 
this specific function call.

**Misc/pr32207.c [No new fix]**: The banner is something that appears only in 
the legacy PM. I think the test only checks that the banner is printed and not 
so much that the par

[PATCH] D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 204808.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63156

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/available-externally-suppress.c
  clang/test/CodeGen/cspgo-instrumentation.c
  clang/test/CodeGen/cspgo-instrumentation_lto.c
  clang/test/CodeGen/cspgo-instrumentation_thinlto.c
  clang/test/CodeGen/pgo-instrumentation.c
  clang/test/CodeGen/pgo-sample.c
  clang/test/CodeGen/thinlto-debug-pm.c
  clang/test/CodeGen/x86_64-instrument-functions.c
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/conditional-temporaries.cpp
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  clang/test/CodeGenObjC/os_log.m
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/Misc/pr32207.c
  llvm/lib/Passes/PassBuilder.cpp

Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -812,8 +812,10 @@
   // available externally globals. Eventually they will be suppressed during
   // codegen, but eliminating here enables more opportunity for GlobalDCE as it
   // may make globals referenced by available external functions dead and saves
-  // running remaining passes on the eliminated functions.
-  MPM.addPass(EliminateAvailableExternallyPass());
+  // running remaining passes on the eliminated functions. These should be
+  // preserved during prelinking for link-time inlining decisions.
+  if (!LTOPreLink)
+MPM.addPass(EliminateAvailableExternallyPass());
 
   if (EnableOrderFileInstrumentation)
 MPM.addPass(InstrOrderFilePass());
Index: clang/test/Misc/pr32207.c
===
--- clang/test/Misc/pr32207.c
+++ clang/test/Misc/pr32207.c
@@ -1,4 +1,4 @@
 // test for r305179
-// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O2 -fno-experimental-new-pass-manager -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
 // CHECK: *** IR Dump After Function Integration/Inlining ***
 void foo() {}
Index: clang/test/CodeGenObjCXX/os_log.mm
===
--- clang/test/CodeGenObjCXX/os_log.mm
+++ clang/test/CodeGenObjCXX/os_log.mm
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc \
-// RUN:   -fexceptions -fcxx-exceptions -O1 | FileCheck %s
+// RUN:   -fexceptions -fcxx-exceptions -O1 -fno-experimental-new-pass-manager | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -O1 -fexperimental-new-pass-manager -fno-inline | FileCheck %s
 
 // Check that no EH cleanup is emitted around the call to __os_log_helper.
 namespace no_eh_cleanup {
Index: clang/test/CodeGenObjC/os_log.m
===
--- clang/test/CodeGenObjC/os_log.m
+++ clang/test/CodeGenObjC/os_log.m
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 -fno-experimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 -fexperimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O0 | FileCheck %s -check-prefix=CHECK-O0
 
 // Make sure we emit clang.arc.use before calling objc_release as part of the
@@ -22,7 +23,8 @@
   // CHECK: %[[CALL:.*]] = tail call %[[TY0:.*]]* (...) @GenString()
   // CHECK: %[[V0:.*]] = bitcast %[[TY0]]* %[[CALL]] to i8*
   // CHECK: %[[V1:.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V0]])
-  // CHECK: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
+  // CHECK-LEGACY: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
+  // CHECK-NEWPM: %[[V2:.*]] = ptrtoint i8* %[[V1]] to i64
   // CHECK: store i8 2, i8* %[[BUF]], align 1
   // CHECK: %[[NUMARGS_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 1
   // CHECK: store i8 1, i8* %[[NUMARGS_I]], align 1
@@ -33,8 +35,10 @@
   // CHECK: %[[ARGDATA_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 4
   // CHECK: %[[ARGDATACAST_I:.*]] = bitcast i8* %[[ARGDATA_I]] to i64*
   // CHECK: store i64 %[[V2]], i64* %[[ARGDATACAST_I]], align 1
-  // CHECK: tail call void (...) @llvm.objc.clang.arc.use(%[[TY0]]* %[[CALL]])
-  // CHECK: tail call void @llvm.objc.release(i8* %[[V0]])
+  // CHECK-LEGACY: tail call void (...) @llvm.objc.clang.arc.use(%[[TY0]]* %[[CALL]])
+  /

r363435 - [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-06-14 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Fri Jun 14 10:58:26 2019
New Revision: 363435

URL: http://llvm.org/viewvc/llvm-project?rev=363435&view=rev
Log:
[OpenMP] Avoid emitting maps for target link variables when unified memory is 
used

Summary: This patch avoids the emission of maps for target link variables when 
unified memory is present.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=363435&r1=363434&r2=363435&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Jun 14 10:58:26 2019
@@ -8266,7 +8266,8 @@ public:
   continue;
 llvm::Optional Res =
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
-if (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link)
+if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
+!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link)
   continue;
 StructRangeInfoTy PartialStruct;
 generateInfoForComponentList(
@@ -9251,6 +9252,10 @@ bool CGOpenMPRuntime::hasAllocateAttribu
   return false;
 }
 
+bool CGOpenMPRuntime::hasRequiresUnifiedSharedMemory() const {
+  return HasRequiresUnifiedSharedMemory;
+}
+
 CGOpenMPRuntime::DisableAutoDeclareTargetRAII::DisableAutoDeclareTargetRAII(
 CodeGenModule &CGM)
 : CGM(CGM) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=363435&r1=363434&r2=363435&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Fri Jun 14 10:58:26 2019
@@ -1623,6 +1623,9 @@ public:
   /// the predefined allocator and translates it into the corresponding address
   /// space.
   virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS);
+
+  /// Return whether the unified_shared_memory has been specified.
+  bool hasRequiresUnifiedSharedMemory() const;
 };
 
 /// Class supports emissionof SIMD-only code.

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=363435&r1=363434&r2=363435&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 14 10:58:26 2019
@@ -2667,7 +2667,8 @@ public:
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
-  (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
+  (Stack->hasRequiresDeclWithClause() ||
+   !Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
   SourceLocation ELoc = E->getExprLoc();

Modified: cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp?rev=363435&r1=363434&r2=363435&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp 
(original)
+++ cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp Fri 
Jun 14 10:58:26 2019
@@ -26,42 +26,35 @@ int bar(int n){
 // CHECK: [[VAR:@.+]] = global double 1.00e+01
 // CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
 
-// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
-// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 
4, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] 
[i64 800, i64 800]
 
 // CHECK: [[N_CASTED:%.+]] = alloca i64
 // CHECK: [[SUM_CASTED:%.+]] = alloca i64
 
-// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
-// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [2 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [2 x i8*]
 
 // CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
 // CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
 
-// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHEC

  1   2   >