[PATCH] D68520: [cmake] Fix clang builds with BUILD_SHARED=ON and CLANG_LINK_CLANG_DYLIB=ON

2020-01-31 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Still LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68520



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


Re: [clang] 0130b6c - Don't assume a reference refers to at least sizeof(T) bytes.

2020-01-31 Thread Shoaib Meenai via cfe-commits
Should this be cherry-picked to 10.0?

On 1/31/20, 7:09 PM, "cfe-commits on behalf of Richard Smith via cfe-commits" 
 
wrote:


Author: Richard Smith
Date: 2020-01-31T19:08:17-08:00
New Revision: 0130b6cb5a8d94511e2bb09ac2f5a613a59f70b4

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

LOG: Don't assume a reference refers to at least sizeof(T) bytes.

When T is a class type, only nvsize(T) bytes need be accessible through
the reference. We had matching bugs in the application of the
dereferenceable attribute and in -fsanitize=undefined.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenCXX/catch-undef-behavior.cpp
clang/test/CodeGenCXX/thunks.cpp

Removed: 





diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2e8e31dbf4c7..6d3a833b5037 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1696,6 +1696,10 @@ class CXXRecordDecl : public RecordDecl {
   /// actually abstract.
   bool mayBeAbstract() const;
 
+  /// Determine whether it's impossible for a class to be derived from this
+  /// class. This is best-effort, and may conservatively return false.
+  bool isEffectivelyFinal() const;
+
   /// If this is the closure type of a lambda expression, retrieve the
   /// number to be used for name mangling in the Itanium C++ ABI.
   ///

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 227fe80ccab4..931a1141b1b4 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1923,6 +1923,18 @@ bool CXXRecordDecl::mayBeAbstract() const {
   return false;
 }
 
+bool CXXRecordDecl::isEffectivelyFinal() const {
+  auto *Def = getDefinition();
+  if (!Def)
+return false;
+  if (Def->hasAttr())
+return true;
+  if (const auto *Dtor = Def->getDestructor())
+if (Dtor->hasAttr())
+  return true;
+  return false;
+}
+
 void CXXDeductionGuideDecl::anchor() {}
 
 bool ExplicitSpecifier::isEquivalent(const ExplicitSpecifier Other) const {
@@ -2142,12 +2154,8 @@ CXXMethodDecl 
*CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
   // Similarly, if the class itself or its destructor is marked 'final',
   // the class can't be derived from and we can therefore devirtualize the 
   // member function call.
-  if (BestDynamicDecl->hasAttr())
+  if (BestDynamicDecl->isEffectivelyFinal())
 return DevirtualizedMethod;
-  if (const auto *dtor = BestDynamicDecl->getDestructor()) {
-if (dtor->hasAttr())
-  return DevirtualizedMethod;
-  }
 
   if (const auto *DRE = dyn_cast(Base)) {
 if (const auto *VD = dyn_cast(DRE->getDecl()))

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3f132a0a62aa..9ed2ccd54487 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2054,8 +2054,8 @@ void CodeGenModule::ConstructAttributeList(
   if (const auto *RefTy = RetTy->getAs()) {
 QualType PTy = RefTy->getPointeeType();
 if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-  RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
-.getQuantity());
+  RetAttrs.addDereferenceableAttr(
+  getMinimumObjectSize(PTy).getQuantity());
 else if (getContext().getTargetAddressSpace(PTy) == 0 &&
  !CodeGenOpts.NullPointerIsValid)
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
@@ -2164,8 +2164,8 @@ void CodeGenModule::ConstructAttributeList(
 if (const auto *RefTy = ParamType->getAs()) {
   QualType PTy = RefTy->getPointeeType();
   if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
-   .getQuantity());
+Attrs.addDereferenceableAttr(
+getMinimumObjectSize(PTy).getQuantity());
   else if (getContext().getTargetAddressSpace(PTy) == 0 &&
!CodeGenOpts.NullPointerIsValid)
 Attrs.addAttribute(llvm::Attribute::NonNull);

diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 

[clang] 0130b6c - Don't assume a reference refers to at least sizeof(T) bytes.

2020-01-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-31T19:08:17-08:00
New Revision: 0130b6cb5a8d94511e2bb09ac2f5a613a59f70b4

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

LOG: Don't assume a reference refers to at least sizeof(T) bytes.

When T is a class type, only nvsize(T) bytes need be accessible through
the reference. We had matching bugs in the application of the
dereferenceable attribute and in -fsanitize=undefined.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenCXX/catch-undef-behavior.cpp
clang/test/CodeGenCXX/thunks.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2e8e31dbf4c7..6d3a833b5037 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1696,6 +1696,10 @@ class CXXRecordDecl : public RecordDecl {
   /// actually abstract.
   bool mayBeAbstract() const;
 
+  /// Determine whether it's impossible for a class to be derived from this
+  /// class. This is best-effort, and may conservatively return false.
+  bool isEffectivelyFinal() const;
+
   /// If this is the closure type of a lambda expression, retrieve the
   /// number to be used for name mangling in the Itanium C++ ABI.
   ///

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 227fe80ccab4..931a1141b1b4 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1923,6 +1923,18 @@ bool CXXRecordDecl::mayBeAbstract() const {
   return false;
 }
 
+bool CXXRecordDecl::isEffectivelyFinal() const {
+  auto *Def = getDefinition();
+  if (!Def)
+return false;
+  if (Def->hasAttr())
+return true;
+  if (const auto *Dtor = Def->getDestructor())
+if (Dtor->hasAttr())
+  return true;
+  return false;
+}
+
 void CXXDeductionGuideDecl::anchor() {}
 
 bool ExplicitSpecifier::isEquivalent(const ExplicitSpecifier Other) const {
@@ -2142,12 +2154,8 @@ CXXMethodDecl 
*CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
   // Similarly, if the class itself or its destructor is marked 'final',
   // the class can't be derived from and we can therefore devirtualize the 
   // member function call.
-  if (BestDynamicDecl->hasAttr())
+  if (BestDynamicDecl->isEffectivelyFinal())
 return DevirtualizedMethod;
-  if (const auto *dtor = BestDynamicDecl->getDestructor()) {
-if (dtor->hasAttr())
-  return DevirtualizedMethod;
-  }
 
   if (const auto *DRE = dyn_cast(Base)) {
 if (const auto *VD = dyn_cast(DRE->getDecl()))

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3f132a0a62aa..9ed2ccd54487 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2054,8 +2054,8 @@ void CodeGenModule::ConstructAttributeList(
   if (const auto *RefTy = RetTy->getAs()) {
 QualType PTy = RefTy->getPointeeType();
 if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-  RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
-.getQuantity());
+  RetAttrs.addDereferenceableAttr(
+  getMinimumObjectSize(PTy).getQuantity());
 else if (getContext().getTargetAddressSpace(PTy) == 0 &&
  !CodeGenOpts.NullPointerIsValid)
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
@@ -2164,8 +2164,8 @@ void CodeGenModule::ConstructAttributeList(
 if (const auto *RefTy = ParamType->getAs()) {
   QualType PTy = RefTy->getPointeeType();
   if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
-   .getQuantity());
+Attrs.addDereferenceableAttr(
+getMinimumObjectSize(PTy).getQuantity());
   else if (getContext().getTargetAddressSpace(PTy) == 0 &&
!CodeGenOpts.NullPointerIsValid)
 Attrs.addAttribute(llvm::Attribute::NonNull);

diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 7389207bc8ad..acc9a9ec4f4a 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -35,20 +35,37 @@ using namespace CodeGen;
 /// Return the best known alignment for an unknown pointer to a
 /// particular class.
 CharUnits CodeGenModule::getClassPointerAlignment(const CXXRecordDecl *RD) {
-  if (!RD->isCompleteDefinition())
+  if (!RD->hasDefinition())
 return CharUnits::One(); // Hopefully won't be used anywhere.
 
   auto  = getContext().getASTRecordLayout(RD);
 
   // If the class is final, then we know that the pointer points to an
   // object of 

[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-31 Thread Ronan Keryell via Phabricator via cfe-commits
keryell requested changes to this revision.
keryell added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:918
+  //
+  // SYCL v2.2 s2.10:
+  // kernels cannot include RTTI information, exception classes,

Can you change the SYCL version to "SYCL 1.2.1 s3.10"?
SYCL 2.2 is non normative: it was just a provisional version which is now 
deprecated and the SYCL committee is working on a newer version.
Thanks.


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

https://reviews.llvm.org/D73651



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


LLVM buildmaster will be updated and restarted soon

2020-01-31 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted in the nearest hour.

Thanks

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


[PATCH] D72876: Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.

2020-01-31 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore requested changes to this revision.
stephanemoore added a comment.
This revision now requires changes to proceed.

One last correction and I think that you're all set!




Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:284
`readability-redundant-smartptr-get 
`_, "Yes"
-   `readability-redundant-string-cstr 
`_,
+   `readability-redundant-string-cstr 
`_, "Yes"
`readability-redundant-string-init 
`_, "Yes"

Please revert this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72876



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


[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

2020-01-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 241855.
bruno added a comment.

- Update patch after Volodymyr's review.
- Refactor bits done as part of rG90f58eaeff5f 
, update 
it to remove that part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/odr_hash-record.c

Index: clang/test/Modules/odr_hash-record.c
===
--- /dev/null
+++ clang/test/Modules/odr_hash-record.c
@@ -0,0 +1,381 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x c %t/Inputs/first.h
+// RUN: %clang_cc1 -fsyntax-only -x c %t/Inputs/second.h
+
+// Build module map file
+// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module SecondModule {">> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -x c \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -I%t/Inputs -verify %s
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+#if defined(FIRST)
+struct S1 {};
+struct S1 s1a;
+#elif defined(SECOND)
+struct S1 {};
+#else
+struct S1 s1;
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  int x;
+  int y;
+};
+#elif defined(SECOND)
+struct S2 {
+  int y;
+  int x;
+};
+#else
+struct S2 s2;
+// expected-error@first.h:* {{'S2' has different definitions in different modules; first difference is definition in module 'FirstModule' found field 'x'}}
+// expected-note@second.h:* {{but in 'SecondModule' found field 'y'}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  double x;
+};
+#elif defined(SECOND)
+struct S3 {
+  int x;
+};
+#else
+struct S3 s3;
+// expected-error@second.h:* {{'S3::x' from module 'SecondModule' is not present in definition of 'struct S3' in module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+typedef int A;
+struct S4 {
+  A x;
+};
+
+struct S5 {
+  A x;
+};
+#elif defined(SECOND)
+typedef int B;
+struct S4 {
+  B x;
+};
+
+struct S5 {
+  int x;
+};
+#else
+struct S4 s4;
+// expected-error@first.h:* {{'S4' has different definitions in different modules; first difference is definition in module 'FirstModule' found field 'x' with type 'A' (aka 'int')}}
+// expected-note@second.h:* {{but in 'SecondModule' found field 'x' with type 'B' (aka 'int')}}
+
+struct S5 s5;
+// expected-error@first.h:* {{'S5' has different definitions in different modules; first difference is definition in module 'FirstModule' found field 'x' with type 'A' (aka 'int')}}
+// expected-note@second.h:* {{but in 'SecondModule' found field 'x' with type 'int'}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  unsigned x;
+};
+#elif defined(SECOND)
+struct S6 {
+  unsigned x : 1;
+};
+#else
+struct S6 s6;
+// expected-error@first.h:* {{'S6' has different definitions in different modules; first difference is definition in module 'FirstModule' found non-bitfield 'x'}}
+// expected-note@second.h:* {{but in 'SecondModule' found bitfield 'x'}}
+#endif
+
+#if defined(FIRST)
+struct S7 {
+  unsigned x : 2;
+};
+#elif defined(SECOND)
+struct S7 {
+  unsigned x : 1;
+};
+#else
+struct S7 s7;
+// expected-error@first.h:* {{'S7' has different definitions in different modules; first difference is definition in module 'FirstModule' found bitfield 'x' with one width expression}}
+// expected-note@second.h:* {{but in 'SecondModule' found bitfield 'x' with different width expression}}
+#endif
+
+#if defined(FIRST)
+struct S8 {
+  unsigned x : 2;
+};
+#elif defined(SECOND)
+struct S8 {
+  unsigned x : 1 + 1;
+};
+#else
+struct S8 s8;
+// expected-error@first.h:* {{'S8' has different definitions in different modules; first difference is definition in module 'FirstModule' found bitfield 'x' with one width expression}}
+// 

[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

2020-01-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

> - Why are you adding ODR hash support for `RecordDecl` and not `TagDecl`? We 
> already have support for `EnumDecl`, so `TagDecl` seems like a good candidate 
> to cover both. Honestly, I don't know if it is possible or a good idea but it 
> looks plausible enough to consider.

The reason is that in C++ ODR diagnostics for TagDecl are handled as part of 
CXXRecordDecl, I didn't want add a path in TagDecl for C/ObjC only.

> - Are anonymous structs working? Worth adding test cases.

They are at the top level but not nested ones, I fixed that and should upload a 
new patch with that next.

> - Are unions working? Didn't notice any code specifically for them but 
> `RecordDecl` covers both structs and unions, so they should be working and we 
> need to test that.

Done in upcoming patch.

> - Few testing additions. These cases might be already covered or might be low 
> value, so take these suggestions with a grain of salt:
>   - test self-referential structs like `struct Node { struct Node *next; };`
>   - test comparing structs and forward declarations, e.g., `struct S;` and 
> `struct S { ... };`, and another couple `struct S { ... };` and `struct S; 
> struct S { ... };` The motivation is to make sure we aren't stumped when we 
> cannot find struct definition or when the definition is in unexpected place.

Ditto.

> Heads up in case it affects you refactoring work:
>  While looking through this code, I found a bug I previously made.  I fixed 
> it with a small change, but that lies in the middle of your refactoring 
> during FieldDecl handling.  The change is here:
> 
> https://reviews.llvm.org/rGa60e8927297005898b10a46300d929ba5cf7833c

Thanks for the heads up @rtrieu, I end up including that as part of 
rG90f58eaeff5f 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734



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


[PATCH] D65839: [Driver] Add verbatim dry run option

2020-01-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

One thing I (a zsh user) feel inconvenient about `-###` is that...

  % echo -###
  zsh: bad pattern: -###
  % echo '-###'
  -###


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65839



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


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-01-31 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: llvm/test/Transforms/Inline/devirtualize-4.ll:2
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S 
| FileCheck %s
+; UN: opt < %s -passes='default' -S | FileCheck %s
+

typo ? UN:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591



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


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-01-31 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 241852.
yamauchi added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update clang/test/CodeGenCXX/member-function-pointer-calls.cpp which this change
combined with D71308  enables 
inlining/simplification.

Add a new test that's derived from
clang/test/CodeGenCXX/member-function-pointer-calls.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591

Files:
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/devirtualize-4.ll

Index: llvm/test/Transforms/Inline/devirtualize-4.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S | FileCheck %s
+; UN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class Interface {
+; public:
+;  virtual void Run() = 0;
+;};
+;
+;class Impl : public Interface {
+; public:
+;  Impl() : f(3) {}
+;  void Run() { DoNotOptimize(this); }
+;
+; private:
+;  int f;
+;};
+;
+;static void IndirectRun(Interface& o) { o.Run(); }
+;
+;void Test() {
+;  Impl o;
+;  IndirectRun(o);
+;}
+
+%class.Impl = type <{ %class.Interface, i32, [4 x i8] }>
+%class.Interface = type { i32 (...)** }
+
+@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast (void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8
+@_ZTVN10__cxxabiv120__si_class_type_infoE = external dso_local global i8*
+@_ZTS4Impl = linkonce_odr dso_local constant [6 x i8] c"4Impl\00", align 1
+@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
+@_ZTS9Interface = linkonce_odr dso_local constant [11 x i8] c"9Interface\00", align 1
+@_ZTI9Interface = linkonce_odr dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @_ZTS9Interface, i32 0, i32 0) }, align 8
+@_ZTI4Impl = linkonce_odr dso_local constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Impl, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*) }, align 8
+@_ZTV9Interface = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI9Interface to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] }, align 8
+
+define dso_local void @_Z4Testv() local_unnamed_addr {
+entry:
+  %o = alloca %class.Impl, align 8
+  %0 = bitcast %class.Impl* %o to i8*
+  call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0)
+  call void @_ZN4ImplC2Ev(%class.Impl* nonnull %o)
+  %1 = getelementptr inbounds %class.Impl, %class.Impl* %o, i64 0, i32 0
+  call fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* nonnull dereferenceable(8) %1)
+  call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0)
+  ret void
+}
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN4ImplC2Ev(%class.Impl* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0
+  call void @_ZN9InterfaceC2Ev(%class.Interface* %0)
+  %1 = getelementptr %class.Impl, %class.Impl* %this, i64 0, i32 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Impl, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8
+  %f = getelementptr inbounds %class.Impl, %class.Impl* %this, i64 0, i32 1
+  store i32 3, i32* %f, align 8
+  ret void
+}
+
+define internal fastcc void @_ZL11IndirectRunR9Interface(%class.Interface* dereferenceable(8) %o) unnamed_addr {
+entry:
+  %0 = bitcast %class.Interface* %o to void (%class.Interface*)***
+  %vtable = load void (%class.Interface*)**, void (%class.Interface*)*** %0, align 8
+  %1 = load void (%class.Interface*)*, void (%class.Interface*)** %vtable, align 8
+  call void %1(%class.Interface* nonnull %o)
+  ret void
+}
+
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+define linkonce_odr dso_local void @_ZN9InterfaceC2Ev(%class.Interface* %this) unnamed_addr align 2 {
+entry:
+  %0 = getelementptr %class.Interface, %class.Interface* %this, i64 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV9Interface, i64 0, 

[clang] aade5fb - Fix wrong devirtualization when the final overrider in one base class

2020-01-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-31T17:06:48-08:00
New Revision: aade5fbbfef3e8555df202082bea905deebc2ca5

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

LOG: Fix wrong devirtualization when the final overrider in one base class
overrides the final overrider in a different base class.

Added: 


Modified: 
clang/lib/AST/CXXInheritance.cpp
clang/lib/AST/DeclCXX.cpp
clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp

Removed: 




diff  --git a/clang/lib/AST/CXXInheritance.cpp 
b/clang/lib/AST/CXXInheritance.cpp
index a3a3794b2edd..0377bd324cb6 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -758,6 +758,8 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap 
) const {
 return false;
   };
 
+  // FIXME: IsHidden reads from Overriding from the middle of a remove_if
+  // over the same sequence! Is this guaranteed to work?
   Overriding.erase(
   std::remove_if(Overriding.begin(), Overriding.end(), IsHidden),
   Overriding.end());

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 48e310e858b2..227fe80ccab4 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2038,17 +2038,36 @@ CXXMethodDecl::getCorrespondingMethodInClass(const 
CXXRecordDecl *RD,
   if (auto *MD = getCorrespondingMethodDeclaredInClass(RD, MayBeBase))
 return MD;
 
+  llvm::SmallVector FinalOverriders;
+  auto AddFinalOverrider = [&](CXXMethodDecl *D) {
+// If this function is overridden by a candidate final overrider, it is not
+// a final overrider.
+for (CXXMethodDecl *OtherD : FinalOverriders) {
+  if (declaresSameEntity(D, OtherD) || recursivelyOverrides(OtherD, D))
+return;
+}
+
+// Other candidate final overriders might be overridden by this function.
+FinalOverriders.erase(
+std::remove_if(FinalOverriders.begin(), FinalOverriders.end(),
+   [&](CXXMethodDecl *OtherD) {
+ return recursivelyOverrides(D, OtherD);
+   }),
+FinalOverriders.end());
+
+FinalOverriders.push_back(D);
+  };
+
   for (const auto  : RD->bases()) {
 const RecordType *RT = I.getType()->getAs();
 if (!RT)
   continue;
 const auto *Base = cast(RT->getDecl());
-CXXMethodDecl *T = this->getCorrespondingMethodInClass(Base);
-if (T)
-  return T;
+if (CXXMethodDecl *D = this->getCorrespondingMethodInClass(Base))
+  AddFinalOverrider(D);
   }
 
-  return nullptr;
+  return FinalOverriders.size() == 1 ? FinalOverriders.front() : nullptr;
 }
 
 CXXMethodDecl *CXXMethodDecl::Create(ASTContext , CXXRecordDecl *RD,
@@ -2105,6 +2124,11 @@ CXXMethodDecl 
*CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
   CXXMethodDecl *DevirtualizedMethod =
   getCorrespondingMethodInClass(BestDynamicDecl);
 
+  // If there final overrider in the dynamic type is ambiguous, we can't
+  // devirtualize this call.
+  if (!DevirtualizedMethod)
+return nullptr;
+
   // If that method is pure virtual, we can't devirtualize. If this code is
   // reached, the result would be UB, not a direct call to the derived class
   // function, and we can't assume the derived class function is defined.

diff  --git 
a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp 
b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
index 130103de97ae..6f5e844b587e 100644
--- a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -255,6 +255,49 @@ namespace Test10 {
   }
 }
 
+namespace TestVBase {
+  struct A { virtual void f(); };
+  struct B : virtual A {};
+  struct C : virtual A { void f() override; };
+
+  extern struct BC final : B, C {} 
+  extern struct BCusingA final : B, C { using A::f; } _using_a;
+  extern struct BCusingB final : B, C { using B::f; } _using_b;
+  extern struct BCusingC final : B, C { using C::f; } _using_c;
+
+  extern struct CB final : C, B {} 
+  extern struct CBusingA final : C, B { using A::f; } _using_a;
+  extern struct CBusingB final : C, B { using B::f; } _using_b;
+  extern struct CBusingC final : C, B { using C::f; } _using_c;
+
+  // CHECK-LABEL: @_ZN9TestVBase4testEv(
+  void test() {
+// FIXME: The 'using A' case can be devirtualized to call A's virtual
+// adjustment thunk for C::f.
+// FIXME: The 'using B' case can be devirtualized, but requires us to emit
+// a derived-to-base or base-to-derived conversion as part of
+// devirtualization.
+
+// CHECK: call void @_ZN9TestVBase1C1fEv(
+bc.f();
+// CHECK: call void %
+bc_using_a.f();
+// CHECK: call void %
+

[PATCH] D68520: [cmake] Fix clang builds with BUILD_SHARED=ON and CLANG_LINK_CLANG_DYLIB=ON

2020-01-31 Thread Tom Stellard via Phabricator via cfe-commits
tstellar requested review of this revision.
tstellar added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68520



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


[PATCH] D65839: [Driver] Add verbatim dry run option

2020-01-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

I'm fine with `-###-verbatim`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65839



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


[PATCH] D68923: Don't warn about missing declarations for partial template specializations

2020-01-31 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG27684ae66d55: Dont warn about missing declarations for 
partial template specializations (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/warn-missing-variable-declarations.cpp


Index: clang/test/SemaCXX/warn-missing-variable-declarations.cpp
===
--- clang/test/SemaCXX/warn-missing-variable-declarations.cpp
+++ clang/test/SemaCXX/warn-missing-variable-declarations.cpp
@@ -70,6 +70,8 @@
 template constexpr int const_var_template = 0;
 template static int static_var_template = 0;
 
+template int var_template;
+
 template int var_template;
 int use_var_template() { return var_template; }
 template int var_template;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12523,6 +12523,7 @@
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
   var->getLocation())) {


Index: clang/test/SemaCXX/warn-missing-variable-declarations.cpp
===
--- clang/test/SemaCXX/warn-missing-variable-declarations.cpp
+++ clang/test/SemaCXX/warn-missing-variable-declarations.cpp
@@ -70,6 +70,8 @@
 template constexpr int const_var_template = 0;
 template static int static_var_template = 0;
 
+template int var_template;
+
 template int var_template;
 int use_var_template() { return var_template; }
 template int var_template;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12523,6 +12523,7 @@
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
   var->getLocation())) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 27684ae - Don't warn about missing declarations for partial template specializations

2020-01-31 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2020-02-01T00:06:03+01:00
New Revision: 27684ae66d5545f211c0ac4393d0ba2bf3b5b47c

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

LOG: Don't warn about missing declarations for partial template specializations

Summary: Just like templates, they are excepted from the ODR rule.

Reviewed By: aaron.ballman, rsmith

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/warn-missing-variable-declarations.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e8589d3bcf44..2175361dab9a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12523,6 +12523,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl 
*var) {
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
   var->getLocation())) {

diff  --git a/clang/test/SemaCXX/warn-missing-variable-declarations.cpp 
b/clang/test/SemaCXX/warn-missing-variable-declarations.cpp
index e2480fd663b0..b50eeed30e7a 100644
--- a/clang/test/SemaCXX/warn-missing-variable-declarations.cpp
+++ b/clang/test/SemaCXX/warn-missing-variable-declarations.cpp
@@ -70,6 +70,8 @@ template int var_template = 0;
 template constexpr int const_var_template = 0;
 template static int static_var_template = 0;
 
+template int var_template;
+
 template int var_template;
 int use_var_template() { return var_template; }
 template int var_template;



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


[PATCH] D73810: [CMake][Fuchsia] Support for building on Windows

2020-01-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 241822.

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

https://reviews.llvm.org/D73810

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake

Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -13,6 +13,10 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 
+if(WIN32 AND NOT MINGW)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -29,8 +33,10 @@
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
-if (APPLE)
+if(APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(WIN32 AND NOT MINGW)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -49,8 +55,17 @@
 set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
-set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+if(WIN32 AND NOT MINGW)
+  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
+  set(LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG ON CACHE BOOL "")
+  set(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
+else()
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+endif()
 
 if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
   set(target "${BOOTSTRAP_CMAKE_CXX_COMPILER_TARGET}")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -18,6 +18,10 @@
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO ON CACHE BOOL "")
 
+if(WIN32 AND NOT MINGW)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -36,6 +40,8 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if (APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(WIN32 AND NOT MINGW)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -61,6 +67,17 @@
   set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "")
   set(DARWIN_osx_ARCHS x86_64 CACHE STRING "")
   set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "")
+elseif(WIN32 AND NOT MINGW)
+  list(APPEND BUILTIN_TARGETS "default")
+  list(APPEND RUNTIME_TARGETS "default")
+
+  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
+  set(LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG ON CACHE BOOL "")
+  set(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
 endif()
 
 foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
@@ -69,6 +86,9 @@
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -78,6 +98,9 @@
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -109,7 +132,7 @@
   set(FUCHSIA_x86_64_NAME x64)
   set(FUCHSIA_riscv64_NAME 

[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:1655
+TheCall->getArg(2)->isIntegerConstantExpr(I, Context);
+if (I.isNullValue())
+  break;

You can EvaluateKnownConstInt here, instead of isIntegerConstantExpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543



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


[PATCH] D73810: [CMake][Fuchsia] Support for building on Windows

2020-01-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: leonardchan, mcgrathr.
Herald added subscribers: cfe-commits, mstorsjo, jfb, mgorny.
Herald added a project: clang.

This change adds the necessary flags for building the full Fuchsia
toolchain on Windows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73810

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake

Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -13,6 +13,10 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 
+if(WIN32)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -29,8 +33,10 @@
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
-if (APPLE)
+if(APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(WIN32)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -49,8 +55,17 @@
 set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
-set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+if(WIN32 AND NOT MINGW)
+  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
+  set(LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG ON CACHE BOOL "")
+  set(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
+else()
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+endif()
 
 if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
   set(target "${BOOTSTRAP_CMAKE_CXX_COMPILER_TARGET}")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -18,6 +18,10 @@
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO ON CACHE BOOL "")
 
+if(WIN32)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -36,6 +40,8 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if (APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(WIN32)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -61,6 +67,17 @@
   set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "")
   set(DARWIN_osx_ARCHS x86_64 CACHE STRING "")
   set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "")
+elseif(WIN32 AND NOT MINGW)
+  list(APPEND BUILTIN_TARGETS "default")
+  list(APPEND RUNTIME_TARGETS "default")
+
+  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_MONOTONIC_CLOCK ON CACHE BOOL "")
+  set(LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG ON CACHE BOOL "")
+  set(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
 endif()
 
 foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
@@ -69,6 +86,9 @@
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -78,6 +98,9 @@
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 

[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2252
+
+ * ``__builtin_memcpy_inline``
+

This is in the wrong section of the documentation.  We could constant-evaluate 
__builtin_memcpy_inline, I guess, but that isn't the primary purpose, and your 
patch doesn't implement constant evaluation anyway.

Might make sense to add a new section, if no existing section makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543



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


[clang-tools-extra] c0f475f - Revert "[clang-doc] Improving Markdown Output"

2020-01-31 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-01-31T14:30:42-08:00
New Revision: c0f475f2e3c3304fb7fc116fdab7871f1d903810

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

LOG: Revert "[clang-doc] Improving Markdown Output"

This reverts commit deae8ee6916711b9b20f73fc1a350c3a034d5b34 as it
broke the build on several bots.

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/assets/index.js
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index dc569e2a482c..249d577e8580 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -314,9 +314,9 @@ genReference(const Reference , StringRef 
CurrentDirectory,
 else
   return genLink(Type.Name, "#" + JumpToSection.getValue());
   }
-  llvm::SmallString<64> Path = Type.getRelativeFilePath(CurrentDirectory);
-  llvm::sys::path::append(Path, Type.getFileBaseName() + ".html");
-
+  llvm::SmallString<128> Path =
+  computeRelativePath(Type.Path, CurrentDirectory);
+  llvm::sys::path::append(Path, Type.Name + ".html");
   // Paths in HTML must be in posix-style
   llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
   if (JumpToSection)
@@ -730,17 +730,15 @@ genHTML(const NamespaceInfo , Index , const 
ClangDocContext ,
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
-  llvm::SmallString<64> BasePath = I.getRelativeFilePath("");
-
   std::vector> ChildNamespaces =
-  genReferencesBlock(I.ChildNamespaces, "Namespaces", BasePath);
+  genReferencesBlock(I.ChildNamespaces, "Namespaces", I.Path);
   AppendVector(std::move(ChildNamespaces), Out);
   std::vector> ChildRecords =
-  genReferencesBlock(I.ChildRecords, "Records", BasePath);
+  genReferencesBlock(I.ChildRecords, "Records", I.Path);
   AppendVector(std::move(ChildRecords), Out);
 
   std::vector> ChildFunctions =
-  genFunctionsBlock(I.ChildFunctions, CDCtx, BasePath);
+  genFunctionsBlock(I.ChildFunctions, CDCtx, I.Path);
   AppendVector(std::move(ChildFunctions), Out);
   std::vector> ChildEnums =
   genEnumsBlock(I.ChildEnums, CDCtx);
@@ -862,8 +860,8 @@ llvm::Error HTMLGenerator::generateDocForInfo(Info *I, 
llvm::raw_ostream ,
"unexpected info type");
   }
 
-  HTMLFile F = genInfoFile(InfoTitle, I->getRelativeFilePath(""),
-   MainContentNodes, InfoIndex, CDCtx);
+  HTMLFile F =
+  genInfoFile(InfoTitle, I->Path, MainContentNodes, InfoIndex, CDCtx);
   F.Render(OS);
 
   return llvm::Error::success();
@@ -904,7 +902,7 @@ static llvm::Error SerializeIndex(ClangDocContext ) {
   J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
   J.attribute("Name", I.Name);
   J.attribute("RefType", getRefType(I.RefType));
-  J.attribute("Path", I.getRelativeFilePath(""));
+  J.attribute("Path", I.Path);
   J.attributeArray("Children", [&] {
 for (const Index  : I.Children)
   IndexToJSON(C);

diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index c8b517ffc53c..ff99c9001349 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -50,20 +50,10 @@ static void writeHeader(const Twine , unsigned int 
Num, raw_ostream ) {
   OS << std::string(Num, '#') + " " + Text << "\n\n";
 }
 
-static void writeFileDefinition(const ClangDocContext , const Location 
,
-raw_ostream ) {
-
-  if (!CDCtx.RepositoryUrl) {
-OS << "*Defined at " << L.Filename << "#" << std::to_string(L.LineNumber)
-   << "*";
-  } else {
-OS << "*Defined at [" << L.Filename << "#" << std::to_string(L.LineNumber)
-   << "](" << StringRef{CDCtx.RepositoryUrl.getValue()}
-   << llvm::sys::path::relative_path(L.Filename) << "#"
-   << std::to_string(L.LineNumber) << ")"
-   << "*";
-  }
-  OS << "\n\n";
+static void writeFileDefinition(const Location , raw_ostream ) {
+  OS << genItalic("Defined at line " + std::to_string(L.LineNumber) + " of " +
+  L.Filename)
+ << "\n\n";
 }
 
 static void writeDescription(const CommentInfo , raw_ostream ) {
@@ -114,16 +104,7 @@ static void writeDescription(const CommentInfo , 
raw_ostream ) {
   }
 }
 
-static void writeNameLink(const StringRef , const Reference ,
-  llvm::raw_ostream ) {
-
-  llvm::SmallString<64> Path = 

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-01-31 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdeae8ee69167: [clang-doc] Improving Markdown Output 
(authored by phosek).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -294,8 +294,9 @@
   }
 
   doc::Info *I = Reduced.get().get();
-  auto InfoPath = getInfoOutputFile(OutDirectory, I->Path, I->extractName(),
-"." + Format);
+  auto InfoPath =
+  getInfoOutputFile(OutDirectory, I->getRelativeFilePath(""),
+I->getFileBaseName(), "." + Format);
   if (!InfoPath) {
 llvm::errs() << toString(InfoPath.takeError()) << "\n";
 Error = true;
@@ -304,9 +305,9 @@
   std::error_code FileErr;
   llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr,
   llvm::sys::fs::OF_None);
-  if (FileErr != OK) {
-llvm::errs() << "Error opening info file: " << FileErr.message()
- << "\n";
+  if (FileErr) {
+llvm::errs() << "Error opening info file " << InfoPath.get() << ": "
+ << FileErr.message() << "\n";
 return;
   }
 
Index: clang-tools-extra/clang-doc/assets/index.js
===
--- clang-tools-extra/clang-doc/assets/index.js
+++ clang-tools-extra/clang-doc/assets/index.js
@@ -31,7 +31,11 @@
 
 function genLink(Ref, CurrentDirectory) {
   var Path = computeRelativePath(Ref.Path, CurrentDirectory);
-  Path = append(Path, Ref.Name + ".html")
+  if (Ref.RefType == "namespace")
+Path = append(Path, "index.html");
+  else
+Path = append(Path, Ref.Name + ".html")
+
   ANode = document.createElement("a");
   ANode.setAttribute("href", Path);
   var TextNode = document.createTextNode(Ref.Name);
Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -135,6 +135,12 @@
   bool mergeable(const Reference );
   void merge(Reference &);
 
+  /// Returns the path for this Reference relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Reference.
+  llvm::SmallString<16> getFileBaseName() const;
+
   SymbolID USR = SymbolID(); // Unique identifier for referenced decl
   SmallString<16> Name;  // Name of type (possibly unresolved).
   InfoType RefType = InfoType::IT_default; // Indicates the type of this
@@ -262,6 +268,12 @@
 
   llvm::SmallString<16> extractName() const;
 
+  /// Returns the file path for this Info relative to CurrentPath.
+  llvm::SmallString<64> getRelativeFilePath(const StringRef ) const;
+
+  /// Returns the basename that should be used for this Info.
+  llvm::SmallString<16> getFileBaseName() const;
+
   // Returns a reference to the parent scope (that is, the immediate parent
   // namespace or class in which this decl resides).
   llvm::Expected getEnclosingScope();
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -114,6 +114,52 @@
   }
 }
 
+static llvm::SmallString<64>
+calculateRelativeFilePath(const InfoType , const StringRef ,
+  const StringRef , const StringRef ) {
+  llvm::SmallString<64> FilePath;
+
+  if (CurrentPath != Path) {
+// iterate back to the top
+for (llvm::sys::path::const_iterator I =
+ llvm::sys::path::begin(CurrentPath);
+ I != llvm::sys::path::end(CurrentPath); ++I)
+  llvm::sys::path::append(FilePath, "..");
+llvm::sys::path::append(FilePath, Path);
+  }
+
+  // Namespace references have a Path to the parent namespace, but
+  // the file is actually in the subdirectory for the namespace.
+  if (Type == doc::InfoType::IT_namespace)
+llvm::sys::path::append(FilePath, Name);
+
+  return llvm::sys::path::relative_path(FilePath);
+}
+
+llvm::SmallString<64>
+Reference::getRelativeFilePath(const StringRef ) const {
+  return calculateRelativeFilePath(RefType, Path, Name, CurrentPath);
+}

[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15554
+LocatorChecker Checker;
+if (Checker.Visit(OrigExpr)) {
+  llvm::copy(Checker.getComponents(),

cchen wrote:
> ABataev wrote:
> > cchen wrote:
> > > ABataev wrote:
> > > > General question about several cases. How we're going to support them?
> > > > 1. (a ? b : c). 
> > > > 2. __builtin_choose_expr(a, b, c).
> > > > 3. a = b.
> > > > 4. a?:b
> > > > 5. __builtin_convertvector(x, ty)
> > > > 6. (int&)a
> > > > 7. v.xy, where v is an extended vector
> > > > 8. a.b, where b is a bitfield
> > > > 9. __builtin_bit_cast(v, ty)
> > > > 10. const_cast(a)
> > > > 11. dynamic_cast(a)
> > > > 12. reinterpret_cast
> > > > 13. static_cast
> > > > 14. typeid() (also is an lvalue).
> > > > 15. __uuidof(*comPtr)
> > > > 16. lambda calls
> > > > 17. User defined literals
> > > > 
> > > I think we could first evaluate the lvalue, and then pass the result of 
> > > `` to device? 
> > What do you mean when you say `evaluate lvalue`? In veneral, it can be 
> > evaluated at the runtime. Do you propose to implement dyic translation? It 
> > will definetely slow down the execution on the device.
> I mean evaluate lvalue before sending  to device. For example:
> ```
> int a, b;
> b = 5;
> #pragma omp target map(a = b) // assign b to a before sending `&(a=b)` to 
> device
> {
>a++;
> }
> ```
> Therefore, the above example have the same semantics as this:
> ```
> int a, b;
> b = 5;
> int  = (a=b)
> #pragma omp target map(c)
> {
>a++;
> }
> ```
Sure, we do this already, generally speaking. The main problem here is how to 
map the address and associate it with address on the device. We do it at the 
compile time, support of general lvalues requires runtime translation + special 
instrumentation of the device code for address translation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[clang-tools-extra] deae8ee - [clang-doc] Improving Markdown Output

2020-01-31 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-01-31T14:21:21-08:00
New Revision: deae8ee6916711b9b20f73fc1a350c3a034d5b34

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

LOG: [clang-doc] Improving Markdown Output

This change has two components. The moves the generated file
for a namespace to the directory named after the namespace in
a file named 'index.'. This greatly improves the browsing
experience since the index page is shown by default for a directory.

The second improves the markdown output by adding the links to the
referenced pages for children objects and the link back to the source
code.

Patch By: Clayton

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

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/assets/index.js
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 249d577e8580..dc569e2a482c 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -314,9 +314,9 @@ genReference(const Reference , StringRef 
CurrentDirectory,
 else
   return genLink(Type.Name, "#" + JumpToSection.getValue());
   }
-  llvm::SmallString<128> Path =
-  computeRelativePath(Type.Path, CurrentDirectory);
-  llvm::sys::path::append(Path, Type.Name + ".html");
+  llvm::SmallString<64> Path = Type.getRelativeFilePath(CurrentDirectory);
+  llvm::sys::path::append(Path, Type.getFileBaseName() + ".html");
+
   // Paths in HTML must be in posix-style
   llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
   if (JumpToSection)
@@ -730,15 +730,17 @@ genHTML(const NamespaceInfo , Index , const 
ClangDocContext ,
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
+  llvm::SmallString<64> BasePath = I.getRelativeFilePath("");
+
   std::vector> ChildNamespaces =
-  genReferencesBlock(I.ChildNamespaces, "Namespaces", I.Path);
+  genReferencesBlock(I.ChildNamespaces, "Namespaces", BasePath);
   AppendVector(std::move(ChildNamespaces), Out);
   std::vector> ChildRecords =
-  genReferencesBlock(I.ChildRecords, "Records", I.Path);
+  genReferencesBlock(I.ChildRecords, "Records", BasePath);
   AppendVector(std::move(ChildRecords), Out);
 
   std::vector> ChildFunctions =
-  genFunctionsBlock(I.ChildFunctions, CDCtx, I.Path);
+  genFunctionsBlock(I.ChildFunctions, CDCtx, BasePath);
   AppendVector(std::move(ChildFunctions), Out);
   std::vector> ChildEnums =
   genEnumsBlock(I.ChildEnums, CDCtx);
@@ -860,8 +862,8 @@ llvm::Error HTMLGenerator::generateDocForInfo(Info *I, 
llvm::raw_ostream ,
"unexpected info type");
   }
 
-  HTMLFile F =
-  genInfoFile(InfoTitle, I->Path, MainContentNodes, InfoIndex, CDCtx);
+  HTMLFile F = genInfoFile(InfoTitle, I->getRelativeFilePath(""),
+   MainContentNodes, InfoIndex, CDCtx);
   F.Render(OS);
 
   return llvm::Error::success();
@@ -902,7 +904,7 @@ static llvm::Error SerializeIndex(ClangDocContext ) {
   J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
   J.attribute("Name", I.Name);
   J.attribute("RefType", getRefType(I.RefType));
-  J.attribute("Path", I.Path);
+  J.attribute("Path", I.getRelativeFilePath(""));
   J.attributeArray("Children", [&] {
 for (const Index  : I.Children)
   IndexToJSON(C);

diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index ff99c9001349..c8b517ffc53c 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -50,10 +50,20 @@ static void writeHeader(const Twine , unsigned int 
Num, raw_ostream ) {
   OS << std::string(Num, '#') + " " + Text << "\n\n";
 }
 
-static void writeFileDefinition(const Location , raw_ostream ) {
-  OS << genItalic("Defined at line " + std::to_string(L.LineNumber) + " of " +
-  L.Filename)
- << "\n\n";
+static void writeFileDefinition(const ClangDocContext , const Location 
,
+raw_ostream ) {
+
+  if (!CDCtx.RepositoryUrl) {
+OS << "*Defined at " << L.Filename << "#" << std::to_string(L.LineNumber)
+   << "*";
+  } else {
+OS << "*Defined at [" << L.Filename << "#" << std::to_string(L.LineNumber)
+   << "](" << StringRef{CDCtx.RepositoryUrl.getValue()}
+   << llvm::sys::path::relative_path(L.Filename) << "#"
+   << std::to_string(L.LineNumber) << ")"
+   << "*";
+  }
+  

[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

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



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15554
+LocatorChecker Checker;
+if (Checker.Visit(OrigExpr)) {
+  llvm::copy(Checker.getComponents(),

ABataev wrote:
> cchen wrote:
> > ABataev wrote:
> > > General question about several cases. How we're going to support them?
> > > 1. (a ? b : c). 
> > > 2. __builtin_choose_expr(a, b, c).
> > > 3. a = b.
> > > 4. a?:b
> > > 5. __builtin_convertvector(x, ty)
> > > 6. (int&)a
> > > 7. v.xy, where v is an extended vector
> > > 8. a.b, where b is a bitfield
> > > 9. __builtin_bit_cast(v, ty)
> > > 10. const_cast(a)
> > > 11. dynamic_cast(a)
> > > 12. reinterpret_cast
> > > 13. static_cast
> > > 14. typeid() (also is an lvalue).
> > > 15. __uuidof(*comPtr)
> > > 16. lambda calls
> > > 17. User defined literals
> > > 
> > I think we could first evaluate the lvalue, and then pass the result of 
> > `` to device? 
> What do you mean when you say `evaluate lvalue`? In veneral, it can be 
> evaluated at the runtime. Do you propose to implement dyic translation? It 
> will definetely slow down the execution on the device.
I mean evaluate lvalue before sending  to device. For example:
```
int a, b;
b = 5;
#pragma omp target map(a = b) // assign b to a before sending `&(a=b)` to device
{
   a++;
}
```
Therefore, the above example have the same semantics as this:
```
int a, b;
b = 5;
int  = (a=b)
#pragma omp target map(c)
{
   a++;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[PATCH] D71092: [VFS] More consistent support for Windows

2020-01-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I was worried there would be more duplication. :) As far as rebuilding the 
wheel square goes, this seems totally reasonable. I had a question and a nit, 
though.




Comment at: llvm/lib/Support/VirtualFileSystem.cpp:-1113
+  sys::path::Style style = sys::path::Style::posix;
+  if (sys::path::is_absolute(WorkingDir.get(), sys::path::Style::windows)) {
+style = sys::path::Style::posix;

It looks like you assign posix style if the working directory has windows path 
style. Is that what you meant to do?



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1117
+  std::string Result = WorkingDir.get();
+  if (Result.empty() || Result.back() != sys::path::get_separator(style)[0]) {
+Result += sys::path::get_separator(style);

`Result.endswith(sys::path::get_separator(style))` saves a boolean condition


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

https://reviews.llvm.org/D71092



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


[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15554
+LocatorChecker Checker;
+if (Checker.Visit(OrigExpr)) {
+  llvm::copy(Checker.getComponents(),

cchen wrote:
> ABataev wrote:
> > General question about several cases. How we're going to support them?
> > 1. (a ? b : c). 
> > 2. __builtin_choose_expr(a, b, c).
> > 3. a = b.
> > 4. a?:b
> > 5. __builtin_convertvector(x, ty)
> > 6. (int&)a
> > 7. v.xy, where v is an extended vector
> > 8. a.b, where b is a bitfield
> > 9. __builtin_bit_cast(v, ty)
> > 10. const_cast(a)
> > 11. dynamic_cast(a)
> > 12. reinterpret_cast
> > 13. static_cast
> > 14. typeid() (also is an lvalue).
> > 15. __uuidof(*comPtr)
> > 16. lambda calls
> > 17. User defined literals
> > 
> I think we could first evaluate the lvalue, and then pass the result of 
> `` to device? 
What do you mean when you say `evaluate lvalue`? In veneral, it can be 
evaluated at the runtime. Do you propose to implement dyic translation? It will 
definetely slow down the execution on the device.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

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



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15554
+LocatorChecker Checker;
+if (Checker.Visit(OrigExpr)) {
+  llvm::copy(Checker.getComponents(),

ABataev wrote:
> General question about several cases. How we're going to support them?
> 1. (a ? b : c). 
> 2. __builtin_choose_expr(a, b, c).
> 3. a = b.
> 4. a?:b
> 5. __builtin_convertvector(x, ty)
> 6. (int&)a
> 7. v.xy, where v is an extended vector
> 8. a.b, where b is a bitfield
> 9. __builtin_bit_cast(v, ty)
> 10. const_cast(a)
> 11. dynamic_cast(a)
> 12. reinterpret_cast
> 13. static_cast
> 14. typeid() (also is an lvalue).
> 15. __uuidof(*comPtr)
> 16. lambda calls
> 17. User defined literals
> 
I think we could first evaluate the lvalue, and then pass the result of 
`` to device? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[clang] de876ad - [diagtree] Use a different color for unimplemented GCC diagnostic flags

2020-01-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-31T13:40:32-08:00
New Revision: de876adab0cb43b79ffc7c5e66cc9053accbb074

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

LOG: [diagtree] Use a different color for unimplemented GCC diagnostic flags
instead of the "enabled by default" color.

It may be technically correct to list unimplemented diagnostics as
"enabled by default" but it's quite misleading.

Added: 


Modified: 
clang/tools/diagtool/DiagnosticNames.h
clang/tools/diagtool/TreeView.cpp

Removed: 




diff  --git a/clang/tools/diagtool/DiagnosticNames.h 
b/clang/tools/diagtool/DiagnosticNames.h
index d8fd6401ef6b..f541e88577cc 100644
--- a/clang/tools/diagtool/DiagnosticNames.h
+++ b/clang/tools/diagtool/DiagnosticNames.h
@@ -76,11 +76,11 @@ namespace diagtool {
 return *this;
   }
 
-  bool operator==(group_iterator ) const {
+  bool operator==(const group_iterator ) const {
 return CurrentID == Other.CurrentID;
   }
 
-  bool operator!=(group_iterator ) const {
+  bool operator!=(const group_iterator ) const {
 return CurrentID != Other.CurrentID;
   }
 };

diff  --git a/clang/tools/diagtool/TreeView.cpp 
b/clang/tools/diagtool/TreeView.cpp
index 96951287cc4e..843bd377e574 100644
--- a/clang/tools/diagtool/TreeView.cpp
+++ b/clang/tools/diagtool/TreeView.cpp
@@ -36,6 +36,17 @@ class TreePrinter {
 return Diags.isIgnored(DiagID, SourceLocation());
   }
 
+  static bool unimplemented(const GroupRecord ) {
+if (!Group.diagnostics().empty())
+  return false;
+
+for (const GroupRecord  : Group.subgroups())
+  if (!unimplemented(GR))
+return false;
+
+return true;
+  }
+
   static bool enabledByDefault(const GroupRecord ) {
 for (const DiagnosticRecord  : Group.diagnostics()) {
   if (isIgnored(DR.DiagID))
@@ -53,7 +64,9 @@ class TreePrinter {
   void printGroup(const GroupRecord , unsigned Indent = 0) {
 out.indent(Indent * 2);
 
-if (enabledByDefault(Group))
+if (unimplemented(Group))
+  out << Colors::RED;
+else if (enabledByDefault(Group))
   out << Colors::GREEN;
 else
   out << Colors::YELLOW;
@@ -117,7 +130,9 @@ class TreePrinter {
 
   void showKey() {
 out << '\n' << Colors::GREEN << "GREEN" << Colors::RESET
-<< " = enabled by default\n\n";
+<< " = enabled by default";
+out << '\n' << Colors::RED << "RED" << Colors::RESET
+<< " = unimplemented (accepted for GCC compatibility)\n\n";
   }
 };
 



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


[clang] 42d4a55 - PR44723: Trigger return type deduction for operator<=>s whose return

2020-01-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-01-31T13:06:48-08:00
New Revision: 42d4a55f227a1cc78ab8071062d869abe88655d9

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

LOG: PR44723: Trigger return type deduction for operator<=>s whose return
types are needed to compute the return type of a defaulted operator<=>.

This raises the question of what to do if return type deduction fails.
The standard doesn't say, and implementations vary, so for now reject
that case eagerly to keep our options open.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/class/class.compare/class.spaceship/p2.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5e88c6ee86ab..7b3f591795bb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8397,6 +8397,12 @@ def note_defaulted_comparison_cannot_deduce : Note<
   "return type of defaulted 'operator<=>' cannot be deduced because "
   "return type %2 of three-way comparison for %select{|member|base class}0 %1 "
   "is not a standard comparison category type">;
+def err_defaulted_comparison_cannot_deduce_undeduced_auto : Error<
+  "return type of defaulted 'operator<=>' cannot be deduced because "
+  "three-way comparison for %select{|member|base class}0 %1 "
+  "has a deduced return type and is not yet defined">;
+def note_defaulted_comparison_cannot_deduce_undeduced_auto : Note<
+  "%select{|member|base class}0 %1 declared here">;
 def note_defaulted_comparison_cannot_deduce_callee : Note<
   "selected 'operator<=>' for %select{|member|base class}0 %1 declared here">;
 def err_incorrect_defaulted_comparison_constexpr : Error<

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 65526e4020cf..389b78dfcf85 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -7445,6 +7445,31 @@ class DefaultedComparisonAnalyzer
 
   if (OO == OO_Spaceship && FD->getReturnType()->isUndeducedAutoType()) {
 if (auto *BestFD = Best->Function) {
+  // If any callee has an undeduced return type, deduce it now.
+  // FIXME: It's not clear how a failure here should be handled. For
+  // now, we produce an eager diagnostic, because that is forward
+  // compatible with most (all?) other reasonable options.
+  if (BestFD->getReturnType()->isUndeducedType() &&
+  S.DeduceReturnType(BestFD, FD->getLocation(),
+ /*Diagnose=*/false)) {
+// Don't produce a duplicate error when asked to explain why the
+// comparison is deleted: we diagnosed that when initially checking
+// the defaulted operator.
+if (Diagnose == NoDiagnostics) {
+  S.Diag(
+  FD->getLocation(),
+  diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
+  << Subobj.Kind << Subobj.Decl;
+  S.Diag(
+  Subobj.Loc,
+  diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
+  << Subobj.Kind << Subobj.Decl;
+  S.Diag(BestFD->getLocation(),
+ diag::note_defaulted_comparison_cannot_deduce_callee)
+  << Subobj.Kind << Subobj.Decl;
+}
+return Result::deleted();
+  }
   if (auto *Info = S.Context.CompCategories.lookupInfoForType(
   BestFD->getCallResultType())) {
 R.Category = Info->Kind;

diff  --git a/clang/test/CXX/class/class.compare/class.spaceship/p2.cpp 
b/clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
index a912384ccf76..dae31e925ba1 100644
--- a/clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
+++ b/clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
@@ -97,6 +97,39 @@ namespace Deduction {
 
   // Check that the above mechanism works.
   template void f(); // expected-note 
{{instantiation of}}
+
+  std::strong_ordering x = A() <=> A();
+}
+
+namespace PR44723 {
+  // Make sure we trigger return type deduction for a callee 'operator<=>'
+  // before inspecting its return type.
+  template struct a {
+friend constexpr auto operator<=>(a const , a const ) {
+  return std::strong_ordering::equal;
+}
+  };
+  struct b {
+friend constexpr auto operator<=>(b const &, b const &) = default;
+a<0> m_value;
+  };
+  std::strong_ordering cmp_b = b() <=> b();
+
+  struct c {
+auto operator<=>(const c&) const&; // expected-note {{selected 
'operator<=>' for base class 'c' declared here}}
+  };
+  struct d : c { // 

[PATCH] D69978: Separately track input and output denormal mode

2020-01-31 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor accepted this revision.
andrew.w.kaylor added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D69978



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


[PATCH] D71092: [VFS] More consistent support for Windows

2020-01-31 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

Ping?


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

https://reviews.llvm.org/D71092



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-31 Thread Tony Lewis via Phabricator via cfe-commits
tonyelewis added a comment.

> Support for checking types should be either opt-in(or opt-out) but never 
> forced. I feel like it would generate too much noise.

Okey dokes. That option could always be added as another feature in the future. 
Thanks very much for all work on this.




Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

njames93 wrote:
> tonyelewis wrote:
> > njames93 wrote:
> > > gribozavr2 wrote:
> > > > njames93 wrote:
> > > > > gribozavr2 wrote:
> > > > > > njames93 wrote:
> > > > > > > gribozavr2 wrote:
> > > > > > > > This heuristic should be a lot more complex. In practice people 
> > > > > > > > have more complex naming conventions (for example, in Clang, 
> > > > > > > > Sema.h corresponds to many files named 
> > > > > > > > SemaSomethingSomething.cpp).
> > > > > > > > 
> > > > > > > > I think there is a high chance that checking only a header with 
> > > > > > > > a matching name will satisfy too few projects to be worth 
> > > > > > > > implementing.
> > > > > > > > 
> > > > > > > > On the other hand, if you could use C++ or Clang modules to 
> > > > > > > > narrow down the list of headers where the declaration should 
> > > > > > > > appear, that would be a much stronger signal.
> > > > > > > That is the reason I added the CheckAnyHeader option. For small 
> > > > > > > projects the matching name would be usually be enough, but for 
> > > > > > > big complex projects there is no feasible check that would work. 
> > > > > > > Falling back to making sure every external definition has a 
> > > > > > > declaration in at least one header will always be a good warning
> > > > > > That's the thing -- due to the lack of consistency in projects and 
> > > > > > style guides for C++, I think most projects will have to turn on 
> > > > > > CheckAnyHeader. We get implementation complexity in ClangTidy, 
> > > > > > false positives in high-profile projects, force users to configure 
> > > > > > ClangTidy to work well for their projects (unless we set 
> > > > > > CheckAnyHeader=1 by default... which then nobody would flip back to 
> > > > > > zero), and little benefit for end users.
> > > > > Would you say the best way would be check if the source file name 
> > > > > starts with the header file name by default. Or is that very specific 
> > > > > to Clang?
> > > > > 
> > > > > ```
> > > > > /// 
> > > > > #include "SomeHeader.h"
> > > > > ```
> > > > > This file would check for declarations in `SomeHeader.h`
> > > > > 
> > > > > Or maybe check if the header file name starts with the source file?
> > > > > 
> > > > > ```
> > > > > /// 
> > > > > #include "SomeHeaderImpl.h"
> > > > > ```
> > > > > This file would check for declarations in `SomeHeaderImpl.h`.
> > > > > Or even check both?
> > > > > Would you say the best way would be check if the source file name 
> > > > > starts with the header file name by default. Or is that very specific 
> > > > > to Clang?
> > > > 
> > > > I don't think it is too specific, it should cover many projects I think.
> > > > 
> > > > > Or maybe check if the header file name starts with the source file?
> > > > 
> > > > Seems like an unusual case to me, but I'm willing to be convinced 
> > > > otherwise.
> > > I thought it was an unusual case and wasn't thinking it would be a good 
> > > idea to add. I'll just set it up so that it will always look in header 
> > > files whose names appear at the start of the main source file.
> > FWIW, my instinct is that there are two separate questions:
> > 
> >  1. What sort of files should have their external-linkage definitions 
> > checked?
> >  2. What sort of included files should be part of the search for adequate 
> > declarations that match those definitions?
> > 
> > ...and that my answers, in reverse order, are:
> > 
> >  2. All included files should be included (ie a check for a given 
> > external-linkage definition should be appeased by _any_ matching 
> > declaration in _any_ included file)
> >  1. Only main files. And (to prevent lots of false-positives when the tool 
> > is run over headers), only "c", "cc", "cxx", "cpp" files by default but 
> > with an option to check in _all_ main files.
> > 
> > I think this has the merits that it:
> >  * allows users to put their valid declaration in files with any extension 
> > they like
> >  * defaults to only firing when run against c/cc/cxx/cpp files but provides 
> > the option to fire when run against a file with _any_ extension
> > 
> > 
> > So I propose that there be one option and it be as follows:
> > 
> > 
> > > .. option:: CheckExtDefnsInAllMainFiles
> > > 
> > > If set to `0` only check external-linkage definitions in main files with 
> > > typical source-file extensions ("c", "cc", "cxx", "cpp").
> > > If set to `1` check external linkage 

[PATCH] D73570: [FPEnv][X86] Platform-specific builtin constrained FP enablement

2020-01-31 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 241771.
kpn added a comment.

Address review comments: FMA tests are now run optimized. This changes where 
the FIXME lines are located.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73570

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/avx512f-builtins-constrained.c
  clang/test/CodeGen/fma-builtins-constrained.c
  clang/test/CodeGen/sse-builtins-constrained.c

Index: clang/test/CodeGen/sse-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/sse-builtins-constrained.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+
+#include 
+
+__m128 test_mm_sqrt_ps(__m128 x) {
+  // COMMON-LABEL: test_mm_sqrt_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtps
+  return _mm_sqrt_ps(x);
+}
+
+__m128 test_sqrt_ss(__m128 x) {
+  // COMMON-LABEL: test_sqrt_ss
+  // COMMONIR: extractelement <4 x float> {{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.sqrt.f32(float {{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.sqrt.f32(float {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtss
+  // COMMONIR: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
+  return _mm_sqrt_ss(x);
+}
+
Index: clang/test/CodeGen/fma-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/fma-builtins-constrained.c
@@ -0,0 +1,352 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -O -emit-llvm -o - | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -ffp-exception-behavior=strict -O -emit-llvm -o - | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -O -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -O -ffp-exception-behavior=strict -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+
+// FIXME: Several of these tests are broken when constrained.
+
+#include 
+
+__m128 test_mm_fmadd_ps(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ps
+  return _mm_fmadd_ps(a, b, c);
+}
+
+__m128d test_mm_fmadd_pd(__m128d a, __m128d b, __m128d c) {
+  // COMMON-LABEL: test_mm_fmadd_pd
+  // UNCONSTRAINED: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CONSTRAINED: call <2 x double> @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213pd
+  return _mm_fmadd_pd(a, b, c);
+}
+
+__m128 test_mm_fmadd_ss(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ss
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ss
+  // COMMONIR: insertelement <4 x float> %{{.*}}, float %{{.*}}, i64 0
+  return _mm_fmadd_ss(a, b, c);
+}
+
+__m128d test_mm_fmadd_sd(__m128d a, __m128d b, __m128d c) {
+  // COMMON-LABEL: test_mm_fmadd_sd
+  // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
+ 

[PATCH] D68923: Don't warn about missing declarations for partial template specializations

2020-01-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Sorry I missed this before now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923



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


Re: [clang] b7ce85a - [Concepts] Fix isDeclarationSpecifier to detect type-constraints correctly

2020-01-31 Thread Richard Smith via cfe-commits
On Fri, 31 Jan 2020, 10:08 Saar Raz via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Saar Raz
> Date: 2020-01-31T20:08:13+02:00
> New Revision: b7ce85a130789d23c69156f4b899962458d1f05d
>
> URL:
> https://github.com/llvm/llvm-project/commit/b7ce85a130789d23c69156f4b899962458d1f05d
> DIFF:
> https://github.com/llvm/llvm-project/commit/b7ce85a130789d23c69156f4b899962458d1f05d.diff
>
> LOG: [Concepts] Fix isDeclarationSpecifier to detect type-constraints
> correctly
>
> isDeclarationSpecifiers did not handle some cases of
> placeholder-type-specifiers with
> type-constraints, causing parsing bugs in abbreviated constructor
> templates.
>
> Add comprehensive handling of type-constraints to isDeclarationSpecifier.
>
> Added:
>
>
> Modified:
> clang/lib/Parse/ParseDecl.cpp
> clang/test/Parser/cxx2a-abbreviated-templates.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
> index 871ca2512598..af6e105ca61f 100644
> --- a/clang/lib/Parse/ParseDecl.cpp
> +++ b/clang/lib/Parse/ParseDecl.cpp
> @@ -5061,6 +5061,8 @@ bool Parser::isDeclarationSpecifier(bool
> DisambiguatingWithExpression) {
>  // recurse to handle whatever we get.
>  if (TryAnnotateTypeOrScopeToken())
>return true;
> +if (TryAnnotateTypeConstraint())
> +  return true;
>  if (Tok.is(tok::identifier))
>return false;
>
> @@ -5193,11 +5195,14 @@ bool Parser::isDeclarationSpecifier(bool
> DisambiguatingWithExpression) {
>
>  // placeholder-type-specifier
>case tok::annot_template_id: {
> -TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
> -return TemplateId->Kind == TNK_Concept_template &&
> +return isTypeConstraintAnnotation() &&
>  (NextToken().is(tok::kw_auto) ||
> NextToken().is(tok::kw_decltype));
>}
> -
> +  case tok::annot_cxxscope:
> +if (NextToken().is(tok::identifier) && TryAnnotateTypeConstraint())
> +  return true;
>

Our behaviour here (on invalid code) depends on whether we've already
annotated the type constraint (if not, we don't require the next token to
be auto/decltype). It'd be good to be consistent here.

Incidentally, if we see any kind of (possibly-qualified) identifier or
template-id followed by auto/decltype, I think we should classify it as a
decl-specifier to improve error recovery when there's a typo in a concept
name.

+return isTypeConstraintAnnotation() &&
> +GetLookAheadToken(2).isOneOf(tok::kw_auto, tok::kw_decltype);
>case tok::kw___declspec:
>case tok::kw___cdecl:
>case tok::kw___stdcall:
>
> diff  --git a/clang/test/Parser/cxx2a-abbreviated-templates.cpp
> b/clang/test/Parser/cxx2a-abbreviated-templates.cpp
> index e2b3803c807e..6562389f7676 100644
> --- a/clang/test/Parser/cxx2a-abbreviated-templates.cpp
> +++ b/clang/test/Parser/cxx2a-abbreviated-templates.cpp
> @@ -9,11 +9,36 @@ namespace ns {
>concept D = true;
>  }
>
> -void foo(C auto a,
> - C auto b,
> - ns::D auto c,
> - ns::D auto d,
> - const C auto e,
> - const C auto f,
> - const ns::D auto g,
> - const ns::D auto h);
> \ No newline at end of file
> +void foo1(C auto a,
> +  C auto b,
> +  ns::D auto c,
> +  ns::D auto d,
> +  const C auto e,
> +  const C auto f,
> +  const ns::D auto g,
> +  const ns::D auto h);
> +void foo2(C auto a);
> +void foo3(C auto b);
> +void foo4(ns::D auto c);
> +void foo5(ns::D auto d);
> +void foo6(const C auto e);
> +void foo7(const C auto f);
> +void foo8(const ns::D auto g);
> +void foo9(const ns::D auto h);
> +
> +struct S1 { S1(C auto a,
> +   C auto b,
> +   ns::D auto c,
> +   ns::D auto d,
> +   const C auto e,
> +   const C auto f,
> +   const ns::D auto g,
> +   const ns::D auto h); };
> +struct S2 { S2(C auto a); };
> +struct S3 { S3(C auto b); };
> +struct S4 { S4(ns::D auto c); };
> +struct S5 { S5(ns::D auto d); };
> +struct S6 { S6(const C auto e); };
> +struct S7 { S7(const C auto f); };
> +struct S8 { S8(const ns::D auto g); };
> +struct S9 { S9(const ns::D auto h); };
> \ 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62372 tests passed, 0 failed 
and 839 were skipped.

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 1 
warnings 
.
 0 of them are added as review comments below (why? 
).

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D73687: [AArch64][SVE] Add SVE2 intrinsics for complex integer dot product

2020-01-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D73687



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


[PATCH] D73580: [clang-tidy] rename_check.py: maintain alphabetical order in Renamed checks section

2020-01-31 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D73580#1852032 , @njames93 wrote:

> It looks good, but could you maybe create a child revision showing what it 
> looks like with a few checks renamed to make sure everything is all working 
> correctly.


I think it'll be easier to test script locally, since several (at least two) 
child revisions would be necessary. By the word, main script boy is borrowed 
from add_new_check.py, so difference only in section name and regular 
expression for entry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73580



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1808-1809
   Record.push_back(VE.getMetadataOrNullID(N->getType()));
+  if (M.getDwarfVersion() >= 5)
+Record.push_back(N->getDefault());
   Record.push_back(VE.getMetadataOrNullID(N->getValue()));

awpandey wrote:
> dblaikie wrote:
> > I don't think we should be using the DWARF version to decide on the schema 
> > - there's no other use of that technique in the parsing/writing code & I 
> > can think of some ways it might go poorly.
> > 
> > Better to encode it & it can be dropped during actual DWARF emission in the 
> > backend if the version doesn't support it.
> I am doing this for making record structure consistent with previous dwarf 
> version.
There's no need/desire to make the record structure consistent with previous 
versions of DWARF.

The only consistency we have is the bitcode backwards compatibility itself.

Please remove these DWARFv5 tests.


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

https://reviews.llvm.org/D73462



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


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If it's reasonable to persist the failure kind, that would probably be good, 
but it might be a lot of work.


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

https://reviews.llvm.org/D73360



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


[clang] b7ce85a - [Concepts] Fix isDeclarationSpecifier to detect type-constraints correctly

2020-01-31 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-01-31T20:08:13+02:00
New Revision: b7ce85a130789d23c69156f4b899962458d1f05d

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

LOG: [Concepts] Fix isDeclarationSpecifier to detect type-constraints correctly

isDeclarationSpecifiers did not handle some cases of 
placeholder-type-specifiers with
type-constraints, causing parsing bugs in abbreviated constructor templates.

Add comprehensive handling of type-constraints to isDeclarationSpecifier.

Added: 


Modified: 
clang/lib/Parse/ParseDecl.cpp
clang/test/Parser/cxx2a-abbreviated-templates.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 871ca2512598..af6e105ca61f 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5061,6 +5061,8 @@ bool Parser::isDeclarationSpecifier(bool 
DisambiguatingWithExpression) {
 // recurse to handle whatever we get.
 if (TryAnnotateTypeOrScopeToken())
   return true;
+if (TryAnnotateTypeConstraint())
+  return true;
 if (Tok.is(tok::identifier))
   return false;
 
@@ -5193,11 +5195,14 @@ bool Parser::isDeclarationSpecifier(bool 
DisambiguatingWithExpression) {
 
 // placeholder-type-specifier
   case tok::annot_template_id: {
-TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
-return TemplateId->Kind == TNK_Concept_template &&
+return isTypeConstraintAnnotation() &&
 (NextToken().is(tok::kw_auto) || NextToken().is(tok::kw_decltype));
   }
-
+  case tok::annot_cxxscope:
+if (NextToken().is(tok::identifier) && TryAnnotateTypeConstraint())
+  return true;
+return isTypeConstraintAnnotation() &&
+GetLookAheadToken(2).isOneOf(tok::kw_auto, tok::kw_decltype);
   case tok::kw___declspec:
   case tok::kw___cdecl:
   case tok::kw___stdcall:

diff  --git a/clang/test/Parser/cxx2a-abbreviated-templates.cpp 
b/clang/test/Parser/cxx2a-abbreviated-templates.cpp
index e2b3803c807e..6562389f7676 100644
--- a/clang/test/Parser/cxx2a-abbreviated-templates.cpp
+++ b/clang/test/Parser/cxx2a-abbreviated-templates.cpp
@@ -9,11 +9,36 @@ namespace ns {
   concept D = true;
 }
 
-void foo(C auto a,
- C auto b,
- ns::D auto c,
- ns::D auto d,
- const C auto e,
- const C auto f,
- const ns::D auto g,
- const ns::D auto h);
\ No newline at end of file
+void foo1(C auto a,
+  C auto b,
+  ns::D auto c,
+  ns::D auto d,
+  const C auto e,
+  const C auto f,
+  const ns::D auto g,
+  const ns::D auto h);
+void foo2(C auto a);
+void foo3(C auto b);
+void foo4(ns::D auto c);
+void foo5(ns::D auto d);
+void foo6(const C auto e);
+void foo7(const C auto f);
+void foo8(const ns::D auto g);
+void foo9(const ns::D auto h);
+
+struct S1 { S1(C auto a,
+   C auto b,
+   ns::D auto c,
+   ns::D auto d,
+   const C auto e,
+   const C auto f,
+   const ns::D auto g,
+   const ns::D auto h); };
+struct S2 { S2(C auto a); };
+struct S3 { S3(C auto b); };
+struct S4 { S4(ns::D auto c); };
+struct S5 { S5(ns::D auto d); };
+struct S6 { S6(const C auto e); };
+struct S7 { S7(const C auto f); };
+struct S8 { S8(const ns::D auto g); };
+struct S9 { S9(const ns::D auto h); };
\ 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] D71033: [analyzer] CERT: STR32-C

2020-01-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 241761.
Charusso added a comment.

- Rebase.


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

https://reviews.llvm.org/D71033

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-notes-warn-on-call-off.cpp
  clang/test/Analysis/cert/str31-c-notes-warn-on-call-on.cpp
  clang/test/Analysis/cert/str32-c-notes.cpp
  clang/test/Analysis/cert/str32-c.cpp
  clang/test/Analysis/malloc.c

Index: clang/test/Analysis/malloc.c
===
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -9,21 +9,6 @@
 
 void clang_analyzer_eval(int);
 
-// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
-// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
-// the builtin type: "Using the typedef version can cause portability
-// problems", but we're ok here because we're not actually running anything.
-// Also of note is this cryptic warning: "The wchar_t type is not supported
-// when you compile C code".
-//
-// See the docs for more:
-// https://msdn.microsoft.com/en-us/library/dh8che7s.aspx
-#if !defined(_WCHAR_T_DEFINED)
-// "Microsoft implements wchar_t as a two-byte unsigned value"
-typedef unsigned short wchar_t;
-#define _WCHAR_T_DEFINED
-#endif // !defined(_WCHAR_T_DEFINED)
-
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *alloca(size_t);
Index: clang/test/Analysis/cert/str32-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str32-c.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.32c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR32-C:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR32-C.+Do+not+pass+a+non-null-terminated+character+sequence+to+a+library+function+that+expects+a+string
+
+#include "../Inputs/system-header-simulator.h"
+
+void *realloc(void *memblock, size_t size);
+
+namespace test_strncpy_bad {
+enum { STR_SIZE = 32 };
+
+size_t func(const char *source) {
+  char c_str[STR_SIZE];
+  size_t ret = 0;
+
+  if (source) {
+c_str[sizeof(c_str) - 1] = '\0';
+strncpy(c_str, source, sizeof(c_str));
+ret = strlen(c_str);
+// expected-warning@-1 {{'c_str' is not null-terminated}}
+  }
+  return ret;
+}
+} // namespace test_strncpy_bad
+
+namespace test_strncpy_good {
+enum { STR_SIZE = 32 };
+
+size_t func(const char *src) {
+  char c_str[STR_SIZE];
+  size_t ret = 0;
+
+  if (src) {
+strncpy(c_str, src, sizeof(c_str) - 1);
+c_str[sizeof(c_str) - 1] = '\0';
+ret = strlen(c_str);
+  }
+  return ret;
+}
+} // namespace test_strncpy_good
+
+namespace test_realloc_bad {
+wchar_t *cur_msg = NULL;
+size_t cur_msg_size = 1024;
+size_t cur_msg_len = 0;
+
+void lessen_memory_usage(void) {
+  if (cur_msg == NULL)
+return;
+
+  size_t temp_size = cur_msg_size / 2 + 1;
+  wchar_t *temp = (wchar_t *)realloc(cur_msg, temp_size * sizeof(wchar_t));
+  /* temp and cur_msg may no longer be null-terminated */
+  if (temp == NULL)
+return;
+
+  cur_msg = temp;
+  cur_msg_size = temp_size;
+  cur_msg_len = wcslen(cur_msg);
+  // expected-warning@-1 {{'cur_msg' is not null-terminated}}
+}
+} // namespace test_realloc_bad
+
+namespace test_realloc_good {
+wchar_t *cur_msg = NULL;
+size_t cur_msg_size = 1024;
+size_t cur_msg_len = 0;
+
+void lessen_memory_usage(void) {
+  if (cur_msg == NULL)
+return;
+
+  size_t temp_size = cur_msg_size / 2 + 1;
+  wchar_t *temp = (wchar_t *)realloc(cur_msg, temp_size * sizeof(wchar_t));
+  /* temp and cur_msg may no longer be null-terminated */
+  if (temp == NULL)
+return;
+
+  cur_msg = temp;
+  /* Properly null-terminate cur_msg */
+  cur_msg[temp_size - 1] = L'\0';
+  cur_msg_size = temp_size;
+  cur_msg_len = wcslen(cur_msg);
+}
+} // namespace test_realloc_good
Index: clang/test/Analysis/cert/str32-c-notes.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str32-c-notes.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.32c \
+// RUN:  -analyzer-output=text -verify %s
+
+// See the examples on the page of STR32-C:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR32-C.+Do+not+pass+a+non-null-terminated+character+sequence+to+a+library+function+that+expects+a+string
+
+#include "../Inputs/system-header-simulator.h"
+
+void *realloc(void *memblock, size_t size);
+
+namespace test_strncpy_bad {
+enum { STR_SIZE = 32 };
+
+size_t func(const char *source) {
+  char c_str[STR_SIZE];
+  // expected-note@-1 {{'c_str' is 

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-31 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In D73462#1851129 , @awpandey wrote:

> @aprantl Thanks for your valuable feedback.
>
> I have a doubt. You need a .ll file its corresponding llvm bytecode generated 
> by current llvm (without my patch). Doest this ll file includes any checks? 
> In the round trip test case I have to do llvm-as followed by llvm-dis then 
> performs checks or something else?


For an example of a bitcode upgrade test check out
https://github.com/llvm/llvm-project/blob/master/llvm/test/Bitcode/DIExpression-4.0.ll
https://github.com/llvm/llvm-project/blob/master/llvm/test/Bitcode/DIExpression-4.0.ll.bc

for example of a round-trip test check out
https://github.com/llvm/llvm-project/blob/master/llvm/test/Assembler/dicompileunit.ll


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

https://reviews.llvm.org/D73462



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


[PATCH] D70805: [analyzer] SValHasDescendant: Determine whether the SVal has an SVal descendant

2020-01-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 241758.
Charusso marked an inline comment as done.
Charusso added a comment.

- Rebase.


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

https://reviews.llvm.org/D70805

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValHasDescendant.h
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/cert/str31-c-warn-on-call-off.cpp
  clang/test/Analysis/cert/str31-c-warn-on-call-on.cpp
  clang/test/Analysis/sval-has-desc.c

Index: clang/test/Analysis/sval-has-desc.c
===
--- /dev/null
+++ clang/test/Analysis/sval-has-desc.c
@@ -0,0 +1,23 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,debug.ExprInspection \
+// RUN:  -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void clang_analyzer_hasDescendantTrue(size_t, const char *);
+void clang_analyzer_hasDescendantFalse(const char *, size_t);
+void clang_analyzer_hasDescendantEquals(const char *, const char *);
+
+void test_desc(const char *src) {
+  size_t size = strlen(src);
+  clang_analyzer_hasDescendantTrue(size, src); // expected-warning {{TRUE}}
+}
+
+void test_non_desc(const char *src) {
+  size_t size = strlen(src);
+  clang_analyzer_hasDescendantFalse(src, size); // expected-warning {{FALSE}}
+}
+
+void test_equality_is_desc(const char *src) {
+  clang_analyzer_hasDescendantEquals(src, src); // expected-warning {{TRUE}}
+}
Index: clang/test/Analysis/cert/str31-c-warn-on-call-on.cpp
===
--- clang/test/Analysis/cert/str31-c-warn-on-call-on.cpp
+++ clang/test/Analysis/cert/str31-c-warn-on-call-on.cpp
@@ -39,7 +39,6 @@
   dest = (char *)malloc(size * 2 + 2);
 
   strcpy(dest, [13]);
-  // expected-warning@-1 {{'strcpy' could write outside of 'dest'}}
   free(dest);
 }
 
@@ -52,7 +51,6 @@
   dest = (char *)malloc(size * 2);
 
   strcpy(dest, [13]);
-  // expected-warning@-1 {{'strcpy' could write outside of 'dest'}}
   free(dest);
 }
 
Index: clang/test/Analysis/cert/str31-c-warn-on-call-off.cpp
===
--- clang/test/Analysis/cert/str31-c-warn-on-call-off.cpp
+++ clang/test/Analysis/cert/str31-c-warn-on-call-off.cpp
@@ -92,7 +92,6 @@
   free(dest); // no-warning
 }
 
-// FIXME: Suppress that with 'SValVisitor' or something similar.
 void test_complex_size_false_positive(const char *src) {
   char *dest;
   size_t size;
@@ -102,8 +101,6 @@
 
   strcpy(dest, [13]);
   do_something(dest);
-  // expected-warning@-1 {{'dest' is not null-terminated}}
-
   free(dest);
 }
 
@@ -117,8 +114,6 @@
 
   strcpy(dest, [13]);
   do_something(dest);
-  // expected-warning@-1 {{'dest' is not null-terminated}}
-
   free(dest);
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
@@ -27,6 +27,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValHasDescendant.h"
 #include "llvm/ADT/Optional.h"
 #include 
 
@@ -244,16 +245,11 @@
   DefinedOrUnknownSVal DestSize = getDynamicSize(State, DestMR, SVB);
 
   // 'strlen(src) + integer' is most likely fine.
-  // FIXME: Use the 'SValVisitor' to catch every such constructs of the symbol.
   // FIXME: We cannot catch every '+ integer' part at the moment so we do not
   // check that property for now.
-  if (const SymExpr *SE = DestSize.getAsSymExpr())
-for (const auto  : SE->symbols())
-  if (const auto *SIE = dyn_cast(Sym))
-if (SIE->getOpcode() == BO_Add)
-  if (const auto *SM = dyn_cast(SIE->getLHS()))
-if (SM->getRegion() == SrcMR)
-  return;
+  SValHasDescendant HasDescendantSrc(SrcMR);
+  if (HasDescendantSrc.Visit(DestSize))
+return;
 
   // 'StringRegion' returns the size with the null-terminator.
   if (const llvm::APSInt *SrcSizeInt = SVB.getKnownValue(State, SrcSize))
Index: clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValHasDescendant.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -41,6 +42,7 @@
   void 

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-01-31 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 241757.
bader added a comment.

Applied suggestion from Ruyman.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/sycl.c
  clang/test/Preprocessor/sycl-macro.cpp

Index: clang/test/Preprocessor/sycl-macro.cpp
===
--- clang/test/Preprocessor/sycl-macro.cpp
+++ clang/test/Preprocessor/sycl-macro.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 %s -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -sycl-std=2015 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL,CHECK-SYCL-STD %s
 
 // CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
+// CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121
+// CHECK-SYCL-STD:#define CL_SYCL_LANGUAGE_VERSION 121
 // CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1
Index: clang/test/Driver/sycl.c
===
--- /dev/null
+++ clang/test/Driver/sycl.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
+
+// DEFAULT: "-fsycl-is-device"
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -450,6 +450,18 @@
 if (LangOpts.FastRelaxedMath)
   Builder.defineMacro("__FAST_RELAXED_MATH__");
   }
+
+  // SYCL Version is set to a value when building SYCL applications
+  switch (LangOpts.getSYCLVersion()) {
+  case LangOptions::SYCLVersionList::SYCL_2015:
+Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
+break;
+  case LangOptions::SYCLVersionList::undefined:
+  default:
+// This is not a SYCL source, nothing to add
+break;
+  }
+
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2545,6 +2545,25 @@
   LangStd = OpenCLLangStd;
   }
 
+  // -sycl-std applies to any SYCL source, not only those containing kernels,
+  // but also those using the SYCL API
+  if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
+Opts.setSYCLVersion(
+llvm::StringSwitch(A->getValue())
+.Cases("2015", "1.2.1", "121", "sycl-1.2.1",
+   LangOptions::SYCLVersionList::SYCL_2015)
+.Default(LangOptions::SYCLVersionList::undefined));
+
+if (Opts.getSYCLVersion() == LangOptions::SYCLVersionList::undefined) {
+  // User has passed an invalid value to the flag, this is an error
+  Diags.Report(diag::err_drv_invalid_value)
+  << A->getAsString(Args) << A->getValue();
+}
+  } else if (Args.hasArg(options::OPT_fsycl_is_device) ||
+ Args.hasArg(options::OPT_fsycl)) {
+Opts.setSYCLVersion(LangOptions::SYCLVersionList::SYCL_2015);
+  }
+
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4010,6 +4010,18 @@
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
   }
 
+  bool IsSYCL = Args.hasArg(options::OPT_fsycl);
+  if (IsSYCL) {
+CmdArgs.push_back("-fsycl-is-device");
+  }
+
+  if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) {
+A->render(Args, CmdArgs);
+  } else if (IsSYCL) {
+// Ensure the default version in SYCL mode is 1.2.1
+CmdArgs.push_back("-sycl-std=1.2.1");
+  }
+
   if (IsOpenMPDevice) {
 // We have to pass the triple of the host if compiling for an OpenMP device.
 std::string NormalizedTriple =
@@ -5259,6 +5271,9 @@
options::OPT_fno_hip_new_launch_api, false))
 CmdArgs.push_back("-fhip-new-launch-api");
 
+  // Forward -sycl-std option to -cc1
+  Args.AddLastArg(CmdArgs, options::OPT_sycl_std_EQ);
+
   if (Arg *A = 

[PATCH] D70805: [analyzer] SValHasDescendant: Determine whether the SVal has an SVal descendant

2020-01-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 2 inline comments as done.
Charusso added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValHasDescendant.h:55
+  bool VisitSymbolRegionValue(const SymbolRegionValue *S) {
+return Visit(S->getRegion());
+  }

NoQ wrote:
> Arithmetic is indeed easy, but for example this part requires a much deeper 
> justification.
Well, this is an experiment. I have checked out the Clang Tidy's 
matcher-writing language's framework so I believe their own language is way 
more better, than implementing `hasDescendant()` only. Some kind of framework 
would be neat, but this is what I came up with as the `hasDescendant()` is the 
most powerful matcher in their world.


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

https://reviews.llvm.org/D70805



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-01-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 241752.
Charusso edited the summary of this revision.
Charusso added a comment.

- 2020-ify the checker writing
- Remove extra bullet-points of CERT checker documentation: we only need the 
checker's documentation, not the packages.


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

https://reviews.llvm.org/D70411

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/cert/str31-c-notes-warn-on-call-off.cpp
  clang/test/Analysis/cert/str31-c-notes-warn-on-call-on.cpp
  clang/test/Analysis/cert/str31-c-warn-on-call-off.cpp
  clang/test/Analysis/cert/str31-c-warn-on-call-on.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,196 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.31c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31-C:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator
+
+#include "../Inputs/system-header-simulator.h"
+
+#define EOF -1
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+void do_something(char *buffer);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+// expected-warning@-1 {{'gets' could write outside of 'buf'}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+  // expected-warning@-1 {{'sprintf' could write outside of 'buf'}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+
+  do_something(buff);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  if (fscanf(stdin, "%s", buf)) {
+// expected-warning@-1 {{'fscanf' could write outside of 'buf'}}
+  }
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  if (fscanf(stdin, "%1023s", buff)) {
+do_something(buff);
+  }
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+  // expected-warning@-1 {{'strcpy' could write outside of 'prog_name'}}
+
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+// expected-warning@-1 {{'strcpy' could write outside of 'buff'}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  do_something(prog_name2);
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+do_something(buff2);
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following are from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] 

[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2020-01-31 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 241749.
Charusso edited the summary of this revision.
Charusso added a comment.

- Let us reuse this patch.
- Remove the expression storing feature.
- Only store known sizes.


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

https://reviews.llvm.org/D69726

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,15 +10,16 @@
 //
 //===--===//
 
-#include "clang/AST/Decl.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -690,16 +691,18 @@
 
 // See if we need to conjure a heap pointer instead of
 // a regular unknown pointer.
-bool IsHeapPointer = false;
-if (const auto *CNE = dyn_cast(E))
-  if (CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
-// FIXME: Delegate this to evalCall in MallocChecker?
-IsHeapPointer = true;
-  }
-
-R = IsHeapPointer ? svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count)
-  : svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy,
- Count);
+const auto *CNE = dyn_cast(E);
+if (CNE && CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  // FIXME: Delegate this to evalCall in MallocChecker?
+  DefinedOrUnknownSVal Size = UnknownVal();
+  if (const Expr *SizeExpr = CNE->getArraySize().getValueOr(nullptr))
+Size = State->getSVal(SizeExpr, LCtx).castAs();
+
+  R = svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count);
+  State = setDynamicSize(State, R.getAsRegion(), Size);
+} else {
+  R = svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy, Count);
+}
   }
   return State->BindExpr(E, LCtx, R);
 }
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -10,15 +10,16 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 
 using namespace clang;
 using namespace ento;
@@ -761,11 +762,17 @@
   // heap. We realize this is an approximation that might not correctly model
   // a custom global allocator.
   if (symVal.isUnknown()) {
-if (IsStandardGlobalOpNewFunction)
+if (IsStandardGlobalOpNewFunction) {
+  DefinedOrUnknownSVal Size = UnknownVal();
+  if (const Expr *SizeExpr = CNE->getArraySize().getValueOr(nullptr))
+Size = State->getSVal(SizeExpr, LCtx).castAs();
+
   symVal = svalBuilder.getConjuredHeapSymbolVal(CNE, LCtx, blockCount);
-else
+  State = setDynamicSize(State, symVal.getAsRegion(), Size);
+} else {
   symVal = svalBuilder.conjureSymbolVal(nullptr, CNE, LCtx, CNE->getType(),
 blockCount);
+}
   }
 
   CallEventManager  = getStateManager().getCallEventManager();
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- 

[PATCH] D61716: [libclang] Expose AtomicType

2020-01-31 Thread Henry Jen via Phabricator via cfe-commits
slowhog updated this revision to Diff 241747.
slowhog added a reviewer: aaron.ballman.
slowhog added a comment.

Updated to latest


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61716

Files:
  clang/include/clang-c/Index.h
  clang/test/Index/print-type.c
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CXType.cpp
  clang/tools/libclang/libclang.exports

Index: clang/tools/libclang/libclang.exports
===
--- clang/tools/libclang/libclang.exports
+++ clang/tools/libclang/libclang.exports
@@ -109,6 +109,7 @@
 clang_Type_getObjCTypeArg
 clang_Type_getModifiedType
 clang_Type_getNullability
+clang_Type_getValueType
 clang_VerbatimBlockLineComment_getText
 clang_VerbatimLineComment_getText
 clang_HTMLTagComment_getAsString
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -115,6 +115,7 @@
 TKCASE(Elaborated);
 TKCASE(Pipe);
 TKCASE(Attributed);
+TKCASE(Atomic);
 default:
   return CXType_Unexposed;
   }
@@ -616,6 +617,7 @@
 TKIND(OCLEvent);
 TKIND(OCLQueue);
 TKIND(OCLReserveID);
+TKIND(Atomic);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -1318,3 +1320,13 @@
   }
   return CXTypeNullability_Invalid;
 }
+
+CXType clang_Type_getValueType(CXType CT) {
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP && TP->getTypeClass() == Type::Atomic)
+return MakeCXType(cast(TP)->getValueType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -1579,6 +1579,13 @@
 PrintTypeTemplateArgs(CT, " [canonicaltemplateargs/%d=");
   }
 }
+/* Print the value type if it exists. */
+{
+  CXType VT = clang_Type_getValueType(T);
+  if (VT.kind != CXType_Invalid) {
+PrintTypeAndTypeKind(VT, " [valuetype=%s] [valuetypekind=%s]");
+  }
+}
 /* Print the modified type if it exists. */
 {
   CXType MT = clang_Type_getModifiedType(T);
Index: clang/test/Index/print-type.c
===
--- clang/test/Index/print-type.c
+++ clang/test/Index/print-type.c
@@ -22,13 +22,15 @@
 
 struct {
   struct {
-int x;
+_Atomic int x;
 int y;
   };
 } bar;
 
 void fun(struct { int x; int y; } *param);
 
+_Atomic(unsigned long) aul;
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -70,4 +72,7 @@
 // CHECK: StructDecl=:18:1 (Definition) [type=struct (anonymous at {{.*}}print-type.c:18:1)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0]
 // CHECK: StructDecl=:23:1 (Definition) [type=struct (anonymous at {{.*}}print-type.c:23:1)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1] [isAnonRecDecl=0]
 // CHECK: StructDecl=:24:3 (Definition) [type=struct (anonymous at {{.*}}print-type.c:24:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=1]
+// CHECK: FieldDecl=x:25:17 (Definition) [type=_Atomic(int)] [typekind=Atomic] [valuetype=int] [valuetypekind=Int] [isPOD=0] [isAnonRecDecl=0]
+// CHECK: FieldDecl=y:26:9 (Definition) [type=int] [typekind=Int] [isPOD=1] [isAnonRecDecl=0]
 // CHECK: StructDecl=:30:10 (Definition) [type=struct (anonymous at {{.*}}print-type.c:30:10)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0]
+// CHECK: VarDecl=aul:32:24 [type=_Atomic(unsigned long)] [typekind=Atomic] [valuetype=unsigned long] [valuetypekind=ULong] [isPOD=0] [isAnonRecDecl=0]
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -33,7 +33,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 59
+#define CINDEX_VERSION_MINOR 60
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3360,7 +3360,8 @@
 
   CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
 
-  CXType_ExtVector = 176
+  CXType_ExtVector = 176,
+  

[PATCH] D73715: - Update .clang-tidy to ignore parameters of main like functions for naming violations in clang and llvm directory

2020-01-31 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf99133e853bf: - Update .clang-tidy to ignore parameters of 
main like functions for naming… (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73715

Files:
  .clang-tidy
  clang/.clang-tidy
  llvm/.clang-tidy


Index: llvm/.clang-tidy
===
--- llvm/.clang-tidy
+++ llvm/.clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: clang/.clang-tidy
===
--- clang/.clang-tidy
+++ clang/.clang-tidy
@@ -19,4 +19,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 


Index: llvm/.clang-tidy
===
--- llvm/.clang-tidy
+++ llvm/.clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: clang/.clang-tidy
===
--- clang/.clang-tidy
+++ clang/.clang-tidy
@@ -19,4 +19,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f99133e - - Update .clang-tidy to ignore parameters of main like functions for naming violations in clang and llvm directory

2020-01-31 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-01-31T16:49:45Z
New Revision: f99133e853bfd2456b334e70933ec0403ad512d6

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

LOG: - Update .clang-tidy to ignore parameters of main like functions for 
naming violations in clang and llvm directory

Summary: Every call to a main like function in llvm and clang lib violates the 
naming convention for parameters. This prevents clang-tidy warning on such 
breaches.

Reviewers: alexfh, hokein

Reviewed By: hokein

Subscribers: merge_guards_bot, aheejin, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
.clang-tidy
clang/.clang-tidy
llvm/.clang-tidy

Removed: 




diff  --git a/.clang-tidy b/.clang-tidy
index 3f407e0160e6..e7e0830cfec5 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -14,4 +14,6 @@ CheckOptions:
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 

diff  --git a/clang/.clang-tidy b/clang/.clang-tidy
index 849c26987efd..5b425a712023 100644
--- a/clang/.clang-tidy
+++ b/clang/.clang-tidy
@@ -19,4 +19,6 @@ CheckOptions:
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 

diff  --git a/llvm/.clang-tidy b/llvm/.clang-tidy
index 3f407e0160e6..e7e0830cfec5 100644
--- a/llvm/.clang-tidy
+++ b/llvm/.clang-tidy
@@ -14,4 +14,6 @@ CheckOptions:
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 



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


[PATCH] D73580: [clang-tidy] rename_check.py: maintain alphabetical order in Renamed checks section

2020-01-31 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

It looks good, but could you maybe create a child revision showing what it 
looks like with a few checks renamed to make sure everything is all working 
correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73580



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-31 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added a comment.

In D73413#1851432 , @tonyelewis wrote:

> Thanks so much for all the effort on this. I think it's really wonderful.
>
> I've added a couple of comments elsewhere.
>
> My other query: does/should this check cover types? Eg does/should it fire on 
> a class definition in a .cpp file that isn't given internal-linkage? I'm 
> inclined to say it should.


Support for checking types should be either opt-in(or opt-out) but never 
forced. I feel like it would generate too much noise.




Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

tonyelewis wrote:
> njames93 wrote:
> > gribozavr2 wrote:
> > > njames93 wrote:
> > > > gribozavr2 wrote:
> > > > > njames93 wrote:
> > > > > > gribozavr2 wrote:
> > > > > > > This heuristic should be a lot more complex. In practice people 
> > > > > > > have more complex naming conventions (for example, in Clang, 
> > > > > > > Sema.h corresponds to many files named 
> > > > > > > SemaSomethingSomething.cpp).
> > > > > > > 
> > > > > > > I think there is a high chance that checking only a header with a 
> > > > > > > matching name will satisfy too few projects to be worth 
> > > > > > > implementing.
> > > > > > > 
> > > > > > > On the other hand, if you could use C++ or Clang modules to 
> > > > > > > narrow down the list of headers where the declaration should 
> > > > > > > appear, that would be a much stronger signal.
> > > > > > That is the reason I added the CheckAnyHeader option. For small 
> > > > > > projects the matching name would be usually be enough, but for big 
> > > > > > complex projects there is no feasible check that would work. 
> > > > > > Falling back to making sure every external definition has a 
> > > > > > declaration in at least one header will always be a good warning
> > > > > That's the thing -- due to the lack of consistency in projects and 
> > > > > style guides for C++, I think most projects will have to turn on 
> > > > > CheckAnyHeader. We get implementation complexity in ClangTidy, false 
> > > > > positives in high-profile projects, force users to configure 
> > > > > ClangTidy to work well for their projects (unless we set 
> > > > > CheckAnyHeader=1 by default... which then nobody would flip back to 
> > > > > zero), and little benefit for end users.
> > > > Would you say the best way would be check if the source file name 
> > > > starts with the header file name by default. Or is that very specific 
> > > > to Clang?
> > > > 
> > > > ```
> > > > /// 
> > > > #include "SomeHeader.h"
> > > > ```
> > > > This file would check for declarations in `SomeHeader.h`
> > > > 
> > > > Or maybe check if the header file name starts with the source file?
> > > > 
> > > > ```
> > > > /// 
> > > > #include "SomeHeaderImpl.h"
> > > > ```
> > > > This file would check for declarations in `SomeHeaderImpl.h`.
> > > > Or even check both?
> > > > Would you say the best way would be check if the source file name 
> > > > starts with the header file name by default. Or is that very specific 
> > > > to Clang?
> > > 
> > > I don't think it is too specific, it should cover many projects I think.
> > > 
> > > > Or maybe check if the header file name starts with the source file?
> > > 
> > > Seems like an unusual case to me, but I'm willing to be convinced 
> > > otherwise.
> > I thought it was an unusual case and wasn't thinking it would be a good 
> > idea to add. I'll just set it up so that it will always look in header 
> > files whose names appear at the start of the main source file.
> FWIW, my instinct is that there are two separate questions:
> 
>  1. What sort of files should have their external-linkage definitions checked?
>  2. What sort of included files should be part of the search for adequate 
> declarations that match those definitions?
> 
> ...and that my answers, in reverse order, are:
> 
>  2. All included files should be included (ie a check for a given 
> external-linkage definition should be appeased by _any_ matching declaration 
> in _any_ included file)
>  1. Only main files. And (to prevent lots of false-positives when the tool is 
> run over headers), only "c", "cc", "cxx", "cpp" files by default but with an 
> option to check in _all_ main files.
> 
> I think this has the merits that it:
>  * allows users to put their valid declaration in files with any extension 
> they like
>  * defaults to only firing when run against c/cc/cxx/cpp files but provides 
> the option to fire when run against a file with _any_ extension
> 
> 
> So I propose that there be one option and it be as follows:
> 
> 
> > .. option:: CheckExtDefnsInAllMainFiles
> > 
> > If set to `0` only check external-linkage definitions in main files with 

[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62288 tests passed, 8 failed 
and 837 were skipped.

  failed: LLVM.CodeGen/AMDGPU/branch-relaxation.ll
  failed: LLVM.CodeGen/AMDGPU/cf-loop-on-constant.ll
  failed: LLVM.CodeGen/AMDGPU/infinite-loop.ll
  failed: LLVM.CodeGen/AMDGPU/optimize-negated-cond.ll
  failed: LLVM.CodeGen/AMDGPU/uniform-cfg.ll
  failed: LLVM.CodeGen/AMDGPU/update-phi.ll
  failed: LLVM.CodeGen/AMDGPU/vgpr-descriptor-waterfall-loop-idom-update.ll
  failed: LLVM.Transforms/LoopStrengthReduce/AMDGPU/different-addrspace-crash.ll

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 2 
warnings 
.
 2 of them are added as review comments below (why? 
).

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780



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


[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62288 tests passed, 8 failed 
and 837 were skipped.

  failed: LLVM.CodeGen/AMDGPU/branch-relaxation.ll
  failed: LLVM.CodeGen/AMDGPU/cf-loop-on-constant.ll
  failed: LLVM.CodeGen/AMDGPU/infinite-loop.ll
  failed: LLVM.CodeGen/AMDGPU/optimize-negated-cond.ll
  failed: LLVM.CodeGen/AMDGPU/uniform-cfg.ll
  failed: LLVM.CodeGen/AMDGPU/update-phi.ll
  failed: LLVM.CodeGen/AMDGPU/vgpr-descriptor-waterfall-loop-idom-update.ll
  failed: LLVM.Transforms/LoopStrengthReduce/AMDGPU/different-addrspace-crash.ll

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 2 
warnings 
.
 2 of them are added as review comments below (why? 
).

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780



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


[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241735.
hokein added a comment.

add trailing blank line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Protobuf.cpp
  clang-tools-extra/clangd/Protobuf.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp

Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -13,6 +13,7 @@
 #include "CodeCompletionStrings.h"
 #include "ExpectedTypes.h"
 #include "Logger.h"
+#include "Protobuf.h"
 #include "SourceCode.h"
 #include "SymbolLocation.h"
 #include "URI.h"
@@ -70,45 +71,6 @@
   return URI::create(AbsolutePath).toString();
 }
 
-// All proto generated headers should start with this line.
-static const char *PROTO_HEADER_COMMENT =
-"// Generated by the protocol buffer compiler.  DO NOT EDIT!";
-
-// Checks whether the decl is a private symbol in a header generated by
-// protobuf compiler.
-// To identify whether a proto header is actually generated by proto compiler,
-// we check whether it starts with PROTO_HEADER_COMMENT.
-// FIXME: make filtering extensible when there are more use cases for symbol
-// filters.
-bool isPrivateProtoDecl(const NamedDecl ) {
-  const auto  = ND.getASTContext().getSourceManager();
-  auto Loc = nameLocation(ND, SM);
-  auto FileName = SM.getFilename(Loc);
-  if (!FileName.endswith(".proto.h") && !FileName.endswith(".pb.h"))
-return false;
-  auto FID = SM.getFileID(Loc);
-  // Double check that this is an actual protobuf header.
-  if (!SM.getBufferData(FID).startswith(PROTO_HEADER_COMMENT))
-return false;
-
-  // ND without identifier can be operators.
-  if (ND.getIdentifier() == nullptr)
-return false;
-  auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
-}
-
 // We only collect #include paths for symbols that are suitable for global code
 // completion, except for namespaces since #include path for a namespace is hard
 // to define.
Index: clang-tools-extra/clangd/Protobuf.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Protobuf.h
@@ -0,0 +1,24 @@
+//===--- Protobuf.h -  --*- 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_CLANGD_PROTOBUF_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H
+
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace clangd {
+
+/// Checks whether the decl is a private symbol in a header generated by
+/// protobuf compiler.
+bool isPrivateProtoDecl(const NamedDecl );
+
+} // namespace clangd
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H
Index: clang-tools-extra/clangd/Protobuf.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Protobuf.cpp
@@ -0,0 +1,54 @@
+//===--- Protobuf.cpp ---*- 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 "Protobuf.h"
+#include "AST.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace clangd {
+
+// All proto generated headers should start with this line.
+static const char *PROTO_HEADER_COMMENT =
+"// Generated by the protocol buffer compiler.  DO NOT EDIT!";
+
+// FIXME: make filtering extensible when there are more use cases for symbol
+// filters.
+bool isPrivateProtoDecl(const NamedDecl ) {
+  const auto  = ND.getASTContext().getSourceManager();
+  auto Loc = 

[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241734.
hokein marked 3 inline comments as done.
hokein added a comment.

update, and address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Protobuf.cpp
  clang-tools-extra/clangd/Protobuf.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp

Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -13,6 +13,7 @@
 #include "CodeCompletionStrings.h"
 #include "ExpectedTypes.h"
 #include "Logger.h"
+#include "Protobuf.h"
 #include "SourceCode.h"
 #include "SymbolLocation.h"
 #include "URI.h"
@@ -70,45 +71,6 @@
   return URI::create(AbsolutePath).toString();
 }
 
-// All proto generated headers should start with this line.
-static const char *PROTO_HEADER_COMMENT =
-"// Generated by the protocol buffer compiler.  DO NOT EDIT!";
-
-// Checks whether the decl is a private symbol in a header generated by
-// protobuf compiler.
-// To identify whether a proto header is actually generated by proto compiler,
-// we check whether it starts with PROTO_HEADER_COMMENT.
-// FIXME: make filtering extensible when there are more use cases for symbol
-// filters.
-bool isPrivateProtoDecl(const NamedDecl ) {
-  const auto  = ND.getASTContext().getSourceManager();
-  auto Loc = nameLocation(ND, SM);
-  auto FileName = SM.getFilename(Loc);
-  if (!FileName.endswith(".proto.h") && !FileName.endswith(".pb.h"))
-return false;
-  auto FID = SM.getFileID(Loc);
-  // Double check that this is an actual protobuf header.
-  if (!SM.getBufferData(FID).startswith(PROTO_HEADER_COMMENT))
-return false;
-
-  // ND without identifier can be operators.
-  if (ND.getIdentifier() == nullptr)
-return false;
-  auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
-}
-
 // We only collect #include paths for symbols that are suitable for global code
 // completion, except for namespaces since #include path for a namespace is hard
 // to define.
Index: clang-tools-extra/clangd/Protobuf.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Protobuf.h
@@ -0,0 +1,24 @@
+//===--- Protobuf.h -  --*- 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_CLANGD_PROTOBUF_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H
+
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace clangd {
+
+/// Checks whether the decl is a private symbol in a header generated by
+/// protobuf compiler.
+bool isPrivateProtoDecl(const NamedDecl );
+
+} // namespace clangd
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H
Index: clang-tools-extra/clangd/Protobuf.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Protobuf.cpp
@@ -0,0 +1,54 @@
+//===--- Protobuf.cpp ---*- 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 "Protobuf.h"
+#include "AST.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace clangd {
+
+// All proto generated headers should start with this line.
+static const char *PROTO_HEADER_COMMENT =
+"// Generated by the protocol buffer compiler.  DO NOT EDIT!";
+
+// FIXME: make filtering extensible when there are more use cases for symbol
+// filters.
+bool isPrivateProtoDecl(const NamedDecl ) {
+  const auto  = 

[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D73780#1851654 , @kadircet wrote:

> LG. I might be missing some context though, what's the reasoning behind? 
> Because, I think it is not necessary to treat protobufs differently.
>
> It might be sensible to have a more generic `isSymbolFromGeneratedFile` 
> filter, but also for this one I don't see any developments in the near future.


the motivation of this change is that we will blacklist the proto symbols for 
rename, we need a place to put protobuf-related functions (and we might improve 
clangd on better supporting protobuf symbol navigation this year) , I think it 
is sensible to lift them into a separate file.




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:81
-// we check whether it starts with PROTO_HEADER_COMMENT.
-// FIXME: make filtering extensible when there are more use cases for symbol
-// filters.

kadircet wrote:
> looks like this fixme got dropped
oops..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780



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


[PATCH] D73701: [clang] fix linkage of nested lambda

2020-01-31 Thread Michael Liao via Phabricator via cfe-commits
hliao accepted this revision.
hliao added a comment.
This revision is now accepted and ready to land.

LGTM, but need @rsmith for the final review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73701



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


[PATCH] D73786: [ARM,MVE] Fix vreinterpretq in big-endian mode.

2020-01-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, MarkMurrayARM, miyuki, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

In big-endian MVE, the simple vector load/store instructions (i.e.
both contiguous and non-widening) don't all store the bytes of a
register to memory in the same order: it matters whether you did a
VSTRB.8, VSTRH.16 or VSTRW.32. Put another way, the in-register
formats of different vector types relate to each other in a different
way from the in-memory formats.

So, if you want to 'bitcast' or 'reinterpret' one vector type as
another, you have to carefully specify which you mean: did you want to
reinterpret the //register// format of one type as that of the other,
or the //memory// format?

The ACLE `vreinterpretq` intrinsics are specified to reinterpret the
register format. But I had implemented them as LLVM IR bitcast, which
is specified for all types as a reinterpretation of the memory format.
So a `vreinterpretq` intrinsic, applied to values already in registers,
would code-generate incorrectly if compiled big-endian: instead of
emitting no code, it would emit a `vrev`.

To fix this, I've introduced a new IR intrinsic to perform a
register-format reinterpretation: `@llvm.arm.mve.vreinterpretq`. It's
implemented by a trivial isel pattern that expects the input in an
MQPR register, and just returns it unchanged.

In the clang codegen, I only emit this new intrinsic where it's
actually needed: I prefer a bitcast wherever it will have the right
effect, because LLVM understands bitcasts better. So we still generate
bitcasts in little-endian mode, and even in big-endian when you're
casting between two vector types with the same lane size.

For testing, I've moved all the codegen tests of vreinterpretq out
into their own file, so that they can have a different set of RUN
lines to check both big- and little-endian.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73786

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/admin.c
  clang/test/CodeGen/arm-mve-intrinsics/reinterpret.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-be.ll

Index: llvm/test/CodeGen/Thumb2/mve-be.ll
===
--- llvm/test/CodeGen/Thumb2/mve-be.ll
+++ llvm/test/CodeGen/Thumb2/mve-be.ll
@@ -295,3 +295,64 @@
   %3 = tail call <4 x i32> asm sideeffect "  VMULLB.s32 $0, $1, $1", "=,w"(<4 x i32> %2) #2
   ret <4 x i32> %3
 }
+
+; Test case demonstrating that 'bitcast' reinterprets the memory format of a
+; vector, as if stored and then loaded. So if it has to go between two
+; operations treating a register as having different lane sizes, then in
+; big-endian mode, it has to emit a vrev32.16, which is equivalent to the
+; effect that vstrw.32 followed by vldrh.16 would have.
+define arm_aapcs_vfpcc void @test_bitcast(<4 x i32>* readonly %in, <8 x i16>* %out) {
+; CHECK-LE-LABEL: test_bitcast:
+; CHECK-LE:   @ %bb.0: @ %entry
+; CHECK-LE-NEXT:vldrw.u32 q0, [r0]
+; CHECK-LE-NEXT:vmul.i32 q0, q0, q0
+; CHECK-LE-NEXT:vmul.i16 q0, q0, q0
+; CHECK-LE-NEXT:vstrw.32 q0, [r1]
+; CHECK-LE-NEXT:bx lr
+;
+; CHECK-BE-LABEL: test_bitcast:
+; CHECK-BE:   @ %bb.0: @ %entry
+; CHECK-BE-NEXT:vldrw.u32 q0, [r0]
+; CHECK-BE-NEXT:vmul.i32 q0, q0, q0
+; CHECK-BE-NEXT:vrev32.16 q0, q0
+; CHECK-BE-NEXT:vmul.i16 q0, q0, q0
+; CHECK-BE-NEXT:vstrh.16 q0, [r1]
+; CHECK-BE-NEXT:bx lr
+entry:
+  %vin = load <4 x i32>, <4 x i32>* %in, align 8
+  %vdbl = mul <4 x i32> %vin, %vin
+  %cast = bitcast <4 x i32> %vdbl to <8 x i16>
+  %cdbl = mul <8 x i16> %cast, %cast
+  store <8 x i16> %cdbl, <8 x i16>* %out, align 8
+  ret void
+}
+
+; Similar test case but using the arm.mve.vreinterpretq intrinsic instead,
+; which is defined to reinterpret the in-register format, so it generates no
+; instruction in either endianness.
+define arm_aapcs_vfpcc void @test_vreinterpretq(<4 x i32>* readonly %in, <8 x i16>* %out) {
+; CHECK-LE-LABEL: test_vreinterpretq:
+; CHECK-LE:   @ %bb.0: @ %entry
+; CHECK-LE-NEXT:vldrw.u32 q0, [r0]
+; CHECK-LE-NEXT:vmul.i32 q0, q0, q0
+; CHECK-LE-NEXT:vmul.i16 q0, q0, q0
+; CHECK-LE-NEXT:vstrw.32 q0, [r1]
+; CHECK-LE-NEXT:bx lr
+;
+; CHECK-BE-LABEL: test_vreinterpretq:
+; CHECK-BE:   @ %bb.0: @ %entry
+; CHECK-BE-NEXT:vldrw.u32 q0, [r0]
+; CHECK-BE-NEXT:vmul.i32 q0, q0, q0
+; CHECK-BE-NEXT:vmul.i16 q0, q0, q0
+; CHECK-BE-NEXT:vstrh.16 q0, [r1]
+; CHECK-BE-NEXT:bx lr
+entry:
+  %vin = load <4 x i32>, <4 x i32>* %in, align 8
+  %vdbl = mul <4 x i32> %vin, %vin
+  %cast = call <8 x i16> 

[PATCH] D73687: [AArch64][SVE] Add SVE2 intrinsics for complex integer dot product

2020-01-31 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 2 inline comments as done.
kmclaughlin added a comment.

Thanks for reviewing this, @efriedma!




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:
+ LLVMSubdivide4VectorType<0>,
+ llvm_i32_ty],
+[IntrNoMem]>;

efriedma wrote:
> Missing ImmArg?
Replaced this with //AdvSIMD_SVE_DOT_Indexed_Intrinsic//, which has the ImmArg 
property but is otherwise identical


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

https://reviews.llvm.org/D73687



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


[PATCH] D73687: [AArch64][SVE] Add SVE2 intrinsics for complex integer dot product

2020-01-31 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 241726.
kmclaughlin added a comment.

- Removed the AdvSIMD_SVE_CDOT_Intrinsic class
- Added ImmArg<4> to AdvSIMD_SVE_CDOT_LANE_Intrinsic


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

https://reviews.llvm.org/D73687

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll
@@ -0,0 +1,61 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+
+;
+; CDOT
+;
+
+define  @cdot_s( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_s:
+; CHECK: cdot z0.s, z1.b, z2.b, #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.nxv4i32( %a,
+ %b,
+ %c,
+i32 0)
+  ret  %out
+}
+
+define  @cdot_d( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_d:
+; CHECK: cdot z0.d, z1.h, z2.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.nxv2i64( %a,
+ %b,
+ %c,
+i32 90)
+  ret  %out
+}
+
+;
+; CDOT(indexed)
+;
+
+define  @cdot_s_idx( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_s_idx:
+; CHECK: cdot z0.s, z1.b, z2.b[0], #180
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.lane.nxv4i32( %a,
+  %b,
+  %c,
+ i32 0, i32 180)
+  ret  %out
+}
+
+
+define  @cdot_d_idx( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_d_idx:
+; CHECK: cdot z0.d, z1.h, z2.h[1], #270
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.lane.nxv2i64( %a,
+  %b,
+  %c,
+ i32 1, i32 270)
+  ret  %out
+}
+
+
+declare  @llvm.aarch64.sve.cdot.nxv4i32(, , , i32)
+declare  @llvm.aarch64.sve.cdot.nxv2i64(, , , i32)
+declare  @llvm.aarch64.sve.cdot.lane.nxv4i32(, , , i32, i32)
+declare  @llvm.aarch64.sve.cdot.lane.nxv2i64(, , , i32, i32)
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -2542,9 +2542,16 @@
   let ElementSize = ElementSizeNone;
 }
 
-multiclass sve2_cintx_dot {
+multiclass sve2_cintx_dot {
   def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
   def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
+
+  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
+ (i32 complexrotateop:$imm))),
+(!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>;
+  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
+ (i32 complexrotateop:$imm))),
+(!cast(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>;
 }
 
 //===--===//
@@ -2589,19 +2596,26 @@
   let ElementSize = ElementSizeNone;
 }
 
-multiclass sve2_cintx_dot_by_indexed_elem {
-  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
+multiclass sve2_cintx_dot_by_indexed_elem {
+  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
 bits<2> iop;
 bits<3> Zm;
 let Inst{20-19} = iop;
 let Inst{18-16} = Zm;
   }
-  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
+  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
 bit iop;
 bits<4> Zm;
 let Inst{20} = iop;
 let Inst{19-16} = Zm;
   }
+
+  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
+ (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
+ (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
+   

[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-31 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:1168
+  Error Err = Error::success();
+  QualType ToElementType = T->getElementType();
+  Expr *ToSizeExpr = T->getSizeExpr();

shafik wrote:
> Should this group be using `importChecked` as well?
Yes, this is a good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-01-31 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D73360#1850001 , @rjmccall wrote:

> Is there no follow-up code when actually emitting the failure diagnostic 
> which tries to figure out a more specific cause of failure?


After looking at this a bit more it seems C++ part calls the diagnostic code 
earlier:

  Sema::PerformImplicitConversion:
  
 case ImplicitConversionSequence::BadConversion:
   bool Diagnosed =
   DiagnoseAssignmentResult(Incompatible, From->getExprLoc(), ToType,
From->getType(), From, Action);

It just seems to always pass `Incompatible`. We could add follow up code 
before? This would be easier than modifying the existing flow completely. 
However, looking at this holistically we would need to repeat all checks 
classifying the failure types...


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

https://reviews.llvm.org/D73360



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


[PATCH] D68923: Don't warn about missing declarations for partial template specializations

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

I think the pings have gone on long enough -- if there's an issue with the 
patch, we can address it post-commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923



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


[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-01-31 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:335
+return AsTExpr;
+  else
+return nullptr;

Please don;e use else after return.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:345
+TOp OpKind) {
+  auto *PartAsBinOp = checkOpKind(Part, OpKind);
+  if (PartAsBinOp) {

Could it be const auto *?



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:347
+  if (PartAsBinOp) {
+auto Operands = getOperands(PartAsBinOp);
+if (areEquivalentExpr(Operands.first, Operands.second))

Please don't use auto when type is not spelled explicitly or iterator.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:352
+   collectOperands(Operands.second, AllOperands, OpKind);
+  } else {
+AllOperands.push_back(Part);

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:363
+  ASTContext ) {
+  const auto OpKind = getOp(TheExpr);
+  // if there are no nested operators of the same kind, it's handled by

Please don't use auto when type is not spelled explicitly or iterator.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:366
+  // operands/parametersAreEquivalent
+  const auto Operands = getOperands(TheExpr);
+  if (!(checkOpKind(Operands.first, OpKind) ||

Please don't use auto when type is not spelled explicitly or iterator.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:375
+  for (ast_type_traits::DynTypedNode Parent : Parents) {
+if (checkOpKind(Parent.get(), OpKind)) {
+  return false;

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:402
+
+if (FoundDuplicates) {
+  Builder->setBinding(

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:1223
+for (const auto  : Result.Nodes.getMap()) {
+  if (StringRef(KeyValue.first).startswith("duplicate")) {
+Diag << KeyValue.second.getSourceRange();

Please elide braces.


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

https://reviews.llvm.org/D73775



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


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-31 Thread Lei Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
antiagainst marked an inline comment as done.
Closed by commit rGdf71000d7d5d: [mlir][spirv] Convert linalg.generic for 
reduction to SPIR-V ops (authored by antiagainst).

Changed prior to commit:
  https://reviews.llvm.org/D73437?vs=241431=241720#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437

Files:
  mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h
  mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h
  mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
  mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
  mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
  mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
  mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
  mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
  mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
  mlir/lib/Conversion/CMakeLists.txt
  mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
  mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
  mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
  mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
  mlir/lib/Dialect/Linalg/Utils/Utils.cpp
  mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
  mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
  mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
  mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
  mlir/tools/mlir-opt/CMakeLists.txt

Index: mlir/tools/mlir-opt/CMakeLists.txt
===
--- mlir/tools/mlir-opt/CMakeLists.txt
+++ mlir/tools/mlir-opt/CMakeLists.txt
@@ -41,6 +41,7 @@
   MLIRQuantOps
   MLIRROCDLIR
   MLIRSPIRV
+  MLIRLinalgToSPIRVTransforms
   MLIRStandardToSPIRVTransforms
   MLIRSPIRVTestPasses
   MLIRSPIRVTransforms
Index: mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
===
--- /dev/null
+++ mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
@@ -0,0 +1,162 @@
+// RUN: mlir-opt -split-input-file -convert-linalg-to-spirv -canonicalize -verify-diagnostics %s -o - | FileCheck %s
+
+//===--===//
+// Single workgroup reduction
+//===--===//
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module attributes {
+  spv.target_env = {
+version = 3 : i32,
+extensions = [],
+capabilities = [1: i32, 63: i32] // Shader, GroupNonUniformArithmetic
+  }
+} {
+
+// CHECK:  spv.globalVariable
+// CHECK-SAME: built_in("LocalInvocationId")
+
+// CHECK:  func @single_workgroup_reduction
+// CHECK-SAME: (%[[INPUT:.+]]: !spv.ptr{{.+}}, %[[OUTPUT:.+]]: !spv.ptr{{.+}})
+
+// CHECK:%[[ZERO:.+]] = spv.constant 0 : i32
+// CHECK:%[[ID:.+]] = spv.Load "Input" %{{.+}} : vector<3xi32>
+// CHECK:%[[X:.+]] = spv.CompositeExtract %[[ID]][0 : i32]
+
+// CHECK:%[[INPTR:.+]] = spv.AccessChain %[[INPUT]][%[[ZERO]], %[[X]]]
+// CHECK:%[[VAL:.+]] = spv.Load "StorageBuffer" %[[INPTR]] : i32
+// CHECK:%[[ADD:.+]] = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %[[VAL]] : i32
+
+// CHECK:%[[OUTPTR:.+]] = spv.AccessChain %[[OUTPUT]][%[[ZERO]], %[[ZERO]]]
+// CHECK:%[[ELECT:.+]] = spv.GroupNonUniformElect "Subgroup" : i1
+
+// CHECK:spv.selection {
+// CHECK:  spv.BranchConditional %[[ELECT]], ^bb1, ^bb2
+// CHECK:^bb1:
+// CHECK:  spv.AtomicIAdd "Device" "AcquireRelease" %[[OUTPTR]], %[[ADD]]
+// CHECK:  spv.Branch ^bb2
+// CHECK:^bb2:
+// CHECK:  spv._merge
+// CHECK:}
+// CHECK:spv.Return
+
+func @single_workgroup_reduction(%input: memref<16xi32>, %output: memref<1xi32>) attributes {
+  spv.entry_point_abi = {local_size = dense<[16, 1, 1]>: vector<3xi32>}
+} {
+  linalg.generic #single_workgroup_reduction_trait %input, %output {
+^bb(%in: i32, %out: i32):
+  %sum = addi %in, %out : i32
+  linalg.yield %sum : i32
+  } : memref<16xi32>, memref<1xi32>
+  spv.Return
+}
+}
+
+// -
+
+// Missing shader entry point ABI
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module attributes {
+  spv.target_env = {
+version = 3 : i32,
+extensions = [],
+capabilities = [1: i32, 63: i32] // Shader, GroupNonUniformArithmetic
+  }
+} {
+func @single_workgroup_reduction(%input: memref<16xi32>, %output: memref<1xi32>) {
+  // expected-error @+1 {{failed to legalize operation 'linalg.generic'}}
+  linalg.generic #single_workgroup_reduction_trait %input, %output {
+^bb(%in: i32, 

[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 241718.
ilya-biryukov added a comment.

Fix compilation after rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/AST/ast-dump-expr-errors.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/Index/getcursor-recovery.cpp
  clang/test/Parser/cxx-concepts-ambig-constraint-expr.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -291,6 +291,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,5 +11,5 @@
 int bar(const unsigned int );
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} \
+   // expected-error {{use of undeclared identifier 'decltype'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'c'}}
 }
Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
 
 struct Noncopyable {
   Noncopyable();
@@ -107,8 

[PATCH] D73762: [clang] New warning for for-loops where the iteration does not match the loop condition

2020-01-31 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Check should also consider cases like: i += 2; i = i + 2; i -= 2; i = i - 2. 
Probably same with multiplications, divisions and shifts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73762



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


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-01-31 Thread John Marshall via cfe-commits
This patch has been languishing for 10 days, and it has been pointed out on 
cfe-dev that it is important to directly CC appropriate reviewers. As there's 
no-one listed in clang/CODE_OWNERS.TXT for diagnostics, I've now CCed "all 
other parts" Richard.

On 20 Jan 2020, at 16:09, John Marshall via cfe-commits 
 wrote:
> 
> This small patch improves the diagnostics when calling a function with the 
> wrong number of arguments. For example, given
> 
>   int
>   foo(int a, int b);
> 
>   int bar() { return foo(1); }
> 
> The existing compiler shows the error message and a note for "foo declared 
> here" showing only the "int" line. Ideally it would show the line containing 
> the word "foo" instead, which it does after this patch. Also if the function 
> declaration starts with some incidental macro, a trace of macro expansion is 
> shown which is likely irrelevant. See for example 
> https://github.com/samtools/htslib/issues/1013 and PR#23564.
> 
> I have not contributed to LLVM before and I am unfamiliar with the difference 
> between getBeginLoc() and getLocation() and the implications of using each. 
> However this patch does fix PR#23564 and perhaps this fix would be mostly a 
> no-brainer for those who are familiar with the code and these two location 
> functions in particular?
> 
> Thanks,
> 
>John

commit 0fcec5ffe9bc048907f623635b3acf8731ac9ffd
Author: John Marshall 
Date:   Mon Jan 20 14:58:14 2020 +

Use getLocation() in too few/many arguments diagnostic

Use the more accurate location when emitting the location of the
function being called's prototype in diagnostics emitted when calling
a function with an incorrect number of arguments.

In particular, avoids showing a trace of irrelevant macro expansions
for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2380a6b8d67..20c33c40c64 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5193,7 +5193,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   return true;
 }
@@ -5238,7 +5238,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);

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


[PATCH] D72401: Fixes for spaces around C# object initializers

2020-01-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bb60e29f18b: [clang-format] Fixes for spaces around C# 
object initializers (authored by Jonathan Coe jb...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72401

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -457,5 +457,34 @@
   EXPECT_EQ(Code, format(Code, Style));
 }
 
+TEST_F(FormatTestCSharp, CSharpObjectInitializers) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  // Start code fragemnts with a comment line so that C++ raw string literals
+  // as seen are identical to expected formatted code.
+
+  verifyFormat(R"(//
+Shape[] shapes = new[] {
+new Circle {
+Radius = 2.7281,
+Colour = Colours.Red,
+},
+new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+},
+};)",
+   Style);
+
+  // Omitted final `,`s will change the formatting.
+  verifyFormat(R"(//
+Shape[] shapes = new[] {new Circle {Radius = 2.7281, Colour = Colours.Red},
+new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+}};)",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2873,6 +2873,13 @@
   if (Left.is(tok::kw_using))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements 
||
spaceRequiredBeforeParens(Right);
+// space between ']' and '{'
+if (Left.is(tok::r_square) && Right.is(tok::l_brace))
+  return true;
+// space before '{' in "new MyType {"
+if (Right.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(tok::kw_new))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -457,5 +457,34 @@
   EXPECT_EQ(Code, format(Code, Style));
 }
 
+TEST_F(FormatTestCSharp, CSharpObjectInitializers) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  // Start code fragemnts with a comment line so that C++ raw string literals
+  // as seen are identical to expected formatted code.
+
+  verifyFormat(R"(//
+Shape[] shapes = new[] {
+new Circle {
+Radius = 2.7281,
+Colour = Colours.Red,
+},
+new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+},
+};)",
+   Style);
+
+  // Omitted final `,`s will change the formatting.
+  verifyFormat(R"(//
+Shape[] shapes = new[] {new Circle {Radius = 2.7281, Colour = Colours.Red},
+new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+}};)",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2873,6 +2873,13 @@
   if (Left.is(tok::kw_using))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements ||
spaceRequiredBeforeParens(Right);
+// space between ']' and '{'
+if (Left.is(tok::r_square) && Right.is(tok::l_brace))
+  return true;
+// space before '{' in "new MyType {"
+if (Right.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(tok::kw_new))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 241717.
ilya-biryukov added a comment.
Herald added a subscriber: bmahjour.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/AST/ast-dump-expr-errors.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/Index/getcursor-recovery.cpp
  clang/test/Parser/cxx-concepts-ambig-constraint-expr.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -291,6 +291,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,5 +11,5 @@
 int bar(const unsigned int );
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} \
+   // expected-error {{use of undeclared identifier 'decltype'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'c'}}
 }
Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
 
 struct Noncopyable {
   

[clang] 0bb60e2 - [clang-format] Fixes for spaces around C# object initializers

2020-01-31 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-01-31T14:22:01Z
New Revision: 0bb60e29f18bd45fc26d5f619150f28fc7541e9b

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

LOG: [clang-format] Fixes for spaces around C# object initializers

Summary: Fix spaces around typename and [] in C# object initializers.

Reviewers: MyDeveloperDay, klimek, krasimir

Reviewed By: MyDeveloperDay, krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3dc88315c352..f6df58dac2d6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2873,6 +2873,13 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine ,
   if (Left.is(tok::kw_using))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements 
||
spaceRequiredBeforeParens(Right);
+// space between ']' and '{'
+if (Left.is(tok::r_square) && Right.is(tok::l_brace))
+  return true;
+// space before '{' in "new MyType {"
+if (Right.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(tok::kw_new))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 3d1b597174d8..5d1131aa0c3a 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -457,5 +457,34 @@ var x = foo(className, $@"some code:
   EXPECT_EQ(Code, format(Code, Style));
 }
 
+TEST_F(FormatTestCSharp, CSharpObjectInitializers) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  // Start code fragemnts with a comment line so that C++ raw string literals
+  // as seen are identical to expected formatted code.
+
+  verifyFormat(R"(//
+Shape[] shapes = new[] {
+new Circle {
+Radius = 2.7281,
+Colour = Colours.Red,
+},
+new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+},
+};)",
+   Style);
+
+  // Omitted final `,`s will change the formatting.
+  verifyFormat(R"(//
+Shape[] shapes = new[] {new Circle {Radius = 2.7281, Colour = Colours.Red},
+new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+}};)",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-31 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:1181
+  Error Err = Error::success();
+  QualType ToElementType = T->getElementType();
+  Expr *ToSizeExpr = T->getSizeExpr();

`importChecked`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-31 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:1168
+  Error Err = Error::success();
+  QualType ToElementType = T->getElementType();
+  Expr *ToSizeExpr = T->getSizeExpr();

Should this group be using `importChecked` as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62288 tests passed, 8 failed 
and 837 were skipped.

  failed: LLVM.CodeGen/AMDGPU/branch-relaxation.ll
  failed: LLVM.CodeGen/AMDGPU/cf-loop-on-constant.ll
  failed: LLVM.CodeGen/AMDGPU/infinite-loop.ll
  failed: LLVM.CodeGen/AMDGPU/optimize-negated-cond.ll
  failed: LLVM.CodeGen/AMDGPU/uniform-cfg.ll
  failed: LLVM.CodeGen/AMDGPU/update-phi.ll
  failed: LLVM.CodeGen/AMDGPU/vgpr-descriptor-waterfall-loop-idom-update.ll
  failed: LLVM.Transforms/LoopStrengthReduce/AMDGPU/different-addrspace-crash.ll

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 3 
warnings 
.
 3 of them are added as review comments below (why? 
).

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780



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


[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

2020-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

As soon as I add a new enum value, this starts crashing some tests (even if we 
don't ever set the flag or serialize it).
Not sure what causes it and won't have time to figure it out before I leave. 
Sorry about that :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591



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


[PATCH] D69978: Separately track input and output denormal mode

2020-01-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 241714.
arsenm marked an inline comment as done.
arsenm added a comment.

Tweak langref


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

https://reviews.llvm.org/D69978

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/denormalfpmode.c
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/Driver/cl-denorms-are-zero.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/denormal-fp-math.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/ADT/FloatingPointMode.h
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/unittests/ADT/FloatingPointMode.cpp

Index: llvm/unittests/ADT/FloatingPointMode.cpp
===
--- llvm/unittests/ADT/FloatingPointMode.cpp
+++ llvm/unittests/ADT/FloatingPointMode.cpp
@@ -13,21 +13,122 @@
 
 namespace {
 
-TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
-  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute("ieee"));
-  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute(""));
+TEST(FloatingPointModeTest, ParseDenormalFPAttributeComponent) {
+  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttributeComponent("ieee"));
+  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttributeComponent(""));
   EXPECT_EQ(DenormalMode::PreserveSign,
-parseDenormalFPAttribute("preserve-sign"));
+parseDenormalFPAttributeComponent("preserve-sign"));
   EXPECT_EQ(DenormalMode::PositiveZero,
-parseDenormalFPAttribute("positive-zero"));
-  EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttribute("foo"));
+parseDenormalFPAttributeComponent("positive-zero"));
+  EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttributeComponent("foo"));
 }
 
 TEST(FloatingPointModeTest, DenormalAttributeName) {
-  EXPECT_EQ("ieee", denormalModeName(DenormalMode::IEEE));
-  EXPECT_EQ("preserve-sign", denormalModeName(DenormalMode::PreserveSign));
-  EXPECT_EQ("positive-zero", denormalModeName(DenormalMode::PositiveZero));
-  EXPECT_EQ("", denormalModeName(DenormalMode::Invalid));
+  EXPECT_EQ("ieee", denormalModeKindName(DenormalMode::IEEE));
+  EXPECT_EQ("preserve-sign", denormalModeKindName(DenormalMode::PreserveSign));
+  EXPECT_EQ("positive-zero", denormalModeKindName(DenormalMode::PositiveZero));
+  EXPECT_EQ("", denormalModeKindName(DenormalMode::Invalid));
+}
+
+TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee,ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee,"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute(""));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute(","));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign,"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign,preserve-sign"));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("positive-zero"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("positive-zero,positive-zero"));
+
+
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("ieee,positive-zero"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::IEEE),
+parseDenormalFPAttribute("positive-zero,ieee"));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::IEEE),
+parseDenormalFPAttribute("preserve-sign,ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("ieee,preserve-sign"));
+
+
+  EXPECT_EQ(DenormalMode(DenormalMode::Invalid, DenormalMode::Invalid),
+parseDenormalFPAttribute("foo"));
+  EXPECT_EQ(DenormalMode(DenormalMode::Invalid, 

[PATCH] D73701: [clang] fix linkage of nested lambda

2020-01-31 Thread Philippe Daouadi via Phabricator via cfe-commits
blastrock updated this revision to Diff 241713.
blastrock edited the summary of this revision.
blastrock added a reverted change: D1783: Allow nested lambdas in NSDMIs (i.e 
default initializers).
blastrock added a comment.

Thank you for the answers.

I have removed all the outermost lambda code and tests still pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73701

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp


Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++14 | FileCheck %s
 
 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv()
 // CHECK-LABEL: define internal void 
@"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
@@ -51,3 +51,16 @@
 }
 int use = foo();
 }
+
+// CHECK-LABEL: define internal void 
@"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_1EEDaS1_ENKUlvE_clEv"
+namespace lambda_capture_in_generic_lambda {
+template  auto foo() {
+  return [](auto func) {
+[func] { func(); }();
+  };
+}
+static void f() {
+  foo()([] { });
+}
+void f1() { f(); }
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1318,19 +1318,6 @@
  LV.isVisibilityExplicit());
 }
 
-static inline const CXXRecordDecl*
-getOutermostEnclosingLambda(const CXXRecordDecl *Record) {
-  const CXXRecordDecl *Ret = Record;
-  while (Record && Record->isLambda()) {
-Ret = Record;
-if (!Record->getParent()) break;
-// Get the Containing Class of this Lambda Class
-Record = dyn_cast_or_null(
-  Record->getParent()->getParent());
-  }
-  return Ret;
-}
-
 LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
   LVComputationKind computation,
   bool IgnoreVarTypeLinkage) {
@@ -1396,25 +1383,9 @@
   return getInternalLinkageFor(D);
 }
 
-// This lambda has its linkage/visibility determined:
-//  - either by the outermost lambda if that lambda has no mangling
-//number.
-//  - or by the parent of the outer most lambda
-// This prevents infinite recursion in settings such as nested lambdas
-// used in NSDMI's, for e.g.
-//  struct L {
-//int t{};
-//int t2 = ([](int a) { return [](int b) { return b; };})(t)(t);
-//  };
-const CXXRecordDecl *OuterMostLambda =
-getOutermostEnclosingLambda(Record);
-if (OuterMostLambda->hasKnownLambdaInternalLinkage() ||
-!OuterMostLambda->getLambdaManglingNumber())
-  return getInternalLinkageFor(D);
-
 return getLVForClosure(
-  OuterMostLambda->getDeclContext()->getRedeclContext(),
-  OuterMostLambda->getLambdaContextDecl(), computation);
+  Record->getDeclContext()->getRedeclContext(),
+  Record->getLambdaContextDecl(), computation);
   }
 
   break;


Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++14 | FileCheck %s
 
 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv()
 // CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
@@ -51,3 +51,16 @@
 }
 int use = foo();
 }
+
+// CHECK-LABEL: define internal void @"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_1EEDaS1_ENKUlvE_clEv"
+namespace lambda_capture_in_generic_lambda {
+template  auto foo() {
+  return [](auto func) {
+[func] { func(); }();
+  };
+}
+static void f() {
+  foo()([] { });
+}
+void f1() { f(); }
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1318,19 +1318,6 @@
  LV.isVisibilityExplicit());
 }
 
-static inline const CXXRecordDecl*
-getOutermostEnclosingLambda(const CXXRecordDecl 

[PATCH] D69978: Separately track input and output denormal mode

2020-01-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked 3 inline comments as done.
arsenm added inline comments.



Comment at: llvm/docs/LangRef.rst:1829
+   operations. The second indicates the handling of denormal inputs to
+   floating point instructions.
+

andrew.w.kaylor wrote:
> Based on the changes below, if the second value is omitted the input mode 
> will be assumed to be the same as the output mode. That should probably be 
> documented. I guess you intend for that not to happen, but the documentation 
> here leaves the result ambiguous if it does happen.
I've added a note for this



Comment at: llvm/docs/LangRef.rst:1848
+   should be converted to 0 as if by ``@llvm.canonicalize`` during
+   lowering.
+

andrew.w.kaylor wrote:
> Is this saying that if a backend generates an instruction that doesn't handle 
> the hardware daz mode then it must insert instructions to check for normals 
> and convert them to zero? If so, do you intend this to apply to all such 
> instructions or only instructions that aren't able to accept denormal inputs?
Only in cases where denormal inputs are invalid or unhandled. The case I'm 
thinking of is the one user in DAGCombiner, where if denormals are not flushed 
the result ends up incorrect (see https://bugs.llvm.org/show_bug.cgi?id=34994)


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

https://reviews.llvm.org/D69978



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


[PATCH] D73723: [clangd][Hover] Handle uninstantiated default args

2020-01-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62330 tests passed, 0 failed 
and 838 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73723



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-31 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Thank you for this work, it is awesome!

I really like the removal of `importSeq` I feel like the resulting code is more 
clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-31 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst marked 4 inline comments as done.
antiagainst added inline comments.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:125
+
+PatternMatchResult SingleWorkgroupReduction::matchAndRewrite(
+linalg::GenericOp genericOp, ArrayRef operands,

nicolasvasilache wrote:
> antiagainst wrote:
> > nicolasvasilache wrote:
> > > Please split this into a precondition and an apply that must succeed so 
> > > we can use the precondition as a Constraint and the apply as a simple 
> > > Rewrite.
> > > I have found this split to be crucial to write custom fused passes with 
> > > DRR.
> > > I claim this is generally the way we should be writing transformations 
> > > when we can, which is the case for Linalg ops. 
> > I feel I don't have all the backgrounds here so I'd appreciate some 
> > explanation as for why it's necessary to separate the match and rewrite. I 
> > think that's the original design of patterns (that we have `match` and 
> > `rewrite` separately) and then later we found it's too cumbersome to carry 
> > over a large matched state between them and then came up with 
> > `matchAndRewrite`? IIUC, every pattern is applied as a whole. I can 
> > understand that the match/rewrite side can be potentially reusable across 
> > patterns as components if they are exposed as helper functions, but that's 
> > more from a library organization and code reuse's perspective; I feel 
> > you've more reasons than that so I'd like to learn about them. :) 
> > 
> > Another question here is that I've matches that is generally useful to 
> > other patterns (checking whether this is a linalg doing reduction) and 
> > matches that is only useful to SPIR-V here (checking whether the workload 
> > can be fit in one local workgroup). How do you handle such cases?
> > 
> > For now I separated the check that whether this is a linalg doing reduction 
> > as a helper function. I haven't put it in some linalg file yet because 
> > currently it's too rigid and overfitting to a specific case. I plan to 
> > extend it and then later maybe we can move it to some linalg file. 
> Let's sync up over video for this, this is a longer discussion and touches 
> phase ordering issues, local patterns etc.
> If you want some of the deeper details please look at the rationale doc: 
> https://mlir.llvm.org/docs/Dialects/Linalg/ (which will soon move to 
> https://mlir.llvm.org/docs/Dialects/LinalgRationale/).
> 
> In the meantime, this is not a blocker but it would be great to sync up in 
> particular on the implementation on those ideas today in DRR.
Awesome, thanks! I've opened https://mlir.llvm.org/docs/Dialects/Linalg/ in a 
tab but haven't read it through yet. ;-P Will do now. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D73723: [clangd][Hover] Handle uninstantiated default args

2020-01-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c903d0373ff: [clangd][Hover] Handle uninstantiated default 
args (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73723

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1609,6 +1609,22 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo ) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -250,6 +250,20 @@
   });
 }
 
+// Default argument might exist but be unavailable, in the case of unparsed
+// arguments for example. This function returns the default argument if it is
+// available.
+const Expr *getDefaultArg(const ParmVarDecl *PVD) {
+  // Default argument can be unparsed or uninstatiated. For the former we
+  // can't do much, as token information is only stored in Sema and not
+  // attached to the AST node. For the latter though, it is safe to proceed as
+  // the expression is still valid.
+  if (!PVD->hasDefaultArg() || PVD->hasUnparsedDefaultArg())
+return nullptr;
+  return PVD->hasUninstantiatedDefaultArg() ? 
PVD->getUninstantiatedDefaultArg()
+: PVD->getDefaultArg();
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo , const Decl *D,
const FunctionDecl *FD,
@@ -269,10 +283,10 @@
 }
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
-if (PVD->hasDefaultArg()) {
+if (const Expr *DefArg = getDefaultArg(PVD)) {
   P.Default.emplace();
   llvm::raw_string_ostream Out(*P.Default);
-  PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
+  DefArg->printPretty(Out, nullptr, Policy);
 }
   }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1609,6 +1609,22 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo ) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -250,6 +250,20 @@
   });
 }
 
+// Default argument might exist but be unavailable, in the case of unparsed
+// arguments for example. This function returns the default argument if it is
+// available.
+const Expr *getDefaultArg(const ParmVarDecl *PVD) {
+  // Default argument can be unparsed or uninstatiated. For the former we
+  // can't do much, as token information is only stored in Sema and not
+  // attached to the AST node. For the latter though, it is safe to proceed as
+  // the expression is still valid.
+  if (!PVD->hasDefaultArg() || PVD->hasUnparsedDefaultArg())
+return nullptr;
+  return PVD->hasUninstantiatedDefaultArg() ? PVD->getUninstantiatedDefaultArg()
+: PVD->getDefaultArg();
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo , const Decl *D,
 

[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-31 Thread Nicolas Vasilache via Phabricator via cfe-commits
nicolasvasilache accepted this revision.
nicolasvasilache added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: Joonsoo.

Thanks Lei, this looks great, glad to see you pushing on this front!




Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:125
+
+PatternMatchResult SingleWorkgroupReduction::matchAndRewrite(
+linalg::GenericOp genericOp, ArrayRef operands,

antiagainst wrote:
> nicolasvasilache wrote:
> > Please split this into a precondition and an apply that must succeed so we 
> > can use the precondition as a Constraint and the apply as a simple Rewrite.
> > I have found this split to be crucial to write custom fused passes with DRR.
> > I claim this is generally the way we should be writing transformations when 
> > we can, which is the case for Linalg ops. 
> I feel I don't have all the backgrounds here so I'd appreciate some 
> explanation as for why it's necessary to separate the match and rewrite. I 
> think that's the original design of patterns (that we have `match` and 
> `rewrite` separately) and then later we found it's too cumbersome to carry 
> over a large matched state between them and then came up with 
> `matchAndRewrite`? IIUC, every pattern is applied as a whole. I can 
> understand that the match/rewrite side can be potentially reusable across 
> patterns as components if they are exposed as helper functions, but that's 
> more from a library organization and code reuse's perspective; I feel you've 
> more reasons than that so I'd like to learn about them. :) 
> 
> Another question here is that I've matches that is generally useful to other 
> patterns (checking whether this is a linalg doing reduction) and matches that 
> is only useful to SPIR-V here (checking whether the workload can be fit in 
> one local workgroup). How do you handle such cases?
> 
> For now I separated the check that whether this is a linalg doing reduction 
> as a helper function. I haven't put it in some linalg file yet because 
> currently it's too rigid and overfitting to a specific case. I plan to extend 
> it and then later maybe we can move it to some linalg file. 
Let's sync up over video for this, this is a longer discussion and touches 
phase ordering issues, local patterns etc.
If you want some of the deeper details please look at the rationale doc: 
https://mlir.llvm.org/docs/Dialects/Linalg/ (which will soon move to 
https://mlir.llvm.org/docs/Dialects/LinalgRationale/).

In the meantime, this is not a blocker but it would be great to sync up in 
particular on the implementation on those ideas today in DRR.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:156
+
+  auto inputMap = 
genericOp.indexing_maps().getValue()[0].cast();
+  auto outputMap =

antiagainst wrote:
> nicolasvasilache wrote:
> > I have similar comments re utils here but it will take a bit longer to put 
> > things in a reasonable form so please just add a TODO that this should use 
> > generic Linalg utils when available. 
> Right. I guess here we need some thinking about how to better design the API 
> to make it generic and usable across different cases. I'm not so versed on 
> that at the current moment. So putting your name in the TODO for now. :) 
SG, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[clang-tools-extra] 9c903d0 - [clangd][Hover] Handle uninstantiated default args

2020-01-31 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-31T15:03:33+01:00
New Revision: 9c903d0373ff940f9143efab8d948edf776de9f1

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

LOG: [clangd][Hover] Handle uninstantiated default args

Summary:
Default args might exist but be unparsed or uninstantiated.
getDefaultArg asserts on those. This patch makes sure we don't crash in such
scenarios.

Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 803efdf5ed1b..ae4c441a73b5 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -250,6 +250,20 @@ void enhanceFromIndex(HoverInfo , const NamedDecl 
,
   });
 }
 
+// Default argument might exist but be unavailable, in the case of unparsed
+// arguments for example. This function returns the default argument if it is
+// available.
+const Expr *getDefaultArg(const ParmVarDecl *PVD) {
+  // Default argument can be unparsed or uninstatiated. For the former we
+  // can't do much, as token information is only stored in Sema and not
+  // attached to the AST node. For the latter though, it is safe to proceed as
+  // the expression is still valid.
+  if (!PVD->hasDefaultArg() || PVD->hasUnparsedDefaultArg())
+return nullptr;
+  return PVD->hasUninstantiatedDefaultArg() ? 
PVD->getUninstantiatedDefaultArg()
+: PVD->getDefaultArg();
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo , const Decl *D,
const FunctionDecl *FD,
@@ -269,10 +283,10 @@ void fillFunctionTypeAndParams(HoverInfo , const Decl 
*D,
 }
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
-if (PVD->hasDefaultArg()) {
+if (const Expr *DefArg = getDefaultArg(PVD)) {
   P.Default.emplace();
   llvm::raw_string_ostream Out(*P.Default);
-  PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
+  DefArg->printPretty(Out, nullptr, Policy);
 }
   }
 

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 894de7dfc251..2876e2f31c13 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1609,6 +1609,22 @@ TEST(Hover, All) {
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo ) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.



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


[PATCH] D73723: [clangd][Hover] Handle uninstantiated default args

2020-01-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 241707.
kadircet marked an inline comment as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73723

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1609,6 +1609,22 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo ) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -250,6 +250,20 @@
   });
 }
 
+// Default argument might exist but be unavailable, in the case of unparsed
+// arguments for example. This function returns the default argument if it is
+// available.
+const Expr *getDefaultArg(const ParmVarDecl *PVD) {
+  // Default argument can be unparsed or uninstatiated. For the former we
+  // can't do much, as token information is only stored in Sema and not
+  // attached to the AST node. For the latter though, it is safe to proceed as
+  // the expression is still valid.
+  if (!PVD->hasDefaultArg() || PVD->hasUnparsedDefaultArg())
+return nullptr;
+  return PVD->hasUninstantiatedDefaultArg() ? 
PVD->getUninstantiatedDefaultArg()
+: PVD->getDefaultArg();
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo , const Decl *D,
const FunctionDecl *FD,
@@ -269,10 +283,10 @@
 }
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
-if (PVD->hasDefaultArg()) {
+if (const Expr *DefArg = getDefaultArg(PVD)) {
   P.Default.emplace();
   llvm::raw_string_ostream Out(*P.Default);
-  PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
+  DefArg->printPretty(Out, nullptr, Policy);
 }
   }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1609,6 +1609,22 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo ) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -250,6 +250,20 @@
   });
 }
 
+// Default argument might exist but be unavailable, in the case of unparsed
+// arguments for example. This function returns the default argument if it is
+// available.
+const Expr *getDefaultArg(const ParmVarDecl *PVD) {
+  // Default argument can be unparsed or uninstatiated. For the former we
+  // can't do much, as token information is only stored in Sema and not
+  // attached to the AST node. For the latter though, it is safe to proceed as
+  // the expression is still valid.
+  if (!PVD->hasDefaultArg() || PVD->hasUnparsedDefaultArg())
+return nullptr;
+  return PVD->hasUninstantiatedDefaultArg() ? PVD->getUninstantiatedDefaultArg()
+: PVD->getDefaultArg();
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo , const Decl *D,
const FunctionDecl 

[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-01-31 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

This patch is to be rebased against D73094 




Comment at: llvm/include/llvm/IR/ModuleSummaryIndex.h:830
   enum Kind {
+Unknown,   ///< Unknown (analysis not performed, don't lower)
 Unsat, ///< Unsatisfiable type (i.e. no global has this type metadata)

I don't think such implicit conversion of Unsat to Unknown is good idea. I 
guess problem will arise for legacy index files: for those ByteArray resolution 
will become Unsat and so on. I suggest moving Unknown the end of the list and 
bumping index version respectively (parseTypeIdSummaryRecord doesn't verify 
TheKind).



Comment at: llvm/lib/Passes/PassBuilder.cpp:1380
+  // in ICP (which is performed earlier than this in the regular LTO pipeline).
+  MPM.addPass(LowerTypeTestsPass(nullptr, nullptr, true));
 

Can we get rid of two identical passes here (and in other places also)? For 
instance 
```
MPM.addPass(LowerTypeTestsPass(ExportSummary, nullptr, true));
```
can both lower type metadata and do final cleanup.



Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1678
+// breaks any uses on assumes.
+if (TypeIdMap.count(TypeId))
+  continue;

I don't think, I understand this.
It looks like that if (a) we have type.test in the module and (b) we don't have 
vtable definition with corresponding type metadata in the same module then 
we'll remove type.test/assume sequence before even getting to ICP. This seems 
strange in the context of previous discussion because virtual function may be 
called in different module from one where vtable is defined, like so:
```
struct A { virtual int foo() { return 42; } };

// calls pA->foo
extern int callFoo(A *pA);
int main() { A a; return callFoo(); }
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

LG. I might be missing some context though, what's the reasoning behind? 
Because, I think it is not necessary to treat protobufs differently.

It might be sensible to have a more generic `isSymbolFromGeneratedFile` filter, 
but also for this one I don't see any developments in the near future.




Comment at: clang-tools-extra/clangd/Protobuf.cpp:24
+
+// To identify whether a proto header is actually generated by proto compiler,
+// we check whether it starts with PROTO_HEADER_COMMENT.

maybe move this comment down below, right before the line `  if 
(!SM.getBufferData(FID).startswith(PROTO_HEADER_COMMENT))`



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:81
-// we check whether it starts with PROTO_HEADER_COMMENT.
-// FIXME: make filtering extensible when there are more use cases for symbol
-// filters.

looks like this fixme got dropped


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780



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


[clang] ba1f3db - [Concepts] Correctly form initial parameter mapping for parameter packs, support substitution into SubstNonTypeTemplateParmExpr

2020-01-31 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-01-31T15:59:42+02:00
New Revision: ba1f3db4b0729ad932aa4f091e9578132d98a0c8

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

LOG: [Concepts] Correctly form initial parameter mapping for parameter packs, 
support substitution into SubstNonTypeTemplateParmExpr

We previously would not correctly for the initial parameter mapping for 
variadic template parameters in Concepts.
Testing this lead to the discovery that with the normalization process we would 
need to substitute into already-substituted-into
template arguments, which means we need to add NonTypeTemplateParmExpr support 
to TemplateInstantiator.
We do that by substituting into the replacement and the type separately, and 
then re-checking the expression against the NTTP
with the new type, in order to form any new required implicit casts (for cases 
where the type of the NTTP was dependent).

Added: 
clang/test/SemaTemplate/instantiate-template-argument.cpp

Modified: 
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/SemaConcept.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 39b070edea52..0de12a0ebe33 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7019,7 +7019,7 @@ class Sema final {
   /// Get a template argument mapping the given template parameter to itself,
   /// e.g. for X in \c template, this would return an expression 
template
   /// argument referencing X.
-  TemplateArgumentLoc getIdentityTemplateArgumentLoc(Decl *Param,
+  TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param,
  SourceLocation Location);
 
   void translateTemplateArguments(const ASTTemplateArgsPtr ,

diff  --git a/clang/include/clang/Sema/SemaConcept.h 
b/clang/include/clang/Sema/SemaConcept.h
index 7fc42a4816ec..c5f9fc45612a 100644
--- a/clang/include/clang/Sema/SemaConcept.h
+++ b/clang/include/clang/Sema/SemaConcept.h
@@ -43,11 +43,15 @@ struct AtomicConstraint {
 if (ParameterMapping->size() != Other.ParameterMapping->size())
   return false;
 
-for (unsigned I = 0, S = ParameterMapping->size(); I < S; ++I)
-  if (!C.getCanonicalTemplateArgument((*ParameterMapping)[I].getArgument())
-   .structurallyEquals(C.getCanonicalTemplateArgument(
-  (*Other.ParameterMapping)[I].getArgument(
+for (unsigned I = 0, S = ParameterMapping->size(); I < S; ++I) {
+  llvm::FoldingSetNodeID IDA, IDB;
+  C.getCanonicalTemplateArgument((*ParameterMapping)[I].getArgument())
+  .Profile(IDA, C);
+  
C.getCanonicalTemplateArgument((*Other.ParameterMapping)[I].getArgument())
+  .Profile(IDB, C);
+  if (IDA != IDB)
 return false;
+}
 return true;
   }
 

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 8fdc6023040f..39169664dad5 100755
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -676,6 +676,10 @@ static bool substituteParameterMappings(Sema , 
NormalizedConstraint ,
   
ArgsAsWritten->arguments().back().getSourceRange().getEnd()));
   if (S.SubstTemplateArguments(*Atomic.ParameterMapping, MLTAL, SubstArgs))
 return true;
+  Atomic.ParameterMapping.emplace(
+MutableArrayRef(
+new (S.Context) TemplateArgumentLoc[SubstArgs.size()],
+SubstArgs.size()));
   std::copy(SubstArgs.arguments().begin(), SubstArgs.arguments().end(),
 N.getAtomicConstraint()->ParameterMapping->begin());
   return false;

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 394c81c82794..1a71f270679d 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2488,7 +2488,7 @@ Sema::getTrivialTemplateArgumentLoc(const 
TemplateArgument ,
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion: {
   NestedNameSpecifierLocBuilder Builder;
-  TemplateName Template = Arg.getAsTemplate();
+  TemplateName Template = Arg.getAsTemplateOrTemplatePattern();
   if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
 Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
   else if (QualifiedTemplateName *QTN =
@@ -2514,27 +2514,10 @@ Sema::getTrivialTemplateArgumentLoc(const 
TemplateArgument ,
 }
 
 TemplateArgumentLoc
-Sema::getIdentityTemplateArgumentLoc(Decl *TemplateParm,
+Sema::getIdentityTemplateArgumentLoc(NamedDecl 

[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

2020-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 241706.
ilya-biryukov added a comment.
Herald added a subscriber: bmahjour.

Rebase on top of refactored dependence propagation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591

Files:
  clang/include/clang/AST/ASTDumperUtils.h
  clang/include/clang/AST/DependencyFlags.h
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -462,6 +462,7 @@
   Record.push_back(E->isValueDependent());
   Record.push_back(E->isInstantiationDependent());
   Record.push_back(E->containsUnexpandedParameterPack());
+  Record.push_back(E->containsErrors());
   Record.push_back(E->getValueKind());
   Record.push_back(E->getObjectKind());
 }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2258,6 +2258,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //DeclRefExpr
@@ -2282,6 +2283,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Integer Literal
@@ -2301,6 +2303,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Character Literal
@@ -2320,6 +2323,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   // CastExpr
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -106,7 +106,7 @@
 
 /// The number of record fields required for the Expr class
 /// itself.
-static const unsigned NumExprFields = NumStmtFields + 7;
+static const unsigned NumExprFields = NumStmtFields + 8;
 
 /// Read and initialize a ExplicitTemplateArgumentList structure.
 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo ,
@@ -518,6 +518,7 @@
   bool ValueDependent = Record.readInt();
   bool InstantiationDependent = Record.readInt();
   bool ContainsUnexpandedTemplateParameters = Record.readInt();
+  bool ContainsErrors = Record.readInt();
   auto Deps = ExprDependence::None;
   if (TypeDependent)
 Deps |= ExprDependence::Type;
@@ -527,6 +528,8 @@
 Deps |= ExprDependence::Instantiation;
   if (ContainsUnexpandedTemplateParameters)
 Deps |= ExprDependence::UnexpandedPack;
+  if (ContainsErrors)
+Deps |= ExprDependence::Error;
   E->setDependencies(Deps);
 
   E->setValueKind(static_cast(Record.readInt()));
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -127,6 +127,11 @@
   if (const auto *E = dyn_cast(Node)) {
 dumpType(E->getType());
 
+if (E->containsErrors()) {
+  ColorScope Color(OS, ShowColors, ErrorsColor);
+  OS << " contains-errors";
+}
+
 {
   ColorScope Color(OS, ShowColors, ValueKindColor);

[PATCH] D72401: Fixes for spaces around C# object initializers

2020-01-31 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!


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

https://reviews.llvm.org/D72401



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


[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-01-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov, 
mgorny.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73780

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Protobuf.cpp
  clang-tools-extra/clangd/Protobuf.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp

Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -13,6 +13,7 @@
 #include "CodeCompletionStrings.h"
 #include "ExpectedTypes.h"
 #include "Logger.h"
+#include "Protobuf.h"
 #include "SourceCode.h"
 #include "SymbolLocation.h"
 #include "URI.h"
@@ -70,45 +71,6 @@
   return URI::create(AbsolutePath).toString();
 }
 
-// All proto generated headers should start with this line.
-static const char *PROTO_HEADER_COMMENT =
-"// Generated by the protocol buffer compiler.  DO NOT EDIT!";
-
-// Checks whether the decl is a private symbol in a header generated by
-// protobuf compiler.
-// To identify whether a proto header is actually generated by proto compiler,
-// we check whether it starts with PROTO_HEADER_COMMENT.
-// FIXME: make filtering extensible when there are more use cases for symbol
-// filters.
-bool isPrivateProtoDecl(const NamedDecl ) {
-  const auto  = ND.getASTContext().getSourceManager();
-  auto Loc = nameLocation(ND, SM);
-  auto FileName = SM.getFilename(Loc);
-  if (!FileName.endswith(".proto.h") && !FileName.endswith(".pb.h"))
-return false;
-  auto FID = SM.getFileID(Loc);
-  // Double check that this is an actual protobuf header.
-  if (!SM.getBufferData(FID).startswith(PROTO_HEADER_COMMENT))
-return false;
-
-  // ND without identifier can be operators.
-  if (ND.getIdentifier() == nullptr)
-return false;
-  auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
-}
-
 // We only collect #include paths for symbols that are suitable for global code
 // completion, except for namespaces since #include path for a namespace is hard
 // to define.
Index: clang-tools-extra/clangd/Protobuf.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Protobuf.h
@@ -0,0 +1,24 @@
+//===--- Protobuf.h -  --*- 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_CLANGD_PROTOBUF_H_
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H_
+
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace clangd {
+
+/// Checks whether the decl is a private symbol in a header generated by
+/// protobuf compiler.
+bool isPrivateProtoDecl(const NamedDecl );
+
+} // namespace clangd
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H_
Index: clang-tools-extra/clangd/Protobuf.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Protobuf.cpp
@@ -0,0 +1,58 @@
+//===--- Protobuf.cpp ---*- 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_CLANGD_PROTOBUF_H_
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOBUF_H_
+
+#include "Protobuf.h"
+#include "AST.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace clangd {
+
+// All proto generated headers should start with this line.
+static const char *PROTO_HEADER_COMMENT =
+"// Generated by the protocol buffer compiler.  DO NOT EDIT!";
+
+// To identify whether a proto header is actually generated by proto compiler,
+// we 

[PATCH] D73723: [clangd][Hover] Handle uninstantiated default args

2020-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang-tools-extra/clangd/Hover.cpp:276
+// we only print the expression.
+if (PVD->hasDefaultArg() && !PVD->hasUnparsedDefaultArg()) {
   P.Default.emplace();

NIT: maybe move this into a helper function?
```
Expr* getDefaultArgForPresentation(ParmVarDecl*);
```
I imagine this could be useful in other contexts too.

PS: As usual, naming is not my strong side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73723



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-31 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd09f12f32f5: Implement -fsemantic-interposition (authored 
by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/semantic-interposition.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Transforms/Inline/inline-semantic-interposition.ll
  llvm/test/Verifier/module-flags-semantic-interposition.ll

Index: llvm/test/Verifier/module-flags-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Verifier/module-flags-semantic-interposition.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 1, align 4
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"SemanticInterposition", float 1.}
+
+; CHECK: SemanticInterposition metadata requires constant integer argument
Index: llvm/test/Transforms/Inline/inline-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-semantic-interposition.ll
@@ -0,0 +1,26 @@
+; Check that @callee1 gets inlined while @callee2 is not, because of
+; SemanticInterposition.
+
+; RUN: opt < %s -inline -S | FileCheck %s
+
+define internal i32 @callee1(i32 %A) {
+  ret i32 %A
+}
+
+define i32 @callee2(i32 %A) {
+  ret i32 %A
+}
+
+; CHECK-LABEL: @caller
+define i32 @caller(i32 %A) {
+; CHECK-NOT: call i32 @callee1(i32 %A)
+  %A1 = call i32 @callee1(i32 %A)
+; CHECK: %A2 = call i32 @callee2(i32 %A)
+  %A2 = call i32 @callee2(i32 %A)
+; CHECK: add i32 %A, %A2
+  %R = add i32 %A1, %A2
+  ret i32 %R
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"SemanticInterposition", i32 1}
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1476,6 +1476,13 @@
"'Linker Options' named metadata no longer supported");
   }
 
+  if (ID->getString() == "SemanticInterposition") {
+ConstantInt *Value =
+mdconst::dyn_extract_or_null(Op->getOperand(2));
+Assert(Value,
+   "SemanticInterposition metadata requires constant integer argument");
+  }
+
   if (ID->getString() == "CG Profile") {
 for (const MDOperand  : cast(Op->getOperand(2))->operands())
   visitModuleFlagCGProfileEntry(MDO);
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -555,6 +555,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  Metadata *MF = getModuleFlag("SemanticInterposition");
+
+  auto *Val = cast_or_null(MF);
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (isInterposableLinkage(getLinkage()))
+return true;
+  return getParent() && getParent()->getSemanticInterposition() &&
+ !isDSOLocal();
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,12 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- 

[clang] fd09f12 - Implement -fsemantic-interposition

2020-01-31 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-01-31T14:02:33+01:00
New Revision: fd09f12f32f57564d619a28b8826d33ade47b12e

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

LOG: Implement -fsemantic-interposition

First attempt at implementing -fsemantic-interposition.

Rely on GlobalValue::isInterposable that already captures most of the expected
behavior.

Rely on a ModuleFlag to state whether we should respect SemanticInterposition or
not. The default remains no.

So this should be a no-op if -fsemantic-interposition isn't used, and if it is,
isInterposable being already used in most optimisation, they should honor it
properly.

Note that it only impacts architecture compiled with -fPIC and no pie.

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

Added: 
clang/test/CodeGen/semantic-interposition.c
llvm/test/Transforms/Inline/inline-semantic-interposition.ll
llvm/test/Verifier/module-flags-semantic-interposition.ll

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/clang_f_opts.c
llvm/include/llvm/IR/GlobalValue.h
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Globals.cpp
llvm/lib/IR/Module.cpp
llvm/lib/IR/Verifier.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index eb0519988fa2..24c8ee2bc9ef 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -904,6 +904,12 @@ Strip (or keep only, if negative) a given number of path 
components when emittin
 
 Turn on runtime checks for various forms of undefined or suspicious behavior. 
See user manual for available checks
 
+.. option:: -fno-semantic-interposition, -fsemantic-interposition
+
+Enable semantic interposition. Semantic interposition allows for the
+interposition of a symbol by another at runtime, thus preventing a range of
+inter-procedural optimisation.
+
 .. option:: -moutline, -mno-outline
 
 Enable function outlining (AArch64 only)

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index f7fa0151d397..4c7f7dde1f7d 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -284,6 +284,7 @@ ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, 
DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
 LANGOPT(SetVisibilityForExternDecls, 1, 0,
 "apply global symbol visibility to external declarations without an 
explicit visibility")
+BENIGN_LANGOPT(SemanticInterposition, 1, 0, "semantic interposition")
 ENUM_LANGOPT(StackProtector, StackProtectorMode, 2, SSPOff,
  "stack protector mode")
 ENUM_LANGOPT(TrivialAutoVarInit, TrivialAutoVarInitKind, 2, 
TrivialAutoVarInitKind::Uninitialized,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4d5806154968..dcec7e6fde1e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3283,7 +3283,8 @@ defm inline_small_functions : 
BooleanFFlag<"inline-small-functions">,
 defm ipa_cp : BooleanFFlag<"ipa-cp">,
 Group;
 defm ivopts : BooleanFFlag<"ivopts">, 
Group;
-def : Flag<["-"], "fno-semantic-interposition">, Group;
+def fsemantic_interposition : Flag<["-"], "fsemantic-interposition">, 
Group, Flags<[CC1Option]>;
+def fno_semantic_interposition: Flag<["-"], "fno-semantic-interposition">, 
Group;
 defm non_call_exceptions : BooleanFFlag<"non-call-exceptions">, 
Group;
 defm peel_loops : BooleanFFlag<"peel-loops">, 
Group;
 defm permissive : BooleanFFlag<"permissive">, Group;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 03c3fec5ebec..6a43b6bba627 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -483,6 +483,11 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Max, "Dwarf Version",
   CodeGenOpts.DwarfVersion);
   }
+
+  if (Context.getLangOpts().SemanticInterposition)
+// Require various optimization to respect semantic interposition.
+getModule().setSemanticInterposition(1);
+
   if (CodeGenOpts.EmitCodeView) {
 // Indicate that we want CodeView in the metadata.
 getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
@@ -872,7 +877,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule ,
   if (isa(GV) && !CGOpts.NoPLT && RM == llvm::Reloc::Static)
 return true;
 
-  // Otherwise don't 

[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-01-31 Thread Alexey Romanov via Phabricator via cfe-commits
alexeyr added a comment.

Also I am not sure why, but the ranges added to the diagnostic in lines 
1222-1226 don't show up in the message.


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

https://reviews.llvm.org/D73775



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


  1   2   >