[PATCH] D94943: [X86][AMX] Fix the typo.

2021-01-18 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94943

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


[PATCH] D94827: [SimplifyCFG] Require and preserve dominator tree

2021-01-18 Thread Max Kazantsev via Phabricator via cfe-commits
mkazantsev added inline comments.



Comment at: llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:263
 const SimplifyCFGOptions ) {
-  assert((!RequireAndPreserveDomTree ||
-  (DT && DT->verify(DominatorTree::VerificationLevel::Full))) &&

lebedev.ri wrote:
> mkazantsev wrote:
> > Why remove that? It looks useful to have (maybe over-paranoid) checks that 
> > DT is correct at least for the first time. I'd rather keep them for a while 
> > unless there is a reason to drop them now.
> Note that this checks that the DomTree *provided by the pass manager* is 
> valid.
> Do we actually want to check that here?
This assert is meant to check that we actually pass it a DomTree immediately 
from the pass manager, and not some previously modified dom tree. It's up to 
you, but I'm a little bit paranoid when it comes to validation of analysis 
structures. It's never too late to remove redundant assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94827

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


[clang-tools-extra] 4b57400 - [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2021-01-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-18T21:05:01-08:00
New Revision: 4b574008aef5a7235c1f894ab065fe300d26e786

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

LOG: [c++20] P1907R1: Support for generalized non-type template arguments of 
scalar type.

Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
reverted because a dependency commit was reverted. This incorporates the
following follow-on commits that were also reverted:

7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim
ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me
95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall
430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki

Added: 
clang/test/CodeGenCXX/template-arguments.cpp

Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/index/remote/Client.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TemplateArgumentVisitor.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CodeGenCXX/mangle-ms-templates.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 588bcfcf2424..bf7675e7d949 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -143,6 +143,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_ARGUMENT_KIND(Declaration);
   TEMPLATE_ARGUMENT_KIND(Template);
   TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
+  TEMPLATE_ARGUMENT_KIND(UncommonValue);
 #undef TEMPLATE_ARGUMENT_KIND
 }
 llvm_unreachable("Unhandled ArgKind enum");

diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 84316659daad..98ef8b3b6d76 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -1079,6 +1079,7 @@ class ExplicitReferenceCollector
 case TemplateArgument::Pack:
 case TemplateArgument::Type:
 case TemplateArgument::Expression:
+case TemplateArgument::UncommonValue:
   break; // Handled by VisitType and VisitExpression.
 };
 return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A);

diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index b09dbf915e46..a153a8812baf 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -152,7 +152,8 @@ class IndexClient : public clangd::SymbolIndex {
   });
   }
 
-  llvm::unique_function indexedFiles() const {
+  llvm::unique_function
+  indexedFiles() const override {
 // FIXME: For now we always return "false" regardless of whether the file
 //was indexed or not. A possible implementation could be based on
 //the idea that we do not want to send a request at every

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 0c5d82b3e9aa..a9bfdb4d5fa5 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2818,8 +2818,8 @@ class ASTContext : public RefCountedBase {
   /// for destruction.
   template  void addDestruction(T *Ptr) const {
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr 

[clang] 5a391d3 - Following up on PR48517, fix handling of template arguments that refer

2021-01-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-18T21:05:01-08:00
New Revision: 5a391d38ac6c561ba908334d427f26124ed9132e

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

LOG: Following up on PR48517, fix handling of template arguments that refer
to dependent declarations.

Treat an id-expression that names a local variable in a templated
function as being instantiation-dependent.

This addresses a language defect whereby a reference to a dependent
declaration can be formed without any construct being value-dependent.
Fixing that through value-dependence turns out to be problematic, so
instead this patch takes the approach (proposed on the core reflector)
of allowing the use of pointers or references to (but not values of)
dependent declarations inside value-dependent expressions, and instead
treating template arguments as dependent if they evaluate to a constant
involving such dependent declarations.

This ends up affecting a bunch of OpenMP tests, due to OpenMP
imprecisely handling instantiation-dependent constructs, bailing out
early instead of processing dependent constructs to the extent possible
when handling the template.

Previously committed as 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e, and
reverted because a dependency commit was reverted.

Added: 
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp

Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/OpenMP/distribute_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_parallel_for_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_collapse_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_ordered_messages.cpp
clang/test/OpenMP/target_simd_collapse_messages.cpp
clang/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_update_from_messages.cpp
clang/test/OpenMP/target_update_to_messages.cpp
clang/test/OpenMP/task_messages.cpp
clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/teams_distribute_simd_dist_schedule_messages.cpp
clang/test/SemaCXX/warn-unused-lambda-capture.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Removed: 
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp



diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index a44d06967431..c963be98d3cb 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -578,12 +578,12 @@ class Expr : public ValueStmt {
   struct EvalStatus {
 /// Whether the evaluated expression has side effects.
 /// For example, (f() && 0) can be folded, but it still has side effects.
-bool HasSideEffects;
+bool HasSideEffects = false;
 
 /// Whether the evaluation hit undefined behavior.
 /// For example, 1.0 / 0.0 can be folded to Inf, but has undefined 
behavior.
 /// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.
-bool HasUndefinedBehavior;
+bool HasUndefinedBehavior = false;
 
 /// Diag - If this is non-null, it will be filled in with a stack of notes
 /// indicating why evaluation failed (or why it failed to produce a 
constant
@@ -592,10 +592,7 @@ class Expr : public ValueStmt {
 /// foldable. If the expression is foldable, but not a constant expression,
 /// the notes will describes why it isn't a constant expression. If the
 /// expression *is* a constant expression, no notes will be produced.
-SmallVectorImpl *Diag;
-
-EvalStatus()
-: HasSideEffects(false), HasUndefinedBehavior(false), Diag(nullptr) {}
+SmallVectorImpl *Diag = nullptr;
 
 // hasSideEffects - Return true if the evaluated expression has
 // side effects.
@@ -606,8 +603,11 @@ class Expr : public ValueStmt {
 
   /// EvalResult is a struct with detailed info about an evaluated expression.
   struct EvalResult : 

[clang] fbb83f1 - PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of

2021-01-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-18T21:05:01-08:00
New Revision: fbb83f18b5485218ad3c36c1d079c89f061372b8

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

LOG: PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of
the nested-name-specifier when determining whether a qualified type is
instantiation-dependent.

Previously reverted in 25a02c3d1a688d3cd18faef96c75fa553efbbac7 due to
causing us to reject some code. It turns out that the rejected code was
ill-formed (no diagnostic required).

Added: 
clang/test/SemaTemplate/instantiation-dependence.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/lib/AST/ItaniumMangle.cpp
clang/test/CXX/drs/dr15xx.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/partial-spec-instantiate.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 143a05cba6ad..319d3850346b 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5412,7 +5412,9 @@ class ElaboratedType final
   ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
  QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl)
   : TypeWithKeyword(Keyword, Elaborated, CanonType,
-NamedType->getDependence()),
+NamedType->getDependence() |
+(NNS ? toTypeDependence(NNS->getDependence())
+ : TypeDependence::None)),
 NNS(NNS), NamedType(NamedType) {
 ElaboratedTypeBits.HasOwnedTagDecl = false;
 if (OwnedTagDecl) {

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 1f8c11f6de96..084a0b0c5bf0 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2583,6 +2583,10 @@ void CXXNameMangler::mangleType(QualType T) {
   if (isa(T))
 break;
 
+  // FIXME: We presumably shouldn't strip off ElaboratedTypes with
+  // instantation-dependent qualifiers. See
+  // https://github.com/itanium-cxx-abi/cxx-abi/issues/114.
+
   QualType Desugared
 = T.getSingleStepDesugaredType(Context.getASTContext());
   if (Desugared == T)

diff  --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index 478a0d7d00dd..8bfa29a8b667 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -239,6 +239,20 @@ namespace dr1550 { // dr1550: yes
   }
 }
 
+namespace dr1558 { // dr1558: 12
+#if __cplusplus >= 201103L
+  template using first_of = T;
+  template first_of f(int); // expected-note 
{{'int' cannot be used prior to '::'}}
+  template void f(...) = delete; // expected-note {{deleted}}
+
+  struct X { typedef void type; };
+  void test() {
+f(0);
+f(0); // expected-error {{deleted}}
+  }
+#endif
+}
+
 namespace dr1560 { // dr1560: 3.5
   void f(bool b, int n) {
 (b ? throw 0 : n) = (b ? n : throw 0) = 0;

diff  --git a/clang/test/CodeGenCXX/mangle-template.cpp 
b/clang/test/CodeGenCXX/mangle-template.cpp
index 9b5220572c2e..40688de7e12e 100644
--- a/clang/test/CodeGenCXX/mangle-template.cpp
+++ b/clang/test/CodeGenCXX/mangle-template.cpp
@@ -342,3 +342,23 @@ namespace fixed_size_parameter_pack {
   template void f(A::B<0, Ns...>);
   void g() { f<1, 2>({}); }
 }
+
+namespace type_qualifier {
+  template using int_t = int;
+  template void f(decltype(int_t() + 1)) {}
+  // FIXME: This mangling doesn't work: we need to mangle the
+  // instantiation-dependent 'int_t' operand.
+  // CHECK: @_ZN14type_qualifier1fIPiEEvDTplcvi_ELi1EE
+  template void f(int);
+
+  // Note that this template has 
diff erent constraints but would mangle the
+  // same:
+  //template void f(decltype(int_t() + 1)) {}
+
+  struct impl { using type = void; };
+  template using alias = impl;
+  template void g(decltype(alias::type(), 1)) {}
+  // FIXME: Similarly we need to mangle the `T*` in here.
+  // CHECK: @_ZN14type_qualifier1gIPiEEvDTcmcvv_ELi1EE
+  template void g(int);
+}

diff  --git a/clang/test/SemaTemplate/instantiation-dependence.cpp 
b/clang/test/SemaTemplate/instantiation-dependence.cpp
new file mode 100644
index ..2b9a47ad25a4
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-dependence.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+// Ensure we substitute into instantiation-dependent but non-dependent
+// constructs. The poster-child for this is...
+template using void_t = void;
+
+namespace PR24076 {
+  template T declval();
+  struct s {};
+
+  template() + 1)>>
+void foo(T) {} // expected-note {{invalid operands to binary expression}}
+
+  void f() {
+foo(s{}); // expected-error {{no matching function}}

[clang] e3065ce - DR2064: decltype(E) is only a dependent type if E is type-dependent, not

2021-01-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-18T21:05:01-08:00
New Revision: e3065ce238475ec202c707f4c58d90df171626ca

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

LOG: DR2064: decltype(E) is only a dependent type if E is type-dependent, not
if E is merely instantiation-dependent.

Previously reverted in 34e72a146111dd986889a0f0ec8767b2ca6b2913;
re-committed with a fix to an issue that caused name mangling to assert.

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Type.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/CodeGenCXX/mangle-subst.cpp
clang/test/Sema/invalid-bitwidth-expr.mm
clang/test/SemaCXX/invalid-template-base-specifier.cpp
clang/test/SemaTemplate/dependent-expr.cpp
clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index ca96b65574bd..8c47047a7526 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -255,6 +255,12 @@ inline TypeDependence 
toTypeDependence(TemplateNameDependence D) {
 inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
   return Dependence(D).type();
 }
+/// Compute the dependence of a type that depends on the type of an expression,
+/// given the dependence of that expression and of its type.
+inline TypeDependence typeToTypeDependence(ExprDependence ED, TypeDependence 
TD) {
+  return Dependence(ED & ~ExprDependence::Value).type() |
+ (TD & TypeDependence::VariablyModified);
+}
 
 inline NestedNameSpecifierDependence
 toNestedNameSpecifierDependendence(TypeDependence D) {

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 44545f00b146..0190573fe36e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5383,10 +5383,10 @@ QualType ASTContext::getDecltypeType(Expr *e, QualType 
UnderlyingType) const {
   DecltypeType *dt;
 
   // C++11 [temp.type]p2:
-  //   If an expression e involves a template parameter, decltype(e) denotes a
-  //   unique dependent type. Two such decltype-specifiers refer to the same
-  //   type only if their expressions are equivalent (14.5.6.1).
-  if (e->isInstantiationDependent()) {
+  //   If an expression e is type-dependent, decltype(e) denotes a unique
+  //   dependent type. Two such decltype-specifiers refer to the same type only
+  //   if their expressions are equivalent (14.5.6.1).
+  if (e->isTypeDependent()) {
 llvm::FoldingSetNodeID ID;
 DependentDecltypeType::Profile(ID, *this, e);
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 73c8f17a5d36..1f8c11f6de96 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2578,6 +2578,11 @@ void CXXNameMangler::mangleType(QualType T) {
 if (!TST->isTypeAlias())
   break;
 
+  // Don't desugar instantiation-dependent decltype / typeof types. We need
+  // to mangle the expression as written.
+  if (isa(T))
+break;
+
   QualType Desugared
 = T.getSingleStepDesugaredType(Context.getASTContext());
   if (Desugared == T)
@@ -5568,12 +5573,11 @@ static bool hasMangledSubstitutionQualifiers(QualType 
T) {
 
 bool CXXNameMangler::mangleSubstitution(QualType T) {
   if (!hasMangledSubstitutionQualifiers(T)) {
-if (const RecordType *RT = T->getAs())
+if (const RecordType *RT = dyn_cast(T))
   return mangleSubstitution(RT->getDecl());
   }
 
   uintptr_t TypePtr = reinterpret_cast(T.getAsOpaquePtr());
-
   return mangleSubstitution(TypePtr);
 }
 
@@ -5732,7 +5736,7 @@ bool CXXNameMangler::mangleStandardSubstitution(const 
NamedDecl *ND) {
 
 void CXXNameMangler::addSubstitution(QualType T) {
   if (!hasMangledSubstitutionQualifiers(T)) {
-if (const RecordType *RT = T->getAs()) {
+if (const RecordType *RT = dyn_cast(T)) {
   addSubstitution(RT->getDecl());
   return;
 }

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 034e175f1352..5dec80be9ccb 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -125,8 +125,7 @@ ArrayType::ArrayType(TypeClass tc, QualType et, QualType 
can,
 //   template int arr[] = {N...};
 : Type(tc, can,
et->getDependence() |
-   (sz ? toTypeDependence(
- turnValueToTypeDependence(sz->getDependence()))
+   (sz ? toTypeDependence(sz->getDependence())
: TypeDependence::None) |
(tc == VariableArray ? TypeDependence::VariablyModified
  

[PATCH] D94943: [X86][AMX] Fix the typo.

2021-01-18 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke created this revision.
Herald added a subscriber: pengfei.
LuoYuanke requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The dpbsud should be dpbssd.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94943

Files:
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c


Index: clang/test/CodeGen/X86/amx_api.c
===
--- clang/test/CodeGen/X86/amx_api.c
+++ clang/test/CodeGen/X86/amx_api.c
@@ -27,7 +27,7 @@
 __tile_loadd(, buf2, STRIDE);
 __tile_loadd(, buf2, STRIDE);
   }
-  __tile_dpbsud(, a, b);
+  __tile_dpbssd(, a, b);
   __tile_stored(buf, STRIDE, c);
 }
 
@@ -39,11 +39,11 @@
   __tile_loadd(, buf, STRIDE);
 }
 
-void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_dpbsud
+void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbssd
   //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_dpbsud(, a, b);
+  __tile_dpbssd(, a, b);
 }
 
 void test_tile_stored(__tile1024i c) {
Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -258,7 +258,7 @@
 }
 
 __DEFAULT_FN_ATTRS_INT8
-static void __tile_dpbsud(__tile1024i *dst, __tile1024i src1,
+static void __tile_dpbssd(__tile1024i *dst, __tile1024i src1,
   __tile1024i src2) {
   dst->tile = _tile_dpbssd_internal(src1.row, src2.col, src1.col, dst->tile,
 src1.tile, src2.tile);


Index: clang/test/CodeGen/X86/amx_api.c
===
--- clang/test/CodeGen/X86/amx_api.c
+++ clang/test/CodeGen/X86/amx_api.c
@@ -27,7 +27,7 @@
 __tile_loadd(, buf2, STRIDE);
 __tile_loadd(, buf2, STRIDE);
   }
-  __tile_dpbsud(, a, b);
+  __tile_dpbssd(, a, b);
   __tile_stored(buf, STRIDE, c);
 }
 
@@ -39,11 +39,11 @@
   __tile_loadd(, buf, STRIDE);
 }
 
-void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
-  //CHECK-LABEL: @test_tile_dpbsud
+void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
+  //CHECK-LABEL: @test_tile_dpbssd
   //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
   //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
-  __tile_dpbsud(, a, b);
+  __tile_dpbssd(, a, b);
 }
 
 void test_tile_stored(__tile1024i c) {
Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -258,7 +258,7 @@
 }
 
 __DEFAULT_FN_ATTRS_INT8
-static void __tile_dpbsud(__tile1024i *dst, __tile1024i src1,
+static void __tile_dpbssd(__tile1024i *dst, __tile1024i src1,
   __tile1024i src2) {
   dst->tile = _tile_dpbssd_internal(src1.row, src2.col, src1.col, dst->tile,
 src1.tile, src2.tile);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

tianshilei1992 wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > I would add a chack that to auxiliary device was specified. And if it 
> > > > was specified, it means this is not device-only mode and still need to 
> > > > emit an error.
> > > No it doesn't. There is nothing wrong with https://godbolt.org/z/T1h9b5, 
> > > and as I said before, I can build the situation in various other ways as 
> > > well, some of which will be outside of the users control. A global can 
> > > exist in the host/device code only.
> > I'm not saying that this is wrong. This code was used to check that the 
> > compiler works correctly and it just allows developer to understand that 
> > there is a problem with the compiler if it misses something and there is a 
> > difference between host and device codegens. If we don't want to emit an 
> > error here, still would be good to have something like an assert to be sure 
> > that the host/device codegens are synced.
> That check still doesn't work for the test case provided by @jdoerfert 
> because host IR doesn't contain that global in the offload info.
As @tianshilei1992 says, my test case does show how this can never be an 
assertion/warning even for regular host+device compliation. There is no 
guarantee a host version exists, or a device one does. We need to gracefully 
allow either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94942: [clangd] Add tweak for implementing abstract class

2021-01-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 317456.
njames93 added a comment.

Forgot to add the untracked files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94942

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ImplementAbstract.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
@@ -0,0 +1,217 @@
+//===-- ImplementAbstractTests.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 "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(ImplementAbstract);
+
+TEST_F(ImplementAbstractTest, TestUnavailable) {
+
+  StringRef Cases[]{
+  // Not a pure virtual method.
+  R"cpp(
+  class A {
+virtual void Foo();
+  };
+  class ^B : public A {};
+)cpp",
+  // Pure virtual method overridden in class.
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+void Foo() override;
+  };
+)cpp",
+  // Pure virtual method overridden in class with virtual keyword
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+virtual void Foo() override;
+  };
+)cpp",
+  // Pure virtual method overridden in class without override keyword
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+void Foo();
+  };
+)cpp",
+  // Pure virtual method overriden in base class.
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class B : public A {
+void Foo() override;
+  };
+  class ^C : public B {
+  };
+)cpp"};
+  for (const auto  : Cases) {
+EXPECT_THAT(Case, Not(isAvailable()));
+  }
+}
+
+TEST_F(ImplementAbstractTest, TestApply) {
+  struct Case {
+llvm::StringRef TestHeader;
+llvm::StringRef TestSource;
+llvm::StringRef ExpectedSource;
+  };
+
+  Case Cases[]{
+  {
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };)cpp",
+  R"cpp(
+  class B : public A {^};
+)cpp",
+  R"cpp(
+  class B : public A {
+void Foo() override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+public:
+virtual void Foo() = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {};
+)cpp",
+  R"cpp(
+  class B : public A {
+public:
+
+void Foo() override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo(int Param) = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {};
+)cpp",
+  R"cpp(
+  class B : public A {
+void Foo(int Param) override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo(int Param) = 0;
+  };)cpp",
+  R"cpp(
+  struct ^B : public A {};
+)cpp",
+  R"cpp(
+  struct B : public A {
+private:
+
+void Foo(int Param) override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo(int Param) const volatile = 0;
+public:
+virtual void Bar(int Param) = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {
+void Foo(int Param) const volatile override;
+  };
+)cpp",
+  R"cpp(
+  class B : public A {
+void Foo(int Param) const volatile override;
+  
+public:
+
+void Bar(int Param) override;
+};
+)cpp",
+  },
+  {
+  R"cpp(
+   class A {
+virtual void Foo() = 0;
+virtual void Bar() = 0;
+  };
+  class B : public A {
+void Foo() override;
+  };
+)cpp",
+  R"cpp(
+  class ^C : public B {
+virtual void Baz();
+  };
+)cpp",
+  R"cpp(
+  class C : public B {
+virtual void Baz();
+void Bar() override;
+
+  };
+)cpp",
+  },
+  {
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };)cpp",
+  R"cpp(
+  class ^B : public A {
+~B();
+  };
+)cpp",
+  R"cpp(
+ 

[PATCH] D94942: [clangd] Add tweak for implementing abstract class

2021-01-18 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: sammccall, kadircet.
Herald added subscribers: usaxena95, arphaman, mgorny.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Add a tweak that will create declarations for all its base classes 
unimplemented pure virtual methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94942

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CMakeLists.txt


Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -117,6 +117,7 @@
   tweaks/ExpandMacroTests.cpp
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
+  tweaks/ImplementAbstractTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
   tweaks/PopulateSwitchTests.cpp
   tweaks/RawStringLiteralTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -21,6 +21,7 @@
   ExpandMacro.cpp
   ExtractFunction.cpp
   ExtractVariable.cpp
+  ImplementAbstract.cpp
   ObjCLocalizeStringLiteral.cpp
   PopulateSwitch.cpp
   RawStringLiteral.cpp


Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -117,6 +117,7 @@
   tweaks/ExpandMacroTests.cpp
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
+  tweaks/ImplementAbstractTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
   tweaks/PopulateSwitchTests.cpp
   tweaks/RawStringLiteralTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -21,6 +21,7 @@
   ExpandMacro.cpp
   ExtractFunction.cpp
   ExtractVariable.cpp
+  ImplementAbstract.cpp
   ObjCLocalizeStringLiteral.cpp
   PopulateSwitch.cpp
   RawStringLiteral.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94941: Add minor version to libclang.so and libclang-cpp.so SONAME

2021-01-18 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added a reviewer: sylvestre.ledru.
Herald added a subscriber: mgorny.
tstellar requested review of this revision.
Herald added a project: clang.

This patch is for the release/11.x branch.  We need to bump the SONAME, because
the ABI of the shared library is changing


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94941

Files:
  clang/CMakeLists.txt
  clang/tools/clang-shlib/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -150,6 +150,7 @@
   else()
 set_target_properties(libclang
   PROPERTIES
+  SOVERSION ${LIBCLANG_LIBRARY_VERSION}
   VERSION ${LIBCLANG_LIBRARY_VERSION}
   DEFINE_SYMBOL _CINDEX_LIB_)
 # FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,7 @@
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+
+set_target_properties(clang-cpp
+  PROPERTIES
+  SOVERSION ${LIBCLANG_LIBRARY_VERSION})
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -509,7 +509,7 @@
 "${CLANG_VERSION_MAJOR}" CACHE STRING
 "Major version number that will be appended to the clang executable name")
 set(LIBCLANG_LIBRARY_VERSION
-"${CLANG_VERSION_MAJOR}" CACHE STRING
+"${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}" CACHE STRING
 "Major version number that will be appended to the libclang library")
 mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION)
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -150,6 +150,7 @@
   else()
 set_target_properties(libclang
   PROPERTIES
+  SOVERSION ${LIBCLANG_LIBRARY_VERSION}
   VERSION ${LIBCLANG_LIBRARY_VERSION}
   DEFINE_SYMBOL _CINDEX_LIB_)
 # FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,7 @@
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+
+set_target_properties(clang-cpp
+  PROPERTIES
+  SOVERSION ${LIBCLANG_LIBRARY_VERSION})
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -509,7 +509,7 @@
 "${CLANG_VERSION_MAJOR}" CACHE STRING
 "Major version number that will be appended to the clang executable name")
 set(LIBCLANG_LIBRARY_VERSION
-"${CLANG_VERSION_MAJOR}" CACHE STRING
+"${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}" CACHE STRING
 "Major version number that will be appended to the libclang library")
 mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2021-01-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10111-10124
+// Check the static member's type given in the explicit instantiation
+// definition against the one in the class template. This won't happen in
+// explicit instantiation declaration because the instantiated code won't
+// be generated in that case.
+if (IsStaticDataMemberInstantiation &&
+TSK == TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameTypeIgnoreLifetime(Prev->getType(), R)) {

Can we combine this with the previous `if`? This is really checking the same 
thing that the `hasSameType` check above checked.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10116
+if (IsStaticDataMemberInstantiation &&
+TSK == TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameTypeIgnoreLifetime(Prev->getType(), R)) {

The check of `TSK` seems unnecessary (and incorrect) here -- we should check 
the type is correct regardless of whether this is an explicit instantiation 
declaration or an explicit instantiation definition.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10117
+TSK == TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameTypeIgnoreLifetime(Prev->getType(), R)) {
+  Diag(T->getTypeLoc().getBeginLoc(),

Please can you point us at an example that needs this "ignore lifetime" nuance? 
We should check with Apple folks what they want to happen here, and we should 
presumably have the same rule for all explicit instantiations of templated 
variables -- both in the static data member case here and the variable template 
case a few lines above.

My expectation is that we want one of these two rules:
1) the declared lifetime should match exactly between the declaration and the 
explicit instantiation, or
2) there cannot be a declared lifetime on the explicit instantiation, and a 
lifetime on the template declaration is ignored by the check
(or a combination of these rules where we accept either option). I don't think 
that matches what you're doing here -- in particular, I think a wrong declared 
lifetime on the explicit instantiation should result in an error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90448

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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 3 inline comments as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:52
+  property(get = __fetch_builtin_##NAME##_##FIELD)) unsigned int FIELD;
+#endif
 

jdoerfert wrote:
> Why do we need these __fetch_builtins (for C). They have a different name 
> than in the C++ variant anyway. In C we could just not define the __fetch 
> stuff but only the Field. So `gridDim.x` will work fine.
`__declspec(property)` doesn't support C so that code were removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 317453.
tianshilei1992 added a comment.

Removed code for C that are still not supported


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

Files:
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  clang/test/Headers/openmp_device_math_isnan.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp

Index: clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
===
--- clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
+++ clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fexceptions -fcxx-exceptions -aux-triple powerpc64le-unknown-unknown -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp -internal-isystem %S/../Headers/Inputs/include -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -fdeclspec -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 

[clang] bc713f6 - PR48763: Better handling for classes that inherit a default constructor.

2021-01-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-01-18T18:54:04-08:00
New Revision: bc713f6a004723d1325bc16e1efc32d0ac82f939

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

LOG: PR48763: Better handling for classes that inherit a default constructor.

The C++ standard wording doesn't appear to properly handle the case
where a class inherits a default constructor from a base class. Various
properties of classes are defined in terms of the corresponding property
of the default constructor, and in this case, the class does not have a
default constructor despite being default-constructible, which the
wording doesn't handle properly.

This change implements a tentative fix for these problems, which has
also been proposed to the C++ committee: if a class would inherit a
default constructor, and does not explicitly declare one, then one is
implicitly declared.

Added: 


Modified: 
clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
clang/test/CXX/special/class.ctor/p6-0x.cpp
clang/test/CXX/special/class.inhctor/p1.cpp
clang/test/CXX/special/class.inhctor/p2.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 4ce6771259d9..d15d6698860f 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -131,6 +131,10 @@ FIELD(HasUninitializedFields, 1, NO_MERGE)
 /// constructors from a base class.
 FIELD(HasInheritedConstructor, 1, NO_MERGE)
 
+/// True if there are any member using-declarations that inherit
+/// default constructors from a base class.
+FIELD(HasInheritedDefaultConstructor, 1, NO_MERGE)
+
 /// True if there are any member using-declarations named
 /// 'operator='.
 FIELD(HasInheritedAssignment, 1, NO_MERGE)

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 568eeb614a76..e32101bb2276 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -744,9 +744,14 @@ class CXXRecordDecl : public RecordDecl {
   ///
   /// This value is used for lazy creation of default constructors.
   bool needsImplicitDefaultConstructor() const {
-return !data().UserDeclaredConstructor &&
-   !(data().DeclaredSpecialMembers & SMF_DefaultConstructor) &&
-   (!isLambda() || lambdaIsDefaultConstructibleAndAssignable());
+return (!data().UserDeclaredConstructor &&
+!(data().DeclaredSpecialMembers & SMF_DefaultConstructor) &&
+(!isLambda() || lambdaIsDefaultConstructibleAndAssignable())) ||
+   // FIXME: Proposed fix to core wording issue: if a class inherits
+   // a default constructor and doesn't explicitly declare one, one
+   // is declared implicitly.
+   (data().HasInheritedDefaultConstructor &&
+!(data().DeclaredSpecialMembers & SMF_DefaultConstructor));
   }
 
   /// Determine whether this class has any user-declared constructors.

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index b806adf36bfb..0368ada0b81c 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -81,7 +81,9 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl 
*D)
   HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
   HasOnlyCMembers(true), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
-  HasInheritedConstructor(false), HasInheritedAssignment(false),
+  HasInheritedConstructor(false),
+  HasInheritedDefaultConstructor(false),
+  HasInheritedAssignment(false),
   NeedOverloadResolutionForCopyConstructor(false),
   NeedOverloadResolutionForMoveConstructor(false),
   NeedOverloadResolutionForCopyAssignment(false),
@@ -814,6 +816,8 @@ void CXXRecordDecl::addedMember(Decl *D) {
 //   constructor [...]
 if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor())
   data().HasConstexprNonCopyMoveConstructor = true;
+if (!isa(D) && Constructor->isDefaultConstructor())
+  data().HasInheritedDefaultConstructor = true;
   }
 
   // Handle destructors.

diff  --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp 
b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
index d64807ed5abd..4951ed6eb959 100644
--- a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
@@ -36,7 +36,7 @@ namespace default_ctor {
   };
 
   struct A {
-A(); // expected-note 

[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 317444.
tianshilei1992 added a comment.

Removed the useless assertion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp


Index: clang/test/OpenMP/declare_target_device_only_compilation.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,16 +2941,12 @@
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum)) {
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "Unable to find target region on line '%0' in the device code.");
-  CGM.getDiags().Report(DiagID) << LineNum;
-  return;
-}
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);
 auto  =
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum];
-assert(Entry.isValid() && "Entry not initialized!");
 Entry.setAddress(Addr);
 Entry.setID(ID);
 Entry.setFlags(Flags);
@@ -3017,9 +3013,10 @@
  OMPTargetGlobalVarEntryKind Flags,
  llvm::GlobalValue::LinkageTypes Linkage) {
   if (CGM.getLangOpts().OpenMPIsDevice) {
+// This could happen if the device compilation is invoked standalone.
+if (!hasDeviceGlobalVarEntryInfo(VarName))
+  initializeDeviceGlobalVarEntryInfo(VarName, Flags, OffloadingEntriesNum);
 auto  = OffloadEntriesDeviceGlobalVar[VarName];
-assert(Entry.isValid() && Entry.getFlags() == Flags &&
-   "Entry not initialized!");
 assert((!Entry.getAddress() || Entry.getAddress() == Addr) &&
"Resetting with the new address.");
 if (Entry.getAddress() && hasDeviceGlobalVarEntryInfo(VarName)) {


Index: clang/test/OpenMP/declare_target_device_only_compilation.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,16 +2941,12 @@
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum)) {
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,

[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 317443.
tianshilei1992 added a comment.

Fixed the test case and rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp


Index: clang/test/OpenMP/declare_target_device_only_compilation.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,13 +2941,10 @@
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum)) {
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "Unable to find target region on line '%0' in the device code.");
-  CGM.getDiags().Report(DiagID) << LineNum;
-  return;
-}
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);
 auto  =
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum];
 assert(Entry.isValid() && "Entry not initialized!");
@@ -3017,9 +3014,11 @@
  OMPTargetGlobalVarEntryKind Flags,
  llvm::GlobalValue::LinkageTypes Linkage) {
   if (CGM.getLangOpts().OpenMPIsDevice) {
+// This could happen if the device compilation is invoked standalone.
+if (!hasDeviceGlobalVarEntryInfo(VarName))
+  initializeDeviceGlobalVarEntryInfo(VarName, Flags, OffloadingEntriesNum);
 auto  = OffloadEntriesDeviceGlobalVar[VarName];
-assert(Entry.isValid() && Entry.getFlags() == Flags &&
-   "Entry not initialized!");
+assert(Entry.isValid() && "Entry not initialized!");
 assert((!Entry.getAddress() || Entry.getAddress() == Addr) &&
"Resetting with the new address.");
 if (Entry.getAddress() && hasDeviceGlobalVarEntryInfo(VarName)) {


Index: clang/test/OpenMP/declare_target_device_only_compilation.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_device_only_compilation.cpp
@@ -0,0 +1,15 @@
+//==///
+// RUN: %clang -S -target powerpc64le-ibm-linux-gnu -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target i386-pc-linux-gnu -fopenmp -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -S -target x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp declare target
+#pragma omp begin declare variant match(device={kind(nohost)})
+int G1;
+#pragma omp end declare variant
+#pragma omp end declare target
+
+// CHECK: @[[G:.+]] = hidden {{.*}}global i32 0, align 4
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2941,13 +2941,10 @@
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum)) {
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "Unable 

[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 3 inline comments as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > I would add a chack that to auxiliary device was specified. And if it was 
> > > specified, it means this is not device-only mode and still need to emit 
> > > an error.
> > No it doesn't. There is nothing wrong with https://godbolt.org/z/T1h9b5, 
> > and as I said before, I can build the situation in various other ways as 
> > well, some of which will be outside of the users control. A global can 
> > exist in the host/device code only.
> I'm not saying that this is wrong. This code was used to check that the 
> compiler works correctly and it just allows developer to understand that 
> there is a problem with the compiler if it misses something and there is a 
> difference between host and device codegens. If we don't want to emit an 
> error here, still would be good to have something like an assert to be sure 
> that the host/device codegens are synced.
That check still doesn't work for the test case provided by @jdoerfert because 
host IR doesn't contain that global in the offload info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94933: [clang] Check for nullptr when instantiating late attrs

2021-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

this looks reasonable to me, thanks for tracking it down!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94933

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


[PATCH] D94827: [SimplifyCFG] Require and preserve dominator tree

2021-01-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D94827#2505431 , @lebedev.ri wrote:

> Wow. So much polarization here.
>
> In D94827#2502435 , @kuhar wrote:
>
>> Wow, this is fantastic. When I first started working on the domtree updater 
>> back in 2017, SimplifyGFG seemed like one of the most difficult passes to 
>> handle, and I wasn't sure if we ever get there. Very impressive work, 
>> @lebedev.ri!
>
>
>
> In D94827#2504239 , @mkazantsev 
> wrote:
>
>> This is awesome. And scary. This is scarily awesome. :)
>
> Why thank you.
> It ended up being rather boringly trivial after all to me.
> The hard part was coming up with the gradual roll-out part (the flag)
>
> As for the rest of comments, let me split this up into parts.
>
> 1. Should SimplifyCFG know how to preserve {,Post}DominatorTree
> 2. Should SimplifyCFG make use of DominatorTree
> 3. Should SimplifyCFGPass require DominatorTree
>
> As for 1., for the life of me i can not take that question seriously.
> Let me point out that SimplifyCFG is an *Utility*, it can be called from 
> other passes,
> and as is painfully visible from the diff, both the `DwarfEHPrepare`
> and `AMDGPUUnifyDivergentExitNodes` do that already.
>
> By keeping SimplifyCFG illiterate about DomTrees, we force it's users
> to also avoid DomTrees to some extent, be it either to just not preserve them,
> or recompute them each time after calling SimplifyCFG.
>
> Is that really what we want to be doing?
> So if such a question is seriously being asked,
> i'd personally suggest to take a step back and **really** think about it.
>
> 3 - ignoring the cost of domtree preservation, this is basically free.
> As far as i can tell from the tests, it doesn't result in any new domtree 
> creations,
> we'd always already calculate domtree after the simplifycfg invocation,
> now we'll just do that earlier.
>
> 2 - well, yeah, that is a question of the patch, isn't it? :)
> Not sure why it's being met with such surprisingly-hostile comments.

I'm not sure why my comment was taken to be hostile. All I want to say is that 
there's a tradeoff here, and I haven't been convinced that it's a good one yet.

I think your point that SimplifyCFG is a utility and may be used in passes that 
want to preserve DT is a good one. I can see an argument for supporting 
DT-preservation in SimplifyCFG, while not requiring it in SimplifyCFGPass and 
not allowing use inside SimplifyCFG itself. Do I understand correctly that 
DwarfEHPrepare may currently use an outdated dominator tree because SimplifyCFG 
does not preserve it? If that is the case, then that should certainly be 
addressed in //some// way.

> In D94827#2505300 , @nikic wrote:
>
>> I'm somewhat skeptical about this change. The motivation seems a bit weak 
>> given the costs involved. The costs are:
>>
>> - Compile-time cost. Your best case estimate puts this at a 0.5% 
>> compile-time regression. This is for the case where SimplifyCFG simplify 
>> preserves DT, without using it. Once the DT is used, the DTU may be flushed 
>> many times while SimplifyCFG iterates. This will drive the average-case cost 
>> up, and likely introduce pathological cases as well.
>
> Gentle reminder that i have already previously suggested to codify that
> LLVM now prioritizes compile-time over everything.
> Or something to that regard, about compile time.
> I don't think that has happened yet, so i'm going to largely blatantly ignore 
> this point.

LLVM does not prioritize compile-time over everything. Compile-time regressions 
are fine as long as they are justified.

I have already stated my concern above. Preserving the DT is one thing, and a 
0.5% compile-time regression is not overly problematic. However, the intention 
behind this change is clearly to also make use of DT inside SimplifyCFG, and 
that's where things become very problematic.  I did a quick try of fetching the 
DT (and thus requiring a DTU flush) on every SimplifyCFG iteration (which is 
what would happen if we implemented your idea regarding unreachable blocks), 
and here's the result I got: 
https://llvm-compile-time-tracker.com/compare.php?from=22b68440e1647e16b5ee24b924986207173c02d1=879bffddcb45b02f3c819e542a327a553ea2=instructions
 Now we go from 0.5% regression to 2.5%. consumer-typeset sees a 5% regression. 
The regressions are larger on individual files, e.g. libclamav_pe.c sees as 
>30% regression. This isn't peanuts. And these are still "average case" 
regressions on relatively benign benchmarks. You can bet that if you do this, 
you're going to see pathologically large regressions on generated code.

I feel like this is a valid concern to have, and I don't like the way you're 
just brushing this off completely. While it seems like common sense to me, I 
will look into updating our developer policy to make explicit mention of 
compile-time 

[PATCH] D94884: [Clang][OpenMP] Include header for CUDA builtin vars into OpenMP wrapper header

2021-01-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:52
+  property(get = __fetch_builtin_##NAME##_##FIELD)) unsigned int FIELD;
+#endif
 

Why do we need these __fetch_builtins (for C). They have a different name than 
in the C++ variant anyway. In C we could just not define the __fetch stuff but 
only the Field. So `gridDim.x` will work fine.



Comment at: clang/lib/Headers/__clang_cuda_builtin_vars.h:95
   // uint3).  This function is defined after we pull in vector_types.h.
-  __attribute__((device)) operator dim3() const;
-  __attribute__((device)) operator uint3() const;
+  DEVICE operator dim3() const;
+  DEVICE operator uint3() const;

tianshilei1992 wrote:
> How can we deal with the conversion in C?
We don't. Given that CUDA is C++ we can just limit us to the C subset. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94884

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


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.






Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

jdoerfert wrote:
> ABataev wrote:
> > I would add a chack that to auxiliary device was specified. And if it was 
> > specified, it means this is not device-only mode and still need to emit an 
> > error.
> No it doesn't. There is nothing wrong with https://godbolt.org/z/T1h9b5, and 
> as I said before, I can build the situation in various other ways as well, 
> some of which will be outside of the users control. A global can exist in the 
> host/device code only.
I'm not saying that this is wrong. This code was used to check that the 
compiler works correctly and it just allows developer to understand that there 
is a problem with the compiler if it misses something and there is a difference 
between host and device codegens. If we don't want to emit an error here, still 
would be good to have something like an assert to be sure that the host/device 
codegens are synced.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94933: [clang] Check for nullptr when instantiating late attrs

2021-01-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: hokein.
Herald added subscribers: usaxena95, kadircet.
adamcz requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This was already done in SemaTemplateInstantiateDecl.cpp, but not in
SemaTemplateInstantiate.cpp.

Anecdotally I've seen some clangd crashes where coredumps point to this
being a problem, but I cannot reproduce this so far.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94933

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp


Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2794,7 +2794,8 @@
 
 Attr *NewAttr =
   instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
-I->NewDecl->addAttr(NewAttr);
+if (NewAttr)
+  I->NewDecl->addAttr(NewAttr);
 LocalInstantiationScope::deleteScopes(I->Scope,
   Instantiator.getStartingScope());
   }


Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2794,7 +2794,8 @@
 
 Attr *NewAttr =
   instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
-I->NewDecl->addAttr(NewAttr);
+if (NewAttr)
+  I->NewDecl->addAttr(NewAttr);
 LocalInstantiationScope::deleteScopes(I->Scope,
   Instantiator.getStartingScope());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Oh, and fix the test. If you have -verify and no errors you need `// 
expected-no-diagnostics`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM, one nit in the test below.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

ABataev wrote:
> I would add a chack that to auxiliary device was specified. And if it was 
> specified, it means this is not device-only mode and still need to emit an 
> error.
No it doesn't. There is nothing wrong with https://godbolt.org/z/T1h9b5, and as 
I said before, I can build the situation in various other ways as well, some of 
which will be outside of the users control. A global can exist in the 
host/device code only.



Comment at: clang/test/OpenMP/declare_target_device_only_compilation.cpp:13
+// CHECK: !omp_offload.info = !{!0}
+// CHECK: !0 = !{i32 1, !"[[G]]", i32 0, i32 0}

Run this as regular target offloading as well. no `-fopenmp-is-device` 
necessary, at least not in https://godbolt.org/z/T1h9b5.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94827: [SimplifyCFG] Require and preserve dominator tree

2021-01-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Wow. So much polarization here.

In D94827#2502435 , @kuhar wrote:

> Wow, this is fantastic. When I first started working on the domtree updater 
> back in 2017, SimplifyGFG seemed like one of the most difficult passes to 
> handle, and I wasn't sure if we ever get there. Very impressive work, 
> @lebedev.ri!



In D94827#2504239 , @mkazantsev wrote:

> This is awesome. And scary. This is scarily awesome. :)

Why thank you.
It ended up being rather boringly trivial after all to me.
The hard part was coming up with the gradual roll-out part (the flag)

As for the rest of comments, let me split this up into parts.

1. Should SimplifyCFG know how to preserve {,Post}DominatorTree
2. Should SimplifyCFG make use of DominatorTree
3. Should SimplifyCFGPass require DominatorTree

As for 1., for the life of me i can not take that question seriously.
Let me point out that SimplifyCFG is an *Utility*, it can be called from other 
passes,
and as is painfully visible from the diff, both the `DwarfEHPrepare`
and `AMDGPUUnifyDivergentExitNodes` do that already.

By keeping SimplifyCFG illiterate about DomTrees, we force it's users
to also avoid DomTrees to some extent, be it either to just not preserve them,
or recompute them each time after calling SimplifyCFG.

Is that really what we want to be doing?
So if such a question is seriously being asked,
i'd personally suggest to take a step back and **really** think about it.

3 - ignoring the cost of domtree preservation, this is basically free.
As far as i can tell from the tests, it doesn't result in any new domtree 
creations,
we'd always already calculate domtree after the simplifycfg invocation,
now we'll just do that earlier.

2 - well, yeah, that is a question of the patch, isn't it? :)
Not sure why it's being met with such surprisingly-hostile comments.

In D94827#2505300 , @nikic wrote:

> I'm somewhat skeptical about this change. The motivation seems a bit weak 
> given the costs involved. The costs are:
>
> - Compile-time cost. Your best case estimate puts this at a 0.5% compile-time 
> regression. This is for the case where SimplifyCFG simplify preserves DT, 
> without using it. Once the DT is used, the DTU may be flushed many times 
> while SimplifyCFG iterates. This will drive the average-case cost up, and 
> likely introduce pathological cases as well.

Gentle reminder that i have already previously suggested to codify that
LLVM now prioritizes compile-time over everything.
Or something to that regard, about compile time.
I don't think that has happened yet, so i'm going to largely blatantly ignore 
this point.

> - Code complexity: At least watching from afar, your path to preserving DT in 
> SimplifyCFG involved quite a few subtle issues, where the first 
> implementation of DT preservation for a given transformation later turned out 
> not to be entirely correct. Given the large number of very different 
> transforms that SimplifyCFG performs, this adds a code complexity and 
> maintenance cost.

1. See above.
2. This is true for practically every change, to some extent, so i'm not sure 
what the point is here.
3. "Never attribute to malice that which is adequately explained by stupidity", 
or in this case, it's not that "later turned out not to be entirely correct", 
this was a *very* intentional roll-out approach, to weed out the cases that 
lacked test coverage.

> The (listed) benefits are:
>
> - Not processing unreachable blocks. I am doubtful that we'll want to use the 
> DT for this purpose, because that would require flushing the DTU on each 
> SimplifyCFG iteration. You'd probably be better off running 
> removeUnreachableBlocks each time. Though it's not clear that this is even a 
> problem that needs solving.



> - Using DT in FoldBranchToCommonDest. This seems to be the real motivation 
> here. I will have to dive deeper into the code to understand what the problem 
> here is and whether it justifies the costs.

In the mean time, now that i'm done with the groundwork, i'll fix that the 
currently-preferred way.




Comment at: llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:263
 const SimplifyCFGOptions ) {
-  assert((!RequireAndPreserveDomTree ||
-  (DT && DT->verify(DominatorTree::VerificationLevel::Full))) &&

mkazantsev wrote:
> Why remove that? It looks useful to have (maybe over-paranoid) checks that DT 
> is correct at least for the first time. I'd rather keep them for a while 
> unless there is a reason to drop them now.
Note that this checks that the DomTree *provided by the pass manager* is valid.
Do we actually want to check that here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94827


[PATCH] D94403: [RISCV] Implement new architecture extension macros

2021-01-18 Thread Simon Cook via Phabricator via cfe-commits
simoncook updated this revision to Diff 317409.
simoncook added a comment.

Rebase on D94930  to show updated version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94403

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -12,12 +12,26 @@
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
 // CHECK-NOT: __riscv_atomic
+// CHECK-NOT: __riscv_zbb
+// CHECK-NOT: __riscv_zbc
+// CHECK-NOT: __riscv_zbe
+// CHECK-NOT: __riscv_zbf
+// CHECK-NOT: __riscv_zbm
+// CHECK-NOT: __riscv_zbp
+// CHECK-NOT: __riscv_zbproposedc
+// CHECK-NOT: __riscv_zbr
+// CHECK-NOT: __riscv_zbs
+// CHECK-NOT: __riscv_zbt
+// CHECK-NOT: __riscv_zfh
+// CHECK-NOT: __riscv_zvamo
+// CHECK-NOT: __riscv_zvlsseg
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
 // CHECK-M-EXT: __riscv_div 1
+// CHECK-M-EXT: __riscv_m 200
 // CHECK-M-EXT: __riscv_mul 1
 // CHECK-M-EXT: __riscv_muldiv 1
 
@@ -25,12 +39,14 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ia -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
+// CHECK-A-EXT: __riscv_a 200
 // CHECK-A-EXT: __riscv_atomic 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32if -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64if -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
+// CHECK-F-EXT: __riscv_f 200
 // CHECK-F-EXT: __riscv_fdiv 1
 // CHECK-F-EXT: __riscv_flen 32
 // CHECK-F-EXT: __riscv_fsqrt 1
@@ -39,6 +55,7 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
+// CHECK-D-EXT: __riscv_d 200
 // CHECK-D-EXT: __riscv_fdiv 1
 // CHECK-D-EXT: __riscv_flen 64
 // CHECK-D-EXT: __riscv_fsqrt 1
@@ -47,12 +64,14 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
+// CHECK-C-EXT: __riscv_c 200
 // CHECK-C-EXT: __riscv_compressed 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32ib0p92 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64ib0p92 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_b 92000
 // CHECK-B-EXT: __riscv_bitmanip 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x c -E -dM %s \
@@ -85,10 +104,83 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
 // RUN:   -march=rv64iv0p9 -x c -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// CHECK-V-EXT: __riscv_v 9000
 // CHECK-V-EXT: __riscv_vector 1
-//
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izbb0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izbb0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBB-EXT %s
+// CHECK-ZBB-EXT: __riscv_zbb 92000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izbc0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izbc0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBC-EXT %s
+// CHECK-ZBC-EXT: __riscv_zbc 92000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izbe0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBE-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izbe0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBE-EXT %s
+// CHECK-ZBE-EXT: __riscv_zbe 92000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izbf0p92 -x c -E -dM %s \
+// RUN: -o - | FileCheck 

[PATCH] D94930: [RISCV] Add support for Zvamo/Zvlsseg to driver

2021-01-18 Thread Simon Cook via Phabricator via cfe-commits
simoncook created this revision.
simoncook added reviewers: asb, luismarques, kito-cheng.
Herald added subscribers: frasercrmck, NickHung, evandro, apazos, 
sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
niosHD, sabuasal, johnrusso, rbar.
simoncook requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94930

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,3 +392,41 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izfh0p1 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZFH %s
 // RV32-EXPERIMENTAL-ZFH: "-target-feature" "+experimental-zfh"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo -### %s -c 2>&1 | 
\
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVAMO-NOFLAG %s
+// RV32-EXPERIMENTAL-ZVAMO-NOFLAG: error: invalid arch name 'rv32izvamo'
+// RV32-EXPERIMENTAL-ZVAMO-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVAMO-NOVERS %s
+// RV32-EXPERIMENTAL-ZVAMO-NOVERS: error: invalid arch name 'rv32izvamo'
+// RV32-EXPERIMENTAL-ZVAMO-NOVERS: experimental extension requires explicit 
version number
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo0p1 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVAMO-BADVERS %s
+// RV32-EXPERIMENTAL-ZVAMO-BADVERS: error: invalid arch name 'rv32izvamo0p1'
+// RV32-EXPERIMENTAL-ZVAMO-BADVERS: unsupported version number 0.1 for 
experimental extension
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVAMO-GOODVERS %s
+// RV32-EXPERIMENTAL-ZVAMO-GOODVERS: "-target-feature" "+experimental-zvamo"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvlsseg -### %s -c 2>&1 
| \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVLSSEG-NOFLAG %s
+// RV32-EXPERIMENTAL-ZVLSSEG-NOFLAG: error: invalid arch name 'rv32izvlsseg'
+// RV32-EXPERIMENTAL-ZVLSSEG-NOFLAG: requires 
'-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvlsseg 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVLSSEG-NOVERS %s
+// RV32-EXPERIMENTAL-ZVLSSEG-NOVERS: error: invalid arch name 'rv32izvlsseg'
+// RV32-EXPERIMENTAL-ZVLSSEG-NOVERS: experimental extension requires explicit 
version number
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvlsseg0p1 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVLSSEG-BADVERS %s
+// RV32-EXPERIMENTAL-ZVLSSEG-BADVERS: error: invalid arch name 
'rv32izvlsseg0p1'
+// RV32-EXPERIMENTAL-ZVLSSEG-BADVERS: unsupported version number 0.1 for 
experimental extension
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvlsseg0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVLSSEG-GOODVERS %s
+// RV32-EXPERIMENTAL-ZVLSSEG-GOODVERS: "-target-feature" 
"+experimental-zvlsseg"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -62,7 +62,7 @@
   Ext == "zbf" || Ext == "zbm" || Ext == "zbp" || Ext == "zbr" ||
   Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
 return RISCVExtensionVersion{"0", "92"};
-  if (Ext == "v")
+  if (Ext == "v" || Ext == "zvamo" || Ext == "zvlsseg")
 return RISCVExtensionVersion{"0", "9"};
   if (Ext == "zfh")
 return RISCVExtensionVersion{"0", "1"};


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,3 +392,41 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32izfh0p1 -menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZFH %s
 // RV32-EXPERIMENTAL-ZFH: "-target-feature" "+experimental-zfh"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo -### %s -c 2>&1 | \
+// RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVAMO-NOFLAG %s
+// RV32-EXPERIMENTAL-ZVAMO-NOFLAG: error: invalid arch name 'rv32izvamo'
+// 

[PATCH] D94906: [clang-format] Apply Allman style to lambdas

2021-01-18 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM.
As a note, I agree with @MyDeveloperDay.
It's more user-friendly and IMO less surprising to set the base wrapping style 
in `BreakBeforeBraces` and then customize it changing in `BraceWrapping`.
I'd argue that it won't be a breaking change for .clang-format configs that are 
"correct" and would just make the examples you brought above work as intended.
Current behaviour is even strange in one case, what values are set to elements 
*omitted* in `BraceWrapping` when `BreakBeforeBraces` is `Custom`? Those from 
`LLVM` style?
Anyway, that goes way beyond this patch. I'd think about implementing this time 
permitting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94906

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


[PATCH] D94906: [clang-format] Apply Allman style to lambdas

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

I think that would have helped me also. I think it's not that easy, but 
honestly never checked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94906

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


[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:90
+for (const auto  :
+ allTargetDecls(N->ASTNode, AST.getHeuristicResolver()))
   ActualDecls.emplace_back(Entry.first, Entry.second);

nridge wrote:
> sammccall wrote:
> > If we really want these to be separate, I think we should be using a null 
> > resolver except for the tests that are explicitly testing heuristics 
> > resolution. (And those tests could check both with/without resolver and 
> > verify it's required...)
> I'm not sure what you mean by "if we really want these to be separate". What 
> are "these"?
I mean the separation between the "hard" AST logic in FindTarget and the 
heuristic resolution. And by "we" I really mean "I", I guess :-)

Ideally we'd test these both separately and smoke-test the interaction, but I 
think the low-hanging fruit is to use all the existing tests, with most of them 
testing FindTarget in isolation and the few exceptions testing 
FindTarget+HeuristicResolver together.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

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


[PATCH] D94827: [SimplifyCFG] Require and preserve dominator tree

2021-01-18 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

>> Code complexity

Was there any RFC or general agreement?

After many patches for this goal the pass is now more complex and harder to 
read..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94827

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


[PATCH] D94927: [clangd] Use ASTSignals in Heuristics CC Ranking.

2021-01-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: kadircet, arphaman.
usaxena95 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94927

Files:
  clang-tools-extra/clangd/Quality.cpp


Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,17 @@
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 


Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,17 @@
   if (NeedsFixIts)
 Score *= 0.5f;
 
+  if (MainFileRefs >= 2) {
+// E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+float S = std::pow(MainFileRefs, -0.11);
+Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+  }
+  if (ScopeRefsInFile >= 2) {
+// E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+float S = std::pow(ScopeRefsInFile, -0.10);
+Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+  }
+
   return Score;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94827: [SimplifyCFG] Require and preserve dominator tree

2021-01-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

I'm somewhat skeptical about this change. The motivation seems a bit weak given 
the costs involved. The costs are:

- Compile-time cost. Your best case estimate puts this at a 0.5% compile-time 
regression. This is for the case where SimplifyCFG simplify preserves DT, 
without using it. Once the DT is used, the DTU may be flushed many times while 
SimplifyCFG iterates. This will drive the average-case cost up, and likely 
introduce pathological cases as well.
- Code complexity: At least watching from afar, your path to preserving DT in 
SimplifyCFG involved quite a few subtle issues, where the first implementation 
of DT preservation for a given transformation later turned out not to be 
entirely correct. Given the large number of very different transforms that 
SimplifyCFG performs, this adds a code complexity and maintenance cost.

The (listed) benefits are:

- Not processing unreachable blocks. I am doubtful that we'll want to use the 
DT for this purpose, because that would require flushing the DTU on each 
SimplifyCFG iteration. You'd probably be better off running 
removeUnreachableBlocks each time. Though it's not clear that this is even a 
problem that needs solving.
- Using DT in FoldBranchToCommonDest. This seems to be the real motivation 
here. I will have to dive deeper into the code to understand what the problem 
here is and whether it justifies the costs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94827

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


[PATCH] D92797: APINotes: add initial stub of APINotesWriter

2021-01-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Ping x 3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92797

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-18 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu added a comment.

In D91944#2505159 , @jdoerfert wrote:

> In D91944#2485167 , @jdoerfert wrote:
>
>> Are the test all passing?
>
> Can we fix the failing tests so we can merge this?

I will work on it this week. Will update soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-01-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for the comments! I'll have a more detailed look later, but just wanted 
to ask one clarifying question for now:




Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:90
+for (const auto  :
+ allTargetDecls(N->ASTNode, AST.getHeuristicResolver()))
   ActualDecls.emplace_back(Entry.first, Entry.second);

sammccall wrote:
> If we really want these to be separate, I think we should be using a null 
> resolver except for the tests that are explicitly testing heuristics 
> resolution. (And those tests could check both with/without resolver and 
> verify it's required...)
I'm not sure what you mean by "if we really want these to be separate". What 
are "these"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

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


[PATCH] D94804: [clang] Allow LifetimeExtendedTemporary to have no access specifier

2021-01-18 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG196cc96f9a64: [clang] Allow LifetimeExtendedTemporary to 
have no access specifier (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94804

Files:
  clang/lib/AST/DeclBase.cpp
  clang/test/PCH/cxx-reference.h


Index: clang/test/PCH/cxx-reference.h
===
--- clang/test/PCH/cxx-reference.h
+++ clang/test/PCH/cxx-reference.h
@@ -11,3 +11,7 @@
 LR & = c;
 RR  = c;
 RR & = 'c';
+
+struct S {
+  const int  = 1; // LifetimeExtendedTemporary inside struct
+};
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -971,21 +971,19 @@
   // 5. it's invalid
   // 6. it's a C++0x static_assert.
   // 7. it's a block literal declaration
-  if (isa(this) ||
-  isa(this) ||
-  isa(this) ||
-  !getDeclContext() ||
-  !isa(getDeclContext()) ||
-  isInvalidDecl() ||
-  isa(this) ||
-  isa(this) ||
+  // 8. it's a temporary with lifetime extended due to being default value.
+  if (isa(this) || isa(this) ||
+  isa(this) || !getDeclContext() ||
+  !isa(getDeclContext()) || isInvalidDecl() ||
+  isa(this) || isa(this) ||
   // FIXME: a ParmVarDecl can have ClassTemplateSpecialization
   // as DeclContext (?).
   isa(this) ||
   // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have
   // AS_none as access specifier.
   isa(this) ||
-  isa(this))
+  isa(this) ||
+  isa(this))
 return true;
 
   assert(Access != AS_none &&


Index: clang/test/PCH/cxx-reference.h
===
--- clang/test/PCH/cxx-reference.h
+++ clang/test/PCH/cxx-reference.h
@@ -11,3 +11,7 @@
 LR & = c;
 RR  = c;
 RR & = 'c';
+
+struct S {
+  const int  = 1; // LifetimeExtendedTemporary inside struct
+};
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -971,21 +971,19 @@
   // 5. it's invalid
   // 6. it's a C++0x static_assert.
   // 7. it's a block literal declaration
-  if (isa(this) ||
-  isa(this) ||
-  isa(this) ||
-  !getDeclContext() ||
-  !isa(getDeclContext()) ||
-  isInvalidDecl() ||
-  isa(this) ||
-  isa(this) ||
+  // 8. it's a temporary with lifetime extended due to being default value.
+  if (isa(this) || isa(this) ||
+  isa(this) || !getDeclContext() ||
+  !isa(getDeclContext()) || isInvalidDecl() ||
+  isa(this) || isa(this) ||
   // FIXME: a ParmVarDecl can have ClassTemplateSpecialization
   // as DeclContext (?).
   isa(this) ||
   // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have
   // AS_none as access specifier.
   isa(this) ||
-  isa(this))
+  isa(this) ||
+  isa(this))
 return true;
 
   assert(Access != AS_none &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 196cc96 - [clang] Allow LifetimeExtendedTemporary to have no access specifier

2021-01-18 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-01-18T19:19:57+01:00
New Revision: 196cc96f9a643d1cb828f48ef15ec30d0de24df7

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

LOG: [clang] Allow LifetimeExtendedTemporary to have no access specifier

The check only runs in debug mode during serialization, but
assert()-fail on:
  struct S { const int& x = 7; };
in C++ mode.

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

Added: 


Modified: 
clang/lib/AST/DeclBase.cpp
clang/test/PCH/cxx-reference.h

Removed: 




diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 0656efae5489..dc59f3dd1f15 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -971,21 +971,19 @@ bool Decl::AccessDeclContextSanity() const {
   // 5. it's invalid
   // 6. it's a C++0x static_assert.
   // 7. it's a block literal declaration
-  if (isa(this) ||
-  isa(this) ||
-  isa(this) ||
-  !getDeclContext() ||
-  !isa(getDeclContext()) ||
-  isInvalidDecl() ||
-  isa(this) ||
-  isa(this) ||
+  // 8. it's a temporary with lifetime extended due to being default value.
+  if (isa(this) || isa(this) ||
+  isa(this) || !getDeclContext() ||
+  !isa(getDeclContext()) || isInvalidDecl() ||
+  isa(this) || isa(this) ||
   // FIXME: a ParmVarDecl can have ClassTemplateSpecialization
   // as DeclContext (?).
   isa(this) ||
   // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have
   // AS_none as access specifier.
   isa(this) ||
-  isa(this))
+  isa(this) ||
+  isa(this))
 return true;
 
   assert(Access != AS_none &&

diff  --git a/clang/test/PCH/cxx-reference.h b/clang/test/PCH/cxx-reference.h
index b46a3671a325..a65d3feee072 100644
--- a/clang/test/PCH/cxx-reference.h
+++ b/clang/test/PCH/cxx-reference.h
@@ -11,3 +11,7 @@ LR  = c;
 LR & = c;
 RR  = c;
 RR & = 'c';
+
+struct S {
+  const int  = 1; // LifetimeExtendedTemporary inside struct
+};



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


[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-01-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko

> F14534708: report-6ea17d.html 

I checked it in IE. It doesn't draw arrows. Investigate this, please.




Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:147
+bool isArrowPiece(const PathDiagnosticPiece ) {
+  return isa(P) && P.getString().empty();
+}

Are you sure that **non-arrow** piece **always** has **non-empty** string 
representation? Can this give us a false positive result?



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:458
   }
   if (event.key == "S") {
 var checked = document.getElementsByName("showCounterexample")[0].checked;

Seems like this shortcut works only with the capital **S** aka //shift+s//
Should we support any **s** state?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D91944#2485167 , @jdoerfert wrote:

> Are the test all passing?

Can we fix the failing tests so we can merge this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D91944#2504924 , @protze.joachim 
wrote:

> I found two issues with this patch regarding the `default` clause:
>
> - The spec does not require a default clause. I get `error: expected 
> expression` if I omit a default clause. The error is gone if I add 
> `default()`.
> - The spec does not allow an empty `default()` clause, but rather expects 
> `default(nothing)`or omission of the default clause. This patch accepts the 
> empty default clause.

There are various issues with this patch. We will fix them afterwards. The 
patch provides a lot of infrastructure we need. Please provide the problematic 
cases in a bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

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

In D93844#2504388 , 
@HazardyKnusperkeks wrote:

> In D93844#2504376 , @MyDeveloperDay 
> wrote:
>
>> What I can't easily tell from the tests is if you are overriding any styles 
>> defined in the parent with a local style.
>
> Yes I do, but I will try to make it clearer in the tests.

Okay after rechecking the code (it is a bit ago that I wrote it), what more do 
you need? I compare the parsed style against a base style (`Google`, to show 
that it’s not the default `LLVM`) modified with the values from the overwrite. 
Only for the last checks where I basically check the same over and over again, 
just trough different means I use a stored style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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


[PATCH] D94403: [RISCV] Implement new architecture extension macros

2021-01-18 Thread Simon Cook via Phabricator via cfe-commits
simoncook added a comment.

In D94403#2504046 , @kito-cheng wrote:

> Thanks you implement that on clang, I think it's really great to included 
> that in LLVM 12 release.
>
> I would like to define marco for sub-extension too, I know that's my fault, I 
> didn't specify the behavior of sub-extension clearly on the spec, but I think 
> it would be great if we also define sub-extension marcos, since it would be 
> easier to check when some core only implement sub-extension, and the code can 
> just check the sub-extensio rather than check both.

That's no problem, I'll extend to cover sub-extensions before landing. I notice 
the zvamo/zvlsseg extensions aren't yet accepted by the -march flag, so I will 
put a patch together for those and likely land those together.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94403

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


[PATCH] D94906: [clang-format] Apply Allman style to lambdas

2021-01-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Similarly I see users having to define everything just to turn one thing off

  {F15089845, size=full}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94906

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


[PATCH] D94906: [clang-format] Apply Allman style to lambdas

2021-01-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think this is LGTM, however..

I've always felt that we shouldn't require `BreakBeforeBraces` to be `Custom` 
in order to be able to use the BraceWrapping.

Users in my view should be able to say:

  BreakBeforeBraces: Allman
  BraceWrapping:
 BeforeLambdaBody: true

This would mean users could pick the "Closest" style to theirs and then modify 
just the fields.

Either that or using BraceWrapping with a non Custom style should be a warning.

It doesn't take much to find .clang-format files on github that look like this

F15089833: image.png 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94906

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


[clang] 291ac7e - [AArch64] Revert back to Intrinsic<> for TME instructions.

2021-01-18 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-01-18T18:03:58Z
New Revision: 291ac7e622d542f8b25f74bc28051762edc90938

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

LOG: [AArch64] Revert back to Intrinsic<> for TME instructions.

This patch reverts back to Intrinsic for the instructions for the
transactional memory extension, so nosync is not included.

Added: 


Modified: 
clang/test/CodeGen/aarch64-tme.cpp
llvm/include/llvm/IR/IntrinsicsAArch64.td

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-tme.cpp 
b/clang/test/CodeGen/aarch64-tme.cpp
index 40a9ab3561ef..5004751cb300 100644
--- a/clang/test/CodeGen/aarch64-tme.cpp
+++ b/clang/test/CodeGen/aarch64-tme.cpp
@@ -38,5 +38,5 @@ extern "C" void arm_feature_tme_defined() {}
 #endif
 // CHECK: define{{.*}} void @arm_feature_tme_defined()
 
-// CHECK: attributes #1 = { nounwind }
+// CHECK: attributes #1 = { nounwind willreturn }
 

diff  --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td 
b/llvm/include/llvm/IR/IntrinsicsAArch64.td
index 9de3e8d732dd..da3085171b19 100644
--- a/llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -811,16 +811,16 @@ def int_aarch64_stgp  : DefaultAttrsIntrinsic<[], 
[llvm_ptr_ty, llvm_i64_ty, llv
 // Transactional Memory Extension (TME) Intrinsics
 let TargetPrefix = "aarch64" in {
 def int_aarch64_tstart  : GCCBuiltin<"__builtin_arm_tstart">,
- DefaultAttrsIntrinsic<[llvm_i64_ty]>;
+ Intrinsic<[llvm_i64_ty], [], [IntrWillReturn]>;
 
-def int_aarch64_tcommit : GCCBuiltin<"__builtin_arm_tcommit">, 
DefaultAttrsIntrinsic<[]>;
+def int_aarch64_tcommit : GCCBuiltin<"__builtin_arm_tcommit">, Intrinsic<[], 
[], [IntrWillReturn]>;
 
 def int_aarch64_tcancel : GCCBuiltin<"__builtin_arm_tcancel">,
-  DefaultAttrsIntrinsic<[], [llvm_i64_ty], 
[ImmArg>]>;
+  Intrinsic<[], [llvm_i64_ty], [IntrWillReturn, 
ImmArg>]>;
 
 def int_aarch64_ttest   : GCCBuiltin<"__builtin_arm_ttest">,
-  DefaultAttrsIntrinsic<[llvm_i64_ty], [],
-[IntrNoMem, IntrHasSideEffects]>;
+  Intrinsic<[llvm_i64_ty], [],
+[IntrNoMem, IntrHasSideEffects, 
IntrWillReturn]>;
 
 // Armv8.7-A load/store 64-byte intrinsics
 defvar data512 = !listsplat(llvm_i64_ty, 8);



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


[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks a lot for doing this!
I have some thoughts on how we can give it a nice API/more clearly separate it 
from FindTarget/improve internal structure.

I'm not sure how we should sequence that/how much to do.
One the one hand, simply moving this code is progress! On the other hand, after 
splitting it the API is more relevant.
We can do certainly land this as mostly moving the code with its existing 
structure if you like, and I or you could try to clean up the interface later.

I would like to get your feedback on the ideas though as I spent a *long* time 
staring at this code today and want to make sure I'm not crazy :-)

In D92290#2504161 , @nridge wrote:

> Change approach to factor out a HeuristicResolver class
>
> I didn't make it an optional parameter to allTargetDecls() etc. If you feel 
> there are call sites which would benefit from //not// passing one in, we can 
> change this.

As far as I know we should always have this available in production, so I don't 
think it needs to be optional in the signature.
However I think it should be *nullable* so we can test this separately, if that 
makes sense?




Comment at: clang-tools-extra/clangd/FindTarget.cpp:453
 case NestedNameSpecifier::TypeSpecWithTemplate:
-  add(QualType(resolveNestedNameSpecifierToType(NNS), 0), Flags);
+  add(QualType(Resolver->resolveNestedNameSpecifierToType(NNS), 0), Flags);
   return;

only `Identifier` needs the heuristic resolution, TypeSpec[WithTemplate] can 
just pull out the stored type



Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:114
+  }
+  if (const auto *ME = dyn_cast(E))
+return {ME->getMemberDecl()};

We shouldn't need these cases, if we're only trying to support dependent E.
(And otherwise, there are lots of other cases we could potentially need to 
support here eventually)



Comment at: clang-tools-extra/clangd/HeuristicResolver.h:37
+
+class HeuristicResolver {
+public:

This could use some class documentation explaining the idea - basically that 
clang's AST generally stores only fully-resolved edges, and therefore template 
ASTs are missing lots of information that we can guess in common cases.



Comment at: clang-tools-extra/clangd/HeuristicResolver.h:37
+
+class HeuristicResolver {
+public:

sammccall wrote:
> This could use some class documentation explaining the idea - basically that 
> clang's AST generally stores only fully-resolved edges, and therefore 
> template ASTs are missing lots of information that we can guess in common 
> cases.
We should have some shared contract around how cases where heuristics are not 
needed (i.e. non-dependent code). And given the current functions, it's not 
obvious what this contract should be.

On the one hand, if we attempt to handle such cases here, I'm not sure we've 
really separated this from FindTarget - e.g. it's hard to find a crisp 
definition of resolveExprToDecls that's distinct from targetDecls(). And we end 
up duplicating code between the two.
On the other hand, if we don't, then internal calls (like the implementation of 
`resolveNestedNameSpecifierToType`) are really awkward.

In either case, I think the resolution is to make sure the scope of the 
heuristic bits are as narrow/isolated as possible. Then if we want to handle 
all cases, it's manageable to do so. And if we don't, we can easily define a 
peer e.g. `resolveNNSToType(const NNS&, const HeuristicResolver *)` either here 
or in AST.h.

(Currently it appears the actual code currently handles some but not all 
non-dependent cases)



Comment at: clang-tools-extra/clangd/HeuristicResolver.h:50
+  // for a call to vector::size().
+  // The name to look up is provided in the form of a factory that takes
+  // an ASTContext, because an ASTContext may be needed to obtain the

Doc seems stale



Comment at: clang-tools-extra/clangd/HeuristicResolver.h:55
+  std::vector
+  resolveDependentMember(const Type *T, DeclarationName NameFactory,
+ llvm::function_ref Filter);

This seems like a really nice example of a heuristic lookup with a clear 
contract :-)



Comment at: clang-tools-extra/clangd/HeuristicResolver.h:56
+  resolveDependentMember(const Type *T, DeclarationName NameFactory,
+ llvm::function_ref Filter);
+

nit: const throughout?



Comment at: clang-tools-extra/clangd/HeuristicResolver.h:60
+  // or more declarations that it likely references.
+  std::vector resolveExprToDecls(const Expr *E);
+

This is pretty vaguely defined. From reading the implementation, this can 
choose to return two things:

1. a ValueDecl representing the value of E
2. a TypeDecl representing the type of E


[PATCH] D94919: [clangd] Fix a crash when indexing invalid ObjC method declaration

2021-01-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
adamcz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This fix will make us not crash, but ideally we would handle this case
better.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94919

Files:
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3493,6 +3493,14 @@
   return Result.TakeString();
 }
 
+if (Method->param_size() > Sel.getNumArgs()) {
+  // FIXME: We could be smarter about this, but for now just avoid a crash
+  // below by returning early.
+  Result.AddTypedTextChunk(
+  Result.getAllocator().CopyString(ND->getNameAsString()));
+  return Result.TakeString();
+}
+
 std::string SelName = Sel.getNameForSlot(0).str();
 SelName += ':';
 if (StartParameter == 0)
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1801,6 +1801,23 @@
   EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
 }
 
+TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {
+  auto TU = TestTU::withCode(R"objc(
+/*error-ok*/
+@interface Foo
+- (void)fun:(bool)foo
+  bar:(bool)bar,
+  baz:(bool)baz;
+@end
+  )objc");
+  TU.ExtraArgs.push_back("-xobjective-c++");
+
+  TU.build();
+  // We mostly care about not crashing, but verify that we didn't insert 
garbage
+  // about X too.
+  EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3493,6 +3493,14 @@
   return Result.TakeString();
 }
 
+if (Method->param_size() > Sel.getNumArgs()) {
+  // FIXME: We could be smarter about this, but for now just avoid a crash
+  // below by returning early.
+  Result.AddTypedTextChunk(
+  Result.getAllocator().CopyString(ND->getNameAsString()));
+  return Result.TakeString();
+}
+
 std::string SelName = Sel.getNameForSlot(0).str();
 SelName += ':';
 if (StartParameter == 0)
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1801,6 +1801,23 @@
   EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
 }
 
+TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {
+  auto TU = TestTU::withCode(R"objc(
+/*error-ok*/
+@interface Foo
+- (void)fun:(bool)foo
+  bar:(bool)bar,
+  baz:(bool)baz;
+@end
+  )objc");
+  TU.ExtraArgs.push_back("-xobjective-c++");
+
+  TU.build();
+  // We mostly care about not crashing, but verify that we didn't insert garbage
+  // about X too.
+  EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

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

LGTM.


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

https://reviews.llvm.org/D90173

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


[PATCH] D94473: [clangd] Use AST-based signals in CodeCompletion.

2021-01-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG275716d6db79: [clangd] Derive new signals in CC from 
ASTSignals. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94473

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/Quality.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "ASTSignals.h"
 #include "Annotations.h"
 #include "ClangdServer.h"
 #include "CodeComplete.h"
@@ -51,6 +52,8 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(MainFileRefs, Refs, "") { return arg.MainFileRefs == Refs; }
+MATCHER_P(ScopeRefs, Refs, "") { return arg.ScopeRefsInFile == Refs; }
 MATCHER_P(NameStartsWith, Prefix, "") {
   return llvm::StringRef(arg.Name).startswith(Prefix);
 }
@@ -1110,6 +1113,49 @@
   UnorderedElementsAre(Named("xy1"), Named("xy2")));
 }
 
+TEST(CompletionTest, ASTSignals) {
+  struct Completion {
+std::string Name;
+unsigned MainFileRefs;
+unsigned ScopeRefsInFile;
+  };
+  CodeCompleteOptions Opts;
+  std::vector RecordedCompletions;
+  Opts.RecordCCResult = [](const CodeCompletion ,
+   const SymbolQualitySignals &,
+   const SymbolRelevanceSignals ,
+   float Score) {
+RecordedCompletions.push_back({CC.Name, R.MainFileRefs, R.ScopeRefsInFile});
+  };
+  ASTSignals MainFileSignals;
+  MainFileSignals.ReferencedSymbols[var("xy1").ID] = 3;
+  MainFileSignals.ReferencedSymbols[var("xy2").ID] = 1;
+  MainFileSignals.ReferencedSymbols[var("xyindex").ID] = 10;
+  MainFileSignals.RelatedNamespaces["tar::"] = 5;
+  MainFileSignals.RelatedNamespaces["bar::"] = 3;
+  Opts.MainFileSignals = 
+  Opts.AllScopes = true;
+  completions(
+  R"cpp(
+  int xy1;
+  int xy2;
+  namespace bar {
+  int xybar = 1;
+  int a = xy^
+  }
+  )cpp",
+  /*IndexSymbols=*/{var("xyindex"), var("tar::xytar"), var("bar::xybar")},
+  Opts);
+  EXPECT_THAT(RecordedCompletions,
+  UnorderedElementsAre(
+  AllOf(Named("xy1"), MainFileRefs(3u), ScopeRefs(0u)),
+  AllOf(Named("xy2"), MainFileRefs(1u), ScopeRefs(0u)),
+  AllOf(Named("xyindex"), MainFileRefs(10u), ScopeRefs(0u)),
+  AllOf(Named("xytar"), MainFileRefs(0u), ScopeRefs(5u)),
+  AllOf(/*both from sema and index*/ Named("xybar"),
+MainFileRefs(0u), ScopeRefs(3u;
+}
+
 SignatureHelp signatures(llvm::StringRef Text, Position Point,
  std::vector IndexSymbols = {}) {
   std::unique_ptr Index;
Index: clang-tools-extra/clangd/Quality.h
===
--- clang-tools-extra/clangd/Quality.h
+++ clang-tools-extra/clangd/Quality.h
@@ -29,6 +29,7 @@
 
 #include "ExpectedTypes.h"
 #include "FileDistance.h"
+#include "TUScheduler.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -140,6 +141,14 @@
   /// CompletionPrefix.
   unsigned FilterLength = 0;
 
+  const ASTSignals *MainFileSignals = nullptr;
+  /// Number of references to the candidate in the main file.
+  unsigned MainFileRefs = 0;
+  /// Number of unique symbols in the main file which belongs to candidate's
+  /// namespace. This indicates how relevant the namespace is in the current
+  /// file.
+  unsigned ScopeRefsInFile = 0;
+
   /// Set of derived signals computed by calculateDerivedSignals(). Must not be
   /// set explicitly.
   struct DerivedSignals {
@@ -155,6 +164,7 @@
 
   void merge(const CodeCompletionResult );
   void merge(const Symbol );
+  void computeASTSignals(const CodeCompletionResult );
 
   // Condense these signals down to a single number, higher is better.
   float evaluateHeuristics() const;
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -294,6 +294,38 @@
   if (!(IndexResult.Flags & Symbol::VisibleOutsideFile)) {
 Scope = AccessibleScope::FileScope;
   }
+  if (MainFileSignals) {
+MainFileRefs =
+std::max(MainFileRefs,
+ 

[clang-tools-extra] 275716d - [clangd] Derive new signals in CC from ASTSignals.

2021-01-18 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2021-01-18T17:37:27+01:00
New Revision: 275716d6db79a6da3d5cee12139dd0c0abf8fd07

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

LOG: [clangd] Derive new signals in CC from ASTSignals.

This patch only introduces new signals but does not use their value
in scoring a CC candidate. Usage of these signals in CC ranking in both
heiristics and ML model will be introduced in later patches.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/Quality.h
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 4f3a47dff05d..a76250fa168e 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -255,6 +255,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
 ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
 ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
 
+CodeCompleteOpts.MainFileSignals = IP->Signals;
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CodeCompleteResult Result = clangd::codeComplete(

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b3b40022fbb2..9cc18ae789d5 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1685,6 +1685,7 @@ class CodeCompleteFlow {
 if (PreferredType)
   Relevance.HadContextType = true;
 Relevance.ContextWords = 
+Relevance.MainFileSignals = Opts.MainFileSignals;
 
 auto  = Bundle.front();
 if (auto FuzzyScore = fuzzyScore(First))

diff  --git a/clang-tools-extra/clangd/CodeComplete.h 
b/clang-tools-extra/clangd/CodeComplete.h
index ddcbd487ecc6..debf71d4117c 100644
--- a/clang-tools-extra/clangd/CodeComplete.h
+++ b/clang-tools-extra/clangd/CodeComplete.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 
+#include "ASTSignals.h"
 #include "Compiler.h"
 #include "Headers.h"
 #include "Protocol.h"
@@ -89,6 +90,7 @@ struct CodeCompleteOptions {
   /// clangd.
   const SymbolIndex *Index = nullptr;
 
+  const ASTSignals *MainFileSignals = nullptr;
   /// Include completions that require small corrections, e.g. change '.' to
   /// '->' on member access etc.
   bool IncludeFixIts = false;

diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 27b959ecacb3..1c41b7c7661f 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -294,6 +294,38 @@ void SymbolRelevanceSignals::merge(const Symbol 
) {
   if (!(IndexResult.Flags & Symbol::VisibleOutsideFile)) {
 Scope = AccessibleScope::FileScope;
   }
+  if (MainFileSignals) {
+MainFileRefs =
+std::max(MainFileRefs,
+ MainFileSignals->ReferencedSymbols.lookup(IndexResult.ID));
+ScopeRefsInFile =
+std::max(ScopeRefsInFile,
+ MainFileSignals->RelatedNamespaces.lookup(IndexResult.Scope));
+  }
+}
+
+void SymbolRelevanceSignals::computeASTSignals(
+const CodeCompletionResult ) {
+  if (!MainFileSignals)
+return;
+  if ((SemaResult.Kind != CodeCompletionResult::RK_Declaration) &&
+  (SemaResult.Kind != CodeCompletionResult::RK_Pattern))
+return;
+  if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+auto ID = getSymbolID(ND);
+if (!ID)
+  return;
+MainFileRefs =
+std::max(MainFileRefs, MainFileSignals->ReferencedSymbols.lookup(ID));
+if (const auto *NSD = dyn_cast(ND->getDeclContext())) {
+  if (NSD->isAnonymousNamespace())
+return;
+  std::string Scope = printNamespaceScope(*NSD);
+  if (!Scope.empty())
+ScopeRefsInFile = std::max(
+ScopeRefsInFile, MainFileSignals->RelatedNamespaces.lookup(Scope));
+}
+  }
 }
 
 void SymbolRelevanceSignals::merge(const CodeCompletionResult ) {
@@ -315,6 +347,7 @@ void SymbolRelevanceSignals::merge(const 
CodeCompletionResult ) {
 InBaseClass |= SemaCCResult.InBaseClass;
   }
 
+  computeASTSignals(SemaCCResult);
   // Declarations are scoped, others (like macros) are assumed global.
   if (SemaCCResult.Declaration)
 Scope = std::min(Scope, computeScope(SemaCCResult.Declaration));

diff  --git a/clang-tools-extra/clangd/Quality.h 

[PATCH] D92277: [OpenCL] Refactor of targets OpenCL option settings

2021-01-18 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/lib/Basic/TargetInfo.cpp:360
+// Set core features based on OpenCL version
+for (auto CoreExt : clang::getCoreFeatures(Opts))
+  getTargetOpts().OpenCLFeaturesMap[CoreExt] = true;

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > I still think the target map should be immutable and especially we 
> > > > should not change it silently based on the language compiled even if we 
> > > > have done it before but that caused incorrect behavior i.e. 
> > > > successfully compiling for the architectures that didn't support the 
> > > > features.
> > > > 
> > > > If I look at existing targets they already set most of the core 
> > > > features apart from 3d image writes. Perhaps it is reasonable to just 
> > > > drop this code? I don't think it makes the issue worse, in fact, I 
> > > > think it will make the behavior slightly better because now a 
> > > > diagnostic will occur if there is an attempt to use the unsupported 
> > > > feature although the diagnostic won't be the optimal one.  After all it 
> > > > will still remain the responsibility of the user to get the right 
> > > > combination of a language version and a target.
> > > > 
> > > > It would be reasonable however to introduce a diagnostic that would 
> > > > report a mismatch between the language version and the hardware support 
> > > > available. We report similar diagnostics in `CompilerInvocation` 
> > > > already. But I don't think we have to do it in this patch because it 
> > > > doesn't introduce any regression. We already have a bug although the 
> > > > behavior of this bug will change. And perhaps if we add `OpenCLOptions` 
> > > > as a part of `LangOpts` at some point this will become straightforward 
> > > > to diagnose. However, I suggest we add information about this issue in 
> > > > a FIXME or perhaps this deserves a clang bug!
> > > > I still think the target map should be immutable and especially we 
> > > > should not change it silently based on the language compiled
> > > 
> > > I'm confused. I think we have agreed to unconditionally support core 
> > > features for a specific language version. Did I miss something?
> > > 
> > > > successfully compiling for the architectures that didn't support the 
> > > > features.
> > > 
> > > I like idea providing diagnostics in that case. Something like: "Warning: 
> > > r600 target doesn't support 
> > > cl_khr_3d_image_writes which is core in OpenCL C 2.0, consider using 
> > > OpenCL C 3.0". I also think this should be done in a separate commit.
> > > 
> > > > If I look at existing targets they already set most of the core 
> > > > features apart from 3d image writes. Perhaps it is reasonable to just 
> > > > drop this code?
> > > 
> > > Oh, I haven't noticed that target set core features. For example 
> > > //cl_khr_global_int32_base_atomics// is being set by NVPTX and AMDGPU, so 
> > > I agree that this should be removed from target settings.
> > It is correct that the core features should be set unconditionally but not 
> > in the `TargetInfo`. If core features are used for targets that don't 
> > support them then it should not succeed silently as it does now i.e. this 
> > means we need to know what is supported by the targets.
> > 
> > Setting target features in `TargetInfo` is correct and should stay.  We 
> > should not change them here though because the language version doesn't 
> > change the target capabilities. It can either expose or hide them from the 
> > user but it should not modify targets. This is why `TargetInfo` is 
> > immutable after its creation and this is how it should stay. I think it's 
> > better if we remove the code here completely and introduce a diagnostic in 
> > the subsequent patches that would just check that the features required in 
> > the language version are supported by the target.
> > 
> > If we do this then during the parsing we will only use feature information 
> > from `OpenCLOptions` not the targets, but we will know that the target have 
> > support of all the features because the check has been performed earlier.
> I'm not generally against of removing core features set up, but I do have 
> some questions and arguments:
> 
> > It is correct that the core features should be set unconditionally but not 
> > in the TargetInfo
> 
> Just to make sure: where do you mean core features should be set 
> unconditionally? 
> 
> > Setting target features in TargetInfo is correct and should stay. We should 
> > not change them here though because the language version doesn't change the 
> > target capabilities. It can either expose or hide them from the user but it 
> > should not modify targets. This is why TargetInfo is immutable after its 
> > creation and this is how it should stay
> 
> I agree that `TargetInfo `should stay immutable during parsing, but for 
> example here, in `TargetInfo::adjust`, current 

[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-18 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added a comment.

I found two issues with this patch regarding the `default` clause:

- The spec does not require a default clause. I get `error: expected 
expression` if I omit a default clause. The error is gone if I add `default()`.
- The spec does not allow an empty `default()` clause, but rather expects 
`default(nothing)`or omission of the default clause. This patch accepts the 
empty default clause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-01-18 Thread Alex Orlov via Phabricator via cfe-commits
aorlov added a comment.

Just a ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D92277: [OpenCL] Refactor of targets OpenCL option settings

2021-01-18 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/lib/Basic/TargetInfo.cpp:360
+// Set core features based on OpenCL version
+for (auto CoreExt : clang::getCoreFeatures(Opts))
+  getTargetOpts().OpenCLFeaturesMap[CoreExt] = true;

Anastasia wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > I still think the target map should be immutable and especially we should 
> > > not change it silently based on the language compiled even if we have 
> > > done it before but that caused incorrect behavior i.e. successfully 
> > > compiling for the architectures that didn't support the features.
> > > 
> > > If I look at existing targets they already set most of the core features 
> > > apart from 3d image writes. Perhaps it is reasonable to just drop this 
> > > code? I don't think it makes the issue worse, in fact, I think it will 
> > > make the behavior slightly better because now a diagnostic will occur if 
> > > there is an attempt to use the unsupported feature although the 
> > > diagnostic won't be the optimal one.  After all it will still remain the 
> > > responsibility of the user to get the right combination of a language 
> > > version and a target.
> > > 
> > > It would be reasonable however to introduce a diagnostic that would 
> > > report a mismatch between the language version and the hardware support 
> > > available. We report similar diagnostics in `CompilerInvocation` already. 
> > > But I don't think we have to do it in this patch because it doesn't 
> > > introduce any regression. We already have a bug although the behavior of 
> > > this bug will change. And perhaps if we add `OpenCLOptions` as a part of 
> > > `LangOpts` at some point this will become straightforward to diagnose. 
> > > However, I suggest we add information about this issue in a FIXME or 
> > > perhaps this deserves a clang bug!
> > > I still think the target map should be immutable and especially we should 
> > > not change it silently based on the language compiled
> > 
> > I'm confused. I think we have agreed to unconditionally support core 
> > features for a specific language version. Did I miss something?
> > 
> > > successfully compiling for the architectures that didn't support the 
> > > features.
> > 
> > I like idea providing diagnostics in that case. Something like: "Warning: 
> > r600 target doesn't support 
> > cl_khr_3d_image_writes which is core in OpenCL C 2.0, consider using OpenCL 
> > C 3.0". I also think this should be done in a separate commit.
> > 
> > > If I look at existing targets they already set most of the core features 
> > > apart from 3d image writes. Perhaps it is reasonable to just drop this 
> > > code?
> > 
> > Oh, I haven't noticed that target set core features. For example 
> > //cl_khr_global_int32_base_atomics// is being set by NVPTX and AMDGPU, so I 
> > agree that this should be removed from target settings.
> It is correct that the core features should be set unconditionally but not in 
> the `TargetInfo`. If core features are used for targets that don't support 
> them then it should not succeed silently as it does now i.e. this means we 
> need to know what is supported by the targets.
> 
> Setting target features in `TargetInfo` is correct and should stay.  We 
> should not change them here though because the language version doesn't 
> change the target capabilities. It can either expose or hide them from the 
> user but it should not modify targets. This is why `TargetInfo` is immutable 
> after its creation and this is how it should stay. I think it's better if we 
> remove the code here completely and introduce a diagnostic in the subsequent 
> patches that would just check that the features required in the language 
> version are supported by the target.
> 
> If we do this then during the parsing we will only use feature information 
> from `OpenCLOptions` not the targets, but we will know that the target have 
> support of all the features because the check has been performed earlier.
I'm not generally against of removing core features set up, but I do have some 
questions and arguments:

> It is correct that the core features should be set unconditionally but not in 
> the TargetInfo

Just to make sure: where do you mean core features should be set 
unconditionally? 

> Setting target features in TargetInfo is correct and should stay. We should 
> not change them here though because the language version doesn't change the 
> target capabilities. It can either expose or hide them from the user but it 
> should not modify targets. This is why TargetInfo is immutable after its 
> creation and this is how it should stay

I agree that `TargetInfo `should stay immutable during parsing, but for example 
here, in `TargetInfo::adjust`, current design already allows to change target 
capabilities based on language options, so I don't see what is conceptually 
wrong here.

> If core features are used for targets that don't support 

[PATCH] D94804: [clang] Allow LifetimeExtendedTemporary to have no access specifier

2021-01-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/lib/AST/DeclBase.cpp:986
+  isa(this) ||
+  isa(this))
 return true;

hokein wrote:
> nit: personally I'd keep the old format style, just appending the new case.
I like the old formatting a little better too, but this is what clang-format 
wants to do and I think keeping the code clang-format clean is more valuable in 
this case. Otherwise everyone submitting here must ignore/silence formatting 
errors and can no longer auto-format this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94804

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


[PATCH] D94606: [clangd] Move DirBasedCDB broadcasting onto its own thread.

2021-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:496
+  std::condition_variable CV;
+  std::atomic ShouldStop = {false}; // Must notify CV after writing.
+  std::deque Queue;

kadircet wrote:
> nit: we already hold the lock within the loop while reading. it is nice that 
> we no longer need to acquire the lock during destructor, but is it worth the 
> extra mental load that comes with memory orderings? (also IIRC, default 
> load/store behaviors are already acquire-release)
Whoops, I split this patch in half and now this makes no sense.

The point is rather that we should interrupt the "evaluate the config for every 
file" loop (which will be part of process()) if ShouldStop is set. So we check 
this atomic inside that loop, without acquiring the lock.

(In practice maybe this is always "fast enough" that we should just run the 
whole loop, enqueue all the background indexing stuff, and then shut down 
afterwards?)

> (also IIRC, default load/store behaviors are already acquire-release)

Default is sequentially consistent, which is almost always more than we need.

---

I've added a check to the existing loop (which probes directory caches), less 
necessary but shows the idea. If you prefer to drop this entirely that's OK too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94606

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


[PATCH] D94606: [clangd] Move DirBasedCDB broadcasting onto its own thread.

2021-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 317365.
sammccall marked an inline comment as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94606

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -217,11 +217,13 @@
 });
 
 DB.getCompileCommand(testPath("build/../a.cc"));
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
 EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(AllOf(
  EndsWith("a.cc"), Not(HasSubstr("..");
 DiscoveredFiles.clear();
 
 DB.getCompileCommand(testPath("build/gen.cc"));
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
 EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(EndsWith("gen.cc")));
   }
 
@@ -237,12 +239,14 @@
 });
 
 DB.getCompileCommand(testPath("a.cc"));
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
 EXPECT_THAT(DiscoveredFiles,
 UnorderedElementsAre(EndsWith("a.cc"), EndsWith("gen.cc"),
  EndsWith("gen2.cc")));
 DiscoveredFiles.clear();
 
 DB.getCompileCommand(testPath("build/gen.cc"));
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
 EXPECT_THAT(DiscoveredFiles, IsEmpty());
   }
 }
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.h
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.h
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.h
@@ -120,6 +120,8 @@
   /// \p File's parents.
   llvm::Optional getProjectInfo(PathRef File) const override;
 
+  bool blockUntilIdle(Deadline Timeout) const override;
+
 private:
   Options Opts;
 
@@ -152,6 +154,9 @@
   };
   llvm::Optional lookupCDB(CDBLookupRequest Request) const;
 
+  class BroadcastThread;
+  std::unique_ptr Broadcaster;
+
   // Performs broadcast on governed files.
   void broadcastCDB(CDBLookupResult Res) const;
 
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -11,6 +11,7 @@
 #include "SourceCode.h"
 #include "support/Logger.h"
 #include "support/Path.h"
+#include "support/Threading.h"
 #include "support/ThreadsafeFS.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
@@ -22,12 +23,15 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -356,7 +360,7 @@
 
 DirectoryBasedGlobalCompilationDatabase::
 DirectoryBasedGlobalCompilationDatabase(const Options )
-: Opts(Opts) {
+: Opts(Opts), Broadcaster(std::make_unique(*this)) {
   if (Opts.CompileCommandsDir)
 OnlyDirCache = std::make_unique(*Opts.CompileCommandsDir);
 }
@@ -471,25 +475,105 @@
   Result.CDB = std::move(CDB);
   Result.PI.SourceRoot = DirCache->Path;
 
-  // FIXME: Maybe make the following part async, since this can block
-  // retrieval of compile commands.
   if (ShouldBroadcast)
 broadcastCDB(Result);
   return Result;
 }
 
-void DirectoryBasedGlobalCompilationDatabase::broadcastCDB(
-CDBLookupResult Result) const {
-  vlog("Broadcasting compilation database from {0}", Result.PI.SourceRoot);
-  assert(Result.CDB && "Trying to broadcast an invalid CDB!");
+// The broadcast thread announces files with new compile commands to the world.
+// Primarily this is used to enqueue them for background indexing.
+//
+// It's on a separate thread because:
+//  - otherwise it would block the first parse of the initial file
+//  - we need to enumerate all files in the CDB, of which there are many
+//  - we (will) have to evaluate config for every file in the CDB, which is slow
+class DirectoryBasedGlobalCompilationDatabase::BroadcastThread {
+  class Filter;
+  DirectoryBasedGlobalCompilationDatabase 
+
+  std::mutex Mu;
+  std::condition_variable CV;
+  std::atomic ShouldStop = {false}; // Must notify CV after writing.
+  struct Task {
+CDBLookupResult Lookup;
+Context Ctx;
+  };
+  std::deque Queue;
+  llvm::Optional ActiveTask;

[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2021-01-18 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 317355.
Conanap marked 2 inline comments as done.
Conanap added a comment.

Loads Hi before Lo now; removed implicit cast.


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

https://reviews.llvm.org/D90173

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm32.ll

Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -1,22 +1,14 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck --check-prefix=CHECK-LE %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
-; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck --check-prefix=CHECK-BE %s
+; RUN: FileCheck %s
 
 ; Function Attrs: norecurse nounwind readnone
 define  <4 x i32> @test_xxsplti32dx_1(<4 x i32> %a) {
-; CHECK-LE-LABEL: test_xxsplti32dx_1:
-; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:xxsplti32dx vs34, 0, 566
-; CHECK-LE-NEXT:blr
-;
-; CHECK-BE-LABEL: test_xxsplti32dx_1:
-; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xxsplti32dx vs34, 1, 566
-; CHECK-BE-NEXT:blr
+; CHECK-LABEL: test_xxsplti32dx_1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxsplti32dx vs34, 0, 566
+; CHECK-NEXT:blr
 entry:
   %vecins1 = shufflevector <4 x i32> %a, <4 x i32> , <4 x i32> 
   ret <4 x i32> %vecins1
@@ -24,15 +16,10 @@
 
 ; Function Attrs: norecurse nounwind readnone
 define  <4 x i32> @test_xxsplti32dx_2(<4 x i32> %a) {
-; CHECK-LE-LABEL: test_xxsplti32dx_2:
-; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:xxsplti32dx vs34, 1, 33
-; CHECK-LE-NEXT:blr
-;
-; CHECK-BE-LABEL: test_xxsplti32dx_2:
-; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xxsplti32dx vs34, 0, 33
-; CHECK-BE-NEXT:blr
+; CHECK-LABEL: test_xxsplti32dx_2:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxsplti32dx vs34, 1, 33
+; CHECK-NEXT:blr
 entry:
   %vecins1 = shufflevector <4 x i32> , <4 x i32> %a, <4 x i32> 
   ret <4 x i32> %vecins1
@@ -40,15 +27,10 @@
 
 ; Function Attrs: norecurse nounwind readnone
 define  <4 x i32> @test_xxsplti32dx_3(<4 x i32> %a) {
-; CHECK-LE-LABEL: test_xxsplti32dx_3:
-; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:xxsplti32dx vs34, 0, 12
-; CHECK-LE-NEXT:blr
-;
-; CHECK-BE-LABEL: test_xxsplti32dx_3:
-; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xxsplti32dx vs34, 1, 12
-; CHECK-BE-NEXT:blr
+; CHECK-LABEL: test_xxsplti32dx_3:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxsplti32dx vs34, 0, 12
+; CHECK-NEXT:blr
 entry:
   %vecins1 = shufflevector <4 x i32> %a, <4 x i32> , <4 x i32> 
   ret <4 x i32> %vecins1
@@ -56,15 +38,10 @@
 
 ; Function Attrs: norecurse nounwind readnone
 define  <4 x i32> @test_xxsplti32dx_4(<4 x i32> %a) {
-; CHECK-LE-LABEL: test_xxsplti32dx_4:
-; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:xxsplti32dx vs34, 1, -683
-; CHECK-LE-NEXT:blr
-;
-; CHECK-BE-LABEL: test_xxsplti32dx_4:
-; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xxsplti32dx vs34, 0, -683
-; CHECK-BE-NEXT:blr
+; CHECK-LABEL: test_xxsplti32dx_4:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxsplti32dx vs34, 1, -683
+; CHECK-NEXT:blr
 entry:
   %vecins1 = shufflevector <4 x i32> , <4 x i32> %a, <4 x i32> 
   ret <4 x i32> %vecins1
@@ -72,15 +49,10 @@
 
 ; Function Attrs: nounwind
 define  <4 x float> @test_xxsplti32dx_5(<4 x float> %vfa) {
-; CHECK-LE-LABEL: test_xxsplti32dx_5:
-; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:xxsplti32dx vs34, 0, 1065353216
-; CHECK-LE-NEXT:blr
-;
-; CHECK-BE-LABEL: test_xxsplti32dx_5:
-; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xxsplti32dx vs34, 1, 1065353216
-; CHECK-BE-NEXT:blr
+; CHECK-LABEL: test_xxsplti32dx_5:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxsplti32dx vs34, 0, 1065353216
+; CHECK-NEXT:blr
 entry:
   %vecins3.i = shufflevector <4 x float> %vfa, <4 x float> , <4 x i32> 
   ret <4 x float> %vecins3.i
@@ -88,15 +60,10 @@
 
 ; Function Attrs: nounwind
 define  <4 x float> @test_xxsplti32dx_6(<4 x float> %vfa) {
-; CHECK-LE-LABEL: test_xxsplti32dx_6:
-; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:xxsplti32dx vs34, 1, 1073741824
-; CHECK-LE-NEXT:blr
-;
-; CHECK-BE-LABEL: test_xxsplti32dx_6:
-; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xxsplti32dx vs34, 0, 1073741824
-; CHECK-BE-NEXT:blr
+; CHECK-LABEL: test_xxsplti32dx_6:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxsplti32dx vs34, 1, 1073741824
+; CHECK-NEXT:   

[PATCH] D94906: [clang-format] Apply Allman style to lambdas

2021-01-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 317358.
HazardyKnusperkeks added a comment.

Formatting corrected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94906

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,58 @@
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine,
+FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  // Reset
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+
   // This shouldn't affect ObjC blocks..
   verifyFormat("[self doSomeThingWithACompletionHandler:^{\n"
"  // ...\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -817,6 +817,7 @@
 Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_Whitesmiths:
 Expanded.BraceWrapping.AfterCaseLabel = true;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,58 @@
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine,
+FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  // Reset
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+
   // This shouldn't affect ObjC blocks..
   verifyFormat("[self 

[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-01-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 317351.
ASDenysPetrov added a comment.

@steakhal 
Oh, sure. Updated.


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

https://reviews.llvm.org/D90157

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -530,108 +530,197 @@
   return evalCast(val, castTy, originalTy);
 }
 
-// FIXME: should rewrite according to the cast kind.
-SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
-  castTy = Context.getCanonicalType(castTy);
-  originalTy = Context.getCanonicalType(originalTy);
-  if (val.isUnknownOrUndef() || castTy == originalTy)
-return val;
+//===--===//
+// Cast methods.
+// `evalCast` is the main method
+// `evalCastKind` and `evalCastSubKind` are helpers
+//===--===//
 
-  if (castTy->isBooleanType()) {
-if (val.isUnknownOrUndef())
-  return val;
-if (val.isConstant())
-  return makeTruthVal(!val.isZeroConstant(), castTy);
-if (!Loc::isLocType(originalTy) &&
-!originalTy->isIntegralOrEnumerationType() &&
-!originalTy->isMemberPointerType())
-  return UnknownVal();
-if (SymbolRef Sym = val.getAsSymbol(true)) {
-  BasicValueFactory  = getBasicValueFactory();
-  // FIXME: If we had a state here, we could see if the symbol is known to
-  // be zero, but we don't.
-  return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
-}
-// Loc values are not always true, they could be weakly linked functions.
-if (Optional L = val.getAs())
-  return evalCastFromLoc(*L, castTy);
+SVal SValBuilder::evalCast(SVal V, QualType CastTy, QualType OriginalTy) {
+  CastTy = Context.getCanonicalType(CastTy);
+  OriginalTy = Context.getCanonicalType(OriginalTy);
+  if (CastTy == OriginalTy)
+return V;
 
-Loc L = val.castAs().getLoc();
-return evalCastFromLoc(L, castTy);
+  // FIXME: Move this check to the most appropriate evalCastKind/evalCastSubKind
+  // function.
+  // For const casts, casts to void, just propagate the value.
+  if (!CastTy->isVariableArrayType() && !OriginalTy->isVariableArrayType())
+if (shouldBeModeledWithNoOp(Context, Context.getPointerType(CastTy),
+Context.getPointerType(OriginalTy)))
+  return V;
+
+  // Cast SVal according to kinds.
+  switch (V.getBaseKind()) {
+  case SVal::UndefinedValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::UnknownValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::LocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::NonLocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown SVal kind");
   }
+}
 
-  // For const casts, casts to void, just propagate the value.
-  if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType())
-if (shouldBeModeledWithNoOp(Context, Context.getPointerType(castTy),
- Context.getPointerType(originalTy)))
-  return val;
+SVal SValBuilder::evalCastKind(UndefinedVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
 
-  // Check for casts from pointers to integers.
-  if (castTy->isIntegralOrEnumerationType() && Loc::isLocType(originalTy))
-return evalCastFromLoc(val.castAs(), castTy);
-
-  // Check for casts from integers to pointers.
-  if (Loc::isLocType(castTy) && originalTy->isIntegralOrEnumerationType()) {
-if (Optional LV = val.getAs()) {
-  if (const MemRegion *R = LV->getLoc().getAsRegion()) {
-StoreManager  = StateMgr.getStoreManager();
-R = storeMgr.castRegion(R, castTy);
-return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
-  }
-  return LV->getLoc();
-}
-return dispatchCast(val, castTy);
+SVal SValBuilder::evalCastKind(UnknownVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
+
+SVal SValBuilder::evalCastKind(Loc V, QualType CastTy, QualType OriginalTy) {
+  switch (V.getSubKind()) {
+  case loc::ConcreteIntKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::GotoLabelKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::MemRegionValKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown SVal kind");
   }
+}
 
-  // Just pass through function and block pointers.
-  if (originalTy->isBlockPointerType() || originalTy->isFunctionPointerType()) 

[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements

2021-01-18 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/test/Parser/stmt-attributes.c:5
+
+  __attribute__((unknown_attribute));// expected-warning {{unknown 
attribute 'unknown_attribute' ignored}}
+  __attribute__((unknown_attribute)) {}  // expected-warning {{unknown 
attribute 'unknown_attribute' ignored}}

aaron.ballman wrote:
> Given that these are parser tests, I think you can drop the attribute name 
> itself except in the cases where you explicitly want to test that an unknown 
> attribute introduces the start of a declaration (or things where the 
> attribute identifier matters for some reason). This will reduce the amount of 
> `expected-warning` comments we need to add.
> 
> Also, because this change impacts C++ and ObjC/C++ as well, I think we should 
> have some tests for language-specific constructs like lambdas, range-based 
> for loops, blocks, etc.
This test is mostly a copy-paste of a similar test for C++11 statement 
attributes.
I think that these cases show that GNU spelling for attributes doesn't break 
anything if we put it in front of these various statements.  And you are 
absolutely right that we need to add more cases for C++ and Obj-C constructs.  
But I don't understand about 'unknown_attribute'.  What should I replace it 
with?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93630

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


[PATCH] D93630: [Attr] Apply GNU-style attributes to expression statements

2021-01-18 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D93630#2490034 , @aaron.ballman 
wrote:

> In D93630#2486574 , @aaron.ballman 
> wrote:
>
>> I'm going to see if I can run the patch against our internal corpus here at 
>> work to see if it shakes out any breakages to real world code. I've not 
>> tried this before, so I have no idea how long it will take before I get 
>> results back, but I'll let you know when I have them.
>
> The tests finally finished over the weekend and came back with no new 
> failures -- that gives me a lot more confidence that this doesn't 
> accidentally change behavior in cases users are likely to hit (at least in C 
> and C++).

That is amazing, thanks for doing that!  I'll make sure that it works for 
Obj-C/Obj-C++.

> I think the next steps are to clean up the tests and then coordinate with the 
> GCC folks to ensure they don't have any strong objections we should be aware 
> of.

I'll clean up the tests!  But, unfortunately, I couldn't proceed with GCC 
folks.  I asked around and I'm not allowed to do that (company rules).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93630

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


[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-01-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Please @ASDenysPetrov, give full context with the option `-U` when you 
export the diff from git.
I would like to quickly swipe through the code before I accept this.


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

https://reviews.llvm.org/D90157

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-01-18 Thread Digger via Phabricator via cfe-commits
DiggerLin added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:520
   Options.DataSections = CodeGenOpts.DataSections;
-  Options.IgnoreXCOFFVisibility = CodeGenOpts.IgnoreXCOFFVisibility;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;

hubert.reinterpretcast wrote:
> DiggerLin wrote:
> > sfertile wrote:
> > > DiggerLin wrote:
> > > > sfertile wrote:
> > > > > DiggerLin wrote:
> > > > > > jasonliu wrote:
> > > > > > > DiggerLin wrote:
> > > > > > > > DiggerLin wrote:
> > > > > > > > > jasonliu wrote:
> > > > > > > > > > DiggerLin wrote:
> > > > > > > > > > > jasonliu wrote:
> > > > > > > > > > > > DiggerLin wrote:
> > > > > > > > > > > > > jasonliu wrote:
> > > > > > > > > > > > > > Instead of just removing this line, should this get 
> > > > > > > > > > > > > > replaced with the new LangOpts option?
> > > > > > > > > > > > > I do not think we need a CodeGenOp of 
> > > > > > > > > > > > > ignore-xcoff-visibility in clang, we only need the 
> > > > > > > > > > > > > LangOpt of the ignore-xcoff-visilbity to control 
> > > > > > > > > > > > > whether we will  generate the visibility in the IR,  
> > > > > > > > > > > > > when the LangOpt of ignore-xcoff-visibility do not 
> > > > > > > > > > > > > generate the visibility attribute of GV in the IR. it 
> > > > > > > > > > > > > do not need CodeGenOp of ignore-xcoff-visibility any 
> > > > > > > > > > > > > more for the clang .
> > > > > > > > > > > > > 
> > > > > > > > > > > > > we have still CodeGen ignore-xcoff-visibility op in  
> > > > > > > > > > > > > llc.
> > > > > > > > > > > > We removed the visibility from IR level with this 
> > > > > > > > > > > > patch. But there is also visibility settings coming 
> > > > > > > > > > > > from CodeGen part of clang, which needs to get ignore 
> > > > > > > > > > > > when we are doing the code gen in llc. So I think you 
> > > > > > > > > > > > still need to set the options correct for llc.
> > > > > > > > > > > yes we have the set the options correct for llc in the 
> > > > > > > > > > > code.
> > > > > > > > > > > 
> > > > > > > > > > > in the source file llvm/lib/CodeGen/CommandFlags.cpp, we 
> > > > > > > > > > > have (in the patch https://reviews.llvm.org/D87451 add 
> > > > > > > > > > > new option -mignore-xcoff-visibility) , the function
> > > > > > > > > > > TargetOptions 
> > > > > > > > > > > codegen::InitTargetOptionsFromCodeGenFlags() {
> > > > > > > > > > > 
> > > > > > > > > > > Options.IgnoreXCOFFVisibility = 
> > > > > > > > > > > getIgnoreXCOFFVisibility(); 
> > > > > > > > > > > ...}
> > > > > > > > > > > 
> > > > > > > > > > What I'm saying is... 
> > > > > > > > > > I think we need a line like this:
> > > > > > > > > > `Options.IgnoreXCOFFVisibility = 
> > > > > > > > > > LangOpts.IgnoreXCOFFVisibility;`
> > > > > > > > > > so that when you invoke clang, backend would get the 
> > > > > > > > > > correct setting as well. 
> > > > > > > > > I do not think so, from the clang FE, we do not generated the 
> > > > > > > > > visibility in the IR. so there is no need these line.
> > > > > > > > or we can say that because we do not set the hidden visibility 
> > > > > > > > into the GlobalValue , so we do not need the 
> > > > > > > > Options.IgnoreXCOFFVisibility = LangOpts.IgnoreXCOFFVisibility;
> > > > > > > I think I mentioned this before, we could have extra visibility 
> > > > > > > settings in clang/lib/CodeGen that's not depending on the 
> > > > > > > existing visibility setting in the IR. (You could search for 
> > > > > > > `setVisibility` there.) That was the reason we did it in llc 
> > > > > > > first. 
> > > > > > I will add Options.IgnoreXCOFFVisibility = 
> > > > > > LangOpts.IgnoreXCOFFVisibility;  here.
> > > > > > I think I mentioned this before, we could have extra visibility 
> > > > > > settings in clang/lib/CodeGen that's not depending on the existing 
> > > > > > visibility setting in the IR. (You could search for setVisibility 
> > > > > > there.) That was the reason we did it in llc first.
> > > > > 
> > > > >  A lot of these are in places we wouldn't encounter with AIX, like 
> > > > > for Objective-C code gen. But are others like [[ 
> > > > > https://github.com/llvm/llvm-project/blob/b03ea054db1bcf9452b3a70e21d3372b6e58759a/clang/lib/CodeGen/ItaniumCXXABI.cpp#L2507
> > > > >  | this]]  an issue? Should they be addressed in this patch?
> > > > after I added the Options.IgnoreXCOFFVisibility = 
> > > > LangOpts.IgnoreXCOFFVisibility , even there is  
> > > > GV->setVisibility(llvm::GlobalValue::HiddenVisibility);  it do not 
> > > > effect our output.
> > > > 
> > > > there is following code in the function void 
> > > > PPCAIXAsmPrinter::emitLinkage(const GlobalValue *GV,
> > > >MCSymbol *GVSym) const
> > > > {
> > > >  . 
> > > >   if (!TM.getIgnoreXCOFFVisibility()) {
> > > > switch (GV->getVisibility()) {
> > > > 
> > > > // TODO: "exported" and 

[PATCH] D89699: [ExtVector] Make .even/.odd/.lo/.hi return vectors for single elements.

2021-01-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

This unfortunately breaks a bunch of existing projects. I'll abandon the change 
for now, as the gains are probably not worth the cost of breaking backwards 
compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89699

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


[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Malhar via Phabricator via cfe-commits
malharJ updated this revision to Diff 317345.
malharJ added a comment.

added tests for loop predication enabled case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp


Index: clang/test/CodeGenCXX/pragma-loop-predicate.cpp
===
--- clang/test/CodeGenCXX/pragma-loop-predicate.cpp
+++ clang/test/CodeGenCXX/pragma-loop-predicate.cpp
@@ -58,6 +58,49 @@
 List[i] = i * 2;
 }
 
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test6(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test6{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test7(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test7{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test8(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test8{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]]
+
+#pragma clang loop vectorize_predicate(enable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test9(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test9{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP9:.*]]
+
+#pragma clang loop vectorize_predicate(enable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
 // CHECK:  ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], 
[[GEN3:![0-9]+]]}
 // CHECK:  [[MP]] = !{!"llvm.loop.mustprogress"}
 // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true}
@@ -74,3 +117,12 @@
 // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1}
 
 // CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], 
[[GEN11:![0-9]+]], [[GEN3]]}
+// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4}
+
+// CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], 
[[GEN11]], [[GEN3]]}
Index: clang/lib/CodeGen/CGLoopInfo.cpp
===
--- clang/lib/CodeGen/CGLoopInfo.cpp
+++ clang/lib/CodeGen/CGLoopInfo.cpp
@@ -249,11 +249,12 @@
   Args.push_back(nullptr);
   Args.append(LoopProperties.begin(), LoopProperties.end());
 
-  // Setting vectorize.predicate
+  // Setting vectorize.predicate when it has been specified and vectorization
+  // has not been disabled.
   bool IsVectorPredicateEnabled = false;
   if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified &&
   Attrs.VectorizeEnable != LoopAttributes::Disable &&
-  Attrs.VectorizeWidth < 1) {
+  Attrs.VectorizeWidth != 1) {
 
 IsVectorPredicateEnabled =
 (Attrs.VectorizePredicateEnable == LoopAttributes::Enable);


Index: clang/test/CodeGenCXX/pragma-loop-predicate.cpp
===
--- clang/test/CodeGenCXX/pragma-loop-predicate.cpp
+++ clang/test/CodeGenCXX/pragma-loop-predicate.cpp
@@ -58,6 +58,49 @@
 List[i] = i * 2;
 }
 
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test6(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test6{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test7(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test7{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test8(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test8{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]]
+
+#pragma clang loop vectorize_predicate(enable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test9(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test9{{.*}}(
+// CHECK: br label {{.*}}, 

[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-01-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 317342.
ASDenysPetrov added a comment.

Unfortunately I wasn't able to reproduce the singe difference in PostgreSQL 
project. So I revised the patch in a part of the difference nature.
This update passed all of CodeChecker's tests without any difference.
So for now the patch looks like ready to be accepted.
Please, welcome for review.


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

https://reviews.llvm.org/D90157

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -530,108 +530,197 @@
   return evalCast(val, castTy, originalTy);
 }
 
-// FIXME: should rewrite according to the cast kind.
-SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
-  castTy = Context.getCanonicalType(castTy);
-  originalTy = Context.getCanonicalType(originalTy);
-  if (val.isUnknownOrUndef() || castTy == originalTy)
-return val;
+//===--===//
+// Cast methods.
+// `evalCast` is the main method
+// `evalCastKind` and `evalCastSubKind` are helpers
+//===--===//
 
-  if (castTy->isBooleanType()) {
-if (val.isUnknownOrUndef())
-  return val;
-if (val.isConstant())
-  return makeTruthVal(!val.isZeroConstant(), castTy);
-if (!Loc::isLocType(originalTy) &&
-!originalTy->isIntegralOrEnumerationType() &&
-!originalTy->isMemberPointerType())
-  return UnknownVal();
-if (SymbolRef Sym = val.getAsSymbol(true)) {
-  BasicValueFactory  = getBasicValueFactory();
-  // FIXME: If we had a state here, we could see if the symbol is known to
-  // be zero, but we don't.
-  return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
-}
-// Loc values are not always true, they could be weakly linked functions.
-if (Optional L = val.getAs())
-  return evalCastFromLoc(*L, castTy);
+SVal SValBuilder::evalCast(SVal V, QualType CastTy, QualType OriginalTy) {
+  CastTy = Context.getCanonicalType(CastTy);
+  OriginalTy = Context.getCanonicalType(OriginalTy);
+  if (CastTy == OriginalTy)
+return V;
 
-Loc L = val.castAs().getLoc();
-return evalCastFromLoc(L, castTy);
+  // FIXME: Move this check to the most appropriate evalCastKind/evalCastSubKind
+  // function.
+  // For const casts, casts to void, just propagate the value.
+  if (!CastTy->isVariableArrayType() && !OriginalTy->isVariableArrayType())
+if (shouldBeModeledWithNoOp(Context, Context.getPointerType(CastTy),
+Context.getPointerType(OriginalTy)))
+  return V;
+
+  // Cast SVal according to kinds.
+  switch (V.getBaseKind()) {
+  case SVal::UndefinedValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::UnknownValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::LocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::NonLocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown SVal kind");
   }
+}
 
-  // For const casts, casts to void, just propagate the value.
-  if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType())
-if (shouldBeModeledWithNoOp(Context, Context.getPointerType(castTy),
- Context.getPointerType(originalTy)))
-  return val;
+SVal SValBuilder::evalCastKind(UndefinedVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
 
-  // Check for casts from pointers to integers.
-  if (castTy->isIntegralOrEnumerationType() && Loc::isLocType(originalTy))
-return evalCastFromLoc(val.castAs(), castTy);
-
-  // Check for casts from integers to pointers.
-  if (Loc::isLocType(castTy) && originalTy->isIntegralOrEnumerationType()) {
-if (Optional LV = val.getAs()) {
-  if (const MemRegion *R = LV->getLoc().getAsRegion()) {
-StoreManager  = StateMgr.getStoreManager();
-R = storeMgr.castRegion(R, castTy);
-return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
-  }
-  return LV->getLoc();
-}
-return dispatchCast(val, castTy);
+SVal SValBuilder::evalCastKind(UnknownVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
+
+SVal SValBuilder::evalCastKind(Loc V, QualType CastTy, QualType OriginalTy) {
+  switch (V.getSubKind()) {
+  case loc::ConcreteIntKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::GotoLabelKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case 

[PATCH] D93101: [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-18 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson marked 3 inline comments as done.
tmatheson added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:9801-9804
+return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr) 
||
+   (Field->isBitField() &&
+truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+  Field));

rsmith wrote:
> Shouldn't this be `&&` not `||`? These functions return `true` if they 
> succeed (unlike the convention in `Sema` where `true` means an error 
> diagnostic was produced).
You are correct. I have updated the logic to be simpler to follow as well.



Comment at: clang/test/CodeGenCXX/bitfield-layout.cpp:88-95
+// CHECK: define i32 @_Z10test_truncv()
+int test_trunc() {
+  union {
+int i : 4;
+  } U = {15};
+  return U.i;
+  // CHECK: ret i32 -1

joechrisellis wrote:
> I'd like to see some more tests that check the truncation behaviour. My 
> understanding is that this is trucating to -1 because of two's complement? 
> How about something like:
> 
> ```
> int test_trunc() {
> union {
> int i : 4;
> } U = {80};
> return U.i;
> // CHECK: ret i32 0
> }
> ```
> 
> Am I understanding the behaviour correctly?
> 
> Some comments about what is actually happening on the bit-level to get this 
> result would also be nice.
Yes that is correct. I have added some new test cases and comments to make it 
clear what they are testing for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93101

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


[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

I believe this sentence is the important part (the width=1 is just an edge 
case):

> For all other non-zero vectorization widths, the pragma is not ignored unless 
> vectorization is explicitly disabled using vectorize(disable)

And this sounds like a sensible fix to me. As in - when the vector width is 
specified that should not mean the predicate(enabled/disabled) is ignored.

Can you expand the test a little for both predicate(enable) and disable?




Comment at: clang/test/CodeGenCXX/pragma-loop-predicate.cpp:77
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)

Can you add a test for vectorize_predicate(enable) vectorize_width(4)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D93101: [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-18 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 317340.
tmatheson added a comment.

Make unions in test cases const, and clarify logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93101

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/bitfield-layout.cpp

Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -emit-llvm -o - -O3 -std=c++11 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
@@ -84,3 +85,68 @@
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } const U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } const U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,14 @@
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, ,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+if (EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr)) {
+  if (Field->isBitField())
+return truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+ Field);
+  return true;
+}
+
+return false;
   }
 
   if (!Result.hasValue())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Malhar via Phabricator via cfe-commits
malharJ added a comment.

> what is the problem with the current behaviour (i.e. not ignoring/handling 
> it)?

The current behaviour is //ignoring/not handling// the vectorize_predication 
pragma whenever vectorization width is non-zero.
Could you kindly see the original condition I stated in my previous comment ?

My patch is trying to fix this by handling the predication pragma for all cases 
(other than when = 1).
Please let me know if Im mistaken.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 317339.
usaxena95 marked 3 inline comments as done.
usaxena95 added a comment.

Addressed comments. Left a todo to fix the bug in RefContainers later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1637,14 +1637,28 @@
 template
 struct $5^TemplateBase {};
 struct $5[[Child3]] : public TemplateBase {};
+
+// Local classes.
+void LocationFunction() {
+  struct $0[[LocalClass1]] : Base {
+void $1[[Foo]]() override;
+  };
+  struct $6^LocalBase {
+virtual void $7^Bar();
+  };
+  struct $6[[LocalClass2]]: LocalBase {
+void $7[[Bar]]() override;
+  };
+}
   )cpp";
 
   Annotations Code(Test);
   auto TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  for (StringRef Label : {"0", "1", "2", "3", "4", "5"}) {
+  auto Index = TU.index();
+  for (StringRef Label : {"0", "1", "2", "3", "4", "5", "6", "7"}) {
 for (const auto  : Code.points(Label)) {
-  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  EXPECT_THAT(findImplementations(AST, Point, Index.get()),
   UnorderedPointwise(DeclRange(), Code.ranges(Label)))
   << Code.code() << " at " << Point << " for Label " << Label;
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -55,6 +55,7 @@
   return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
+MATCHER_P(HasName, Name, "") { return arg.Name == Name; }
 MATCHER_P(TemplateArgs, TemplArgs, "") {
   return arg.TemplateSpecializationArgs == TemplArgs;
 }
@@ -157,6 +158,37 @@
   EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
 }
 
+TEST_F(ShouldCollectSymbolTest, CollectLocalClassesAndVirtualMethods) {
+  build(R"(
+namespace nx {
+auto f() {
+  int Local;
+  auto LocalLambda = [&](){
+Local++;
+class ClassInLambda{};
+return Local;
+  };
+} // auto ensures function body is parsed.
+auto foo() {
+  class LocalBase {
+virtual void LocalVirtual();
+void LocalConcrete();
+int BaseMember;
+  };
+}
+} // namespace nx
+  )",
+"");
+  auto AST = File.build();
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("ClassInLambda", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalBase", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalVirtual", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("LocalConcrete", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("BaseMember", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+}
+
 TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
   HeaderName = "f.proto.h";
   build(
@@ -228,7 +260,7 @@
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
-IndexOpts.IndexFunctionLocals = false;
+IndexOpts.IndexFunctionLocals = true;
 Collector = std::make_shared(COpts);
 return std::make_unique(Collector, std::move(IndexOpts),
  PragmaHandler);
@@ -320,7 +352,11 @@
 void ff() {} // ignore
 }
 
-void f1() {}
+void f1() {
+  auto LocalLambda = [&](){
+class ClassInLambda{};
+  };
+}
 
 namespace foo {
 // Type alias
@@ -351,7 +387,7 @@
AllOf(QName("Foo::operator="), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested"), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested::f"), ForCodeCompletion(false)),
-
+   AllOf(QName("ClassInLambda"), ForCodeCompletion(false)),
AllOf(QName("Friend"), ForCodeCompletion(true)),
AllOf(QName("f1"), ForCodeCompletion(true)),
AllOf(QName("f2"), ForCodeCompletion(true)),
@@ -774,7 +810,8 @@
   };
   EXPECT_EQ(Container("ref1a"),
 findSymbol(Symbols, "f2").ID); // 

[PATCH] D85025: [RecoveryExpr]WIP: Support dependence in C-only codepath

2021-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein abandoned this revision.
hokein added a comment.
Herald added a subscriber: dexonsmith.

Thanks for @rsmith's initial comments.

This is done, all related patches have been landed in upstream, and this 
feature is enabled by default for all languages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85025

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


[PATCH] D92277: [OpenCL] Refactor of targets OpenCL option settings

2021-01-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:62
 
-  /// Check if \c Ext is supported as an (optional) OpenCL core features for
-  /// the given OpenCL version.
-  ///
-  /// \param Ext - Extension to look up.
-  /// \param LO - \c LangOptions specifying the OpenCL version.
-  /// \returns \c true if \c Ext is known and supported, \c false otherwise.
-  bool isSupportedCore(llvm::StringRef Ext, const LangOptions ) const {
-auto E = OptMap.find(Ext);
-if (E == OptMap.end()) {
-  return false;
-}
-// In C++ mode all extensions should work at least as in v2.0.
-auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = E->getValue();
-return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
-  }
+struct OpenCLOptionInfo {
+  // Option starts to be available in this OpenCL version

azabaznov wrote:
> Anastasia wrote:
> > I think it would be better to keep it in `OpenCLOptions`, as we don't 
> > intend this to be used stand-alone also considering that it's a `struct`? I 
> > understand that this is now being used in Targets too but that use should 
> > hopefully be eliminated in the future.
> This check is needed to check availability of extensions (see comment in 
> `Targets.cpp`). Or you mean to define it as a nested class in `OpenCLOptions`?
> Or you mean to define it as a nested class in OpenCLOptions?

Exactly.



Comment at: clang/lib/Basic/TargetInfo.cpp:360
+// Set core features based on OpenCL version
+for (auto CoreExt : clang::getCoreFeatures(Opts))
+  getTargetOpts().OpenCLFeaturesMap[CoreExt] = true;

azabaznov wrote:
> Anastasia wrote:
> > I still think the target map should be immutable and especially we should 
> > not change it silently based on the language compiled even if we have done 
> > it before but that caused incorrect behavior i.e. successfully compiling 
> > for the architectures that didn't support the features.
> > 
> > If I look at existing targets they already set most of the core features 
> > apart from 3d image writes. Perhaps it is reasonable to just drop this 
> > code? I don't think it makes the issue worse, in fact, I think it will make 
> > the behavior slightly better because now a diagnostic will occur if there 
> > is an attempt to use the unsupported feature although the diagnostic won't 
> > be the optimal one.  After all it will still remain the responsibility of 
> > the user to get the right combination of a language version and a target.
> > 
> > It would be reasonable however to introduce a diagnostic that would report 
> > a mismatch between the language version and the hardware support available. 
> > We report similar diagnostics in `CompilerInvocation` already. But I don't 
> > think we have to do it in this patch because it doesn't introduce any 
> > regression. We already have a bug although the behavior of this bug will 
> > change. And perhaps if we add `OpenCLOptions` as a part of `LangOpts` at 
> > some point this will become straightforward to diagnose. However, I suggest 
> > we add information about this issue in a FIXME or perhaps this deserves a 
> > clang bug!
> > I still think the target map should be immutable and especially we should 
> > not change it silently based on the language compiled
> 
> I'm confused. I think we have agreed to unconditionally support core features 
> for a specific language version. Did I miss something?
> 
> > successfully compiling for the architectures that didn't support the 
> > features.
> 
> I like idea providing diagnostics in that case. Something like: "Warning: 
> r600 target doesn't support 
> cl_khr_3d_image_writes which is core in OpenCL C 2.0, consider using OpenCL C 
> 3.0". I also think this should be done in a separate commit.
> 
> > If I look at existing targets they already set most of the core features 
> > apart from 3d image writes. Perhaps it is reasonable to just drop this code?
> 
> Oh, I haven't noticed that target set core features. For example 
> //cl_khr_global_int32_base_atomics// is being set by NVPTX and AMDGPU, so I 
> agree that this should be removed from target settings.
It is correct that the core features should be set unconditionally but not in 
the `TargetInfo`. If core features are used for targets that don't support them 
then it should not succeed silently as it does now i.e. this means we need to 
know what is supported by the targets.

Setting target features in `TargetInfo` is correct and should stay.  We should 
not change them here though because the language version doesn't change the 
target capabilities. It can either expose or hide them from the user but it 
should not modify targets. This is why `TargetInfo` is immutable after its 
creation and this is how it should stay. I think it's better if we remove the 
code here completely and introduce a diagnostic in the subsequent patches that 

[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

In D94779#2504519 , @malharJ wrote:

> I had a look at the Clang Language Extension 
> 
>  ... and I saw this:
>
>> Specifying a width/count of 1 disables the optimization, and is equivalent 
>> to vectorize(disable) or interleave(disable).

Ah yes, thanks. I think we should improve the langref spec also, this should be 
described in the same paragraph, not floating below some example.

With this cleared up, I agree with Florian, ignoring things isn't great. 
But this brings me back to my question earlier: what is the problem with the 
current behaviour (i.e. not ignoring/handling it)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D92277: [OpenCL] Refactor of targets OpenCL option settings

2021-01-18 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:17
 // If the extensions are to be enumerated without the supported OpenCL version,
-// define OPENCLEXT(ext) where ext is the name of the extension.
+// define OPENCLEXTNAME(ext) where ext is the name of the extension.
 //

Anastasia wrote:
> I guess you mean that this extension is not against a specific version i.e. 
> applies to all versions?
Yeah, this is needed to enumerate all extensions (as it was earlier). I only 
changed the naming of macro in this patch, I'll adjust the comment.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:79
+OPENCL_EXTENSION(cl_khr_subgroups, 200)
+OPENCL_EXTENSION(cl_khr_subgroup_extended_types, 200)
+OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, 200)

Anastasia wrote:
> Is this code accidental? The following extensions `cl_khr_subgroup_*` were 
> recently removed from this file.
> 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLExtensions.def
Yes, thanks for noticing. This got here accidentally after rebasing.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:55
+// OpenCL C version mask
+static inline bool OpenCLVersionIsContainedInMask(const LangOptions ,
+  unsigned Mask) {

Anastasia wrote:
> A small renaming
> `OpenCLVersionIsContainedInMask` -> `isOpenCLVersionContainedInMask`
Sure, will change.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:62
 
-  /// Check if \c Ext is supported as an (optional) OpenCL core features for
-  /// the given OpenCL version.
-  ///
-  /// \param Ext - Extension to look up.
-  /// \param LO - \c LangOptions specifying the OpenCL version.
-  /// \returns \c true if \c Ext is known and supported, \c false otherwise.
-  bool isSupportedCore(llvm::StringRef Ext, const LangOptions ) const {
-auto E = OptMap.find(Ext);
-if (E == OptMap.end()) {
-  return false;
-}
-// In C++ mode all extensions should work at least as in v2.0.
-auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = E->getValue();
-return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
-  }
+struct OpenCLOptionInfo {
+  // Option starts to be available in this OpenCL version

Anastasia wrote:
> I think it would be better to keep it in `OpenCLOptions`, as we don't intend 
> this to be used stand-alone also considering that it's a `struct`? I 
> understand that this is now being used in Targets too but that use should 
> hopefully be eliminated in the future.
This check is needed to check availability of extensions (see comment in 
`Targets.cpp`). Or you mean to define it as a nested class in `OpenCLOptions`?



Comment at: clang/lib/Basic/TargetInfo.cpp:360
+// Set core features based on OpenCL version
+for (auto CoreExt : clang::getCoreFeatures(Opts))
+  getTargetOpts().OpenCLFeaturesMap[CoreExt] = true;

Anastasia wrote:
> I still think the target map should be immutable and especially we should not 
> change it silently based on the language compiled even if we have done it 
> before but that caused incorrect behavior i.e. successfully compiling for the 
> architectures that didn't support the features.
> 
> If I look at existing targets they already set most of the core features 
> apart from 3d image writes. Perhaps it is reasonable to just drop this code? 
> I don't think it makes the issue worse, in fact, I think it will make the 
> behavior slightly better because now a diagnostic will occur if there is an 
> attempt to use the unsupported feature although the diagnostic won't be the 
> optimal one.  After all it will still remain the responsibility of the user 
> to get the right combination of a language version and a target.
> 
> It would be reasonable however to introduce a diagnostic that would report a 
> mismatch between the language version and the hardware support available. We 
> report similar diagnostics in `CompilerInvocation` already. But I don't think 
> we have to do it in this patch because it doesn't introduce any regression. 
> We already have a bug although the behavior of this bug will change. And 
> perhaps if we add `OpenCLOptions` as a part of `LangOpts` at some point this 
> will become straightforward to diagnose. However, I suggest we add 
> information about this issue in a FIXME or perhaps this deserves a clang bug!
> I still think the target map should be immutable and especially we should not 
> change it silently based on the language compiled

I'm confused. I think we have agreed to unconditionally support core features 
for a specific language version. Did I miss something?

> successfully compiling for the architectures that didn't support the features.

I like idea providing diagnostics in 

[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D94785#2503939 , @nridge wrote:

> In D94785#2501806 , @usaxena95 wrote:
>
>> Although now that I enabled this in all SymbolCollectorTests, this causes a 
>> regression in RefContainers.
>>
>>   void f2() {
>> (void) $ref1a[[f1]](1);
>> auto fptr = &$ref1b[[f1]];
>>   }
>>
>> `` is contained in `fptr` instead of `f2`. No immediate ideas why would 
>> this happen.
>
> I have a theory as to why.
>
> If you look at the next test case in `RefContainers`:
>
>   int $toplevel2[[v1]] = $ref2[[f1]](2);
>
> here, `v1` is a global variable, and it is the containing symbol for the 
> reference in the initializer.
>
> So, I think libIndex considers references in initializers to be contained in 
> the declaration of the variable. The reason this didn't happen for local 
> variables until now, is that `IndexFunctionLocals` was false, and libIndex 
> probably avoids returning non-indexed symbols in `ASTNode::Parent`.

This looks like a bug in libindex -- not sure we should fix that before this 
patch, I think we can probably live with this, and fix the bug afterwards.




Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:64
   index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
-  IndexOpts.IndexFunctionLocals = false;
+  IndexOpts.IndexFunctionLocals = true;
   if (IsIndexMainAST) {

Can you add a comment explicitly mentioning that we only index function-local 
classes and its methods? Without a comment, the reader would expect we index 
all function-local symbols by just reading this part of code.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:223
   // Skip symbols in anonymous namespaces in header files.
   if (!IsMainFileOnly && ND.isInAnonymousNamespace())
 return false;

nit: CollectMainFileSymbols affects the function-local symbols, I think? please 
update the comments of `SymbolCollector::Options::CollectMainFileSymbols`.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:231
+  // For function local symbols, index only classes.
+  if (ND.getParentFunctionOrMethod())
+return isa(ND);

nit: use `index::isFunctionLocalSymbol`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

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


[PATCH] D69560: [clang-tidy] Add 'experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type' check

2021-01-18 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

I have re-analysed Bitcoin and Xerces with the new version (not yet published 
to Phab), and the results are looking really good! There is an insignificant 
change in the number of reports, 1 or 2 new ones compared to the previous, all 
explained by the fact that "unnamed parameters" are marked as ignored, i.e. the 
previous report (which reported 3 swappable parameters, one unnamed) is marked 
//"Resolved"// (1), but there is the (2 swappable one without the unnamed at 
the start/end) as //"New"//. Due to this, I will spare you from showing the 
essentially same table from above again: the total number of results are 
unchanged, only the details of each (and they are changed in a positive 
(towards more sensible) direction).

In addition, I've implemented the "patterned name filtering" (a really 
rudimentary, but seemingly rather powerful version), with the rule "if two 
parameters are similar to at most 1 letter at the beginning or the end" (2), 
they should be scrapped from the result set.

Throwing out one-way implicit conversions (which I admit was a huge and utterly 
useless misunderstanding and misdesign from our part...) is also a good update. 
In addition, I've did the analysis with the explicit "do not report `bool, 
bool, ...` sequences" rule enabled. This silenced (as bool swaps are a more 
special problem wrt. "strong typing" - and even a separate guideline rule 
exists for them) 30 and 27 reports from the strictest case, for Bitcoing and 
Xerces, respectively.

There're still a few bugs (which I discovered but doesn't affect the above 
statements) to fix before I can split the patches and upload them to Phab.



(1): In CodeChecker, if you store a new result set over an already existing 
named result set, the bug reports that disappeared are marked "Resolved".
(2): `lhs, rhs`, `text1, text2, text3`, `qmat, rmat, tmat`, etc. are covered by 
this.


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

https://reviews.llvm.org/D69560

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


[PATCH] D94871: [Clang][OpenMP] Fixed an issue that clang crashed when compiling OpenMP program in device only mode without host IR

2021-01-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2944-2947
+// This could happen if the device compilation is invoked standalone.
+if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
+  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+  OffloadingEntriesNum);

I would add a chack that to auxiliary device was specified. And if it was 
specified, it means this is not device-only mode and still need to emit an 
error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94871

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


[PATCH] D94906: [clang-format] Apply Allman style to lambdas

2021-01-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to https://lists.llvm.org/pipermail/cfe-dev/2021-January/067481.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94906

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,57 @@
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine, 
FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  // Reset
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+
   // This shouldn't affect ObjC blocks..
   verifyFormat("[self doSomeThingWithACompletionHandler:^{\n"
"  // ...\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -817,6 +817,7 @@
 Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_Whitesmiths:
 Expanded.BraceWrapping.AfterCaseLabel = true;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,57 @@
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine, FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  

[PATCH] D94239: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests

2021-01-18 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG689aaba7acf5: [SystemZ][z/OS] Fix No such file or directory 
expression error matching in lit… (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94239

Files:
  clang/test/CodeGen/basic-block-sections.c
  clang/test/CodeGen/ubsan-blacklist-vfs.c
  clang/test/Frontend/stats-file.c
  lld/test/COFF/driver.test
  lld/test/COFF/manifestinput-error.test
  lld/test/COFF/nodefaultlib.test
  lld/test/COFF/pdb-type-server-invalid-signature.yaml
  lld/test/ELF/archive-thin-missing-member.s
  lld/test/ELF/basic.s
  lld/test/ELF/symbol-ordering-file.s
  llvm/test/DebugInfo/symbolize-missing-file.test
  llvm/test/tools/dsymutil/X86/papertrail-warnings.test
  llvm/test/tools/llvm-ar/missing-thin-archive-member.test
  llvm/test/tools/llvm-ar/replace.test
  llvm/test/tools/llvm-ar/response.test
  llvm/test/tools/llvm-cxxdump/trivial.test
  llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
  llvm/test/tools/llvm-mc/basic.test
  llvm/test/tools/llvm-mca/invalid_input_file_name.test
  llvm/test/tools/llvm-ml/basic.test
  llvm/test/tools/llvm-objcopy/COFF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/error-format.test
  llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
  llvm/test/tools/llvm-objcopy/redefine-symbols.test
  llvm/test/tools/llvm-profdata/weight-instr.test
  llvm/test/tools/llvm-profdata/weight-sample.test
  llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
  llvm/test/tools/llvm-readobj/basic.test
  llvm/test/tools/llvm-readobj/thin-archive.test
  llvm/test/tools/llvm-size/no-input.test
  llvm/test/tools/llvm-xray/X86/no-such-file.txt
  llvm/test/tools/obj2yaml/invalid_input_file.test
  llvm/test/tools/yaml2obj/output-file.yaml

Index: llvm/test/tools/yaml2obj/output-file.yaml
===
--- llvm/test/tools/yaml2obj/output-file.yaml
+++ llvm/test/tools/yaml2obj/output-file.yaml
@@ -9,7 +9,7 @@
 
 # RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck %s
 
-# CHECK: yaml2obj: error: failed to open '{{.*}}/path/does/not/exist': {{[Nn]}}o such file or directory
+# CHECK: yaml2obj: error: failed to open '{{.*}}/path/does/not/exist': {{.*}}{{[Nn]}}o such file or directory
 
 !ELF
 FileHeader:
Index: llvm/test/tools/obj2yaml/invalid_input_file.test
===
--- llvm/test/tools/obj2yaml/invalid_input_file.test
+++ llvm/test/tools/obj2yaml/invalid_input_file.test
@@ -1,3 +1,3 @@
 # RUN: not obj2yaml  %p/path/does/not/exist 2>&1 | FileCheck %s
 
-# CHECK: Error reading file: {{.*}}/path/does/not/exist: {{[Nn]}}o such file or directory
+# CHECK: Error reading file: {{.*}}/path/does/not/exist: {{.*}}{{[Nn]}}o such file or directory
Index: llvm/test/tools/llvm-xray/X86/no-such-file.txt
===
--- llvm/test/tools/llvm-xray/X86/no-such-file.txt
+++ llvm/test/tools/llvm-xray/X86/no-such-file.txt
@@ -1,4 +1,4 @@
 ; RUN: not llvm-xray extract no-such-file 2>&1 | FileCheck %s
 
 ; CHECK: llvm-xray: Cannot extract instrumentation map from 'no-such-file'.
-; CHECK-NEXT: {{[Nn]}}o such file or directory
+; CHECK-NEXT: {{.*}}{{[Nn]}}o such file or directory
Index: llvm/test/tools/llvm-size/no-input.test
===
--- llvm/test/tools/llvm-size/no-input.test
+++ llvm/test/tools/llvm-size/no-input.test
@@ -1,7 +1,7 @@
 ## Show that llvm-size emits an error if passed in a non-existent file.
 
 # RUN: not llvm-size %t.blah 2>&1 | FileCheck %s -DFILE=%t.blah --check-prefix=ENOENT
-# ENOENT: {{.*}}llvm-size{{.*}}: error: '[[FILE]]': {{[Nn]}}o such file or directory
+# ENOENT: {{.*}}llvm-size{{.*}}: error: '[[FILE]]': {{.*}}{{[Nn]}}o such file or directory
 
 ## Show that llvm-size reads a.out if not passed any file.
 
Index: llvm/test/tools/llvm-readobj/thin-archive.test
===
--- llvm/test/tools/llvm-readobj/thin-archive.test
+++ llvm/test/tools/llvm-readobj/thin-archive.test
@@ -60,7 +60,7 @@
 # MISSING: File: {{.*}}1.o
 # MISSING: Format: elf64-x86-64
 # MISSING-NOT: File: {{.*}}3.o
-# ERR: error: '{{.*}}.a': '{{.*}}2.o': {{[Nn]}}o such file or directory
+# ERR: error: '{{.*}}.a': '{{.*}}2.o': {{.*}}{{[Nn]}}o such file or directory
 
 --- !ELF
 FileHeader:
Index: llvm/test/tools/llvm-readobj/basic.test
===
--- llvm/test/tools/llvm-readobj/basic.test
+++ llvm/test/tools/llvm-readobj/basic.test
@@ -2,7 +2,7 @@
 RUN: not llvm-readobj %t.blah 2>&1 | FileCheck --check-prefix=ENOENT -DTOOL=readobj %s
 RUN: not llvm-readelf %t.blah 2>&1 | FileCheck --check-prefix=ENOENT -DTOOL=readelf %s
 

[clang] 689aaba - [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests

2021-01-18 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-01-18T07:14:37-05:00
New Revision: 689aaba7acf5778bfe96bfd7bc4f1f3ceed20dc8

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

LOG: [SystemZ][z/OS] Fix No such file or directory expression error matching in 
lit tests

On z/OS, the following error message is not matched correctly in lit tests. 
This patch updates the CHECK expression to match successfully.
```
EDC5129I No such file or directory.
```

Reviewed By: muiez

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

Added: 


Modified: 
clang/test/CodeGen/basic-block-sections.c
clang/test/CodeGen/ubsan-blacklist-vfs.c
clang/test/Frontend/stats-file.c
lld/test/COFF/driver.test
lld/test/COFF/manifestinput-error.test
lld/test/COFF/nodefaultlib.test
lld/test/COFF/pdb-type-server-invalid-signature.yaml
lld/test/ELF/archive-thin-missing-member.s
lld/test/ELF/basic.s
lld/test/ELF/symbol-ordering-file.s
llvm/test/DebugInfo/symbolize-missing-file.test
llvm/test/tools/dsymutil/X86/papertrail-warnings.test
llvm/test/tools/llvm-ar/missing-thin-archive-member.test
llvm/test/tools/llvm-ar/replace.test
llvm/test/tools/llvm-ar/response.test
llvm/test/tools/llvm-cxxdump/trivial.test
llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
llvm/test/tools/llvm-mc/basic.test
llvm/test/tools/llvm-mca/invalid_input_file_name.test
llvm/test/tools/llvm-ml/basic.test
llvm/test/tools/llvm-objcopy/COFF/add-section.test
llvm/test/tools/llvm-objcopy/ELF/add-section.test
llvm/test/tools/llvm-objcopy/ELF/error-format.test
llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
llvm/test/tools/llvm-objcopy/redefine-symbols.test
llvm/test/tools/llvm-profdata/weight-instr.test
llvm/test/tools/llvm-profdata/weight-sample.test
llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
llvm/test/tools/llvm-readobj/basic.test
llvm/test/tools/llvm-readobj/thin-archive.test
llvm/test/tools/llvm-size/no-input.test
llvm/test/tools/llvm-xray/X86/no-such-file.txt
llvm/test/tools/obj2yaml/invalid_input_file.test
llvm/test/tools/yaml2obj/output-file.yaml

Removed: 




diff  --git a/clang/test/CodeGen/basic-block-sections.c 
b/clang/test/CodeGen/basic-block-sections.c
index 70cdeeebb0d3..91bcb6222848 100644
--- a/clang/test/CodeGen/basic-block-sections.c
+++ b/clang/test/CodeGen/basic-block-sections.c
@@ -41,4 +41,4 @@ int another(int a) {
 //
 // UNIQUE: .section .text.world.world.__part.1,
 // UNIQUE: .section .text.another.another.__part.1,
-// ERROR: error:  unable to load basic block sections function list: 
'{{[Nn]}}o such file or directory'
+// ERROR: error:  unable to load basic block sections function list: 
'{{.*}}{{[Nn]}}o such file or directory'

diff  --git a/clang/test/CodeGen/ubsan-blacklist-vfs.c 
b/clang/test/CodeGen/ubsan-blacklist-vfs.c
index 0647cbf7a57b..a8509eb2f6f9 100644
--- a/clang/test/CodeGen/ubsan-blacklist-vfs.c
+++ b/clang/test/CodeGen/ubsan-blacklist-vfs.c
@@ -8,10 +8,10 @@
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%/T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
 
 // RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%/T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
-// INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': {{[Nn]}}o such file 
or directory
+// INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': {{.*}}{{[Nn]}}o such 
file or directory
 
 // RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%t-nonexistent.blacklist -emit-llvm %s 
-o - 2>&1 | FileCheck %s --check-prefix=INVALID
-// INVALID: nonexistent.blacklist': {{[Nn]}}o such file or directory
+// INVALID: nonexistent.blacklist': {{.*}}{{[Nn]}}o such file or directory
 
 unsigned i;
 

diff  --git a/clang/test/Frontend/stats-file.c 
b/clang/test/Frontend/stats-file.c
index 53b264534c57..007bb7f00b6c 100644
--- a/clang/test/Frontend/stats-file.c
+++ b/clang/test/Frontend/stats-file.c
@@ -5,4 +5,4 @@
 // CHECK: }
 
 // RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
-// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
+// OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{.*}}{{[Nn]}}o such file or directory'

diff  --git a/lld/test/COFF/driver.test b/lld/test/COFF/driver.test
index d756dc9ed4aa..951a4d3319f1 100644
--- 

[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Malhar via Phabricator via cfe-commits
malharJ added a comment.

I had a look at the Clang Language Extension 

 ... and I saw this:

> Specifying a width/count of 1 disables the optimization, and is equivalent to 
> vectorize(disable) or interleave(disable).

And regarding the original condition,  it seems to check whether vector 
predication has been specified and  vectorization is not disabled explicitly.
I think at the very least we should have Attrs.VectorizeWidth > 1 since it is 
being ANDed ?

  if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified &&
  Attrs.VectorizeEnable != LoopAttributes::Disable &&
   Attrs.VectorizeWidth < 1)

I put in

  && Attrs.VectorizeWidth != 1

since the Clang parser threw an error when passing a value of 0 for the width 
and I thought it would be good to indicate explicitly that we don't want equal 
to 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

> This ensures that the Clang loop pragma vectorize_predicate([enable|disable]) 
> is ignored
> when vectorize_width(1) is also used, since that effectively disables 
> vectorization.

Could you elaborate *why* it `vectorize_predicate` should be ignored when 
`vectorize_width(1)`? In general, I do not think that Clang silently ignoring 
the pragma is great for the user experience. If we can detect cases where we 
know the pragma will be ignored, could we at least warn the user?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-18 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

I am trying to remember details here, but first about this:

> vectorize_width(1) is also used, since that effectively disables 
> vectorization.

I am not sure this is true (i.e. effectively disabling auto-vec) since in 
LangRef we specify:

> The vector width is specified by vectorize_width(_value_[, fixed|scalable]), 
> where _value_ is a positive integer and the type of vectorization can be 
> specified with an optional second parameter.

So, I *think* `vectorize_width(1)` enables the vectoriser, just the width is 
set to 1. And this explains why I added that condition `VectorizeWidth < 1`.

This leads me to wonder what the actual problem is with this?




Comment at: clang/test/CodeGenCXX/pragma-loop-predicate.cpp:102
+
+// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], 
[[GEN11:![0-9]+]], [[GEN3]]}
+// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4}

malharJ wrote:
> SjoerdMeijer wrote:
> > Do we also expect:
> > 
> >!{!"llvm.loop.vectorize.predicate.enable", i1 false}
> > 
> > here since the test sets:
> > 
> >   vectorize_predicate(disable) vectorize_width(4)
> GEN8 covers checking for that ?
Ah yep, of course, I missed that, so ignore this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2021-01-18 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous marked 3 inline comments as done.
nomanous added a comment.

Ping @rsmith @dblaikie @MaskRay @haowei @Xiangling_L @lebedev.ri


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90448

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


[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

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

In D93844#2504376 , @MyDeveloperDay 
wrote:

> What I can't easily tell from the tests is if you are overriding any styles 
> defined in the parent with a local style.

Yes I do, but I will try to make it clearer in the tests.




Comment at: clang/include/clang/Format/Format.h:57
+  // the parent directories. It is not part of the actual style for formatting.
+  // Thus the // instead of ///.
+  bool InheritsParentConfig;

MyDeveloperDay wrote:
> I don't quite understand this last sentence
If I would use `///` it would end up in the `ClangFormatStyleOptions.rst`. I 
only want to make clear it is no mistake that it only got `//` while all other 
members are documented with `///`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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


[PATCH] D93101: [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-18 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 317309.
tmatheson added a comment.

Add test RUN line that checks C++11 behaviour


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93101

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/bitfield-layout.cpp


Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -emit-llvm -o - -O3 
-std=c++11 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
@@ -84,3 +85,68 @@
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,10 @@
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, ,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr) 
||
+   (Field->isBitField() &&
+truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+  Field));
   }
 
   if (!Result.hasValue())


Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -emit-llvm -o - -O3 -std=c++11 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
@@ -84,3 +85,68 @@
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return 

[PATCH] D94473: [clangd] Use AST-based signals in CodeCompletion.

2021-01-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 317307.
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94473

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/Quality.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "ASTSignals.h"
 #include "Annotations.h"
 #include "ClangdServer.h"
 #include "CodeComplete.h"
@@ -51,6 +52,8 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(MainFileRefs, Refs, "") { return arg.MainFileRefs == Refs; }
+MATCHER_P(ScopeRefs, Refs, "") { return arg.ScopeRefsInFile == Refs; }
 MATCHER_P(NameStartsWith, Prefix, "") {
   return llvm::StringRef(arg.Name).startswith(Prefix);
 }
@@ -1110,6 +1113,49 @@
   UnorderedElementsAre(Named("xy1"), Named("xy2")));
 }
 
+TEST(CompletionTest, ASTSignals) {
+  struct Completion {
+std::string Name;
+unsigned MainFileRefs;
+unsigned ScopeRefsInFile;
+  };
+  CodeCompleteOptions Opts;
+  std::vector RecordedCompletions;
+  Opts.RecordCCResult = [](const CodeCompletion ,
+   const SymbolQualitySignals &,
+   const SymbolRelevanceSignals ,
+   float Score) {
+RecordedCompletions.push_back({CC.Name, R.MainFileRefs, R.ScopeRefsInFile});
+  };
+  ASTSignals MainFileSignals;
+  MainFileSignals.ReferencedSymbols[var("xy1").ID] = 3;
+  MainFileSignals.ReferencedSymbols[var("xy2").ID] = 1;
+  MainFileSignals.ReferencedSymbols[var("xyindex").ID] = 10;
+  MainFileSignals.RelatedNamespaces["tar::"] = 5;
+  MainFileSignals.RelatedNamespaces["bar::"] = 3;
+  Opts.MainFileSignals = 
+  Opts.AllScopes = true;
+  completions(
+  R"cpp(
+  int xy1;
+  int xy2;
+  namespace bar {
+  int xybar = 1;
+  int a = xy^
+  }
+  )cpp",
+  /*IndexSymbols=*/{var("xyindex"), var("tar::xytar"), var("bar::xybar")},
+  Opts);
+  EXPECT_THAT(RecordedCompletions,
+  UnorderedElementsAre(
+  AllOf(Named("xy1"), MainFileRefs(3u), ScopeRefs(0u)),
+  AllOf(Named("xy2"), MainFileRefs(1u), ScopeRefs(0u)),
+  AllOf(Named("xyindex"), MainFileRefs(10u), ScopeRefs(0u)),
+  AllOf(Named("xytar"), MainFileRefs(0u), ScopeRefs(5u)),
+  AllOf(/*both from sema and index*/ Named("xybar"),
+MainFileRefs(0u), ScopeRefs(3u;
+}
+
 SignatureHelp signatures(llvm::StringRef Text, Position Point,
  std::vector IndexSymbols = {}) {
   std::unique_ptr Index;
Index: clang-tools-extra/clangd/Quality.h
===
--- clang-tools-extra/clangd/Quality.h
+++ clang-tools-extra/clangd/Quality.h
@@ -29,6 +29,7 @@
 
 #include "ExpectedTypes.h"
 #include "FileDistance.h"
+#include "TUScheduler.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -140,6 +141,14 @@
   /// CompletionPrefix.
   unsigned FilterLength = 0;
 
+  const ASTSignals *MainFileSignals = nullptr;
+  /// Number of references to the candidate in the main file.
+  unsigned MainFileRefs = 0;
+  /// Number of unique symbols in the main file which belongs to candidate's
+  /// namespace. This indicates how relevant the namespace is in the current
+  /// file.
+  unsigned ScopeRefsInFile = 0;
+
   /// Set of derived signals computed by calculateDerivedSignals(). Must not be
   /// set explicitly.
   struct DerivedSignals {
@@ -155,6 +164,7 @@
 
   void merge(const CodeCompletionResult );
   void merge(const Symbol );
+  void computeASTSignals(const CodeCompletionResult );
 
   // Condense these signals down to a single number, higher is better.
   float evaluateHeuristics() const;
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -294,6 +294,38 @@
   if (!(IndexResult.Flags & Symbol::VisibleOutsideFile)) {
 Scope = AccessibleScope::FileScope;
   }
+  if (MainFileSignals) {
+MainFileRefs =
+std::max(MainFileRefs,
+ 

[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

2021-01-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

What I can't easily tell from the tests is if you are overriding any styles 
defined in the parent with a local style.




Comment at: clang/include/clang/Format/Format.h:57
+  // the parent directories. It is not part of the actual style for formatting.
+  // Thus the // instead of ///.
+  bool InheritsParentConfig;

I don't quite understand this last sentence


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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


[PATCH] D94804: [clang] Allow LifetimeExtendedTemporary to have no access specifier

2021-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks.




Comment at: clang/lib/AST/DeclBase.cpp:986
+  isa(this) ||
+  isa(this))
 return true;

nit: personally I'd keep the old format style, just appending the new case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94804

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


[PATCH] D93101: [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-18 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 317306.
tmatheson added a comment.

Added more test cases and explanatory comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93101

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/bitfield-layout.cpp


Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -84,3 +84,68 @@
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,10 @@
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, ,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr) 
||
+   (Field->isBitField() &&
+truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+  Field));
   }
 
   if (!Result.hasValue())


Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -84,3 +84,68 @@
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,10 @@
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, ,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, 

[PATCH] D93453: [flang][driver] Add support for `-I`

2021-01-18 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

Thank you @FarisRehman , LGTM!

I believe that you addressed all PR comments. As requested, there are tests for:

- `#include`
- `INCLUDE`
- `USE`

Your tests also demonstrate that the order of include paths is significant and 
that that's preserved by the driver. Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93453

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


[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2021-01-18 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous updated this revision to Diff 317299.

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

https://reviews.llvm.org/D90448

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp

Index: clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+template
+class A
+{
+ static T a; //expected-note {{in instantiation of static data member 'A::a' requested here}}
+};
+
+template
+T A::a;
+
+class B
+{ };
+
+template int A::a; //expected-error {{type 'int' of explicit instantiation of 'A::a' does not match expected type 'B'}}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -9992,6 +9992,7 @@
 
 VarDecl *Prev = Previous.getAsSingle();
 VarTemplateDecl *PrevTemplate = Previous.getAsSingle();
+bool IsStaticDataMemberInstantiation = false;
 
 if (!PrevTemplate) {
   if (!Prev || !Prev->isStaticDataMember()) {
@@ -10013,6 +10014,8 @@
 // FIXME: Can we provide a note showing where this was declared?
 return true;
   }
+
+  IsStaticDataMemberInstantiation = true;
 } else {
   // Explicitly instantiate a variable template.
 
@@ -10105,6 +10108,21 @@
   return true;
 }
 
+// Check the static member's type given in the explicit instantiation
+// definition against the one in the class template. This won't happen in
+// explicit instantiation declaration because the instantiated code won't
+// be generated in that case.
+if (IsStaticDataMemberInstantiation &&
+TSK == TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameTypeIgnoreLifetime(Prev->getType(), R)) {
+  Diag(T->getTypeLoc().getBeginLoc(),
+   diag::err_invalid_template_static_data_member_spec_type)
+  << Prev << R << Prev->getType();
+  Diag(Prev->getLocation(), diag::note_template_static_data_member_def_here)
+  << Prev;
+  return true;
+}
+
 // FIXME: Create an ExplicitInstantiation node?
 return (Decl*) nullptr;
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5122,6 +5122,8 @@
   "of %select{explicit instantiation|explicit specialization|"
   "partial specialization|redeclaration}0 of %1 does not match"
   " expected type %3">;
+def err_invalid_template_static_data_member_spec_type : Error<"type %1 "
+  "of explicit instantiation of %q0 does not match expected type %2">;
 def err_mismatched_exception_spec_explicit_instantiation : Error<
   "exception specification in explicit instantiation does not match "
   "instantiated one">;
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -2355,6 +2355,20 @@
   bool hasSameType(QualType T1, QualType T2) const {
 return getCanonicalType(T1) == getCanonicalType(T2);
   }
+
+  /// Determine whether the given types \p T1 and \p T2 are equivalent with
+  /// lifetime qualifiers ignored. We want this because with option -fobjc-arc,
+  /// the compiler automatically adds Objective C lifetime qualifiers for
+  /// static data members. Sometimes, this will make two types not equal while
+  /// they should be.
+  bool hasSameTypeIgnoreLifetime(QualType T1, QualType T2) const {
+SplitQualType ST1 = getCanonicalType(T1).split();
+SplitQualType ST2 = getCanonicalType(T2).split();
+ST1.Quals.removeObjCLifetime();
+ST2.Quals.removeObjCLifetime();
+return ST1 == ST2;
+  }
+
   bool hasSameType(const Type *T1, const Type *T2) const {
 return getCanonicalType(T1) == getCanonicalType(T2);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

2021-01-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 317295.
HazardyKnusperkeks marked 2 inline comments as done.
HazardyKnusperkeks edited the summary of this revision.
HazardyKnusperkeks added a comment.

- Rebased
- Renamed to `InhteritParentConfig`
- Reworked to remove the recursion of `getStyle`
- Now supports the command line style options
- Test cases extended for the latter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16731,6 +16731,85 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", );
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9.1: overwriting a file style, when parent no file exists with no
+  // fallback style
+  ASSERT_TRUE(FS.addFile("/e/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: InheritParentConfig\n"
+  "ColumnLimit: 20")));
+  ASSERT_TRUE(FS.addFile("/e/sub/code.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getNoStyle();
+Style.ColumnLimit = 20;
+return Style;
+  }());
+
+  // Test 9.2: with LLVM fallback style
+  Style9 = getStyle("file", "/e/sub/code.cpp", "LLVM", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+Style.ColumnLimit = 20;
+return Style;
+  }());
+
+  // Test 9.3: with a parent file
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google\n"
+  "UseTab: Always")));
+  Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getGoogleStyle();
+Style.ColumnLimit = 20;
+Style.UseTab = FormatStyle::UT_Always;
+return Style;
+  }());
+
+  // Test 9.4: propagate more than one level
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/code.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer(
+ "BasedOnStyle: InheritParentConfig\n"
+ "WhitespaceSensitiveMacros: ['FOO', 'BAR']")));
+  std::vector NonDefaultWhiteSpaceMacros{"FOO", "BAR"};
+
+  const auto SubSubStyle = [] {
+auto Style = getGoogleStyle();
+Style.ColumnLimit = 20;
+Style.UseTab = FormatStyle::UT_Always;
+Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;
+return Style;
+  }();
+
+  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);
+  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.5: use InheritParentConfig as style name
+  Style9 =
+  getStyle("inheritparentconfig", "/e/sub/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.6: use command line style with inheritance
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig}", "/e/sub/code.cpp",
+"none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.7: use command line style with inheritance and own config
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig, "
+"WhitespaceSensitiveMacros: ['FOO', 'BAR']}",
+"/e/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -866,6 +866,7 @@
 
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
+  LLVMStyle.InheritsParentConfig = false;
   LLVMStyle.Language = Language;
   LLVMStyle.AccessModifierOffset = -2;
   LLVMStyle.AlignEscapedNewlines = FormatStyle::ENAS_Right;
@@ -1339,6 +1340,8 @@
 *Style = getMicrosoftStyle(Language);
   } else if (Name.equals_lower("none")) {
 *Style = getNoStyle();
+  } else if (Name.equals_lower("inheritparentconfig")) {
+

[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2021-01-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 317294.
HazardyKnusperkeks added a comment.

- Rebased
- Fixed(?) the last UnitTest, please take a look @krasimir


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -3144,7 +3144,7 @@
 "  # commen6\n"
 "  # commen7",
 format("k:val#commen1 commen2\n"
-   " # commen3\n"
+   " #commen3\n"
"# commen4\n"
"a:1#commen5 commen6\n"
" #commen7",
@@ -3275,6 +3275,506 @@
JSStyle20));
 }
 
+TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
+  FormatStyle Style = getLLVMStyle();
+  StringRef NoTextInComment = " //   \n"
+  "\n"
+  "void foo() {// \n"
+  "// \n"
+  "}";
+
+  EXPECT_EQ("//\n"
+"\n"
+"void foo() { //\n"
+"  //\n"
+"}",
+format(NoTextInComment, Style));
+
+  Style.SpacesInLineCommentPrefix.Minimum = 0;
+  EXPECT_EQ("//\n"
+"\n"
+"void foo() { //\n"
+"  //\n"
+"}",
+format(NoTextInComment, Style));
+
+  Style.SpacesInLineCommentPrefix.Minimum = 5;
+  EXPECT_EQ("//\n"
+"\n"
+"void foo() { //\n"
+"  //\n"
+"}",
+format(NoTextInComment, Style));
+
+  Style = getLLVMStyle();
+  StringRef Code =
+  "//Free comment without space\n"
+  "\n"
+  "//   Free comment with 3 spaces\n"
+  "\n"
+  "///Free Doxygen without space\n"
+  "\n"
+  "///   Free Doxygen with 3 spaces\n"
+  "\n"
+  "/// A Doxygen Comment with a nested list:\n"
+  "/// - Foo\n"
+  "/// - Bar\n"
+  "///   - Baz\n"
+  "///   - End\n"
+  "/// of the inner list\n"
+  "///   .\n"
+  "/// .\n"
+  "\n"
+  "namespace Foo {\n"
+  "bool bar(bool b) {\n"
+  "  bool ret1 = true; ///TokenText;
   if (NamespaceTok->is(TT_NamespaceMacro))
 text += "(";
@@ -278,7 +280,8 @@
   EndCommentNextTok->NewlinesBefore == 0 &&
   EndCommentNextTok->isNot(tok::eof);
 const std::string EndCommentText =
-computeEndCommentText(NamespaceName, AddNewline, NamespaceTok);
+computeEndCommentText(NamespaceName, AddNewline, NamespaceTok,
+  Style.SpacesInLineCommentPrefix.Minimum);
 if (!hasEndComment(EndCommentPrevTok)) {
   bool isShort = I - StartLineIndex <= kShortNamespaceMaxLines + 1;
   if (!isShort)
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -632,6 +632,8 @@
Style.SpacesInContainerLiterals);
 IO.mapOptional("SpacesInCStyleCastParentheses",
Style.SpacesInCStyleCastParentheses);
+IO.mapOptional("SpacesInLineCommentPrefix",
+   Style.SpacesInLineCommentPrefix);
 IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
 IO.mapOptional("SpaceBeforeSquareBrackets",
@@ -681,6 +683,20 @@
   }
 };
 
+template <> struct MappingTraits {
+  static void mapping(IO , FormatStyle::SpacesInLineComment ) {
+// Transform the maximum to signed, to parse "-1" correctly
+int signedMaximum = static_cast(Space.Maximum);
+IO.mapOptional("Minimum", Space.Minimum);
+IO.mapOptional("Maximum", signedMaximum);
+Space.Maximum = static_cast(signedMaximum);
+
+if (Space.Maximum != -1u) {
+  Space.Minimum = std::min(Space.Minimum, Space.Maximum);
+}
+  }
+};
+
 // Allows to read vector while keeping default values.
 // IO.getContext() should contain a pointer to the FormatStyle structure, that
 // will be used to get default values for missing keys.
@@ -955,6 +971,7 @@
   LLVMStyle.SpaceInEmptyParentheses = false;
   LLVMStyle.SpacesInContainerLiterals = true;
   LLVMStyle.SpacesInCStyleCastParentheses = false;
+  LLVMStyle.SpacesInLineCommentPrefix = {/*Minimum=*/1, /*Maximum=*/-1u};
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot 

[clang] b43075e - [clang-format] Fix documentation of bcc1dee600

2021-01-18 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2021-01-18T11:03:13+01:00
New Revision: b43075e34a598460fe1590d950862a26449e8d10

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

LOG: [clang-format] Fix documentation of bcc1dee600

That was an oversight.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 928d136ef9ff..27dcee83a538 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3077,7 +3077,10 @@ the configuration (without a prefix: ``Auto``).
 **StatementAttributeLikeMacros** (``std::vector``)
   Macros which are ignored in front of a statement, as if they were an
   attribute. So that they are not parsed as identifier, for example for Qts
-  emit. \code
+  emit.
+
+  .. code-block:: c++
+
 AlignConsecutiveDeclarations: true
 StatementAttributeLikeMacros: []
 unsigned char data = 'x';

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 943a33cee4fd..385803700d58 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2678,7 +2678,8 @@ struct FormatStyle {
 
   /// Macros which are ignored in front of a statement, as if they were an
   /// attribute. So that they are not parsed as identifier, for example for Qts
-  /// emit. \code
+  /// emit.
+  /// \code
   ///   AlignConsecutiveDeclarations: true
   ///   StatementAttributeLikeMacros: []
   ///   unsigned char data = 'x';



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


[PATCH] D93776: [clang-format] Add StatementAttributeLikeMacros option

2021-01-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 317292.
HazardyKnusperkeks added a comment.

Fix documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93776

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14731,6 +14731,11 @@
   CHECK_PARSE("AttributeMacros: [attr1, attr2]", AttributeMacros,
   std::vector({"attr1", "attr2"}));
 
+  Style.StatementAttributeLikeMacros.clear();
+  CHECK_PARSE("StatementAttributeLikeMacros: [emit,Q_EMIT]",
+  StatementAttributeLikeMacros,
+  std::vector({"emit", "Q_EMIT"}));
+
   Style.StatementMacros.clear();
   CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros,
   std::vector{"QUNUSED"});
@@ -17803,6 +17808,36 @@
"struct constant;",
Style);
 }
+
+TEST_F(FormatTest, StatementAttributeLikeMacros) {
+  FormatStyle Style = getLLVMStyle();
+  StringRef Source = "void Foo::slot() {\n"
+ "  unsigned char MyChar = 'x';\n"
+ "  emit signal(MyChar);\n"
+ "  Q_EMIT signal(MyChar);\n"
+ "}";
+
+  EXPECT_EQ(Source, format(Source, Style));
+
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("void Foo::slot() {\n"
+"  unsigned char MyChar = 'x';\n"
+"  emit  signal(MyChar);\n"
+"  Q_EMIT signal(MyChar);\n"
+"}",
+format(Source, Style));
+
+  Style.StatementAttributeLikeMacros.push_back("emit");
+  EXPECT_EQ(Source, format(Source, Style));
+
+  Style.StatementAttributeLikeMacros = {};
+  EXPECT_EQ("void Foo::slot() {\n"
+"  unsigned char MyChar = 'x';\n"
+"  emit  signal(MyChar);\n"
+"  Q_EMITsignal(MyChar);\n"
+"}",
+format(Source, Style));
+}
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -655,6 +655,9 @@
   return true;
 if (C.Tok->isNot(TT_StartOfName))
   return false;
+if (C.Tok->Previous &&
+C.Tok->Previous->is(TT_StatementAttributeLikeMacro))
+  return false;
 // Check if there is a subsequent name that starts the same declaration.
 for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
   if (Next->is(tok::comment))
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1368,7 +1368,8 @@
 TT_ImplicitStringLiteral, TT_InlineASMBrace, TT_JsFatArrow,
 TT_LambdaArrow, TT_NamespaceMacro, TT_OverloadedOperator,
 TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral,
-TT_UntouchableMacroFunc, TT_ConstraintJunctions))
+TT_UntouchableMacroFunc, TT_ConstraintJunctions,
+TT_StatementAttributeLikeMacro))
   CurrentToken->setType(TT_Unknown);
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -52,6 +52,10 @@
 Macros.insert(
 {(WhitespaceSensitiveMacro), TT_UntouchableMacroFunc});
   }
+  for (const std::string  :
+   Style.StatementAttributeLikeMacros)
+Macros.insert({(StatementAttributeLikeMacro),
+   TT_StatementAttributeLikeMacro});
 }
 
 ArrayRef FormatTokenLexer::lex() {
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -96,6 +96,7 @@
   TYPE(RegexLiteral)   \
   TYPE(SelectorName)   \
   TYPE(StartOfName)\
+  TYPE(StatementAttributeLikeMacro)\
   TYPE(StatementMacro) \
   TYPE(StructuredBindingLSquare) 

  1   2   >