[PATCH] D66094: [CodeGen] Emit destructor calls for non-trivial C structs returned by function calls and loaded from volatile objects

2020-03-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:677
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+Cleanup.setExprNeedsCleanups(true);
+

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > ahatanak wrote:
> > > > rjmccall wrote:
> > > > > Why only when the l-value is volatile?
> > > > I was trying to avoid emitting `ExprWithCleanups` when it wasn't needed 
> > > > and it seemed that it wasn't needed for non-volatile types. I'm not 
> > > > sure it's important, so I've removed the check for volatile. Also, 
> > > > `ExprWithCleanups` shouldn't' be emitted when this is in file scope, so 
> > > > I fixed that too.
> > > Hmm, not sure about this file-scope thing, since the combination of C++ 
> > > dynamic initializers and statement-expressions means  we can have pretty 
> > > unrestricted code there.
> > I should have explained why this was needed, but I wanted to prevent 
> > emitting `ExprWithCleanups` in the following example:
> > 
> > ```
> > struct A {
> >   id f0;
> > };
> > 
> > typedef struct A A;
> > 
> > A g = (A){ .f0 = 0 };
> > ```
> > 
> > The l-value to r-value conversion happens here because compound literals 
> > are l-values. Since `g` is a global of a non-trivial C struct type, we 
> > shouldn't try to push a cleanup and destruct the object.
> > 
> > We don't have to think about the C++ case since the line below checks the 
> > type is a non-trivial C type. I didn't think about statement expressions, 
> > but they aren't allowed in file scope, so I guess that's not a problem 
> > either.
> I would hope that the constant-evaluator here might be smart enough to ignore 
> some elidable temporaries.
Do you mean the constant-evaluator should evaluate initializers that are 
`ExprWithCleanups` to constants in a case like this?  It's possible to do so by 
seeing whether the sub-expression of `ExprWithCleanups` is constant, but it 
looks like we also have to set the `CleanupInfo::CleanupsHaveSideEffects` flag 
to false when it's a file scope expression so that 
`ConstExprEmitter::VisitExprWithCleanups` can constant-fold the 
`ExprWithCleanups` initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66094



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


[PATCH] D60748: Adds an option "malign-pass-aggregate" to make the alignment of the struct and union parameters compatible with the default gcc

2020-03-19 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 updated this revision to Diff 251290.
LiuChen3 retitled this revision from " Fix i386 struct and union parameter 
alignment" to "Adds an option "malign-pass-aggregate" to make the alignment of 
the struct and union parameters compatible with the default gcc".
LiuChen3 edited the summary of this revision.
LiuChen3 added a comment.

Add an option "malign-pass-aggregate" to compatible with gcc default passing 
struct and union.


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

https://reviews.llvm.org/D60748

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/x86_32-align-linux.c
  clang/test/CodeGen/x86_32-align-linux.cpp

Index: clang/test/CodeGen/x86_32-align-linux.cpp
===
--- /dev/null
+++ clang/test/CodeGen/x86_32-align-linux.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -malign-pass-aggregate -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+#include 
+
+typedef __attribute__((aligned(16))) int alignedint16;
+typedef __attribute__((aligned(64))) int alignedint64;
+
+class __attribute__((aligned(64))) X1 {
+  class  __attribute__((aligned(32))) {
+   __m128 a1;
+  } a;
+  int b;
+};
+
+class __attribute__((aligned(64))) X2 {
+  class  __attribute__((aligned(32))) {
+int a1;
+alignedint16 a2;
+  } a;
+  int b;
+};
+
+class __attribute__((aligned(32))) X3 {
+  class __attribute__((aligned(64))) {
+int a1;
+alignedint16 a2;
+  } a;
+ int b;
+};
+
+class __attribute__((aligned(16))) X4 {
+  class  __attribute__((aligned(32))) {
+int a1;
+alignedint64 a2;
+  } a;
+  int b;
+};
+
+class __attribute__((aligned(64))) X5 {
+  int x;
+};
+
+class __attribute__((aligned(64))) X6 {
+  int x;
+  alignedint64 y;
+};
+
+extern void foo(int, ...);
+
+class X1 x1;
+class X2 x2;
+class X3 x3;
+class X4 x4;
+class X5 x5;
+class X6 x6;
+
+// CHECK-LABEL: define void @_Z4testv()
+// CHECK: entry:
+// CHECK: call void (i32, ...) @_Z3fooiz(i32 1, %class.X1* byval(%class.X1) align 64
+// CHECK: call void (i32, ...) @_Z3fooiz(i32 1, %class.X2* byval(%class.X2) align 64
+// CHECK: call void (i32, ...) @_Z3fooiz(i32 1, %class.X3* byval(%class.X3) align 64
+// CHECK: call void (i32, ...) @_Z3fooiz(i32 1, %class.X4* byval(%class.X4) align 64
+// CHECK: call void (i32, ...) @_Z3fooiz(i32 1, %class.X5* byval(%class.X5) align 4
+// CHECK: call void (i32, ...) @_Z3fooiz(i32 1, %class.X6* byval(%class.X6) align 64
+
+void test(void)
+{
+  foo(1, x1);
+  foo(1, x2);
+  foo(1, x3);
+  foo(1, x4);
+  foo(1, x5);
+  foo(1, x6);
+}
Index: clang/test/CodeGen/x86_32-align-linux.c
===
--- /dev/null
+++ clang/test/CodeGen/x86_32-align-linux.c
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -malign-pass-aggregate -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+#include 
+
+typedef union {
+  int d[4];
+   __m128 m;
+} M128;
+
+typedef __attribute__((aligned(16))) int alignedint16;
+typedef __attribute__((aligned(64))) int alignedint64;
+
+struct __attribute__((aligned(64))) X1 {
+ struct  __attribute__((aligned(32))) {
+  int a1;
+ } a;
+ int b;
+};
+
+
+struct __attribute__((aligned(64))) X2 {
+ struct  __attribute__((aligned(32))) {
+  int a1;
+  alignedint16 a2;
+ } a;
+ int b;
+};
+
+struct __attribute__((aligned(32))) X3 {
+ struct __attribute__((aligned(64))) {
+  int a1;
+  alignedint16 a2;
+ } a;
+ int b;
+};
+
+struct __attribute__((aligned(16))) X4 {
+ struct  __attribute__((aligned(32))) {
+  int a1;
+  alignedint64 a2;
+ } a;
+ int b;
+};
+
+struct __attribute__((aligned(64))) X5 {
+  int x;
+};
+
+struct __attribute__((aligned(64))) X6 {
+ int x;
+ alignedint64 y;
+};
+
+union U1 {
+ struct __attribute__((aligned(32))) {
+  int i;
+  __m128 m;
+ };
+ int b;
+};
+
+extern void foo(int, ...);
+
+M128 a;
+struct X1 x1;
+struct X2 x2;
+struct X3 x3;
+struct X4 x4;
+struct X5 x5;
+struct X6 x6;
+union  U1 u1;
+
+// CHECK-LABEL: define void @test
+// CHECK: entry:
+// CHECK: call void (i32, ...) @foo(i32 1, %union.M128* byval(%union.M128) align 16
+// CHECK: call void (i32, ...) @foo(i32 1, <4 x float>
+// CHECK: call void (i32, ...) @foo(i32 1, %struct.X1* byval(%struct.X1) align 4
+// CHECK: call void (i32, ...) @foo(i32 1, %struct.X2* byval(%struct.X2) align 64
+// CHECK: call void (i32, ...) @foo(i32 1, %struct.X3* byval(%struct.X3) align 64
+// CHECK: call void (i32, ...) @foo(i32 1, %struct.X4* byval(%struct.X4) align 64
+// CHECK: call void (i32, ...) @foo(i32 1, %struct.X5* byval(%struct.X5) align 4
+// CHECK: call void (i32, ...) @foo(i32 1, %struct.X6* byval(%struct.X6) align 64
+// CHECK: call void (i32, ...) @foo(i32 1, %union.U1* byval(%union.U1) align 32
+void test(void)
+{
+  foo(1, a);
+  foo(1, a.m);
+  foo(1, x1);
+  fo

[PATCH] D76392: [AST] Make Expr::setDependence protected and remove add/removeDependence. NFC

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/Expr.h:2766
 
+  void markDependentForPostponedNameLookup() {
+setDependence(getDependence() | ExprDependence::TypeValueInstantiation);

the method name seems too concrete to me, I'd prefer to drop 
`ForPostponedNameLookup`, though there is only one usage in Sema.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76392



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


[clang] 4b0f1e1 - [AST] Add a flag indicating if any subexpression had errors

2020-03-19 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-03-19T08:56:10+01:00
New Revision: 4b0f1e12c243dd4c42665df0e2eab61f2fc4d237

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

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

The only subexpression that is considered an error now is TypoExpr, but
we plan to add expressions with errors to improve editor tooling on broken
code. We intend to use the same mechanism to guard against spurious
diagnostics on those as well.

See the follow-up revision for an actual usage of the flag.

Original patch from Ilya.

Reviewers: sammccall

Reviewed By: sammccall

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/ASTDumperUtils.h
clang/include/clang/AST/ComputeDependence.h
clang/include/clang/AST/DependenceFlags.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/Type.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTDumperUtils.h 
b/clang/include/clang/AST/ASTDumperUtils.h
index 55a085449a9b..1dce913049ad 100644
--- a/clang/include/clang/AST/ASTDumperUtils.h
+++ b/clang/include/clang/AST/ASTDumperUtils.h
@@ -62,6 +62,8 @@ static const TerminalColor LocationColor = 
{llvm::raw_ostream::YELLOW, false};
 static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false};
 // bitfield/objcproperty/objcsubscript/vectorcomponent
 static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false};
+// contains-errors
+static const TerminalColor ErrorsColor = {llvm::raw_ostream::RED, true};
 
 // Null statements
 static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false};

diff  --git a/clang/include/clang/AST/ComputeDependence.h 
b/clang/include/clang/AST/ComputeDependence.h
index 593ff3a6eb16..69ccb6c676e5 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -59,6 +59,7 @@ class CXXDeleteExpr;
 class ArrayTypeTraitExpr;
 class ExpressionTraitExpr;
 class CXXNoexceptExpr;
+class PackExpansionExpr;
 class SubstNonTypeTemplateParmExpr;
 class CoroutineSuspendExpr;
 class DependentCoawaitExpr;
@@ -71,6 +72,7 @@ class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
 class MaterializeTemporaryExpr;
+class CXXFoldExpr;
 class TypeTraitExpr;
 class ConceptSpecializationExpr;
 class PredefinedExpr;
@@ -134,6 +136,7 @@ ExprDependence computeDependence(CXXDeleteExpr *E);
 ExprDependence computeDependence(ArrayTypeTraitExpr *E);
 ExprDependence computeDependence(ExpressionTraitExpr *E);
 ExprDependence computeDependence(CXXNoexceptExpr *E, CanThrowResult CT);
+ExprDependence computeDependence(PackExpansionExpr *E);
 ExprDependence computeDependence(SubstNonTypeTemplateParmExpr *E);
 ExprDependence computeDependence(CoroutineSuspendExpr *E);
 ExprDependence computeDependence(DependentCoawaitExpr *E);
@@ -149,6 +152,7 @@ ExprDependence computeDependence(LambdaExpr *E,
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);
 ExprDependence computeDependence(CXXDependentScopeMemberExpr *E);
 ExprDependence computeDependence(MaterializeTemporaryExpr *E);
+ExprDependence computeDependence(CXXFoldExpr *E);
 ExprDependence computeDependence(TypeTraitExpr *E);
 ExprDependence computeDependence(ConceptSpecializationExpr *E,
  bool ValueDependent);

diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 21daf0a203ac..ee6439fc984c 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -20,19 +20,23 @@ struct ExprDependenceScope {
 Type = 4,
 Value = 8,
 
+// clang extension: this expr contains or references an error, and is
+// considered dependent on how that error is resolved.
+Error = 16,
+
 None = 0,
-All = 15,
+All = 31,
 
 TypeValue = Type | Value,
 TypeInstantiation = Type | Instantiation,
 ValueInstantiation = Value | Instantiation,
 TypeValueInstantiation = Type | Value | Instantiation,
 
-LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Value)
+LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)
   };
 };
 using ExprDependence = ExprDependenceScope::ExprDependence;
-static constexpr unsigned ExprDependenceBits = 4;
+static constexpr unsigned ExprDependenceBits = 5;
 
 struct TypeDependenceScope {
   enum TypeDependence : uint8_t {
@@ -47,6 +51,8 @@ struct TypeDependenceScope {
 /// 

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

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/AST/ComputeDependence.cpp:174
 ExprDependence clang::computeDependence(NoInitExpr *E) {
   return toExprDependence(E->getType()->getDependence()) &
  ExprDependence::Instantiation;

sammccall wrote:
> hokein wrote:
> > sammccall wrote:
> > > I'm not terribly sure of the implications of not propagating the error 
> > > bit here. I tend to think that "contains errors" most closely follows 
> > > instantiation-dependence (i.e. it's fairly strict/lexical), so I'd 
> > > consider propagating it here.
> > > 
> > > BTW, DesignatedInitUpdateExpr seems to have totally broken dependence 
> > > computations - it's always non-dependent! (Not introduced by this 
> > > refactoring, I think). Any idea what's up there?
> > you mean `DesignatedInitExpr`? I didn't see any problem there, why it is 
> > always non-dependent?
> no, DesignatedInitUpdateExpr. There's no computeDependence function, it just 
> marks itself as non-dependent in the constructor.
oh, no, that's totally wrong. I think it was there before, added a FIXME. 
Thanks for spotting it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591



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


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

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 251299.
hokein marked 2 inline comments as done.
hokein added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591

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

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -540,6 +540,7 @@
   Record.push_back(E->isValueDependent());
   Record.push_back(E->isInstantiationDependent());
   Record.push_back(E->containsUnexpandedParameterPack());
+  Record.push_back(E->containsErrors());
   Record.push_back(E->getValueKind());
   Record.push_back(E->getObjectKind());
 }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2280,6 +2280,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //DeclRefExpr
@@ -2303,6 +2304,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Integer Literal
@@ -2321,6 +2323,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Character Literal
@@ -2339,6 +2342,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   // CastExpr
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -106,7 +106,8 @@
 
 /// The number of record fields required for the Expr class
 /// itself.
-static const unsigned NumExprFields = NumStmtFields + 7;
+static const unsigned NumExprFields =
+NumStmtFields + ExprDependenceBits + 3;
 
 /// Read and initialize a ExplicitTemplateArgumentList structure.
 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
@@ -517,6 +518,7 @@
   bool ValueDependent = Record.readInt();
   bool InstantiationDependent = Record.readInt();
   bool ContainsUnexpandedTemplateParameters = Record.readInt();
+  bool ContainsErrors = Record.readInt();
   auto Deps = ExprDependence::None;
   if (TypeDependent)
 Deps |= ExprDependence::Type;
@@ -526,6 +528,8 @@
 Deps |= ExprDependence::Instantiation;
   if (ContainsUnexpandedTemplateParameters)
 Deps |= ExprDependence::UnexpandedPack;
+  if (ContainsErrors)
+Deps |= ExprDependence::Error;
   E->setDependence(Deps);
 
   E->setValueKind(static_cast(Record.readInt()));
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -126,6 +126,11 @@
   if (const auto *E = dyn_cast(Node)) {
 dumpType(E->getType());
 
+if (E->containsErrors()) {
+  ColorScope Color(OS, Sho

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

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b0f1e12c243: [AST] Add a flag indicating if any 
subexpression had errors (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591

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

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -540,6 +540,7 @@
   Record.push_back(E->isValueDependent());
   Record.push_back(E->isInstantiationDependent());
   Record.push_back(E->containsUnexpandedParameterPack());
+  Record.push_back(E->containsErrors());
   Record.push_back(E->getValueKind());
   Record.push_back(E->getObjectKind());
 }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2280,6 +2280,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //DeclRefExpr
@@ -2303,6 +2304,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Integer Literal
@@ -2321,6 +2323,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Character Literal
@@ -2339,6 +2342,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   // CastExpr
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -106,7 +106,8 @@
 
 /// The number of record fields required for the Expr class
 /// itself.
-static const unsigned NumExprFields = NumStmtFields + 7;
+static const unsigned NumExprFields =
+NumStmtFields + ExprDependenceBits + 3;
 
 /// Read and initialize a ExplicitTemplateArgumentList structure.
 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
@@ -517,6 +518,7 @@
   bool ValueDependent = Record.readInt();
   bool InstantiationDependent = Record.readInt();
   bool ContainsUnexpandedTemplateParameters = Record.readInt();
+  bool ContainsErrors = Record.readInt();
   auto Deps = ExprDependence::None;
   if (TypeDependent)
 Deps |= ExprDependence::Type;
@@ -526,6 +528,8 @@
 Deps |= ExprDependence::Instantiation;
   if (ContainsUnexpandedTemplateParameters)
 Deps |= ExprDependence::UnexpandedPack;
+  if (ContainsErrors)
+Deps |= ExprDependence::Error;
   E->setDependence(Deps);
 
   E->setValueKind(static_cast(Record.readInt()));
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -126,6 +126,11 @@
   if (const auto *E = dyn_cast(Node)) {
 dumpType(E->getType());
 
+ 

[PATCH] D65592: [Parser] Avoid spurious 'missing template' error in presence of typos

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 251303.
hokein added a comment.

rebase to master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65592

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/SemaTemplate/dependent-typos-recovery.cpp

Index: clang/test/SemaTemplate/dependent-typos-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/dependent-typos-recovery.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'template' keywords.
+struct B {
+  template 
+  int f(){};
+} builder;// expected-note 2{{'builder' declared here}}
+
+auto a = bilder.f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
+auto b = (*(&bilder+0)).f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1605,7 +1605,7 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus &&
-  ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  ParseOptionalCXXScopeSpecifier(SS, EnteringContext))
 return ANK_Error;
 
   if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
@@ -1841,8 +1841,7 @@
 //simple-template-id
 SourceLocation TypenameLoc = ConsumeToken();
 CXXScopeSpec SS;
-if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
-   /*EnteringContext=*/false, nullptr,
+if (ParseOptionalCXXScopeSpecifier(SS, /*EnteringContext=*/false, nullptr,
/*IsTypename*/ true))
   return true;
 if (SS.isEmpty()) {
@@ -1914,7 +1913,7 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus)
-if (ParseOptionalCXXScopeSpecifier(SS, nullptr, /*EnteringContext*/false))
+if (ParseOptionalCXXScopeSpecifier(SS, /*EnteringContext*/ false))
   return true;
 
   return TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation);
@@ -2043,7 +2042,7 @@
   assert(MightBeCXXScopeToken() && "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  if (ParseOptionalCXXScopeSpecifier(SS, EnteringContext))
 return true;
   if (SS.isEmpty())
 return false;
@@ -2152,8 +2151,7 @@
 
   // Parse nested-name-specifier.
   if (getLangOpts().CPlusPlus)
-ParseOptionalCXXScopeSpecifier(Result.SS, nullptr,
-   /*EnteringContext=*/false);
+ParseOptionalCXXScopeSpecifier(Result.SS, /*EnteringContext=*/false);
 
   // Check nested-name specifier.
   if (Result.SS.isInvalid()) {
@@ -2164,8 +2162,8 @@
   // Parse the unqualified-id.
   SourceLocation TemplateKWLoc; // FIXME: parsed, but unused.
   if (ParseUnqualifiedId(
-  Result.SS, /*EnteringContext*/false, /*AllowDestructorName*/true,
-  /*AllowConstructorName*/true, /*AllowDeductionGuide*/false, nullptr,
+  Result.SS, /*EnteringContext*/ false, /*AllowDestructorName*/ true,
+  /*AllowConstructorName*/ true, /*AllowDeductionGuide*/ false,
   &TemplateKWLoc, Result.Name)) {
 T.skipToEnd();
 return true;
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -363,9 +363,9 @@
   DiagnoseAndSkipCXX11Attributes();
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
-  /*EnteringContext=*/false, /*MayBePseudoDestructor=*/nullptr,
-  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
+  if (ParseOptionalCXXScopeSpecifier(
+  SS, /*EnteringContext=*/false, /*MayBePseudoDestructor=*/nullptr,
+  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
   SS.isInvalid()) {
 SkipUntil(tok::semi);
 return nullptr;
@@ -380,8 +380,7 @@
  /*AllowDestructorName=*/false,
  /*AllowConstructorName=*/false,
  /*AllowDeductionGuide=*/false,
- /*ObjectType=*/ParsedType(), /*TemplateKWLoc=*/nullptr,
- Result)) {
+ /*TemplateKWLoc=*/nullptr, Result)) {
 SkipUntil(tok::semi);
 return nullptr;
   }
@@ -683,7 +682,7 @@
   CXXScopeSpec SS;
   bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope);
   if (ParseOptionalCXXScopeSpecifier(
-  SS, ParsedType(),
+   

[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:29
+  assert(SS->isOpened() && 
\
+ "Create of error node failed (only way to get this state)?");
+

Create -> Creation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D76418: [Syntax] Build template declaration nodes

2020-03-19 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rollforward of
https://reviews.llvm.org/rGdd12826808f9079e164b82e64b0697a077379241 after
temporarily adding -fno-delayed-template-parsing to the TreeTest.

Original summary:

> Copy of https://reviews.llvm.org/D72334, submitting with Ilya's permission.
> 
> Handles template declaration of all kinds.
> 
> Also builds template declaration nodes for specializations and explicit
>  instantiations of classes.
> 
> Some missing things will be addressed in the follow-up patches:
> 
> - specializations of functions and variables,
> - template parameters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76418

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -99,6 +99,7 @@
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
+  "-fno-delayed-template-parsing",
   "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);
@@ -678,6 +679,212 @@
   `-;
 )txt"},
   {R"cpp(
+template  struct cls {};
+template  int var = 10;
+template  int fun() {}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-cls
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-int
+|   |-SimpleDeclarator
+|   | |-var
+|   | |-=
+|   | `-UnknownExpression
+|   |   `-10
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-fun
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"},
+  {R"cpp(
+template 
+struct X {
+  template 
+  U foo();
+};
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-{
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-U
+| |->
+| `-SimpleDeclaration
+|   |-U
+|   |-SimpleDeclarator
+|   | |-foo
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
+|-}
+`-;
+)txt"},
+  {R"cpp(
+template  struct X {};
+template  struct X {};
+template <> struct X {};
+
+template struct X;
+extern template struct X;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-T
+|   |-*
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-int
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-ExplicitTemplateInstantiation
+| |-template
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-double
+|   |->
+|   `-;
+`-ExplicitTemplateInstantiation
+  |-extern
+  |-template
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-float
+|->
+`-;
+)txt"},
+  {R"cpp(
+template  struct X { struct Y; };
+template  struct X::Y {};
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-Y
+|   | `-;
+|   |-}
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-T
+|->
+|-::
+|-Y
+|-{
+|-}
+`-;
+   )txt"},
+  {R"cpp(
 namespace ns {}
 using namespace ::ns;
 )cpp",
@@ -726,7 +933,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-UnknownDeclaration
+`-TemplateDeclaration
   |-template
   |-<
   |-UnknownDeclaration
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -58,6 +58,10 @@
 return OS << "Linka

[clang] 981f080 - [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-19 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-03-19T09:36:23Z
New Revision: 981f0802b37597975606d2b5f5bbc25974c4c3df

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

LOG: [SVE] Generate overloaded functions for ACLE intrinsics.

The SVE ACLE allows using a short-form for the intrinsics, e.g.
the following two declarations generate the same code:

  svuint32_t svld1(svbool_t, uint32_t const *);
  svuint32_t svld1_u32(svbool_t, uint32_t const *);

using the attribute:
  __clang_arm_builtin_alias

so that any call to svld1(svbool_t, uint32_t const *) will
map to __builtin_sve_svld1_u32.

Reviewers: SjoerdMeijer, miyuki, efriedma, simon_tatham, rengolin

Reviewed By: SjoerdMeijer

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a0d521d17d0f..10ed63d7ccae 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -359,6 +359,8 @@ class TargetArch arches> : TargetSpec {
   let Arches = arches;
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
+def TargetAArch64 : TargetArch<["aarch64"]>;
+def TargetAnyArm : TargetArch;
 def TargetAVR : TargetArch<["avr"]>;
 def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
@@ -623,7 +625,7 @@ def Alias : Attr {
   let Documentation = [Undocumented];
 }
 
-def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr {
+def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Clang<"__clang_arm_builtin_alias">];
   let Args = [IdentifierArgument<"BuiltinName">];
   let Subjects = SubjectList<[Function], ErrorDiag>;

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 67b7fa6cb46f..393fdcb479d5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4980,6 +4980,17 @@ static bool ArmCdeAliasValid(unsigned BuiltinID, 
StringRef AliasName) {
   return ArmBuiltinAliasValid(BuiltinID, AliasName, Map, IntrinNames);
 }
 
+static bool ArmSveAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  switch (BuiltinID) {
+  default:
+return false;
+#define GET_SVE_BUILTINS
+#define BUILTIN(name, types, attr) case SVE::BI##name:
+#include "clang/Basic/arm_sve_builtins.inc"
+return true;
+  }
+}
+
 static void handleArmBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   if (!AL.isArgIdent(0)) {
 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
@@ -4991,8 +5002,10 @@ static void handleArmBuiltinAliasAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
   unsigned BuiltinID = Ident->getBuiltinID();
   StringRef AliasName = cast(D)->getIdentifier()->getName();
 
-  if (!ArmMveAliasValid(BuiltinID, AliasName) &&
-  !ArmCdeAliasValid(BuiltinID, AliasName)) {
+  bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
+  if ((IsAArch64 && !ArmSveAliasValid(BuiltinID, AliasName)) ||
+  (!IsAArch64 && !ArmMveAliasValid(BuiltinID, AliasName) &&
+   !ArmCdeAliasValid(BuiltinID, AliasName))) {
 S.Diag(AL.getLoc(), diag::err_attribute_arm_builtin_alias);
 return;
   }

diff  --git 
a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
new file mode 100644
index ..90258f00de43
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s 
-D__ARM_FEATURE_SVE | FileCheck %s
+
+#include 
+//
+// ld1
+//
+
+svint8_t test_svld1_s8(svbool_t pg, const int8_t *base)
+{
+  // CHECK-LABEL: test_svld1_s8
+  // CHECK:  @llvm.masked.load.nxv16i8.p0nxv16i8(* %{{.*}}, i32 1,  %{{.*}},  
zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint16_t test_svld1_s16(svbool_t pg, const int16_t *base)
+{
+  // CHECK-LABEL: test_svld1_s16
+  // CHECK:  @llvm.masked.load.nxv8i16.p0nxv8i16(* %{{.*}}, i32 1,  %{{.*}},  
zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint32_t test_svld1_s32(svbool_t pg, const int32_t *base)
+{
+  // CHECK-LABEL: test_svld1_s32
+  // CHECK:  @llvm.masked.load.nxv4i32.p0nxv4i32(* %{{.*}}, i32 1,  %{{.*}},  
zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint64_t test_svld1_s64(svbool_t pg, const int64_t *base)
+{
+  // CHECK-LABEL: test_svld1_s64
+  // CHECK:  @llvm.masked.load.nxv2i64.p0nxv2i64(* %{{.*}}, i32 1,  %{{.*}},  
zeroinitializer)
+

[PATCH] D76396: Allow immediate invocation of constructors

2020-03-19 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

thanks for the the patch, but I have already a patch aiming to do the same 
thing. D74007 

> Provide improvements which allow the cached values of ConstantExpr to be used 
> by both the constant evaluator and code gen

this is definitely something we should do.

> Update the application of evaluation contexts, using the stronger guarantees 
> of manifest constant evaluation to apply the ConstantEvaluated evaluation 
> context in more places

the tracking of evaluation context isn't as good as it could/should.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76396



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


[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-03-19 Thread Tyker via Phabricator via cfe-commits
Tyker created this revision.
Tyker added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Tyker added a parent revision: D74130: [clang] fix consteval call in default 
arguements .

with this patch instead of emitting calls to consteval function. the IR-gen 
will emit a store of the already computed result.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76420

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -emit-llvm -Wno-unused-value %s -verify > /dev/null
 
 typedef __SIZE_TYPE__ size_t;
 
Index: clang/test/CodeGenCXX/cxx2a-consteval.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2a-consteval.cpp
@@ -0,0 +1,212 @@
+// NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EVAL -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-FN -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-STATIC -input-file=%t.ll %s
+// RUN: %clang_cc1 -emit-llvm %s -Dconsteval="" -std=c++2a -o %t.ll
+// RUNA: FileCheck -check-prefix=EXPR -input-file=%t.ll %s
+
+// there is two version of symbol checks to ensure
+// that the symbol we are looking for are correct
+// EVAL-NOT: @__cxx_global_var_init()
+// EXPR: @__cxx_global_var_init()
+
+// EVAL-NOT: @_Z4ret7v()
+// EXPR: @_Z4ret7v()
+consteval int ret7() {
+  return 7;
+}
+
+int test_ret7() {
+// EVAL-FN-LABEL: @_Z9test_ret7v(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[I:%.*]] = alloca i32, align 4
+// EVAL-FN-NEXT:store i32 7, i32* [[I]], align 4
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* [[I]], align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  int i = ret7();
+  return i;
+}
+
+// EVAL-STATIC: @global_i = global i32 7, align 4
+int global_i = ret7();
+
+// EVAL-STATIC: @_ZL7i_const = internal constant i32 5, align 4
+constexpr int i_const = 5;
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int& retI() {
+  return i_const;
+}
+
+const int& test_retRefI() {
+// EVAL-FN-LABEL: @_Z12test_retRefIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:ret i32* @_ZL7i_const
+//
+  return retI();
+}
+
+int test_retI() {
+// EVAL-FN-LABEL: @_Z9test_retIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return retI();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int* retIPtr() {
+  return &i_const;
+}
+
+int test_retIPtr() {
+// EVAL-FN-LABEL: @_Z12test_retIPtrv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return *retIPtr();
+}
+
+const int* test_retPIPtr() {
+// EVAL-FN-LABEL: @_Z13test_retPIPtrv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:ret i32* @_ZL7i_const
+//
+  return retIPtr();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int&& retIRRef() {
+  return static_cast(i_const);
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+const int&& test_retIRRef() {
+  return static_cast(retIRRef());
+}
+
+int test_retIRRefI() {
+// EVAL-FN-LABEL: @_Z14test_retIRRefIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return retIRRef();
+}
+
+struct Agg {
+  int a;
+  long b;
+};
+
+// EVAL-NOT: @_Z6retAggv()
+// EXPR: @_Z6retAggv()
+consteval Agg retAgg() {
+  return {13, 17};
+}
+
+long test_retAgg() {
+// EVAL-FN-LABEL: @_Z11test_retAggv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[B:%.*]] = alloca i64, align 8
+// EVAL-FN-NEXT:[[REF_TMP:%.*]] = alloca [[STRUCT_AGG:%.*]], align 8
+// EVAL-FN-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[STRUCT_AGG]], %struct.Agg* [[REF_TMP]], i32 0, i32 0
+// EVAL-FN-NEXT:store i32 13, i32* [[TMP0]], align 8
+// EVAL-FN-NEXT:[[TMP1:%.*]] = getelementptr inbounds [[STRUCT_AGG]], %struct.Agg* [[REF_TMP]], i32 0, i32 1
+// EVAL-FN-NEXT:store i64 17, i64* [[TMP1]], align 8
+// EVAL-FN-NEXT:

[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-19 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sdesmalen marked 4 inline comments as done.
Closed by commit rG981f0802b375: [SVE] Generate overloaded functions for ACLE 
intrinsics. (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D75861?vs=249404&id=251311#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75861

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -100,6 +100,10 @@
   /// string for passing to the BUILTIN() macro in Builtins.def.
   std::string builtin_str() const;
 
+  /// Return the C/C++ string representation of a type for use in the
+  /// arm_sve.h header file.
+  std::string str() const;
+
 private:
   /// Creates the type based on the typespec string in TS.
   void applyTypespec();
@@ -335,6 +339,45 @@
   return "q" + utostr(getNumElements() * NumVectors) + S;
 }
 
+std::string SVEType::str() const {
+  if (isPredicatePattern())
+return "sv_pattern";
+
+  if (isPrefetchOp())
+return "sv_prfop";
+
+  std::string S;
+  if (Void)
+S += "void";
+  else {
+if (isScalableVector())
+  S += "sv";
+if (!Signed && !Float)
+  S += "u";
+
+if (Float)
+  S += "float";
+else if (isScalarPredicate())
+  S += "bool";
+else
+  S += "int";
+
+if (!isScalarPredicate())
+  S += utostr(ElementBitwidth);
+if (!isScalableVector() && isVector())
+  S += "x" + utostr(getNumElements());
+if (NumVectors > 1)
+  S += "x" + utostr(NumVectors);
+S += "_t";
+  }
+
+  if (Constant)
+S += " const";
+  if (Pointer)
+S += " *";
+
+  return S;
+}
 void SVEType::applyTypespec() {
   for (char I : TS) {
 switch (I) {
@@ -515,8 +558,19 @@
<< "(...) __builtin_sve_" << mangleName(ClassS)
<< "(__VA_ARGS__)\n";
   } else {
-llvm_unreachable("Not yet implemented. Overloaded intrinsics will follow "
- "in a future patch");
+std::string FullName = mangleName(ClassS);
+std::string ProtoName = mangleName(ClassG);
+
+OS << "__aio __attribute__((__clang_arm_builtin_alias("
+   << "__builtin_sve_" << FullName << ")))\n";
+
+OS << getTypes()[0].str() << " " << ProtoName << "(";
+for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
+  if (I != 0)
+OS << ", ";
+  OS << getTypes()[I + 1].str();
+}
+OS << ");\n";
   }
 }
 
@@ -559,6 +613,11 @@
 Out.push_back(std::make_unique(Name, Proto, Merge,
   LLVMName, Flags, TS, ClassS,
   *this, Guard));
+
+// Also generate the short-form (e.g. svadd_m) for the given type-spec.
+if (Intrinsic::isOverloadedIntrinsic(Name))
+  Out.push_back(std::make_unique(
+  Name, Proto, Merge, LLVMName, Flags, TS, ClassG, *this, Guard));
   }
 }
 
@@ -608,6 +667,10 @@
   OS << "typedef __SVFloat64_t svfloat64_t;\n";
   OS << "typedef __SVBool_t  svbool_t;\n\n";
 
+  OS << "/* Function attributes */\n";
+  OS << "#define __aio static inline __attribute__((__always_inline__, "
+"__nodebug__, __overloadable__))\n\n";
+
   SmallVector, 128> Defs;
   std::vector RV = Records.getAllDerivedDefinitions("Inst");
   for (auto *R : RV)
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s -D__ARM_FEATURE_SVE | FileCheck %s
+
+#include 
+//
+// ld1
+//
+
+svint8_t test_svld1_s8(svbool_t pg, const int8_t *base)
+{
+  // CHECK-LABEL: test_svld1_s8
+  // CHECK:  @llvm.masked.load.nxv16i8.p0nxv16i8(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint16_t test_svld1_s16(svbool_t pg, const int16_t *base)
+{
+  // CHECK-LABEL: test_svld1_s16
+  // CHECK:  @llvm.masked.load.nxv8i16.p0nxv8i16(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint32_t test_svld1_s32(svbool_t pg, const int32_t *base)
+{
+  // CHECK-LABEL: test_svld1_s32
+  // CHECK:  @llvm.masked.load.nxv4i32.p0nxv4i32(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint64_t test_svld1_s64(svbool_t pg, const int64_t *base)
+{
+  // CHECK-LABEL: test_svld1_s64
+  // CHECK:  @llvm.masked.load.nxv2i64.p0nxv2i64(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svuint8_t

[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-19 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Addressed review comments before commititng. Thanks for the review @miyuki  and 
@SjoerdMeijer!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75861



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


[PATCH] D76367: [clang-format] Handle C# generic type constraints

2020-03-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir requested changes to this revision.
krasimir added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:326
 
+void UnwrappedLineParser::parseCSharpGenericTypeConstraint(bool ConsumeBrace) {
+  do {

If you remove the reference from parseRecored (see comment there), consider 
removing the `ConsumeBrace` argument -- all other references set it to `false`.
We can add this later when we need it.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2314
 }
+if (Style.isCSharp() && FormatTok->is(Keywords.kw_where)) {
+  addUnwrappedLine();

No tests fail if I remove this `if`.
Consider adding a test case for this or removing.
As this is the first in a series of patches, maybe we can add this in a later 
patch.



Comment at: clang/unittests/Format/FormatTestCSharp.cpp:631
   verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
-  verifyFormat(R"(class ItemFactory where T : new() {})", Style);
 

consider moving this test case to the new `CSharpGenericTypeConstraints`, 
re-formatted (as I understand it, this patch forces a newline before the 
`while`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76367



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


[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Some nits inlined




Comment at: clang/include/clang/Basic/AArch64SVETypeFlags.h:72
+  bool isStructStore() const { return Flags & IsStructStore; }
+  bool isZxtReturn() const { return Flags & IsZxtReturn; }
+

nit: this one is non obvious (at least to me), so perhaps worth a comment what 
this is. I can guess that Zext means zero extending, but you know, the 
context...



Comment at: clang/include/clang/Basic/arm_sve.td:128
 def SVLD1   : MInst<"svld1[_{2}]", "dPc", "csilUcUsUiUlhfd", [IsLoad]>;
+def SVLD1SB : MInst<"svld1sb_{d}", "dPS", "silUsUiUl",   [IsLoad], 
 MemEltTyInt8>;
+def SVLD1UB : MInst<"svld1ub_{d}", "dPW", "silUsUiUl",   [IsLoad, 
IsZxtReturn], MemEltTyInt8>;

nit: don't think we have a coding style for tablegen, but it is exceeding 80 
characters, even making this on phabricator a bit difficult to read, perhaps 
you can reshuffle this a bit.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7467
+
+  return IsZxtReturn ? Builder.CreateZExt(Load, VectorTy)
+ : Builder.CreateSExt(Load, VectorTy);

nit: and now looking at this, this can be a zero or sign extend, so `Zxt` is 
slightly misleading?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76238



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


[PATCH] D76422: Testing presubmits

2020-03-19 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

ignore me


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76422

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -99,6 +99,7 @@
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
+  "-fno-delayed-template-parsing",
   "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);
@@ -678,6 +679,212 @@
   `-;
 )txt"},
   {R"cpp(
+template  struct cls {};
+template  int var = 10;
+template  int fun() {}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-cls
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-int
+|   |-SimpleDeclarator
+|   | |-var
+|   | |-=
+|   | `-UnknownExpression
+|   |   `-10
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-fun
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"},
+  {R"cpp(
+template 
+struct X {
+  template 
+  U foo();
+};
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-{
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-U
+| |->
+| `-SimpleDeclaration
+|   |-U
+|   |-SimpleDeclarator
+|   | |-foo
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
+|-}
+`-;
+)txt"},
+  {R"cpp(
+template  struct X {};
+template  struct X {};
+template <> struct X {};
+
+template struct X;
+extern template struct X;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-T
+|   |-*
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-int
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-ExplicitTemplateInstantiation
+| |-template
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-double
+|   |->
+|   `-;
+`-ExplicitTemplateInstantiation
+  |-extern
+  |-template
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-float
+|->
+`-;
+)txt"},
+  {R"cpp(
+template  struct X { struct Y; };
+template  struct X::Y {};
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-Y
+|   | `-;
+|   |-}
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-T
+|->
+|-::
+|-Y
+|-{
+|-}
+`-;
+   )txt"},
+  {R"cpp(
 namespace ns {}
 using namespace ::ns;
 )cpp",
@@ -726,7 +933,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-UnknownDeclaration
+`-TemplateDeclaration
   |-template
   |-<
   |-UnknownDeclaration
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -58,6 +58,10 @@
 return OS << "LinkageSpecificationDeclaration";
   case NodeKind::SimpleDeclaration:
 return OS << "SimpleDeclaration";
+  case NodeKind::TemplateDeclaration:
+return OS << "TemplateDeclaration";
+  case NodeKind::ExplicitTemplateInstantiation:
+return OS << "ExplicitTemplateInstantiation";
   case NodeKind::NamespaceDefinition:
 return OS << "NamespaceDefinition";
   case NodeKind::NamespaceAliasDefinition:
@@ -118,6 +122,12 @@
 return OS << "StaticAssertDeclaration_message";
   case syntax::NodeRole::SimpleDeclaration_declarator:

[PATCH] D76379: [Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std::next()`

2020-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 251320.
baloghadamsoftware added a comment.

Updated according to the comments and automatic formatting suggestions.


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

https://reviews.llvm.org/D76379

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h


Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -785,8 +785,8 @@
 
   template 
   ForwardIterator
-  next (ForwardIterator it,
-typename iterator_traits::difference_type n = 1) {
+  next(ForwardIterator it,
+   typename iterator_traits::difference_type n = 1) {
 advance(it, n);
 return it;
   }
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -41,21 +41,19 @@
   void verifyNext(CheckerContext &C, SVal LHS, SVal RHS) const;
   void reportBug(const StringRef &Message, SVal Val, CheckerContext &C,
  ExplodedNode *ErrNode) const;
+
 public:
   IteratorRangeChecker();
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
 
-  typedef void (IteratorRangeChecker::*AdvanceFn)(CheckerContext &, SVal,
-  SVal) const;
+  using AdvanceFn = void (IteratorRangeChecker::*)(CheckerContext &, SVal,
+   SVal) const;
 
   CallDescriptionMap AdvanceFunctions = {
-{{{"std", "advance"}, 2},
- &IteratorRangeChecker::verifyAdvance},
-{{{"std", "prev"}, 2},
- &IteratorRangeChecker::verifyPrev},
-{{{"std", "next"}, 2},
- &IteratorRangeChecker::verifyNext},
+  {{{"std", "advance"}, 2}, &IteratorRangeChecker::verifyAdvance},
+  {{{"std", "prev"}, 2}, &IteratorRangeChecker::verifyPrev},
+  {{{"std", "next"}, 2}, &IteratorRangeChecker::verifyNext},
   };
 };
 
@@ -128,8 +126,9 @@
 (this->**Verifier)(C, Call.getArgSVal(0), Call.getArgSVal(1));
   } else {
 auto &BVF = C.getSValBuilder().getBasicValueFactory();
-(this->**Verifier)(C, Call.getArgSVal(0),
-   
nonloc::ConcreteInt(BVF.getValue(llvm::APSInt::get(1;
+(this->**Verifier)(
+C, Call.getArgSVal(0),
+nonloc::ConcreteInt(BVF.getValue(llvm::APSInt::get(1;
   }
 }
   }
@@ -161,8 +160,8 @@
 }
 
 void IteratorRangeChecker::verifyRandomIncrOrDecr(CheckerContext &C,
- OverloadedOperatorKind Op,
- SVal LHS, SVal RHS) const {
+  OverloadedOperatorKind Op,
+  SVal LHS, SVal RHS) const {
   auto State = C.getState();
 
   auto Value = RHS;
@@ -213,7 +212,7 @@
 }
 
 void IteratorRangeChecker::verifyNext(CheckerContext &C, SVal LHS,
- SVal RHS) const {
+  SVal RHS) const {
   verifyRandomIncrOrDecr(C, OO_Plus, LHS, RHS);
 }
 


Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -785,8 +785,8 @@
 
   template 
   ForwardIterator
-  next (ForwardIterator it,
-typename iterator_traits::difference_type n = 1) {
+  next(ForwardIterator it,
+   typename iterator_traits::difference_type n = 1) {
 advance(it, n);
 return it;
   }
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -41,21 +41,19 @@
   void verifyNext(CheckerContext &C, SVal LHS, SVal RHS) const;
   void reportBug(const StringRef &Message, SVal Val, CheckerContext &C,
  ExplodedNode *ErrNode) const;
+
 public:
   IteratorRangeChecker();
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
 
-  typedef void (IteratorRangeChecker::*AdvanceFn)(CheckerContext &, SVal,
-  SVal) const;
+  using AdvanceFn = void (IteratorRangeChecker::*)(CheckerContext &, SVal,
+   SVal) const;
 
   CallDescriptionMap AdvanceFunctions = {
-{{{"std", "advance"}, 2},
- &IteratorRangeChecker::verifyAdvance},
-{{{"std", "prev"}, 2},
- &IteratorRange

[PATCH] D76379: [Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std::next()`

2020-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

In D76379#1929698 , @Szelethus wrote:

> The patch looks great, though I'd kindly ask you to wait a bit for someone 
> with a bit more experience on `SVal`-smithing ;)


Do you mean the change from `const SVal &` to `SVal`? It was done according to 
this comment .

> Generally speaking, I think the word you are looking for is "validate", not 
> "verify", is that right, @whisperity?

We always used the word "verify" in the iterator checkers for checking for 
bugs. The word "check" is reserved for the hooks, "handle" is used in the 
modeling. This is an internal concept for the container-iterator ecosystem, I 
do not know about common Clang Static Analyzer coding standard here.


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

https://reviews.llvm.org/D76379



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


[PATCH] D76424: [AST] Use TypeDependence bitfield to calculate dependence on Types. NFC

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
sammccall added a comment.

This mostly corresponds to the Expr refactoring in 
ec3060c72de6ab6992269318d92764199856e5fe 
, without 
the followup moving it to ComputeDependence yet.

I used a constructor param to assist in the refactoring and because most cases 
are really simple.


This clears the way for adding an Error dependence bit to Type and having it
mostly-automatically propagated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76424

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/include/clang/AST/LocInfoType.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp

Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DependenceFlags.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
@@ -123,14 +124,15 @@
 //
 //   template int arr[] = {N...};
 : Type(tc, can,
-   et->isDependentType() || (sz && sz->isValueDependent()) ||
-   tc == DependentSizedArray,
-   et->isInstantiationDependentType() ||
-   (sz && sz->isInstantiationDependent()) ||
-   tc == DependentSizedArray,
-   (tc == VariableArray || et->isVariablyModifiedType()),
-   et->containsUnexpandedParameterPack() ||
-   (sz && sz->containsUnexpandedParameterPack())),
+   et->getDependence() |
+   (sz ? toTypeDependence(
+ turnValueToTypeDependence(sz->getDependence()))
+   : TypeDependence::None) |
+   (tc == VariableArray ? TypeDependence::VariablyModified
+: TypeDependence::None) |
+   (tc == DependentSizedArray
+? TypeDependence::DependentInstantiation
+: TypeDependence::None)),
   ElementType(et) {
   ArrayTypeBits.IndexTypeQuals = tq;
   ArrayTypeBits.SizeModifier = sm;
@@ -217,14 +219,16 @@
   E->Profile(ID, Context, true);
 }
 
-DependentVectorType::DependentVectorType(
-const ASTContext &Context, QualType ElementType, QualType CanonType,
-Expr *SizeExpr, SourceLocation Loc, VectorType::VectorKind VecKind)
-: Type(DependentVector, CanonType, /*Dependent=*/true,
-   /*InstantiationDependent=*/true,
-   ElementType->isVariablyModifiedType(),
-   ElementType->containsUnexpandedParameterPack() ||
-   (SizeExpr && SizeExpr->containsUnexpandedParameterPack())),
+DependentVectorType::DependentVectorType(const ASTContext &Context,
+ QualType ElementType,
+ QualType CanonType, Expr *SizeExpr,
+ SourceLocation Loc,
+ VectorType::VectorKind VecKind)
+: Type(DependentVector, CanonType,
+   TypeDependence::DependentInstantiation |
+   ElementType->getDependence() |
+   (SizeExpr ? toTypeDependence(SizeExpr->getDependence())
+ : TypeDependence::None)),
   Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
   VectorTypeBits.VecKind = VecKind;
 }
@@ -238,19 +242,16 @@
   SizeExpr->Profile(ID, Context, true);
 }
 
-DependentSizedExtVectorType::DependentSizedExtVectorType(const
- ASTContext &Context,
- QualType ElementType,
- QualType can,
- Expr *SizeExpr,
- SourceLocation loc)
-: Type(DependentSizedExtVector, can, /*Dependent=*/true,
-   /*InstantiationDependent=*/true,
-   ElementType->isVariablyModifiedType(),
-   (ElementType->containsUnexpandedParameterPack() ||
-(SizeExpr && SizeExpr->containsUnexpandedParameterPack(,
-  Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
-  loc(loc) {}
+DependentSizedExtVectorType::DependentSizedExtVectorType(
+const ASTContext &Context, QualType ElementType, QualType can,
+Expr *SizeExpr, SourceLocation loc)
+: Type(DependentSizedExtVector, can,
+   TypeDependence::DependentInstantiation |
+   ElementType->getDependence() |
+   (SizeExpr ? toTypeDependence(SizeExpr->

[PATCH] D76424: [AST] Use TypeDependence bitfield to calculate dependence on Types. NFC

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This mostly corresponds to the Expr refactoring in 
ec3060c72de6ab6992269318d92764199856e5fe 
, without 
the followup moving it to ComputeDependence yet.

I used a constructor param to assist in the refactoring and because most cases 
are really simple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76424



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


[PATCH] D76062: [PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support

2020-03-19 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked an inline comment as done.
stuij added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:184
+  // Also include the Armv8.5 defines
+  // FIXME: Armv8.6 makes some extensions mandatory. Handle them here.
+  getTargetDefinesARMV85A(Opts, Builder);

SjoerdMeijer wrote:
> Can you be more specific, what are we missing here?
> 
> Hmm, now I see the same above: "FIXME: Armv8.5 makes some extensions 
> mandatory. Handle them here."
> While you're at it, can you also change that?
Those comments were somewhat of a drive-by nature, made by a GCC contributor. I 
went through the v8.x extensions and tried to match them with both GCC and LLVM 
feature defines. Neither LLVM or GCC has defines for all extensions, and after 
talking to the contributer (Kyrylo Tkachov), it turns out he had at most parity 
with GCC in mind. 

As an aside GCC seems to have about 14 feature defines that are not present in 
LLVM, and one feature is spelled __ARM_FEATURE_FP16_FML in GCC and 
__ARM_FEATURE_FP16FML in LLVM.

After surveying the list, I found a few defines that could be placed here. I've 
added them as inline comments. I think they deserve their own patch, as this 
involves multiple revisions and you'd like to make sure that it's all handled 
sensibly. I believe we have plans to overhaul this general area.

I've removed the fixme's in revisions that didn't actually need them.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:52
+  AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
+  AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM))

SjoerdMeijer wrote:
> just double checking (because I can't remember): BF16 is a mandatory 
> extension?
for 8.2 it isn't, for 8.6 it is


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76062



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


[PATCH] D76094: [clangd] Change line break behaviour for hoverinfo

2020-03-19 Thread Lorenz Junglas via Phabricator via cfe-commits
lolleko updated this revision to Diff 251334.
lolleko edited the summary of this revision.
lolleko added a comment.

Addressed review.

Paragraphs (lines separated by a double line break `\n\n`) are currently not 
retained. Because the current implementation of markup::Paragraph only appends 
a single white space after it's contents 
(https://github.com/llvm/llvm-project/blob/e26e9ba288ce156b851504ebbb7d8a775572957c/clang-tools-extra/clangd/FormattedString.cpp#L368).
I think this is semantically wrong because in natural language aswell as markup 
languages like md, html, ... a paragraph should be followed by a blank line.
But since a lot of code relies on that single white space paragraph, this 
should be addressed in a different patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76094

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1883,6 +1883,118 @@
   }
 }
 
+TEST(Hover, LineBreakConversionDocs) {
+  struct Case {
+const std::function Builder;
+llvm::StringRef ExpectedRenderMarkdown;
+llvm::StringRef ExpectedRenderPlainText;
+  } Cases[] = {{
+   [](HoverInfo &HI) { HI.Documentation = "foo\n\n\nbar"; },
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n\n\n\tbar"; },
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n\n\n bar"; },
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo.\nbar"; },
+   "foo.  \nbar",
+   "foo.\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo:\nbar"; },
+   "foo:  \nbar",
+   "foo:\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo,\nbar"; },
+   "foo,  \nbar",
+   "foo,\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo;\nbar"; },
+   "foo;  \nbar",
+   "foo;\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo!\nbar"; },
+   "foo!  \nbar",
+   "foo!\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo?\nbar"; },
+   "foo?  \nbar",
+   "foo?\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n-bar"; },
+   "foo  \n-bar",
+   "foo\n-bar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n*bar"; },
+   // TODO `*` should probably not be escaped after line break
+   "foo  \n\\*bar",
+   "foo\n*bar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n@bar"; },
+   "foo  \n@bar",
+   "foo\n@bar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n\\bar"; },
+   // TODO `\` should probably not be escaped after line break
+   "foo  \nbar",
+   "foo\n\\bar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n>bar"; },
+   // TODO `>` should probably not be escaped after line break
+   "foo  \n\\>bar",
+   "foo\n>bar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\n#bar"; },
+   "foo  \n#bar",
+   "foo\n#bar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo  \nbar"; },
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\nbar"; },
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentation = "foo\\\nbar"; },
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   [](HoverInfo &HI) { HI.Documentati

[PATCH] D76062: [PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support

2020-03-19 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 251336.
stuij marked 3 inline comments as done.
stuij added a comment.

addressing Sjoerd's comments on mandatory defines and rewording


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76062

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/lib/Target/ARM/ARMInstrVFP.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/test/MC/AArch64/SVE/bfcvt-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfcvt.s
  llvm/test/MC/AArch64/SVE/bfcvtnt-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfcvtnt.s
  llvm/test/MC/AArch64/SVE/bfdot-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfdot.s
  llvm/test/MC/AArch64/SVE/bfmlal-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfmlal.s
  llvm/test/MC/AArch64/SVE/bfmmla-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfmmla.s
  llvm/test/MC/AArch64/armv8.6a-bf16.s
  llvm/test/MC/ARM/bfloat16-a32-errors.s
  llvm/test/MC/ARM/bfloat16-a32-errors2.s
  llvm/test/MC/ARM/bfloat16-a32.s
  llvm/test/MC/ARM/bfloat16-t32-errors.s
  llvm/test/MC/ARM/bfloat16-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.6a-bf16.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-a32_1.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-a32_2.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-t32.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-t32_errors.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -26,9 +26,9 @@
 "armv7e-m","armv7em",  "armv8-a", "armv8","armv8a",
 "armv8l",  "armv8.1-a","armv8.1a","armv8.2-a","armv8.2a",
 "armv8.3-a",   "armv8.3a", "armv8.4-a",   "armv8.4a", "armv8.5-a",
-"armv8.5a", "armv8-r", "armv8r",  "armv8-m.base", "armv8m.base",
-"armv8-m.main", "armv8m.main", "iwmmxt",  "iwmmxt2",  "xscale",
-"armv8.1-m.main",
+"armv8.5a", "armv8.6-a",   "armv8.6a", "armv8-r", "armv8r",
+"armv8-m.base", "armv8m.base", "armv8-m.main", "armv8m.main", "iwmmxt",
+"iwmmxt2",  "xscale",  "armv8.1-m.main",
 };
 
 bool testARMCPU(StringRef CPUName, StringRef ExpectedArch,
@@ -411,6 +411,9 @@
   testARMArch("armv8.5-a", "generic", "v8.5a",
   ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(
+  testARMArch("armv8.6-a", "generic", "v8.6a",
+  ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
   testARMArch("armv8-r", "cortex-r52", "v8r",
   ARMBuildAttrs::CPUArch::v8_R));
   EXPECT_TRUE(
@@ -678,7 +681,7 @@
   "v7",   "v7a","v7ve",  "v7hl",   "v7l",   "v7-r",   "v7r",   "v7-m",
   "v7m",  "v7k","v7s",   "v7e-m",  "v7em",  "v8-a",   "v8","v8a",
   "v8l",  "v8.1-a", "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
-  "v8.4a", "v8.5-a","v8.5a", "v8-r",   "v8m.base", "v8m.main", "v8.1m.main"
+  "v8.4a", "v8.5-a","v8.5a", "v8.6-a", "v8.6a", "v8-r",   "v8m.base", "v8m.main", "v8.1m.main"
   };
 
   for (unsigned i = 0; i < array_lengthof(Arch); i++) {
@@ -743,6 +746,7 @@
 case ARM::ArchKind::ARMV8_3A:
 case ARM::ArchKind::ARMV8_4A:
 case ARM::ArchKind::ARMV8_5A:
+case ARM::ArchKind::ARMV8_6A:
   EXPECT_EQ(ARM::ProfileKind::A, ARM::parseArchProfile(ARMArch[i]));
   break;
 default:
@@ -1008,6 +1012,8 @@
   ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(testAArch64Arch("armv8.5-a", "generic", "v8.5a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testAArch64Arch("armv8.6-a", "generic", "v8.6a",
+  ARMBuildAttrs::CPUArch::v8_A));
 }
 
 bool testAArch64Extension(StringRef CPUName, AArch64::ArchKind AK,
Index: llvm/test/MC/Disassembler/ARM

[PATCH] D76392: [AST] Make Expr::setDependence protected and remove add/removeDependence. NFC

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang/include/clang/AST/Expr.h:2766
 
+  void markDependentForPostponedNameLookup() {
+setDependence(getDependence() | ExprDependence::TypeValueInstantiation);

hokein wrote:
> the method name seems too concrete to me, I'd prefer to drop 
> `ForPostponedNameLookup`, though there is only one usage in Sema.
So the idea here is that we're breaking encapsulation for a special purpose, 
and this method shouldn't be generally used to manipulate dependence.
If we do want to add another usage (in sema or elsewhere) for another purpose, 
it makes sense to have to modify `Expr` (by renaming the method or adding 
another one), just as if this function was private.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76392



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


[PATCH] D76392: [AST] Make Expr::setDependence protected and remove add/removeDependence. NFC

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 251337.
sammccall added a comment.

Add comment on markDependentForPostponedNameLookup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76392

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConcepts.cpp
  clang/lib/Sema/SemaOverload.cpp

Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12720,7 +12720,7 @@
   // base classes.
   CallExpr *CE = CallExpr::Create(Context, Fn, Args, Context.DependentTy,
   VK_RValue, RParenLoc);
-  CE->addDependence(ExprDependence::TypeValueInstantiation);
+  CE->markDependentForPostponedNameLookup();
   *Result = CE;
   return true;
 }
Index: clang/lib/AST/ExprConcepts.cpp
===
--- clang/lib/AST/ExprConcepts.cpp
+++ clang/lib/AST/ExprConcepts.cpp
@@ -175,13 +175,13 @@
   RequiresExprBits.IsSatisfied |= Dependent;
   // FIXME: move the computing dependency logic to ComputeDependence.h
   if (ContainsUnexpandedParameterPack)
-addDependence(ExprDependence::UnexpandedPack);
+setDependence(getDependence() | ExprDependence::UnexpandedPack);
   // FIXME: this is incorrect for cases where we have a non-dependent
   // requirement, but its parameters are instantiation-dependent. RequiresExpr
   // should be instantiation-dependent if it has instantiation-dependent
   // parameters.
   if (Dependent)
-addDependence(ExprDependence::ValueInstantiation);
+setDependence(getDependence() | ExprDependence::ValueInstantiation);
 }
 
 RequiresExpr::RequiresExpr(ASTContext &C, EmptyShell Empty,
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1497,28 +1497,15 @@
   MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
NameInfo, T, VK, OK, NOUR);
 
-  if (isa(MemberDecl)) {
-DeclContext *DC = MemberDecl->getDeclContext();
-// dyn_cast_or_null is used to handle objC variables which do not
-// have a declaration context.
-CXXRecordDecl *RD = dyn_cast_or_null(DC);
-if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC)) {
-  if (E->isTypeDependent() && !T->isDependentType())
-E->removeDependence(ExprDependence::Type);
-}
-// Bitfield with value-dependent width is type-dependent.
-FieldDecl *FD = dyn_cast(MemberDecl);
-if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent())
-  E->addDependence(ExprDependence::Type);
-  }
-
+  // FIXME: remove remaining dependence computation to computeDependence().
+  auto Deps = E->getDependence();
   if (HasQualOrFound) {
 // FIXME: Wrong. We should be looking at the member declaration we found.
 if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent())
-  E->addDependence(ExprDependence::TypeValueInstantiation);
+  Deps |= ExprDependence::TypeValueInstantiation;
 else if (QualifierLoc &&
  QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())
-  E->addDependence(ExprDependence::Instantiation);
+  Deps |= ExprDependence::Instantiation;
 
 E->MemberExprBits.HasQualifierOrFoundDecl = true;
 
@@ -1532,16 +1519,17 @@
   TemplateArgs || TemplateKWLoc.isValid();
 
   if (TemplateArgs) {
-auto Deps = TemplateArgumentDependence::None;
+auto TemplateArgDeps = TemplateArgumentDependence::None;
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc, *TemplateArgs,
-E->getTrailingObjects(), Deps);
-if (Deps & TemplateArgumentDependence::Instantiation)
-  E->addDependence(ExprDependence::Instantiation);
+E->getTrailingObjects(), TemplateArgDeps);
+if (TemplateArgDeps & TemplateArgumentDependence::Instantiation)
+  Deps |= ExprDependence::Instantiation;
   } else if (TemplateKWLoc.isValid()) {
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc);
   }
+  E->setDependence(Deps);
 
   return E;
 }
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -475,7 +475,25 @@
 }
 
 ExprDependence clang::computeDependence(MemberExpr *E) {
-  return E->getBase()->getDependence();
+  auto *MemberDecl = E->getMemberDecl();
+  auto D = E->getBase()->getDependence();
+  if (FieldDecl *FD = dyn_cast(MemberDecl)) {
+DeclContext *DC = MemberDecl->getDeclContext();
+// dyn_cast_or_null is used to handle objC variables which do not
+// have a declaration context.
+CXXRecordDecl *RD = dyn_ca

[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-03-19 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked 2 inline comments as done.
sdesmalen added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7467
+
+  return IsZxtReturn ? Builder.CreateZExt(Load, VectorTy)
+ : Builder.CreateSExt(Load, VectorTy);

SjoerdMeijer wrote:
> nit: and now looking at this, this can be a zero or sign extend, so `Zxt` is 
> slightly misleading?
The default is sign-extend, so we added a flag for the case where a zero-extend 
is needed/expected. Are you suggesting to rename the flag or to add an extra 
flag for IsSxt?



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1.c:314
+  // CHECK: @llvm.masked.store.nxv8i16.p0nxv8i16( %data, 
* %[[GEP]], i32 1,  %{{.*}})
+  return svst1_vnum_u16(pg, base, 129, data);
+}

I can probably prune these tests a bit, when we generated these initially we 
also tested for code-gen, (hence the 129, which doesn't fit the immediate). 
This is properly tested in .ll tests in LLVM now, so I'll remove these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76238



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


[PATCH] D65592: [Parser] Avoid spurious 'missing template' error in presence of typos

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!

I don't love adding those overloads, but not clear there's something better.




Comment at: clang/lib/Parse/ParseExprCXX.cpp:2973
 
+bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
+bool AllowDestructorName,

I'd consider inlining these convenience overloads



Comment at: clang/lib/Parse/ParseTemplate.cpp:685
   if (ParseOptionalCXXScopeSpecifier(
-  SS, ParsedType(),
+  SS, ParsedType(), /*ObjectHadErrors*/false,
   /*EnteringContext=*/false,

nit: ObjectHadErrors=



Comment at: clang/lib/Parse/ParseTemplate.cpp:685
   if (ParseOptionalCXXScopeSpecifier(
-  SS, ParsedType(),
+  SS, ParsedType(), /*ObjectHadErrors*/false,
   /*EnteringContext=*/false,

sammccall wrote:
> nit: ObjectHadErrors=
this can use the simple overload, ParsedType() is the same as nullptr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65592



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


[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-03-19 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.

I'm happy with the approach here.

At some point we should put version numbers into the target features, but I 
think that can wait until we know how to cope with how the `G` extension 
expands into its other extensions (this has some open questions in general). 
This suggestion does not, in my mind, block this patch, as including 
`experimental-` in the target feature names does make it clear which features 
are experimental today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73891



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


[clang] dade859 - [ARM] Setting missing isLaneQ attribute on Neon Intrisics definitions

2020-03-19 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2020-03-19T12:04:14Z
New Revision: dade859b58827eaddc88f820c5dd5a28cf3532f3

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

LOG: [ARM] Setting missing isLaneQ attribute on Neon Intrisics definitions

Summary:
Some of the `*_laneq` intrinsics defined in arm_neon.td were missing the
setting of the `isLaneQ` attribute. This patch sets the attribute on the
related definitions, as they will be required to properly perform range
checks on their lane arguments.

Reviewers: jmolloy, t.p.northover, rsmith, olista01, dnsampaio

Reviewed By: dnsampaio

Subscribers: dnsampaio, kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 380a2a0a5fa6..5ae25b311bb2 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -881,16 +881,22 @@ def COPY_LANE : IOpInst<"vcopy_lane", "..I.I",
 def COPYQ_LANE : IOpInst<"vcopy_lane", "..IqI",
 "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN>;
 def COPY_LANEQ : IOpInst<"vcopy_laneq", "..IQI",
- "csilPcPsPlUcUsUiUlfd", OP_COPY_LN>;
+ "csilPcPsPlUcUsUiUlfd", OP_COPY_LN> {
+  let isLaneQ = 1;
+}
 def COPYQ_LANEQ : IOpInst<"vcopy_laneq", "..I.I",
- "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN>;
+ "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN> {
+  let isLaneQ = 1;
+}
 
 

 // Set all lanes to same value
 def VDUP_LANE1: WOpInst<"vdup_lane", ".qI", "hdQhQdPlQPl", OP_DUP_LN>;
 def VDUP_LANE2: WOpInst<"vdup_laneq", ".QI",
   "csilUcUsUiUlPcPshfdQcQsQiQlQPcQPsQUcQUsQUiQUlQhQfQdPlQPl",
-OP_DUP_LN>;
+OP_DUP_LN> {
+  let isLaneQ = 1;
+}
 def DUP_N   : WOpInst<"vdup_n", ".1", "dQdPlQPl", OP_DUP>;
 def MOV_N   : WOpInst<"vmov_n", ".1", "dQdPlQPl", OP_DUP>;
 
@@ -906,38 +912,60 @@ def CREATE : NoTestOpInst<"vcreate", ".(IU>)", "dPl", 
OP_CAST> {
 

 
 def VMLA_LANEQ   : IOpInst<"vmla_laneq", "...QI",
-   "siUsUifQsQiQUsQUiQf", OP_MLA_LN>;
+   "siUsUifQsQiQUsQUiQf", OP_MLA_LN> {
+  let isLaneQ = 1;
+}
 def VMLS_LANEQ   : IOpInst<"vmls_laneq", "...QI",
-   "siUsUifQsQiQUsQUiQf", OP_MLS_LN>;
+   "siUsUifQsQiQUsQUiQf", OP_MLS_LN> {
+  let isLaneQ = 1;
+}
 
 def VFMA_LANE: IInst<"vfma_lane", "...qI", "fdQfQd">;
 def VFMA_LANEQ   : IInst<"vfma_laneq", "...QI", "fdQfQd"> {
   let isLaneQ = 1;
 }
 def VFMS_LANE: IOpInst<"vfms_lane", "...qI", "fdQfQd", OP_FMS_LN>;
-def VFMS_LANEQ   : IOpInst<"vfms_laneq", "...QI", "fdQfQd", OP_FMS_LNQ>;
+def VFMS_LANEQ   : IOpInst<"vfms_laneq", "...QI", "fdQfQd", OP_FMS_LNQ> {
+  let isLaneQ = 1;
+}
 
-def VMLAL_LANEQ  : SOpInst<"vmlal_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLAL_LN>;
+def VMLAL_LANEQ  : SOpInst<"vmlal_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLAL_LN> 
{
+  let isLaneQ = 1;
+}
 def VMLAL_HIGH_LANE   : SOpInst<"vmlal_high_lane", "(>Q)(>Q)Q.I", "siUsUi",
 OP_MLALHi_LN>;
 def VMLAL_HIGH_LANEQ  : SOpInst<"vmlal_high_laneq", "(>Q)(>Q)QQI", "siUsUi",
-OP_MLALHi_LN>;
-def VMLSL_LANEQ  : SOpInst<"vmlsl_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLSL_LN>;
+OP_MLALHi_LN> {
+  let isLaneQ = 1;
+}
+def VMLSL_LANEQ  : SOpInst<"vmlsl_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLSL_LN> 
{
+  let isLaneQ = 1;
+}
 def VMLSL_HIGH_LANE   : SOpInst<"vmlsl_high_lane", "(>Q)(>Q)Q.I", "siUsUi",
 OP_MLSLHi_LN>;
 def VMLSL_HIGH_LANEQ  : SOpInst<"vmlsl_high_laneq", "(>Q)(>Q)QQI", "siUsUi",
-OP_MLSLHi_LN>;
+OP_MLSLHi_LN> {
+  let isLaneQ = 1;
+}
 
-def VQDMLAL_LANEQ  : SOpInst<"vqdmlal_laneq", "(>Q)(>Q).QI", "si", 
OP_QDMLAL_LN>;
+def VQDMLAL_LANEQ  : SOpInst<"vqdmlal_laneq", "(>Q)(>Q).QI", "si", 
OP_QDMLAL_LN> {
+  let isLaneQ = 1;
+}
 def VQDMLAL_HIGH_LANE   : SOpInst<"vqdmlal_high_lane", "(>Q)(>Q)Q.I", "si",
 OP_QDMLALHi_LN>;
 def VQDMLAL_HIGH_LANEQ  : SOpInst<"vqdmlal_high_laneq", "(>Q)(>Q)QQI", "si",
-OP_QDMLALHi_LN>;
-def VQDMLSL_LANEQ  : SOpInst<"vqdmlsl_laneq", "(>Q)(>Q).QI", "si", 
OP_QDMLSL_LN>;
+OP_QDMLALHi_LN> {
+  let isLaneQ = 1;
+}
+def VQDMLSL_LANEQ  : SOpInst<"vqdmlsl_la

[clang] d427116 - [ARM] Creating 'call_mangled' for Neon intrinsics definitions

2020-03-19 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2020-03-19T12:05:55Z
New Revision: d42711625af8188edb15c8ddad8c861fbca89c17

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

LOG: [ARM] Creating 'call_mangled' for Neon intrinsics definitions

Summary:
As multiple versions of the same Neon intrinsic can be created through
the same TableGen definition with the same argument types, the existing
`call` operator is not always able to properly perform overload
resolutions.

As these different intrinsic versions are differentiated later on by the
NeonEmitter through name mangling, this patch introduces a new
`call_mangled` operator to the TableGen definitions, which allows a call
for an otherwise ambiguous intrinsic by matching its mangled name with
the mangled variation of the caller.

Reviewers: jmolloy, t.p.northover, rsmith, olista01, dnsampaio

Reviewed By: dnsampaio

Subscribers: dnsampaio, kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon_incl.td
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon_incl.td 
b/clang/include/clang/Basic/arm_neon_incl.td
index 28b00d162a00..6313faf0fa30 100644
--- a/clang/include/clang/Basic/arm_neon_incl.td
+++ b/clang/include/clang/Basic/arm_neon_incl.td
@@ -60,6 +60,15 @@ def op;
 // example: (call "vget_high", $p0) -> "vgetq_high_s16(__p0)"
 //(assuming $p0 has type int16x8_t).
 def call;
+// call_mangled - Invoke another intrinsic matching the mangled name variation
+//of the caller's base type. If there is no intrinsic defined
+//that has the variation and takes the given types, an error
+//is generated at tblgen time.
+// example: (call_mangled "vfma_lane", $p0, $p1) -> "vfma_lane(__p0, __p1)"
+//(assuming non-LaneQ caller)
+//  (call_mangled "vfma_lane", $p0, $p1) -> "vfma_laneq(__p0, __p1)"
+//(assuming LaneQ caller)
+def call_mangled;
 // cast - Perform a cast to a 
diff erent type. This gets emitted as a static
 //C-style cast. For a pure reinterpret cast (T x = *(T*)&y), use
 //"bitcast".

diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 59ea15493f03..ea4060757a4f 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -27,8 +27,9 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
-#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
@@ -518,7 +519,8 @@ class Intrinsic {
 std::pair emitDagDupTyped(DagInit *DI);
 std::pair emitDagShuffle(DagInit *DI);
 std::pair emitDagCast(DagInit *DI, bool IsBitCast);
-std::pair emitDagCall(DagInit *DI);
+std::pair emitDagCall(DagInit *DI,
+ bool MatchMangledName);
 std::pair emitDagNameReplace(DagInit *DI);
 std::pair emitDagLiteral(DagInit *DI);
 std::pair emitDagOp(DagInit *DI);
@@ -546,7 +548,8 @@ class NeonEmitter {
 public:
   /// Called by Intrinsic - this attempts to get an intrinsic that takes
   /// the given types as arguments.
-  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types);
+  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types,
+  Optional MangledName);
 
   /// Called by Intrinsic - returns a globally-unique number.
   unsigned getUniqueNumber() { return UniqueNumber++; }
@@ -1383,8 +1386,8 @@ std::pair 
Intrinsic::DagEmitter::emitDag(DagInit *DI) {
 return emitDagSaveTemp(DI);
   if (Op == "op")
 return emitDagOp(DI);
-  if (Op == "call")
-return emitDagCall(DI);
+  if (Op == "call" || Op == "call_mangled")
+return emitDagCall(DI, Op == "call_mangled");
   if (Op == "name_replace")
 return emitDagNameReplace(DI);
   if (Op == "literal")
@@ -1411,7 +1414,8 @@ std::pair 
Intrinsic::DagEmitter::emitDagOp(DagInit *DI) {
   }
 }
 
-std::pair Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
+std::pair
+Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
   std::vector Types;
   std::vector Values;
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
@@ -1427,7 +1431,13 @@ std::pair 
Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
 N = SI->getAsUnquotedString();
   else
 N = emitDagArg(DI->getArg(0), "").second;
-  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types);
+  Optional MangledName;
+  if (MatchMangledName) {
+if (Intr.getRecord()->getValueAsBit("isLaneQ"))
+  

[clang] d4ad386 - [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane intrinsics

2020-03-19 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2020-03-19T12:08:12Z
New Revision: d4ad386ee1955ceb63fc616b3e30abb553e0685f

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

LOG: [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane 
intrinsics

Summary:
The range checks performed for the vqrdmulh_lane and vqrdmulh_lane Neon
intrinsics were incorrectly using their return type as the base type for
the range check performed on their 'lane' argument.

This patch updates those intrisics to use the type of the proper reference
argument to perform the range checks.

Reviewers: jmolloy, t.p.northover, rsmith, olista01, dnsampaio

Reviewed By: dnsampaio

Subscribers: dnsampaio, kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/arm-neon-range-checks.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 4490aad777dd..f949edc378fc 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -547,8 +547,8 @@ def VQDMULH_LANE  : SOpInst<"vqdmulh_lane", "..qI", 
"siQsQi", OP_QDMULH_LN>;
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
 let ArchGuard = "defined(__aarch64__)" in {
-def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..qI", "siQsQi">;
-def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..qI", "siQsQi">;
+def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
+def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d0ac4dd5b737..e42339dbcfcc 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5824,9 +5824,14 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   case NEON::BI__builtin_neon_vqdmulh_lane_v:
   case NEON::BI__builtin_neon_vqrdmulhq_lane_v:
   case NEON::BI__builtin_neon_vqrdmulh_lane_v: {
+llvm::Type *RTy = Ty;
+if (BuiltinID == NEON::BI__builtin_neon_vqdmulhq_lane_v ||
+BuiltinID == NEON::BI__builtin_neon_vqrdmulhq_lane_v)
+  RTy = llvm::VectorType::get(Ty->getVectorElementType(),
+  Ty->getVectorNumElements() * 2);
 llvm::Type *Tys[2] = {
-Ty, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
-/*isQuad*/ false))};
+RTy, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
+ /*isQuad*/ false))};
 return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, NameHint);
   }
   case NEON::BI__builtin_neon_vqdmulhq_laneq_v:

diff  --git a/clang/test/CodeGen/arm-neon-range-checks.c 
b/clang/test/CodeGen/arm-neon-range-checks.c
index 313bd07ff190..488dad6d59ac 100644
--- a/clang/test/CodeGen/arm-neon-range-checks.c
+++ b/clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@ void test_vqdmulh_lane(int32x2_t a, int32x2_t b) {
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside 
the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@ void test_vqrdmulh_lane(int32x2_t a, int32x2_t v) {
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}



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


[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-19 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Adding special test functions is not as easy, then `StreamState` should be 
accessible from another checker. It could be added to the same file, or new 
file but then moving the data structures into header is needed. At least for 
short-term it is more simple to add a stream function that generates error 
state (`fseek` is applicable or other). This is why the `fseek` patch is better 
to be included in this change (but makes it more complicated). Otherwise this 
revision must be added without tests for state observer functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D76367: [clang-format] Handle C# generic type constraints

2020-03-19 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 251349.
jbcoe added a comment.

Address review comments to move deleted test and remove redundant code.

Redundant call to `parseCSharpGenericTypeConstraint` was used for free 
functions which are not legal in C#.


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

https://reviews.llvm.org/D76367

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -628,7 +628,6 @@
   verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
   verifyFormat(R"(private float[,] Values;)", Style);
   verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
-  verifyFormat(R"(class ItemFactory where T : new() {})", Style);
 
   Style.SpacesInSquareBrackets = true;
   verifyFormat(R"(private float[ , ] Values;)", Style);
@@ -673,5 +672,22 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(//
+class ItemFactory
+where T : new() {})", Style);
+
+  verifyFormat(R"(//
+class Dictionary
+where TKey : IComparable
+where TVal : IMyInterface {
+  public void MyMethod(T t)
+  where T : IMyInterface { doThing(); }
+})",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -126,6 +126,10 @@
   void parseJavaScriptEs6ImportExport();
   void parseStatementMacro();
   void parseCSharpAttribute();
+  // Parse a C# generic type constraint: `where T : IComparable`.
+  // See:
+  // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/where-generic-type-constraint
+  void parseCSharpGenericTypeConstraint();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -323,6 +323,24 @@
   addUnwrappedLine();
 }
 
+void UnwrappedLineParser::parseCSharpGenericTypeConstraint() {
+  do {
+switch (FormatTok->Tok.getKind()) {
+case tok::l_brace:
+  return;
+default:
+  if (FormatTok->is(Keywords.kw_where)) {
+addUnwrappedLine();
+nextToken();
+parseCSharpGenericTypeConstraint();
+break;
+  }
+  nextToken();
+  break;
+}
+  } while (!eof());
+}
+
 void UnwrappedLineParser::parseCSharpAttribute() {
   int UnpairedSquareBrackets = 1;
   do {
@@ -1344,6 +1362,12 @@
   parseTryCatch();
   return;
 case tok::identifier: {
+  if (Style.isCSharp() && FormatTok->is(Keywords.kw_where) &&
+  Line->MustBeDeclaration) {
+addUnwrappedLine();
+parseCSharpGenericTypeConstraint();
+break;
+  }
   if (FormatTok->is(TT_MacroBlockEnd)) {
 addUnwrappedLine();
 return;
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -64,6 +64,8 @@
 }
 if (static_cast(Indent) + Offset >= 0)
   Indent += Offset;
+if (Line.First->is(TT_CSharpGenericTypeConstraint))
+  Indent = Line.Level * Style.IndentWidth + Style.ContinuationIndentWidth;
   }
 
   /// Update the indent state given that \p Line indent should be
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1047,6 +1047,11 @@
Keywords.kw___has_include_next)) {
 parseHasInclude();
   }
+  if (Tok->is(Keywords.kw_where) && Tok->Next &&
+  Tok->Next->isNot(tok::l_paren)) {
+Tok->Type = TT_CSharpGenericTypeConstraint;
+parseCSharpGenericTypeConstraint();
+  }
   break;
 default:
   break;
@@ -1054,6 +1059,30 @@
 return true;
   }
 
+  void parseCSharpGenericTypeConstraint() {
+while (CurrentToken) {
+  if (CurrentToken->is(tok::less)) {
+// parseAngle is too greedy and will consume the whole line.
+CurrentToken->Type = TT_TemplateOpener;
+next();
+  } else if (CurrentToken->is(tok::greater)) {
+CurrentToken->Type = TT_TemplateCloser;
+n

[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7467
+
+  return IsZxtReturn ? Builder.CreateZExt(Load, VectorTy)
+ : Builder.CreateSExt(Load, VectorTy);

sdesmalen wrote:
> SjoerdMeijer wrote:
> > nit: and now looking at this, this can be a zero or sign extend, so `Zxt` 
> > is slightly misleading?
> The default is sign-extend, so we added a flag for the case where a 
> zero-extend is needed/expected. Are you suggesting to rename the flag or to 
> add an extra flag for IsSxt?
I don't know to be honest, it was a nit anyway, but whatever you think is best. 
But just reading the name `IsZxtReturn`, I was only expecting a zero-extend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76238



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


[PATCH] D74766: [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane intrinsics

2020-03-19 Thread Lucas Prates via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4ad386ee195: [ARM] Fixing range checks for Neon's 
vqdmulhq_lane and vqrdmulhq_lane intrinsics (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74766

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-neon-range-checks.c


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside 
the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5824,9 +5824,14 @@
   case NEON::BI__builtin_neon_vqdmulh_lane_v:
   case NEON::BI__builtin_neon_vqrdmulhq_lane_v:
   case NEON::BI__builtin_neon_vqrdmulh_lane_v: {
+llvm::Type *RTy = Ty;
+if (BuiltinID == NEON::BI__builtin_neon_vqdmulhq_lane_v ||
+BuiltinID == NEON::BI__builtin_neon_vqrdmulhq_lane_v)
+  RTy = llvm::VectorType::get(Ty->getVectorElementType(),
+  Ty->getVectorNumElements() * 2);
 llvm::Type *Tys[2] = {
-Ty, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
-/*isQuad*/ false))};
+RTy, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
+ /*isQuad*/ false))};
 return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, NameHint);
   }
   case NEON::BI__builtin_neon_vqdmulhq_laneq_v:
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -547,8 +547,8 @@
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
 let ArchGuard = "defined(__aarch64__)" in {
-def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..qI", "siQsQi">;
-def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..qI", "siQsQi">;
+def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
+def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
Index: clang/lib/CodeGen/CGBuiltin.cpp

[PATCH] D76062: [PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support

2020-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Besides the irrelevant formatting nits, one minor question about the clang test.




Comment at: clang/test/Driver/aarch64-cpus.c:622
+
+// The BFloat16 extension is a mandatory component of the Armv8.6-A 
extensions, but is permitted as an
+// optional feature for any implementation of Armv8.2-A to Armv8.5-A 
(inclusive)

Do we need 2 additional tests here?
- one for v8.6,
- and another with SVE?





Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:7806
+  def v4f16 : BaseSIMDThreeSameVectorBFDot<0, U, asm, ".2s", ".4h", V64,
+ v2f32, v8i8>;
+  def v8f16 : BaseSIMDThreeSameVectorBFDot<1, U, asm, ".4s", ".8h", V128,

nit: indentation is a bit off here



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:7808
+  def v8f16 : BaseSIMDThreeSameVectorBFDot<1, U, asm, ".4s", ".8h", V128,
+ v4f32, v16i8>;
+}

here too



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:7812
+class BaseSIMDThreeSameVectorBF16DotI {
+

and this can be on the same line as above?



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:7867
+V128, asm, ".4s",
+  []> {
+  let AsmString = !strconcat(asm, "{\t$Rd", ".4s", ", $Rn", ".8h",

and perhaps this one. But looks intentional, perhaps it's fine then, I don't 
know.



Comment at: llvm/lib/Target/ARM/ARMInstrNEON.td:8936
+   N3RegFrm, IIC_VDOTPROD, "", "", []>
+{
+

on the same line as above?



Comment at: llvm/lib/Target/ARM/ARMInstrNEON.td:8937
+{
+
+let hasNoSchedulingInfo = 1;

no newline?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76062



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


[PATCH] D74618: [ARM] Creating 'call_mangled' for Neon intrinsics definitions

2020-03-19 Thread Lucas Prates via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd42711625af8: [ARM] Creating 'call_mangled' for 
Neon intrinsics definitions (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74618

Files:
  clang/include/clang/Basic/arm_neon_incl.td
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -27,8 +27,9 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
-#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
@@ -518,7 +519,8 @@
 std::pair emitDagDupTyped(DagInit *DI);
 std::pair emitDagShuffle(DagInit *DI);
 std::pair emitDagCast(DagInit *DI, bool IsBitCast);
-std::pair emitDagCall(DagInit *DI);
+std::pair emitDagCall(DagInit *DI,
+ bool MatchMangledName);
 std::pair emitDagNameReplace(DagInit *DI);
 std::pair emitDagLiteral(DagInit *DI);
 std::pair emitDagOp(DagInit *DI);
@@ -546,7 +548,8 @@
 public:
   /// Called by Intrinsic - this attempts to get an intrinsic that takes
   /// the given types as arguments.
-  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types);
+  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types,
+  Optional MangledName);
 
   /// Called by Intrinsic - returns a globally-unique number.
   unsigned getUniqueNumber() { return UniqueNumber++; }
@@ -1383,8 +1386,8 @@
 return emitDagSaveTemp(DI);
   if (Op == "op")
 return emitDagOp(DI);
-  if (Op == "call")
-return emitDagCall(DI);
+  if (Op == "call" || Op == "call_mangled")
+return emitDagCall(DI, Op == "call_mangled");
   if (Op == "name_replace")
 return emitDagNameReplace(DI);
   if (Op == "literal")
@@ -1411,7 +1414,8 @@
   }
 }
 
-std::pair Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
+std::pair
+Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
   std::vector Types;
   std::vector Values;
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
@@ -1427,7 +1431,13 @@
 N = SI->getAsUnquotedString();
   else
 N = emitDagArg(DI->getArg(0), "").second;
-  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types);
+  Optional MangledName;
+  if (MatchMangledName) {
+if (Intr.getRecord()->getValueAsBit("isLaneQ"))
+  N += "q";
+MangledName = Intr.mangleName(N, ClassS);
+  }
+  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types, MangledName);
 
   // Make sure the callee is known as an early def.
   Callee.setNeededEarly();
@@ -1832,7 +1842,8 @@
 // NeonEmitter implementation
 //===--===//
 
-Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types) {
+Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types,
+ Optional MangledName) {
   // First, look up the name in the intrinsic map.
   assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(),
   ("Intrinsic '" + Name + "' not found!").str());
@@ -1861,17 +1872,19 @@
 }
 ErrMsg += ")\n";
 
+if (MangledName && MangledName != I.getMangledName(true))
+  continue;
+
 if (I.getNumParams() != Types.size())
   continue;
 
-bool Good = true;
-for (unsigned Arg = 0; Arg < Types.size(); ++Arg) {
-  if (I.getParamType(Arg) != Types[Arg]) {
-Good = false;
-break;
-  }
-}
-if (Good)
+unsigned ArgNum = 0;
+bool MatchingArgumentTypes =
+std::all_of(Types.begin(), Types.end(), [&](const auto &Type) {
+  return Type == I.getParamType(ArgNum++);
+});
+
+if (MatchingArgumentTypes)
   GoodVec.push_back(&I);
   }
 
Index: clang/include/clang/Basic/arm_neon_incl.td
===
--- clang/include/clang/Basic/arm_neon_incl.td
+++ clang/include/clang/Basic/arm_neon_incl.td
@@ -60,6 +60,15 @@
 // example: (call "vget_high", $p0) -> "vgetq_high_s16(__p0)"
 //(assuming $p0 has type int16x8_t).
 def call;
+// call_mangled - Invoke another intrinsic matching the mangled name variation
+//of the caller's base type. If there is no intrinsic defined
+//that has the variation and takes the given types, an error
+//is generated at tblgen time.
+// example: (call_mangled "vfma_lane", $p0, $p1) -> "vfma_lane(__p0, __p1)"
+//(assuming non-LaneQ caller)
+//  (call_mangled "vfma_lane", $p0, $p1) -> "vfma_laneq(__p0, __

[PATCH] D74616: [ARM] Setting missing isLaneQ attribute on Neon Intrisics definitions

2020-03-19 Thread Lucas Prates via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdade859b5882: [ARM] Setting missing isLaneQ attribute on 
Neon Intrisics definitions (authored by pratlucas).
Herald added a subscriber: danielkiss.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74616

Files:
  clang/include/clang/Basic/arm_neon.td

Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -881,16 +881,22 @@
 def COPYQ_LANE : IOpInst<"vcopy_lane", "..IqI",
 "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN>;
 def COPY_LANEQ : IOpInst<"vcopy_laneq", "..IQI",
- "csilPcPsPlUcUsUiUlfd", OP_COPY_LN>;
+ "csilPcPsPlUcUsUiUlfd", OP_COPY_LN> {
+  let isLaneQ = 1;
+}
 def COPYQ_LANEQ : IOpInst<"vcopy_laneq", "..I.I",
- "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN>;
+ "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN> {
+  let isLaneQ = 1;
+}
 
 
 // Set all lanes to same value
 def VDUP_LANE1: WOpInst<"vdup_lane", ".qI", "hdQhQdPlQPl", OP_DUP_LN>;
 def VDUP_LANE2: WOpInst<"vdup_laneq", ".QI",
   "csilUcUsUiUlPcPshfdQcQsQiQlQPcQPsQUcQUsQUiQUlQhQfQdPlQPl",
-OP_DUP_LN>;
+OP_DUP_LN> {
+  let isLaneQ = 1;
+}
 def DUP_N   : WOpInst<"vdup_n", ".1", "dQdPlQPl", OP_DUP>;
 def MOV_N   : WOpInst<"vmov_n", ".1", "dQdPlQPl", OP_DUP>;
 
@@ -906,38 +912,60 @@
 
 
 def VMLA_LANEQ   : IOpInst<"vmla_laneq", "...QI",
-   "siUsUifQsQiQUsQUiQf", OP_MLA_LN>;
+   "siUsUifQsQiQUsQUiQf", OP_MLA_LN> {
+  let isLaneQ = 1;
+}
 def VMLS_LANEQ   : IOpInst<"vmls_laneq", "...QI",
-   "siUsUifQsQiQUsQUiQf", OP_MLS_LN>;
+   "siUsUifQsQiQUsQUiQf", OP_MLS_LN> {
+  let isLaneQ = 1;
+}
 
 def VFMA_LANE: IInst<"vfma_lane", "...qI", "fdQfQd">;
 def VFMA_LANEQ   : IInst<"vfma_laneq", "...QI", "fdQfQd"> {
   let isLaneQ = 1;
 }
 def VFMS_LANE: IOpInst<"vfms_lane", "...qI", "fdQfQd", OP_FMS_LN>;
-def VFMS_LANEQ   : IOpInst<"vfms_laneq", "...QI", "fdQfQd", OP_FMS_LNQ>;
+def VFMS_LANEQ   : IOpInst<"vfms_laneq", "...QI", "fdQfQd", OP_FMS_LNQ> {
+  let isLaneQ = 1;
+}
 
-def VMLAL_LANEQ  : SOpInst<"vmlal_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLAL_LN>;
+def VMLAL_LANEQ  : SOpInst<"vmlal_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLAL_LN> {
+  let isLaneQ = 1;
+}
 def VMLAL_HIGH_LANE   : SOpInst<"vmlal_high_lane", "(>Q)(>Q)Q.I", "siUsUi",
 OP_MLALHi_LN>;
 def VMLAL_HIGH_LANEQ  : SOpInst<"vmlal_high_laneq", "(>Q)(>Q)QQI", "siUsUi",
-OP_MLALHi_LN>;
-def VMLSL_LANEQ  : SOpInst<"vmlsl_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLSL_LN>;
+OP_MLALHi_LN> {
+  let isLaneQ = 1;
+}
+def VMLSL_LANEQ  : SOpInst<"vmlsl_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLSL_LN> {
+  let isLaneQ = 1;
+}
 def VMLSL_HIGH_LANE   : SOpInst<"vmlsl_high_lane", "(>Q)(>Q)Q.I", "siUsUi",
 OP_MLSLHi_LN>;
 def VMLSL_HIGH_LANEQ  : SOpInst<"vmlsl_high_laneq", "(>Q)(>Q)QQI", "siUsUi",
-OP_MLSLHi_LN>;
+OP_MLSLHi_LN> {
+  let isLaneQ = 1;
+}
 
-def VQDMLAL_LANEQ  : SOpInst<"vqdmlal_laneq", "(>Q)(>Q).QI", "si", OP_QDMLAL_LN>;
+def VQDMLAL_LANEQ  : SOpInst<"vqdmlal_laneq", "(>Q)(>Q).QI", "si", OP_QDMLAL_LN> {
+  let isLaneQ = 1;
+}
 def VQDMLAL_HIGH_LANE   : SOpInst<"vqdmlal_high_lane", "(>Q)(>Q)Q.I", "si",
 OP_QDMLALHi_LN>;
 def VQDMLAL_HIGH_LANEQ  : SOpInst<"vqdmlal_high_laneq", "(>Q)(>Q)QQI", "si",
-OP_QDMLALHi_LN>;
-def VQDMLSL_LANEQ  : SOpInst<"vqdmlsl_laneq", "(>Q)(>Q).QI", "si", OP_QDMLSL_LN>;
+OP_QDMLALHi_LN> {
+  let isLaneQ = 1;
+}
+def VQDMLSL_LANEQ  : SOpInst<"vqdmlsl_laneq", "(>Q)(>Q).QI", "si", OP_QDMLSL_LN> {
+  let isLaneQ = 1;
+}
 def VQDMLSL_HIGH_LANE   : SOpInst<"vqdmlsl_high_lane", "(>Q)(>Q)Q.I", "si",
 OP_QDMLSLHi_LN>;
 def VQDMLSL_HIGH_LANEQ  : SOpInst<"vqdmlsl_high_laneq", "(>Q)(>Q)QQI", "si",
-OP_QDMLSLHi_LN>;
+OP_QDMLSLHi_LN> {
+  let isLaneQ = 1;
+}
 
 // Newly add double parameter for vmul_lane in aarch64
 // Note: d type is handled by SCALAR_VMUL_LANE
@@ -945,32 +973,48 @@
 
 // Note: d type is handled by SCALAR_VMUL_LANEQ
 def VMUL_LANEQ   : IOpInst<"vmul_laneq", "..QI",
-   "sifUsUiQsQiQUsQUiQfQd", OP_MUL_LN>;
-def VMULL_LANEQ  : SOpInst<"vmu

RE: [PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-03-19 Thread Narayanaswamy, Ravi via cfe-commits
If it Is not updated can you update the OpenMP feature tracking doc. 
https://clang.llvm.org/docs/OpenMPSupport.html
Thanks
Ravi

-Original Message-
From: Michael Kruse via Phabricator  
Sent: Tuesday, March 17, 2020 8:34 PM
To: a.bat...@hotmail.com; jdoerf...@anl.gov; hfin...@anl.gov; Wilmarth, Terry L 
; Bae, Hansang ; 
protze.joac...@gmail.com; Churbanov, Andrey ; 
Narayanaswamy, Ravi ; 
jonathanchesterfi...@gmail.com; Rokos, Georgios 
Cc: jholewin...@nvidia.com; zhang.guans...@gmail.com; arpha...@gmail.com; 
cfe-commits@lists.llvm.org; p8u8i7l5t1q9r...@ibm-systems-z.slack.com; 
1.in...@gmail.com
Subject: [PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

Meinersbur created this revision.
Meinersbur added reviewers: ABataev, jdoerfert, hfinkel, tlwilmar, hbae, 
protze.joachim, AndreyChurbanov, RaviNarayanaswamy, JonChesterfield, grokos.
Herald added subscribers: arphaman, guansong, hiraditya, jholewinski.

The tile directive is in OpenMP's Technical Report 8 and foreseeably will be 
part of the upcoming OpenMP 5.1 standard.

This implementation is based on an AST transformation providing a de-sugared 
loop nest. This makes it simple to forward the de-sugared transformation to 
loop associated directives taking the tiled loops. In contrast to other loop 
associated directives, the OMPTileDirective does not use CapturedStmts. Letting 
loop associated directives consume loops from different capture context would 
be difficult.

A significant amount of code generation logic is taking place in the Sema 
class. Eventually, I would prefer if these would move into the CodeGen 
component such that we could make use of the OpenMPIRBuilder, together with 
flang. Only expressions converting between the language's iteration variable 
and the logical iteration space need to take place in the semantic analyzer: 
Getting the of iterations (e.g. the overload resolution of `std::distance`) and 
converting the logical iteration number to the iteration variable (e.g. 
overload resolution of `iteration + .omp.iv`). In clang, only CXXForRangeStmt 
is also represented by its de-sugared components. However, OpenMP loop are not 
defined as syntatic sugar. Starting with an AST-based approach allows us to 
gradually move generated AST statements into CodeGen, instead all at once.

I would also like to refactor `checkOpenMPLoop` into its functionalities in a 
follow-up. In this patch it is used twice. Once for checking proper nesting and 
emitting diagnostics, and additionally for deriving the logical iteration space 
per-loop (instead of for the loop nest).


Repository:
  rC Clang

https://reviews.llvm.org/D76342

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Index/openmp-tile.c
  clang/test/OpenMP/tile_ast_print.cpp
  clang/test/OpenMP/tile_codegen.cpp
  clang/test/OpenMP/tile_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Analysis/DependenceGraphBuilder.cpp

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


[PATCH] D76367: [clang-format] Handle C# generic type constraints

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

Thank you!


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

https://reviews.llvm.org/D76367



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


[clang] dcbcec4 - [clang-format] Handle C# generic type constraints

2020-03-19 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-19T12:56:08Z
New Revision: dcbcec4822f47ec5b638dd9c20dcebd464569dae

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

LOG: [clang-format] Handle C# generic type constraints

Summary:
Treat each C# generic type constraint, `where T: ...`, as a line.

Add C# keyword: where

Add Token Types: CSharpGenericTypeConstraint, CSharpGenericTypeConstraintColon, 
CSharpGenericTypeConstraintComma.

This patch does not wrap generic type constraints well, that will be addressed 
in a follow up patch.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 1b885b518f0d..10a5f0e96f96 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -108,6 +108,9 @@ namespace format {
   TYPE(CSharpNullCoalescing)   
\
   TYPE(CSharpNullConditional)  
\
   TYPE(CSharpNullConditionalLSquare)   
\
+  TYPE(CSharpGenericTypeConstraint)
\
+  TYPE(CSharpGenericTypeConstraintColon)   
\
+  TYPE(CSharpGenericTypeConstraintComma)   
\
   TYPE(Unknown)
 
 enum TokenType {
@@ -779,6 +782,7 @@ struct AdditionalKeywords {
 kw_unsafe = &IdentTable.get("unsafe");
 kw_ushort = &IdentTable.get("ushort");
 kw_when = &IdentTable.get("when");
+kw_where = &IdentTable.get("where");
 
 // Keep this at the end of the constructor to make sure everything here
 // is
@@ -796,6 +800,7 @@ struct AdditionalKeywords {
  kw_is, kw_lock, kw_null, kw_object, kw_out, kw_override, kw_params,
  kw_readonly, kw_ref, kw_string, kw_stackalloc, kw_sbyte, kw_sealed,
  kw_uint, kw_ulong, kw_unchecked, kw_unsafe, kw_ushort, kw_when,
+ kw_where,
  // Keywords from the JavaScript section.
  kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,
  kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly,
@@ -900,6 +905,7 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_unsafe;
   IdentifierInfo *kw_ushort;
   IdentifierInfo *kw_when;
+  IdentifierInfo *kw_where;
 
   /// Returns \c true if \p Tok is a true JavaScript identifier, returns
   /// \c false if it is a keyword or a pseudo keyword.

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d546a9f7c606..7193c8e6de44 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1047,6 +1047,11 @@ class AnnotatingParser {
Keywords.kw___has_include_next)) {
 parseHasInclude();
   }
+  if (Tok->is(Keywords.kw_where) && Tok->Next &&
+  Tok->Next->isNot(tok::l_paren)) {
+Tok->Type = TT_CSharpGenericTypeConstraint;
+parseCSharpGenericTypeConstraint();
+  }
   break;
 default:
   break;
@@ -1054,6 +1059,30 @@ class AnnotatingParser {
 return true;
   }
 
+  void parseCSharpGenericTypeConstraint() {
+while (CurrentToken) {
+  if (CurrentToken->is(tok::less)) {
+// parseAngle is too greedy and will consume the whole line.
+CurrentToken->Type = TT_TemplateOpener;
+next();
+  } else if (CurrentToken->is(tok::greater)) {
+CurrentToken->Type = TT_TemplateCloser;
+next();
+  } else if (CurrentToken->is(tok::comma)) {
+CurrentToken->Type = TT_CSharpGenericTypeConstraintComma;
+next();
+  } else if (CurrentToken->is(Keywords.kw_where)) {
+CurrentToken->Type = TT_CSharpGenericTypeConstraint;
+next();
+  } else if (CurrentToken->is(tok::colon)) {
+CurrentToken->Type = TT_CSharpGenericTypeConstraintColon;
+next();
+  } else {
+next();
+  }
+}
+  }
+
   void parseIncludeDirective() {
 if (CurrentToken && CurrentToken->is(tok::less)) {
   next();
@@ -3299,6 +3328,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
 if (Right.is(TT_CSharpNamedArgumentColon) ||
 Left.is(TT_CSharpNamedArgumentColon))
   return false;
+if (Right.is(TT_CSharpGenericTypeConstraint))
+  return true;
   } else if (Sty

[clang] d9b9621 - Reland D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-19 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-03-19T13:57:30+01:00
New Revision: d9b962100942c71a4c26debaa716f7ab0c4ea8a1

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

LOG: Reland D73534: [DebugInfo] Enable the debug entry values feature by default

The issue that was causing the build failures was fixed with the D76164.

Added: 
llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/DebugInfo/AArch64/dbgcall-site-float-entry-value.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovd.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovs.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/callsite-stack-value.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86/loclists-dwp.ll
llvm/test/tools/llvm-locstats/locstats.ll

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 3c8b0eeb47a5..e047054447f3 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -63,7 +63,6 @@ CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the 
new, experimental
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
-CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs

diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index b7a2826d8fcb..cc30893703df 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -388,8 +388,6 @@ def flto_visibility_public_std:
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
-def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
-HelpText<"Enables debug info about call site parameter's

[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-03-19 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.

LGTM, thanks Simon!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73891



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


[PATCH] D76367: [clang-format] Handle C# generic type constraints

2020-03-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcbcec4822f4: [clang-format] Handle C# generic type 
constraints (authored by Jonathan Coe ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76367

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -628,7 +628,6 @@
   verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
   verifyFormat(R"(private float[,] Values;)", Style);
   verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
-  verifyFormat(R"(class ItemFactory where T : new() {})", Style);
 
   Style.SpacesInSquareBrackets = true;
   verifyFormat(R"(private float[ , ] Values;)", Style);
@@ -673,5 +672,22 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(//
+class ItemFactory
+where T : new() {})", Style);
+
+  verifyFormat(R"(//
+class Dictionary
+where TKey : IComparable
+where TVal : IMyInterface {
+  public void MyMethod(T t)
+  where T : IMyInterface { doThing(); }
+})",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -126,6 +126,10 @@
   void parseJavaScriptEs6ImportExport();
   void parseStatementMacro();
   void parseCSharpAttribute();
+  // Parse a C# generic type constraint: `where T : IComparable`.
+  // See:
+  // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/where-generic-type-constraint
+  void parseCSharpGenericTypeConstraint();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -323,6 +323,24 @@
   addUnwrappedLine();
 }
 
+void UnwrappedLineParser::parseCSharpGenericTypeConstraint() {
+  do {
+switch (FormatTok->Tok.getKind()) {
+case tok::l_brace:
+  return;
+default:
+  if (FormatTok->is(Keywords.kw_where)) {
+addUnwrappedLine();
+nextToken();
+parseCSharpGenericTypeConstraint();
+break;
+  }
+  nextToken();
+  break;
+}
+  } while (!eof());
+}
+
 void UnwrappedLineParser::parseCSharpAttribute() {
   int UnpairedSquareBrackets = 1;
   do {
@@ -1344,6 +1362,12 @@
   parseTryCatch();
   return;
 case tok::identifier: {
+  if (Style.isCSharp() && FormatTok->is(Keywords.kw_where) &&
+  Line->MustBeDeclaration) {
+addUnwrappedLine();
+parseCSharpGenericTypeConstraint();
+break;
+  }
   if (FormatTok->is(TT_MacroBlockEnd)) {
 addUnwrappedLine();
 return;
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -64,6 +64,8 @@
 }
 if (static_cast(Indent) + Offset >= 0)
   Indent += Offset;
+if (Line.First->is(TT_CSharpGenericTypeConstraint))
+  Indent = Line.Level * Style.IndentWidth + Style.ContinuationIndentWidth;
   }
 
   /// Update the indent state given that \p Line indent should be
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1047,6 +1047,11 @@
Keywords.kw___has_include_next)) {
 parseHasInclude();
   }
+  if (Tok->is(Keywords.kw_where) && Tok->Next &&
+  Tok->Next->isNot(tok::l_paren)) {
+Tok->Type = TT_CSharpGenericTypeConstraint;
+parseCSharpGenericTypeConstraint();
+  }
   break;
 default:
   break;
@@ -1054,6 +1059,30 @@
 return true;
   }
 
+  void parseCSharpGenericTypeConstraint() {
+while (CurrentToken) {
+  if (CurrentToken->is(tok::less)) {
+// parseAngle is too greedy and will consume the whole line.
+CurrentToken->Type = TT_TemplateOpener;
+next();
+  } else if (CurrentToken->is(tok::greater)) {
+CurrentToken->Type = TT_TemplateCloser;
+next();

[PATCH] D76424: [AST] Use TypeDependence bitfield to calculate dependence on Types. NFC

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/include/clang/AST/Type.h:2882
-  Pointee->isInstantiationDependentType()),
- Pointee->isVariablyModifiedType(),
- (Cls->containsUnexpandedParameterPack() ||

we have behavior change for VariableModified bit, now it is `Cls|Pointee` vs 
`Pointee` before



Comment at: clang/include/clang/AST/TypeProperties.td:457
+if (dependent)
+  
const_cast(result.getTypePtr())->addDependence(TypeDependence::DependentInstantiation);
 return result;

nit: the line length seems > 80 columns.



Comment at: clang/lib/AST/Type.cpp:3036
 
-if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
-epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())

when converting an ExprDep to TypeDep, we simply drop the value-dependent bit, 
so here we will not set the instantiation-bit for typeDep if  NoexceptExpr is 
value dependent but not instantiation-dependent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76424



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


[PATCH] D76429: [clangd] Fix elog message when preamble build fails.

2020-03-19 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
sammccall accepted this revision.
This revision is now accepted and ready to land.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76429

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


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -162,7 +162,7 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {2}", FileName,
+elog("Could not build a preamble for file {0} version {1}", FileName,
  Inputs.Version);
 return nullptr;
   }


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -162,7 +162,7 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {2}", FileName,
+elog("Could not build a preamble for file {0} version {1}", FileName,
  Inputs.Version);
 return nullptr;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-19 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Thanks Shiva, making it alias of -G makes sense, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[clang-tools-extra] 55b92dc - [clangd] Fix elog message when preamble build fails.

2020-03-19 Thread Sam McCall via cfe-commits

Author: Adam Czachorowski
Date: 2020-03-19T15:09:46+01:00
New Revision: 55b92dcb35a0758bea294ab6e42f9954ac06cac3

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

LOG: [clangd] Fix elog message when preamble build fails.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Preamble.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index bd92b8c1bdb4..fdee71fd2244 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -162,7 +162,7 @@ buildPreamble(PathRef FileName, CompilerInvocation &CI,
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {2}", FileName,
+elog("Could not build a preamble for file {0} version {1}", FileName,
  Inputs.Version);
 return nullptr;
   }



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


[clang] cf1f8f9 - [OPENMP][DOCS]Update list of constructs and status, NFC.

2020-03-19 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-19T10:20:29-04:00
New Revision: cf1f8f9bec220fcbefe0cff835ab9f8c6291cfc6

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

LOG: [OPENMP][DOCS]Update list of constructs and status, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 66ce6eda9c8c..ecdf73871833 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -131,7 +131,7 @@ implementation.
 
+--+--+--+---+
 | loop extension   | clause: if for SIMD directives
   | :good:`done` | 
  |
 
+--+--+--+---+
-| loop extension   | inclusive scan extension (matching C++17 
PSTL)   | :none:`unclaimed`|
   |
+| loop extension   | inclusive scan extension (matching C++17 
PSTL)   | :none:`claimed`  |
   |
 
+--+--+--+---+
 | memory mangagement   | memory allocators 
   | :good:`done` | r341687,r357929 
  |
 
+--+--+--+---+
@@ -179,6 +179,10 @@ implementation.
 
+--+--+--+---+
 | device extension | clause: device_type   
   | :good:`done` | 
  |
 
+--+--+--+---+
+| device extension | clause: extended device   
   | :good:`done` | 
   |
++--+--+--+---+
+| device extension | clause: uses_allocators clause
   | :none:`claimed`  | 
   |
++--+--+--+---+
 | device extension | clause: in_reduction  
   | :part:`worked on`| r308768 
  |
 
+--+--+--+---+
 | device extension | omp_get_device_num()  
   | :part:`worked on`| D54342  
  |



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


[PATCH] D76094: [clangd] Change line break behaviour for hoverinfo

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this fits in a lot better!
I think there's some more details that could be handled, e.g. if a line is much 
shorter than the max line length, then that probably implies it's a "real" 
break. But if we get the code structure right, these should be easy to plug in 
later.

> Because the current implementation of markup::Paragraph only appends a single 
> white space after it's contents. I think this is semantically wrong because 
> in natural language aswell as markup languages like md, html, ... a paragraph 
> should be followed by a blank line

Yeah, we can look at this again, but we shouldn't do so in this patch. You're 
right on the semantics, but real implementations (particularly VSCode) use a 
distasteful amount of whitespace around HTML paragraphs vs other UI elements 
and don't give us any control over the CSS. (Similarly rendering paragraph 
breaks as `\n\n` in plaintext feels much too heavyweight in terminal-based 
editors in my experience)

BTW, it's really useful to upload diffs with full file context, I think -U9 
will do this, though I tend to use `arc diff` which always includes it.




Comment at: clang-tools-extra/clangd/Hover.cpp:524
+
+// Parses in documentation comments and tries to preserve the markup in the
+// comment.

I think we're going to end up using this elsewhere, e.g. in code completion.
Fine to keep it in Hover for now, but please expose it from hover.h and test it 
directly (rather than via HoverInfo::present())

This will also allow moving this implementation to the end of the file, rather 
than interleaving it with unrelated parts of hover logic.



Comment at: clang-tools-extra/clangd/Hover.cpp:527
+// Currently only linebreaks are handled.
+void parseDocumentation(std::string Input, markup::Document &Output) {
+

nit: input should be StringRef since you never mutate it



Comment at: clang-tools-extra/clangd/Hover.cpp:529
+
+  auto IsParagraphLineBreak = [](llvm::StringRef Str, size_t LineBreakIndex) {
+if (LineBreakIndex + 1 >= Str.size()) {

nit: we'd generally use static/anon-namespace functions rather than lambdas for 
helpers when we don't need to capture much stuff.



Comment at: clang-tools-extra/clangd/Hover.cpp:583
+
+  for (size_t CharIndex = 0; CharIndex < TrimmedInput.size();) {
+if (TrimmedInput[CharIndex] == '\n') {

I think this could be easier to read by separating the strategy from some of 
the details.

From my reading of the code, the strategy is:
 - examine the raw lines from the input to determine where true paragraph 
breaks occur. (In general, based on the end of the previous line and the start 
of the new line)
 - form each groups of raw lines into a paragraph (by trimming whitespace and 
`\`, dropping blank lines, and joining the results with spaces)

Given this, I think we could extract a couple of functions like:
 - `bool breakBetween(StringRef Before, StringRef After)`
 - `std::string joinRawLines(ArrayRef)`

and the outer loop becomes simpler, like:
```
SmallVector RawLines;
llvm::SplitString(Input, RawLines, "\n");
ArrayRef Remaining = RawLines;
while (!Remaining.empty()) {
  int Para = 1;
  while (Para < Remaining.size() && !breakBetween(Remaining[Para-1], 
Remaining[Para]))
Para++;
  std::string ParaText = joinRawLines(Remaining.take_front(Para));
  if (!ParaText.empty())
Output.addParagraph().appendText(std::move(ParaText));
  Remaining = Remaining.drop_front(Para);
}
```

I think this signature for `breakBetween` in terms of stringrefs would result 
in the lambdas you have here being a bit more readable, and the main is clearer 
for not dealing directly with string, whitespace, etc.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1886
 
+TEST(Hover, LineBreakConversionDocs) {
+  struct Case {

@kadircet this feels like a case where having a debug output mode like 
`[Para:foo][Para:bar]` would be useful!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76094



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


[PATCH] D76429: [clangd] Fix elog message when preamble build fails.

2020-03-19 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG55b92dcb35a0: [clangd] Fix elog message when preamble build 
fails. (authored by adamcz, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76429

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


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -162,7 +162,7 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {2}", FileName,
+elog("Could not build a preamble for file {0} version {1}", FileName,
  Inputs.Version);
 return nullptr;
   }


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -162,7 +162,7 @@
 SerializedDeclsCollector.takeMacros(), std::move(StatCache),
 SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-elog("Could not build a preamble for file {0} version {2}", FileName,
+elog("Could not build a preamble for file {0} version {1}", FileName,
  Inputs.Version);
 return nullptr;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Re-enabled with the d9b962100942 
.

If we face a failure again, since this enables the whole feature, I recommend 
reverting smaller pieces of the feature that was causing the problem, rather 
than reverting this patch.


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

https://reviews.llvm.org/D73534



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


[clang] 5d67fb3 - [AST][NFCi] Make CXXBasePaths::Origin const

2020-03-19 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-03-19T07:54:05-07:00
New Revision: 5d67fb3eccc7884e52d5252379456b87b14ce58b

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

LOG: [AST][NFCi] Make CXXBasePaths::Origin const

Added: 


Modified: 
clang/include/clang/AST/CXXInheritance.h

Removed: 




diff  --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index f223c1f2f4f0..8b1bcb367b3b 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -119,7 +119,7 @@ class CXXBasePaths {
   friend class CXXRecordDecl;
 
   /// The type from which this search originated.
-  CXXRecordDecl *Origin = nullptr;
+  const CXXRecordDecl *Origin = nullptr;
 
   /// Paths - The actual set of paths that can be taken from the
   /// derived class to the same base class.
@@ -225,8 +225,8 @@ class CXXBasePaths {
 
   /// Retrieve the type from which this base-paths search
   /// began
-  CXXRecordDecl *getOrigin() const { return Origin; }
-  void setOrigin(CXXRecordDecl *Rec) { Origin = Rec; }
+  const CXXRecordDecl *getOrigin() const { return Origin; }
+  void setOrigin(const CXXRecordDecl *Rec) { Origin = Rec; }
 
   /// Clear the base-paths results.
   void clear();



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


[PATCH] D65592: [Parser] Avoid spurious 'missing template' error in presence of typos

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 251379.
hokein added a comment.

address review comments, remove the overload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65592

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/SemaTemplate/dependent-typos-recovery.cpp

Index: clang/test/SemaTemplate/dependent-typos-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/dependent-typos-recovery.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'template' keywords.
+struct B {
+  template 
+  int f(){};
+} builder;// expected-note 2{{'builder' declared here}}
+
+auto a = bilder.f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
+auto b = (*(&bilder+0)).f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1605,7 +1605,9 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus &&
-  ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+ /*ObjectHadErrors=*/false,
+ EnteringContext))
 return ANK_Error;
 
   if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
@@ -1842,6 +1844,7 @@
 SourceLocation TypenameLoc = ConsumeToken();
 CXXScopeSpec SS;
 if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+   /*ObjectHadErrors=*/false,
/*EnteringContext=*/false, nullptr,
/*IsTypename*/ true))
   return true;
@@ -1914,7 +1917,9 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus)
-if (ParseOptionalCXXScopeSpecifier(SS, nullptr, /*EnteringContext*/false))
+if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+   /*ObjectHadErrors=*/false,
+   /*EnteringContext*/ false))
   return true;
 
   return TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation);
@@ -2043,7 +2048,9 @@
   assert(MightBeCXXScopeToken() && "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+ /*ObjectHadErrors=*/false,
+ EnteringContext))
 return true;
   if (SS.isEmpty())
 return false;
@@ -2152,7 +2159,8 @@
 
   // Parse nested-name-specifier.
   if (getLangOpts().CPlusPlus)
-ParseOptionalCXXScopeSpecifier(Result.SS, nullptr,
+ParseOptionalCXXScopeSpecifier(Result.SS, /*ObjectType=*/nullptr,
+   /*ObjectHadErrors=*/false,
/*EnteringContext=*/false);
 
   // Check nested-name specifier.
@@ -2163,10 +2171,12 @@
 
   // Parse the unqualified-id.
   SourceLocation TemplateKWLoc; // FIXME: parsed, but unused.
-  if (ParseUnqualifiedId(
-  Result.SS, /*EnteringContext*/false, /*AllowDestructorName*/true,
-  /*AllowConstructorName*/true, /*AllowDeductionGuide*/false, nullptr,
-  &TemplateKWLoc, Result.Name)) {
+  if (ParseUnqualifiedId(Result.SS, /*ObjectType=*/nullptr,
+ /*ObjectHadErrors=*/false, /*EnteringContext*/ false,
+ /*AllowDestructorName*/ true,
+ /*AllowConstructorName*/ true,
+ /*AllowDeductionGuide*/ false, &TemplateKWLoc,
+ Result.Name)) {
 T.skipToEnd();
 return true;
   }
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -363,9 +363,11 @@
   DiagnoseAndSkipCXX11Attributes();
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
-  /*EnteringContext=*/false, /*MayBePseudoDestructor=*/nullptr,
-  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
+  if (ParseOptionalCXXScopeSpecifier(
+  SS, /*ObjectType=*/nullptr,
+  /*ObjectHadErrors=*/false, /*EnteringContext=*/false,
+  /*MayBePseudoDestructor=*/nullptr,
+  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
   SS.i

[clang] 6cff2e9 - [Analyzer] Bugfix for CheckerRegistry

2020-03-19 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-03-19T16:06:42+01:00
New Revision: 6cff2e9f7884690d480b961f78806cbb91773b34

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

LOG: [Analyzer] Bugfix for CheckerRegistry

`CheckerRegistry` registers a checker either if it is excplicitly
enabled or it is a dependency of an explicitly enabled checker and is
not explicitly disabled. In both cases it is also important that the
checker should be registered (`shoudRegister`//XXX//`()` returns true).

Currently there is a bug here: if the dependenct checker is not
explicitly disabled it is registered regardless of whether it should
be registered. This patch fixes this bug.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h 
b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
index 8f0c7edc58b4..8830542f27d8 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -167,7 +167,7 @@ class CheckerRegistry {
 }
 
 bool isDisabled(const LangOptions &LO) const {
-  return State == StateFromCmdLine::State_Disabled && ShouldRegister(LO);
+  return State == StateFromCmdLine::State_Disabled || !ShouldRegister(LO);
 }
 
 // Since each checker must have a 
diff erent full name, we can identify

diff  --git a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp 
b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
index d0cf291eb2b8..8027d3338b69 100644
--- a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -81,6 +81,66 @@ TEST(RegisterCustomCheckers, CheckLocationIncDec) {
   runCheckerOnCode("void f() { int *p; (*p)++; }"));
 }
 
+//===--===//
+// Unsatisfied checker dependency
+//===--===//
+
+class PrerequisiteChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,
+   "This is the prerequisite checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerPrerequisiteChecker(CheckerManager &mgr) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterPrerequisiteChecker(const LangOptions &LO) {
+  return false;
+}
+
+class DependentChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Dependent", categories::LogicError,
+   "This is the Dependent Checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerDependentChecker(CheckerManager &mgr) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterDependentChecker(const LangOptions &LO) {
+  return true;
+}
+
+void addDependentChecker(AnalysisASTConsumer &AnalysisConsumer,
+ AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"custom.Dependent", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+ Registry.addChecker(registerPrerequisiteChecker,
+ shouldRegisterPrerequisiteChecker,
+ "custom.Prerequisite", "Description", "", false);
+ Registry.addChecker(registerDependentChecker,
+ shouldRegisterDependentChecker,
+ "custom.Dependent", "Description", "", false);
+ Registry.addDependency("custom.Dependent", "custom.Prerequisite");
+});
+}
+
+TEST(RegisterDependentCheckers, RegisterChecker) {
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+  EXPECT_EQ(Diags, "");
+}
+
 } // namespace
 } // namespace ento
 } // namespace clang



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


[PATCH] D76422: Testing presubmits

2020-03-19 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko updated this revision to Diff 251387.
hlopko added a comment.

Removing fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76422

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -678,6 +678,212 @@
   `-;
 )txt"},
   {R"cpp(
+template  struct cls {};
+template  int var = 10;
+template  int fun() {}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-cls
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-int
+|   |-SimpleDeclarator
+|   | |-var
+|   | |-=
+|   | `-UnknownExpression
+|   |   `-10
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-fun
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"},
+  {R"cpp(
+template 
+struct X {
+  template 
+  U foo();
+};
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-{
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-U
+| |->
+| `-SimpleDeclaration
+|   |-U
+|   |-SimpleDeclarator
+|   | |-foo
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
+|-}
+`-;
+)txt"},
+  {R"cpp(
+template  struct X {};
+template  struct X {};
+template <> struct X {};
+
+template struct X;
+extern template struct X;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-T
+|   |-*
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-int
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-ExplicitTemplateInstantiation
+| |-template
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-double
+|   |->
+|   `-;
+`-ExplicitTemplateInstantiation
+  |-extern
+  |-template
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-float
+|->
+`-;
+)txt"},
+  {R"cpp(
+template  struct X { struct Y; };
+template  struct X::Y {};
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-Y
+|   | `-;
+|   |-}
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-T
+|->
+|-::
+|-Y
+|-{
+|-}
+`-;
+   )txt"},
+  {R"cpp(
 namespace ns {}
 using namespace ::ns;
 )cpp",
@@ -726,7 +932,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-UnknownDeclaration
+`-TemplateDeclaration
   |-template
   |-<
   |-UnknownDeclaration
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -58,6 +58,10 @@
 return OS << "LinkageSpecificationDeclaration";
   case NodeKind::SimpleDeclaration:
 return OS << "SimpleDeclaration";
+  case NodeKind::TemplateDeclaration:
+return OS << "TemplateDeclaration";
+  case NodeKind::ExplicitTemplateInstantiation:
+return OS << "ExplicitTemplateInstantiation";
   case NodeKind::NamespaceDefinition:
 return OS << "NamespaceDefinition";
   case NodeKind::NamespaceAliasDefinition:
@@ -118,6 +122,12 @@
 return OS << "StaticAssertDeclaration_message";
   case syntax::NodeRole::SimpleDeclaration_declarator:
 return OS << "SimpleDeclaration_declarator";
+  case syntax::NodeRole::TemplateDeclaration_declaration:
+return OS << "TemplateDeclaration_declaration";
+  case syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword:
+return OS << "ExplicitTemplateInstantiation_externKeyword";
+  case syntax::NodeRole::ExplicitTemplateInstantiation_dec

[PATCH] D76432: [clangd] Add a tweak for adding "using" statement.

2020-03-19 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, mgrang, 
jkorous, MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.

This triggers on types and function calls with namespace qualifiers. The
action is to remove the qualifier and instead add a "using" statement at
appropriate place.

It is not always clear where to add the "using" line. Right now we find
the nearest "using" line and add it there, thus keeping with local
convention. If there are no usings, we put it at the deepest relevant
namespace level.

This is an initial version only. There are several improvements that
can be made:

- Support for qualifiers that are not purely namespace (e.g.  record

types, etc).

- Removing qualifier from other instances of the same type/call.
- Smarter placement of the "using" line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76432

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

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2390,6 +2390,191 @@
 EXPECT_EQ(apply(Case.first), Case.second);
   }
 }
+
+TWEAK_TEST(AddUsing);
+TEST_F(AddUsingTest, Prepare) {
+  const std::string Header = R"cpp(
+namespace one {
+void oo() {}
+namespace two {
+enum ee {};
+void ff() {}
+class cc {
+public:
+  struct st {};
+  static void mm() {}
+};
+}
+})cpp";
+
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^:^:^t^w^o^:^:^f^f(); }");
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^::^o^o(); }");
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^:^:^t^w^o^:^:^e^e E; }");
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^:^:^t^w^o:^:^c^c C; }");
+  EXPECT_UNAVAILABLE(Header +
+ "void fun() { o^n^e^:^:^t^w^o^:^:^c^c^:^:^m^m(); }");
+  EXPECT_UNAVAILABLE(Header +
+ "void fun() { o^n^e^:^:^t^w^o^:^:^c^c^:^:^s^t inst; }");
+}
+
+TEST_F(AddUsingTest, Apply) {
+  FileName = "test.cpp";
+  struct {
+llvm::StringRef TestSource;
+llvm::StringRef ExpectedSource;
+  } Cases[]{{
+// Function, no other using, namespace.
+R"cpp(
+#include "test.hpp"
+namespace {
+void fun() {
+  ^o^n^e^:^:^t^w^o^:^:^f^f();
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+namespace {using one::two::ff;
+
+void fun() {
+  ff();
+}
+})cpp",
+},
+// Type, no other using, namespace.
+{
+R"cpp(
+#include "test.hpp"
+namespace {
+void fun() {
+  on^e::t^wo::c^c inst;
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+namespace {using one::two::cc;
+
+void fun() {
+  cc inst;
+}
+})cpp",
+},
+// Type, no other using, no namespace.
+{
+R"cpp(
+#include "test.hpp"
+
+void fun() {
+  on^e::t^wo::e^e inst;
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+using one::two::ee;
+
+void fun() {
+  ee inst;
+})cpp"},
+// Function, other usings.
+{
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+using one::two::ee;
+
+namespace {
+void fun() {
+  one::two::f^f();
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+using one::two::ff;using one::two::ee;
+
+namespace {
+void fun() {
+  ff();
+}
+})cpp",
+},
+// Function, other usings inside namespace.
+{
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+
+namespace {
+
+using one::two::ff;
+
+void fun() {
+  o^ne::o^o();
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+
+namespace {
+
+using one::oo;using one::two::ff;
+
+void fun() {
+  oo();
+}
+})cpp"},
+// Using comes after cursor.
+{
+R"cpp(
+#include "test.hpp"
+
+namespace {
+
+void fun() {
+  one::t^wo::ff();
+}
+
+using one::two::cc;
+
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+namespace {using one::two::ff;
+
+
+void fun() {
+  ff();
+}
+
+using one::two::cc;
+
+})cpp"}};
+  llvm::StringMap EditedFiles;
+  for (const auto &Case : Cases) {
+for (const auto &SubCase : expandCases(Case.TestSource)) {
+  ExtraFiles["test.hpp"] = R"cpp(
+namespace one {
+void oo() {}
+namespace two {
+enum ee {};
+void ff() {}
+class cc {
+public:
+  struct st {};
+  static void mm() {}
+};
+}
+})cpp";
+  EXPECT_EQ(apply(SubCase, &EditedFiles), Case.ExpectedSource);
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/clangd/refactor/tweaks/C

[clang] 0dd0b10 - [Parser] Avoid spurious 'missing template' error in presence of typos.

2020-03-19 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-03-19T16:15:27+01:00
New Revision: 0dd0b1017c807e7a803e69be7bdc5c0ac7b469d8

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

LOG: [Parser] Avoid spurious 'missing template' error in presence of typos.

Suppress those diagnostics if lhs of a member expression contains
errors. Typo correction produces dependent expressions even in
non-template code, that led to spurious diagnostics before.

previous:
/tmp/t.cpp:6:17: error: use 'template' keyword to treat 'f' as a dependent 
template name
auto a = bilder.f();
^
template
/tmp/t.cpp:6:10: error: use of undeclared identifier 'bilder'; did you mean 
'builder'?
auto a = bilder.f();
 ^~
 builder

vs now:

/tmp/t.cpp:6:10: error: use of undeclared identifier 'bilder'; did you mean 
'builder'?
auto a = bilder.f();
 ^~
 builder

Original patch from Ilya.

Reviewers: sammccall

Reviewed By: sammccall

Tags: #clang

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

Added: 
clang/test/SemaTemplate/dependent-typos-recovery.cpp

Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Parse/ParseStmtAsm.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index a9c68a2e231e..9a22bac75e62 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1814,7 +1814,9 @@ class Parser : public CodeCompletionHandler {
   bool EnteringContext, IdentifierInfo &II,
   CXXScopeSpec &SS);
 
-  bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, ParsedType ObjectType,
+  bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
+  ParsedType ObjectType,
+  bool ObjectHasErrors,
   bool EnteringContext,
   bool *MayBePseudoDestructor = nullptr,
   bool IsTypename = false,
@@ -2908,11 +2910,12 @@ class Parser : public CodeCompletionHandler {
   AccessSpecifier getAccessSpecifierIfPresent() const;
 
   bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
+ParsedType ObjectType,
+bool ObjectHadErrors,
 SourceLocation TemplateKWLoc,
 IdentifierInfo *Name,
 SourceLocation NameLoc,
 bool EnteringContext,
-ParsedType ObjectType,
 UnqualifiedId &Id,
 bool AssumeTemplateId);
   bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
@@ -3081,13 +3084,12 @@ class Parser : public CodeCompletionHandler {
   bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind,
   SmallVectorImpl &Vars,
   OpenMPVarListDataTy &Data);
-  bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
-  bool AllowDestructorName,
-  bool AllowConstructorName,
+  bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType,
+  bool ObjectHadErrors, bool EnteringContext,
+  bool AllowDestructorName, bool AllowConstructorName,
   bool AllowDeductionGuide,
-  ParsedType ObjectType,
-  SourceLocation *TemplateKWLoc,
-  UnqualifiedId &Result);
+  SourceLocation *TemplateKWLoc, UnqualifiedId 
&Result);
+
   /// Parses the mapper modifier in map, to, and from clauses.
   bool parseMapperModifier(OpenMPVarListDataTy &Data);
   /// Parses map-type-modifiers in map clause.

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 17298dad4564..ba4f5d86612a 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4421,7 +4421,8 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 ColonProtectionRAIIObject X(*this, AllowDeclaration);
 
 CXXScopeSpec Spec;
-if (ParseOptionalCXXScopeSpecifier(Spec, nullptr,
+if (ParseOptionalCXXScopeSpecifier(Spec, /*ObjectType=*/nullptr,
+ 

[PATCH] D76433: [Syntax] Make TreeTest independent from the host platform.

2020-03-19 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hlopko added a parent revision: D76366: [Syntax] Split syntax tests.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76433

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -98,8 +98,12 @@
 if (!Diags->getClient())
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
-std::vector Args = {"syntax-test", "-std=c++11",
-  "-fsyntax-only", FileName};
+std::vector Args = {
+  "syntax-test", "-std=c++11",
+  // Hard-setting target so the unit test behavior doesn't depend on the
+  // host.
+  "-target", "x86_64-unknown-unknown",
+  "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);
 Invocation->getFrontendOpts().DisableFree = false;


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -98,8 +98,12 @@
 if (!Diags->getClient())
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
-std::vector Args = {"syntax-test", "-std=c++11",
-  "-fsyntax-only", FileName};
+std::vector Args = {
+  "syntax-test", "-std=c++11",
+  // Hard-setting target so the unit test behavior doesn't depend on the
+  // host.
+  "-target", "x86_64-unknown-unknown",
+  "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);
 Invocation->getFrontendOpts().DisableFree = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49074: [Analyzer] Basic support for multiplication and division in the constraint manager

2020-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 251391.
baloghadamsoftware added a comment.
Herald added a reviewer: Szelethus.
Herald added subscribers: ASDenysPetrov, steakhal.

Rebased.


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

https://reviews.llvm.org/D49074

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/multiplicative-folding.c

Index: clang/test/Analysis/multiplicative-folding.c
===
--- clang/test/Analysis/multiplicative-folding.c
+++ clang/test/Analysis/multiplicative-folding.c
@@ -573,6 +573,1478 @@
   }
 }
 
+void signed_multiplication_lt_0(int32_t n) {
+  if (n * 2 < 3) {
+int32_t  U1 = 0x8001,
+L2 = 0xc000, U2 = 1,
+L3 = 0x4000;
+
+assert(INT_MIN * 2 < 3);
+assert(U1 * 2 < 3);
+assert((U1 + 1) * 2 >= 3);
+assert(L2 * 2 < 3);
+assert((L2 - 1) * 2 >= 3);
+assert(U2 * 2 < 3);
+assert((U2 + 1) * 2 >= 3);
+assert(L3 * 2 < 3);
+assert((L3 - 1) * 2 >= 3);
+assert(INT_MAX * 2 < 3);
+
+if (n < INT_MIN / 2) {
+  clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+ //expected-warning@-1{{TRUE}}
+  clang_analyzer_eval(n <= U1); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n > U1); //expected-warning{{FALSE}}
+} else if (n < INT_MAX / 2){
+  clang_analyzer_eval(n < L2); //expected-warning{{FALSE}}
+  clang_analyzer_eval(n >= L2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n <= U2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n > U2); //expected-warning{{FALSE}}
+} else {
+  clang_analyzer_eval(n < L3); //expected-warning{{FALSE}}
+  clang_analyzer_eval(n >= L3); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n == INT_MAX); //expected-warning{{FALSE}}
+ //expected-warning@-1{{TRUE}}
+}
+  }
+}
+
+void signed_multiplication_lt_1(int32_t n) {
+  if (n * 2 < 4) {
+int32_t  U1 = 0x8001,
+L2 = 0xc000, U2 = 1,
+L3 = 0x4000;
+
+assert(INT_MIN * 2 < 4);
+assert(U1 * 2 < 4);
+assert((U1 + 1) * 2 >= 4);
+assert(L2 * 2 < 4);
+assert((L2 - 1) * 2 >= 4);
+assert(U2 * 2 < 4);
+assert((U2 + 1) * 2 >= 4);
+assert(L3 * 2 < 4);
+assert((L3 - 1) * 2 >= 4);
+assert(INT_MAX * 2 < 4);
+
+if (n < INT_MIN / 2) {
+  clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+ //expected-warning@-1{{TRUE}}
+  clang_analyzer_eval(n <= U1); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n > U1); //expected-warning{{FALSE}}
+} else if (n < INT_MAX / 2){
+  clang_analyzer_eval(n < L2); //expected-warning{{FALSE}}
+  clang_analyzer_eval(n >= L2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n <= U2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n > U2); //expected-warning{{FALSE}}
+} else {
+  clang_analyzer_eval(n < L3); //expected-warning{{FALSE}}
+  clang_analyzer_eval(n >= L3); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n == INT_MAX); //expected-warning{{FALSE}}
+ //expected-warning@-1{{TRUE}}
+}
+  }
+}
+
+void signed_multiplication_lt_2(int32_t n) {
+  if (n * 2 < 5) {
+int32_t  U1 = 0x8002,
+L2 = 0xc000, U2 = 2,
+L3 = 0x4000;
+
+assert(INT_MIN * 2 < 5);
+assert(U1 * 2 < 5);
+assert((U1 + 1) * 2 >= 5);
+assert(L2 * 2 < 5);
+assert((L2 - 1) * 2 >= 5);
+assert(U2 * 2 < 5);
+assert((U2 + 1) * 2 >= 5);
+assert(L3 * 2 < 5);
+assert((L3 - 1) * 2 >= 5);
+assert(INT_MAX * 2 < 5);
+
+if (n < INT_MIN / 2) {
+  clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+ //expected-warning@-1{{TRUE}}
+  clang_analyzer_eval(n <= U1); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n > U1); //expected-warning{{FALSE}}
+} else if (n < INT_MAX / 2){
+  clang_analyzer_eval(n < L2); //expected-warning{{FALSE}}
+  clang_analyzer_eval(n >= L2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n <= U2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n > U2); //expected-warning{{FALSE}}
+} else {
+  clang_analyzer_eval(n < L3); //expected-warning{{FALSE}}
+  clang_analyzer_eval(n >= L3); //expected-warning{{TRUE}}
+  clang_analyzer_eval(n == INT_MAX); //expected-warning{{FALSE}}
+ //expected-warning@-1{{TRUE}}
+}
+  }
+}
+
+void signed_multiplication_lt_3(int32_t n) {
+  if (n * 3 < 4) {
+int32_t  U1 = 0xaaab,
+

[PATCH] D50256: [Analyzer] Basic support for multiplication and division in the constraint manager (for == and != only)

2020-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 251389.
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.
Herald added a reviewer: Szelethus.
Herald added subscribers: ASDenysPetrov, martong, steakhal.

Rebased.


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

https://reviews.llvm.org/D50256

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/multiplicative-folding.c

Index: clang/test/Analysis/multiplicative-folding.c
===
--- /dev/null
+++ clang/test/Analysis/multiplicative-folding.c
@@ -0,0 +1,689 @@
+// RUN: %clang_analyze_cc1 --std=c11 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached(void);
+
+#define UINT_MAX (~0U)
+#define INT_MAX (int)(UINT_MAX & (UINT_MAX >> 1))
+#define INT_MIN (-INT_MAX - 1)
+
+#define ULONG_LONG_MAX (~0UL)
+#define LONG_LONG_MAX (long long)(ULONG_LONG_MAX & (ULONG_LONG_MAX >> 1))
+#define LONG_LONG_MIN (-LONG_LONG_MAX - 1)
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+typedef int int32_t;
+typedef unsigned int uint32_t;
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+void signed_multiplication_eq(int32_t n) {
+  if (n * 2 == 3) {
+clang_analyzer_warnIfReached(); // no-warning
+
+  } else if (n * 2 == 4) {
+const int32_t C1 = 0x8002, C2 = 2;
+
+assert(C1 * 2 == 4);
+assert(C2 * 2 == 4);
+
+clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C1 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C1); //expected-warning{{FALSE}}
+  //expected-warning@-1{{TRUE}}
+clang_analyzer_eval(n == C1 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == 0); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C2 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C2); //expected-warning{{FALSE}}
+  //expected-warning@-1{{TRUE}}
+clang_analyzer_eval(n == C2 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == INT_MAX); //expected-warning{{FALSE}}
+
+  } else if (n * 3 == 4) {
+const int32_t C1 = 0xaaac;
+
+assert(C1 * 3 == 4);
+
+clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C1 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C1); //expected-warning{{TRUE}}
+clang_analyzer_eval(n == C1 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == 0); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == INT_MAX); //expected-warning{{FALSE}}
+
+  } else if (n * 4 == -5) {
+clang_analyzer_warnIfReached(); // no-warning
+
+  } else if (n * 4 == -8) {
+const int32_t C1 = 0xbffe, C2 = 0xfffe,
+  C3 = 0x3ffe, C4 = 0x7ffe;
+
+assert(C1 * 4 == -8);
+assert(C2 * 4 == -8);
+assert(C3 * 4 == -8);
+assert(C4 * 4 == -8);
+
+clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C1 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C1); //expected-warning{{FALSE}}
+  //expected-warning@-1{{TRUE}}
+clang_analyzer_eval(n == C1 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C2 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C2); //expected-warning{{FALSE}}
+  //expected-warning@-1{{TRUE}}
+clang_analyzer_eval(n == C2 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == 0); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C3 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C3); //expected-warning{{FALSE}}
+  //expected-warning@-1{{TRUE}}
+clang_analyzer_eval(n == C3 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C4 - 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == C4); //expected-warning{{FALSE}}
+  //expected-warning@-1{{TRUE}}
+clang_analyzer_eval(n == C4 + 1); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == INT_MAX); //expected-warning{{FALSE}}
+
+  } else if (n * 6 == -7) {
+clang_analyzer_warnIfReached(); // no-warning
+
+  } else if (n * 6 == -2) {
+const int32_t C1 = 0xd555, C2 = 0x;
+
+assert(C1 * 6 == -2);
+assert(C2 * 6 == -2);
+
+clang_analyzer_eval(n == INT_MIN); //expected-warning{{FALSE}}
+clang_analyzer_eval(n == 

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

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 251393.
hokein added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330

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

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -487,6 +487,8 @@
 auto x = decltype(&1)(^);
 auto y = new decltype(&1)(^);
   )cpp";
-  EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
+  EXPECT_THAT(collectPreferredTypes(Code),
+  Each("decltype((1))"));
 }
+
 } // namespace
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -292,6 +292,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int &i);
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C

[PATCH] D65592: [Parser] Avoid spurious 'missing template' error in presence of typos

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0dd0b1017c80: [Parser] Avoid spurious 'missing 
template' error in presence of typos. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65592

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/SemaTemplate/dependent-typos-recovery.cpp

Index: clang/test/SemaTemplate/dependent-typos-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/dependent-typos-recovery.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'template' keywords.
+struct B {
+  template 
+  int f(){};
+} builder;// expected-note 2{{'builder' declared here}}
+
+auto a = bilder.f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
+auto b = (*(&bilder+0)).f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1605,7 +1605,9 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus &&
-  ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+ /*ObjectHadErrors=*/false,
+ EnteringContext))
 return ANK_Error;
 
   if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
@@ -1842,6 +1844,7 @@
 SourceLocation TypenameLoc = ConsumeToken();
 CXXScopeSpec SS;
 if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+   /*ObjectHadErrors=*/false,
/*EnteringContext=*/false, nullptr,
/*IsTypename*/ true))
   return true;
@@ -1914,7 +1917,9 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus)
-if (ParseOptionalCXXScopeSpecifier(SS, nullptr, /*EnteringContext*/false))
+if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+   /*ObjectHadErrors=*/false,
+   /*EnteringContext*/ false))
   return true;
 
   return TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation);
@@ -2043,7 +2048,9 @@
   assert(MightBeCXXScopeToken() && "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+ /*ObjectHadErrors=*/false,
+ EnteringContext))
 return true;
   if (SS.isEmpty())
 return false;
@@ -2152,7 +2159,8 @@
 
   // Parse nested-name-specifier.
   if (getLangOpts().CPlusPlus)
-ParseOptionalCXXScopeSpecifier(Result.SS, nullptr,
+ParseOptionalCXXScopeSpecifier(Result.SS, /*ObjectType=*/nullptr,
+   /*ObjectHadErrors=*/false,
/*EnteringContext=*/false);
 
   // Check nested-name specifier.
@@ -2163,10 +2171,12 @@
 
   // Parse the unqualified-id.
   SourceLocation TemplateKWLoc; // FIXME: parsed, but unused.
-  if (ParseUnqualifiedId(
-  Result.SS, /*EnteringContext*/false, /*AllowDestructorName*/true,
-  /*AllowConstructorName*/true, /*AllowDeductionGuide*/false, nullptr,
-  &TemplateKWLoc, Result.Name)) {
+  if (ParseUnqualifiedId(Result.SS, /*ObjectType=*/nullptr,
+ /*ObjectHadErrors=*/false, /*EnteringContext*/ false,
+ /*AllowDestructorName*/ true,
+ /*AllowConstructorName*/ true,
+ /*AllowDeductionGuide*/ false, &TemplateKWLoc,
+ Result.Name)) {
 T.skipToEnd();
 return true;
   }
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -363,9 +363,11 @@
   DiagnoseAndSkipCXX11Attributes();
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
-  /*EnteringContext=*/false, /*MayBePseudoDestructor=*/nullptr,
-  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
+  if (ParseOptionalCXXScopeSpecifier(
+  SS, /*ObjectType=*/nullptr,
+  /*ObjectHadErrors=*/false, /*EnteringContext=*/false,
+  /*MayBePseudoDestructor=*/nullptr,
+  

[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cff2e9f7884: [Analyzer] Bugfix for CheckerRegistry 
(authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842

Files:
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp


Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -81,6 +81,66 @@
   runCheckerOnCode("void f() { int *p; (*p)++; }"));
 }
 
+//===--===//
+// Unsatisfied checker dependency
+//===--===//
+
+class PrerequisiteChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,
+   "This is the prerequisite checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerPrerequisiteChecker(CheckerManager &mgr) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterPrerequisiteChecker(const LangOptions &LO) {
+  return false;
+}
+
+class DependentChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Dependent", categories::LogicError,
+   "This is the Dependent Checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerDependentChecker(CheckerManager &mgr) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterDependentChecker(const LangOptions &LO) {
+  return true;
+}
+
+void addDependentChecker(AnalysisASTConsumer &AnalysisConsumer,
+ AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"custom.Dependent", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+ Registry.addChecker(registerPrerequisiteChecker,
+ shouldRegisterPrerequisiteChecker,
+ "custom.Prerequisite", "Description", "", false);
+ Registry.addChecker(registerDependentChecker,
+ shouldRegisterDependentChecker,
+ "custom.Dependent", "Description", "", false);
+ Registry.addDependency("custom.Dependent", "custom.Prerequisite");
+});
+}
+
+TEST(RegisterDependentCheckers, RegisterChecker) {
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+  EXPECT_EQ(Diags, "");
+}
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -167,7 +167,7 @@
 }
 
 bool isDisabled(const LangOptions &LO) const {
-  return State == StateFromCmdLine::State_Disabled && ShouldRegister(LO);
+  return State == StateFromCmdLine::State_Disabled || !ShouldRegister(LO);
 }
 
 // Since each checker must have a different full name, we can identify


Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -81,6 +81,66 @@
   runCheckerOnCode("void f() { int *p; (*p)++; }"));
 }
 
+//===--===//
+// Unsatisfied checker dependency
+//===--===//
+
+class PrerequisiteChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,
+   "This is the prerequisite checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerPrerequisiteChecker(CheckerManager &mgr) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterPrerequisiteChecker(const LangOptions &LO) {
+  return false;
+}
+
+class DependentChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Dependent", categories::

[PATCH] D60748: Adds an option "malign-pass-aggregate" to make the alignment of the struct and union parameters compatible with the default gcc

2020-03-19 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Since the ABI this is trying to match is not documented literally anywhere, I 
think we need to have some confidence that what this implements is actually the 
same as what GCC does. While I wrote up what I think the algorithm is, without 
some sort of script to allow testing it against a bunch of examples, I wouldn't 
say I'm confident of its correctness.

I'm not sure if you can reverse-engineer what the alignment must have been from 
the assembly output, or from some debug flags. Or if maybe doing something 
silly like modifying the source to insert a printf would be the best method to 
test this.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:1542-1544
+// i386 System V ABI 2.1: Structures and unions assume the alignment of 
their
+// most strictly aligned component.
+//

This comment isn't useful. While it may be what the System V ABI document says, 
that's clearly incorreect, and is  not what the code is or should be doing. 
Please document what is actually implemented, instead.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1559
+  if (const auto *AT = QT->getAsArrayTypeUnsafe())
+TempAlignment = getContext().getTypeAlign(AT->getElementType()) / 
8;
+  else // recursively to get each type's alignment

Also needs to call getTypeStackAlignInBytes?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1567
+  if (MaxAlignment >= 16)
+return std::max(MaxAlignment, Align);
+  else // return 4 when all the type alignments less than 16 bytes

I think this is wrong and that it should only return Align. The computation of 
the alignment of the elements is only to see if their alignment is >= 16.

If the alignment of the elements' types is >= 16, but the alignment of the 
structure is less than the alignment of one of its elements (e.g. due to 
`__attribute__ packed`), we should return the alignment of the structure.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1570
+return 4;
+} else if (Align < 16)
+  return MinABIStackAlignInBytes;

If I understood GCC's algorithm correctly, I think this needs to come first?



Comment at: clang/test/CodeGen/x86_32-align-linux.cpp:9
+
+class __attribute__((aligned(64))) X1 {
+  class  __attribute__((aligned(32))) {

Confused me that this was a different X1 than in the test-case above. I'm not 
sure why the tests need to be duplicated here in a .cpp file in the first place?


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

https://reviews.llvm.org/D60748



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


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

2020-03-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

all prerequisite patches have been landed, it is time to land this patch now. 
Would be nice to have a second look before committing it +@sammccall.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330



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


[PATCH] D76433: [Syntax] Make TreeTest independent from the host platform.

2020-03-19 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko updated this revision to Diff 251399.
hlopko added a comment.

Reformat


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76433

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -99,6 +99,9 @@
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
+  // Hard-setting target so the unit test
+  // behavior doesn't depend on the host.
+  "-target", "x86_64-unknown-unknown",
   "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -99,6 +99,9 @@
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
+  // Hard-setting target so the unit test
+  // behavior doesn't depend on the host.
+  "-target", "x86_64-unknown-unknown",
   "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-19 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked 3 inline comments as done.
zoecarver added a comment.

@lebedev.ri LLVM may be better, I'm not sure. If you feel strongly I can move 
it.

@jyknight I'm planning on adding a builtin that uses this method. I can put the 
patch up for that first if you would like.




Comment at: clang/include/clang/Basic/TargetInfo.h:1192
+  // Get the cache line size of a given cpu. This method switches over
+  // the given cpu and returns `0` if the CPU is not found.
+  virtual Optional getCPUCacheLineSize() const { return None; }

lebedev.ri wrote:
> Comment is no longer valid - returns `None` instead.
> Also, might it be worth explicitly calling out that there is zero guarantees 
> of stability of the returned values?
Good catch. I think we should try to have as much stability as possible but I 
can add a note that these values may change. 



Comment at: clang/lib/Basic/Targets/X86.cpp:1786
+// i386
+case CK_i386:
+// Netburst

craig.topper wrote:
> I found the documentation for the 82385 cache controller chip for the 386. 
> It's a bit weird. The tags for the cache are based on 16 byte lines, but 
> there are valid bits for every 2 bytes within that line. So its possible for 
> only a portion of a line to be valid.
Interesting. Does this mean that we should be returning a different value?



Comment at: clang/lib/Basic/Targets/X86.cpp:1840
+// Core
+case CK_Core2:
+case CK_Generic:

craig.topper wrote:
> If Yonah and Penryn are 64, then Core2 should be as well. It's the generation 
> between them.
I'll update it. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918



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


[clang] 88bf9b3 - [Syntax] Build template declaration nodes

2020-03-19 Thread Dmitri Gribenko via cfe-commits

Author: Marcel Hlopko
Date: 2020-03-19T17:43:07+01:00
New Revision: 88bf9b3d26f06eaf33972d1f371edc4cb187ff1a

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

LOG: [Syntax] Build template declaration nodes

Summary:
Rollforward of
https://reviews.llvm.org/rGdd12826808f9079e164b82e64b0697a077379241 after
temporarily adding -fno-delayed-template-parsing to the TreeTest.

Original summary:

> Copy of https://reviews.llvm.org/D72334, submitting with Ilya's permission.
>
> Handles template declaration of all kinds.
>
> Also builds template declaration nodes for specializations and explicit
> instantiations of classes.
>
> Some missing things will be addressed in the follow-up patches:
>
> * specializations of functions and variables,
> * template parameters.

Reviewers: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Nodes.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 82fcac33f99b..f4d482bb848c 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -64,6 +64,8 @@ enum class NodeKind : uint16_t {
   StaticAssertDeclaration,
   LinkageSpecificationDeclaration,
   SimpleDeclaration,
+  TemplateDeclaration,
+  ExplicitTemplateInstantiation,
   NamespaceDefinition,
   NamespaceAliasDefinition,
   UsingNamespaceDirective,
@@ -112,6 +114,9 @@ enum class NodeRole : uint8_t {
   StaticAssertDeclaration_condition,
   StaticAssertDeclaration_message,
   SimpleDeclaration_declarator,
+  TemplateDeclaration_declaration,
+  ExplicitTemplateInstantiation_externKeyword,
+  ExplicitTemplateInstantiation_declaration,
   ArraySubscript_sizeExpression,
   TrailingReturnType_arrow,
   TrailingReturnType_declarator,
@@ -396,6 +401,34 @@ class SimpleDeclaration final : public Declaration {
   std::vector declarators();
 };
 
+/// template  
+class TemplateDeclaration final : public Declaration {
+public:
+  TemplateDeclaration() : Declaration(NodeKind::TemplateDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::TemplateDeclaration;
+  }
+  syntax::Leaf *templateKeyword();
+  syntax::Declaration *declaration();
+};
+
+/// template 
+/// Examples:
+/// template struct X
+/// template void foo()
+/// template int var
+class ExplicitTemplateInstantiation final : public Declaration {
+public:
+  ExplicitTemplateInstantiation()
+  : Declaration(NodeKind::ExplicitTemplateInstantiation) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::ExplicitTemplateInstantiation;
+  }
+  syntax::Leaf *templateKeyword();
+  syntax::Leaf *externKeyword();
+  syntax::Declaration *declaration();
+};
+
 /// namespace  {  }
 class NamespaceDefinition final : public Declaration {
 public:

diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 9ebf7d29d8ed..a09ac1c53e34 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Syntax/Nodes.h"
@@ -189,7 +190,6 @@ class syntax::TreeBuilder {
   /// Should be called for expressions in non-statement position to avoid
   /// wrapping into expression statement.
   void markExprChild(Expr *Child, NodeRole Role);
-
   /// Set role for a token starting at \p Loc.
   void markChildToken(SourceLocation Loc, NodeRole R);
   /// Set role for \p T.
@@ -199,6 +199,9 @@ class syntax::TreeBuilder {
   void markChild(llvm::ArrayRef Range, NodeRole R);
   /// Set role for the delayed node that spans exactly \p Range.
   void markDelayedChild(llvm::ArrayRef Range, NodeRole R);
+  /// Set role for the node that may or may not be delayed. Node must span
+  /// exactly \p Range.
+  void markMaybeDelayedChild(llvm::ArrayRef Range, NodeRole R);
 
   /// Finish building the tree and consume the root node.
   syntax::TranslationUnit *finalize() && {
@@ -215,6 +218,9 @@ class syntax::TreeBuilder {
 return TU;
   }
 
+  /// Finds a token starting at \p L. The token must exist if \p L is valid.
+  const syntax::Token *findToken(SourceLocation L) const;
+
   /// getRange() finds the syntax tokens corresponding to the passed source
   /// locations.
   /// \p First is the start position of the first token and \p Last is 

[PATCH] D76418: [Syntax] Build template declaration nodes

2020-03-19 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88bf9b3d26f0: [Syntax] Build template declaration nodes 
(authored by hlopko, committed by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D76418?vs=251304&id=251404#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76418

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -99,6 +99,7 @@
   Diags->setClient(new IgnoringDiagConsumer);
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
+  "-fno-delayed-template-parsing",
   "-fsyntax-only", FileName};
 Invocation = createInvocationFromCommandLine(Args, Diags, FS);
 assert(Invocation);
@@ -678,6 +679,212 @@
   `-;
 )txt"},
   {R"cpp(
+template  struct cls {};
+template  int var = 10;
+template  int fun() {}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-cls
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-int
+|   |-SimpleDeclarator
+|   | |-var
+|   | |-=
+|   | `-UnknownExpression
+|   |   `-10
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-fun
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"},
+  {R"cpp(
+template 
+struct X {
+  template 
+  U foo();
+};
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-{
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-U
+| |->
+| `-SimpleDeclaration
+|   |-U
+|   |-SimpleDeclarator
+|   | |-foo
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
+|-}
+`-;
+)txt"},
+  {R"cpp(
+template  struct X {};
+template  struct X {};
+template <> struct X {};
+
+template struct X;
+extern template struct X;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-T
+|   |-*
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-int
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-ExplicitTemplateInstantiation
+| |-template
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-double
+|   |->
+|   `-;
+`-ExplicitTemplateInstantiation
+  |-extern
+  |-template
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-float
+|->
+`-;
+)txt"},
+  {R"cpp(
+template  struct X { struct Y; };
+template  struct X::Y {};
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-Y
+|   | `-;
+|   |-}
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-T
+|->
+|-::
+|-Y
+|-{
+|-}
+`-;
+   )txt"},
+  {R"cpp(
 namespace ns {}
 using namespace ::ns;
 )cpp",
@@ -726,7 +933,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-UnknownDeclaration
+`-TemplateDeclaration
   |-template
   |-<
   |-UnknownDeclaration
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -58,6 +58,10 @@
 return OS << "LinkageSpecificationDeclaration";
   case NodeKind::SimpleDeclaration:
 return OS << "SimpleDeclaration";
+  case NodeKind::TemplateDeclaration:
+return OS << "TemplateDeclaration";
+  case NodeKind::ExplicitTemplateInstanti

[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-19 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 251409.
tmsriram marked 2 inline comments as done.
tmsriram added a comment.

Address reviewer comments.  Fix test and delete blank line.


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

https://reviews.llvm.org/D73307

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/unique-internal-funcnames.c
  clang/test/Driver/funique-internal-funcnames.c

Index: clang/test/Driver/funique-internal-funcnames.c
===
--- /dev/null
+++ clang/test/Driver/funique-internal-funcnames.c
@@ -0,0 +1,4 @@
+// RUN: %clang -### -funique-internal-funcnames %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -funique-internal-funcnames -fno-unique-internal-funcnames %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// CHECK-OPT: "-funique-internal-funcnames"
+// CHECK-NOOPT-NOT: {{-funique-internal-funcnames}}
Index: clang/test/CodeGen/unique-internal-funcnames.c
===
--- /dev/null
+++ clang/test/CodeGen/unique-internal-funcnames.c
@@ -0,0 +1,16 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target x86_64 -S -o - %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang -target x86_64 -S -funique-internal-funcnames -o -  %s | FileCheck %s --check-prefix=UNIQUE
+
+static int foo() {
+  return 0;
+}
+
+int (*bar())() {
+  return foo;
+}
+
+// PLAIN: foo:
+// UNIQUE-NOT: foo:
+// UNIQUE: foo.{{[0-9a-f]+}}:
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -958,6 +958,7 @@
   Opts.StackSizeSection = Args.hasArg(OPT_fstack_size_section);
   Opts.UniqueSectionNames = !Args.hasArg(OPT_fno_unique_section_names);

+  Opts.UniqueInternalFuncNames = Args.hasArg(OPT_funique_internal_funcnames);
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1124,6 +1124,23 @@
   const auto *ND = cast(GD.getDecl());
   std::string MangledName = getMangledNameImpl(*this, GD, ND);
 
+  // With option -funique-internal-funcnames, functions with internal linkage
+  // should get unique names.  Use the hash of module name to get a unique
+  // identifier and this is a best effort.
+  if (getCodeGenOpts().UniqueInternalFuncNames &&
+  dyn_cast(GD.getDecl()) &&
+  getFunctionLinkage(GD) == llvm::GlobalValue::InternalLinkage &&
+  !getModule().getSourceFileName().empty()) {
+llvm::MD5 Md5;
+Md5.update(getModule().getSourceFileName());
+llvm::MD5::MD5Result R;
+Md5.final(R);
+SmallString<32> Str;
+llvm::MD5::stringifyResult(R, Str);
+std::string UniqueSuffix = ("." + Str).str();
+MangledName += UniqueSuffix;
+  }
+
   // Ensure either we have different ABIs between host and device compilations,
   // says host compilation following MSVC ABI but device compilation follows
   // Itanium C++ ABI or, if they follow the same ABI, kernel names after
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4222,6 +4222,8 @@
 options::OPT_fno_function_sections,
 options::OPT_fdata_sections,
 options::OPT_fno_data_sections,
+options::OPT_funique_internal_funcnames,
+options::OPT_fno_unique_internal_funcnames,
 options::OPT_funique_section_names,
 options::OPT_fno_unique_section_names,
 options::OPT_mrestrict_it,
@@ -4819,6 +4821,10 @@
 options::OPT_fno_unique_section_names, true))
 CmdArgs.push_back("-fno-unique-section-names");
 
+  if (Args.hasFlag(options::OPT_funique_internal_funcnames,
+   options::OPT_fno_unique_internal_funcnames, false))
+CmdArgs.push_back("-funique-internal-funcnames");
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1971,6 +1971,12 @@
 def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">,
   Group, Flags<[CC1Option]>;
 
+def funique_internal_funcnames : Flag <["-"], "funique-inte

[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-03-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 251407.
ZarkoCA marked 3 inline comments as done.
ZarkoCA added a comment.

Changed comments per suggestions. 
Added `va_copy` in test case.


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

https://reviews.llvm.org/D76360

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-vararg.c


Index: clang/test/CodeGen/aix-vararg.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-vararg.c
@@ -0,0 +1,40 @@
+// REQUIRES: powerpc-registered-target
+// REQUIRES: asserts
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | 
FileCheck %s --check-prefix=32BIT
+#include 
+
+void aix_varg(int a, ...) {
+  va_list arg;
+  va_start(arg, a);
+  va_list arg2;
+  va_arg(arg, int);
+  va_copy(arg2, arg);
+  va_end(arg);
+  va_end(arg2);
+}
+
+// 32BIT:   define void @aix_varg(i32 %a, ...) #0 {
+// 32BIT-NEXT:  entry:
+// 32BIT-NEXT:%a.addr = alloca i32, align 4
+// 32BIT-NEXT:%arg = alloca i8*, align 4
+// 32BIT-NEXT:%arg2 = alloca i8*, align 4
+// 32BIT-NEXT:store i32 %a, i32* %a.addr, align 4
+// 32BIT-NEXT:%arg1 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_start(i8* %arg1)
+// 32BIT-NEXT:%argp.cur = load i8*, i8** %arg, align 4
+// 32BIT-NEXT:%argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4
+// 32BIT-NEXT:store i8* %argp.next, i8** %arg, align 4
+// 32BIT-NEXT:%0 = bitcast i8* %argp.cur to i32*
+// 32BIT-NEXT:%1 = load i32, i32* %0, align 4
+// 32BIT-NEXT:%2 = bitcast i8** %arg2 to i8*
+// 32BIT-NEXT:%3 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_copy(i8* %2, i8* %3)
+// 32BIT-NEXT:%arg3 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_end(i8* %arg3)
+// 32BIT-NEXT:%arg24 = bitcast i8** %arg2 to i8*
+// 32BIT-NEXT:call void @llvm.va_end(i8* %arg24)
+// 32BIT-NEXT:ret void
+// 32BIT-NEXT:  }
+// 32BIT: declare void @llvm.va_start(i8*) #1
+// 32BIT: declare void @llvm.va_copy(i8*, i8*) #1
+// 32BIT: declare void @llvm.va_end(i8*) #1
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4172,7 +4172,8 @@
 
 // PowerPC-32
 namespace {
-/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
+/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ABI information, used by PowerPC 
ELF
+/// (SVR4), Darwin and AIX.
 class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
   bool IsSoftFloatABI;
 
@@ -4229,7 +4230,10 @@
 // DefaultABIInfo::EmitVAArg.
 Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAList,
   QualType Ty) const {
-  if (getTarget().getTriple().isOSDarwin()) {
+  // TODO: Add AIX ABI Info. Currently, we are relying on PPC32_SVR4_ABIInfo to
+  // emit correct VAArg.
+  if (getTarget().getTriple().isOSDarwin() ||
+  getTarget().getTriple().isOSAIX()) {
 auto TI = getContext().getTypeInfoInChars(Ty);
 TI.second = getParamTypeAlignment(Ty);
 
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -369,7 +369,8 @@
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
-// This is the ELF definition, and is overridden by the Darwin sub-target
+// This is the ELF definition, and is overridden by the Darwin and AIX
+// sub-targets.
 return TargetInfo::PowerABIBuiltinVaList;
   }
 };


Index: clang/test/CodeGen/aix-vararg.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-vararg.c
@@ -0,0 +1,40 @@
+// REQUIRES: powerpc-registered-target
+// REQUIRES: asserts
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | FileCheck %s --check-prefix=32BIT
+#include 
+
+void aix_varg(int a, ...) {
+  va_list arg;
+  va_start(arg, a);
+  va_list arg2;
+  va_arg(arg, int);
+  va_copy(arg2, arg);
+  va_end(arg);
+  va_end(arg2);
+}
+
+// 32BIT:   define void @aix_varg(i32 %a, ...) #0 {
+// 32BIT-NEXT:  entry:
+// 32BIT-NEXT:%a.addr = alloca i32, align 4
+// 32BIT-NEXT:%arg = alloca i8*, align 4
+// 32BIT-NEXT:%arg2 = alloca i8*, align 4
+// 32BIT-NEXT:store i32 %a, i32* %a.addr, align 4
+// 32BIT-NEXT:%arg1 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_start(i8* %arg1)
+// 32BIT-NEXT:%argp.cur = load i8*, i8** %arg, align 4
+// 32BIT-NEXT:%argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4
+// 32BIT-NEXT:store i8* %argp.next, i8** %arg, align 4
+// 32BIT-NEXT:%0 = bitcast i8* %argp.cur to i32*
+// 32BIT-NEXT:%1 = load i32, i32* %0, align 4
+// 32BIT-NEXT:%2 = bitcast i8** %arg2 to i8*
+// 32BIT-NEXT:%3 = bitca

[PATCH] D76396: Allow immediate invocation of constructors

2020-03-19 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders abandoned this revision.
wchilders added a comment.

In D76396#1930773 , @Tyker wrote:

> I have already a patch aiming to do the same thing. D74007 
> 


Oof, okay, sounds good. I was not aware of this patch, it looks to be much 
further along :)

>> Provide improvements which allow the cached values of ConstantExpr to be 
>> used by both the constant evaluator and code gen
> 
> this is definitely something we should do.
> 
>> Update the application of evaluation contexts, using the stronger guarantees 
>> of manifest constant evaluation to apply the ConstantEvaluated evaluation 
>> context in more places
> 
> the tracking of evaluation context isn't as good as it could/should.

With this being closed out in favor of Tyker's patch, I'll post a patch for 
reusing cached values of ConstantExpr shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76396



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


[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-03-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 8 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4175
 namespace {
 /// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
 class PPC32_SVR4_ABIInfo : public DefaultABIInfo {

sfertile wrote:
> This name and comment is misleading, the class is used for both SVR4 and 
> Darwin, and after this patch AIX. We need to fix the name comment to reflect 
> that.
Does this wording of the comment work? 



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4232
   QualType Ty) const {
-  if (getTarget().getTriple().isOSDarwin()) {
+  // TODO: Add AIX ABI Info.  Currently we are relying on PPC32_SVR4_ABIInfo to
+  // emit correct VAArg.

hubert.reinterpretcast wrote:
> No need for two spaces. Add comma after "Currently".
Thanks, I've found it hard to shake the habits my Grade 8 typing teacher taught 
me. 



Comment at: clang/test/CodeGen/aix-vararg.c:4
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | 
FileCheck %s --check-prefix=32BIT
+#include 
+

hubert.reinterpretcast wrote:
> Can we use built-in types and functions in place of a header inclusion?
I'm worried about legal/copyright issues with using contents from AIX system 
headers to LLVM testcases. But I can do that for sure once I understand what I 
am allowed to do.   



Comment at: clang/test/CodeGen/aix-vararg.c:10
+  va_arg(arg, int);
+  va_end(arg);
+}

jasonliu wrote:
> As part of a "va_..." family, do we also want to test va_copy? 
Good suggestion, added. 


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

https://reviews.llvm.org/D76360



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


[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX

2020-03-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 251408.
ZarkoCA marked 11 inline comments as done.
ZarkoCA added a comment.

Addressed code comments, working on adding and fixing tests for further clarity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76130

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll
  llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll

Index: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll
@@ -0,0 +1,316 @@
+; RUN: llc -O2 -mtriple powerpc64-ibm-aix-xcoff -stop-after=machine-cp -verify-machineinstrs < %s | \
+; RUN: FileCheck --check-prefixes=CHECK,64BIT %s
+
+; RUN: llc -O2 -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec \
+; RUN:  -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefixes=CHECKASM,ASM64PWR4 %s
+
+
+  @a = local_unnamed_addr global i32 1, align 4
+  @b = local_unnamed_addr global i32 2, align 4
+  @c = local_unnamed_addr global i32 3, align 4
+  @d = local_unnamed_addr global i32 4, align 4
+  @e = local_unnamed_addr global i32 5, align 4
+  @f = local_unnamed_addr global i32 6, align 4
+  @g = local_unnamed_addr global i32 7, align 4
+  @h = local_unnamed_addr global i32 8, align 4
+  @i = local_unnamed_addr global i32 9, align 4
+  @j = local_unnamed_addr global i32 10, align 4
+
+define signext i32 @va_arg1(i32 signext %a, ...) local_unnamed_addr {
+entry:
+  %arg = alloca i8*, align 8
+  %0 = bitcast i8** %arg to i8*
+  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)
+  call void @llvm.va_start(i8* nonnull %0)
+  %cmp7 = icmp sgt i32 %a, 0
+  br i1 %cmp7, label %for.body.preheader, label %for.end
+
+for.body.preheader:
+  %argp.cur.pre = load i8*, i8** %arg, align 8
+  %1 = add i32 %a, -1
+  %2 = zext i32 %1 to i64
+  %3 = add nuw nsw i64 %2, 1
+  %min.iters.check = icmp ult i32 %1, 8
+  br i1 %min.iters.check, label %for.body.preheader28, label %vector.memcheck
+
+vector.memcheck:
+  %uglygep = getelementptr inbounds i8, i8* %0, i64 1
+  %scevgep = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %4 = shl nuw nsw i64 %2, 3
+  %5 = add nuw nsw i64 %4, 8
+  %scevgep11 = getelementptr i8, i8* %argp.cur.pre, i64 %5
+  %bound0 = icmp ugt i8* %scevgep11, %0
+  %bound1 = icmp ult i8* %scevgep, %uglygep
+  %found.conflict = and i1 %bound0, %bound1
+  br i1 %found.conflict, label %for.body.preheader28, label %vector.ph
+
+vector.ph:
+  %n.mod.vf = and i64 %3, 7
+  %6 = icmp eq i64 %n.mod.vf, 0
+  %7 = select i1 %6, i64 8, i64 %n.mod.vf
+  %n.vec = sub nsw i64 %3, %7
+  %8 = shl nsw i64 %n.vec, 3
+  %ind.end = getelementptr i8, i8* %argp.cur.pre, i64 %8
+  %ind.end13 = trunc i64 %n.vec to i32
+  %next.gep = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %next.gep17 = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %next.gep20 = getelementptr i8, i8* %argp.cur.pre, i64 8
+  br label %vector.body
+
+vector.body:
+  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+  %vec.phi = phi <4 x i32> [ , %vector.ph ], [ %19, %vector.body ]
+  %vec.phi21 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %20, %vector.body ]
+  %9 = shl i64 %index, 3
+  %10 = shl i64 %index, 3
+  %11 = or i64 %10, 32
+  %12 = shl i64 %index, 3
+  %13 = or i64 %12, 56
+  %14 = getelementptr inbounds i8, i8* %next.gep20, i64 %13
+  %15 = getelementptr inbounds i8, i8* %next.gep, i64 %9
+  %16 = getelementptr inbounds i8, i8* %next.gep17, i64 %11
+  %17 = bitcast i8* %15 to <8 x i32>*
+  %18 = bitcast i8* %16 to <8 x i32>*
+  %wide.vec = load <8 x i32>, <8 x i32>* %17, align 4
+  %wide.vec23 = load <8 x i32>, <8 x i32>* %18, align 4
+  %strided.vec = shufflevector <8 x i32> %wide.vec, <8 x i32> undef, <4 x i32> 
+  %strided.vec24 = shufflevector <8 x i32> %wide.vec23, <8 x i32> undef, <4 x i32> 
+  %19 = add <4 x i32> %strided.vec, %vec.phi
+  %20 = add <4 x i32> %strided.vec24, %vec.phi21
+  %index.next = add i64 %index, 8
+  %21 = icmp eq i64 %index.next, %n.vec
+  br i1 %21, label %middle.block, label %vector.body
+
+middle.block:
+  store i8* %14, i8** %arg, align 8
+  %bin.rdx = add <4 x i32> %20, %19
+  %rdx.shuf = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> 
+  %bin.rdx25 = add <4 x i32> %bin.rdx, %rdx.shuf
+  %rdx.shuf26 = shufflevector <4 x i32> %bin.rdx25, <4 x i32> undef, <4 x i32> 
+  %bin.rdx27 = add <4 x i32> %bin.rdx25, %rdx.shuf26
+  %22 = extractelement <4 x i32> %bin.rdx27, i32 0
+  br label %for.body.preheader28
+
+for.body.preheader28:
+  %argp.cur.ph = phi i8* [ %argp.cur.pre, %vector.memcheck ], [ %argp.cur.pre, %for.body.preheader ], [ %ind.end, %middle.block ]
+  %total.09.ph = phi i32 [ undef, %vector.memcheck ], [ undef, %for.body.preheader ], [ %22, %middle.block ]
+  %i.08.ph = phi i32 [ 0, %vector.memcheck ], [ 0, %for.body.preheader ], [ %ind.end13

[PATCH] D76385: Allow remapping Clang module include paths

2020-03-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 251411.
aprantl added a comment.

Don't try to be too clever.


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

https://reviews.llvm.org/D76385

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/Modules/debug-info-moduleimport.m


Index: clang/test/Modules/debug-info-moduleimport.m
===
--- clang/test/Modules/debug-info-moduleimport.m
+++ clang/test/Modules/debug-info-moduleimport.m
@@ -34,9 +34,11 @@
 
 // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps \
 // RUN:   -fmodules-cache-path=%t -fdebug-prefix-map=%t=/MODULE-CACHE \
+// RUN:   -fdebug-prefix-map=%S=/SRCDIR \
 // RUN:   -fmodule-format=obj -dwarf-ext-refs \
 // RUN:   %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=SKEL-CHECK
+// SKEL-CHECK: includePath: "/SRCDIR/Inputs"
 // SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]]
 // SKEL-CHECK: ![[CUFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR:.*]]"
 // SKEL-CHECK: distinct !DICompileUnit({{.*}}file: 
![[DWOFILE:[0-9]+]]{{.*}}splitDebugFilename: "/MODULE-CACHE{{.*}}dwoId
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2483,6 +2483,14 @@
 assert(StringRef(M->Name).startswith(CGM.getLangOpts().ModuleName) &&
"clang module without ASTFile must be specified by -fmodule-name");
 
+  // Return a StringRef to the remapped Path.
+  auto RemapPath = [&](std::string Path) -> std::string {
+Path = remapDIPath(Path);
+StringRef Relative(Path);
+Relative.consume_front(TheCU->getDirectory());
+return Relative.str();
+  };
+
   if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
@@ -2492,14 +2500,12 @@
 ? (uint64_t)Mod.getSignature()[1] << 32 | Mod.getSignature()[0]
 : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-std::string PCM = remapDIPath(Mod.getASTFile());
-StringRef RelativePCM(PCM);
-RelativePCM.consume_front(TheCU->getDirectory());
+std::string PCM = Mod.getASTFile().str();
 DIB.createCompileUnit(
 TheCU->getSourceLanguage(),
 // TODO: Support "Source" from external AST providers?
 DIB.createFile(Mod.getModuleName(), TheCU->getDirectory()),
-TheCU->getProducer(), false, StringRef(), 0, RelativePCM,
+TheCU->getProducer(), false, StringRef(), 0, RemapPath(PCM),
 llvm::DICompileUnit::FullDebug, Signature);
 DIB.finalize();
   }
@@ -2508,9 +2514,10 @@
   IsRootModule ? nullptr
: getOrCreateModuleRef(ASTSourceDescriptor(*M->Parent),
   CreateSkeletonCU);
+  std::string IncludePath = Mod.getPath().str();
   llvm::DIModule *DIMod =
   DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
-Mod.getPath());
+RemapPath(IncludePath));
   ModuleCache[M].reset(DIMod);
   return DIMod;
 }


Index: clang/test/Modules/debug-info-moduleimport.m
===
--- clang/test/Modules/debug-info-moduleimport.m
+++ clang/test/Modules/debug-info-moduleimport.m
@@ -34,9 +34,11 @@
 
 // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps \
 // RUN:   -fmodules-cache-path=%t -fdebug-prefix-map=%t=/MODULE-CACHE \
+// RUN:   -fdebug-prefix-map=%S=/SRCDIR \
 // RUN:   -fmodule-format=obj -dwarf-ext-refs \
 // RUN:   %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=SKEL-CHECK
+// SKEL-CHECK: includePath: "/SRCDIR/Inputs"
 // SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]]
 // SKEL-CHECK: ![[CUFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR:.*]]"
 // SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[DWOFILE:[0-9]+]]{{.*}}splitDebugFilename: "/MODULE-CACHE{{.*}}dwoId
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2483,6 +2483,14 @@
 assert(StringRef(M->Name).startswith(CGM.getLangOpts().ModuleName) &&
"clang module without ASTFile must be specified by -fmodule-name");
 
+  // Return a StringRef to the remapped Path.
+  auto RemapPath = [&](std::string Path) -> std::string {
+Path = remapDIPath(Path);
+StringRef Relative(Path);
+Relative.consume_front(TheCU->getDirectory());
+return Relative.str();
+  };
+
   if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {
 // PCH files don't have a signature field in the control block,
 //

[PATCH] D76393: Allow remapping the sysroot with -fdebug-prefix-map.

2020-03-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 251412.
aprantl added a comment.
Herald added a subscriber: hiraditya.

Don't try to be too clever with the strings.


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

https://reviews.llvm.org/D76393

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c
  llvm/lib/DWARFLinker/DWARFLinker.cpp


Index: llvm/lib/DWARFLinker/DWARFLinker.cpp
===
--- llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -1914,12 +1914,13 @@
   return 0;
 }
 
-static std::string remapPath(StringRef Path,
+static std::string remapPath(std::string Path,
  const objectPrefixMap &ObjectPrefixMap) {
+  StringRef PathRef(Path);
   for (const auto &Entry : ObjectPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (PathRef.startswith(Entry.first))
+  return (Twine(Entry.second) + PathRef.substr(Entry.first.size())).str();
+  return Path;
 }
 
 bool DWARFLinker::registerModuleReference(
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
 // RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
 // RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
@@ -40,3 +41,4 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: 
"/UNLIKELY_PATH/empty")
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: 
"/UNLIKELY_PATH/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
+// CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "/UNLIKELY_PATH/empty"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -631,7 +631,7 @@
   ? llvm::DICompileUnit::DebugNameTableKind::None
   : static_cast(
 CGOpts.DebugNameTable),
-  CGOpts.DebugRangesBaseAddress, Sysroot, SDK);
+  CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {


Index: llvm/lib/DWARFLinker/DWARFLinker.cpp
===
--- llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -1914,12 +1914,13 @@
   return 0;
 }
 
-static std::string remapPath(StringRef Path,
+static std::string remapPath(std::string Path,
  const objectPrefixMap &ObjectPrefixMap) {
+  StringRef PathRef(Path);
   for (const auto &Entry : ObjectPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (PathRef.startswith(Entry.first))
+  return (Twine(Entry.second) + PathRef.substr(Entry.first.size())).str();
+  return Path;
 }
 
 bool DWARFLinker::registerModuleReference(
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
 // RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=/UNLIKEL

[PATCH] D66094: [CodeGen] Emit destructor calls for non-trivial C structs returned by function calls and loaded from volatile objects

2020-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:677
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+Cleanup.setExprNeedsCleanups(true);
+

ahatanak wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > ahatanak wrote:
> > > > > rjmccall wrote:
> > > > > > Why only when the l-value is volatile?
> > > > > I was trying to avoid emitting `ExprWithCleanups` when it wasn't 
> > > > > needed and it seemed that it wasn't needed for non-volatile types. 
> > > > > I'm not sure it's important, so I've removed the check for volatile. 
> > > > > Also, `ExprWithCleanups` shouldn't' be emitted when this is in file 
> > > > > scope, so I fixed that too.
> > > > Hmm, not sure about this file-scope thing, since the combination of C++ 
> > > > dynamic initializers and statement-expressions means  we can have 
> > > > pretty unrestricted code there.
> > > I should have explained why this was needed, but I wanted to prevent 
> > > emitting `ExprWithCleanups` in the following example:
> > > 
> > > ```
> > > struct A {
> > >   id f0;
> > > };
> > > 
> > > typedef struct A A;
> > > 
> > > A g = (A){ .f0 = 0 };
> > > ```
> > > 
> > > The l-value to r-value conversion happens here because compound literals 
> > > are l-values. Since `g` is a global of a non-trivial C struct type, we 
> > > shouldn't try to push a cleanup and destruct the object.
> > > 
> > > We don't have to think about the C++ case since the line below checks the 
> > > type is a non-trivial C type. I didn't think about statement expressions, 
> > > but they aren't allowed in file scope, so I guess that's not a problem 
> > > either.
> > I would hope that the constant-evaluator here might be smart enough to 
> > ignore some elidable temporaries.
> Do you mean the constant-evaluator should evaluate initializers that are 
> `ExprWithCleanups` to constants in a case like this?  It's possible to do so 
> by seeing whether the sub-expression of `ExprWithCleanups` is constant, but 
> it looks like we also have to set the `CleanupInfo::CleanupsHaveSideEffects` 
> flag to false when it's a file scope expression so that 
> `ConstExprEmitter::VisitExprWithCleanups` can constant-fold the 
> `ExprWithCleanups` initializer.
In this case, what we're doing is eliding a "temporary" (really an object with 
wider lifetime, but if the object isn't referenceable, we can compile as-if the 
object is really temporary) and therefore bypassing the need for a cleanup 
entirely.  I wouldn't expect the AST to change to reflect that this is 
possible, just the constant evaluator.  Basically, it needs to look through 
`ExprWithCleanups`; we probably already peephole the 
`LValueToRValue(CompoundLiteralExpr)` combination.

We do try to do constant-evaluation on local initializers as well as an 
optimization, and abstractly that should also work with these constructs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66094



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


[PATCH] D76396: Allow immediate invocation of constructors

2020-03-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D76396#1930773 , @Tyker wrote:

> I have already a patch aiming to do the same thing. D74007 
> 


Thanks. Sorry I dropped the ball on that one. =/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76396



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/unique-internal-funcnames.c:3
+
+// RUN: %clang -target x86_64 -S -o - %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang -target x86_64 -S -funique-internal-funcnames -o -  %s | 
FileCheck %s --check-prefix=UNIQUE

You can hardly find any .c -> .s test in clang/test. We mostly do .c -> .ll 
testing. `.ll` -> `.s` are in llvm/test/CodeGen. 


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

https://reviews.llvm.org/D73307



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


[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-03-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4176
+/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ABI information, used by PowerPC 
ELF
+/// (SVR4), Darwin and AIX.
 class PPC32_SVR4_ABIInfo : public DefaultABIInfo {

I would suggest using an "Oxford comma" before the "and". Also, colon instead 
of comma before "used".



Comment at: clang/test/CodeGen/aix-vararg.c:4
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | 
FileCheck %s --check-prefix=32BIT
+#include 
+

ZarkoCA wrote:
> hubert.reinterpretcast wrote:
> > Can we use built-in types and functions in place of a header inclusion?
> I'm worried about legal/copyright issues with using contents from AIX system 
> headers to LLVM testcases. But I can do that for sure once I understand what 
> I am allowed to do.   
I just mean:
`__builtin_va_list`
`__builtin_va_start`
`__builtin_va_copy`
`__builtin_va_arg`
`__builtin_va_end`



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

https://reviews.llvm.org/D76360



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


[PATCH] D76098: [clangd] Do not trigger go-to-def textual fallback inside string literals

2020-03-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 251418.
nridge added a comment.

Take a blacklisting approach


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76098

Files:
  clang-tools-extra/clangd/XRefs.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
@@ -628,7 +628,8 @@
 // Comment mentioning M^yClass
   )cpp",
   R"cpp(// String
-struct [[MyClass]] {};
+struct MyClass {};
+// Not triggered for string literal tokens.
 const char* s = "String literal mentioning M^yClass";
   )cpp",
   R"cpp(// Ifdef'ed out code
@@ -680,7 +681,7 @@
   EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
 }
   }
-}
+} // namespace
 
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -374,6 +374,17 @@
   unsigned WordOffset = Word.data() - Code.data();
   SourceLocation WordStart = SM.getComposedLoc(File, WordOffset);
 
+  // Attempt to determine the kind of token that contains the word,
+  // and bail if it's a string literal. Note that we cannot always
+  // determine the token kind (e.g. comments, for which we do want
+  // to activate, are not retained by TokenBuffer).
+  for (syntax::Token T : syntax::spelledTokensTouching(Loc, AST.getTokens())) {
+if (T.range(AST.getSourceManager()).touches(WordOffset + Word.size())) {
+  if (isStringLiteral(T.kind()))
+return {};
+}
+  }
+
   // Do not consider tokens that survived preprocessing.
   // We are erring on the safe side here, as a user may expect to get
   // accurate (as opposed to textual-heuristic) results for such tokens.


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -628,7 +628,8 @@
 // Comment mentioning M^yClass
   )cpp",
   R"cpp(// String
-struct [[MyClass]] {};
+struct MyClass {};
+// Not triggered for string literal tokens.
 const char* s = "String literal mentioning M^yClass";
   )cpp",
   R"cpp(// Ifdef'ed out code
@@ -680,7 +681,7 @@
   EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
 }
   }
-}
+} // namespace
 
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -374,6 +374,17 @@
   unsigned WordOffset = Word.data() - Code.data();
   SourceLocation WordStart = SM.getComposedLoc(File, WordOffset);
 
+  // Attempt to determine the kind of token that contains the word,
+  // and bail if it's a string literal. Note that we cannot always
+  // determine the token kind (e.g. comments, for which we do want
+  // to activate, are not retained by TokenBuffer).
+  for (syntax::Token T : syntax::spelledTokensTouching(Loc, AST.getTokens())) {
+if (T.range(AST.getSourceManager()).touches(WordOffset + Word.size())) {
+  if (isStringLiteral(T.kind()))
+return {};
+}
+  }
+
   // Do not consider tokens that survived preprocessing.
   // We are erring on the safe side here, as a user may expect to get
   // accurate (as opposed to textual-heuristic) results for such tokens.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76438: ConstantExpr cached APValues if present for constant evaluation

2020-03-19 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders created this revision.
wchilders added reviewers: Tyker, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch allows the constant evaluator to use `APValueResult`s from 
`ConstantExpr`s.

There are some outstanding concerns I'll mark with inline comments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76438

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6751,8 +6751,13 @@
 return Error(E);
   }
 
-  bool VisitConstantExpr(const ConstantExpr *E)
-{ return StmtVisitorTy::Visit(E->getSubExpr()); }
+  bool VisitConstantExpr(const ConstantExpr *E) {
+if (E->hasAPValueResult())
+  return DerivedSuccess(E->getAPValueResult(), E);
+
+return StmtVisitorTy::Visit(E->getSubExpr());
+  }
+
   bool VisitParenExpr(const ParenExpr *E)
 { return StmtVisitorTy::Visit(E->getSubExpr()); }
   bool VisitUnaryExtension(const UnaryOperator *E)
@@ -7317,6 +7322,16 @@
 return true;
   }
 
+  bool VisitConstantExpr(const ConstantExpr *E) {
+if (E->hasAPValueResult()) {
+  APValue Result = E->getAPValueResult();
+  if (Result.isLValue())
+return Success(Result, E);
+}
+
+return ExprEvaluatorBaseTy::Visit(E->getSubExpr());
+  }
+
   bool VisitMemberExpr(const MemberExpr *E) {
 // Handle non-static data members.
 QualType BaseTy;
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -356,6 +356,8 @@
 }
 
 APValue ConstantExpr::getAPValueResult() const {
+  assert(hasAPValueResult());
+
   switch (ConstantExprBits.ResultKind) {
   case ConstantExpr::RSK_APValue:
 return APValueResult();
@@ -2870,9 +2872,6 @@
   return CE->getChosenSubExpr();
   }
 
-  else if (auto *CE = dyn_cast(E))
-return CE->getSubExpr();
-
   return E;
 }
 
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1063,6 +1063,9 @@
   bool isImmediateInvocation() const {
 return ConstantExprBits.IsImmediateInvocation;
   }
+  bool hasAPValueResult() const {
+return ConstantExprBits.APValueKind != APValue::None;
+  }
   APValue getAPValueResult() const;
   APValue &getResultAsAPValue() const { return APValueResult(); }
   llvm::APSInt getResultAsAPSInt() const;


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6751,8 +6751,13 @@
 return Error(E);
   }
 
-  bool VisitConstantExpr(const ConstantExpr *E)
-{ return StmtVisitorTy::Visit(E->getSubExpr()); }
+  bool VisitConstantExpr(const ConstantExpr *E) {
+if (E->hasAPValueResult())
+  return DerivedSuccess(E->getAPValueResult(), E);
+
+return StmtVisitorTy::Visit(E->getSubExpr());
+  }
+
   bool VisitParenExpr(const ParenExpr *E)
 { return StmtVisitorTy::Visit(E->getSubExpr()); }
   bool VisitUnaryExtension(const UnaryOperator *E)
@@ -7317,6 +7322,16 @@
 return true;
   }
 
+  bool VisitConstantExpr(const ConstantExpr *E) {
+if (E->hasAPValueResult()) {
+  APValue Result = E->getAPValueResult();
+  if (Result.isLValue())
+return Success(Result, E);
+}
+
+return ExprEvaluatorBaseTy::Visit(E->getSubExpr());
+  }
+
   bool VisitMemberExpr(const MemberExpr *E) {
 // Handle non-static data members.
 QualType BaseTy;
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -356,6 +356,8 @@
 }
 
 APValue ConstantExpr::getAPValueResult() const {
+  assert(hasAPValueResult());
+
   switch (ConstantExprBits.ResultKind) {
   case ConstantExpr::RSK_APValue:
 return APValueResult();
@@ -2870,9 +2872,6 @@
   return CE->getChosenSubExpr();
   }
 
-  else if (auto *CE = dyn_cast(E))
-return CE->getSubExpr();
-
   return E;
 }
 
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1063,6 +1063,9 @@
   bool isImmediateInvocation() const {
 return ConstantExprBits.IsImmediateInvocation;
   }
+  bool hasAPValueResult() const {
+return ConstantExprBits.APValueKind != APValue::None;
+  }
   APValue getAPValueResult() const;
   APValue &getResultAsAPValue() const { return APValueResult(); }
   llvm::APSInt getResultAsAPSInt() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76438: ConstantExpr cached APValues if present for constant evaluation

2020-03-19 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders added inline comments.



Comment at: clang/lib/AST/Expr.cpp:2875
 
-  else if (auto *CE = dyn_cast(E))
-return CE->getSubExpr();
-
   return E;
 }

`IgnoreParensSingleStep` for some reason has been unwrapping `ConstantExpr`s. 
This results in the constant evaluator, removing the ConstantExpr, and 
reevaluating the expression. There are no observed downsides to removing this 
condition, in the test suite, however, it's strange enough to note.



Comment at: clang/lib/AST/ExprConstant.cpp:7329
+  if (Result.isLValue())
+return Success(Result, E);
+}

This doesn't seem to be the right answer, and `ConstantExpr`s don't have 
`LValue` `APValue`s, at least, not that are reaching this case. We had a 
previous implementation that also, kind of punted on this issue with an 
override in `TemporaryExprEvaluator`: 
https://gitlab.com/lock3/clang/-/blob/9fbaeea06fc567ac472264bec2a72661a1e06c73/clang/lib/AST/ExprConstant.cpp#L9753


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76438



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


[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX

2020-03-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:7076
+static const MCPhysReg GPR_64[] = {PPC::X3, PPC::X4, PPC::X5, PPC::X6,
+   PPC::X7, PPC::X8, PPC::X9, PPC::X10};
+unsigned const NumGPArgRegs = array_lengthof(GPR_32);

jasonliu wrote:
> This two array gets used to in CC_AIX and here. It would be great if we only 
> have one set of copy. 
I agree, but the array is local to CC_AIX as far as I understand and there is 
not a good way to access it from here without having to modify CC_AIX.  I think 
it would be a good to do it at a later point when it's not undergoing so much 
change already. 



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:7014
 
 if (VA.isRegLoc()) {
   MVT::SimpleValueType SVT = ValVT.getSimpleVT().SimpleTy;

jasonliu wrote:
> Do we need  `&& !VA.needsCustom() ` here?
Yes, it's better if I add it, thanks.



Comment at: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll:1
+; RUN: llc -O2 -mtriple powerpc-ibm-aix-xcoff -stop-after=machine-cp 
-mattr=-altivec -verify-machineinstrs < %s | \
+; RUN: FileCheck --check-prefixes=CHECK,32BIT %s

jasonliu wrote:
> Do we need '-O2' specified here and below?
It makes the IR and assembly much cleaner and easier to read, imo. 



Comment at: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll:7
+; RUN: FileCheck --check-prefixes=CHECKASM,ASM32PWR4 %s
+
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)

jasonliu wrote:
> A general comment about how to test va_arg.
> I think the two test cases we have here are not enough. 
> On top of my head I would probably add in getting double as va_arg argument, 
> uses of va_copy and so on. 
> It's probably worth checking how other targets test va_arg. Grep "va_start" 
> in llvm/test/CodeGen would give you a lot of hit. 
Yes, I can clean up the tests and add more.  Agreed we need more and I can 
simplify them so it's clear what's being tested. 



Comment at: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll:15
+
+@a = local_unnamed_addr global i32 1, align 4
+@b = local_unnamed_addr global i32 2, align 4

jasonliu wrote:
> These variables didn't get used anywhere.
Removed, but as I said earlier, I'll also do a rework of the tests. 



Comment at: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll:27
+; Function Attrs: nounwind
+define i32 @va_arg1(i32 %a, ...) local_unnamed_addr {
+entry:

jasonliu wrote:
> These tests used for loops to call va_arg mutliple times. 
> Maybe it's just me, but I found the test cases are much harder to read. 
> I would suggest maybe just unroll the for loop and generate as much as the 
> va_arg call that you need? 
> 
> For the cases below, I suppose you would want to call va_arg 9 times, and 2 
> times respectfully. Maybe it's not that bad. If the tests gets too long, you 
> could consider split the tests into separate files. 
Yes, see reply above, I will rework the tests. 



Comment at: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll:33
+  call void @llvm.va_start(i8* nonnull %0)
+  %cmp7 = icmp sgt i32 %a, 0
+  br i1 %cmp7, label %for.body.preheader, label %for.end

jasonliu wrote:
> a is 1, so we would only call va_arg once, despite we have 9 vaarg argument. 
> Is this the intention of the test?
a = 1 doesn't mean we call va_arg once. This is the IR for the function 
definition that I got using this c code (modified for this example): 
```
a = 1;
int va_arg1(int a,...) {
...
}
```
The callee doesn't know how many vararg arguments will be called, just does the 
setup for the variadic parameter (...) in the IR. 



Comment at: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll:162
+  %add7 = add nsw i32 %add6, %eight
+  %cmp15 = icmp sgt i32 %eight, 0
+  br i1 %cmp15, label %for.body.preheader, label %for.end

jasonliu wrote:
> We only have 2 va_arg arguments here, but we called va_arg 8 times? I think 
> that's undefined behavior. 
Seem my reply above.  That said, there is some confusion with respect to tests 
and they'll be reworked.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76130



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


[PATCH] D76416: [ASan] Apply -ffile-prefix-map mappings to ASan instrumentation

2020-03-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 251421.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76416

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/asan-globals-file-prefix-map.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/asan_file_prefix_map.ll
  llvm/test/Instrumentation/AddressSanitizer/asan_no_file_prefix_map.ll

Index: llvm/test/Instrumentation/AddressSanitizer/asan_no_file_prefix_map.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan_no_file_prefix_map.ll
@@ -0,0 +1,20 @@
+; RUN: opt < %s -asan -asan-module -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@global = global i32 0, align 4
+@global2 = global i32 0, align 4
+
+; Check that the string used for the source location has its original prefix.
+; CHECK: @___asan_gen_.{{[0-9]+}} = private unnamed_addr constant [22 x i8] c"/tmp/asan-globals.cpp\00", align 1
+; CHECK: @___asan_gen_.{{[0-9]+}} = private unnamed_addr constant [22 x i8] c"blah/asan-globals.cpp\00", align 1
+
+!llvm.asan.globals = !{!0, !1}
+!101 = !{!"/tmp", !"/some/other/tmp"}
+!102 = !{!"blah", !"../some/other/blah"}
+
+!0 = !{i32* @global, !6, !"global", i1 false, i1 false}
+!1 = !{i32* @global2, !7, !"global2", i1 false, i1 false}
+
+!6 = !{!"/tmp/asan-globals.cpp", i32 5, i32 5}
+!7 = !{!"blah/asan-globals.cpp", i32 5, i32 5}
Index: llvm/test/Instrumentation/AddressSanitizer/asan_file_prefix_map.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan_file_prefix_map.ll
@@ -0,0 +1,21 @@
+; RUN: opt < %s -asan -asan-module -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@global = global i32 0, align 4
+@global2 = global i32 0, align 4
+
+; Check that the string used for the source location has it's prefix replaced if llvm.asan.file.prefix.map is present.
+; CHECK: @___asan_gen_.{{[0-9]+}} = private unnamed_addr constant [33 x i8] c"/some/other/tmp/asan-globals.cpp\00", align 1
+; CHECK: @___asan_gen_.{{[0-9]+}} = private unnamed_addr constant [36 x i8] c"../some/other/blah/asan-globals.cpp\00", align 1
+
+!llvm.asan.globals = !{!0, !1}
+!llvm.asan.file.prefix.map = !{!101, !102}
+!101 = !{!"/tmp", !"/some/other/tmp"}
+!102 = !{!"blah", !"../some/other/blah"}
+
+!0 = !{i32* @global, !6, !"global", i1 false, i1 false}
+!1 = !{i32* @global2, !7, !"global2", i1 false, i1 false}
+
+!6 = !{!"/tmp/asan-globals.cpp", i32 5, i32 5}
+!7 = !{!"blah/asan-globals.cpp", i32 5, i32 5}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1151,6 +1151,26 @@
 mdconst::extract(MDN->getOperand(4));
 E.IsBlacklisted |= IsBlacklisted->isOne();
   }
+
+  // Go through the file prefix map to replace prefixes in metadata that may
+  // contain filepaths. Do this once in the globals metadata pass so we don't
+  // need to run over the map in ASan for each metadata instance.
+  NamedMDNode *PrefixMap = M.getNamedMetadata("llvm.asan.file.prefix.map");
+  if (!PrefixMap)
+return;
+  for (auto &Entry : Entries) {
+for (auto *MDN : PrefixMap->operands()) {
+  assert(MDN->getNumOperands() == 2 &&
+ "Each node in the prefix map should be a pair");
+  StringRef Prefix = cast(MDN->getOperand(0))->getString();
+  StringRef Replacement = cast(MDN->getOperand(1))->getString();
+  if (llvm::sys::path::replace_path_prefix(
+  Entry.second.SourceLoc.Filename, Prefix, Replacement,
+  llvm::sys::path::Style::native, true)) {
+break;
+  }
+}
+  }
 }
 
 AnalysisKey ASanGlobalsMetadataAnalysis::Key;
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -22,7 +22,7 @@
 
 /// Frontend-provided metadata for source location.
 struct LocationMetadata {
-  StringRef Filename;
+  llvm::SmallString<64> Filename;
   int LineNo = 0;
   int ColumnNo = 0;
 
Index: clang/test/CodeGen/asan-globals-file-prefix-map.cpp
===
--- /dev/null
+++ clang/test/CodeGen/asan-globals-file-prefix-map.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsanitize=address -ffile-prefix-map=%S=/t

[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D74918#1931488 , @zoecarver wrote:

> @lebedev.ri LLVM may be better, I'm not sure. If you feel strongly I can move 
> it.


I do think that it makes much more sense somewhere closer to the backend

> @jyknight I'm planning on adding a builtin that uses this method. I can put 
> the patch up for that first if you would like.

but that being said, currently nothing needs that and with all those concerns 
about exposing this info,
i'd hold off moving it until it is settled whether it is needed (and not a dead 
code) in the first place :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74918



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1129
+  // should get unique names.  Use the hash of module name to get a unique
+  // identifier and this is a best effort.
+  if (getCodeGenOpts().UniqueInternalFuncNames &&

maybe
`identifier as this is a best-effort solution`




Comment at: clang/test/CodeGen/unique-internal-funcnames.c:16
+// UNIQUE-NOT: foo:
+// UNIQUE: foo.{{[0-9a-f]+}}:

What does `getModule().getSourceFileName()` contain?
The full path to the source file, or just the source file basename?
If latter, maybe check the full name?


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

https://reviews.llvm.org/D73307



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


[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-03-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/include/clang/Basic/AArch64SVETypeFlags.h:72
+  bool isStructStore() const { return Flags & IsStructStore; }
+  bool isZxtReturn() const { return Flags & IsZxtReturn; }
+

SjoerdMeijer wrote:
> nit: this one is non obvious (at least to me), so perhaps worth a comment 
> what this is. I can guess that Zext means zero extending, but you know, the 
> context...
"Zxt" is not a standard abbreviation in LLVM: please use "Zext", or 
"ZeroExtend".



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7471
+
+Value *CodeGenFunction::EmitSVEMaskedStore(llvm::Type *ReturnTy,
+   SmallVectorImpl &Ops,

ReturnTy is unused?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7475
+  llvm::PointerType *PTy = cast(Ops[1]->getType());
+  llvm::Type *MemEltTy = PTy->getPointerElementType();
+

Please avoid using getPointerElementType where possible... it will interfere 
with opaque pointer types work.  (You should be able to get the element type 
from the AST.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76238



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-19 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

As far as I understand, this is not a propeller specific patch, but it fixes a 
general problem in AFDO as well. Perhaps change the summary to reflect that?


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

https://reviews.llvm.org/D73307



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


[clang] a983562 - Precommit test for clang::CallGraph declared functions.

2020-03-19 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-19T12:00:30-07:00
New Revision: a983562b23458777a7226ec6cfe41cbeb9d291de

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

LOG: Precommit test for clang::CallGraph declared functions.

https://reviews.llvm.org/D76435 fixes this problem, functions that are
being declared but ARE called aren't entered into the callgraph.

Added: 


Modified: 
clang/test/Analysis/debug-CallGraph.cpp

Removed: 




diff  --git a/clang/test/Analysis/debug-CallGraph.cpp 
b/clang/test/Analysis/debug-CallGraph.cpp
index 0f5a83b268a0..5453e2f21533 100644
--- a/clang/test/Analysis/debug-CallGraph.cpp
+++ b/clang/test/Analysis/debug-CallGraph.cpp
@@ -81,8 +81,26 @@ namespace Lambdas {
   }
 }
 
+namespace CallDecl {
+  void SomeDecl();
+  void SomeOtherDecl();
+  void SomeDef() {}
+
+  void Caller() {
+SomeDecl();
+SomeOtherDecl();
+  }
+
+  void SomeOtherDecl() {
+SomeDef();
+  }
+}
+
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ 
SomeNS::templUser Lambdas::Callee Lambdas::f1 Lambdas::f1\(\)::\(anonymous 
class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ 
SomeNS::templUser Lambdas::Callee Lambdas::f1 Lambdas::f1\(\)::\(anonymous 
class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) 
CallDecl::SomeDef CallDecl::Caller CallDecl::SomeOtherDecl $}}
+// CHECK-NEXT: {{Function: CallDecl::Caller calls: CallDecl::SomeOtherDecl $}}
+// CHECK-NEXT: {{Function: CallDecl::SomeOtherDecl calls: CallDecl::SomeDef $}}
+// CHECK-NEXT: {{Function: CallDecl::SomeDef calls: $}}
 // CHECK-NEXT: {{Function: Lambdas::f1 calls: Lambdas::f1\(\)::\(anonymous 
class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) $}}
 // CHECK-NEXT: {{Function: Lambdas::f1\(\)::\(anonymous class\)::operator\(\) 
calls: Lambdas::Callee $}}
 // CHECK-NEXT: {{Function: Lambdas::f1\(\)::\(anonymous class\)::operator\(\) 
calls: Lambdas::Callee $}}



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-19 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1129
+  // should get unique names.  Use the hash of module name to get a unique
+  // identifier and this is a best effort.
+  if (getCodeGenOpts().UniqueInternalFuncNames &&

lebedev.ri wrote:
> maybe
> `identifier as this is a best-effort solution`
> 
Address review comment here.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1135
+llvm::MD5 Md5;
+Md5.update(getModule().getSourceFileName());
+llvm::MD5::MD5Result R;

Source filenames are not guaranteed to be unique, or it does contain the path 
as well?



Comment at: clang/test/CodeGen/unique-internal-funcnames.c:3
+
+// RUN: %clang -target x86_64 -S -o - %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang -target x86_64 -S -funique-internal-funcnames -o -  %s | 
FileCheck %s --check-prefix=UNIQUE

MaskRay wrote:
> You can hardly find any .c -> .s test in clang/test. We mostly do .c -> .ll 
> testing. `.ll` -> `.s` are in llvm/test/CodeGen. 
Is this convention documented somewhere? Any concerns of producing .s?


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

https://reviews.llvm.org/D73307



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


[PATCH] D76443: Use ConstantExpr cached APValues if present for code generation

2020-03-19 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders created this revision.
wchilders added reviewers: void, Tyker, rsmith.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
wchilders added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:1095
+// preventing the cached results from being used.
+if (!isa(fe)) {
+  enterFullExpression(fe);

This one is a bit weird, I think the comment explains it well, but I feel there 
should be a better way to handle this or if there are similar issues lurking 
elsewhere.


This patch allows code gen to use `APValue` Results from `ConstantExpr`s.

There are some outstanding concerns I'll mark with inline comments.

This is the codegen "sister patch" of: https://reviews.llvm.org/D76438


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76443

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h

Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1390,6 +1390,21 @@
   /// \param QT is the clang QualType of the null pointer.
   llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT);
 
+  /// Try to emit the given expression as a constant; returns 0 if the
+  /// expression cannot be emitted as a constant.
+  llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType,
+   CodeGenFunction *CGF = nullptr);
+
+  /// Emit the given constant value as a constant, in the type's scalar
+  /// representation.
+  llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType,
+CodeGenFunction *CGF = nullptr);
+
+  /// Emit the given constant value as a constant, in the type's memory
+  /// representation.
+  llvm::Constant *EmitConstantValueForMemory(const APValue &Value,
+ QualType DestType,
+ CodeGenFunction *CGF = nullptr);
 private:
   llvm::Constant *GetOrCreateLLVMFunction(
   StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2289,6 +2289,8 @@
 TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
+  llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType);
+
   /// CreateTempAlloca - This creates an alloca and inserts it into the entry
   /// block if \p ArraySize is nullptr, otherwise inserts it at the current
   /// insertion point of the builder. The caller is responsible for setting an
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2529,3 +2529,9 @@
 
   return llvm::DebugLoc();
 }
+
+
+llvm::Constant *CodeGenFunction::EmitConstantValue(const APValue& Value,
+   QualType DestType) {
+  return CGM.EmitConstantValue(Value, DestType, this);
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1089,8 +1089,13 @@
   // statements following block literals with non-trivial cleanups.
   RunCleanupsScope cleanupScope(*this);
   if (const FullExpr *fe = dyn_cast_or_null(RV)) {
-enterFullExpression(fe);
-RV = fe->getSubExpr();
+// Constant expressions will emit their cached APValues, so
+// we don't want to handle this here, as it will unwrap them,
+// preventing the cached results from being used.
+if (!isa(fe)) {
+  enterFullExpression(fe);
+  RV = fe->getSubExpr();
+}
   }
 
   // FIXME: Clean this up by using an LValue for ReturnTemp,
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -433,7 +433,12 @@
   Value *VisitExpr(Expr *S);
 
   Value *VisitConstantExpr(ConstantExpr *E) {
-return Visit(E->getSubExpr());
+if (E->hasAPValueResult()) {
+  assert(!E->getType()->isVoidType());
+  return CGF.EmitConstantValue(E->getAPValueResult(), E->getType());
+} else {
+  return Visit(E->getSubExpr());
+}
   }
   Value *VisitParenExpr(ParenExpr *PE) {
 return Visit(PE->getSubExpr());
Index: clang/lib/CodeGen/CGExprConstant.cpp
=

[PATCH] D76443: Use ConstantExpr cached APValues if present for code generation

2020-03-19 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:1095
+// preventing the cached results from being used.
+if (!isa(fe)) {
+  enterFullExpression(fe);

This one is a bit weird, I think the comment explains it well, but I feel there 
should be a better way to handle this or if there are similar issues lurking 
elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76443



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


[PATCH] D76444: Use FinishThunk to finish musttail thunks

2020-03-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: hans, rjmccall.
Herald added a project: clang.

FinishThunk, and the invariant of setting and then unsetting
CurCodeDecl, was added in 7f416cc42638 (2015). The invariant didn't
exist when I added this musttail codepath in ab2090d10765 (2014).
Recently in 28328c3771, I started using this codepath on non-Windows
platforms, and users reported problems during release testing (PR44987).

The issue was already present for users of EH on i686-windows-msvc, so I
added a test for that case as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76444

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/test/CodeGenCXX/ms-thunks-ehspec.cpp
  clang/test/CodeGenCXX/thunks-ehspec.cpp


Index: clang/test/CodeGenCXX/thunks-ehspec.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/thunks-ehspec.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions %s 
-triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 
-disable-llvm-passes | FileCheck %s
+
+// When generating the thunk for secondary, do not push terminate scopes for
+// either the varargs or non-varargs case. Related to PR44987.
+
+struct A {
+  virtual void primary_key();
+};
+struct B {
+  virtual void secondary();
+  virtual void secondary_vararg(int, ...);
+};
+class C : A, B {
+  virtual void primary_key();
+  void secondary() noexcept;
+  void secondary_vararg(int, ...) noexcept;
+};
+void C::primary_key() {}
+
+// CHECK-LABEL: define available_externally void 
@_ZThn8_N1C9secondaryEv(%class.C* %this)
+// CHECK-NOT: invoke
+// CHECK: tail call void @_ZN1C9secondaryEv(%class.C* %{{.*}})
+// CHECK-NOT: invoke
+// CHECK: ret void
+
+// CHECK-LABEL: define available_externally void 
@_ZThn8_N1C16secondary_varargEiz(%class.C* %this, i32 %0, ...)
+// CHECK-NOT: invoke
+// CHECK:  musttail call void (%class.C*, i32, ...) 
@_ZN1C16secondary_varargEiz(%class.C* %{{.*}}, i32 %{{.*}}, ...) #2
+// CHECK-NEXT:  ret void
Index: clang/test/CodeGenCXX/ms-thunks-ehspec.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-thunks-ehspec.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions %s -triple=i686-windows-msvc 
-emit-llvm -o - | FileCheck %s
+
+// When generating thunks using musttail due to inalloca parameters, don't push
+// and pop terminate scopes. PR44987
+
+struct NonTrivial {
+  NonTrivial();
+  NonTrivial(const NonTrivial &o);
+  ~NonTrivial();
+  int x;
+};
+struct A {
+  virtual void f(NonTrivial o) noexcept;
+};
+struct B {
+  virtual void f(NonTrivial o) noexcept;
+};
+class C : A, B {
+  virtual void f(NonTrivial o) noexcept;
+};
+C c;
+
+// CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void 
@"?f@C@@G3AEXUNonTrivial@@@Z"(%class.C* %this, <{ %struct.NonTrivial }>* 
inalloca %0)
+// CHECK-NOT: invoke
+// CHECK: musttail call x86_thiscallcc void 
@"?f@C@@EAEXUNonTrivial@@@Z"(%class.C* %{{.*}}, <{ %struct.NonTrivial }>* 
inalloca %0)
+// CHECK-NEXT  ret void
+
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -437,7 +437,8 @@
   // Finish the function to maintain CodeGenFunction invariants.
   // FIXME: Don't emit unreachable code.
   EmitBlock(createBasicBlock());
-  FinishFunction();
+
+  FinishThunk();
 }
 
 void CodeGenFunction::generateThunk(llvm::Function *Fn,
@@ -564,7 +565,7 @@
   CGM.SetLLVMFunctionAttributesForDefinition(GD.getDecl(), ThunkFn);
 
   // Thunks for variadic methods are special because in general variadic
-  // arguments cannot be perferctly forwarded. In the general case, clang
+  // arguments cannot be perfectly forwarded. In the general case, clang
   // implements such thunks by cloning the original function body. However, for
   // thunks with no return adjustment on targets that support musttail, we can
   // use musttail to perfectly forward the variadic arguments.


Index: clang/test/CodeGenCXX/thunks-ehspec.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/thunks-ehspec.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-passes | FileCheck %s
+
+// When generating the thunk for secondary, do not push terminate scopes for
+// either the varargs or non-varargs case. Related to PR44987.
+
+struct A {
+  virtual void primary_key();
+};
+struct B {
+  virtual void secondary();
+  virtual void secondary_vararg(int, ...);
+};
+class C : A, B {
+  virtual void primary_key();
+  void secondary() noexcept;
+  void secondary_vararg(int, ...) noexcept;
+};
+void C::primary_key() {}
+
+// CHECK-LABEL: define available_externally void @_ZThn8_N1C9secondaryEv(%class.C* %this)
+// CHECK-NOT: invoke
+// CHECK: tail call 

[clang] 430c9a8 - [Hexagon] Enable linux #defines

2020-03-19 Thread Sid Manning via cfe-commits

Author: Sid Manning
Date: 2020-03-19T14:33:49-05:00
New Revision: 430c9a80c17b00ec65b8254810e3c9e122d13f98

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

LOG: [Hexagon] Enable linux #defines

Enable standard linux defines when the triple is Linux and the
environment is musl.

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

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/test/Preprocessor/hexagon-predefines.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index c063f8ca4472..9181c715085e 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -117,6 +117,9 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
 return new XCoreTargetInfo(Triple, Opts);
 
   case llvm::Triple::hexagon:
+if (os == llvm::Triple::Linux &&
+Triple.getEnvironment() == llvm::Triple::Musl)
+  return new LinuxTargetInfo(Triple, Opts);
 return new HexagonTargetInfo(Triple, Opts);
 
   case llvm::Triple::lanai:

diff  --git a/clang/test/Preprocessor/hexagon-predefines.c 
b/clang/test/Preprocessor/hexagon-predefines.c
index 5be8b96e290d..54013ceffa64 100644
--- a/clang/test/Preprocessor/hexagon-predefines.c
+++ b/clang/test/Preprocessor/hexagon-predefines.c
@@ -101,3 +101,15 @@
 // RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck 
\
 // RUN: %s -check-prefix CHECK-ELF
 // CHECK-ELF: #define __ELF__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 -target-feature +hvxv67 \
+// RUN: -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-LINUX
+// CHECK-LINUX: #define __gnu_linux__ 1
+// CHECK-LINUX: #define __linux 1
+// CHECK-LINUX: #define __linux__ 1
+// CHECK-LINUX: #define __unix 1
+// CHECK-LINUX: #define __unix__ 1
+// CHECK-LINUX: #define linux 1
+// CHECK-LINUX: #define unix 1



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


[PATCH] D76310: [Hexagon] Add linux #defines when linux triple is selected

2020-03-19 Thread Sid Manning via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG430c9a80c17b: [Hexagon] Enable linux #defines (authored by 
sidneym).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76310

Files:
  clang/lib/Basic/Targets.cpp
  clang/test/Preprocessor/hexagon-predefines.c


Index: clang/test/Preprocessor/hexagon-predefines.c
===
--- clang/test/Preprocessor/hexagon-predefines.c
+++ clang/test/Preprocessor/hexagon-predefines.c
@@ -101,3 +101,15 @@
 // RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck 
\
 // RUN: %s -check-prefix CHECK-ELF
 // CHECK-ELF: #define __ELF__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 -target-feature +hvxv67 \
+// RUN: -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-LINUX
+// CHECK-LINUX: #define __gnu_linux__ 1
+// CHECK-LINUX: #define __linux 1
+// CHECK-LINUX: #define __linux__ 1
+// CHECK-LINUX: #define __unix 1
+// CHECK-LINUX: #define __unix__ 1
+// CHECK-LINUX: #define linux 1
+// CHECK-LINUX: #define unix 1
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -117,6 +117,9 @@
 return new XCoreTargetInfo(Triple, Opts);
 
   case llvm::Triple::hexagon:
+if (os == llvm::Triple::Linux &&
+Triple.getEnvironment() == llvm::Triple::Musl)
+  return new LinuxTargetInfo(Triple, Opts);
 return new HexagonTargetInfo(Triple, Opts);
 
   case llvm::Triple::lanai:


Index: clang/test/Preprocessor/hexagon-predefines.c
===
--- clang/test/Preprocessor/hexagon-predefines.c
+++ clang/test/Preprocessor/hexagon-predefines.c
@@ -101,3 +101,15 @@
 // RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck \
 // RUN: %s -check-prefix CHECK-ELF
 // CHECK-ELF: #define __ELF__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 -target-feature +hvxv67 \
+// RUN: -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-LINUX
+// CHECK-LINUX: #define __gnu_linux__ 1
+// CHECK-LINUX: #define __linux 1
+// CHECK-LINUX: #define __linux__ 1
+// CHECK-LINUX: #define __unix 1
+// CHECK-LINUX: #define __unix__ 1
+// CHECK-LINUX: #define linux 1
+// CHECK-LINUX: #define unix 1
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -117,6 +117,9 @@
 return new XCoreTargetInfo(Triple, Opts);
 
   case llvm::Triple::hexagon:
+if (os == llvm::Triple::Linux &&
+Triple.getEnvironment() == llvm::Triple::Musl)
+  return new LinuxTargetInfo(Triple, Opts);
 return new HexagonTargetInfo(Triple, Opts);
 
   case llvm::Triple::lanai:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-19 Thread Anna Thomas via Phabricator via cfe-commits
anna updated this revision to Diff 251447.
anna added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

fixed clang tests. rot-intrinsics.c testcase has 5 different RUNs with 3 
prefixes. Depending on target-triple, the attribute is added to the caller, so 
I've disabled the optimization for that specific test with 
-update-return-attrs=false


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140

Files:
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/movbe-builtins.c
  clang/test/CodeGen/rot-intrinsics.c
  clang/test/CodeGen/waitpkg.c
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Inline/ret_attr_update.ll

Index: llvm/test/Transforms/Inline/ret_attr_update.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/ret_attr_update.ll
@@ -0,0 +1,75 @@
+; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s
+; RUN: opt < %s -passes=always-inline -S | FileCheck %s
+
+declare i8* @foo(i8*)
+declare i8* @bar(i8*)
+
+define i8* @callee(i8 *%p) alwaysinline {
+; CHECK: @callee(
+; CHECK: call i8* @foo(i8* noalias %p)
+  %r = call i8* @foo(i8* noalias %p)
+  ret i8* %r
+}
+
+define i8* @caller(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller
+; CHECK: call nonnull i8* @foo(i8* noalias
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee(i8* %gep)
+  ret i8* %p
+}
+
+declare void @llvm.experimental.guard(i1,...)
+; Cannot add nonnull attribute to foo.
+define internal i8* @callee_with_throwable(i8* %p) alwaysinline {
+; CHECK-NOT: callee_with_throwable
+  %r = call i8* @foo(i8* %p)
+  %cond = icmp ne i8* %r, null
+  call void (i1, ...) @llvm.experimental.guard(i1 %cond) [ "deopt"() ]
+  ret i8* %r
+}
+
+; Here also we cannot add nonnull attribute to the call bar.
+define internal i8* @callee_with_explicit_control_flow(i8* %p) alwaysinline {
+; CHECK-NOT: callee_with_explicit_control_flow
+  %r = call i8* @bar(i8* %p)
+  %cond = icmp ne i8* %r, null
+  br i1 %cond, label %ret, label %orig
+
+ret:
+  ret i8* %r
+
+orig:
+  ret i8* %p
+}
+
+define i8* @caller2(i8* %ptr, i64 %x, i1 %cond) {
+; CHECK-LABEL: @caller2
+; CHECK: call i8* @foo
+; CHECK: call i8* @bar
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee_with_throwable(i8* %gep)
+  %q = call nonnull i8* @callee_with_explicit_control_flow(i8* %gep)
+  br i1 %cond, label %pret, label %qret
+
+pret:
+  ret i8* %p
+
+qret:
+  ret i8* %q
+}
+
+define internal i8* @callee3(i8 *%p) alwaysinline {
+; CHECK-NOT: callee3
+  %r = call noalias i8* @foo(i8* %p)
+  ret i8* %r
+}
+
+; add the deref attribute to the existing attributes on foo.
+define i8* @caller3(i8* %ptr, i64 %x) {
+; CHECK-LABEL: caller3
+; CHECK: call noalias dereferenceable_or_null(12) i8* @foo
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee3(i8* %gep)
+  ret i8* %p
+}
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -80,11 +80,21 @@
   cl::Hidden,
   cl::desc("Convert noalias attributes to metadata during inlining."));
 
+static cl::opt UpdateReturnAttributes(
+"update-return-attrs", cl::init(true), cl::Hidden,
+cl::desc("Update return attributes on calls within inlined body"));
+
 static cl::opt
 PreserveAlignmentAssumptions("preserve-alignment-assumptions-during-inlining",
   cl::init(true), cl::Hidden,
   cl::desc("Convert align attributes to assumptions during inlining."));
 
+static cl::opt MaxInstCheckedForThrow(
+"max-inst-checked-for-throw-during-inlining", cl::Hidden,
+cl::desc("the maximum number of instructions analyzed for may throw during "
+ "attribute inference in inlined body"),
+cl::init(4));
+
 llvm::InlineResult llvm::InlineFunction(CallBase *CB, InlineFunctionInfo &IFI,
 AAResults *CalleeAAR,
 bool InsertLifetime) {
@@ -1136,6 +1146,77 @@
   }
 }
 
+static void AddReturnAttributes(CallSite CS, ValueToValueMapTy &VMap) {
+  if (!UpdateReturnAttributes)
+return;
+  AttrBuilder AB(CS.getAttributes(), AttributeList::ReturnIndex);
+  if (AB.empty())
+return;
+
+  auto *CalledFunction = CS.getCalledFunction();
+  auto &Context = CalledFunction->getContext();
+
+  auto GetClonedValue = [&](Instruction *I) -> Value * {
+ValueToValueMapTy::iterator VMI = VMap.find(I);
+if (VMI == VMap.end())
+  return nullptr;
+return VMI->second;
+  };
+
+  auto MayContainThrowingCall = [&](Instruction *RVal, Instruction *RInst) {
+unsigned NumInstChecked = 0;
+for (auto &I :
+ make_range(RVa

  1   2   >