[PATCH] D81725: [AArch64][SVE] Enable __ARM_FEATURE_SVE macros.

2020-06-25 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfabe67728eea: [AArch64][SVE] Enable __ARM_FEATURE_SVE 
macros. (authored by sdesmalen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81725

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_abd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_abs.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_add.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_addv.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_and.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_andv.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asr.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asrd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bic.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brka.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkn.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkpa.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkpb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cadd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clasta.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clastb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cls.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clz.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntp.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_compact.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_div.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_divr.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_eor.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_eorv.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_expa.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_exth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get2.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get3.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get4.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_insr.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_lasta.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_lastb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1rq.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c
  clang/

[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-06-25 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber added a comment.

Ping.


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

https://reviews.llvm.org/D80514



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


[PATCH] D82362: Move default module cache from system temporary directory

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3253
+  CmdArgs.push_back(Args.MakeArgString(Path));
+}
   }

davezarzycki wrote:
> sammccall wrote:
> > what happens in the else case?
> No module caching.
This seems reasonable (though a bit surprising that it happens silently). 
Please add a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82362



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


[PATCH] D82497: [Clang][SourceManager] optimize getFileIDLocal()

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

LGTM, thanks!

Btw, I've recently learned about http://llvm-compile-time-tracker.com/ so you 
might want to check the effect afterwards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82497



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


[clang] d6efc98 - Reland "[clang][Driver] Correct tool search path priority"

2020-06-25 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2020-06-25T09:33:43+01:00
New Revision: d6efc9811646edbfe13f06c2676fb469f1c155b1

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

LOG: Reland "[clang][Driver] Correct tool search path priority"

This reverts commit f570d5810485fa6fb2e1009f795a899d79bd429f.

The test was failing on MacOS if you set
LLVM_DEFAULT_TARGET_TRIPLE. For example if you set it to
"x86_64-apple-darwin" clang actually uses
"x86_64-apple-darwin".

To fix this get default triple from clang itself during the
test instead of substituting it in via lit.

Added: 
clang/test/Driver/program-path-priority.c

Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 24436ec4e8d7..1f718b30c551 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4766,13 +4766,11 @@ void Driver::generatePrefixedToolNames(
 }
 
 static bool ScanDirForExecutable(SmallString<128> &Dir,
- ArrayRef Names) {
-  for (const auto &Name : Names) {
-llvm::sys::path::append(Dir, Name);
-if (llvm::sys::fs::can_execute(Twine(Dir)))
-  return true;
-llvm::sys::path::remove_filename(Dir);
-  }
+ const std::string &Name) {
+  llvm::sys::path::append(Dir, Name);
+  if (llvm::sys::fs::can_execute(Twine(Dir)))
+return true;
+  llvm::sys::path::remove_filename(Dir);
   return false;
 }
 
@@ -4785,8 +4783,9 @@ std::string Driver::GetProgramPath(StringRef Name, const 
ToolChain &TC) const {
   for (const auto &PrefixDir : PrefixDirs) {
 if (llvm::sys::fs::is_directory(PrefixDir)) {
   SmallString<128> P(PrefixDir);
-  if (ScanDirForExecutable(P, TargetSpecificExecutables))
-return std::string(P.str());
+  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables)
+if (ScanDirForExecutable(P, TargetSpecificExecutable))
+  return std::string(P.str());
 } else {
   SmallString<128> P((PrefixDir + Name).str());
   if (llvm::sys::fs::can_execute(Twine(P)))
@@ -4795,17 +4794,25 @@ std::string Driver::GetProgramPath(StringRef Name, 
const ToolChain &TC) const {
   }
 
   const ToolChain::path_list &List = TC.getProgramPaths();
-  for (const auto &Path : List) {
-SmallString<128> P(Path);
-if (ScanDirForExecutable(P, TargetSpecificExecutables))
-  return std::string(P.str());
-  }
+  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables) {
+// For each possible name of the tool look for it in
+// program paths first, then the path.
+// Higher priority names will be first, meaning that
+// a higher priority name in the path will be found
+// instead of a lower priority name in the program path.
+// E.g. -gcc on the path will be found instead
+// of gcc in the program path
+for (const auto &Path : List) {
+  SmallString<128> P(Path);
+  if (ScanDirForExecutable(P, TargetSpecificExecutable))
+return std::string(P.str());
+}
 
-  // If all else failed, search the path.
-  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables)
+// Fall back to the path
 if (llvm::ErrorOr P =
 llvm::sys::findProgramByName(TargetSpecificExecutable))
   return *P;
+  }
 
   return std::string(Name);
 }

diff  --git a/clang/test/Driver/program-path-priority.c 
b/clang/test/Driver/program-path-priority.c
new file mode 100644
index ..ba893e7e2e2c
--- /dev/null
+++ b/clang/test/Driver/program-path-priority.c
@@ -0,0 +1,109 @@
+/// Don't create symlinks on Windows
+// UNSUPPORTED: system-windows
+
+/// Check the priority used when searching for tools
+/// Names and locations are usually in this order:
+/// -tool, tool, -tool
+/// program path, PATH
+/// (from highest to lowest priority)
+/// A higher priority name found in a lower priority
+/// location will win over a lower priority name in a
+/// higher priority location.
+/// Prefix dirs (added with -B) override the location,
+/// so only name priority is accounted for, unless we fail to find
+/// anything at all in the prefix.
+
+/// Symlink clang to a new dir which will be its
+/// "program path" for these tests
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: ln -s %clang %t/clang
+
+/// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: /gcc
+
+/// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=PROG_PATH_

[PATCH] D82526: [AST][RecoveryExpr] Add error-bit to NestNameSpecifierDependence and TemplateNameDependence.

2020-06-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

We might lose the error-bit if the error-bit goes through the code path
"error type/expr" -> "error template argument" -> "nested name specifier" ->
... -> "template Specialization type"

Template name also needs this, as a template can be nested into
an error specifier, e.g. templateName apply in
`TC(Foo, int()))>::template apply`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82526

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/test/Sema/invalid-bitwidth-expr.mm

Index: clang/test/Sema/invalid-bitwidth-expr.mm
===
--- clang/test/Sema/invalid-bitwidth-expr.mm
+++ clang/test/Sema/invalid-bitwidth-expr.mm
@@ -18,3 +18,17 @@
   int X : func();
 };
 constexpr int sss = sizeof(Y);
+
+bool Foo(int *); // expected-note {{candidate function not viable}}
+template 
+struct Base {};
+template 
+auto func() {
+  // error-bit should be propagated from TemplateArgument to NestNameSpecifier.
+  class Base::type C; // expected-error {{no matching function for call to 'Foo'}}
+  return C;
+}
+struct Z {
+  int X : func(); // expected-note {{in instantiation of function template}}
+};
+constexpr int  = sizeof(Z);
Index: clang/include/clang/AST/DependenceFlags.h
===
--- clang/include/clang/AST/DependenceFlags.h
+++ clang/include/clang/AST/DependenceFlags.h
@@ -64,41 +64,26 @@
 };
 using TypeDependence = TypeDependenceScope::TypeDependence;
 
-struct TemplateArgumentDependenceScope {
-  enum TemplateArgumentDependence : uint8_t {
-UnexpandedPack = 1,
-Instantiation = 2,
-Dependent = 4,
-
-Error = 8,
-
-DependentInstantiation = Dependent | Instantiation,
-None = 0,
-All = 15,
-LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)
-  };
-};
-using TemplateArgumentDependence =
-TemplateArgumentDependenceScope ::TemplateArgumentDependence;
-
 #define LLVM_COMMON_DEPENDENCE(NAME)   \
   struct NAME##Scope { \
 enum NAME : uint8_t {  \
   UnexpandedPack = 1,  \
   Instantiation = 2,   \
   Dependent = 4,   \
+  Error = 8,   \
\
   None = 0,\
   DependentInstantiation = Dependent | Instantiation,  \
-  All = 7, \
+  All = 15,\
\
-  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Dependent)\
+  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)\
 }; \
   };   \
   using NAME = NAME##Scope::NAME;
 
 LLVM_COMMON_DEPENDENCE(NestedNameSpecifierDependence)
 LLVM_COMMON_DEPENDENCE(TemplateNameDependence)
+LLVM_COMMON_DEPENDENCE(TemplateArgumentDependence)
 #undef LLVM_COMMON_DEPENDENCE
 
 // A combined space of all dependence concepts for all node types.
@@ -149,7 +134,8 @@
   Dependence(NestedNameSpecifierDependence D) :
 V ( translate(D, NNSDependence::UnexpandedPack, UnexpandedPack) |
 translate(D, NNSDependence::Instantiation, Instantiation) |
-translate(D, NNSDependence::Dependent, Dependent)){}
+translate(D, NNSDependence::Dependent, Dependent) |
+translate(D, NNSDependence::Error, Error)) {}
 
   Dependence(TemplateArgumentDependence D)
   : V(translate(D, TADependence::UnexpandedPack, UnexpandedPack) |
@@ -160,7 +146,8 @@
   Dependence(TemplateNameDependence D)
   : V(translate(D, TNDependence::UnexpandedPack, UnexpandedPack) |
  translate(D, TNDependence::Instantiation, Instantiation) |
- translate(D, TNDependence::Dependent, Dependent)) {}
+ translate(D, TNDependence::Dependent, Dependent) |
+ translate(D, TNDependence::Error, Error)) {}
 
   TypeDependence type() const {
 return translate(V, UnexpandedPack, TypeDependence::UnexpandedPack) |
@@ -181,7 +168,8 @@
   NestedNameSpecifierDependence nestedNameSpecifier() const {
 return translate(V, UnexpandedPack, NNSDependence::UnexpandedPack) |
translate(V, Instantiation, NNSDependence::Instantiation) |
-  

[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-06-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas marked 2 inline comments as done.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:1
+//===--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp 
---===//
+//

I find this name too general. 
We are testing here the behavior of TraverseStmt specifically, perhaps 
`TraverseStmt.cpp` would be a more appropriate name



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:17
+class RecordingVisitorBase : public TestVisitor {
+  bool VisitPostOrder;
+

ymandel wrote:
> Consider using an enum rather than a bool.
Agreed.
This would avoid all the /*VisitPostOrder=*/false




Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:81
+
+bool TraverseIntegerLiteral(IntegerLiteral *E) {
+  recordCallback(__func__, E);

E for Expr? Ok, Expr is base class of IntegerLiteral.
I propose to use either: 
S for Stmt, it  is a more homogeneus name and **also** a base class of 
IntegerLiteral
Or 
IL for IntegerLiteral, and then we stick with this convention



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:124
+TraverseIntegerLiteral IntegerLiteral(3)
+WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt BinaryOperator(+)

Good! Here the post order is still calling WalkUpFrom even though our Traverse 
doesn't call it in IntegerLiteral!



Comment at: 
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:148-161
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S);
+  return true;
+}
+
+bool WalkUpFromExpr(Expr *E) {
+  recordCallback(__func__, E);

> E for Expr? Ok, Expr is base class of IntegerLiteral.
> I propose to use either:
> S for Stmt, it is a more homogeneus name and also a base class of 
> IntegerLiteral
> Or
> IL for IntegerLiteral, and then we stick with this convention

Here it gets even more confusing.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:153
+
+bool WalkUpFromExpr(Expr *E) {
+  recordCallback(__func__, E);

I think overriding WalkUpFromDerived when you already have WalkUpFromStmt 
doesn't bring much value.
In the case of fully derived AST nodes we just get the repeated information 
about the type of this node, e.g. 
WalkUpFromIntegerLiteral IntegerLiteral(x) 
instead of
WalkUpFromStmt IntegerLiteral(x)
 
In the case of intermediate AST nodes, as WalkUpFromExpr, we get some 
information but do we need that?
Here for instance, the information we get is: 
WalkUpFromExpr Node => Node is an Expr
WalkUpFromStmt Node => Node is a Stmt
I don't think this information is very valuable



Comment at: 
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:300-309
+WalkUpFromStmt CompoundStmt
+WalkUpFromStmt IntegerLiteral(1)
+WalkUpFromStmt BinaryOperator(+)
+WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt CallExpr(add)
+WalkUpFromStmt ImplicitCastExpr

I think we spotted something funny here. RAV didn't call our overriden 
TraverseBinaryOperator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485



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


[PATCH] D82313: [OpenCL] Reject block arguments

2020-06-25 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 273253.
svenvh added a comment.

Add test case with a block as a parameter of another block.


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

https://reviews.llvm.org/D82313

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/Frontend/opencl.cl
  clang/test/SemaOpenCL/invalid-block.cl

Index: clang/test/SemaOpenCL/invalid-block.cl
===
--- clang/test/SemaOpenCL/invalid-block.cl
+++ clang/test/SemaOpenCL/invalid-block.cl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s
 
 // OpenCL v2.0 s6.12.5
-void f0(int (^const bl)());
+void f0(int (^const bl)()); // expected-error{{declaring function parameter of type 'int (__generic ^const __private)(void)' is not allowed}}
 // All blocks declarations must be const qualified and initialized.
 void f1() {
   int (^bl1)(void) = ^() {
@@ -26,9 +26,18 @@
   };
 }
 
-// A block cannot be the return value of a function.
+// A block cannot be the return value or parameter of a function.
 typedef int (^bl_t)(void);
-bl_t f3(bl_t bl); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}}
+bl_t f3a(int); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}}
+bl_t f3b(bl_t bl);
+// expected-error@-1{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}}
+// expected-error@-2{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
+void f3c() {
+  // Block with a block argument.
+  int (^const bl2)(bl_t block_arg) = ^() { // expected-error{{declaring function parameter of type '__private bl_t' (aka 'int (__generic ^const __private)(void)') is not allowed}}
+return block_arg(); // expected-error{{implicit declaration of function 'block_arg' is invalid in OpenCL}}
+  };
+}
 
 struct bl_s {
   int (^bl)(void); // expected-error {{the 'int (__generic ^const)(void)' type cannot be used to declare a structure or union field}}
Index: clang/test/Frontend/opencl.cl
===
--- clang/test/Frontend/opencl.cl
+++ clang/test/Frontend/opencl.cl
@@ -21,7 +21,7 @@
 #endif
 #endif
 
-void f(void (^g)(void)) {
+typedef int (^bl_t)(void);
 #if defined(__OPENCL_C_VERSION__) || defined(__OPENCL_CPP_VERSION__)
 #if !defined(BLOCKS) && (defined(__OPENCL_CPP_VERSION__)  || __OPENCL_C_VERSION__ != CL_VERSION_2_0)
   // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0}}
@@ -29,7 +29,6 @@
 #else
   // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
-}
 
 // CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
 // CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
Index: clang/test/CodeGenOpenCL/blocks.cl
===
--- clang/test/CodeGenOpenCL/blocks.cl
+++ clang/test/CodeGenOpenCL/blocks.cl
@@ -70,26 +70,6 @@
 
 // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
 
-// Test that we support block arguments.
-// COMMON-LABEL: define {{.*}} @blockArgFunc
-int blockArgFunc(int (^ bl)(void)) {
-  return bl();
-}
-
-// COMMON-LABEL: define {{.*}} @get21
-// COMMON: define {{.*}} @__get21_block_invoke
-// COMMON: ret i32 21
-int get21() {
-  return blockArgFunc(^{return 21;});
-}
-
-// COMMON-LABEL: define {{.*}} @get42
-// COMMON: define {{.*}} @__get42_block_invoke
-// COMMON: ret i32 42
-int get42() {
-  return blockArgFunc(^{return 42;});
-}
-
 // COMMON-LABEL: define {{.*}}@call_block
 // call {{.*}}@__call_block_block_invoke
 int call_block() {
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5135,8 +5135,8 @@
 // FIXME: This really should be in BuildFunctionType.
 if (S.getLangOpts().OpenCL) {
   if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16")) {
-S.Diag(Param->getLocation(),
-  diag::err_opencl_half_param) << ParamTy;
+S.Diag(Param->getLocation(), diag::err_opencl_invalid_param)
+<< ParamTy << 0;
 D.setInvalidType();
 Param->setInvalidDecl();
   }
@@ -5155,6 +5155,11 @@
 Param->setKNRPromoted(true);
   }
 }
+  } else if (S.getLangOpts().OpenCL && ParamTy->isBlockPointerType()) {
+// OpenCL 2.0 s6.12.5: A block cannot be a parameter of a function.
+S.Diag(Par

[PATCH] D82386: [clangd] Config: Fragments and parsing from YAML

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

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82386

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -0,0 +1,160 @@
+//===-- ConfigYAMLTests.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ConfigFragment.h"
+#include "Matchers.h"
+#include "Protocol.h"
+#include "llvm/Support/SMLoc.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "gtest/internal/gtest-internal.h"
+
+namespace clang {
+namespace clangd {
+namespace config {
+template  void PrintTo(const Located &V, std::ostream *OS) {
+  *OS << ::testing::PrintToString(*V);
+}
+
+namespace {
+using ::testing::AllOf;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+
+MATCHER_P(Val, Value, "") {
+  if (*arg == Value)
+return true;
+  *result_listener << "value is " << *arg;
+  return false;
+}
+
+Position toPosition(llvm::SMLoc L, const llvm::SourceMgr &SM) {
+  auto LineCol = SM.getLineAndColumn(L);
+  Position P;
+  P.line = LineCol.first - 1;
+  P.character = LineCol.second - 1;
+  return P;
+}
+
+Range toRange(llvm::SMRange R, const llvm::SourceMgr &SM) {
+  return Range{toPosition(R.Start, SM), toPosition(R.End, SM)};
+}
+
+struct CapturedDiags {
+  std::function callback() {
+return [this](const llvm::SMDiagnostic &D) {
+  Diagnostics.emplace_back();
+  Diag &Out = Diagnostics.back();
+  Out.Message = D.getMessage().str();
+  Out.Kind = D.getKind();
+  Out.Pos.line = D.getLineNo() - 1;
+  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
+  if (!D.getRanges().empty()) {
+const auto &R = D.getRanges().front();
+Out.Range.emplace();
+Out.Range->start.line = Out.Range->end.line = Out.Pos.line;
+Out.Range->start.character = R.first;
+Out.Range->end.character = R.second;
+  }
+};
+  }
+  struct Diag {
+std::string Message;
+llvm::SourceMgr::DiagKind Kind;
+Position Pos;
+llvm::Optional Range;
+
+friend void PrintTo(const Diag &D, std::ostream *OS) {
+  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
+  << D.Message << "@" << llvm::to_string(D.Pos);
+}
+  };
+  std::vector Diagnostics;
+};
+
+MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
+MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
+MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
+MATCHER_P(DiagRange, R, "") { return arg.Range == R; }
+
+TEST(ParseYAML, SyntacticForms) {
+  CapturedDiags Diags;
+  const char *YAML = R"yaml(
+If:
+  PathMatch:
+- 'abc'
+CompileFlags: { Add: [foo, bar] }
+---
+CompileFlags:
+  Add: |
+b
+az
+  )yaml";
+  auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 2u);
+  EXPECT_FALSE(Results.front().Condition.HasUnrecognizedCondition);
+  EXPECT_THAT(Results.front().Condition.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results.front().CompileFlags.Add,
+  ElementsAre(Val("foo"), Val("bar")));
+
+  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+}
+
+TEST(ParseYAML, Locations) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+If:
+  PathMatch: [['???bad***regex(((']]
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 1u);
+  ASSERT_NE(Results.front().Source.Manager, nullptr);
+  EXPECT_EQ(toRange(Results.front().Condition.PathMatch.front().Range,
+*Results.front().Source.Manager),
+YAML.range());
+}
+
+TEST(ParseYAML, Diagnostics) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+If:
+  [[UnknownCondition]]: "foo"
+CompileFlags:
+  Add: 'first'
+---
+CompileFlags: {^
+)yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+
+  ASSERT_THAT(
+  Diags.Diagnostics,
+  El

[PATCH] D82386: [clangd] Config: Fragments and parsing from YAML

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks!

> Apart from the comments(IIRC which are mostly minor), it felt like there were 
> a few lines that aren't clang-format'd. Please make sure to run clang-format 
> on the files at some point.

git-clang-format thinks it's clean, so please point out any examples you see!




Comment at: clang-tools-extra/clangd/ConfigFragment.h:9
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// The configuration system allows users to control this:

kadircet wrote:
> i think this paragraph belongs to `Config.h`
This first sentence does, and I'll put it there too, but I think one redundant 
sentence to establish the context is reasonable.

The next three lines belong in this file because they describe how users 
control config (which they do through ConfigFragment, not through Config).



Comment at: clang-tools-extra/clangd/ConfigFragment.h:16
+// configuration as obtained from a source like a file.
+// This is distinct from how the config is interpreted (CompiledFragment),
+// combined (ConfigProvider) and exposed to the rest of clangd (Config).

kadircet wrote:
> again i don't think these are relevant here.
> 
> maybe provide more details about any new config option should start 
> propagating from here, as this is the closest layer to user written config,
> again i don't think these are relevant here.

I think how this code relates to the rest of the system is a pretty important 
thing for documentation to cover! I wish docs in general did a better job of 
this.
Relying on xrefs in the code is pretty noisy and low-level, and guessing at 
filenames doesn't scale well.

> maybe provide more details about any new config option should start 
> propagating from here, as this is the closest layer to user written config,

Yeah - it depends whether you're looking at "here is a feature I'd like to make 
configurable" vs "here is some configuration syntax I want to support".
I've moved it here, but I'm not 100% sure it's the right call.



Comment at: clang-tools-extra/clangd/ConfigFragment.h:61
+  /// BufferName is used for the SourceMgr and diagnostics.
+  static std::vector parseYAML(llvm::StringRef YAML,
+ llvm::StringRef BufferName,

kadircet wrote:
> what about `fromYAML` and returning `vector` ?
> what about fromYAML

I can live with it if you like, but I prefer parse:
 - Fragment::fromYAML reads funny as it returns multiple fragments in general
 - parse describes the action more clearly and so hints toward thinking about 
error handling etc

> returning vector ?
why? the resulting vector is slower (has to copy instead of move on 
reallocation).
It prevents us from moving from the fragment when we compile it (which we do in 
some places)



Comment at: clang-tools-extra/clangd/ConfigFragment.h:65
+
+  struct SourceInfo {
+/// Retains a buffer of the original source this fragment was parsed from.

kadircet wrote:
> why the bundling?
Oops, this is so I could give them a collective comment, and I forgot to do 
it...

The idea is everything else represents the directly-user-specified "body" of 
the configuration, but these fields are different. (The associated directory 
also goes here, though wasn't needed in this patch).
I wanted to wall these off a bit as the outer struct will gain many fields and 
so this may become less obvious. (Also makes it easier to skip over if we're 
generating docs etc)



Comment at: clang-tools-extra/clangd/ConfigFragment.h:69
+/// Shared because multiple fragments are often parsed from one (YAML) 
file.
+/// May be null, then all locations are ignored.
+std::shared_ptr Manager;

kadircet wrote:
> maybe `invalid/absent` rather than `ignored` (or change it to say should be 
> ignored) ? I am assuming this is referring to locations of config parameters 
> like `Add`s and conditions.
Changed to "should be ignored". guaranteeing that the SMRanges is stronger but 
not actually useful.



Comment at: clang-tools-extra/clangd/ConfigFragment.h:73
+/// Only valid if SourceManager is set.
+llvm::SMLoc Location;
+  };

kadircet wrote:
> what is the use of this ?
There may be multiple fragments in a file.

When tracking how fragments are used in the logs, there should be enough 
information to identify the particular fragment, without having to guess.
 - during parsing, we can log in some source-specific way
 - in the Fragment form, we can log this location to identify the fragment
 - during compilation, we log this location and the pointer address of the new 
CompiledFragment
 - subsequently we can just log the CompiledFragment address



Comment at: clang-tools-extra/clangd/ConfigFragment.h:75
+  };
+  SourceInfo Source;
+

kadircet wrote:
> why not mak

[PATCH] D82498: [SourceManager] don't check invalid param of getLocalSLocEntry()

2020-06-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/include/clang/Basic/SourceManager.h:1649
   const SrcMgr::SLocEntry &getLocalSLocEntry(unsigned Index,
  bool *Invalid = nullptr) const {
 assert(Index < LocalSLocEntryTable.size() && "Invalid index");

i think we should drop Invalid from the signature completely if we are going 
for this.

I've sent out D82532 to get rid of the libclang dependency on this, after it 
lands this should be possible to clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82498



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


[PATCH] D82532: [libclang] Get rid of relience on SourceManager member signature

2020-06-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, bkramer.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

Libclang was enforcing a singature on SourceManager::getLocalSLocEntry
which isn't possible to satisfy as pointed out in
https://reviews.llvm.org/D80681#inline-751438.

This patch updates the libclang, hopefully without breaking API stability, to
not rely on member signature. To enable changing the signature in D82498 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82532

Files:
  clang/tools/libclang/CIndexInclusionStack.cpp


Index: clang/tools/libclang/CIndexInclusionStack.cpp
===
--- clang/tools/libclang/CIndexInclusionStack.cpp
+++ clang/tools/libclang/CIndexInclusionStack.cpp
@@ -18,10 +18,9 @@
 #include "clang/Frontend/ASTUnit.h"
 using namespace clang;
 
-static void getInclusions(const SrcMgr::SLocEntry 
&(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
-  CXTranslationUnit TU, CXInclusionVisitor CB,
-  CXClientData clientData)
-{
+namespace {
+void getInclusions(bool IsLocal, unsigned n, CXTranslationUnit TU,
+   CXInclusionVisitor CB, CXClientData clientData) {
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
@@ -30,8 +29,8 @@
 
   for (unsigned i = 0 ; i < n ; ++i) {
 bool Invalid = false;
-const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+const SrcMgr::SLocEntry &SL =
+IsLocal ? SM.getLocalSLocEntry(i) : SM.getLoadedSLocEntry(i, &Invalid);
 if (!SL.isFile() || Invalid)
   continue;
 
@@ -61,11 +60,11 @@
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
- const_cast(FI.getContentCache()->OrigEntry)),
+   const_cast(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
   }
 }
-
+} // namespace
 
 void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
  CXClientData clientData) {
@@ -83,14 +82,13 @@
   // a AST/PCH file, but this file has a pre-compiled preamble, we also need
   // to look in that file.
   if (n == 1 || SM.getPreambleFileID().isValid()) {
-getInclusions(&SourceManager::getLoadedSLocEntry,
-  SM.loaded_sloc_entry_size(), TU, CB, clientData);
+getInclusions(/*IsLocal=*/false, SM.loaded_sloc_entry_size(), TU, CB,
+  clientData);
   }
 
   // Not a PCH/AST file. Note, if there is a preamble, it could still be that
   // there are #includes in this file (e.g. for any include after the first
   // declaration).
   if (n != 1)
-getInclusions(&SourceManager::getLocalSLocEntry, n, TU, CB, clientData);
-
+getInclusions(/*IsLocal=*/true, n, TU, CB, clientData);
 }


Index: clang/tools/libclang/CIndexInclusionStack.cpp
===
--- clang/tools/libclang/CIndexInclusionStack.cpp
+++ clang/tools/libclang/CIndexInclusionStack.cpp
@@ -18,10 +18,9 @@
 #include "clang/Frontend/ASTUnit.h"
 using namespace clang;
 
-static void getInclusions(const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
-  CXTranslationUnit TU, CXInclusionVisitor CB,
-  CXClientData clientData)
-{
+namespace {
+void getInclusions(bool IsLocal, unsigned n, CXTranslationUnit TU,
+   CXInclusionVisitor CB, CXClientData clientData) {
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
@@ -30,8 +29,8 @@
 
   for (unsigned i = 0 ; i < n ; ++i) {
 bool Invalid = false;
-const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+const SrcMgr::SLocEntry &SL =
+IsLocal ? SM.getLocalSLocEntry(i) : SM.getLoadedSLocEntry(i, &Invalid);
 if (!SL.isFile() || Invalid)
   continue;
 
@@ -61,11 +60,11 @@
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
- const_cast(FI.getContentCache()->OrigEntry)),
+   const_cast(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
   }
 }
-
+} // namespace
 
 void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
  CXClientData clientData) {
@@ -83,14 +82,13 @@
   // a AST/PCH file, but this file has a pre-compiled preamble, we also need
   // to look in that file.
   if (n == 1 || SM.getPreambleFileID().isValid()) {
-getInclusions(&SourceManager::getLoadedSLocEntry,
-  SM.loaded_sloc_entry_size(), TU, CB, clientData);
+getInclusions(/*IsLocal=*/false, SM.lo

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-25 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

As a future work, when something support `if`s, it should also support `?:`, 
and eliminate redundant conditionals from there, too.

I believe this check (together with `misc-redundant-expr`) should go into the 
`readability-` group.


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

https://reviews.llvm.org/D81272



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


[clang] e010d14 - [analyzer] SATest: Add initial docker infrastructure

2020-06-25 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-06-25T12:28:21+03:00
New Revision: e010d1432fa15cff7a6d369f5e372d995e2eba5d

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

LOG: [analyzer] SATest: Add initial docker infrastructure

Summary:
Static analysis is very sensitive to environment.
OS and libraries installed can affect the results.  This fact makes
it extremely hard to have a regression testing system that will
produce stable results.

For this very reason, this commit introduces a new dockerized testing
environment, so that every analyzer developer can check their changes
against previous analysis results.

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

Added: 
clang/utils/analyzer/Dockerfile
clang/utils/analyzer/entrypoint.py

Modified: 


Removed: 




diff  --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile
new file mode 100644
index ..e87377c9eec1
--- /dev/null
+++ b/clang/utils/analyzer/Dockerfile
@@ -0,0 +1,52 @@
+FROM ubuntu:bionic
+
+RUN apt-get update && apt-get install -y \
+apt-transport-https \
+ca-certificates \
+gnupg \
+software-properties-common \
+wget
+
+# newer CMake is required by LLVM
+RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 
2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg 
>/dev/null
+RUN apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
+
+# test system dependencies
+RUN apt-get update && apt-get install -y \
+git \
+gettext \
+python3 \
+python3-pip \
+cmake \
+ninja-build
+
+# box2d dependencies
+RUN apt-get install -y \
+libx11-dev \
+libxrandr-dev \
+libxinerama-dev \
+libxcursor-dev \
+libxi-dev
+
+# symengine dependencies
+RUN apt-get install -y \
+libgmp10 \
+libgmp-dev
+
+RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
+
+VOLUME /analyzer
+VOLUME /projects
+VOLUME /llvm-project
+VOLUME /build
+VOLUME /scripts
+
+ENV PATH="/analyzer/bin:${PATH}"
+
+ADD entrypoint.py /entrypoint.py
+
+# Uncomment in case of requirements
+# ADD requirements.txt /requirements.txt
+# RUN pip3 install -r /requirements.txt
+
+ENTRYPOINT ["python", "/entrypoint.py"]

diff  --git a/clang/utils/analyzer/entrypoint.py 
b/clang/utils/analyzer/entrypoint.py
new file mode 100644
index ..3b85628a9a85
--- /dev/null
+++ b/clang/utils/analyzer/entrypoint.py
@@ -0,0 +1,52 @@
+import argparse
+import os
+
+from typing import List, Tuple
+
+from subprocess import check_call
+
+
+def main():
+settings, rest = parse_arguments()
+if settings.build_llvm or settings.build_llvm_only:
+build_llvm()
+if settings.build_llvm_only:
+return
+test(rest)
+
+
+def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
+parser = argparse.ArgumentParser()
+parser.add_argument('--build-llvm', action='store_true')
+parser.add_argument('--build-llvm-only', action='store_true')
+return parser.parse_known_args()
+
+
+def build_llvm() -> None:
+os.chdir('/build')
+cmake()
+ninja()
+
+
+CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
+"-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
+"-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \
+"-DLLVM_ENABLE_TERMINFO=OFF -DCLANG_ENABLE_ARCMT=OFF " \
+"-DCLANG_ENABLE_STATIC_ANALYZER=ON"
+
+
+def cmake():
+check_call(CMAKE_COMMAND + ' /llvm-project/llvm', shell=True)
+
+
+def ninja():
+check_call("ninja install", shell=True)
+
+
+def test(args: List[str]):
+os.chdir("/projects")
+check_call("/scripts/SATest.py " + " ".join(args), shell=True)
+
+
+if __name__ == '__main__':
+main()



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


[clang] 3770f5c - [analyzer] SATest: Add convenience 'docker' command

2020-06-25 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-06-25T12:28:22+03:00
New Revision: 3770f5c9b98c5bae2f099f5c24e05eb4a0cca1d0

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

LOG: [analyzer] SATest: Add convenience 'docker' command

Summary:
It provides a simpler interface for testing within docker.
This way the user is not required to no how to use `docker run` and
its options.

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

Added: 


Modified: 
clang/utils/analyzer/SATest.py

Removed: 




diff  --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index f45f593d08ec..f7cf5146566d 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -9,6 +9,16 @@
 
 import argparse
 import sys
+import os
+
+from subprocess import check_call
+
+SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
+PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
+DEFAULT_LLVM_DIR = os.path.realpath(os.path.join(SCRIPTS_DIR,
+ os.path.pardir,
+ os.path.pardir,
+ os.path.pardir))
 
 
 def add(parser, args):
@@ -78,6 +88,37 @@ def update(parser, args):
 SATestUpdateDiffs.update_reference_results(project)
 
 
+def docker(parser, args):
+if len(args.rest) > 0:
+if args.rest[0] != "--":
+parser.error("REST arguments should start with '--'")
+args.rest = args.rest[1:]
+
+if args.build_image:
+docker_build_image()
+else:
+docker_run(args)
+
+
+def docker_build_image():
+check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
+   shell=True)
+
+
+def docker_run(args):
+check_call("docker run --rm --name satest "
+   "-v {llvm}:/llvm-project "
+   "-v {build}:/build "
+   "-v {clang}:/analyzer "
+   "-v {scripts}:/scripts "
+   "-v {projects}:/projects "
+   "satest-image:latest {args}"
+   .format(llvm=args.llvm_project_dir, build=args.build_dir,
+   clang=args.clang_dir, scripts=SCRIPTS_DIR,
+   projects=PROJECTS_DIR, args=' '.join(args.rest)),
+   shell=True)
+
+
 def main():
 parser = argparse.ArgumentParser()
 subparsers = parser.add_subparsers()
@@ -180,6 +221,27 @@ def main():
 # TODO: add option to decide whether we should use git
 upd_parser.set_defaults(func=update)
 
+# docker subcommand
+dock_parser = subparsers.add_parser(
+"docker",
+help="Run regression system in the docker.")
+
+dock_parser.add_argument("--build-image", action="store_true",
+ help="Build docker image for running tests.")
+dock_parser.add_argument("--llvm-project-dir", action="store",
+ default=DEFAULT_LLVM_DIR,
+ help="Path to LLVM source code. Defaults "
+ "to the repo where this script is located. ")
+dock_parser.add_argument("--build-dir", action="store", default="",
+ help="Path to a directory where docker should "
+ "build LLVM code.")
+dock_parser.add_argument("--clang-dir", action="store", default="",
+ help="Path to find/install LLVM installation.")
+dock_parser.add_argument("rest", nargs=argparse.REMAINDER, default=[],
+ help="Additionall args that will be forwarded "
+ "to the docker's entrypoint.")
+dock_parser.set_defaults(func=docker)
+
 args = parser.parse_args()
 args.func(parser, args)
 



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


[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-25 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

I think the warnings can be hidden by something like this (I'm no expert in 
this area though, but it seems like this technique has been used a number of 
times before in llvm, so hopefully it applies here as well):

  diff --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
  index ca0a76db78f4..1970541bc56a 100644
  --- a/clang-tools-extra/clangd/Preamble.cpp
  +++ b/clang-tools-extra/clangd/Preamble.cpp
  @@ -230,6 +230,7 @@ llvm::Expected
   scanPreamble(llvm::StringRef Contents, const tooling::CompileCommand &Cmd) {
 class EmptyFS : public ThreadsafeFS {
 public:
  +using ThreadsafeFS::view;
   llvm::IntrusiveRefCntPtr
   view(llvm::NoneType) const override {
 return new llvm::vfs::InMemoryFileSystem;
  diff --git a/clang-tools-extra/clangd/support/ThreadsafeFS.h 
b/clang-tools-extra/clangd/support/ThreadsafeFS.h
  index aa6825fb3999..eb9016bad201 100644
  --- a/clang-tools-extra/clangd/support/ThreadsafeFS.h
  +++ b/clang-tools-extra/clangd/support/ThreadsafeFS.h
  @@ -42,6 +42,7 @@ public:
   
   class RealThreadsafeFS : public ThreadsafeFS {
   public:
  +  using ThreadsafeFS::view;
 llvm::IntrusiveRefCntPtr
 view(llvm::NoneType) const override;
   };

at least I get no warnings when building clangd (haven't checked the unittests, 
but I don't care about warnings in those right now).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920



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


[PATCH] D82532: [libclang] Get rid of relience on SourceManager member signature

2020-06-25 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.

Regardless of the outcome on the other patch, I like this code better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82532



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-06-25 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett closed this revision.
DavidSpickett added a comment.

Relanded as d6efc9811646edbfe13f06c2676fb469f1c155b1 
. Change 
was to get the default triple from clang itself, as on MacOS this can be 
different to the value you set via CMake.

Closing this review as the diff shown was committed as 
028571d60843cb87e2637ef69ee09090d4526c62 
 but 
wasn't closed automatically because I had the wrong diff link in the commit msg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[PATCH] D81571: [analyzer] SATest: Add initial docker infrastructure

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe010d1432fa1: [analyzer] SATest: Add initial docker 
infrastructure (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81571

Files:
  clang/utils/analyzer/Dockerfile
  clang/utils/analyzer/entrypoint.py

Index: clang/utils/analyzer/entrypoint.py
===
--- /dev/null
+++ clang/utils/analyzer/entrypoint.py
@@ -0,0 +1,52 @@
+import argparse
+import os
+
+from typing import List, Tuple
+
+from subprocess import check_call
+
+
+def main():
+settings, rest = parse_arguments()
+if settings.build_llvm or settings.build_llvm_only:
+build_llvm()
+if settings.build_llvm_only:
+return
+test(rest)
+
+
+def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
+parser = argparse.ArgumentParser()
+parser.add_argument('--build-llvm', action='store_true')
+parser.add_argument('--build-llvm-only', action='store_true')
+return parser.parse_known_args()
+
+
+def build_llvm() -> None:
+os.chdir('/build')
+cmake()
+ninja()
+
+
+CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
+"-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
+"-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \
+"-DLLVM_ENABLE_TERMINFO=OFF -DCLANG_ENABLE_ARCMT=OFF " \
+"-DCLANG_ENABLE_STATIC_ANALYZER=ON"
+
+
+def cmake():
+check_call(CMAKE_COMMAND + ' /llvm-project/llvm', shell=True)
+
+
+def ninja():
+check_call("ninja install", shell=True)
+
+
+def test(args: List[str]):
+os.chdir("/projects")
+check_call("/scripts/SATest.py " + " ".join(args), shell=True)
+
+
+if __name__ == '__main__':
+main()
Index: clang/utils/analyzer/Dockerfile
===
--- /dev/null
+++ clang/utils/analyzer/Dockerfile
@@ -0,0 +1,52 @@
+FROM ubuntu:bionic
+
+RUN apt-get update && apt-get install -y \
+apt-transport-https \
+ca-certificates \
+gnupg \
+software-properties-common \
+wget
+
+# newer CMake is required by LLVM
+RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
+RUN apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
+
+# test system dependencies
+RUN apt-get update && apt-get install -y \
+git \
+gettext \
+python3 \
+python3-pip \
+cmake \
+ninja-build
+
+# box2d dependencies
+RUN apt-get install -y \
+libx11-dev \
+libxrandr-dev \
+libxinerama-dev \
+libxcursor-dev \
+libxi-dev
+
+# symengine dependencies
+RUN apt-get install -y \
+libgmp10 \
+libgmp-dev
+
+RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
+
+VOLUME /analyzer
+VOLUME /projects
+VOLUME /llvm-project
+VOLUME /build
+VOLUME /scripts
+
+ENV PATH="/analyzer/bin:${PATH}"
+
+ADD entrypoint.py /entrypoint.py
+
+# Uncomment in case of requirements
+# ADD requirements.txt /requirements.txt
+# RUN pip3 install -r /requirements.txt
+
+ENTRYPOINT ["python", "/entrypoint.py"]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81572: [analyzer] SATest: Add convenience 'docker' command

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3770f5c9b98c: [analyzer] SATest: Add convenience 
'docker' command (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81572

Files:
  clang/utils/analyzer/SATest.py


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -9,6 +9,16 @@
 
 import argparse
 import sys
+import os
+
+from subprocess import check_call
+
+SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
+PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
+DEFAULT_LLVM_DIR = os.path.realpath(os.path.join(SCRIPTS_DIR,
+ os.path.pardir,
+ os.path.pardir,
+ os.path.pardir))
 
 
 def add(parser, args):
@@ -78,6 +88,37 @@
 SATestUpdateDiffs.update_reference_results(project)
 
 
+def docker(parser, args):
+if len(args.rest) > 0:
+if args.rest[0] != "--":
+parser.error("REST arguments should start with '--'")
+args.rest = args.rest[1:]
+
+if args.build_image:
+docker_build_image()
+else:
+docker_run(args)
+
+
+def docker_build_image():
+check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
+   shell=True)
+
+
+def docker_run(args):
+check_call("docker run --rm --name satest "
+   "-v {llvm}:/llvm-project "
+   "-v {build}:/build "
+   "-v {clang}:/analyzer "
+   "-v {scripts}:/scripts "
+   "-v {projects}:/projects "
+   "satest-image:latest {args}"
+   .format(llvm=args.llvm_project_dir, build=args.build_dir,
+   clang=args.clang_dir, scripts=SCRIPTS_DIR,
+   projects=PROJECTS_DIR, args=' '.join(args.rest)),
+   shell=True)
+
+
 def main():
 parser = argparse.ArgumentParser()
 subparsers = parser.add_subparsers()
@@ -180,6 +221,27 @@
 # TODO: add option to decide whether we should use git
 upd_parser.set_defaults(func=update)
 
+# docker subcommand
+dock_parser = subparsers.add_parser(
+"docker",
+help="Run regression system in the docker.")
+
+dock_parser.add_argument("--build-image", action="store_true",
+ help="Build docker image for running tests.")
+dock_parser.add_argument("--llvm-project-dir", action="store",
+ default=DEFAULT_LLVM_DIR,
+ help="Path to LLVM source code. Defaults "
+ "to the repo where this script is located. ")
+dock_parser.add_argument("--build-dir", action="store", default="",
+ help="Path to a directory where docker should "
+ "build LLVM code.")
+dock_parser.add_argument("--clang-dir", action="store", default="",
+ help="Path to find/install LLVM installation.")
+dock_parser.add_argument("rest", nargs=argparse.REMAINDER, default=[],
+ help="Additionall args that will be forwarded "
+ "to the docker's entrypoint.")
+dock_parser.set_defaults(func=docker)
+
 args = parser.parse_args()
 args.func(parser, args)
 


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -9,6 +9,16 @@
 
 import argparse
 import sys
+import os
+
+from subprocess import check_call
+
+SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
+PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
+DEFAULT_LLVM_DIR = os.path.realpath(os.path.join(SCRIPTS_DIR,
+ os.path.pardir,
+ os.path.pardir,
+ os.path.pardir))
 
 
 def add(parser, args):
@@ -78,6 +88,37 @@
 SATestUpdateDiffs.update_reference_results(project)
 
 
+def docker(parser, args):
+if len(args.rest) > 0:
+if args.rest[0] != "--":
+parser.error("REST arguments should start with '--'")
+args.rest = args.rest[1:]
+
+if args.build_image:
+docker_build_image()
+else:
+docker_run(args)
+
+
+def docker_build_image():
+check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
+   shell=True)
+
+
+def docker_run(args):
+check_call("docker run --rm --name satest "
+   "-v {llvm}:/llvm-project "
+   "-v {build}:/build "
+   "-v {clang}:/analyzer "
+   "-v {scripts}:/scripts "
+  

[PATCH] D81592: [analyzer] SATest: Add a set of initial projects for testing

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dc2802773ce: [analyzer] SATest: Add a set of initial 
projects for testing (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81592

Files:
  .gitignore
  clang/utils/analyzer/.dockerignore
  clang/utils/analyzer/projects/box2d/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/box2d/run_static_analyzer.cmd
  clang/utils/analyzer/projects/cxxopts/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/cxxopts/run_static_analyzer.cmd
  clang/utils/analyzer/projects/libsoundio/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/libsoundio/run_static_analyzer.cmd
  clang/utils/analyzer/projects/oatpp/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/oatpp/run_static_analyzer.cmd
  clang/utils/analyzer/projects/projects.json
  clang/utils/analyzer/projects/symengine/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/symengine/run_static_analyzer.cmd
  clang/utils/analyzer/projects/termbox/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/termbox/run_static_analyzer.cmd
  clang/utils/analyzer/projects/tinyexpr/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/tinyexpr/run_static_analyzer.cmd
  clang/utils/analyzer/projects/tinyspline/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/tinyspline/run_static_analyzer.cmd
  clang/utils/analyzer/projects/tinyvm/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/tinyvm/run_static_analyzer.cmd
  clang/utils/analyzer/projects/zstd/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/zstd/run_static_analyzer.cmd

Index: clang/utils/analyzer/projects/zstd/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/zstd/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake ./build/cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild_analyzer -GNinja
+cmake --build build_analyzer
Index: clang/utils/analyzer/projects/zstd/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/zstd/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build_analyzer
Index: clang/utils/analyzer/projects/tinyvm/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/tinyvm/run_static_analyzer.cmd
@@ -0,0 +1 @@
+make
Index: clang/utils/analyzer/projects/tinyvm/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/tinyvm/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+make clean
Index: clang/utils/analyzer/projects/tinyspline/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/tinyspline/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/tinyspline/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/tinyspline/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/tinyexpr/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/tinyexpr/run_static_analyzer.cmd
@@ -0,0 +1 @@
+make
Index: clang/utils/analyzer/projects/tinyexpr/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/tinyexpr/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+make clean
Index: clang/utils/analyzer/projects/termbox/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/termbox/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+./waf configure
+./waf
Index: clang/utils/analyzer/projects/termbox/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/termbox/cleanup_run_static_analyzer.sh
@@ -0,0 +1,2 @@
+./waf clean
+exit 0
Index: clang/utils/analyzer/projects/symengine/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/symengine/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -DWITH_COTIRE=OFF -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/symengine/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/symengi

[PATCH] D81600: [analyzer] SATest: Fix package versions for test dependencies

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a84ab9f9bdb: [analyzer] SATest: Fix package versions for 
test dependencies (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81600

Files:
  clang/utils/analyzer/Dockerfile


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -13,34 +13,34 @@
 
 # test system dependencies
 RUN apt-get update && apt-get install -y \
-git \
-gettext \
-python3 \
-python3-pip \
-cmake \
-ninja-build
+git=1:2.17.1-1ubuntu0.7 \
+gettext=0.19.8.1-6ubuntu0.3 \
+python3=3.6.7-1~18.04 \
+python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
+cmake=3.17.3-0kitware1 \
+ninja-build=1.8.2-1
 
 # box2d dependencies
 RUN apt-get install -y \
-libx11-dev \
-libxrandr-dev \
-libxinerama-dev \
-libxcursor-dev \
-libxi-dev
+libx11-dev=2:1.6.4-3ubuntu0.2 \
+libxrandr-dev=2:1.5.1-1 \
+libxinerama-dev=2:1.1.3-1 \
+libxcursor-dev=1:1.1.15-1 \
+libxi-dev=2:1.7.9-1
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10 \
-libgmp-dev
+libgmp10=2:6.1.2+dfsg-2 \
+libgmp-dev=2:6.1.2+dfsg-2
 
 # simbody dependencies
 RUN apt-get install -y \
-liblapack-dev
+liblapack-dev=3.7.1-4ubuntu1
 
 # drogon dependencies
 RUN apt-get install -y \
-libjsonrpccpp-dev \
-uuid-dev
+libjsonrpccpp-dev=0.7.0-1build2 \
+uuid-dev=2.31.1-0.4ubuntu3.6
 
 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
 


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -13,34 +13,34 @@
 
 # test system dependencies
 RUN apt-get update && apt-get install -y \
-git \
-gettext \
-python3 \
-python3-pip \
-cmake \
-ninja-build
+git=1:2.17.1-1ubuntu0.7 \
+gettext=0.19.8.1-6ubuntu0.3 \
+python3=3.6.7-1~18.04 \
+python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
+cmake=3.17.3-0kitware1 \
+ninja-build=1.8.2-1
 
 # box2d dependencies
 RUN apt-get install -y \
-libx11-dev \
-libxrandr-dev \
-libxinerama-dev \
-libxcursor-dev \
-libxi-dev
+libx11-dev=2:1.6.4-3ubuntu0.2 \
+libxrandr-dev=2:1.5.1-1 \
+libxinerama-dev=2:1.1.3-1 \
+libxcursor-dev=1:1.1.15-1 \
+libxi-dev=2:1.7.9-1
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10 \
-libgmp-dev
+libgmp10=2:6.1.2+dfsg-2 \
+libgmp-dev=2:6.1.2+dfsg-2
 
 # simbody dependencies
 RUN apt-get install -y \
-liblapack-dev
+liblapack-dev=3.7.1-4ubuntu1
 
 # drogon dependencies
 RUN apt-get install -y \
-libjsonrpccpp-dev \
-uuid-dev
+libjsonrpccpp-dev=0.7.0-1build2 \
+uuid-dev=2.31.1-0.4ubuntu3.6
 
 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81595: [analyzer] SATest: Make main script Python2 compatible

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94f0eb83a2e5: [analyzer] SATest: Make main script Python2 
compatible (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81595

Files:
  clang/utils/analyzer/SATest.py


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -1,12 +1,5 @@
 #!/usr/bin/env python
 
-import SATestAdd
-import SATestBuild
-import SATestUpdateDiffs
-import CmpRuns
-
-from ProjectMap import ProjectInfo, ProjectMap
-
 import argparse
 import sys
 import os
@@ -22,6 +15,9 @@
 
 
 def add(parser, args):
+import SATestAdd
+from ProjectMap import ProjectInfo
+
 if args.source == "git" and (args.origin == "" or args.commit == ""):
 parser.error(
 "Please provide both --origin and --commit if source is 'git'")
@@ -37,6 +33,9 @@
 
 
 def build(parser, args):
+import SATestBuild
+from ProjectMap import ProjectMap
+
 SATestBuild.VERBOSE = args.verbose
 
 project_map = ProjectMap()
@@ -72,6 +71,16 @@
 
 
 def compare(parser, args):
+import CmpRuns
+
+choices = [CmpRuns.HistogramType.RELATIVE.value,
+   CmpRuns.HistogramType.LOG_RELATIVE.value,
+   CmpRuns.HistogramType.ABSOLUTE.value]
+
+if args.histogram is not None and args.histogram not in choices:
+parser.error("Incorrect histogram type, available choices are {}"
+ .format(choices))
+
 dir_old = CmpRuns.ResultsDirectory(args.old[0], args.root_old)
 dir_new = CmpRuns.ResultsDirectory(args.new[0], args.root_new)
 
@@ -83,6 +92,9 @@
 
 
 def update(parser, args):
+import SATestUpdateDiffs
+from ProjectMap import ProjectMap
+
 project_map = ProjectMap()
 for project in project_map.projects:
 SATestUpdateDiffs.update_reference_results(project)
@@ -145,8 +157,7 @@
 "(please provide --origin and --commit), "
 "'zip' for unpacking source from a zip file, "
 "'script' for downloading source by running "
-"a custom script {}"
-.format(SATestBuild.DOWNLOAD_SCRIPT))
+"a custom script")
 add_parser.add_argument("--origin", action="store", default="",
 help="Origin link for a git repository")
 add_parser.add_argument("--commit", action="store", default="",
@@ -207,9 +218,6 @@
 dest="show_stats", default=False,
 help="Show change in statistics")
 cmp_parser.add_argument("--histogram", action="store", default=None,
-choices=[CmpRuns.HistogramType.RELATIVE.value,
- CmpRuns.HistogramType.LOG_RELATIVE.value,
- CmpRuns.HistogramType.ABSOLUTE.value],
 help="Show histogram of paths differences. "
 "Requires matplotlib")
 cmp_parser.add_argument("old", nargs=1, help="Directory with old results")
@@ -231,6 +239,8 @@
 
 dock_parser.add_argument("--build-image", action="store_true",
  help="Build docker image for running tests.")
+dock_parser.add_argument("--shell", action="store_true",
+ help="Start a shell on docker.")
 dock_parser.add_argument("--llvm-project-dir", action="store",
  default=DEFAULT_LLVM_DIR,
  help="Path to LLVM source code. Defaults "


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -1,12 +1,5 @@
 #!/usr/bin/env python
 
-import SATestAdd
-import SATestBuild
-import SATestUpdateDiffs
-import CmpRuns
-
-from ProjectMap import ProjectInfo, ProjectMap
-
 import argparse
 import sys
 import os
@@ -22,6 +15,9 @@
 
 
 def add(parser, args):
+import SATestAdd
+from ProjectMap import ProjectInfo
+
 if args.source == "git" and (args.origin == "" or args.commit == ""):
 parser.error(
 "Please provide both --origin and --commit if source is 'git'")
@@ -37,6 +33,9 @@
 
 
 def build(parser, args):
+import SATestBuild
+from ProjectMap import ProjectMap
+
 SATestBuild.VERBOSE = args.verbose
 
 project_map = ProjectMap()
@@ -72,6 +71,16 @@
 
 
 def compare(parser, args):
+import CmpRuns
+
+choices = [CmpRuns.HistogramType.RELATIVE.value,
+   CmpRuns.HistogramType.LOG_RELATIVE.value,
+   CmpRuns.HistogramType.ABSOLUTE.value]
+
+if args.histogram is not None and args.histogram not in choices:
+   

[PATCH] D81598: [analyzer] SATest: Add an easy option to connect to docker for debugging

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11f287826fb3: [analyzer] SATest: Add an easy option to 
connect to docker for debugging (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81598

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/entrypoint.py

Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -2,13 +2,15 @@
 import os
 import sys
 
-from typing import List, Tuple
-
 from subprocess import call, check_call, CalledProcessError
+from time import sleep
+from typing import List, Tuple
 
 
 def main():
 settings, rest = parse_arguments()
+if settings.wait:
+wait()
 if settings.build_llvm or settings.build_llvm_only:
 build_llvm()
 if settings.build_llvm_only:
@@ -16,8 +18,16 @@
 sys.exit(test(rest))
 
 
+def wait():
+# It is an easy on CPU way of keeping the docker container running
+# while the user has a terminal session in that container.
+while True:
+sleep(3600)
+
+
 def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
 parser = argparse.ArgumentParser()
+parser.add_argument('--wait', action='store_true')
 parser.add_argument('--build-llvm', action='store_true')
 parser.add_argument('--build-llvm-only', action='store_true')
 return parser.parse_known_args()
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -108,8 +108,10 @@
 
 if args.build_image:
 docker_build_image()
+elif args.shell:
+docker_shell(args)
 else:
-docker_run(args)
+sys.exit(docker_run(args, ' '.join(args.rest)))
 
 
 def docker_build_image():
@@ -117,21 +119,40 @@
   shell=True))
 
 
-def docker_run(args):
-sys.exit(call("docker run --rm --name satest "
-  "-v {llvm}:/llvm-project "
-  "-v {build}:/build "
-  "-v {clang}:/analyzer "
-  "-v {scripts}:/scripts "
-  "-v {projects}:/projects "
-  "satest-image:latest {args}"
-  .format(llvm=args.llvm_project_dir,
-  build=args.build_dir,
-  clang=args.clang_dir,
-  scripts=SCRIPTS_DIR,
-  projects=PROJECTS_DIR,
-  args=' '.join(args.rest)),
-  shell=True))
+def docker_shell(args):
+try:
+# First we need to start the docker container in a waiting mode,
+# so it doesn't do anything, but most importantly keeps working
+# while the shell session is in progress.
+docker_run(args, "--wait", "--detach")
+# Since the docker container is running, we can actually connect to it
+call("docker exec -it satest bash", shell=True)
+
+except KeyboardInterrupt:
+pass
+
+finally:
+print("Please wait for docker to clean up")
+call("docker stop satest", shell=True)
+
+
+def docker_run(args, command, docker_args=""):
+return call("docker run --rm --name satest "
+"-v {llvm}:/llvm-project "
+"-v {build}:/build "
+"-v {clang}:/analyzer "
+"-v {scripts}:/scripts "
+"-v {projects}:/projects "
+"{docker_args} "
+"satest-image:latest {command}"
+.format(llvm=args.llvm_project_dir,
+build=args.build_dir,
+clang=args.clang_dir,
+scripts=SCRIPTS_DIR,
+projects=PROJECTS_DIR,
+docker_args=docker_args,
+command=command),
+shell=True)
 
 
 def main():
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81596: [analyzer] SATest: Do not re-run CMake in Docker if not needed

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG061b5bf914c6: [analyzer] SATest: Do not re-run CMake in 
Docker if not needed (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81596

Files:
  clang/utils/analyzer/entrypoint.py


Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -23,16 +23,21 @@
 return parser.parse_known_args()
 
 
-def build_llvm() -> None:
+def build_llvm():
 os.chdir('/build')
 try:
-cmake()
+if is_cmake_needed():
+cmake()
 ninja()
 except CalledProcessError:
 print("Build failed!")
 sys.exit(1)
 
 
+def is_cmake_needed():
+return "build.ninja" not in os.listdir()
+
+
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
 "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
 "-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \


Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -23,16 +23,21 @@
 return parser.parse_known_args()
 
 
-def build_llvm() -> None:
+def build_llvm():
 os.chdir('/build')
 try:
-cmake()
+if is_cmake_needed():
+cmake()
 ninja()
 except CalledProcessError:
 print("Build failed!")
 sys.exit(1)
 
 
+def is_cmake_needed():
+return "build.ninja" not in os.listdir()
+
+
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
 "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
 "-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81601: [analyzer] SATest: Use logger in single-threaded mode as well

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG495fd6404190: [analyzer] SATest: Use logger in 
single-threaded mode as well (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81601

Files:
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -70,9 +70,27 @@
 # Helper functions.
 ###
 
+class StreamToLogger:
+def __init__(self, logger: logging.Logger,
+ log_level: int = logging.INFO):
+self.logger = logger
+self.log_level = log_level
+
+def write(self, message: str):
+# Rstrip in order not to write an extra newline.
+self.logger.log(self.log_level, message.rstrip())
+
+def flush(self):
+pass
+
+def fileno(self) -> int:
+return 0
+
+
+Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = sys.stdout
-LOCAL.stderr = sys.stderr
+LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
 
 
 def stderr(message: str):
@@ -164,23 +182,6 @@
 VERBOSE = 0
 
 
-class StreamToLogger:
-def __init__(self, logger: logging.Logger,
- log_level: int = logging.INFO):
-self.logger = logger
-self.log_level = log_level
-
-def write(self, message: str):
-# Rstrip in order not to write an extra newline.
-self.logger.log(self.log_level, message.rstrip())
-
-def flush(self):
-pass
-
-def fileno(self) -> int:
-return 0
-
-
 ###
 # Test harness logic.
 ###


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -70,9 +70,27 @@
 # Helper functions.
 ###
 
+class StreamToLogger:
+def __init__(self, logger: logging.Logger,
+ log_level: int = logging.INFO):
+self.logger = logger
+self.log_level = log_level
+
+def write(self, message: str):
+# Rstrip in order not to write an extra newline.
+self.logger.log(self.log_level, message.rstrip())
+
+def flush(self):
+pass
+
+def fileno(self) -> int:
+return 0
+
+
+Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = sys.stdout
-LOCAL.stderr = sys.stderr
+LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
 
 
 def stderr(message: str):
@@ -164,23 +182,6 @@
 VERBOSE = 0
 
 
-class StreamToLogger:
-def __init__(self, logger: logging.Logger,
- log_level: int = logging.INFO):
-self.logger = logger
-self.log_level = log_level
-
-def write(self, message: str):
-# Rstrip in order not to write an extra newline.
-self.logger.log(self.log_level, message.rstrip())
-
-def flush(self):
-pass
-
-def fileno(self) -> int:
-return 0
-
-
 ###
 # Test harness logic.
 ###
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81593: [analyzer] SATest: Make docker interfaces transparent

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe30706af2e14: [analyzer] SATest: Make docker interfaces 
transparent (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81593

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/entrypoint.py

Index: clang/utils/analyzer/entrypoint.py
===
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -1,9 +1,10 @@
 import argparse
 import os
+import sys
 
 from typing import List, Tuple
 
-from subprocess import check_call
+from subprocess import call, check_call, CalledProcessError
 
 
 def main():
@@ -12,7 +13,7 @@
 build_llvm()
 if settings.build_llvm_only:
 return
-test(rest)
+sys.exit(test(rest))
 
 
 def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
@@ -24,8 +25,12 @@
 
 def build_llvm() -> None:
 os.chdir('/build')
-cmake()
-ninja()
+try:
+cmake()
+ninja()
+except CalledProcessError:
+print("Build failed!")
+sys.exit(1)
 
 
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
@@ -43,9 +48,9 @@
 check_call("ninja install", shell=True)
 
 
-def test(args: List[str]):
+def test(args: List[str]) -> int:
 os.chdir("/projects")
-check_call("/scripts/SATest.py " + " ".join(args), shell=True)
+return call("/scripts/SATest.py " + " ".join(args), shell=True)
 
 
 if __name__ == '__main__':
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -11,7 +11,7 @@
 import sys
 import os
 
-from subprocess import check_call
+from subprocess import call
 
 SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
 PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
@@ -101,22 +101,25 @@
 
 
 def docker_build_image():
-check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
-   shell=True)
+sys.exit(call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
+  shell=True))
 
 
 def docker_run(args):
-check_call("docker run --rm --name satest "
-   "-v {llvm}:/llvm-project "
-   "-v {build}:/build "
-   "-v {clang}:/analyzer "
-   "-v {scripts}:/scripts "
-   "-v {projects}:/projects "
-   "satest-image:latest {args}"
-   .format(llvm=args.llvm_project_dir, build=args.build_dir,
-   clang=args.clang_dir, scripts=SCRIPTS_DIR,
-   projects=PROJECTS_DIR, args=' '.join(args.rest)),
-   shell=True)
+sys.exit(call("docker run --rm --name satest "
+  "-v {llvm}:/llvm-project "
+  "-v {build}:/build "
+  "-v {clang}:/analyzer "
+  "-v {scripts}:/scripts "
+  "-v {projects}:/projects "
+  "satest-image:latest {args}"
+  .format(llvm=args.llvm_project_dir,
+  build=args.build_dir,
+  clang=args.clang_dir,
+  scripts=SCRIPTS_DIR,
+  projects=PROJECTS_DIR,
+  args=' '.join(args.rest)),
+  shell=True))
 
 
 def main():
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81599: [analyzer] SATest: Add 5 more projects for testing

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f55355c16b6: [analyzer] SATest: Add 5 more projects for 
testing (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81599

Files:
  clang/utils/analyzer/Dockerfile
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/projects/drogon/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/drogon/run_static_analyzer.cmd
  clang/utils/analyzer/projects/duckdb/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/duckdb/run_static_analyzer.cmd
  clang/utils/analyzer/projects/fmt/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/fmt/run_static_analyzer.cmd
  clang/utils/analyzer/projects/projects.json
  clang/utils/analyzer/projects/re2/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/re2/run_static_analyzer.cmd
  clang/utils/analyzer/projects/simbody/cleanup_run_static_analyzer.sh
  clang/utils/analyzer/projects/simbody/run_static_analyzer.cmd

Index: clang/utils/analyzer/projects/simbody/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/simbody/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/simbody/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/simbody/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/re2/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/re2/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/re2/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/re2/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/projects.json
===
--- clang/utils/analyzer/projects/projects.json
+++ clang/utils/analyzer/projects/projects.json
@@ -68,5 +68,40 @@
 "source": "git",
 "origin": "https://github.com/facebook/zstd.git";,
 "commit": "2af4e073"
+  },
+  {
+"name": "simbody",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/simbody/simbody.git";,
+"commit": "5cf513d"
+  },
+  {
+"name": "duckdb",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/cwida/duckdb.git";,
+"commit": "d098c9f"
+  },
+  {
+"name": "drogon",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/an-tao/drogon.git";,
+"commit": "fd2a612"
+  },
+  {
+"name": "fmt",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/fmtlib/fmt.git";,
+"commit": "5e7c70e"
+  },
+  {
+"name": "re2",
+"mode": 1,
+"source": "git",
+"origin": "https://github.com/google/re2.git";,
+"commit": "2b25567"
   }
 ]
Index: clang/utils/analyzer/projects/fmt/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/fmt/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/fmt/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/fmt/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/duckdb/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/duckdb/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/duckdb/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/duckdb/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: clang/utils/analyzer/projects/drogon/run_static_analyzer.cmd
===
--- /dev/null
+++ clang/utils/analyzer/projects/drogon/run_static_analyzer.cmd
@@ -0,0 +1,2 @@
+cmake . -DCMAKE_BUILD_TYPE=Debug -Bbuild -GNinja
+cmake --build build
Index: clang/utils/analyzer/projects/drogon/cleanup_run_static_analyzer.sh
===
--- /dev/null
+++ clang/utils/analyzer/projects/drogon/cleanup_run_static_analyzer.sh
@@ -0,0 +1 @@
+rm -rf ./build
Index: c

[clang] e4e2d8e - Ensure that CompilerInvocationTest normalizes default target triples

2020-06-25 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2020-06-25T10:41:40+01:00
New Revision: e4e2d8e4c2d2d61a5baf7eeab69a3f539343eca6

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

LOG: Ensure that CompilerInvocationTest normalizes default target triples

This fixes a build failure. More details at 
http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/78/steps/test-check-clang/logs/FAIL%3A%20Clang-Unit%3A%3ACC1CommandLineGenerationTest.CanGenerateCC1CommandLineSeparateRequiredAbsent

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 9cce66e41872..ed82d678462f 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -78,7 +78,8 @@ TEST_F(CC1CommandLineGenerationTest,
 
 TEST_F(CC1CommandLineGenerationTest,
CanGenerateCC1CommandLineSeparateRequiredAbsent) {
-  const std::string DefaultTriple = llvm::sys::getDefaultTargetTriple();
+  const std::string DefaultTriple =
+  llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
   const char *Args[] = {"clang", "-xc++", "-"};
 
   CompilerInvocation CInvok;



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


[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-25 Thread liu hui via Phabricator via cfe-commits
lh123 created this revision.
lh123 added a reviewer: kadircet.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
lh123 added a parent revision: D82373: [CodeComplete] Tweak code completion for 
`typename`..

Add code completion for using alias.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82535

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -59,6 +59,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -102,6 +103,7 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
+  // CHECK-CC2-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
@@ -140,6 +142,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC3-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -232,6 +235,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -62,6 +62,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -112,6 +113,7 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
@@ -156,6 +158,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -264,6 +267,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1816,6 +1816,19 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+// using name = type
+static void AddUsingAliasResult(ResultBuilder &Results) {
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+Results.getCodeCompletionTUInfo());
+  Builder.AddTypedTextChunk("using");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_Equal);
+  Builder.AddPlaceholderChunk("type");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}

[PATCH] D80981: [AST] Fix a crash on accessing a class without definition in constexpr function context.

2020-06-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 273281.
hokein marked 5 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80981

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-default-init-value-crash.cpp

Index: clang/test/SemaCXX/constexpr-default-init-value-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-default-init-value-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify -fno-recovery-ast
+
+namespace NoCrash {
+struct ForwardDecl; // expected-note {{forward declaration of}}
+struct Foo {// expected-note 2{{candidate constructor}}
+  ForwardDecl f;// expected-error {{field has incomplete type}}
+};
+
+constexpr Foo getFoo() {
+  Foo e = 123; // expected-error {{no viable conversion from 'int' to 'NoCrash::Foo'}}
+  return e;
+}
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4475,37 +4475,48 @@
 }
 
 /// Get the value to use for a default-initialized object of type T.
-static APValue getDefaultInitValue(QualType T) {
+/// Return false if it encounters something invalid.
+static bool getDefaultInitValue(QualType T, APValue &Result) {
+  bool Success = true;
   if (auto *RD = T->getAsCXXRecordDecl()) {
-if (RD->isUnion())
-  return APValue((const FieldDecl*)nullptr);
-
-APValue Struct(APValue::UninitStruct(), RD->getNumBases(),
-   std::distance(RD->field_begin(), RD->field_end()));
+if (RD->isInvalidDecl()) {
+  Result = APValue();
+  return false;
+}
+if (RD->isUnion()) {
+  Result = APValue((const FieldDecl *)nullptr);
+  return true;
+}
+Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
+ std::distance(RD->field_begin(), RD->field_end()));
 
 unsigned Index = 0;
 for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
-   End = RD->bases_end(); I != End; ++I, ++Index)
-  Struct.getStructBase(Index) = getDefaultInitValue(I->getType());
+  End = RD->bases_end();
+ I != End; ++I, ++Index)
+  Success &= getDefaultInitValue(I->getType(), Result.getStructBase(Index));
 
 for (const auto *I : RD->fields()) {
   if (I->isUnnamedBitfield())
 continue;
-  Struct.getStructField(I->getFieldIndex()) =
-  getDefaultInitValue(I->getType());
+  Success &= getDefaultInitValue(I->getType(),
+ Result.getStructField(I->getFieldIndex()));
 }
-return Struct;
+return Success;
   }
 
   if (auto *AT =
   dyn_cast_or_null(T->getAsArrayTypeUnsafe())) {
-APValue Array(APValue::UninitArray(), 0, AT->getSize().getZExtValue());
-if (Array.hasArrayFiller())
-  Array.getArrayFiller() = getDefaultInitValue(AT->getElementType());
-return Array;
+Result = APValue(APValue::UninitArray(), 0, AT->getSize().getZExtValue());
+if (Result.hasArrayFiller())
+  Success &=
+  getDefaultInitValue(AT->getElementType(), Result.getArrayFiller());
+
+return Success;
   }
 
-  return APValue::IndeterminateValue();
+  Result = APValue::IndeterminateValue();
+  return true;
 }
 
 namespace {
@@ -4535,10 +4546,8 @@
   Info.CurrentCall->createTemporary(VD, VD->getType(), true, Result);
 
   const Expr *InitE = VD->getInit();
-  if (!InitE) {
-Val = getDefaultInitValue(VD->getType());
-return true;
-  }
+  if (!InitE)
+return getDefaultInitValue(VD->getType(), Val);
 
   if (InitE->isValueDependent())
 return false;
@@ -5535,11 +5544,11 @@
   const Expr *LHSExpr;
   const FieldDecl *Field;
   bool DuringInit;
-
+  bool Failed = false;
   static const AccessKinds AccessKind = AK_Assign;
 
   typedef bool result_type;
-  bool failed() { return false; }
+  bool failed() { return Failed; }
   bool found(APValue &Subobj, QualType SubobjType) {
 // We are supposed to perform no initialization but begin the lifetime of
 // the object. We interpret that as meaning to do what default
@@ -5563,8 +5572,9 @@
   diag::note_constexpr_union_member_change_during_init);
   return false;
 }
-
-Subobj.setUnion(Field, getDefaultInitValue(Field->getType()));
+APValue Result;
+Failed = !getDefaultInitValue(Field->getType(), Result);
+Subobj.setUnion(Field, Result);
 return true;
   }
   bool found(APSInt &Value, QualType SubobjType) {
@@ -5880,8 +5890,9 @@
 for (; !declaresSameEntity(*FieldIt, FD); ++FieldIt) {
   assert(FieldIt != RD->field_end() && "missing field?");
   if (!FieldIt->isUnnamedBitfield())
-R

[PATCH] D80981: [AST] Fix a crash on accessing a class without definition in constexpr function context.

2020-06-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the review!




Comment at: clang/lib/AST/ExprConstant.cpp:4320
+if (!RD->hasDefinition())
+  return APValue();
 APValue Struct(APValue::UninitStruct(), RD->getNumBases(),

rsmith wrote:
> hokein wrote:
> > rsmith wrote:
> > > hokein wrote:
> > > > rsmith wrote:
> > > > > hokein wrote:
> > > > > > sammccall wrote:
> > > > > > > This doesn't look all that safe - you're using a `None` value to 
> > > > > > > indicate failure, but no current code path does that and none of 
> > > > > > > the callers seem to check for failure.
> > > > > > > (e.g. `evaluateVarDecl` returns true instead of false).
> > > > > > > Presumably we're going to get a diagnostic somewhere (though it's 
> > > > > > > not completely obvious to me) but can we be sure we won't assume 
> > > > > > > this value has the right type somewhere down the line?
> > > > > > > 
> > > > > > > I get the feeling this is correct and I don't have enough context 
> > > > > > > to understand why... how about you :-)
> > > > > > I don't have a promising explanation neither. 
> > > > > > 
> > > > > > I didn't find a better way to model failures in 
> > > > > > `getDefaultInitValue`. This function is used in multiple places of 
> > > > > > this file (and I'm not sure whether we should change it).
> > > > > > 
> > > > > > @rsmith any thoughts?
> > > > > `APValue()` is a valid representation for an object of class type, 
> > > > > representing a class object that is outside its lifetime, so I think 
> > > > > it's OK to use this representation, if we can be sure that this only 
> > > > > happens along error paths. (It's not ideal, though.)
> > > > > 
> > > > > If we can't be sure this happens only along error paths, then we 
> > > > > should produce a diagnostic here. Perhaps feed an `EvalInfo&` and a 
> > > > > source location into every caller of this function and produce a 
> > > > > diagnostic if we end up querying the default-initialized value of an 
> > > > > incomplete-but-valid class type. Or perhaps we could check that the 
> > > > > class is complete and valid from every caller of this function 
> > > > > instead. (I think that we guarantee that, for a valid complete class 
> > > > > type, all transitive subobjects are of valid complete types, so 
> > > > > checking this only once at the top level before calling into 
> > > > > `getDefaultInitValue` should be enough.)
> > > > Thanks for the suggestions.
> > > > 
> > > > oh, yeah, I missed that the `Foo` Decl is invalid, so checking the 
> > > > class decl is valid at every caller of `getDefaultInitValue` should 
> > > > work -- it would also fix other potential issues, looks like here we 
> > > > guarantee that the VarDecl is valid, but don't verify the decl which 
> > > > the VarDecl's type refers to is valid in all callers.  
> > > > 
> > > > Given the fact that the `VarDecl` e is valid and class `Foo` Decl is 
> > > > invalid, another option to fix the crash is to invalidate this 
> > > > `VarDecl`. Should we invalidate the VarDecl if the type of the VarDecl 
> > > > refers to an invalid decl? My gut feeling is that it is worth keeping 
> > > > the VarDecl valid, so that more related AST nodes will be built (for 
> > > > better recovery and diagnostics), though it seems unsafe. 
> > > I think keeping the `VarDecl` valid is probably the better choice, to 
> > > allow us to build downstream uses of it. Also, because variables can be 
> > > redeclared, we could have something like `struct A; extern A v; struct A 
> > > { invalid; };` -- and we can't reasonably retroactively mark `v` as 
> > > invalid in this case, so we can't guarantee that the type of every valid 
> > > variable is itself valid. (We *could* guarantee that the type of every 
> > > valid variable *definition* is valid, but that will lead to 
> > > inconsistencies where defining the variable causes later behavior of 
> > > references to the variable to change.)
> > > 
> > > It's really unfortunate that we don't have a good definition of what 
> > > "valid" means for a variable, or really any listing of what invariants we 
> > > maintain in the AST in the presence of invalid nodes. :( This is one of 
> > > the things I would work on if I had time...
> > > I think keeping the VarDecl valid is probably the better choice, to allow 
> > > us to build downstream uses of it. Also, because variables can be 
> > > redeclared, we could have something like struct A; extern A v; struct A { 
> > > invalid; }; -- and we can't reasonably retroactively mark v as invalid in 
> > > this case, so we can't guarantee that the type of every valid variable is 
> > > itself valid. (We *could* guarantee that the type of every valid variable 
> > > *definition* is valid, but that will lead to inconsistencies where 
> > > defining the variable causes later behavior of references to the variable 
> > > to change.
> > 
> > yeah, that makes sense, thanks for the explanation.
> > 
> > I have

[PATCH] D81282: [builtins] Move more float128-related helpers to GENERIC_TF_SOURCES list

2020-06-25 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81282



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


[clang] b5d3abe - [libclang] Get rid of relience on SourceManager member signature

2020-06-25 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-25T12:04:12+02:00
New Revision: b5d3abea228bf17a009a007061c82d14461766c7

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

LOG: [libclang] Get rid of relience on SourceManager member signature

Summary:
Libclang was enforcing a singature on SourceManager::getLocalSLocEntry
which isn't possible to satisfy as pointed out in
https://reviews.llvm.org/D80681#inline-751438.

This patch updates the libclang, hopefully without breaking API stability, to
not rely on member signature. To enable changing the signature in D82498.

Reviewers: sammccall, bkramer

Subscribers: arphaman, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/tools/libclang/CIndexInclusionStack.cpp

Removed: 




diff  --git a/clang/tools/libclang/CIndexInclusionStack.cpp 
b/clang/tools/libclang/CIndexInclusionStack.cpp
index f1c5b53c5ef6..7572512ae576 100644
--- a/clang/tools/libclang/CIndexInclusionStack.cpp
+++ b/clang/tools/libclang/CIndexInclusionStack.cpp
@@ -18,10 +18,9 @@
 #include "clang/Frontend/ASTUnit.h"
 using namespace clang;
 
-static void getInclusions(const SrcMgr::SLocEntry 
&(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
-  CXTranslationUnit TU, CXInclusionVisitor CB,
-  CXClientData clientData)
-{
+namespace {
+void getInclusions(bool IsLocal, unsigned n, CXTranslationUnit TU,
+   CXInclusionVisitor CB, CXClientData clientData) {
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
@@ -30,8 +29,8 @@ static void getInclusions(const SrcMgr::SLocEntry 
&(SourceManager::*Getter)(unsi
 
   for (unsigned i = 0 ; i < n ; ++i) {
 bool Invalid = false;
-const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+const SrcMgr::SLocEntry &SL =
+IsLocal ? SM.getLocalSLocEntry(i) : SM.getLoadedSLocEntry(i, &Invalid);
 if (!SL.isFile() || Invalid)
   continue;
 
@@ -61,11 +60,11 @@ static void getInclusions(const SrcMgr::SLocEntry 
&(SourceManager::*Getter)(unsi
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
- const_cast(FI.getContentCache()->OrigEntry)),
+   const_cast(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
   }
 }
-
+} // namespace
 
 void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
  CXClientData clientData) {
@@ -83,14 +82,13 @@ void clang_getInclusions(CXTranslationUnit TU, 
CXInclusionVisitor CB,
   // a AST/PCH file, but this file has a pre-compiled preamble, we also need
   // to look in that file.
   if (n == 1 || SM.getPreambleFileID().isValid()) {
-getInclusions(&SourceManager::getLoadedSLocEntry,
-  SM.loaded_sloc_entry_size(), TU, CB, clientData);
+getInclusions(/*IsLocal=*/false, SM.loaded_sloc_entry_size(), TU, CB,
+  clientData);
   }
 
   // Not a PCH/AST file. Note, if there is a preamble, it could still be that
   // there are #includes in this file (e.g. for any include after the first
   // declaration).
   if (n != 1)
-getInclusions(&SourceManager::getLocalSLocEntry, n, TU, CB, clientData);
-
+getInclusions(/*IsLocal=*/true, n, TU, CB, clientData);
 }



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


[PATCH] D82256: [analyzer] Enable constructor support in evalCall event

2020-06-25 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added a comment.

In D82256#2113233 , @NoQ wrote:

> @vrnithinkumar what's your preferred `Full Name ` for llvm's git?


Nithin Vadukkumchery Rajendrakumar 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82256



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


[PATCH] D82532: [libclang] Get rid of relience on SourceManager member signature

2020-06-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5d3abea228b: [libclang] Get rid of relience on 
SourceManager member signature (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82532

Files:
  clang/tools/libclang/CIndexInclusionStack.cpp


Index: clang/tools/libclang/CIndexInclusionStack.cpp
===
--- clang/tools/libclang/CIndexInclusionStack.cpp
+++ clang/tools/libclang/CIndexInclusionStack.cpp
@@ -18,10 +18,9 @@
 #include "clang/Frontend/ASTUnit.h"
 using namespace clang;
 
-static void getInclusions(const SrcMgr::SLocEntry 
&(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
-  CXTranslationUnit TU, CXInclusionVisitor CB,
-  CXClientData clientData)
-{
+namespace {
+void getInclusions(bool IsLocal, unsigned n, CXTranslationUnit TU,
+   CXInclusionVisitor CB, CXClientData clientData) {
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
@@ -30,8 +29,8 @@
 
   for (unsigned i = 0 ; i < n ; ++i) {
 bool Invalid = false;
-const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+const SrcMgr::SLocEntry &SL =
+IsLocal ? SM.getLocalSLocEntry(i) : SM.getLoadedSLocEntry(i, &Invalid);
 if (!SL.isFile() || Invalid)
   continue;
 
@@ -61,11 +60,11 @@
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
- const_cast(FI.getContentCache()->OrigEntry)),
+   const_cast(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
   }
 }
-
+} // namespace
 
 void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
  CXClientData clientData) {
@@ -83,14 +82,13 @@
   // a AST/PCH file, but this file has a pre-compiled preamble, we also need
   // to look in that file.
   if (n == 1 || SM.getPreambleFileID().isValid()) {
-getInclusions(&SourceManager::getLoadedSLocEntry,
-  SM.loaded_sloc_entry_size(), TU, CB, clientData);
+getInclusions(/*IsLocal=*/false, SM.loaded_sloc_entry_size(), TU, CB,
+  clientData);
   }
 
   // Not a PCH/AST file. Note, if there is a preamble, it could still be that
   // there are #includes in this file (e.g. for any include after the first
   // declaration).
   if (n != 1)
-getInclusions(&SourceManager::getLocalSLocEntry, n, TU, CB, clientData);
-
+getInclusions(/*IsLocal=*/true, n, TU, CB, clientData);
 }


Index: clang/tools/libclang/CIndexInclusionStack.cpp
===
--- clang/tools/libclang/CIndexInclusionStack.cpp
+++ clang/tools/libclang/CIndexInclusionStack.cpp
@@ -18,10 +18,9 @@
 #include "clang/Frontend/ASTUnit.h"
 using namespace clang;
 
-static void getInclusions(const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
-  CXTranslationUnit TU, CXInclusionVisitor CB,
-  CXClientData clientData)
-{
+namespace {
+void getInclusions(bool IsLocal, unsigned n, CXTranslationUnit TU,
+   CXInclusionVisitor CB, CXClientData clientData) {
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
@@ -30,8 +29,8 @@
 
   for (unsigned i = 0 ; i < n ; ++i) {
 bool Invalid = false;
-const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+const SrcMgr::SLocEntry &SL =
+IsLocal ? SM.getLocalSLocEntry(i) : SM.getLoadedSLocEntry(i, &Invalid);
 if (!SL.isFile() || Invalid)
   continue;
 
@@ -61,11 +60,11 @@
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
- const_cast(FI.getContentCache()->OrigEntry)),
+   const_cast(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
   }
 }
-
+} // namespace
 
 void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
  CXClientData clientData) {
@@ -83,14 +82,13 @@
   // a AST/PCH file, but this file has a pre-compiled preamble, we also need
   // to look in that file.
   if (n == 1 || SM.getPreambleFileID().isValid()) {
-getInclusions(&SourceManager::getLoadedSLocEntry,
-  SM.loaded_sloc_entry_size(), TU, CB, clientData);
+getInclusions(/*IsLocal=*/false, SM.loaded_sloc_entry_size(), TU, CB,
+  clientData);
   }
 
   // Not a PCH/AST file. Note, if there is a preamble, it could still be that
   // there are #includes in this file (e.g. for any include after the first
   // declaration).
   if 

[clang] 9fb7e98 - [AST] Fix a crash on accessing a class without definition in constexpr function context.

2020-06-25 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-25T12:13:05+02:00
New Revision: 9fb7e98db5aaef617878a127b663efa4d01aa834

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

LOG: [AST] Fix a crash on accessing a class without definition in constexpr 
function context.

Reviewed By: rsmith

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

Added: 
clang/test/SemaCXX/constexpr-default-init-value-crash.cpp

Modified: 
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 45a2fd2a53d2..afae020f3dd2 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -4475,37 +4475,48 @@ static bool HandleBaseToDerivedCast(EvalInfo &Info, 
const CastExpr *E,
 }
 
 /// Get the value to use for a default-initialized object of type T.
-static APValue getDefaultInitValue(QualType T) {
+/// Return false if it encounters something invalid.
+static bool getDefaultInitValue(QualType T, APValue &Result) {
+  bool Success = true;
   if (auto *RD = T->getAsCXXRecordDecl()) {
-if (RD->isUnion())
-  return APValue((const FieldDecl*)nullptr);
-
-APValue Struct(APValue::UninitStruct(), RD->getNumBases(),
-   std::distance(RD->field_begin(), RD->field_end()));
+if (RD->isInvalidDecl()) {
+  Result = APValue();
+  return false;
+}
+if (RD->isUnion()) {
+  Result = APValue((const FieldDecl *)nullptr);
+  return true;
+}
+Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
+ std::distance(RD->field_begin(), RD->field_end()));
 
 unsigned Index = 0;
 for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
-   End = RD->bases_end(); I != End; ++I, ++Index)
-  Struct.getStructBase(Index) = getDefaultInitValue(I->getType());
+  End = RD->bases_end();
+ I != End; ++I, ++Index)
+  Success &= getDefaultInitValue(I->getType(), 
Result.getStructBase(Index));
 
 for (const auto *I : RD->fields()) {
   if (I->isUnnamedBitfield())
 continue;
-  Struct.getStructField(I->getFieldIndex()) =
-  getDefaultInitValue(I->getType());
+  Success &= getDefaultInitValue(I->getType(),
+ 
Result.getStructField(I->getFieldIndex()));
 }
-return Struct;
+return Success;
   }
 
   if (auto *AT =
   dyn_cast_or_null(T->getAsArrayTypeUnsafe())) {
-APValue Array(APValue::UninitArray(), 0, AT->getSize().getZExtValue());
-if (Array.hasArrayFiller())
-  Array.getArrayFiller() = getDefaultInitValue(AT->getElementType());
-return Array;
+Result = APValue(APValue::UninitArray(), 0, AT->getSize().getZExtValue());
+if (Result.hasArrayFiller())
+  Success &=
+  getDefaultInitValue(AT->getElementType(), Result.getArrayFiller());
+
+return Success;
   }
 
-  return APValue::IndeterminateValue();
+  Result = APValue::IndeterminateValue();
+  return true;
 }
 
 namespace {
@@ -4535,10 +4546,8 @@ static bool EvaluateVarDecl(EvalInfo &Info, const 
VarDecl *VD) {
   Info.CurrentCall->createTemporary(VD, VD->getType(), true, Result);
 
   const Expr *InitE = VD->getInit();
-  if (!InitE) {
-Val = getDefaultInitValue(VD->getType());
-return true;
-  }
+  if (!InitE)
+return getDefaultInitValue(VD->getType(), Val);
 
   if (InitE->isValueDependent())
 return false;
@@ -5535,11 +5544,11 @@ struct StartLifetimeOfUnionMemberHandler {
   const Expr *LHSExpr;
   const FieldDecl *Field;
   bool DuringInit;
-
+  bool Failed = false;
   static const AccessKinds AccessKind = AK_Assign;
 
   typedef bool result_type;
-  bool failed() { return false; }
+  bool failed() { return Failed; }
   bool found(APValue &Subobj, QualType SubobjType) {
 // We are supposed to perform no initialization but begin the lifetime of
 // the object. We interpret that as meaning to do what default
@@ -5563,8 +5572,9 @@ struct StartLifetimeOfUnionMemberHandler {
   diag::note_constexpr_union_member_change_during_init);
   return false;
 }
-
-Subobj.setUnion(Field, getDefaultInitValue(Field->getType()));
+APValue Result;
+Failed = !getDefaultInitValue(Field->getType(), Result);
+Subobj.setUnion(Field, Result);
 return true;
   }
   bool found(APSInt &Value, QualType SubobjType) {
@@ -5880,8 +5890,9 @@ static bool HandleConstructorCall(const Expr *E, const 
LValue &This,
 for (; !declaresSameEntity(*FieldIt, FD); ++FieldIt) {
   assert(FieldIt != RD->field_end() && "missing field?");
   if (!FieldIt->isUnnamedBitfield())
-Result.getStructField(FieldIt->getFieldIndex()) =
-getDefaultInitValue(FieldIt

RE: [clang] 9d8d064 - [NFC] Silence compiler warning [-Wmissing-braces].

2020-06-25 Thread Huihui Zhang via cfe-commits
Thanks for the feedback! 😊

-Original Message-
From: David Blaikie 
Sent: Wednesday, June 24, 2020 1:49 PM
To: Huihui Zhang ; Huihui Zhang 
Cc: cfe-commits 
Subject: [EXT] Re: [clang] 9d8d064 - [NFC] Silence compiler warning 
[-Wmissing-braces].

Generally it'd be helpful to describe what the change is in the subject line 
("Add braces around initialization of a subobject
[-Wmissing-braces]") as that's more informative than "Silence compiler warning 
[-Wmissing braces]", the latter doesn't say how it was silenced, which might 
make a difference/be relevant to those reading/reviewing changes (makes a 
difference to me, at least)

On Wed, Jun 17, 2020 at 1:02 PM Huihui Zhang via cfe-commits 
 wrote:
>
>
> Author: Huihui Zhang
> Date: 2020-06-17T13:01:53-07:00
> New Revision: 9d8d0646d751326e2766caeaa20f6e0d4b89a4f6
>
> URL:
> https://github.com/llvm/llvm-project/commit/9d8d0646d751326e2766caeaa2
> 0f6e0d4b89a4f6
> DIFF:
> https://github.com/llvm/llvm-project/commit/9d8d0646d751326e2766caeaa2
> 0f6e0d4b89a4f6.diff
>
> LOG: [NFC] Silence compiler warning [-Wmissing-braces].
>
> clang/lib/CodeGen/CGNonTrivialStruct.cpp:330:7: warning: suggest braces 
> around initialization of subobject [-Wmissing-braces]
>   Address(CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
>   ^~~~
>   {
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGNonTrivialStruct.cpp
>
> Removed:
>
>
>
> ##
> ## diff  --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
> b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
> index 73188c48e885..d134be83a9dc 100644
> --- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
> +++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
> @@ -326,9 +326,9 @@ static std::array 
> getParamAddrs(std::index_sequence IntSeq,
>  std::array 
> Alignments,
>  FunctionArgList Args,
>  CodeGenFunction *CGF) {
> -  return std::array{
> +  return std::array{{
>Address(CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
> -  Alignments[Ints])...};
> +  Alignments[Ints])...}};
>  }
>
>  // Template classes that are used as bases for classes that emit
> special
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-25 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2082
+  const Type *RetTyPtr = RetTy.getTypePtr();
+  if (!RetTy->isVoidType() && !RetTyPtr->isRecordType() &&
+  RetAI.getKind() != ABIArgInfo::Indirect) {

Other types that we should think about from a padding perspective:

 * `nullptr_t` (which has the same size and alignment as `void*` but is all 
padding)
 * 80-bit `long double` and `_Complex long double` (I don't know whether we 
guarantee to initialize the 6 padding bytes)
 * member pointers might contain padding under some ABI rules -- under the MS 
ABI, you get a struct containing N pointers followed by M ints, which could 
have 4 bytes of tail padding on 64-bit targets
 * vector types with tail padding (eg, a vector of 3 `char`s is sometimes 
passed as an `i32` with one byte `undef`)
 * matrix types (presumably the same concerns as for vector types apply here)
 * maybe Obj-C object types?
 * `_ExtInt` types (eg, returning an `_ExtInt(65)` initialized to 0 produces an 
`{i64, i64}` containing 7 bytes of `undef`)

It would be safer to list exactly those types for which we know this assumption 
is correct rather than assuming that it's correct by default -- I think more 
than half of the `Type` subclasses for concrete canonical types can have undef 
bits in their IR representation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

> We don't have any optimizations that infer either "speculatable" or "frozen", 
> though, so I'm not sure there's any practical impact here.

`speculatable` is on the shortlist for the Attributor. Will happen eventually. 
I am sure `frozen` will follow once it is in. We already came across the "need" 
in the `nonnull` conversation for example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-25 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 273287.
lh123 added a comment.

format code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82535

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -59,6 +59,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -102,6 +103,7 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
+  // CHECK-CC2-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
@@ -140,6 +142,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC3-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -232,6 +235,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -62,6 +62,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -112,6 +113,7 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
@@ -156,6 +158,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -264,6 +267,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1816,6 +1816,19 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+// using name = type
+static void AddUsingAliasResult(ResultBuilder &Results) {
+  CodeCompletionBuilder Builder(Results.getAllocator(),
+Results.getCodeCompletionTUInfo());
+  Builder.AddTypedTextChunk("using");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_Equal);
+  Builder.AddPlaceholderChunk("type");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+
 static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
const LangOptions

[PATCH] D80981: [AST] Fix a crash on accessing a class without definition in constexpr function context.

2020-06-25 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9fb7e98db5aa: [AST] Fix a crash on accessing a class without 
definition in constexpr function… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80981

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-default-init-value-crash.cpp

Index: clang/test/SemaCXX/constexpr-default-init-value-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-default-init-value-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify -fno-recovery-ast
+
+namespace NoCrash {
+struct ForwardDecl; // expected-note {{forward declaration of}}
+struct Foo {// expected-note 2{{candidate constructor}}
+  ForwardDecl f;// expected-error {{field has incomplete type}}
+};
+
+constexpr Foo getFoo() {
+  Foo e = 123; // expected-error {{no viable conversion from 'int' to 'NoCrash::Foo'}}
+  return e;
+}
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4475,37 +4475,48 @@
 }
 
 /// Get the value to use for a default-initialized object of type T.
-static APValue getDefaultInitValue(QualType T) {
+/// Return false if it encounters something invalid.
+static bool getDefaultInitValue(QualType T, APValue &Result) {
+  bool Success = true;
   if (auto *RD = T->getAsCXXRecordDecl()) {
-if (RD->isUnion())
-  return APValue((const FieldDecl*)nullptr);
-
-APValue Struct(APValue::UninitStruct(), RD->getNumBases(),
-   std::distance(RD->field_begin(), RD->field_end()));
+if (RD->isInvalidDecl()) {
+  Result = APValue();
+  return false;
+}
+if (RD->isUnion()) {
+  Result = APValue((const FieldDecl *)nullptr);
+  return true;
+}
+Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
+ std::distance(RD->field_begin(), RD->field_end()));
 
 unsigned Index = 0;
 for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
-   End = RD->bases_end(); I != End; ++I, ++Index)
-  Struct.getStructBase(Index) = getDefaultInitValue(I->getType());
+  End = RD->bases_end();
+ I != End; ++I, ++Index)
+  Success &= getDefaultInitValue(I->getType(), Result.getStructBase(Index));
 
 for (const auto *I : RD->fields()) {
   if (I->isUnnamedBitfield())
 continue;
-  Struct.getStructField(I->getFieldIndex()) =
-  getDefaultInitValue(I->getType());
+  Success &= getDefaultInitValue(I->getType(),
+ Result.getStructField(I->getFieldIndex()));
 }
-return Struct;
+return Success;
   }
 
   if (auto *AT =
   dyn_cast_or_null(T->getAsArrayTypeUnsafe())) {
-APValue Array(APValue::UninitArray(), 0, AT->getSize().getZExtValue());
-if (Array.hasArrayFiller())
-  Array.getArrayFiller() = getDefaultInitValue(AT->getElementType());
-return Array;
+Result = APValue(APValue::UninitArray(), 0, AT->getSize().getZExtValue());
+if (Result.hasArrayFiller())
+  Success &=
+  getDefaultInitValue(AT->getElementType(), Result.getArrayFiller());
+
+return Success;
   }
 
-  return APValue::IndeterminateValue();
+  Result = APValue::IndeterminateValue();
+  return true;
 }
 
 namespace {
@@ -4535,10 +4546,8 @@
   Info.CurrentCall->createTemporary(VD, VD->getType(), true, Result);
 
   const Expr *InitE = VD->getInit();
-  if (!InitE) {
-Val = getDefaultInitValue(VD->getType());
-return true;
-  }
+  if (!InitE)
+return getDefaultInitValue(VD->getType(), Val);
 
   if (InitE->isValueDependent())
 return false;
@@ -5535,11 +5544,11 @@
   const Expr *LHSExpr;
   const FieldDecl *Field;
   bool DuringInit;
-
+  bool Failed = false;
   static const AccessKinds AccessKind = AK_Assign;
 
   typedef bool result_type;
-  bool failed() { return false; }
+  bool failed() { return Failed; }
   bool found(APValue &Subobj, QualType SubobjType) {
 // We are supposed to perform no initialization but begin the lifetime of
 // the object. We interpret that as meaning to do what default
@@ -5563,8 +5572,9 @@
   diag::note_constexpr_union_member_change_during_init);
   return false;
 }
-
-Subobj.setUnion(Field, getDefaultInitValue(Field->getType()));
+APValue Result;
+Failed = !getDefaultInitValue(Field->getType(), Result);
+Subobj.setUnion(Field, Result);
 return true;
   }
   bool found(APSInt &Value, QualType SubobjType) {
@@ -5880,8 +5890,9 @@
 for (; !declaresSameEntity(*FieldIt, FD); ++FieldIt) {
   assert(FieldIt != RD->field

[clang] 22f02db - [Matrix] Group matrix diagnostics together (NFC).

2020-06-25 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-06-25T11:47:33+01:00
New Revision: 22f02db625dd3ffd7d041edb6ef5af371f4fa474

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

LOG: [Matrix] Group matrix diagnostics together (NFC).

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ec31178389f9..beccdf9a3210 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10789,35 +10789,28 @@ def err_matrix_separate_incomplete_index: Error<
   "matrix row and column subscripts cannot be separated by any expression">;
 def err_matrix_subscript_comma: Error<
   "comma expressions are not allowed as indices in matrix subscript 
expressions">;
-
-def warn_mismatched_import : Warning<
-  "import %select{module|name}0 (%1) does not match the import 
%select{module|name}0 (%2) of the "
-  "previous declaration">,
-  InGroup;
-def warn_import_on_definition : Warning<
-  "import %select{module|name}0 cannot be applied to a function with a 
definition">,
-  InGroup;
-
 def err_builtin_matrix_arg: Error<"first argument must be a matrix">;
-
 def err_builtin_matrix_scalar_unsigned_arg: Error<
   "%0 argument must be a constant unsigned integer expression">;
-
 def err_builtin_matrix_pointer_arg: Error<
   "%0 argument must be a pointer to a valid matrix element type">;
-
 def err_builtin_matrix_pointer_arg_mismatch: Error<
   "the pointee of the second argument must match the element type of the first 
argument (%0 != %1)">;
-
 def err_builtin_matrix_store_to_const: Error<
   "cannot store matrix to read-only pointer">;
-
 def err_builtin_matrix_stride_too_small: Error<
   "stride must be greater or equal to the number of rows">;
-
 def err_builtin_matrix_invalid_dimension: Error<
   "%0 dimension is outside the allowed range [1, %1]">;
 
+def warn_mismatched_import : Warning<
+  "import %select{module|name}0 (%1) does not match the import 
%select{module|name}0 (%2) of the "
+  "previous declaration">,
+  InGroup;
+def warn_import_on_definition : Warning<
+  "import %select{module|name}0 cannot be applied to a function with a 
definition">,
+  InGroup;
+
 def err_preserve_field_info_not_field : Error<
   "__builtin_preserve_field_info argument %0 not a field access">;
 def err_preserve_field_info_not_const: Error<



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


[clang] 043b608 - [Matrix] Use 1st/2nd instead of first/second in matrix diags.

2020-06-25 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-06-25T11:55:03+01:00
New Revision: 043b608399559969f563eaa52e11a7ffe37137d9

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

LOG: [Matrix] Use 1st/2nd instead of first/second in matrix diags.

This was suggested in D72782 and brings the diagnostics more in line
with how argument references are handled elsewhere.

Reviewers: rjmccall, jfb, Bigcheese

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/matrix-type-builtins.c
clang/test/SemaCXX/matrix-type-builtins.cpp
clang/test/SemaObjC/matrix-type-builtins.m

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index beccdf9a3210..9067c45adc77 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10789,13 +10789,13 @@ def err_matrix_separate_incomplete_index: Error<
   "matrix row and column subscripts cannot be separated by any expression">;
 def err_matrix_subscript_comma: Error<
   "comma expressions are not allowed as indices in matrix subscript 
expressions">;
-def err_builtin_matrix_arg: Error<"first argument must be a matrix">;
+def err_builtin_matrix_arg: Error<"1st argument must be a matrix">;
 def err_builtin_matrix_scalar_unsigned_arg: Error<
   "%0 argument must be a constant unsigned integer expression">;
 def err_builtin_matrix_pointer_arg: Error<
-  "%0 argument must be a pointer to a valid matrix element type">;
+  "%ordinal0 argument must be a pointer to a valid matrix element type">;
 def err_builtin_matrix_pointer_arg_mismatch: Error<
-  "the pointee of the second argument must match the element type of the first 
argument (%0 != %1)">;
+  "the pointee of the 2nd argument must match the element type of the 1st 
argument (%0 != %1)">;
 def err_builtin_matrix_store_to_const: Error<
   "cannot store matrix to read-only pointer">;
 def err_builtin_matrix_stride_too_small: Error<

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e6a3b54c3cc1..9d0516e0232e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -15295,7 +15295,8 @@ ExprResult 
Sema::SemaBuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
   if (checkArgCount(*this, TheCall, 4))
 return ExprError();
 
-  Expr *PtrExpr = TheCall->getArg(0);
+  unsigned PtrArgIdx = 0;
+  Expr *PtrExpr = TheCall->getArg(PtrArgIdx);
   Expr *RowsExpr = TheCall->getArg(1);
   Expr *ColumnsExpr = TheCall->getArg(2);
   Expr *StrideExpr = TheCall->getArg(3);
@@ -15319,14 +15320,14 @@ ExprResult 
Sema::SemaBuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
   QualType ElementTy;
   if (!PtrTy) {
 Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-<< "first";
+<< PtrArgIdx + 1;
 ArgError = true;
   } else {
 ElementTy = PtrTy->getPointeeType().getUnqualifiedType();
 
 if (!ConstantMatrixType::isValidElementType(ElementTy)) {
   Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-  << "first";
+  << PtrArgIdx + 1;
   ArgError = true;
 }
   }
@@ -15402,8 +15403,9 @@ ExprResult 
Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
   if (checkArgCount(*this, TheCall, 3))
 return ExprError();
 
+  unsigned PtrArgIdx = 1;
   Expr *MatrixExpr = TheCall->getArg(0);
-  Expr *PtrExpr = TheCall->getArg(1);
+  Expr *PtrExpr = TheCall->getArg(PtrArgIdx);
   Expr *StrideExpr = TheCall->getArg(2);
 
   bool ArgError = false;
@@ -15442,7 +15444,7 @@ ExprResult 
Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
   auto *PtrTy = PtrExpr->getType()->getAs();
   if (!PtrTy) {
 Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-<< "second";
+<< PtrArgIdx + 1;
 ArgError = true;
   } else {
 QualType ElementTy = PtrTy->getPointeeType();

diff  --git a/clang/test/Sema/matrix-type-builtins.c 
b/clang/test/Sema/matrix-type-builtins.c
index d8da11aa05aa..2f7e4549e495 100644
--- a/clang/test/Sema/matrix-type-builtins.c
+++ b/clang/test/Sema/matrix-type-builtins.c
@@ -11,11 +11,11 @@ void transpose(sx5x10_t a, ix3x2_t b, dx3x3 c, int *d, int 
e) {
   b = __builtin_matrix_transpose(b);
   // expected-error@-1 {{assigning to 'ix3x2_t' (aka 'int 
__attribute__((matrix_type(3, 2)))') from incompatible type 'int 
__attribute__((matrix_type(2, 3)))'}}
   __builtin_matrix_transpose(d);
-  // expected-error@-1 {{first argument must be a matrix}}
+  // expected-error@-1 {{1st argument must be a matrix}}
   __builtin_matrix_transpose(e);
-  // expected-error@-1 {{f

[clang] 8938a6c - [NFC] update test to make diff of the following commit clear

2020-06-25 Thread via cfe-commits

Author: Tyker
Date: 2020-06-25T12:59:44+02:00
New Revision: 8938a6c9ede29a2d738357c44d66a017d74fcc7e

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

LOG: [NFC] update test to make diff of the following commit clear

Added: 


Modified: 
clang/test/CodeGen/align_value.cpp
clang/test/CodeGen/alloc-align-attr.c
clang/test/CodeGen/builtin-align.c
clang/test/CodeGen/builtin-assume-aligned.c
llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
llvm/test/Transforms/Inline/align.ll

Removed: 




diff  --git a/clang/test/CodeGen/align_value.cpp 
b/clang/test/CodeGen/align_value.cpp
index 3badcd74f46d..acbfbaf2ba5c 100644
--- a/clang/test/CodeGen/align_value.cpp
+++ b/clang/test/CodeGen/align_value.cpp
@@ -1,103 +1,192 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
 
 typedef double * __attribute__((align_value(64))) aligned_double;
 
+// CHECK-LABEL: define {{[^@]+}}@_Z3fooPdS_Rd
+// CHECK-SAME: (double* align 64 [[X:%.*]], double* align 32 [[Y:%.*]], 
double* nonnull align 128 dereferenceable(8) [[Z:%.*]]) #0
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca double*, align 8
+// CHECK-NEXT:[[Y_ADDR:%.*]] = alloca double*, align 8
+// CHECK-NEXT:[[Z_ADDR:%.*]] = alloca double*, align 8
+// CHECK-NEXT:store double* [[X]], double** [[X_ADDR]], align 8
+// CHECK-NEXT:store double* [[Y]], double** [[Y_ADDR]], align 8
+// CHECK-NEXT:store double* [[Z]], double** [[Z_ADDR]], align 8
+// CHECK-NEXT:ret void
+//
 void foo(aligned_double x, double * y __attribute__((align_value(32))),
  double & z __attribute__((align_value(128 { };
-// CHECK: define void @_Z3fooPdS_Rd(double* align 64 %x, double* align 32 %y, 
double* nonnull align 128 dereferenceable(8) %z)
 
 struct ad_struct {
   aligned_double a;
 };
 
+// CHECK-LABEL: define {{[^@]+}}@_Z3fooR9ad_struct
+// CHECK-SAME: (%struct.ad_struct* nonnull align 8 dereferenceable(8) 
[[X:%.*]]) #0
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca %struct.ad_struct*, align 8
+// CHECK-NEXT:store %struct.ad_struct* [[X]], %struct.ad_struct** 
[[X_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load %struct.ad_struct*, %struct.ad_struct** 
[[X_ADDR]], align 8
+// CHECK-NEXT:[[A:%.*]] = getelementptr inbounds [[STRUCT_AD_STRUCT:%.*]], 
%struct.ad_struct* [[TMP0]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load double*, double** [[A]], align 8
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint double* [[TMP1]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 63
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret double* [[TMP1]]
+//
 double *foo(ad_struct& x) {
-// CHECK-LABEL: @_Z3fooR9ad_struct
 
-// CHECK: [[PTRINT1:%.+]] = ptrtoint
-// CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63
-// CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
-// CHECK: call void @llvm.assume(i1 [[MASKCOND1]])
   return x.a;
 }
 
+// CHECK-LABEL: define {{[^@]+}}@_Z3gooP9ad_struct
+// CHECK-SAME: (%struct.ad_struct* [[X:%.*]]) #0
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca %struct.ad_struct*, align 8
+// CHECK-NEXT:store %struct.ad_struct* [[X]], %struct.ad_struct** 
[[X_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load %struct.ad_struct*, %struct.ad_struct** 
[[X_ADDR]], align 8
+// CHECK-NEXT:[[A:%.*]] = getelementptr inbounds [[STRUCT_AD_STRUCT:%.*]], 
%struct.ad_struct* [[TMP0]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load double*, double** [[A]], align 8
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint double* [[TMP1]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 63
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret double* [[TMP1]]
+//
 double *goo(ad_struct *x) {
-// CHECK-LABEL: @_Z3gooP9ad_struct
 
-// CHECK: [[PTRINT2:%.+]] = ptrtoint
-// CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], 63
-// CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
-// CHECK: call void @llvm.assume(i1 [[MASKCOND2]])
   return x->a;
 }
 
+// CHECK-LABEL: define {{[^@]+}}@_Z3barPPd
+// CHECK-SAME: (double** [[X:%.*]]) #0
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca double**, align 8
+// CHECK-NEXT:store double** [[X]], double*** [[X_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double**, double*** [[X_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double*, double** [[TMP0]], align 8
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint double* [[T

[PATCH] D82429: [sve][acle] Add some C intrinsics for brain float types.

2020-06-25 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2-bfloat.c:7
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu 
-target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify -verify-ignore-unexpected=error 
-verify-ignore-unexpected=note %s
+// R UN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify=overload-bf16 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+

fpetrogalli wrote:
> I could do with an extra pair of eyes here: I can't figure out why the 
> warning raised by this run is not detected by the `overload-bf16-warning` 
> below... (Same for the same line I have added in the test for tbx).
Ah, it works in the example I linked because `whilerw` / `whilewr` uses the 
scalar `bfloat16_t`, whereas this is using sizeless type which is predicated on 
`-D__ARM_FEATURE_SVE_BF16` so we get:

```error: 'error' diagnostics seen but not expected:
  File 
/home/culrho01/llvm-project/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2-bfloat.c
 Line 18: unknown type name 'svbfloat16_t'; did you mean 'svfloat16_t'?
  File 
/home/culrho01/llvm-project/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2-bfloat.c
 Line 18: unknown type name 'svbfloat16x2_t'; did you mean 'svfloat16x2_t'?```

I'm not sure if/how we can test this for the overloaded form


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82429



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


[PATCH] D82473: [Matrix] Use 1st/2nd instead of first/second in matrix diags.

2020-06-25 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG043b60839955: [Matrix] Use 1st/2nd instead of first/second 
in matrix diags. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82473

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/matrix-type-builtins.c
  clang/test/SemaCXX/matrix-type-builtins.cpp
  clang/test/SemaObjC/matrix-type-builtins.m

Index: clang/test/SemaObjC/matrix-type-builtins.m
===
--- clang/test/SemaObjC/matrix-type-builtins.m
+++ clang/test/SemaObjC/matrix-type-builtins.m
@@ -22,10 +22,10 @@
 
 double test_store(MatrixValue *mv, float *Ptr) {
   __builtin_matrix_column_major_store(mv.value, Ptr, 1);
-  // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'double')}}
+  // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'double')}}
   // expected-error@-2 {{stride must be greater or equal to the number of rows}}
 
   __builtin_matrix_column_major_store(mv.value, mv.value, mv.value);
-  // expected-error@-1 {{second argument must be a pointer to a valid matrix element type}}
+  // expected-error@-1 {{2nd argument must be a pointer to a valid matrix element type}}
   // expected-error@-2 {{casting 'double4x4' (aka 'double __attribute__((matrix_type(4, 4)))') to incompatible type 'unsigned long}}
 }
Index: clang/test/SemaCXX/matrix-type-builtins.cpp
===
--- clang/test/SemaCXX/matrix-type-builtins.cpp
+++ clang/test/SemaCXX/matrix-type-builtins.cpp
@@ -15,9 +15,9 @@
   // expected-error@-3 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 3)))'}}
 
   __builtin_matrix_transpose(A);
-  // expected-error@-1 {{first argument must be a matrix}}
-  // expected-error@-2 {{first argument must be a matrix}}
-  // expected-error@-3 {{first argument must be a matrix}}
+  // expected-error@-1 {{1st argument must be a matrix}}
+  // expected-error@-2 {{1st argument must be a matrix}}
+  // expected-error@-3 {{1st argument must be a matrix}}
 
   return __builtin_matrix_transpose(A.value);
   // expected-error@-1 {{cannot initialize return object of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 3)))') with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 2)))'}}
@@ -99,13 +99,13 @@
   // expected-error@-1 {{row argument must be a constant unsigned integer expression}}
   // expected-error@-2 {{column argument must be a constant unsigned integer expression}}
   (void)__builtin_matrix_column_major_load(X, 2, 2, 2);
-  // expected-error@-1 {{first argument must be a pointer to a valid matrix element type}}
+  // expected-error@-1 {{1st argument must be a pointer to a valid matrix element type}}
 }
 
 template 
 void column_major_store(MyMatrix &A, PtrTy Ptr, unsigned Stride) {
   __builtin_matrix_column_major_store(A.value, Ptr, Stride);
-  // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}}
+  // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'unsigned int')}}
 }
 
 template 
@@ -126,14 +126,14 @@
 void column_major_store(MyMatrix &A, EltTy1 *Ptr) {
   __builtin_matrix_column_major_store(A.value, Ptr, 1);
   // expected-error@-1 3 {{stride must be greater or equal to the number of rows}}
-  // expected-error@-2 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}}
-  // expected-error@-3 {{the pointee of the second argument must match the element type of the first argument ('unsigned int' != 'float')}}
+  // expected-error@-2 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'unsigned int')}}
+  // expected-error@-3 {{the pointee of the 2nd argument must match the element type of the 1st argument ('unsigned int' != 'float')}}
 
   char *s;
   return __builtin_matrix_column_major_store(A.value, s, 20);
-  // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}}
-  // expected-error@-2 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}}
-  // expected-error@-3 {{he pointee of the second argument must match the element type of the first argument ('char' != 'float')}}
+  // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'unsigned int')}}
+  // expected-error@-2 {{the pointee of the 2

[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-06-25 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc95ffadb2474: [AssumeBundles] Use operand bundles to encode 
alignment assumptions (authored by Tyker).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -546,3 +546,41 @@
   ASSERT_EQ(AR[0].Index, 1u);
   ASSERT_EQ(AR[0].Assume, &*First);
 }
+
+TEST(AssumeQueryAPI, Alignment) {
+  LLVMContext C;
+  SMDiagnostic Err;
+  std::unique_ptr Mod = parseAssemblyString(
+  "declare void @llvm.assume(i1)\n"
+  "define void @test(i32* %P, i32* %P1, i32* %P2, i32 %I3, i1 %B) {\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P, i32 8, i32 %I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P1, i32 %I3, i32 "
+  "%I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P2, i32 16, i32 8)]\n"
+  "ret void\n}\n",
+  Err, C);
+  if (!Mod)
+Err.print("AssumeQueryAPI", errs());
+
+  Function *F = Mod->getFunction("test");
+  BasicBlock::iterator Start = F->begin()->begin();
+  IntrinsicInst *II;
+  RetainedKnowledge RK;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(0));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(1));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(2));
+  ASSERT_EQ(RK.ArgValue, 8u);
+}
Index: llvm/test/Verifier/assume-bundles.ll
===
--- llvm/test/Verifier/assume-bundles.ll
+++ llvm/test/Verifier/assume-bundles.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
 declare void @llvm.assume(i1)
@@ -6,14 +7,21 @@
 ; CHECK: tags must be valid attribute names
   call void @llvm.assume(i1 true) ["adazdazd"()]
 ; CHECK: the second argument should be a constant integral value
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 %P1)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 %P1)]
 ; CHECK: to many arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 8, i32 8)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 8, i32 8)]
 ; CHECK: this attribute should have 2 arguments
-  call void @llvm.assume(

[PATCH] D81282: [builtins] Move more float128-related helpers to GENERIC_TF_SOURCES list

2020-06-25 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

Look reasonable from my POV, but I don't know enough about CMake or the 
compiler-rt build system to LGTM this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81282



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


[clang-tools-extra] 95a3550 - Repair various issues with modernize-avoid-bind

2020-06-25 Thread Aaron Ballman via cfe-commits

Author: Jeff Trull
Date: 2020-06-25T07:29:53-04:00
New Revision: 95a3550dc89a0d424d90e2c0ad30d9ecfa9422cf

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

LOG: Repair various issues with modernize-avoid-bind

In the process of running this check on a large codebase I found a
number of limitations, and thought I would pass on my fixes for
possible integration upstream:

* Templated function call operators are not supported
* Function object constructors are always used directly in the lambda
  body, even if their arguments are not captured
* Placeholders with namespace qualifiers (std::placeholders::_1) are
  not detected
* Lambda arguments should be forwarded to the stored function
* Data members from other classes still get captured with this
* Expressions (as opposed to variables) inside std::ref are not captured
  properly
* Function object templates sometimes have their template arguments
  replaced with concrete types

This patch resolves all those issues and adds suitable unit tests.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index 37f9eb6955d3..cadb84e1d038 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -35,7 +35,8 @@ namespace modernize {
 namespace {
 
 enum BindArgumentKind { BK_Temporary, BK_Placeholder, BK_CallExpr, BK_Other };
-enum CaptureMode { CM_None, CM_ByRef, CM_ByValue, CM_InitExpression };
+enum CaptureMode { CM_None, CM_ByRef, CM_ByValue };
+enum CaptureExpr { CE_None, CE_Var, CE_InitExpression };
 
 enum CallableType {
   CT_Other,  // unknown
@@ -60,6 +61,10 @@ struct BindArgument {
   // captured.
   CaptureMode CM = CM_None;
 
+  // Whether the argument is a simple variable (we can capture it directly),
+  // or an expression (we must introduce a capture variable).
+  CaptureExpr CE = CE_None;
+
   // The exact spelling of this argument in the source code.
   StringRef SourceTokens;
 
@@ -86,6 +91,7 @@ struct CallableInfo {
   CallableType Type = CT_Other;
   CallableMaterializationKind Materialization = CMK_Other;
   CaptureMode CM = CM_None;
+  CaptureExpr CE = CE_None;
   StringRef SourceTokens;
   std::string CaptureIdentifier;
   std::string UsageIdentifier;
@@ -102,6 +108,12 @@ struct LambdaProperties {
 
 } // end namespace
 
+static bool tryCaptureAsLocalVariable(const MatchFinder::MatchResult &Result,
+  BindArgument &B, const Expr *E);
+
+static bool tryCaptureAsMemberVariable(const MatchFinder::MatchResult &Result,
+   BindArgument &B, const Expr *E);
+
 static const Expr *ignoreTemporariesAndPointers(const Expr *E) {
   if (const auto *T = dyn_cast(E))
 return ignoreTemporariesAndPointers(T->getSubExpr());
@@ -148,12 +160,22 @@ initializeBindArgumentForCallExpr(const 
MatchFinder::MatchResult &Result,
   // std::ref(x) means to capture x by reference.
   if (isCallExprNamed(CE, "boost::ref") || isCallExprNamed(CE, "std::ref")) {
 B.Kind = BK_Other;
+if (tryCaptureAsLocalVariable(Result, B, CE->getArg(0)) ||
+tryCaptureAsMemberVariable(Result, B, CE->getArg(0))) {
+  B.CE = CE_Var;
+} else {
+  // The argument to std::ref is an expression that produces a reference.
+  // Create a capture reference to hold it.
+  B.CE = CE_InitExpression;
+  B.UsageIdentifier = "capture" + llvm::utostr(CaptureIndex++);
+}
+// Strip off the reference wrapper.
+B.SourceTokens = getSourceTextForExpr(Result, CE->getArg(0));
 B.CM = CM_ByRef;
-B.UsageIdentifier =
-std::string(getSourceTextForExpr(Result, CE->getArg(0)));
   } else {
 B.Kind = BK_CallExpr;
-B.CM = CM_InitExpression;
+B.CM = CM_ByValue;
+B.CE = CE_InitExpression;
 B.UsageIdentifier = "capture" + llvm::utostr(CaptureIndex++);
   }
   B.CaptureIdentifier = B.UsageIdentifier;
@@ -204,6 +226,7 @@ static bool tryCaptureAsMemberVariable(const 
MatchFinder::MatchResult &Result,
 
   E = E->IgnoreImplicit();
   if (isa(E)) {
+// E is a direct use of "this".
 B.CM = CM_ByValue;
 B.UsageIdentifier = std::string(getSourceTextForExpr(Result, E));
 B.CaptureIdentifier = "this";
@@ -217,10 +240,15 @@ static bool tryCaptureAsMemberVariable(const 
MatchFinder::MatchResult &Result,
   if (!ME->isLValue() || !isa(ME->getMemberDecl()))
 return false;
 
-  B.CM = CM_ByValue;
-  B.UsageIdenti

[PATCH] D81769: [clang-tidy] Repair various issues with modernize-avoid-bind

2020-06-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the patch! I've commit on your behalf in 
95a3550dc89a0d424d90e2c0ad30d9ecfa9422cf 



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

https://reviews.llvm.org/D81769



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


[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

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

Addressed code review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485

Files:
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -0,0 +1,644 @@
+//===--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+
+using namespace clang;
+
+namespace {
+
+enum class ShouldTraversePostOrder : bool {
+  No = false,
+  Yes = true,
+};
+
+/// Base class for tests for RecursiveASTVisitor tests that validate the
+/// sequence of calls to user-defined callbacks like Traverse*(), WalkUp*(),
+/// Visit*().
+template 
+class RecordingVisitorBase : public TestVisitor {
+  ShouldTraversePostOrder ShouldTraversePostOrderValue;
+
+public:
+  RecordingVisitorBase(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+  : ShouldTraversePostOrderValue(ShouldTraversePostOrderValue) {}
+
+  bool shouldTraversePostOrder() const {
+return static_cast(ShouldTraversePostOrderValue);
+  }
+
+  // Callbacks received during traversal.
+  std::string CallbackLog;
+
+  std::string stmtToString(Stmt *S) {
+StringRef ClassName = S->getStmtClassName();
+if (IntegerLiteral *IL = dyn_cast(S)) {
+  return (ClassName + "(" + IL->getValue().toString(10, false) + ")").str();
+}
+if (BinaryOperator *BO = dyn_cast(S)) {
+  return (ClassName + "(" + BinaryOperator::getOpcodeStr(BO->getOpcode()) +
+  ")")
+  .str();
+}
+if (CallExpr *CE = dyn_cast(S)) {
+  if (FunctionDecl *Callee = CE->getDirectCallee()) {
+if (Callee->getIdentifier()) {
+  return (ClassName + "(" + Callee->getName() + ")").str();
+}
+  }
+}
+if (DeclRefExpr *DRE = dyn_cast(S)) {
+  if (NamedDecl *ND = DRE->getFoundDecl()) {
+if (ND->getIdentifier()) {
+  return (ClassName + "(" + ND->getName() + ")").str();
+}
+  }
+}
+return ClassName.str();
+  }
+
+  /// Record the fact that the user-defined callback member function
+  /// \p CallbackName was called with the argument \p S.
+  void recordCallback(StringRef CallbackName, Stmt *S) {
+CallbackLog += (CallbackName + " " + stmtToString(S) + "\n").str();
+  }
+};
+
+template 
+::testing::AssertionResult visitorCallbackLogEqual(VisitorTy Visitor,
+   StringRef Code,
+   StringRef ExpectedLog) {
+  Visitor.runOver(Code);
+  // EXPECT_EQ shows the diff between the two strings if they are different.
+  EXPECT_EQ(ExpectedLog.trim().str(),
+StringRef(Visitor.CallbackLog).trim().str());
+  if (ExpectedLog.trim() != StringRef(Visitor.CallbackLog).trim()) {
+return ::testing::AssertionFailure();
+  }
+  return ::testing::AssertionSuccess();
+}
+
+} // namespace
+
+TEST(RecursiveASTVisitor, Callbacks_TraverseLeaf) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseIntegerLiteral(IntegerLiteral *IL) {
+  recordCallback(__func__, IL);
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S);
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void add(int, int);
+void test() {
+  1;
+  2 + 3;
+  add(4, 5);
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+TraverseIntegerLiteral IntegerLiteral(1)
+WalkUpFromStmt BinaryOperator(+)
+TraverseIntegerLiteral IntegerLiteral(2)
+TraverseIntegerLiteral IntegerLiteral(3)
+WalkUpFromStmt CallExpr(add)
+WalkUpFromStmt ImplicitCastExpr
+WalkUpFromStmt DeclRefExpr(add)
+TraverseIntegerLiteral IntegerLiteral(4)
+TraverseIntegerLiteral IntegerLiteral(5)
+)txt"));
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
+  R"txt(
+TraverseIntegerLiteral IntegerLiteral(1)
+WalkUpFromStmt IntegerLiteral(1)
+TraverseIntegerLiteral IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(2)
+TraverseIntegerLiteral IntegerLiteral(3)
+WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt BinaryOperator(+)
+WalkUpFr

[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-06-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked 5 inline comments as done.
gribozavr2 added inline comments.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:16
+template 
+class RecordingVisitorBase : public TestVisitor {
+  bool VisitPostOrder;

ymandel wrote:
> Add class comment?
Added.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:17
+class RecordingVisitorBase : public TestVisitor {
+  bool VisitPostOrder;
+

eduucaldas wrote:
> ymandel wrote:
> > Consider using an enum rather than a bool.
> Agreed.
> This would avoid all the /*VisitPostOrder=*/false
> 
Changed to enum.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:81
+
+bool TraverseIntegerLiteral(IntegerLiteral *E) {
+  recordCallback(__func__, E);

eduucaldas wrote:
> E for Expr? Ok, Expr is base class of IntegerLiteral.
> I propose to use either: 
> S for Stmt, it  is a more homogeneus name and **also** a base class of 
> IntegerLiteral
> Or 
> IL for IntegerLiteral, and then we stick with this convention
Changed to a more specific abbreviation everywhere I could find.



Comment at: 
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:148-161
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S);
+  return true;
+}
+
+bool WalkUpFromExpr(Expr *E) {
+  recordCallback(__func__, E);

eduucaldas wrote:
> > E for Expr? Ok, Expr is base class of IntegerLiteral.
> > I propose to use either:
> > S for Stmt, it is a more homogeneus name and also a base class of 
> > IntegerLiteral
> > Or
> > IL for IntegerLiteral, and then we stick with this convention
> 
> Here it gets even more confusing.
Changed the name to `IL`.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:153
+
+bool WalkUpFromExpr(Expr *E) {
+  recordCallback(__func__, E);

eduucaldas wrote:
> I think overriding WalkUpFromDerived when you already have WalkUpFromStmt 
> doesn't bring much value.
> In the case of fully derived AST nodes we just get the repeated information 
> about the type of this node, e.g. 
> WalkUpFromIntegerLiteral IntegerLiteral(x) 
> instead of
> WalkUpFromStmt IntegerLiteral(x)
>  
> In the case of intermediate AST nodes, as WalkUpFromExpr, we get some 
> information but do we need that?
> Here for instance, the information we get is: 
> WalkUpFromExpr Node => Node is an Expr
> WalkUpFromStmt Node => Node is a Stmt
> I don't think this information is very valuable
I added these overrides not to collect more information, but to get more 
coverage. It is true that if we look carefully at the implementation we can 
probably infer that WalkUpFrom chaining works fine. I'm adding tests to ensure 
that it continues to work correctly in future. It would be nice if we could 
factor out a separate test that shows just that chaining logic, but I don't see 
how to easily do it. WalkUpFrom methods are called from a bunch of places 
depending on what Traverse methods are overridden, whether we are in the data 
recursion optimization, and whether we are in the post-order traversal mode. 
Those focused tests would have to define the same combinations of callbacks in 
RecursiveASTVisitor as these tests here.




Comment at: 
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:300-309
+WalkUpFromStmt CompoundStmt
+WalkUpFromStmt IntegerLiteral(1)
+WalkUpFromStmt BinaryOperator(+)
+WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt CallExpr(add)
+WalkUpFromStmt ImplicitCastExpr

eduucaldas wrote:
> I think we spotted something funny here. RAV didn't call our overriden 
> TraverseBinaryOperator.
I added a FIXME that explains that this is a potential bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485



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


[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

mostly LG, apart from the comments around the fallthrough, thanks!




Comment at: clang/lib/Sema/SemaCodeComplete.cpp:2061
 
+if (SemaRef.getLangOpts().CPlusPlus11)
+  AddUsingAliasResult(Results);

there's already a fallthrough down below, please drop this one.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:2091
 
   if (CCC == Sema::PCC_Class) {
+if (SemaRef.getLangOpts().CPlusPlus11)

let's put this right after using declaration. (this at least needs to be 
outside this if statement to be triggered by fallthrough)



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:1820
+// using name = type
+static void AddUsingAliasResult(ResultBuilder &Results) {
+  CodeCompletionBuilder Builder(Results.getAllocator(),

let's take in the `CodeCompletionBuilder&` too instead of creating a new one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82535



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


[PATCH] D82498: [SourceManager] don't check invalid param of getLocalSLocEntry()

2020-06-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/include/clang/Basic/SourceManager.h:1649
   const SrcMgr::SLocEntry &getLocalSLocEntry(unsigned Index,
  bool *Invalid = nullptr) const {
 assert(Index < LocalSLocEntryTable.size() && "Invalid index");

kadircet wrote:
> i think we should drop Invalid from the signature completely if we are going 
> for this.
> 
> I've sent out D82532 to get rid of the libclang dependency on this, after it 
> lands this should be possible to clear.
landed that patch please rebase and get rid of this parameter completely. Also 
please add a comment to `getSLocEntryByID` saying that `Invalid won't be 
modified for local sloc entries`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82498



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


[PATCH] D82310: Add `BoolLiteralExpression` to SyntaxTree

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



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1240
+  true;
+  false;
+}

gribozavr2 wrote:
> eduucaldas wrote:
> > gribozavr2 wrote:
> > > C99 has bool literals, but the program should include stdbool.h.
> > > 
> > > I feel like it is better to make the predicate something like 
> > > "hasBoolType()" and change the test to include stdbool.h.
> > [[ https://clang.llvm.org/doxygen/stdbool_8h_source.html | stdbool ]] 
> > consists on macro definitions, mapping booleans to integers. `true` is 
> > preprocessed into 1 and `false` to 0 .
> > I don't  think there is a reasonable way of getting the proper SyntaxTree 
> > from that macro expansion
> > 
> > Additional problem, we don't have the test infrastructure for includes, 
> > AFAIK ^^
> > 
> > Finally, regarding the predicates, I prefer if they relate to languages, 
> > otherwise we might create many predicates that test for exactly the same 
> > thing, e.g. we would have `hasBoolType()` and `hasNullPtr()` that 
> > ultimately do the same thing, test if Language is not C 
> > true is preprocessed into 1 and false to 0 .
> 
> I see -- yes, that would make a completely different syntax tree.
> 
> > Finally, regarding the predicates, I prefer if they relate to languages, 
> > otherwise we might create many predicates that test for exactly the same 
> > thing
> 
> Generally, testing for features instead of product versions is considered 
> better, as that leads to more future-proof code (for example, we learned this 
> lesson again in the area of web extensions and standards). In future, Clang 
> can start supporting a language feature in other language modes as an 
> extension (for example, supporting `_Atomic` in C++ is already a thing), or 
> the language standard itself can decide to incorporate the feature (for 
> example, C 2035 could adopt the `nullptr` keyword). It is highly unlikely for 
> complex features like templates, but may reasonably happen for simpler 
> features.
> Generally, testing for features instead of product versions is considered 
> better, as that leads to more future-proof code 

I totally agree with all you said. My worry was more regarding the fact that 
the implementation of `hasBoolType` would merely check for the language 
anyways. So if, following what you said, `true` and `false` really became a 
feature of C35 then the code would still be broken. 

But then I guess it would be easier to fix `hasBoolType` than finding all the 
places where we used just `isC` because booleans are not in C. 

Specially if all these predicates were put in `clang/Testing/CommandLineArgs.h` 
or something similar where more people would be seeing it. 

Which brings the question shouldn't we move these predicates up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82310



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


[PATCH] D82345: [sve][acle] Implement some of the C intrinsics for brain float.

2020-06-25 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added a comment.

We need to guard the LLVM patterns on the +bf16 feature as we've done in other 
patches




Comment at: clang/include/clang/Basic/arm_sve.td:694
 def SVDUPQ_16 : SInst<"svdupq[_n]_{d}", "d",  "sUsh", MergeNone>;
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16) && 
defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC) " in {
+  def SVDUPQ_BF16 : SInst<"svdupq[_n]_{d}", "d",  "b", MergeNone>;

`__ARM_FEATURE_SVE_BF16` will imply `__ARM_FEATURE_BF16_SCALAR_ARITHMETIC` so 
guarding only on the former should be sufficient. Same applies below



Comment at: clang/include/clang/Basic/arm_sve.td:830
 
+def SVINSR   : SInst<"svinsr[_n_{d}]", "dds",  "csilUcUsUiUlhfd", MergeNone, 
"aarch64_sve_insr">;
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16) && 
defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC) " in {

nit: remove double spaces



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7745-7746
+
+  case SVETypeFlags::EltTyBFloat16:
+return llvm::ScalableVectorType::get(Builder.getInt1Ty(), 8);
   }

already added in D82399, you should see it when rebasing



Comment at: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll:317-318
+  %out = call bfloat @llvm.aarch64.sve.clastb.n.nxv8bf16( %pg,
+bfloat %a,
+ 
%b)
+  ret bfloat %out

nit: alignment



Comment at: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll:665
+  %res = call bfloat @llvm.aarch64.sve.lasta.nxv8bf16( %pg,
+%a)
+  ret bfloat %res

nit: alignment



Comment at: llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll:65-66
+  %out = call  @llvm.aarch64.sve.dup.nxv8bf16( %a,
+ %pg,
+bfloat %b)
+  ret  %out

nit: alignment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82345



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


[PATCH] D82310: Add `BoolLiteralExpression` to SyntaxTree

2020-06-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 273310.
eduucaldas marked 2 inline comments as done.
eduucaldas added a comment.

isC -> hasBoolType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82310

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
@@ -69,6 +69,10 @@
Language == Lang_CXX20;
   }
 
+  bool hasBoolType() const {
+return Language == Lang_C89 || Language == Lang_C99;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -1228,6 +1232,40 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, BoolLiteral) {
+  if (GetParam().hasBoolType()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  true;
+  false;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-BoolLiteralExpression
+| | `-true
+| `-;
+|-ExpressionStatement
+| |-BoolLiteralExpression
+| | `-false
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, IntegerLiteral) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
@@ -1691,18 +1729,18 @@
 |-{
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-BoolLiteralExpression
 | | | `-true
 | | |-||
-| | `-UnknownExpression
+| | `-BoolLiteralExpression
 | |   `-false
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-BoolLiteralExpression
 | | | `-true
 | | |-or
-| | `-UnknownExpression
+| | `-BoolLiteralExpression
 | |   `-false
 | `-;
 |-ExpressionStatement
@@ -2556,7 +2594,7 @@
 |-StaticAssertDeclaration
 | |-static_assert
 | |-(
-| |-UnknownExpression
+| |-BoolLiteralExpression
 | | `-true
 | |-,
 | |-UnknownExpression
@@ -2566,7 +2604,7 @@
 `-StaticAssertDeclaration
   |-static_assert
   |-(
-  |-UnknownExpression
+  |-BoolLiteralExpression
   | `-true
   |-)
   `-;
@@ -3186,7 +3224,7 @@
   |   |-)
   |   |-noexcept
   |   |-(
-  |   |-UnknownExpression
+  |   |-BoolLiteralExpression
   |   | `-true
   |   `-)
   `-;
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -22,6 +22,8 @@
 return OS << "CxxNullPtrExpression";
   case NodeKind::IntegerLiteralExpression:
 return OS << "IntegerLiteralExpression";
+  case NodeKind::BoolLiteralExpression:
+return OS << "BoolLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -200,6 +202,11 @@
   findChild(syntax::NodeRole::LiteralToken));
 }
 
+syntax::Leaf *syntax::BoolLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::LiteralToken));
+}
+
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::LiteralToken));
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -654,6 +654,13 @@
 return true;
   }
 
+  bool WalkUpFromCXXBoolLiteralExpr(CXXBoolLiteralExpr *S) {
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::BoolLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -45,6 +45,7 @@
   BinaryOperatorExpression,
   CxxNullPtrExpression,
   IntegerLiteralExpression,
+  BoolLiteralExpression,
   IdExpression,
 
   // Statements.
@@ -264,6 +265,16 @@
   syntax::Leaf *literalToken();
 };
 
+/// Expression for boolean literals. C++ [lex.bool]
+class BoolLiteralExpression final : public Expression {
+public:
+  BoolLiteralExpression() : Expression(NodeKind::BoolLiteralExpression) 

[PATCH] D81311: [RFC] LangRef: Define byref parameter attribute

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

I did realize one edge case that is different between carrying the size and the 
type. You can have a zero sized type with an alignment, but 0 is naturally an 
invalid value for the attribute (and all the others that carry an integer)


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

https://reviews.llvm.org/D81311



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


[clang] 32ea339 - [OPENMP]Dynamic globalization for parallel target regions.

2020-06-25 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-25T08:25:24-04:00
New Revision: 32ea3397bec820f98f0b77ca37244142ce700207

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

LOG: [OPENMP]Dynamic globalization for parallel target regions.

Summary:
Added support for dynamic memory allocation for globalized variables in
case if execution of target regions in parallel is required.

Reviewers: jdoerfert

Subscribers: jholewinski, yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/OpenMP/nvptx_data_sharing.cpp
clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
clang/test/OpenMP/nvptx_parallel_codegen.cpp
clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
clang/test/OpenMP/nvptx_teams_codegen.cpp
clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index bc0c17a14789..b0d9b3a0c632 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -231,6 +231,7 @@ LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA 
devices.")
 LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA 
devices.")
 LANGOPT(OpenMPCUDAReductionBufNum , 32, 1024, "Number of the reduction records 
in the intermediate reduction buffer used for the teams reductions.")
 LANGOPT(OpenMPOptimisticCollapse  , 1, 0, "Use at most 32 bits to represent 
the collapsed loop nest counter.")
+LANGOPT(OpenMPCUDATargetParallel, 1, 0, "Support parallel execution of target 
region on Cuda-based devices.")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c6474c1e5ccd..eca822c6afa3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1687,6 +1687,12 @@ def fopenmp_optimistic_collapse : Flag<["-"], 
"fopenmp-optimistic-collapse">, Gr
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_optimistic_collapse : Flag<["-"], 
"fno-openmp-optimistic-collapse">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>;
+def fopenmp_cuda_parallel_target_regions : Flag<["-"], 
"fopenmp-cuda-parallel-target-regions">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
+  HelpText<"Support parallel execution of target regions on Cuda-based 
devices.">;
+def fno_openmp_cuda_parallel_target_regions : Flag<["-"], 
"fno-openmp-cuda-parallel-target-regions">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>,
+  HelpText<"Support only serial execution of target regions on Cuda-based 
devices.">;
 def static_openmp: Flag<["-"], "static-openmp">,
   HelpText<"Use the static host OpenMP runtime while linking.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
index 896442daa401..744342f606a2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -85,6 +85,9 @@ enum OpenMPRTLFunctionNVPTX {
   /// Call to void* __kmpc_data_sharing_coalesced_push_stack(size_t size,
   /// int16_t UseSharedMemory);
   OMPRTL_NVPTX__kmpc_data_sharing_coalesced_push_stack,
+  /// Call to void* __kmpc_data_sharing_push_stack(size_t size, int16_t
+  /// UseSharedMemory);
+  OMPRTL_NVPTX__kmpc_data_sharing_push_stack,
   /// Call to void __kmpc_data_sharing_pop_stack(void *a);
   OMPRTL_NVPTX__kmpc_data_sharing_pop_stack,
   /// Call to void __kmpc_begin_sharing_variables(void ***args,
@@ -1753,6 +1756,16 @@ 
CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction(unsigned Function) {
 FnTy, /*Name=*/"__kmpc_data_sharing_coalesced_push_stack");
 break;
   }
+  case OMPRTL_NVPTX__kmpc_data_sharing_push_stack: {
+// Build void *__kmpc_data_sharing_push_stack(size_t size, int16_t
+// UseSharedMemory);
+llvm::Type *TypeParams[] = {CGM.SizeTy, CGM.Int16Ty};
+auto *FnTy =
+llvm::FunctionType::get(CGM.VoidPtrTy, TypeParams, /*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(
+FnTy, /*Name

[clang] 3765799 - Fix a crash with [[clang::acquire_handle]] when written as a type

2020-06-25 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-06-25T08:45:32-04:00
New Revision: 37657991d17a274b1ac9c6ee63697a0138eab317

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

LOG: Fix a crash with [[clang::acquire_handle]] when written as a type
attribute with no arguments provided.

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp
clang/test/Sema/attr-handles.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 81a0c4a2a9c2..08d12fc25bf7 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8110,6 +8110,15 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
 case ParsedAttr::AT_AcquireHandle: {
   if (!type->isFunctionType())
 return;
+
+  if (attr.getNumArgs() != 1) {
+state.getSema().Diag(attr.getLoc(),
+ diag::err_attribute_wrong_number_arguments)
+<< attr << 1;
+attr.setInvalid();
+return;
+  }
+
   StringRef HandleType;
   if (!state.getSema().checkStringLiteralArgumentAttr(attr, 0, HandleType))
 return;

diff  --git a/clang/test/Sema/attr-handles.cpp 
b/clang/test/Sema/attr-handles.cpp
index 5abb1e8d00bc..135467b6c0a8 100644
--- a/clang/test/Sema/attr-handles.cpp
+++ b/clang/test/Sema/attr-handles.cpp
@@ -17,6 +17,7 @@ int (* __attribute__((acquire_handle("Fuchsia"))) fpt)(char 
*); // expected-warn
 auto lambdat = [](int handle __attribute__((use_handle("Fuchsia"
 __attribute__((acquire_handle("Fuchsia"))) -> int { return 0; };
 int __attribute((acquire_handle("Fuchsia"))) ta; // expected-warning 
{{'acquire_handle' attribute only applies to functions, typedefs, and 
parameters}}
+int open(const char *path, int flags, ...) [[clang::acquire_handle]]; // 
expected-error {{'acquire_handle' attribute takes one argument}}
 
 // Typedefs.
 typedef int callback(char *) __attribute__((acquire_handle("Fuchsia")));



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-25 Thread Layton Kifer via Phabricator via cfe-commits
laytonio added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:838
+if (isValidTRECandidate(CI))
+  HasValidCandidates = true;
+  }

Is there any reason to find and validate candidates now only to have to redo it 
when we actually perform the eliminations? If so, is there any reason this 
needs to follow a different code path than findTRECandidate? findTRECandidate 
is doing the same checks, except for canMoveAboveCall and 
canTransformAccumulatorRecursion, which should probably be refactored into 
findTRECandidate from eliminateCall anyway. If not then all of this code goes 
away and we're left with the same canTRE as in trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82310: Add `BoolLiteralExpression` to SyntaxTree

2020-06-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked an inline comment as done.
gribozavr2 added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1240
+  true;
+  false;
+}

eduucaldas wrote:
> gribozavr2 wrote:
> > eduucaldas wrote:
> > > gribozavr2 wrote:
> > > > C99 has bool literals, but the program should include stdbool.h.
> > > > 
> > > > I feel like it is better to make the predicate something like 
> > > > "hasBoolType()" and change the test to include stdbool.h.
> > > [[ https://clang.llvm.org/doxygen/stdbool_8h_source.html | stdbool ]] 
> > > consists on macro definitions, mapping booleans to integers. `true` is 
> > > preprocessed into 1 and `false` to 0 .
> > > I don't  think there is a reasonable way of getting the proper SyntaxTree 
> > > from that macro expansion
> > > 
> > > Additional problem, we don't have the test infrastructure for includes, 
> > > AFAIK ^^
> > > 
> > > Finally, regarding the predicates, I prefer if they relate to languages, 
> > > otherwise we might create many predicates that test for exactly the same 
> > > thing, e.g. we would have `hasBoolType()` and `hasNullPtr()` that 
> > > ultimately do the same thing, test if Language is not C 
> > > true is preprocessed into 1 and false to 0 .
> > 
> > I see -- yes, that would make a completely different syntax tree.
> > 
> > > Finally, regarding the predicates, I prefer if they relate to languages, 
> > > otherwise we might create many predicates that test for exactly the same 
> > > thing
> > 
> > Generally, testing for features instead of product versions is considered 
> > better, as that leads to more future-proof code (for example, we learned 
> > this lesson again in the area of web extensions and standards). In future, 
> > Clang can start supporting a language feature in other language modes as an 
> > extension (for example, supporting `_Atomic` in C++ is already a thing), or 
> > the language standard itself can decide to incorporate the feature (for 
> > example, C 2035 could adopt the `nullptr` keyword). It is highly unlikely 
> > for complex features like templates, but may reasonably happen for simpler 
> > features.
> > Generally, testing for features instead of product versions is considered 
> > better, as that leads to more future-proof code 
> 
> I totally agree with all you said. My worry was more regarding the fact that 
> the implementation of `hasBoolType` would merely check for the language 
> anyways. So if, following what you said, `true` and `false` really became a 
> feature of C35 then the code would still be broken. 
> 
> But then I guess it would be easier to fix `hasBoolType` than finding all the 
> places where we used just `isC` because booleans are not in C. 
> 
> Specially if all these predicates were put in 
> `clang/Testing/CommandLineArgs.h` or something similar where more people 
> would be seeing it. 
> 
> Which brings the question shouldn't we move these predicates up?
Sorry for miscommunication -- in this specific we could go either way, since 
the C bool feature is already implemented to have a very different AST than in 
C++, and given C's stability principles, it is unlikely to change.

I am trying to move this testing infra to a common place in 
https://reviews.llvm.org/D82179.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82310



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


[PATCH] D82324: [OPENMP]Dynamic globalization for parallel target regions.

2020-06-25 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32ea3397bec8: [OPENMP]Dynamic globalization for parallel 
target regions. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82324

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
+++ clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -1,9 +1,12 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix SEQ
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-cuda-parallel-target-regions | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix  PAR
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
-// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -fopenmp-cuda-teams-reduction-recs-num=2048 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix SEQ
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -fopenmp-cuda-teams-reduction-recs-num=2048 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix SEQ
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - -fopenmp-cuda-parallel-target-regions | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix PAR
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -fopenmp-cuda-teams-reduction-recs-num=2048 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - -fopenmp-cuda-parallel-target-regions | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix PAR
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
@@ -12,21 +15,21 @@
 // CHECK-DAG: [[TEAM2_REDUCE_TY:%.+]] = type { [{{1024|2048}} x i8], [{{1024|2048}} x float] }
 // CHECK-DAG: [[TEAM3_REDUCE_TY:%.+]] = type { [{{1024|2048}} x i32], [{{1024|2048}} x i16] }
 // CHECK-DAG: [[TEAMS_REDUCE_UNION_TY:%.+]] = type { [[TEAM1_REDUCE_TY]] }
-// CHECK-DAG: [[MAP_TY:%.+]] = type { [128 x i8] }
+// SEQ-DAG: [[MAP_TY:%.+]] = type { [128 x i8] }
 
-// CHECK-DAG: [[KERNEL_PTR:@.+]] = internal addrspace(3) global i8* null
-// CHECK-DAG: [[KERNEL_SHARED1:@.+]] = internal unnamed_addr constant i16 1
-

[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-06-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked 4 inline comments as done.
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:452
+  EquivalenceClass(const EquivalenceClass &) = default;
+  EquivalenceClass &operator=(const EquivalenceClass &) = default;
+  EquivalenceClass(EquivalenceClass &&) = default;

NoQ wrote:
> Assignment operator is currently the only thing that makes this class mutable 
> (by allowing to change the `ID` after the class is constructed). Given that 
> we want to put it into the program state, i don't think we want it to be 
> mutable. Can we remove this operator?
Sure, that's a good point!



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:537
+  // true for equality and false for disequality.
+  bool IsEquality = true;
+

NoQ wrote:
> Do i understand correctly that this isn't used yet and it's for the later 
> patches?
Not exactly, it is used in two symmetric cases:
  # We assumed a condition and we try to understand if what we assumed is an 
equality operation
  # We try understand something about a symbol and we want to understand if it 
is an equality operation

So, in the first case, the branch covering `IsEquality == false` does nothing 
and is designed for the later patches.

The second case, however, does work right now.  If we see an equality operation 
where operands are known to be a part of the same class, we can tell for sure 
the result of the comparison.  This way `a == b` is `true` and `a != b` is 
`false`.  You can find this logic in `getRangeForEqualities`.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1425
+  // merge the smaller class into the bigger one.
+  if (Members.getHeight() >= OtherMembers.getHeight()) {
+return mergeImpl(BV, F, State, Members, Other, OtherMembers);

NoQ wrote:
> This makes me slightly worry about nondeterminism: height may depend on 
> things like numeric values of pointers. I guess at the end of the day this 
> will only manifest in choosing a different representative for the merged 
> class, so it shouldn't be too bad, but i'd still rather double-check.
I agree, but as you pointed out correctly, it affects only which ID is used for 
the class.  Other ID is cease to exist after this function.  ID is used other 
than for comparison only for trivial classes, which is not going to happen 
because it is guaranteed to be non-trivial after the merge.  The only thing 
that it might affect is the ordering in the map, but we already have a problem 
with that as we use pointers for keys.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1603-1604
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef State,
SymbolReaper &SymReaper) {
+  ClassMembersTy ClassMembersMap = State->get();

NoQ wrote:
> Ok, this turned out to be much scarier than i expected. At least, can we 
> somehow assert that our data structures remain internally consistent after 
> these operations? I.e., things like "a symbol points to an equivalence class 
> iff it belongs to the set of members of that class", etc.
Assertion like this might cost us double of what we have in this function right 
now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445



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


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-25 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

In D69987#2079524 , @rogfer01 wrote:

> The patch as it stands now LGTM and I think it can be committed. Is there any 
> objection remaining?
>
> Any further comments @simoncook @asb?


This LGTM - thanks @HsiangKai and everyone who's been working on this. As Simon 
said before, it's really nicely laid out which makes it much easier to review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


Re: [PATCH] D82225: [libTooling] Delete deprecated `Stencil` combinators.

2020-06-25 Thread Yitzhak Mandelbaum via cfe-commits
Thanks for alerting me. Why is it important to strip out this information?
Also, might this be something we can change on the arcanist side (to not
add to the commit message) rather than strip out on the git end?

On Wed, Jun 24, 2020 at 3:28 PM Fangrui Song via Phabricator <
revi...@reviews.llvm.org> wrote:

> MaskRay added a comment.
>
> Hi, your git commit contains extra Phabricator tags. You can drop
> `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git
> commit with the following script:
>
>   arcfilter () {
>   arc amend
>   git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1}
> /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/
> {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
>   }
>
> `Reviewed By: ` is considered important by some people. Please keep the
> tag. (I have updated my script to use `--date=now` (setting author date to
> committer date))
>
> `https://reviews.llvm.org/D80978` 
> contains a git pre-push hook to automate this.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D82225/new/
>
> https://reviews.llvm.org/D82225
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5b9ce07 - [openmp] Use Directive_enumSize instead of OMPD_unknown position

2020-06-25 Thread via cfe-commits

Author: Valentin Clement
Date: 2020-06-25T09:18:54-04:00
New Revision: 5b9ce07a761f7d62ad793f9827750243de597215

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

LOG: [openmp] Use Directive_enumSize instead of OMPD_unknown position

Summary:
Previously OMPD_unknown was last item in the Directive enumeration and its 
position was
used in various comparison and assertion. With the new Directive enumeration, 
this should be
change with  llvm::omp::Directive_enumSize. This patch fix two place where it 
was not done in
D81736.

Reviewers: vdmitrie, jdoerfert, jdenny

Reviewed By: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index a000e4dee3b8..87d2c4b5a056 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -580,7 +580,7 @@ bool 
clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
 void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
-  assert(DKind <= OMPD_unknown);
+  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
   switch (DKind) {
   case OMPD_parallel:
   case OMPD_parallel_for:

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 546a265cff85..9fa57d8c9791 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -194,8 +194,9 @@ static OpenMPDirectiveKindExWrapper 
parseOpenMPDirectiveKind(Parser &P) {
   DKind = F[I][2];
 }
   }
-  return DKind < OMPD_unknown ? static_cast(DKind)
-  : OMPD_unknown;
+  return unsigned(DKind) < llvm::omp::Directive_enumSize
+ ? static_cast(DKind)
+ : OMPD_unknown;
 }
 
 static DeclarationName parseOpenMPReductionId(Parser &P) {



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


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-25 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoV.td:9
+///
+/// This file describes the RISC-V instructions from the standard 'V',
+/// Vector instruction set extension.

Please add similar language as in RISCVInstrInfoB.td to indicate the version 
being described and explain this version is experimental and hasn't been 
ratified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-25 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 273321.
lh123 marked 3 inline comments as done.
lh123 added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82535

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -59,6 +59,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -103,6 +104,7 @@
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -140,6 +142,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC3-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -232,6 +235,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -62,6 +62,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -113,6 +114,7 @@
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -156,6 +158,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -264,6 +267,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1816,6 +1816,18 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+// using name = type
+static void AddUsingAliasResult(CodeCompletionBuilder &Builder,
+ResultBuilder &Results) {
+  Builder.AddTypedTextChunk("using");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_Equal);
+  Builder.AddPlaceholderChunk("type");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+
 static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
const LangOptions &LangOpts) {
   switch (CCC) {
@@ -2059,6 +2071,9 @@

[PATCH] D82518: [openmp] Use Directive_enumSize instead of OMPD_unknown position

2020-06-25 Thread Valentin Clement via Phabricator via cfe-commits
clementval marked 2 inline comments as done.
clementval added inline comments.



Comment at: clang/lib/Basic/OpenMPKinds.cpp:583
 OpenMPDirectiveKind DKind) {
-  assert(DKind <= OMPD_unknown);
+  assert(unsigned(DKind) <= llvm::omp::Directive_enumSize);
   switch (DKind) {

jdoerfert wrote:
> `<`, right?
You are right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82518



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


[PATCH] D82518: [openmp] Use Directive_enumSize instead of OMPD_unknown position

2020-06-25 Thread Valentin Clement via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b9ce07a761f: [openmp] Use Directive_enumSize instead of 
OMPD_unknown position (authored by clementval).

Changed prior to commit:
  https://reviews.llvm.org/D82518?vs=273216&id=273327#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82518

Files:
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp


Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -194,8 +194,9 @@
   DKind = F[I][2];
 }
   }
-  return DKind < OMPD_unknown ? static_cast(DKind)
-  : OMPD_unknown;
+  return unsigned(DKind) < llvm::omp::Directive_enumSize
+ ? static_cast(DKind)
+ : OMPD_unknown;
 }
 
 static DeclarationName parseOpenMPReductionId(Parser &P) {
Index: clang/lib/Basic/OpenMPKinds.cpp
===
--- clang/lib/Basic/OpenMPKinds.cpp
+++ clang/lib/Basic/OpenMPKinds.cpp
@@ -580,7 +580,7 @@
 void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
-  assert(DKind <= OMPD_unknown);
+  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
   switch (DKind) {
   case OMPD_parallel:
   case OMPD_parallel_for:


Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -194,8 +194,9 @@
   DKind = F[I][2];
 }
   }
-  return DKind < OMPD_unknown ? static_cast(DKind)
-  : OMPD_unknown;
+  return unsigned(DKind) < llvm::omp::Directive_enumSize
+ ? static_cast(DKind)
+ : OMPD_unknown;
 }
 
 static DeclarationName parseOpenMPReductionId(Parser &P) {
Index: clang/lib/Basic/OpenMPKinds.cpp
===
--- clang/lib/Basic/OpenMPKinds.cpp
+++ clang/lib/Basic/OpenMPKinds.cpp
@@ -580,7 +580,7 @@
 void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
-  assert(DKind <= OMPD_unknown);
+  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
   switch (DKind) {
   case OMPD_parallel:
   case OMPD_parallel_for:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-06-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:537
+  // true for equality and false for disequality.
+  bool IsEquality = true;
+

vsavchenko wrote:
> NoQ wrote:
> > Do i understand correctly that this isn't used yet and it's for the later 
> > patches?
> Not exactly, it is used in two symmetric cases:
>   # We assumed a condition and we try to understand if what we assumed is an 
> equality operation
>   # We try understand something about a symbol and we want to understand if 
> it is an equality operation
> 
> So, in the first case, the branch covering `IsEquality == false` does nothing 
> and is designed for the later patches.
> 
> The second case, however, does work right now.  If we see an equality 
> operation where operands are known to be a part of the same class, we can 
> tell for sure the result of the comparison.  This way `a == b` is `true` and 
> `a != b` is `false`.  You can find this logic in `getRangeForEqualities`.
Ok, makes sense!



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1603-1604
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef State,
SymbolReaper &SymReaper) {
+  ClassMembersTy ClassMembersMap = State->get();

vsavchenko wrote:
> NoQ wrote:
> > Ok, this turned out to be much scarier than i expected. At least, can we 
> > somehow assert that our data structures remain internally consistent after 
> > these operations? I.e., things like "a symbol points to an equivalence 
> > class iff it belongs to the set of members of that class", etc.
> Assertion like this might cost us double of what we have in this function 
> right now.
Sounds pretty amazing and worth every microsecond.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445



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


[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-06-25 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

The last patchset contains the comment about rounding, so I think I will 
consider this accepted.

As a final addendum to the discussion on rounding and overflow... The last 
Appendix to the E-C TR does actually say:

  2.   In the first edition requires that overflow handling is done before 
rounding; for the second edition the order is changed: rounding should be done 
first, followed by overflow handling. Note that this change does not affect any 
result when the overflow mode is saturation. 

The wording in the main text could be a bit clearer about it being explicit, 
though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73186



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


[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:335
+  template  struct is_same_method_impl {
+static bool isSameMethod(...) { return false; }
+  };

Why use var-args rather than spelling out the type arguments like you have on 
lines 339-341 or, simpler, line 351?



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:339
+  template <> struct is_same_method_impl {
+template (S))); break;
+if (isSameMethod(&RecursiveASTVisitor::Traverse##CLASS,
\
+ &Derived::Traverse##CLASS)) { 
\

Do you explain this logic somewhere? Or do you feel it will be obvious to the 
reader? (I don't have a good intuition about this class to judge).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486



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


[PATCH] D82448: [AArch64][SVE] Add bfloat16 support to store intrinsics

2020-06-25 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 4 inline comments as done.
kmclaughlin added a comment.

Thanks for reviewing this again, @fpetrogalli!




Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c:4
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+#include 

fpetrogalli wrote:
> Nit: is it worth adding the `ASM-NOT: warning` check that is used in other 
> tests? Of course, only if it doesn't fail, for in such case we would have to 
> address the problem in a separate patch.
> 
> (Same for all the new C tests added in this patch).
Adding the check doesn't fail, but I will add these checks to the load & store 
tests in a separate patch


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

https://reviews.llvm.org/D82448



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


[PATCH] D82448: [AArch64][SVE] Add bfloat16 support to store intrinsics

2020-06-25 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 273331.
kmclaughlin added a comment.

- Added HasSVE to Predicates in AArch64SVEInstrInfo.td
- Removed unnecessary indentation changes in AArch64SVEInstrInfo.td
- Removed hasBF16 variable from performST1Combine/performSTNT1Combine


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

https://reviews.llvm.org/D82448

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_stnt1-bfloat.c
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-imm.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-reg.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-stores.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
  llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-imm.ll
  llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-reg.ll
  
llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
  
llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll

Index: llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
===
--- llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
@@ -94,6 +94,20 @@
   ret void
 }
 
+define void @test_masked_ldst_sv8bf16(bfloat* %base,  %mask, i64 %offset) nounwind #0 {
+; CHECK-LABEL: test_masked_ldst_sv8bf16:
+; CHECK-NEXT: ldnt1h { z[[DATA:[0-9]+]].h }, p0/z, [x0, x1, lsl #1]
+; CHECK-NEXT: stnt1h { z[[DATA]].h }, p0, [x0, x1, lsl #1]
+; CHECK-NEXT: ret
+  %gep = getelementptr bfloat, bfloat* %base, i64 %offset
+  %data = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %mask,
+  bfloat* %gep)
+  call void @llvm.aarch64.sve.stnt1.nxv8bf16( %data,
+  %mask,
+ bfloat* %gep)
+  ret void
+}
+
 ; 16-lane non-temporal load/stores.
 
 define void @test_masked_ldst_sv16i8(i8* %base,  %mask, i64 %offset) nounwind {
@@ -121,6 +135,7 @@
 ; 8-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv8i16(, i16*)
 declare  @llvm.aarch64.sve.ldnt1.nxv8f16(, half*)
+declare  @llvm.aarch64.sve.ldnt1.nxv8bf16(, bfloat*)
 
 ; 16-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv16i8(, i8*)
@@ -128,14 +143,18 @@
 ; 2-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv2i64(, , i64*)
 declare void @llvm.aarch64.sve.stnt1.nxv2f64(, , double*)
-  
-; 4-element non-temporal stores.
+
+; 4-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv4i32(, , i32*)
 declare void @llvm.aarch64.sve.stnt1.nxv4f32(, , float*)
-  
-; 8-element non-temporal stores.
+
+; 8-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv8i16(, , i16*)
 declare void @llvm.aarch64.sve.stnt1.nxv8f16(, , half*)
+declare void @llvm.aarch64.sve.stnt1.nxv8bf16(, , bfloat*)
 
 ; 16-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv16i8(, , i8*)
+
+; +bf16 is required for the bfloat version.
+attributes #0 = { "target-features"="+sve,+bf16" }
Index: llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
===
--- llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
@@ -139,6 +139,23 @@
   ret void
 }
 
+define void @test_masked_ldst_sv8bf16( * %base,  %mask) nounwind #0 {
+; CHECK-LABEL: test_masked_ldst_sv8bf16:
+; CHECK-NEXT: ldnt1h { z[[DATA:[0-9]+]].h }, p0/z, [x0, #-1, mul vl]
+; CHECK-NEXT: stnt1h { z[[DATA]].h }, p0, [x0, #2, mul vl]
+; CHECK-NEXT: ret
+  %base_load = getelementptr , * %base, i64 -1
+  %base_load_bc = bitcast * %base_load to bfloat*
+  %data = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %mask,
+  bfloat* %base_load_bc)
+  %base_store = getelementptr ,  * %base, i64 2
+  %base_store_bc = bitcast * %base_store to bfloat*
+  call void @llvm.aarch64.sve.stnt1.nxv8bf16( %data,
+  %mask,
+ bfloat* %base_store_bc)
+  ret void
+}
+
 ; 16-lane non-temporal load/stores.
 
 define void @test_masked_ldst_sv16i8( * %base,  %mas

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

2020-06-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro created this revision.
djtodoro added reviewers: vsk, aprantl, dblaikie, probinson.
djtodoro added projects: debug-info, LLVM.
Herald added a project: clang.
Herald added subscribers: llvm-commits, cfe-commits.
djtodoro added a parent revision: D82546: [Debugify][OriginalMode] Export the 
report into JSON file.

In order to test the preservation of the original Debug Info metadata in your 
projects, a front end option could be very useful, since users usually report 
that a concrete entity (e.g. variable `x`, or function `fn2()`) is missing 
debug info. The [0] is an example of running the utility on GDB Project.

[0] https://djolertrk.github.io/di-checker-html-report-example/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/DebugInfo/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/DebugInfo/debugify-each-original.c
===
--- /dev/null
+++ clang/test/DebugInfo/debugify-each-original.c
@@ -0,0 +1,57 @@
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -emit-llvm -S \
+// RUN: -O1 -o - %s 2>&1 | FileCheck %s
+
+int main()
+{
+  int x = 1;
+  int y = 2;
+  return x + y;
+}
+
+// CHECK: Force set function attributes: PASS
+// CHECK-NEXT: Infer set function attributes: PASS
+// CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation: PASS
+// CHECK-NEXT: Called Value Propagation: PASS
+// CHECK-NEXT: Global Variable Optimizer: PASS
+// CHECK-NEXT: Promote Memory to Register: PASS
+// CHECK-NEXT: Dead Argument Elimination: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Globals Alias Analysis: PASS
+// CHECK-NEXT: SROA: PASS
+// CHECK-NEXT: Early CSE w/ MemorySSA: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Conditionally eliminate dead library calls: PASS
+// CHECK-NEXT: PGOMemOPSize: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Reassociate expressions: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: MemCpy Optimization: PASS
+// CHECK-NEXT: Sparse Conditional Constant Propagation: PASS
+// CHECK-NEXT: Bit-Tracking Dead Code Elimination: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Aggressive Dead Code Elimination: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: A No-Op Barrier Pass: PASS
+// CHECK-NEXT: Deduce function attributes in RPO: PASS
+// CHECK-NEXT: Global Variable Optimizer: PASS
+// CHECK-NEXT: Dead Global Elimination: PASS
+// CHECK-NEXT: Globals Alias Analysis: PASS
+// CHECK-NEXT: Float to int: PASS
+// CHECK-NEXT: Lower constant intrinsics: PASS
+// CHECK-NEXT: Loop Distribution: PASS
+// CHECK-NEXT: Loop Vectorization: PASS
+// CHECK-NEXT: Loop Load Elimination: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Optimize scalar/vector ops: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Warn about non-applied transformations: PASS
+// CHECK-NEXT: Alignment from assumptions: PASS
+// CHECK-NEXT: Strip Unused Function Prototypes: PASS
+// CHECK-NEXT: Remove redundant instructions: PASS
+// CHECK-NEXT: Hoist/decompose integer division and remainder: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable

[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Looks good! Only real question is one of design -- should we consider the 
(deeper) change of templating the various types rather than using dynamic 
typing?  For that matter, the decision doesn't even have to be the same for 
both AtomicChange and the Transformer types. Transformer could be templated 
while AtomicChange uses any.

I'm inclined towards what you have, but that may just be laziness on part 
(since this requires minimal changes).  I'm curious to hear what Dmitri thinks.




Comment at: clang/include/clang/Tooling/Refactoring/AtomicChange.h:144
   tooling::Replacements Replaces;
+  llvm::Any Metadata;
 };

Please add a field comment. Something like what you have in the revision 
description would be good.



Comment at: clang/lib/Tooling/Refactoring/AtomicChange.cpp:210
+: AtomicChange(SM, KeyPosition) {
+  Metadata = std::move(M);
+}

I assume that  
```
: AtomicChange(SM, KeyPosition), Metadata(std::move(M)) {}
```
didn't work?



Comment at: clang/unittests/Tooling/RefactoringTest.cpp:1299
 
+struct SomeMetadata {
+  int Data;

any reason not to use int directly as the type carried in the metadata?



Comment at: clang/unittests/Tooling/TransformerTest.cpp:460
+  auto Factory = newFrontendActionFactory(&MatchFinder);
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Input, std::vector(), "input.cc",

Why expect vs assert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82226



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


[PATCH] D82312: Add `CharLiteral` to SyntaxTree

2020-06-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 273343.
eduucaldas marked 3 inline comments as done.
eduucaldas added a comment.

Add tests for unicode characters


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82312

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
@@ -69,6 +69,10 @@
Language == Lang_CXX20;
   }
 
+  bool isCXX17OrLater() const {
+return Language == Lang_CXX17 || Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -1228,6 +1232,135 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, CharacterLiteral) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  'a';
+  '\n';
+  '\x20';
+  '\0';
+  L'a';
+  L'α';
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-'a'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-'\n'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-'\x20'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-'\0'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-L'a'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-L'α'
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, CharacterLiteralUtf) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  u'a';
+  u'構';
+  U'a';
+  U'🌲';
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-u'a'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-u'構'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-U'a'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-U'🌲'
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, CharacterLiteralUtf8) {
+  if (!GetParam().isCXX17OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  u8'a';
+  u8'\x7f';
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-u8'a'
+| `-;
+|-ExpressionStatement
+| |-CharacterLiteralExpression
+| | `-u8'\x7f'
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, IntegerLiteral) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -22,6 +22,8 @@
 return OS << "CxxNullPtrExpression";
   case NodeKind::IntegerLiteralExpression:
 return OS << "IntegerLiteralExpression";
+  case NodeKind::CharacterLiteralExpression:
+return OS << "CharacterLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -200,6 +202,11 @@
   findChild(syntax::NodeRole::LiteralToken));
 }
 
+syntax::Leaf *syntax::CharacterLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::LiteralToken));
+}
+
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::LiteralToken));
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -654,6 +654,13 @@
 return true;
   }
 
+  bool WalkUpFromCharacterLiteral(CharacterLiteral *S) {
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::CharacterLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.ma

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

2020-06-25 Thread liu hui via Phabricator via cfe-commits
lh123 created this revision.
lh123 added a reviewer: kadircet.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
lh123 added a parent revision: D82535: [CodeComplete] Add code completion for 
using alias..

add code completion for `delete` and `default` specifier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82548

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/delete-default-specifier.cpp

Index: clang/test/CodeCompletion/delete-default-specifier.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/delete-default-specifier.cpp
@@ -0,0 +1,24 @@
+struct A {
+  A() = default;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:2:9 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: default
+  // CHECK-CC1-NEXT: COMPLETION: delete
+  A(const A &);
+};
+
+A::A(const A &) = default;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:19 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: COMPLETION: default
+// CHECK-CC2-NEXT: COMPLETION: delete
+
+struct B {
+  void test() = delete;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:15:17 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // CHECK-CC3: COMPLETION: default
+  // CHECK-CC3-NEXT: COMPLETION: delete
+};
+
+void test() = delete;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:21:15 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: COMPLETION: default
+// CHECK-CC4-NEXT: COMPLETION: delete
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6261,6 +6261,25 @@
 Results.data(), Results.size());
 }
 
+void Sema::CodeCompleteFunctionDeleteAndDefaultSpecifier() {
+  if (!LangOpts.CPlusPlus11) {
+return;
+  }
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_Other);
+  Results.EnterNewScope();
+  // FIXME(liuhui): Ideally, we should only provide `default` completion for
+  // special functions.
+  Results.AddResult("default");
+  // FIXME(liuhui): Ideally, we should only provide `delete` completion for the
+  // first function declaration.
+  Results.AddResult("delete");
+  Results.ExitScope();
+  HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+Results.data(), Results.size());
+}
+
 /// Macro that optionally prepends an "@" to the string literal passed in via
 /// Keyword, depending on whether NeedAt is true or false.
 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2714,6 +2714,11 @@
   DefinitionKind = FDK_Defaulted;
 else if (KW.is(tok::kw_delete))
   DefinitionKind = FDK_Deleted;
+else if (KW.is(tok::code_completion)) {
+  Actions.CodeCompleteFunctionDeleteAndDefaultSpecifier();
+  cutOffParsing();
+  return nullptr;
+}
   }
 }
 DeclaratorInfo.setFunctionDefinitionKind(DefinitionKind);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2046,46 +2046,52 @@
   }
 
   // Check to see if we have a function *definition* which must have a body.
-  if (D.isFunctionDeclarator() &&
-  // Look at the next token to make sure that this isn't a function
-  // declaration.  We have to check this because __attribute__ might be the
-  // start of a function definition in GCC-extended K&R C.
-  !isDeclarationAfterDeclarator()) {
-
-// Function definitions are only allowed at file scope and in C++ classes.
-// The C++ inline method definition case is handled elsewhere, so we only
-// need to handle the file scope definition case.
-if (Context == DeclaratorContext::FileContext) {
-  if (isStartOfFunctionDefinition(D)) {
-if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
-  Diag(Tok, diag::err_function_declared_typedef);
-
-  // Recover by treating the 'typedef' as spurious.
-  DS.ClearStorageClassSpecs();
-}
+  if (D.isFunctionDeclarator()) {
+if (Tok.is(tok::equal) && NextToken().is(tok::code_completion)) {
+  Actions.CodeCompleteFunctionDeleteAndDefa

[PATCH] D82360: Add StringLiteral to SyntaxTree

2020-06-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 273346.
eduucaldas added a comment.

Add unicode tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82360

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
@@ -1228,6 +1228,109 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, StringLiteral) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  "a\n\0\x20";
+  L"αβ";
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-StringLiteralExpression
+| | `-"a\n\0\x20"
+| `-;
+|-ExpressionStatement
+| |-StringLiteralExpression
+| | `-L"αβ"
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, StringLiteralUtf) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  u8"a\x1f\x05";
+  u"C++抽象構文木";
+  U"📖🌲\n";
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-StringLiteralExpression
+| | `-u8"a\x1f\x05"
+| `-;
+|-ExpressionStatement
+| |-StringLiteralExpression
+| | `-u"C++抽象構文木"
+| `-;
+|-ExpressionStatement
+| |-StringLiteralExpression
+| | `-U"📖🌲\n"
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, StringLiteralRaw) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  R"SyntaxTree(
+  Hello "Syntax" \"
+  )SyntaxTree";
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-StringLiteralExpression
+| | `-R"SyntaxTree(
+  Hello "Syntax" \"
+  )SyntaxTree"
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, IntegerLiteral) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
@@ -2559,7 +2662,7 @@
 | |-UnknownExpression
 | | `-true
 | |-,
-| |-UnknownExpression
+| |-StringLiteralExpression
 | | `-"message"
 | |-)
 | `-;
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -22,6 +22,8 @@
 return OS << "CxxNullPtrExpression";
   case NodeKind::IntegerLiteralExpression:
 return OS << "IntegerLiteralExpression";
+  case NodeKind::StringLiteralExpression:
+return OS << "StringLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -200,6 +202,11 @@
   findChild(syntax::NodeRole::LiteralToken));
 }
 
+syntax::Leaf *syntax::StringLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::LiteralToken));
+}
+
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::LiteralToken));
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -654,6 +654,13 @@
 return true;
   }
 
+  bool WalkUpFromStringLiteral(StringLiteral *S) {
+Builder.markChildToken(S->getBeginLoc(), syntax::NodeRole::LiteralToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::StringLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -45,6 +45,7 @@
   BinaryOperatorExpression,
   CxxNullPtrExpression,
   IntegerLiteralExpression,
+  StringLiteralExpression,
   IdExpression,
 
   // Statements.
@@ -264,6 +265,16 @@
   syntax::Leaf *literalToken();
 };
 
+/// Expression for string-literals. C++ [lex.string]
+class StringLiteralExpression final : public Expression {
+public:
+  StringLiteralExpression() : Expression(NodeKind::StringLiteralExpres

[PATCH] D82318: Add `FloatingLiteral` to SyntaxTree

2020-06-25 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 273347.
eduucaldas marked an inline comment as done.
eduucaldas added a comment.

Fix indenting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82318

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
@@ -69,6 +69,10 @@
Language == Lang_CXX20;
   }
 
+  bool isCXX17OrLater() const {
+return Language == Lang_CXX17 || Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -1228,6 +1232,91 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, FloatingLiteral) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  1e-2;
+  2.;
+  .2;
+  2.f;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-1e-2
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-2.
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-.2
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-2.f
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, FloatingLiteralHexadecimal) {
+  if (!GetParam().isCXX17OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  0xfp1;
+  0xf.p1;
+  0x.fp1;
+  0xf.fp1f;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xfp1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xf.p1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0x.fp1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xf.fp1f
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, IntegerLiteral) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -22,6 +22,8 @@
 return OS << "CxxNullPtrExpression";
   case NodeKind::IntegerLiteralExpression:
 return OS << "IntegerLiteralExpression";
+  case NodeKind::FloatingLiteralExpression:
+return OS << "FloatingLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -195,6 +197,11 @@
   findChild(syntax::NodeRole::IdExpression_id));
 }
 
+syntax::Leaf *syntax::FloatingLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::LiteralToken));
+}
+
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::LiteralToken));
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -654,6 +654,13 @@
 return true;
   }
 
+  bool WalkUpFromFloatingLiteral(FloatingLiteral *S) {
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::FloatingLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -45,6 +45,7 @@
   BinaryOperatorExpression,
   CxxNullPtrExpression,
   IntegerLiteralExpression,
+  FloatingLiteralExpression,
   IdExpression,
 
   // Statements.
@@ -254,6 +255,17 @@
   syntax::Leaf *nullPtrKeyword();
 };
 
+/// Expression for floating-point literals. C++ [lex.fcon]
+class FloatingLiteralExpression final : public Expression {
+public:
+  FloatingLiteralExpression()
+  : Expression(NodeKind::FloatingLiteralExpression) {}
+  static bool classof(const Nod

[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-25 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai marked an inline comment as done.
HsiangKai added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrFormats.td:56
+def NoConstraint : RISCVVConstraint<0>;
+def WidenV   : RISCVVConstraint<1>;
+def WidenW   : RISCVVConstraint<2>;

evandro wrote:
> HsiangKai wrote:
> > evandro wrote:
> > > Methinks that these constraints `WidenV`, `WidenW`, `WidenCvt`, should be 
> > > split up by their components.  IOW, into `Widen`, `Wide` (input), `Cvt`.  
> > > This way, it's easier to test for specific constraints.
> > Do you mean
> > 
> > WidenV = Widen;
> > WidenW = Widen | WideInput;
> > WidenCvt = Widen | Cvt;
> Yes.
Got it. I will improve it based on v0.9 implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-25 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai marked an inline comment as done.
HsiangKai added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoV.td:9
+///
+/// This file describes the RISC-V instructions from the standard 'V',
+/// Vector instruction set extension.

asb wrote:
> Please add similar language as in RISCVInstrInfoB.td to indicate the version 
> being described and explain this version is experimental and hasn't been 
> ratified.
Got it. I will add more comments similar to RISCVInstrInfoB.td before landing 
the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D70603: Change while to do-while

2020-06-25 Thread Seija Kijin via Phabricator via cfe-commits
pi1024e added a comment.

Any updates?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70603



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


[PATCH] D82448: [AArch64][SVE] Add bfloat16 support to store intrinsics

2020-06-25 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli accepted this revision.
fpetrogalli added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!




Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c:4
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+#include 

kmclaughlin wrote:
> fpetrogalli wrote:
> > Nit: is it worth adding the `ASM-NOT: warning` check that is used in other 
> > tests? Of course, only if it doesn't fail, for in such case we would have 
> > to address the problem in a separate patch.
> > 
> > (Same for all the new C tests added in this patch).
> Adding the check doesn't fail, but I will add these checks to the load & 
> store tests in a separate patch
Yep - thanks for confirming.


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

https://reviews.llvm.org/D82448



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


[PATCH] D82501: [sve][acle] Add reinterpret intrinsics for brain float.

2020-06-25 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked 2 inline comments as done.
fpetrogalli added inline comments.



Comment at: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_reinterpret-bfloat.c:5
+
+#include 
+

david-arm wrote:
> Hi @fpetrogalli, in the same way that you asked @kmclaughlin if she could add 
> the ASM-NOT check line in her patch, are you able to do that here? You'd need 
> to add an additional RUN line though to compile to assembly. Don't worry if 
> it's not possible though!
It is possible, but my understanding is that we anyway decided to do this work 
as a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82501



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


[PATCH] D82391: [AArch64][SVE] Add bfloat16 support to svext intrinsic

2020-06-25 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 273365.
c-rhodes added a comment.

Changes:

- Guard patterns on `+bf16`.


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

https://reviews.llvm.org/D82391

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll


Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -516,6 +516,16 @@
   ret  %out
 }
 
+define  @ext_bf16( %a,  %b) #0 {
+; CHECK-LABEL: ext_bf16:
+; CHECK: ext z0.b, z0.b, z1.b, #6
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ext.nxv8bf16( %a,
+%b,
+   i32 3)
+  ret  %out
+}
+
 define  @ext_f16( %a,  %b) {
 ; CHECK-LABEL: ext_f16:
 ; CHECK: ext z0.b, z0.b, z1.b, #6
@@ -1876,6 +1886,7 @@
 declare  @llvm.aarch64.sve.ext.nxv8i16(, 
, i32)
 declare  @llvm.aarch64.sve.ext.nxv4i32(, 
, i32)
 declare  @llvm.aarch64.sve.ext.nxv2i64(, 
, i32)
+declare  @llvm.aarch64.sve.ext.nxv8bf16(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv8f16(, 
, i32)
 declare  @llvm.aarch64.sve.ext.nxv4f32(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv2f64(, , i32)
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1454,7 +1454,6 @@
 
 def : Pat<(nxv8f16 (bitconvert (nxv16i8 ZPR:$src))), (nxv8f16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv8i16 ZPR:$src))), (nxv8f16 ZPR:$src)>;
-def : Pat<(nxv8bf16 (bitconvert (nxv8i16 ZPR:$src))), (nxv8bf16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv4i32 ZPR:$src))), (nxv8f16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8f16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv4f32 ZPR:$src))), (nxv8f16 ZPR:$src)>;
@@ -1473,6 +1472,14 @@
 def : Pat<(nxv2f64 (bitconvert (nxv2i64 ZPR:$src))), (nxv2f64 ZPR:$src)>;
 def : Pat<(nxv2f64 (bitconvert (nxv8f16 ZPR:$src))), (nxv2f64 ZPR:$src)>;
 def : Pat<(nxv2f64 (bitconvert (nxv4f32 ZPR:$src))), (nxv2f64 ZPR:$src)>;
+
+  }
+
+  let Predicates = [IsLE, HasBF16] in {
+def : Pat<(nxv16i8 (bitconvert (nxv8bf16 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+
+def : Pat<(nxv8bf16 (bitconvert (nxv16i8 ZPR:$src))), (nxv8bf16 ZPR:$src)>;
+def : Pat<(nxv8bf16 (bitconvert (nxv8i16 ZPR:$src))), (nxv8bf16 ZPR:$src)>;
   }
 
   def : Pat<(nxv16i1 (reinterpret_cast (nxv16i1 PPR:$src))), (COPY_TO_REGCLASS 
PPR:$src, PPR)>;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
@@ -0,0 +1,26 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README 
for instructions on how to resolve it.
+// ASM-NOT: warning
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbfloat16_t test_svext_bf16(svbfloat16_t op1, svbfloat16_t op2)
+{
+  // CHECK-LABEL: test_svext_bf16
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.ext.nxv8bf16( %op1,  %op2, i32 127)
+  // CHECK: ret  %[[INTRINSIC]]
+  // expected-warning@+1 {{implicit dec

Re: [PATCH] D82225: [libTooling] Delete deprecated `Stencil` combinators.

2020-06-25 Thread Fāng-ruì Sòng via cfe-commits
On Thu, Jun 25, 2020 at 5:53 AM Yitzhak Mandelbaum  wrote:
>
> Thanks for alerting me. Why is it important to strip out this information? 
> Also, might this be something we can change on the arcanist side (to not add 
> to the commit message) rather than strip out on the git end?

Mostly to keep commit descriptions tidy. In a paper of git log output,
large volume of unneeded Phabricator tags dilutes useful information.
It is said that hacking on the Phabricator side can prevent pushing
some tags, but it may also lose convenience because currently one can
edit Reviewers: and Subscribers:.

> On Wed, Jun 24, 2020 at 3:28 PM Fangrui Song via Phabricator 
>  wrote:
>>
>> MaskRay added a comment.
>>
>> Hi, your git commit contains extra Phabricator tags. You can drop 
>> `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git 
>> commit with the following script:
>>
>>   arcfilter () {
>>   arc amend
>>   git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
>> /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ 
>> {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
>>   }
>>
>> `Reviewed By: ` is considered important by some people. Please keep the tag. 
>> (I have updated my script to use `--date=now` (setting author date to 
>> committer date))
>>
>> `https://reviews.llvm.org/D80978` contains a git pre-push hook to automate 
>> this.
>>
>>
>> Repository:
>>   rG LLVM Github Monorepo
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D82225/new/
>>
>> https://reviews.llvm.org/D82225
>>
>>
>>


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


[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

2020-06-25 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 273372.
gamesh411 added a comment.

update test value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82561

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/test/Analysis/analyzer-config.c


Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -41,7 +41,7 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 100
+// CHECK-NEXT: ctu-import-threshold = 8
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -324,7 +324,7 @@
 "Lowering this threshold can alleviate the memory burder of "
 "analysis with many interdependent definitions located in "
 "various translation units.",
-100u)
+8u)
 
 ANALYZER_OPTION(
 unsigned, AlwaysInlineSize, "ipa-always-inline-size",


Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -41,7 +41,7 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 100
+// CHECK-NEXT: ctu-import-threshold = 8
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -324,7 +324,7 @@
 "Lowering this threshold can alleviate the memory burder of "
 "analysis with many interdependent definitions located in "
 "various translation units.",
-100u)
+8u)
 
 ANALYZER_OPTION(
 unsigned, AlwaysInlineSize, "ipa-always-inline-size",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70603: Change while to do-while

2020-06-25 Thread Seija Kijin via Phabricator via cfe-commits
pi1024e added a comment.

@MaskRay it's been months yet this hasn't landed yet. Why?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70603



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


[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

2020-06-25 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 created this revision.
gamesh411 added reviewers: martong, balazske.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
gamesh411 updated this revision to Diff 273372.
gamesh411 added a comment.

update test value


The default value of 100 makes the analysis slow. Projects of considerable
size can take more time to finish than it is practical. The new default
setting of 8 is based on the analysis of LLVM itself. With the old default
value of 100 the analysis time was over a magnitude slower. Thresholding the
load of ASTUnits is to be extended in the future with a more fine-tuneable
solution that accomodates to the specifics of the project analyzed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82561

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/test/Analysis/analyzer-config.c


Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -41,7 +41,7 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 100
+// CHECK-NEXT: ctu-import-threshold = 8
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -324,7 +324,7 @@
 "Lowering this threshold can alleviate the memory burder of "
 "analysis with many interdependent definitions located in "
 "various translation units.",
-100u)
+8u)
 
 ANALYZER_OPTION(
 unsigned, AlwaysInlineSize, "ipa-always-inline-size",


Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -41,7 +41,7 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 100
+// CHECK-NEXT: ctu-import-threshold = 8
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -324,7 +324,7 @@
 "Lowering this threshold can alleviate the memory burder of "
 "analysis with many interdependent definitions located in "
 "various translation units.",
-100u)
+8u)
 
 ANALYZER_OPTION(
 unsigned, AlwaysInlineSize, "ipa-always-inline-size",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82563: [Sema][NFC] Remove Redundant Condition

2020-06-25 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: sammccall, rsmith.
baloghadamsoftware added a project: clang.
Herald added subscribers: martong, gamesh411, Szelethus, dkrupp, rnkovacs.

Condition `TypeQuals` is checked both in an outer and in an inner `if` 
statement in static function `ConvertDeclSpecToType()` in file `SemaType.cpp`. 
This patch removes the redundant inner check.

The issue was found using `clang-tidy` check under review 
`misc-redundant-condition`. See https://reviews.llvm.org/D81272.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82563

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1759,7 +1759,7 @@
 //   The effect of a cv-qualifier-seq in a function declarator is not the
 //   same as adding cv-qualification on top of the function type. In the
 //   latter case, the cv-qualifiers are ignored.
-if (TypeQuals && Result->isFunctionType()) {
+if (Result->isFunctionType()) {
   diagnoseAndRemoveTypeQualifiers(
   S, DS, TypeQuals, Result, DeclSpec::TQ_const | DeclSpec::TQ_volatile,
   S.getLangOpts().CPlusPlus


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1759,7 +1759,7 @@
 //   The effect of a cv-qualifier-seq in a function declarator is not the
 //   same as adding cv-qualification on top of the function type. In the
 //   latter case, the cv-qualifiers are ignored.
-if (TypeQuals && Result->isFunctionType()) {
+if (Result->isFunctionType()) {
   diagnoseAndRemoveTypeQualifiers(
   S, DS, TypeQuals, Result, DeclSpec::TQ_const | DeclSpec::TQ_volatile,
   S.getLangOpts().CPlusPlus
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82562: Implement AVX ABI Warning/error

2020-06-25 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: craig.topper, echristo.

The x86-64 "avx" feature changes how >128 bit vector types are passed,
instead of being passed in separate 128 bit registers, they can be
passed in 256 bit registers.

"avx512f" does the same thing, except it switches from 256 bit registers
to 512 bit registers.

The result of both of these is an ABI incompatibility between functions
compiled with and without these features.

This patch implements a warning/error pair upon an attempt to call a
function that would run afoul of this. First, if a function is called
that would have its ABI changed, we issue a warning.

Second, if said call is made in a situation where the caller and callee
are known to have different calling conventions (such as the case of
'target'), we instead issue an error.


Repository:
  rC Clang

https://reviews.llvm.org/D82562

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/target-avx-abi-diag.c
  clang/test/CodeGen/target-builtin-error-3.c
  clang/test/CodeGen/target-builtin-noerror.c

Index: clang/test/CodeGen/target-builtin-noerror.c
===
--- clang/test/CodeGen/target-builtin-noerror.c
+++ clang/test/CodeGen/target-builtin-noerror.c
@@ -6,15 +6,15 @@
 
 // No warnings.
 extern __m256i a;
-int __attribute__((target("avx"))) bar(__m256i a) {
+int __attribute__((target("avx"))) bar() {
   return _mm256_extract_epi32(a, 3);
 }
 
 int baz() {
-  return bar(a);
+  return bar();
 }
 
-int __attribute__((target("avx"))) qq_avx(__m256i a) {
+int __attribute__((target("avx"))) qq_avx() {
   return _mm256_extract_epi32(a, 3);
 }
 
@@ -25,7 +25,7 @@
 extern __m256i a;
 int qq() {
   if (__builtin_cpu_supports("avx"))
-return qq_avx(a);
+return qq_avx();
   else
 return qq_noavx();
 }
Index: clang/test/CodeGen/target-builtin-error-3.c
===
--- clang/test/CodeGen/target-builtin-error-3.c
+++ clang/test/CodeGen/target-builtin-error-3.c
@@ -18,11 +18,12 @@
   return __extension__ ({ __m256 __a = (a); (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
 }
 static inline half16 __attribute__((__overloadable__)) convert_half( float16 a ) {
-  half16 r; 
-  r.lo = convert_half( a.lo); 
+  half16 r;
+  r.lo = convert_half(a.lo);
   return r;
 }
 void avx_test( uint16_t *destData, float16 argbF)
 {
-   ((half16U*)destData)[0] = convert_half(argbF);
+  // expected-warning@+1{{AVX vector argument of type 'float16' (vector of 16 'float' values) without 'avx512f' enabled changes the ABI}}
+  ((half16U *)destData)[0] = convert_half(argbF);
 }
Index: clang/test/CodeGen/target-avx-abi-diag.c
===
--- /dev/null
+++ clang/test/CodeGen/target-avx-abi-diag.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512 -o - -S
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512 -o - -S
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -verify=both -o - -S
+
+// both-no-diagnostics
+
+typedef short avx512fType __attribute__((vector_size(64)));
+typedef short avx256Type __attribute__((vector_size(32)));
+
+__attribute__((target("avx"))) void takesAvx256(avx256Type t);
+__attribute__((target("avx512f"))) void takesAvx512(avx512fType t);
+void takesAvx256_no_target(avx256Type t);
+void takesAvx512_no_target(avx512fType t);
+
+void variadic(int i, ...);
+__attribute__((target("avx512f"))) void variadic_err(int i, ...);
+
+// If neither side has an attribute, warn.
+void call_warn(void) {
+  avx256Type t1;
+  takesAvx256_no_target(t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
+
+  avx512fType t2;
+  takesAvx512_no_target(t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
+
+  variadic(1, t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
+  variadic(3, t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
+}
+
+// If only 1 side has an attribute, error.
+void call_errors(void) {
+  avx256Type t1;
+  takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
+  avx512fType t2;
+  takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
+
+  variadic_err(1, t1); // no256-error {

[PATCH] D82391: [AArch64][SVE] Add bfloat16 support to svext intrinsic

2020-06-25 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli accepted this revision.
fpetrogalli added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


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

https://reviews.llvm.org/D82391



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


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

2020-06-25 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 273378.
aelitashen added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Formatting the codes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477

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

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

[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-25 Thread Evandro Menezes via Phabricator via cfe-commits
evandro added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrFormats.td:56
+def NoConstraint : RISCVVConstraint<0>;
+def WidenV   : RISCVVConstraint<1>;
+def WidenW   : RISCVVConstraint<2>;

HsiangKai wrote:
> evandro wrote:
> > HsiangKai wrote:
> > > evandro wrote:
> > > > Methinks that these constraints `WidenV`, `WidenW`, `WidenCvt`, should 
> > > > be split up by their components.  IOW, into `Widen`, `Wide` (input), 
> > > > `Cvt`.  This way, it's easier to test for specific constraints.
> > > Do you mean
> > > 
> > > WidenV = Widen;
> > > WidenW = Widen | WideInput;
> > > WidenCvt = Widen | Cvt;
> > Yes.
> Got it. I will improve it based on v0.9 implementation.
Please, address this comment before committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


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

2020-06-25 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen abandoned this revision.
aelitashen added a comment.

Mistakenly created two diffs on same commit, See D82477 
 for the original diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82505



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-25 Thread Alexey Lapshin via Phabricator via cfe-commits
avl marked an inline comment as done.
avl added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:838
+if (isValidTRECandidate(CI))
+  HasValidCandidates = true;
+  }

laytonio wrote:
> Is there any reason to find and validate candidates now only to have to redo 
> it when we actually perform the eliminations? If so, is there any reason this 
> needs to follow a different code path than findTRECandidate? findTRECandidate 
> is doing the same checks, except for canMoveAboveCall and 
> canTransformAccumulatorRecursion, which should probably be refactored into 
> findTRECandidate from eliminateCall anyway. If not then all of this code goes 
> away and we're left with the same canTRE as in trunk.
We are enumerating all instructions here, so we could understand if there are 
not TRE candidates and stop earlier. That is the reason for doing it here.

I agree that findTRECandidate should be refactored to have the same checks as 
here. 

What do you think is better to do:

- leave early check for TRE candidates in canTRE or remove it
- refactor findTRECandidate or leave it as is

?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


  1   2   3   >