[clang-tools-extra] ba268d2 - [clangd] Fix a typo, NFC.

2020-10-08 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-08T09:35:49+02:00
New Revision: ba268d2fb09ceabfa03a6499258f973be62d7663

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

LOG: [clangd] Fix a typo, NFC.

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index c52ec007bbdc..7322b71e57ce 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -274,7 +274,7 @@ class ClangdServer {
 
   /// Test the validity of a rename operation.
   ///
-  /// If NewName is provided, it peforms a name validation.
+  /// If NewName is provided, it performs a name validation.
   void prepareRename(PathRef File, Position Pos,
  llvm::Optional NewName,
  const RenameOptions &RenameOpts,



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


[PATCH] D88881: [clangd] Add a NewName optional parameter to clangdServer::prepareRename.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:277
+  ///
+  /// If NewName is provided, it peforms a name validation.
   void prepareRename(PathRef File, Position Pos,

danielmartin wrote:
> 
oh, thanks! Fixed in ba268d2fb09ceabfa03a6499258f973be62d7663.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D1

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


[PATCH] D88984: Prefer libc++ headers in the -isysroot over the toolchain

2020-10-08 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

On macOS, LLDB's tests pass `-isysroot /path/to/SDK` to Clang but expect that 
Clang always prefers the the libc++ headers that are in the Clang build 
directory. So if we change this behaviour then we should have a way to keep the 
old behaviour around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88984

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


[PATCH] D88916: [AMDGPU] Add gfx602, gfx705, gfx805 targets

2020-10-08 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: clang/lib/Basic/Cuda.cpp:1
 #include "clang/Basic/Cuda.h"
 

(aside - this file seems to be missing the copyright header - probably should 
be fixed separately though)



Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:1733
 static const EnumEntry ElfHeaderAMDGPUFlags[] = {
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_NONE),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_R600_R600),

I'm not sure what exactly clang-format is complaining about here, but it might 
be worth reformatting this enum as requested, possibly as a separate commit, I 
don't mind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88916

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


[PATCH] D84387: [AST][RecoveryExpr] Part4: Support dependent cast-expr in C for error-recovery.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa96bcfb19674: [AST][RecoveryExpr] Support dependent 
cast-expr in C for error-recovery. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D84387?vs=296611&id=296882#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84387

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/Sema/error-dependence.c


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -1,11 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type 
%s
 
-int call(int); // expected-note2 {{'call' declared here}}
+int call(int); // expected-note3 {{'call' declared here}}
 
 void test1(int s) {
   // verify "assigning to 'int' from incompatible type ''" is
   // not emitted.
   s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify diagnostic "operand of type '' where arithmetic or
+  // pointer type is required" is not emitted.
+  (float)call(); // expected-error {{too few arguments to function call}}
 }
 
 void test2(int* ptr, float f) {
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -81,4 +81,9 @@
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int *' lvalue
   // CHECK-NEXT: `-DeclRefExpr {{.*}} 'float' lvalue
   (ptr > f ? ptr : f);
+
+  // CHECK: CStyleCastExpr {{.*}} 'float' contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
+  (float)some_func();
 }
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2707,6 +2707,17 @@
 return;
   }
 
+  // If the type is dependent, we won't do any other semantic analysis now.
+  if (Self.getASTContext().isDependenceAllowed() &&
+  (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
+   SrcExpr.get()->isValueDependent())) {
+assert((DestType->containsErrors() || SrcExpr.get()->containsErrors() ||
+SrcExpr.get()->containsErrors()) &&
+   "should only occur in error-recovery path.");
+assert(Kind == CK_Dependent);
+return;
+  }
+
   // Overloads are allowed with C extensions, so we need to support them.
   if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
 DeclAccessPair DAP;


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -1,11 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type %s
 
-int call(int); // expected-note2 {{'call' declared here}}
+int call(int); // expected-note3 {{'call' declared here}}
 
 void test1(int s) {
   // verify "assigning to 'int' from incompatible type ''" is
   // not emitted.
   s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify diagnostic "operand of type '' where arithmetic or
+  // pointer type is required" is not emitted.
+  (float)call(); // expected-error {{too few arguments to function call}}
 }
 
 void test2(int* ptr, float f) {
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -81,4 +81,9 @@
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int *' lvalue
   // CHECK-NEXT: `-DeclRefExpr {{.*}} 'float' lvalue
   (ptr > f ? ptr : f);
+
+  // CHECK: CStyleCastExpr {{.*}} 'float' contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
+  (float)some_func();
 }
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2707,6 +2707,17 @@
 return;
   }
 
+  // If the type is dependent, we won't do any other semantic analysis now.
+  if (Self.getASTContext().isDependenceAllowed() &&
+  (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
+   SrcExpr.get()->isValueDependent())) {
+assert((DestType->containsErrors() || SrcExpr.get()->containsErrors() ||
+SrcExpr.get()->containsErrors()) &&
+   "should only occur in error-recovery path.");
+assert(Kind == CK_Dependent);
+return;
+  }
+
   // Overloads are allowed with C extensions, so we need to support them.
   if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
 DeclAccessPair DA

[clang] a96bcfb - [AST][RecoveryExpr] Support dependent cast-expr in C for error-recovery.

2020-10-08 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-08T10:00:29+02:00
New Revision: a96bcfb196740b5be217f6166462ee1206530520

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

LOG: [AST][RecoveryExpr] Support dependent cast-expr in C for error-recovery.

Suppress spurious "typecheck_cond_expect_scalar_operand" diagnostic.

See whole context: https://reviews.llvm.org/D85025

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/Sema/SemaCast.cpp
clang/test/AST/ast-dump-recovery.c
clang/test/Sema/error-dependence.c

Removed: 




diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index d59f1880a7ff..0bd240585bd7 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2707,6 +2707,17 @@ void CastOperation::CheckCStyleCast() {
 return;
   }
 
+  // If the type is dependent, we won't do any other semantic analysis now.
+  if (Self.getASTContext().isDependenceAllowed() &&
+  (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
+   SrcExpr.get()->isValueDependent())) {
+assert((DestType->containsErrors() || SrcExpr.get()->containsErrors() ||
+SrcExpr.get()->containsErrors()) &&
+   "should only occur in error-recovery path.");
+assert(Kind == CK_Dependent);
+return;
+  }
+
   // Overloads are allowed with C extensions, so we need to support them.
   if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
 DeclAccessPair DAP;

diff  --git a/clang/test/AST/ast-dump-recovery.c 
b/clang/test/AST/ast-dump-recovery.c
index 7b2bcf27ecce..d14aedebe490 100644
--- a/clang/test/AST/ast-dump-recovery.c
+++ b/clang/test/AST/ast-dump-recovery.c
@@ -81,4 +81,9 @@ void test2() {
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int *' lvalue
   // CHECK-NEXT: `-DeclRefExpr {{.*}} 'float' lvalue
   (ptr > f ? ptr : f);
+
+  // CHECK: CStyleCastExpr {{.*}} 'float' contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
+  (float)some_func();
 }

diff  --git a/clang/test/Sema/error-dependence.c 
b/clang/test/Sema/error-dependence.c
index b83a79f8c4c6..41733cdba3fe 100644
--- a/clang/test/Sema/error-dependence.c
+++ b/clang/test/Sema/error-dependence.c
@@ -1,11 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type 
%s
 
-int call(int); // expected-note2 {{'call' declared here}}
+int call(int); // expected-note3 {{'call' declared here}}
 
 void test1(int s) {
   // verify "assigning to 'int' from incompatible type ''" is
   // not emitted.
   s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify diagnostic "operand of type '' where arithmetic or
+  // pointer type is required" is not emitted.
+  (float)call(); // expected-error {{too few arguments to function call}}
 }
 
 void test2(int* ptr, float f) {



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


[PATCH] D84304: [AST][RecoveryExpr] Part 2: Build dependent callexpr in C for error-recovery.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 296885.
hokein added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84304

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/Sema/error-dependence.c


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -10,6 +10,9 @@
   // verify diagnostic "operand of type '' where arithmetic or
   // pointer type is required" is not emitted.
   (float)call(); // expected-error {{too few arguments to function call}}
+  // verify disgnostic "called object type '' is not a function
+  // or function pointer" is not emitted.
+  (*__builtin_classify_type)(1); // expected-error {{builtin functions must be 
directly called}}
 }
 
 void test2(int* ptr, float f) {
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -87,3 +87,18 @@
   // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
   (float)some_func();
 }
+
+void test3() {
+  // CHECK: CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: |-ParenExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT: | `-RecoveryExpr {{.*}} contains-errors
+  // CHECK-NEXT: |   `-DeclRefExpr {{.*}} '__builtin_classify_type'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  (*__builtin_classify_type)(1);
+
+  extern void ext();
+  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
+  ext(undef_var);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6439,6 +6439,21 @@
 checkDirectCallValidity(*this, Fn, FD, ArgExprs);
   }
 
+  if (Context.isDependenceAllowed() &&
+  (Fn->isTypeDependent() || Expr::hasAnyTypeDependentArguments(ArgExprs))) 
{
+assert(!getLangOpts().CPlusPlus);
+assert(Fn->containsErrors() ||
+   llvm::any_of(ArgExprs,
+[](clang::Expr *E) { return E->containsErrors(); }) &&
+   "should only occur in error-recovery path.");
+QualType ReturnType =
+llvm::isa_and_nonnull(NDecl)
+? dyn_cast(NDecl)->getCallResultType()
+: Context.DependentTy;
+return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
+Expr::getValueKindForType(ReturnType), RParenLoc,
+CurFPFeatureOverrides());
+  }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);
 }
@@ -6579,7 +6594,7 @@
  CurFPFeatureOverrides(), NumParams, UsesADL);
   }
 
-  if (!getLangOpts().CPlusPlus) {
+  if (!Context.isDependenceAllowed()) {
 // Forget about the nulled arguments since typo correction
 // do not handle them well.
 TheCall->shrinkNumArgs(Args.size());
@@ -19116,7 +19131,7 @@
 /// Check for operands with placeholder types and complain if found.
 /// Returns ExprError() if there was an error and no recovery was possible.
 ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
-  if (!getLangOpts().CPlusPlus) {
+  if (!Context.isDependenceAllowed()) {
 // C cannot handle TypoExpr nodes on either side of a binop because it
 // doesn't handle dependent types properly, so make sure any TypoExprs have
 // been dealt with before checking the operands.


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -10,6 +10,9 @@
   // verify diagnostic "operand of type '' where arithmetic or
   // pointer type is required" is not emitted.
   (float)call(); // expected-error {{too few arguments to function call}}
+  // verify disgnostic "called object type '' is not a function
+  // or function pointer" is not emitted.
+  (*__builtin_classify_type)(1); // expected-error {{builtin functions must be directly called}}
 }
 
 void test2(int* ptr, float f) {
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -87,3 +87,18 @@
   // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
   (float)some_func();
 }
+
+void test3() {
+  // CHECK: CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: |-ParenExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT: | `-RecoveryExpr {{.*}} contains-errors
+  // CHECK-NEXT: |   `-DeclRefExpr {{.*}} '__builtin_classify_type'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  (*__builtin_classify_type)(1);
+
+ 

[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).

2020-10-08 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: llvm/include/llvm/Analysis/TargetLibraryInfo.h:91
 Accelerate, // Use Accelerate framework.
+LIBMVEC,// GLIBC Vector Math library.
 MASSV,  // IBM MASS vector library.

Can we call this LIBMVEC-X86? Libmvec itself is supposed to support other 
architectures, I can see list of mappings for each of the supported targets.

Then, the logic of selecting the correct one in the frontent clang would depend 
on the value of `-fvec-lib=libmvec` plus the value of `-target`.


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

https://reviews.llvm.org/D88154

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


[PATCH] D88929: [OpenMP] Change CMake Configuration to Build for Highest CUDA Architecture by Default

2020-10-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Nice patch. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88929

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


[PATCH] D87279: [clang] Fix handling of physical registers in inline assembly operands.

2020-10-08 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa updated this revision to Diff 296901.
jonpa marked an inline comment as done.
jonpa added a comment.

Updated per review to use SmallSet.


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

https://reviews.llvm.org/D87279

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c

Index: clang/test/CodeGen/systemz-inline-asm.c
===
--- clang/test/CodeGen/systemz-inline-asm.c
+++ clang/test/CodeGen/systemz-inline-asm.c
@@ -129,3 +129,17 @@
 // CHECK: [[RESULT:%.*]] = tail call fp128 asm "axbr $0, $2", "=f,0,f"(fp128 %f, fp128 %g)
 // CHECK: store fp128 [[RESULT]], fp128* [[DEST]]
 }
+
+// Test that there are no tied physreg uses. TwoAddress pass cannot deal with them.
+int test_physregs(void) {
+  // CHECK-LABEL: define signext i32 @test_physregs()
+  register int l __asm__("r7") = 0;
+
+  // CHECK: call i32 asm "lr $0, $1", "={r7},{r7}"
+  __asm__("lr %0, %1" : "+r"(l));
+
+  // CHECK: call i32 asm "$0 $1 $2", "={r7},{r7},{r7}"
+  __asm__("%0 %1 %2" : "+r"(l) : "r"(l));
+
+  return l;
+}
Index: clang/test/CodeGen/systemz-inline-asm-02.c
===
--- /dev/null
+++ clang/test/CodeGen/systemz-inline-asm-02.c
@@ -0,0 +1,13 @@
+// RUN: not %clang_cc1 -triple s390x-linux-gnu -O2 -emit-llvm -o - %s 2>&1 \
+// RUN:  | FileCheck %s
+// REQUIRES: systemz-registered-target
+
+// Test that an error is given if a physreg is defined by multiple operands.
+int test_physreg_defs(void) {
+  register int l __asm__("r7") = 0;
+
+  // CHECK: error: Multiple outputs to hard register: r7
+  __asm__("" : "+r"(l), "=r"(l));
+
+  return l;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -21,6 +21,7 @@
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
@@ -1836,7 +1837,8 @@
 static std::string
 AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
const TargetInfo &Target, CodeGenModule &CGM,
-   const AsmStmt &Stmt, const bool EarlyClobber) {
+   const AsmStmt &Stmt, const bool EarlyClobber,
+   std::string *GCCReg = nullptr) {
   const DeclRefExpr *AsmDeclRef = dyn_cast(&AsmExpr);
   if (!AsmDeclRef)
 return Constraint;
@@ -1861,6 +1863,8 @@
   }
   // Canonicalize the register here before returning it.
   Register = Target.getNormalizedGCCRegisterName(Register);
+  if (GCCReg != nullptr)
+*GCCReg = Register.str();
   return (EarlyClobber ? "&{" : "{") + Register.str() + "}";
 }
 
@@ -2059,6 +2063,9 @@
   // Keep track of out constraints for tied input operand.
   std::vector OutputConstraints;
 
+  // Keep track of defined physregs.
+  llvm::SmallSet PhysRegOutputs;
+
   // An inline asm can be marked readonly if it meets the following conditions:
   //  - it doesn't have any sideeffects
   //  - it doesn't clobber memory
@@ -2078,9 +2085,15 @@
 const Expr *OutExpr = S.getOutputExpr(i);
 OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
 
+std::string GCCReg;
 OutputConstraint = AddVariableConstraints(OutputConstraint, *OutExpr,
   getTarget(), CGM, S,
-  Info.earlyClobber());
+  Info.earlyClobber(),
+  &GCCReg);
+// Give an error on multiple outputs to same physreg.
+if (!GCCReg.empty() && !PhysRegOutputs.insert(GCCReg).second)
+  CGM.Error(S.getAsmLoc(), "Multiple outputs to hard register: " + GCCReg);
+
 OutputConstraints.push_back(OutputConstraint);
 LValue Dest = EmitLValue(OutExpr);
 if (!Constraints.empty())
@@ -2167,7 +2180,8 @@
 LargestVectorWidth =
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
-  if (Info.allowsRegister())
+  // Don't tie physregs.
+  if (Info.allowsRegister() && GCCReg.empty())
 InOutConstraints += llvm::utostr(i);
   else
 InOutConstraints += OutputConstraint;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-10-08 Thread David Sherwood via Phabricator via cfe-commits
david-arm created this revision.
david-arm added reviewers: sdesmalen, ctetreau, fhahn, c-rhodes.
Herald added subscribers: cfe-commits, psnobl, tschuett.
Herald added a reviewer: efriedma.
Herald added a reviewer: aaron.ballman.
Herald added a project: clang.
david-arm requested review of this revision.

This patch adds support for an optional second parameter passed to
the vectorize_width pragma, which indicates if the user wishes
to use fixed width or scalable vectorization. For example the user
can now write something like:

  #pragma clang loop vectorize_width(4, fixed)

or

  #pragma clang loop vectorize_width(4, scalable)

I have added a new 'scalable_numeric' state to the LoopHintAttr class
to indicate whether the numeric vectorization width is scalable or
not. When generating IR we make use of the new format for the
llvm.loop.vectorize.width attribute that allows us to effectively pass
an ElementCount that contains the vectorization factor and a scalable
flag.

Tests were added to

  clang/test/CodeGenCXX/pragma-loop.cpp

for both the 'fixed' and 'scalable' optional parameter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89031

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp

Index: clang/test/CodeGenCXX/pragma-loop.cpp
===
--- clang/test/CodeGenCXX/pragma-loop.cpp
+++ clang/test/CodeGenCXX/pragma-loop.cpp
@@ -158,6 +158,30 @@
   for_template_constant_expression_test(List, Length);
 }
 
+// Verify do loop is performing fixed width vectorization
+void do_test_fixed(int *List, int Length) {
+  int i = 0;
+
+#pragma clang loop vectorize_width(16, fixed) interleave_count(4) unroll(disable) distribute(disable)
+  do {
+// CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_15:.*]]
+List[i] = i * 2;
+i++;
+  } while (i < Length);
+}
+
+// Verify do loop is performing scalable vectorization
+void do_test_scalable(int *List, int Length) {
+  int i = 0;
+
+#pragma clang loop vectorize_width(16, scalable) interleave_count(4) unroll(disable) distribute(disable)
+  do {
+// CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_16:.*]]
+List[i] = i * 2;
+i++;
+  } while (i < Length);
+}
+
 // CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_FULL:.*]]}
 // CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
 
@@ -215,3 +239,10 @@
 
 // CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[WIDTH_10:.*]], ![[VECTORIZE_ENABLE]]}
 // CHECK: ![[WIDTH_10]] = !{!"llvm.loop.vectorize.width", i32 10}
+
+// CHECK: ![[LOOP_15]] = distinct !{![[LOOP_15]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_FIXED:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[WIDTH_16_FIXED]] = !{!"llvm.loop.vectorize.width", i32 16}
+
+// CHECK: ![[LOOP_16]] = distinct !{![[LOOP_16]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_SCALABLE:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[WIDTH_16_SCALABLE]] = !{!"llvm.loop.vectorize.width", ![[ELEMENT_COUNT_16_SCALABLE:.*]]}
+// CHECK: ![[ELEMENT_COUNT_16_SCALABLE]] = !{i32 16, i32 1}
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -139,10 +139,17 @@
LoopHintAttr::PipelineInitiationInterval)
  .Case("distribute", LoopHintAttr::Distribute)
  .Default(LoopHintAttr::Vectorize);
-if (Option == LoopHintAttr::VectorizeWidth ||
-Option == LoopHintAttr::InterleaveCount ||
-Option == LoopHintAttr::UnrollCount ||
-Option == LoopHintAttr::PipelineInitiationInterval) {
+if (Option == LoopHintAttr::VectorizeWidth) {
+  assert(ValueExpr && "Attribute must have a valid value expression.");
+  if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
+return nullptr;
+  if (StateLoc && StateLoc->Ident && StateLoc->Ident->isStr("scalable"))
+State = LoopHintAttr::ScalableNumeric;
+  else
+State = LoopHintAttr::Numeric;
+} else if (Option == LoopHintAttr::InterleaveCount ||
+   Option == LoopHintAttr::UnrollCount ||
+   Option == LoopHintAttr::PipelineInitiationInterval) {
   assert(ValueExpr && "Attribute must have a valid value expression.");
   if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
 return nullptr;
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -1093,7 +1093,6 @@
   assert(Tok.is(tok::annot_prag

[PATCH] D88964: [clangd] Add a missing include-fixer test for incomplete_type, NFC.

2020-10-08 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.

still LGTM




Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:715
   auto TU = TestTU::withCode(Test.code());
+  TU.ExtraArgs.push_back("-std=c++17");
   auto Index = buildIndexWithSymbol(

hokein wrote:
> kadircet wrote:
> > why do we need c++17 ?
> The newly-added test case is using C++17 feature (structure binding), needs 
> this flag to suppress a diagnostic warning. 
> 
ah okay i see it now, structured binding wasn't obvious from the test case 
above (i thought there was a typo :D



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:738
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("nested"),
+ "incomplete type 'ns::X' named in nested name specifier"),

hokein wrote:
> kadircet wrote:
> > can you move this back to original position ?
> yeah, I reordered the list.
> 
> there are two orders: the one listed here, and the one listed in 
> `IncludeFixer.cpp`.
> 
> The motivation is to make them aligned, so that it would be easier to compare 
> and spot the difference. The current state is not friendly to readers.
i don't think the orderings in the source vs test is that relevant, but SGTM if 
it helps you. mainly because:
- as it might be harder in future to trigger diagnostics in the order we want
- it is an invariant hard to maintain without at least the reviewer or author 
of changes knowing about(and remembering) it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88964

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


[PATCH] D88411: [clangd] Introduce MemoryTrees

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> Still LGTM, commit it already :-D

Haha, waiting for dependents to be stamped as well :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88411

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


[PATCH] D88411: [clangd] Introduce MemoryTrees

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

- Inline MemoryTree::self


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88411

Files:
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/MemoryTree.cpp
  clang-tools-extra/clangd/support/MemoryTree.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp

Index: clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp
@@ -0,0 +1,78 @@
+//===-- MemoryTreeTests.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/MemoryTree.h"
+#include "llvm/Support/Allocator.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+using testing::Contains;
+using testing::IsEmpty;
+using testing::UnorderedElementsAre;
+
+MATCHER_P2(WithNameAndSize, Name, Size, "") {
+  return arg.first == Name &&
+ arg.getSecond().total() == static_cast(Size);
+}
+
+TEST(MemoryTree, Basics) {
+  MemoryTree MT;
+  EXPECT_EQ(MT.total(), 0U);
+  EXPECT_THAT(MT.children(), IsEmpty());
+
+  MT.addUsage(42);
+  EXPECT_EQ(MT.total(), 42U);
+  EXPECT_THAT(MT.children(), IsEmpty());
+
+  MT.child("leaf").addUsage(1);
+  EXPECT_EQ(MT.total(), 43U);
+  EXPECT_THAT(MT.children(), UnorderedElementsAre(WithNameAndSize("leaf", 1)));
+
+  // child should be idempotent.
+  MT.child("leaf").addUsage(1);
+  EXPECT_EQ(MT.total(), 44U);
+  EXPECT_THAT(MT.children(), UnorderedElementsAre(WithNameAndSize("leaf", 2)));
+}
+
+TEST(MemoryTree, DetailedNodesWithoutDetails) {
+  MemoryTree MT;
+  MT.detail("should_be_ignored").addUsage(2);
+  EXPECT_THAT(MT.children(), IsEmpty());
+  EXPECT_EQ(MT.total(), 2U);
+
+  // Make sure children from details are merged.
+  MT.detail("first_detail").child("leaf").addUsage(1);
+  MT.detail("second_detail").child("leaf").addUsage(1);
+  EXPECT_THAT(MT.children(), Contains(WithNameAndSize("leaf", 2)));
+}
+
+TEST(MemoryTree, DetailedNodesWithDetails) {
+  llvm::BumpPtrAllocator Alloc;
+  MemoryTree MT(&Alloc);
+
+  {
+auto &Detail = MT.detail("first_detail");
+Detail.child("leaf").addUsage(1);
+EXPECT_THAT(MT.children(), Contains(WithNameAndSize("first_detail", 1)));
+EXPECT_THAT(Detail.children(), Contains(WithNameAndSize("leaf", 1)));
+  }
+
+  {
+auto &Detail = MT.detail("second_detail");
+Detail.child("leaf").addUsage(1);
+EXPECT_THAT(MT.children(), Contains(WithNameAndSize("second_detail", 1)));
+EXPECT_THAT(Detail.children(), Contains(WithNameAndSize("leaf", 1)));
+  }
+}
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -99,6 +99,7 @@
   support/ContextTests.cpp
   support/FunctionTests.cpp
   support/MarkupTests.cpp
+  support/MemoryTreeTests.cpp
   support/ThreadingTests.cpp
   support/TestTracer.cpp
   support/TraceTests.cpp
Index: clang-tools-extra/clangd/support/MemoryTree.h
===
--- /dev/null
+++ clang-tools-extra/clangd/support/MemoryTree.h
@@ -0,0 +1,86 @@
+//===--- MemoryTree.h - A special tree for components and sizes -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MEMORYTREE_H_
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MEMORYTREE_H_
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/StringSaver.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A tree that can be used to represent memory usage of nested components while
+/// preserving the hierarchy.
+/// Edges have associated names. An edge that might not be interesting to all
+/// traversers or costly to copy (e.g. file names) can be marked as "detail".
+/// Tree construction allows chosing between a detailed and brief mode, in brief
+/// mode a

[PATCH] D88968: [WebAssembly] Prototype i16x8.q15mulr_sat_s

2020-10-08 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:117
 
+TARGET_BUILTIN(__builtin_wasm_q15mulr_saturate_s_i8x16, "V8UsV8UsV8Us", "nc", 
"simd128")
+

- Is it implemented in the VM? If not shouldn't we use `unimplemented-simd128`?
- Are the args and the result unsigned?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88968

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


[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-10-08 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@JakeMerdichAMD @MyDeveloperDay Do you know if the regression has been fixed?
thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79388

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


[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).

2020-10-08 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: llvm/include/llvm/Analysis/TargetLibraryInfo.h:91
 Accelerate, // Use Accelerate framework.
+LIBMVEC,// GLIBC Vector Math library.
 MASSV,  // IBM MASS vector library.

fpetrogalli wrote:
> Can we call this LIBMVEC-X86? Libmvec itself is supposed to support other 
> architectures, I can see list of mappings for each of the supported targets.
> 
> Then, the logic of selecting the correct one in the frontent clang would 
> depend on the value of `-fvec-lib=libmvec` plus the value of `-target`.
So if I follow correctly, we can choose the various vendor-specific libraries 
as well as `libmvec` which itself has target-specific ports.

Would it make sense to just add an overload of `addVectorizableFunctions()` 
that would consider the `Triple` and remove any entries from `VectorDescs` that 
the target doesn't support? Or even more specifically, simply add the `Triple` 
argument to `addVectorizableFunctionsFromVecLib()` and call something like 
`removeLIBMVECEntriesForTarget(const Triple &T)` that would do the job.

And of course, if the triple isn't provided and the user is targeting an 
architecture that doesn't provide some entry, that is just user error.


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

https://reviews.llvm.org/D88154

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


[PATCH] D89035: [clangd] New CC Ranking Model to fix bad inference due to overflow.

2020-10-08 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added a reviewer: adamcz.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Unreachable file distances are represented as
`std::numeric_limits::max()`.
The previous dataset recorded the signals as `signed int` capturing this default
value as `-1`.

A new dataset was regenerated and a new model is trained that
interprets this unreachable as the intended value.

Distribution of `SymbolScopeDistance`:
Value Normalised Frequency
0 46.6184
429496729529.5342
6 14.5666
4  6.4433
2  1.4534
8  0.5760
10 0.3581


Distribution of `FileProximityDistance`:
Value Normalised Frequency
429496729539.9378
12 5.1997
14 4.9828
15 4.4221
16 4.3820
13 4.2765
17 3.8957
11 3.6387
19 3.4799
18 3.4076



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89035

Files:
  clang-tools-extra/clangd/quality/model/forest.json




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


[clang] 70bf350 - [Driver] Add output file to properties of Command

2020-10-08 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2020-10-08T18:23:39+07:00
New Revision: 70bf35070a74df02ed12b9988ce58d50e63a7c04

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

LOG: [Driver] Add output file to properties of Command

Object of class `Command` contains various properties of a command to
execute, but output file was missed from them. This change adds this
property. It is required for reporting consumed time and memory implemented
in D78903 and may be used in other cases too.

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

Added: 


Modified: 
clang/include/clang/Driver/Job.h
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/Ananas.cpp
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CloudABI.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CrossWindows.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/DragonFly.cpp
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Driver/ToolChains/InterfaceStubs.cpp
clang/lib/Driver/ToolChains/MSP430.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/Minix.cpp
clang/lib/Driver/ToolChains/Myriad.cpp
clang/lib/Driver/ToolChains/NaCl.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/lib/Driver/ToolChains/RISCVToolchain.cpp
clang/lib/Driver/ToolChains/Solaris.cpp
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/lib/Driver/ToolChains/XCore.cpp
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index 6173b9d314b4..8a348c8048d0 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -122,6 +122,9 @@ class Command {
   /// The list of program arguments which are inputs.
   llvm::opt::ArgStringList InputFilenames;
 
+  /// The list of program arguments which are outputs. May be empty.
+  std::vector OutputFilenames;
+
   /// Response file name, if this command is set to use one, or nullptr
   /// otherwise
   const char *ResponseFile = nullptr;
@@ -158,8 +161,8 @@ class Command {
 
   Command(const Action &Source, const Tool &Creator,
   ResponseFileSupport ResponseSupport, const char *Executable,
-  const llvm::opt::ArgStringList &Arguments,
-  ArrayRef Inputs);
+  const llvm::opt::ArgStringList &Arguments, ArrayRef 
Inputs,
+  ArrayRef Outputs = None);
   // FIXME: This really shouldn't be copyable, but is currently copied in some
   // error handling in Driver::generateCompilationDiagnostics.
   Command(const Command &) = default;
@@ -201,6 +204,14 @@ class Command {
 
   const llvm::opt::ArgStringList &getArguments() const { return Arguments; }
 
+  const llvm::opt::ArgStringList &getInputFilenames() const {
+return InputFilenames;
+  }
+
+  const std::vector &getOutputFilenames() const {
+return OutputFilenames;
+  }
+
 protected:
   /// Optionally print the filenames to be compiled
   void PrintFileNames() const;
@@ -212,7 +223,7 @@ class CC1Command : public Command {
   CC1Command(const Action &Source, const Tool &Creator,
  ResponseFileSupport ResponseSupport, const char *Executable,
  const llvm::opt::ArgStringList &Arguments,
- ArrayRef Inputs);
+ ArrayRef Inputs, ArrayRef Outputs = None);
 
   void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
  CrashReportInfo *CrashInfo = nullptr) const override;
@@ -230,7 +241,7 @@ class FallbackCommand : public Command {
   FallbackCommand(const Action &Source_, const Tool &Creator_,
   ResponseFileSupport ResponseSupport, const char *Executable_,
   const llvm::opt::ArgStringList &Arguments_,
-  ArrayRef Inputs,
+  ArrayRef Inputs, ArrayRef Outputs,
   std::unique_ptr Fallback_);
 
   void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
@@ -250,7 +261,8 @@ class ForceSuccessCommand : public Command {
   ResponseFileSupport ResponseSupport,
   const char *Executable_,
   const llvm::opt::ArgStringLis

[PATCH] D78902: [Driver] Add output file to properties of Command

2020-10-08 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70bf35070a74: [Driver] Add output file to properties of 
Command (authored by sepavloff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78902

Files:
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/Minix.cpp
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -259,4 +259,34 @@
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
 }
+
+TEST(ToolChainTest, CommandOutput) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  "clang LLVM compiler", InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
+  std::unique_ptr CC(
+  CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"}));
+  const JobList &Jobs = CC->getJobs();
+
+  const auto &CmdCompile = Jobs.getJobs().front();
+  const auto &InFile = CmdCompile->getInputFilenames().front();
+  EXPECT_STREQ(InFile, "foo.cpp");
+  auto ObjFile = CmdCompile->getOutputFilenames().front();
+  EXPECT_TRUE(StringRef(ObjFile).endswith(".o"));
+
+  const auto &CmdLink = Jobs.getJobs().back();
+  const auto LinkInFile = CmdLink->getInputFilenames().front();
+  EXPECT_EQ(ObjFile, LinkInFile);
+  auto ExeFile = CmdLink->getOutputFilenames().front();
+  EXPECT_EQ("a.out", ExeFile);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -53,7 +53,7 @@
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
- Exec, CmdArgs, Inputs));
+ Exec, CmdArgs, Inputs, Output));
 }
 
 void tools::XCore::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -82,7 +82,7 @@
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
- Exec, CmdArgs, Inputs));
+ Exec, CmdArgs, Inputs, Output));
 }
 
 /// XCore tool chain
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -114,8 +114,9 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  C.addCommand(std::make_unique(
-  JA, *this, ResponseFileSupport::AtFileCurCP(), Linker, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(JA, *this,
+ ResponseFileSupport::AtFileCurCP(),
+ Linker, CmdArgs, Inputs, Output));
 
   // When optimizing, if wasm-opt is available, run it.
   if (A

[PATCH] D88964: [clangd] Add a missing include-fixer test for incomplete_type, NFC.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:738
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("nested"),
+ "incomplete type 'ns::X' named in nested name specifier"),

kadircet wrote:
> hokein wrote:
> > kadircet wrote:
> > > can you move this back to original position ?
> > yeah, I reordered the list.
> > 
> > there are two orders: the one listed here, and the one listed in 
> > `IncludeFixer.cpp`.
> > 
> > The motivation is to make them aligned, so that it would be easier to 
> > compare and spot the difference. The current state is not friendly to 
> > readers.
> i don't think the orderings in the source vs test is that relevant, but SGTM 
> if it helps you. mainly because:
> - as it might be harder in future to trigger diagnostics in the order we want
> - it is an invariant hard to maintain without at least the reviewer or author 
> of changes knowing about(and remembering) it
yeah, it does help me, especially when I start adding more diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88964

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


[PATCH] D88964: [clangd] Add a missing include-fixer test for incomplete_type, NFC.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4e27220c2a1: [clangd] Add a missing include-fixer test for 
incomplete_type, NFC. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88964

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -708,9 +708,11 @@
 int main() {
   ns::X *x;
   x$access[[->]]f();
+  auto& $type[[[]]a] = *x;
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
+  TU.ExtraArgs.push_back("-std=c++17");
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
@@ -731,7 +733,13 @@
  "member access into incomplete type 'ns::X'"),
 DiagName("incomplete_member_access"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X");
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("type"),
+   "incomplete type 'ns::X' where a complete type is 
required"),
+  DiagName("incomplete_type"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X");
 }
 
 TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -68,10 +68,10 @@
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) const {
   switch (Info.getID()) {
-  case diag::err_incomplete_type:
-  case diag::err_incomplete_member_access:
-  case diag::err_incomplete_base_class:
   case diag::err_incomplete_nested_name_spec:
+  case diag::err_incomplete_base_class:
+  case diag::err_incomplete_member_access:
+  case diag::err_incomplete_type:
 // Incomplete type diagnostics should have a QualType argument for the
 // incomplete type.
 for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -708,9 +708,11 @@
 int main() {
   ns::X *x;
   x$access[[->]]f();
+  auto& $type[[[]]a] = *x;
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
+  TU.ExtraArgs.push_back("-std=c++17");
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
@@ -731,7 +733,13 @@
  "member access into incomplete type 'ns::X'"),
 DiagName("incomplete_member_access"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X");
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("type"),
+   "incomplete type 'ns::X' where a complete type is required"),
+  DiagName("incomplete_type"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X");
 }
 
 TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -68,10 +68,10 @@
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) const {
   switch (Info.getID()) {
-  case diag::err_incomplete_type:
-  case diag::err_incomplete_member_access:
-  case diag::err_incomplete_base_class:
   case diag::err_incomplete_nested_name_spec:
+  case diag::err_incomplete_base_class:
+  case diag::err_incomplete_member_access:
+  case diag::err_incomplete_type:
 // Incomplete type diagnostics should have a QualType argument for the
 // incomplete type.
 for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang-tools-extra] a4e2722 - [clangd] Add a missing include-fixer test for incomplete_type, NFC.

2020-10-08 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-08T13:33:38+02:00
New Revision: a4e27220c2a1046616556b8aadb0ae8f5e0255be

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

LOG: [clangd] Add a missing include-fixer test for incomplete_type, NFC.

Also sort the list to make it easier to verify with the implementation
code.

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeFixer.cpp 
b/clang-tools-extra/clangd/IncludeFixer.cpp
index 7704ccb82c0f..0fd8db0d1167 100644
--- a/clang-tools-extra/clangd/IncludeFixer.cpp
+++ b/clang-tools-extra/clangd/IncludeFixer.cpp
@@ -68,10 +68,10 @@ class VisitedContextCollector : public VisibleDeclConsumer {
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) const {
   switch (Info.getID()) {
-  case diag::err_incomplete_type:
-  case diag::err_incomplete_member_access:
-  case diag::err_incomplete_base_class:
   case diag::err_incomplete_nested_name_spec:
+  case diag::err_incomplete_base_class:
+  case diag::err_incomplete_member_access:
+  case diag::err_incomplete_type:
 // Incomplete type diagnostics should have a QualType argument for the
 // incomplete type.
 for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 8fd1fe385a1c..e80a135c0a99 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -708,9 +708,11 @@ class Y : $base[[public ns::X]] {};
 int main() {
   ns::X *x;
   x$access[[->]]f();
+  auto& $type[[[]]a] = *x;
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
+  TU.ExtraArgs.push_back("-std=c++17");
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
@@ -731,7 +733,13 @@ int main() {
  "member access into incomplete type 'ns::X'"),
 DiagName("incomplete_member_access"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X");
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("type"),
+   "incomplete type 'ns::X' where a complete type is 
required"),
+  DiagName("incomplete_type"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X");
 }
 
 TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {



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


[PATCH] D89035: [clangd] New CC Ranking Model to fix bad inference due to overflow.

2020-10-08 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 296925.
usaxena95 added a comment.

Update model to LambdaMART instead of XE_NDCG.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89035

Files:
  clang-tools-extra/clangd/quality/model/forest.json




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


Re: [cfe-dev] Upcoming upgrade of LLVM buildbot

2020-10-08 Thread Andrzej Warzynski via cfe-commits
Our Flang-aarch64 buildbots just won't connect to the main Buildbot 
master anymore. I switched them to the staging buildbot master instead 
and it seems fine for now. Is there anything that we can/should tweak at 
our end?


http://lab.llvm.org:8014/#/waterfall?tags=flang

-Andrzej

On 08/10/2020 00:31, Galina Kistanova via cfe-dev wrote:

They are online now - http://lab.llvm.org:8011/#/waterfall?tags=sanitizer

AnnotatedCommand has severe design conflict with the new buildbot.
We have changed it to be safe and still do something useful, but it will 
need more love and care.


Please let me know if you have some spare time to work on porting 
AnnotatedCommand.


Thanks

Galina

On Wed, Oct 7, 2020 at 2:57 PM Vitaly Buka > wrote:


It looks like all sanitizer builder are still offline
http://lab.llvm.org:8011/#/builders

On Tue, 6 Oct 2020 at 00:34, Galina Kistanova via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Hello everyone,

The staging buildbot was up and running for 6 days now, and
looks good.

Tomorrow at 12:00 PM PDT we will switch the production buildbot
to the new version.

If you are a bot owner, you do not need to do anything at this
point, unless I'll ask you to help.
The buildbot will go down for a short period of time, and then a
new version will come up and will accept connections from your bots.

Please note that the new version has a bit different URL
structure. You will need to update the bookmarks or scripts if
you have stored direct URLs to inside the buldbot.

We will be watching the production and staging bots and will be
improving zorg for the next week or so.

I will need your feedback about blame e-mails delivery, IRC
reporting issues, and anything you could spot wrong with the new
bot. I  hope the transition will go smoothly and we will handle
issues quickly if any would come up.

After production is good and we have about a week of running
history, I'll ask the bot owners to upgrade buildbots on their
side. Please do not upgrade your buildbots unless I'll ask you
to. We are trying to limit a number of moving parts at this
stage. We will start accepting change to zorg at this point.
Please feel free to talk to me if you will have a special
situation and if you would absolutely have to make changes.

Thanks for your support and help. And please feel free to ask if
you have questions.

Galina


On Thu, Sep 10, 2020 at 9:35 PM Galina Kistanova
mailto:gkistan...@gmail.com>> wrote:

Hello everyone,

The buildbot upgrade is entering the phase when the results
to become visible.

No change is required at this time on any of the builders.
The bot owners could upgrade the buildbot on build computers
later, at their convenience, as this is not on the critical
path.

We are going to upgrade the staging bot first. Then, once
that is stable and all detected issues are resolved, we will
upgrade the production bot.

I will need some help with testing, and will be asking to
move some of the builders temporarily to the staging. LLVM
buildbot is a piece of critical infrastructure, so more eyes
and hands in making sure it works properly the better.

I'll be posting updates and ETA of particular changes in
this thread.

Please feel free to ask if you have any questions or concerns.

Thanks

Galina

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


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


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


[PATCH] D89036: [clangd] Add more incomplete_type diagnostics that could be fixed by include-fixer.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89036

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -707,9 +707,18 @@
 class Y : $base[[public ns::X]] {};
 int main() {
   ns::X *x;
+  ns::X& ref_x;
   x$access[[->]]f();
   auto& $type[[[]]a] = *x;
+
+  ns::X $incomplete[[var]];
+  $tag[[ref_x]]->f();
+  $use[[ns::X()]];
+  $sizeof[[sizeof]](ns::X);
+  for (auto it : $for[[ref_x]]);
 }
+
+ns::X $return[[func]]() {}
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.ExtraArgs.push_back("-std=c++17");
@@ -739,7 +748,37 @@
"incomplete type 'ns::X' where a complete type is 
required"),
   DiagName("incomplete_type"),
   WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-  "Add include \"x.h\" for symbol ns::X");
+  "Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("incomplete"),
+ "variable has incomplete type 'ns::X'"),
+DiagName("typecheck_decl_incomplete_type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("tag"), "incomplete definition of type 'ns::X'"),
+  DiagName("typecheck_incomplete_tag"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("use"), "invalid use of incomplete type 
'ns::X'"),
+  DiagName("invalid_incomplete_type_use"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("sizeof"), "invalid application of 'sizeof' to 
"
+   "an incomplete type 'ns::X'"),
+DiagName("sizeof_alignof_incomplete_or_sizeless_type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("for"),
+ "cannot use incomplete type 'ns::X' as a range"),
+DiagName("for_range_incomplete_type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("return"),
+ "incomplete result type 'ns::X' in function definition"),
+DiagName("func_def_incomplete_result"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X");
 }
 
 TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -72,6 +72,12 @@
   case diag::err_incomplete_base_class:
   case diag::err_incomplete_member_access:
   case diag::err_incomplete_type:
+  case diag::err_typecheck_decl_incomplete_type:
+  case diag::err_typecheck_incomplete_tag:
+  case diag::err_invalid_incomplete_type_use:
+  case diag::err_sizeof_alignof_incomplete_or_sizeless_type:
+  case diag::err_for_range_incomplete_type:
+  case diag::err_func_def_incomplete_result:
 // Incomplete type diagnostics should have a QualType argument for the
 // incomplete type.
 for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -707,9 +707,18 @@
 class Y : $base[[public ns::X]] {};
 int main() {
   ns::X *x;
+  ns::X& ref_x;
   x$access[[->]]f();
   auto& $type[[[]]a] = *x;
+
+  ns::X $incomplete[[var]];
+  $tag[[ref_x]]->f();
+  $use[[ns::X()]];
+  $sizeof[[sizeof]](ns::X);
+  for (auto it : $for[[ref_x]]);
 }
+
+ns::X $return[[func]]() {}
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.ExtraArgs.push_back("-std=c++17");
@@ -739,7 +748,37 @@
"incomplete type 'ns::X' where a c

[PATCH] D87604: [X86] Convert integer _mm_reduce_* intrinsics to emit llvm.reduction intrinsics (PR47506)

2020-10-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 296930.
RKSimon added a comment.
Herald added a subscriber: pengfei.

rebased now that the reduction intrinsics are no longer experiemental


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87604

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fintrin.h
  clang/test/CodeGen/X86/avx512-reduceIntrin.c
  clang/test/CodeGen/X86/avx512-reduceMinMaxIntrin.c

Index: clang/test/CodeGen/X86/avx512-reduceMinMaxIntrin.c
===
--- clang/test/CodeGen/X86/avx512-reduceMinMaxIntrin.c
+++ clang/test/CodeGen/X86/avx512-reduceMinMaxIntrin.c
@@ -4,25 +4,13 @@
 
 long long test_mm512_reduce_max_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_max_epi64(
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:extractelement <8 x i64> %{{.*}}, i32 0
+// CHECK:call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %{{.*}})
   return _mm512_reduce_max_epi64(__W);
 }
 
 unsigned long long test_mm512_reduce_max_epu64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_max_epu64(
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.umax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.umax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.umax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:extractelement <8 x i64> %{{.*}}, i32 0
+// CHECK:call i64 @llvm.vector.reduce.umax.v8i64(<8 x i64> %{{.*}})
   return _mm512_reduce_max_epu64(__W);
 }
 
@@ -42,25 +30,13 @@
 
 long long test_mm512_reduce_min_epi64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_min_epi64(
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smin.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smin.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smin.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:extractelement <8 x i64> %{{.*}}, i32 0
+// CHECK:call i64 @llvm.vector.reduce.smin.v8i64(<8 x i64> %{{.*}})
   return _mm512_reduce_min_epi64(__W);
 }
 
 unsigned long long test_mm512_reduce_min_epu64(__m512i __W){
 // CHECK-LABEL: @test_mm512_reduce_min_epu64(
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.umin.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.umin.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.umin.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:extractelement <8 x i64> %{{.*}}, i32 0
+// CHECK:call i64 @llvm.vector.reduce.umin.v8i64(<8 x i64> %{{.*}})
   return _mm512_reduce_min_epu64(__W);
 }
 
@@ -82,13 +58,7 @@
 // CHECK-LABEL: @test_mm512_mask_reduce_max_epi64(
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:call <8 x i64> @llvm.smax.v8i64(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
-// CHECK:extractelement <8 x i64> %{{.*}}, i32 0
+// CHECK:call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %{{.*}})
   return _mm512_mask_reduce_max_epi64(__M, __W); 
 }
 
@@ -96,13 +66,7 @@
 // CHECK-LABEL: @test_mm512_mask_reduce_max_epu64(
 // CHECK:bitcast i8 %{{.*}} to <8 x i1>
 // CHECK:select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
-// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> 
-// CHECK:ca

[PATCH] D88833: [clang-tidy] Do not warn on pointer decays in system macros

2020-10-08 Thread fiesh via Phabricator via cfe-commits
fiesh added a comment.

@aaron.ballman valid point.  It would seem natural to diagnose both since the 
user is voluntarily causing the decay?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88833

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


[clang] 6668e4c - [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

2020-10-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2020-10-08T08:20:38-04:00
New Revision: 6668e4cc685e74a17ebd386913e842ac3d7472e5

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

LOG: [OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target 
Offload

Summary:
This patch adds an error to Clang that detects if OpenMP offloading is used
between two architectures with incompatible pointer sizes. This ensures that
the data mapping can be done correctly and solves an issue in code generation
generating the wrong size pointer.

Reviewer: jdoerfert

Subscribers: cfe-commits delcypher guansong llvm-commits sstefan1 yaxunl

Tags: #OpenMP #Clang

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

Added: 
clang/test/OpenMP/target_incompatible_architecture_messages.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3bf1bb19b7ae..29bc19e5a84e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -253,6 +253,7 @@ def err_drv_optimization_remark_format : Error<
   "unknown remark serializer format: '%0'">;
 def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, 
please use [no]simd instead">;
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
+def err_drv_incompatible_omp_arch : Error<"OpenMP target architecture '%0' 
pointer size is incompatible with host '%1'">;
 def err_drv_omp_host_ir_file_not_found : Error<
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index b402f53cc765..a1ad86e7a851 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3191,6 +3191,15 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 
   // Get the OpenMP target triples if any.
   if (Arg *A = Args.getLastArg(options::OPT_fopenmp_targets_EQ)) {
+enum ArchPtrSize { Arch16Bit, Arch32Bit, Arch64Bit };
+auto getArchPtrSize = [](const llvm::Triple &T) {
+  if (T.isArch16Bit())
+return Arch16Bit;
+  if (T.isArch32Bit())
+return Arch32Bit;
+  assert(T.isArch64Bit() && "Expected 64-bit architecture");
+  return Arch64Bit;
+};
 
 for (unsigned i = 0; i < A->getNumValues(); ++i) {
   llvm::Triple TT(A->getValue(i));
@@ -3206,6 +3215,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 TT.getArch() == llvm::Triple::x86 ||
 TT.getArch() == llvm::Triple::x86_64))
 Diags.Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
+  else if (getArchPtrSize(T) != getArchPtrSize(TT))
+Diags.Report(diag::err_drv_incompatible_omp_arch)
+<< A->getValue(i) << T.str();
   else
 Opts.OMPTargetTriples.push_back(TT);
 }

diff  --git a/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp 
b/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
index c62832a2705f..cb36973c8dab 100644
--- a/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
@@ -1,19 +1,37 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x

[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88949

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


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Geoff Levner via Phabricator via cfe-commits
glevner added a comment.

Great. I don't have commit access though. If I did, I would love to commit it 
to the release branch, which is what we use...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88949

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


[PATCH] D88363: [CodeGen] Improve likelihood attribute branch weights

2020-10-08 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

In D88363#2317241 , @Mordante wrote:

> Can you explain the kind of issues you're having?

At the shallowest level, our -O1 produces different IR and fails the test, 
which is more or less our problem; however my understanding is that tests in 
the LLVM project / subprojects should aim to test as little amount of code as 
code possible. Relying on all of -O1 makes it a brittle test -- changes to any 
optimisation pass enabled in -O1 could cause this test to fail spuriously.

Instead, I believe the test should be in two parts:

- One checking clang produces the correct /unoptimised/ IR output
- One or more checking that the consuming IR passes do-the-right-thing

An example is (some of) the TBAA tests -- as you suggest, they're using `-O1 
-disable-llvm-passes` to check that clang produces stores with !tbaa metadata 
attached. Then over in the LLVM optimisation passes there are tests checking 
that GVN / LICM etc correctly consume TBAA metadata. Note that I'm unfamiliar 
with how branch weights work, but I believe the principle is the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88363

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


[PATCH] D88414: [clangd] Introduce memory dumping to FileIndex, FileSymbols and BackgroundIndex

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D88414#2317106 , @sammccall wrote:

> Now there's lots of usage (which looks good!) i'm finding it a bit hard to 
> keep track of what the tree will look like overall.
>
> At some point it'd be great to:
>  a) bind this to an LSP extension so we can see it in editors

i was also thinking about it and couldn't decide between a "custom command" vs 
"code action".

- the former gives a richer interaction, but requires every editor plugin to 
implement support.
- the latter is a little bit more restrictive but doesn't require a bunch of 
extra work.

I am happy to go with the "code action" approach initially. WDYT? (not in the 
scope of this patch)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88414

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


[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2338
+  Exprs = Exprs.drop_front();
+  if (Exprs.size() == 0)
+return llvm::ConstantPointerNull::get(Int8PtrTy);

`Exprs.empty()` would be more concise.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2354-2356
+auto *Constant = ConstEmiter.emitAbstract(
+CE->getBeginLoc(), CE->getAPValueResult(), CE->getType());
+return Constant;

You can return the expression directly, which removes a somewhat questionable 
use of `auto`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3683
+  auto *Attr =
+  AnnotateAttr::Create(Context, Str, Args.empty() ? nullptr : Args.data(),
+   Args.size(), CI.getRange(), CI.getSyntax());

Just curious, but is the `?:` actually necessary? I would have assumed that an 
empty `ArrayRef` would return `nullptr` from `data()`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3688
+Expr *&E = Attr->args_begin()[Idx];
+ConstantExpr *CE = dyn_cast(E);
+if (!E) {

`auto *` since the type is spelled out in the initialization.

Also, I think this is unsafe -- it looks like during template instantiation, 
any arguments that have a substitution failure will come through as `nullptr`, 
and this will crash.

What should happen on template instantiation failure for these arguments? I 
think the whole attribute should probably be dropped with appropriate 
diagnostics rather than emitting a partial attribute, but perhaps you have 
different ideas.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3691
+  Diag(CI.getLoc(), diag::err_attribute_argument_n_type)
+  << "'annotate'" << Idx << AANT_ArgumentConstantExpr;
+  return;

This is unfortunate -- you should be passing in the `ParsedAttr` object so that 
the diagnostic engine can take care of properly formatting the diagnostic. For 
instance, this will incorrectly name the attribute `'annotate'` instead of 
`clang::annotate'` if that's how the user spelled the attribute. I don't recall 
whether it will work on an `AttributeCommonInfo` though.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3694
+}
+if (E->getDependence() || (CE && CE->hasAPValueResult()))
+  continue;

`E->getDependence()` smells a bit fishy because this will early bail on any 
kind of dependency, including an error dependency. Do you mean to care only 
about type and/or value dependence here?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3704-3705
+  Result = E->EvaluateAsRValue(Eval, Context, true);
+else
+  Result = E->EvaluateAsLValue(Eval, Context, true);
+

Under what circumstances would we want the constant expressions to be lvalues? 
I would have guessed you would want to call `Expr::EvaluateAsConstantExpr()` 
instead of either of these.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3730
+  for (unsigned Idx = 0; Idx < AL.getNumArgs(); Idx++) {
+if (AL.isArgIdent(Idx))
+  Args.push_back(nullptr);

Hmm, I think you should assert that you never get an identifier at this point 
-- the parser should be treating all of these as expressions and not simple 
identifiers.



Comment at: clang/test/SemaCXX/attr-annotate.cpp:1
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -verify %s
+

Do you mean to emit llvm here? I think that should probably be `-fsyntax-only`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

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


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-10-08 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added inline comments.



Comment at: clang/test/CodeGen/volatile.c:1
-// RUN: %clang_cc1 -triple=%itanium_abi_triple -emit-llvm < %s | FileCheck %s 
-check-prefix CHECK -check-prefix CHECK-IT
+// RUN: %clang_cc1 -triple=%itanium_abi_triple -emit-llvm < %s | FileCheck %s 
-check-prefix CHECK -check-prefixes %volatile_prefix
 // RUN: %clang_cc1 -triple=%ms_abi_triple -emit-llvm < %s | FileCheck %s 
-check-prefix CHECK -check-prefix CHECK-MS

I think it would be better to change this test to use explicit triples, so that 
we're always testing both the ARM and non-ARM behaviour, regardless of the 
default triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932

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


[PATCH] D88363: [CodeGen] Improve likelihood attribute branch weights

2020-10-08 Thread Bruno De Fraine via Phabricator via cfe-commits
bdf added a comment.

In D88363#2319157 , @jmorse wrote:

> In D88363#2317241 , @Mordante wrote:
>
>> Can you explain the kind of issues you're having?
>
> At the shallowest level, our -O1 produces different IR and fails the test, 
> which is more or less our problem; however my understanding is that tests in 
> the LLVM project / subprojects should aim to test as little amount of code as 
> possible. Relying on all of -O1 makes it a brittle test -- changes to any 
> optimisation pass enabled in -O1 could cause this test to fail spuriously.
>
> Instead, I believe the test should be in two parts:
>
> - One checking clang produces the correct /unoptimised/ IR output
> - One or more checking that the consuming IR passes do-the-right-thing

As I see, the intent of the test is not so much to verify a certain expected 
output, but more to verify that two styles of likelihood hints in C code 
produce the same code structure and branch weights. Theses styles are 
likely/unlikely-annotations, and use of __builtin_expect in the if condition. 
But the processing of these two is quite different:

- for likely/unlikely annotations, branch weights are added immediately in the 
initial CodeGen
- __builtin_expect is first translated straightforward to an expect intrinsic, 
then processed by a later lower-expect pass

To make the test less brittle, would it be possible to explicitly select only 
the optimization passes that are needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88363

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


[clang-tools-extra] a0a6fd4 - [clangd] New CC Ranking Model to fix bad inference due to overflow.

2020-10-08 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2020-10-08T15:30:00+02:00
New Revision: a0a6fd435c6066d40d9c20835f1e52aad1e8cc65

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

LOG: [clangd] New CC Ranking Model to fix bad inference due to overflow.

Unreachable file distances are represented as
`std::numeric_limits::max()`.
The previous dataset recorded the signals as `signed int` capturing this default
value as `-1`.

A new dataset was regenerated and a new model is trained that
interprets this unreachable as the intended value.

Distribution of `SymbolScopeDistance`:
Value Normalised Frequency
0 46.6184
429496729529.5342
6 14.5666
4  6.4433
2  1.4534
8  0.5760
10 0.3581


Distribution of `FileProximityDistance`:
Value Normalised Frequency
429496729539.9378
12 5.1997
14 4.9828
15 4.4221
16 4.3820
13 4.2765
17 3.8957
11 3.6387
19 3.4799
18 3.4076


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

Added: 


Modified: 
clang-tools-extra/clangd/quality/model/forest.json

Removed: 



error:
 too big or took too long to generate


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


[PATCH] D89035: [clangd] New CC Ranking Model to fix bad inference due to overflow.

2020-10-08 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0a6fd435c60: [clangd] New CC Ranking Model to fix bad 
inference due to overflow. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89035

Files:
  clang-tools-extra/clangd/quality/model/forest.json

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


[PATCH] D87451: add new option -mignore-xcoff-visibility

2020-10-08 Thread Digger via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
DiggerLin marked an inline comment as done.
Closed by commit rG92bca1284308: [AIX] add new option -mignore-xcoff-visibility 
(authored by DiggerLin).

Changed prior to commit:
  https://reviews.llvm.org/D87451?vs=296267&id=296953#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/Driver/ignore-xcoff-visibility.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll

Index: llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll
@@ -0,0 +1,48 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec  < %s | \
+; RUN:   FileCheck --check-prefix=VISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -ignore-xcoff-visibility < %s | \
+; RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefix=VISIBILITY-ASM %s
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -ignore-xcoff-visibility < %s | \
+; RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+
+@foo_p = global void ()* @zoo_extern_h, align 4
+@b = protected global i32 0, align 4
+
+define hidden void @foo_h(i32* %p) {
+entry:
+  %p.addr = alloca i32*, align 4
+  store i32* %p, i32** %p.addr, align 4
+  %0 = load i32*, i32** %p.addr, align 4
+  %1 = load i32, i32* %0, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* %0, align 4
+  ret void
+}
+
+declare hidden void @zoo_extern_h()
+
+define protected void @bar() {
+entry:
+  call void @foo_h(i32* @b)
+  %0 = load void ()*, void ()** @foo_p, align 4
+  call void %0()
+  ret void
+}
+
+; VISIBILITY-ASM: .globl  foo_h[DS],hidden
+; VISIBILITY-ASM: .globl  .foo_h,hidden
+; VISIBILITY-ASM: .globl  bar[DS],protected
+; VISIBILITY-ASM: .globl  .bar,protected
+; VISIBILITY-ASM: .globl  b,protected
+
+; IGNOREVISIBILITY-ASM: .globl  foo_h[DS]
+; IGNOREVISIBILITY-ASM: .globl  .foo_h
+; IGNOREVISIBILITY-ASM: .globl  bar[DS]
+; IGNOREVISIBILITY-ASM: .globl  .bar
+; IGNOREVISIBILITY-ASM: .globl  b
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1702,17 +1702,19 @@
   assert(LinkageAttr != MCSA_Invalid && "LinkageAttr should not MCSA_Invalid.");
 
   MCSymbolAttr VisibilityAttr = MCSA_Invalid;
-  switch (GV->getVisibility()) {
+  if (!TM.getIgnoreXCOFFVisibility()) {
+switch (GV->getVisibility()) {
 
-  // TODO: "exported" and "internal" Visibility needs to go here.
-  case GlobalValue::DefaultVisibility:
-break;
-  case GlobalValue::HiddenVisibility:
-VisibilityAttr = MAI->getHiddenVisibilityAttr();
-break;
-  case GlobalValue::ProtectedVisibility:
-VisibilityAttr = MAI->getProtectedVisibilityAttr();
-break;
+// TODO: "exported" and "internal" Visibility needs to go here.
+case GlobalValue::DefaultVisibility:
+  break;
+case GlobalValue::HiddenVisibility:
+  VisibilityAttr = MAI->getHiddenVisibilityAttr();
+  break;
+case GlobalValue::ProtectedVisibility:
+  VisibilityAttr = MAI->getProtectedVisibilityAttr();
+  break;
+}
   }
 
   OutStreamer->emitXCOFFSymbolLinkageWithVisibility(GVSym, LinkageAttr,
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -74,6 +74,7 @@
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
+CGOPT(bool, IgnoreXCOFFVisibility)
 CGOPT(std::string, BBSections)
 CGOPT(unsigned, TLSSize)
 CGOPT(bool, EmulatedTLS)
@@ -333,6 +334,13 @@
   cl::init(false));
   CGBINDOPT(FunctionSections);
 
+  static cl::opt IgnoreXCOFFVisibility(
+  "ignore-xcoff-visibility",
+  cl::desc("Not emit the visibility attribute for asm in AIX OS or give "
+   "all symb

[clang] 92bca12 - [AIX] add new option -mignore-xcoff-visibility

2020-10-08 Thread via cfe-commits

Author: diggerlin
Date: 2020-10-08T09:34:58-04:00
New Revision: 92bca1284308452b8eb549e9382873645320cf19

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

LOG: [AIX] add new option -mignore-xcoff-visibility

SUMMARY:

In IBM compiler xlclang , there is an option -fnovisibility which suppresses 
visibility. For more details see: 
https://www.ibm.com/support/knowledgecenter/SSGH3R_16.1.0/com.ibm.xlcpp161.aix.doc/compiler_ref/opt_visibility.html.

We need to add the option -mignore-xcoff-visibility for compatibility with the 
IBM AIX OS (as the option is enabled by default in AIX). With this option llvm 
does not emit any visibility attribute to ASM or XCOFF object file.

The option only work on the AIX OS, for other non-AIX OS using the option will 
report an unsupported options error.

In AIX OS:

1.1  the option -mignore-xcoff-visibility is enabled by default , if there is 
not -fvisibility=* and -mignore-xcoff-visibility explicitly in the clang 
command .

1.2 if there is -fvisibility=* explicitly but not -mignore-xcoff-visibility  
explicitly in the clang command.  it will generate visibility attributes.

1.3 if there are  both  -fvisibility=* and  -mignore-xcoff-visibility  
explicitly in the clang command. The option  "-mignore-xcoff-visibility" wins , 
it do not emit the visibility attribute.

The option -mignore-xcoff-visibility has no effect on visibility attribute when 
compile with -emit-llvm option to generated LLVM IR.

Reviewer: daltenty,Jason Liu

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

Added: 
clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
clang/test/Driver/ignore-xcoff-visibility.cpp
llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 370f13d6c955..135495668e2d 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2617,6 +2617,10 @@ Align doubles to two words in structs (x86 only)
 
 Link stack frames through backchain on System Z
 
+.. option:: -mignore-xcoff-visibility
+
+Do not emit any visibility attribute for asm on AIX or give all symbols 
'unspecified' visibility in XCOFF object file (XCOFF only)
+
 .. option:: -mbranches-within-32B-boundaries
 
 Align selected branches (fused, jcc, jmp) within 32-byte boundary

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 062a8c3fe64a..4054f93cf4a4 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -37,6 +37,7 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit 
__attribute__((malloc)) o
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
 CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
+CODEGENOPT(IgnoreXCOFFVisibility , 1, 0) ///< -mignore-xcoff-visibility
 CODEGENOPT(ControlFlowGuardNoChecks  , 1, 0) ///< -cfguard-no-checks
 CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
 CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling 
destructors.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 87e7db27a827..9170a33b3155 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2566,6 +2566,9 @@ defm zvector : OptInFFlag<"zvector", "Enable System z 
vector language extension"
 def mzvector : Flag<["-"], "mzvector">, Alias;
 def mno_zvector : Flag<["-"], "mno-zvector">, Alias;
 
+def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, 
Group,
+HelpText<"Not emit the visibility attribute for asm in AIX OS or give all 
symbols 'unspecified' visibility in XCOFF object file">,
+  Flags<[CC1Option]>;
 def mbackchain : Flag<["-"], "mbackchain">, Group, 
Flags<[DriverOption,CC1Option]>,
   HelpText<"Link stack frames through backchain on System Z">;
 def mno_backchain : Flag<["-"], "mno-backchain">, Group, 
Flags<[DriverOption,CC1Option]>;

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index dbd67a6ebe9b..1b90a4c1a99e 100644
--- a/clang/lib/CodeGen/BackendU

[PATCH] D88275: [ASTMatchers] Add matcher `hasParentIgnoringImplicit`.

2020-10-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

TL;DR Stephen's fix works; I'll drop this patch.

> Why do you use `TK_IgnoreImplicitCastsAndParentheses` instead of 
> `TK_IgnoreUnlessSpelledInSource`? All you seem to be doing is showing that 
> the former is broken. I've always thought we should remove the former. `AsIs` 
> and `IgnoreUnlessSpelledInSource` should be enough for anyone.
>
>> @steveire, would you consider this [when using 
>> `TK_IgnoreImplicitCastsAndParentheses`] to be a bug in the traversal 
>> behavior?
>
> It's probably a bug in how `TK_IgnoreImplicitCastsAndParentheses` is 
> processed?

Changing to `TK_IgnoreUnlessSpelledInSource` fixes the test, as you suggested. 
Thanks!

As for why I chose the former -- it was the closest match to what I was doing 
and the comments on the struct didn't guide me one way or another.

>> I have strong reservations about modal matching, especially given that it 
>> had severe issues
>
> I think "severe" is an overstatement.

I think it was an unhelpful word choice -- sorry about that.  I could go into 
more detail as to why I chose that, but without detail it's not a helpful 
description. Suffice it to say that we had multiple instances of suprising 
behaviour, which lost quite a few hours.

>> I'm only worried we're making AST matching more confusing by having two 
>> different ways of inconsistently accomplishing the same-ish thing.
>
> The `traverse` matcher and `IgnoreUnlessSpelledInSource` were introduced so 
> that matchers like `hasParentIgnoringImplicit` (and all the other 
> `hasParentIgnoring*`) would never be needed (and so that the already-existing 
> `ignore*` matchers would be needed only rarely). I agree with Aaron that it's 
> not a good design to continue.
>
> I think the existence of this new `hasParentIgnoringImplicit` matcher is 
> further motivation that `IgnoreUnlessSpelledInSource` should be used more, 
> especially when writing new matcher code. It is simpler. I get the impression 
> people haven't tried it and prefer to write the complicated stuff instead.
>
> I still don't see a problem with `traverse` being modal, but that fact seems 
> to make you not use it, @ymandel ?

This is a longer discussion and not necessarily worth having on this review 
thread. Are you attending the dev meeting today? If so, want to chat during the 
coffee break? Otherwise, it seems like it could be helpful to schedule a 
meeting to discuss for some other time.

That said, I'm more inclined towards its use as a specialty operator, for 
situations like this, than as a general purpose tool for matchers. I can't say 
I much like the current regime of explicit `ignore` operators either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88275

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


[PATCH] D88417: [clangd] Record memory usages after each notification

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 296955.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88417

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -17,6 +17,7 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "URI.h"
+#include "support/MemoryTree.h"
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
@@ -27,6 +28,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
@@ -48,6 +50,7 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::Gt;
@@ -1236,6 +1239,21 @@
   EXPECT_FALSE(DiagConsumer.HadDiagsInLastCallback);
 }
 
+TEST(ClangdServer, MemoryUsageTest) {
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  Server.addDocument(FooCpp, "");
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  llvm::BumpPtrAllocator Alloc;
+  MemoryTree MT(&Alloc);
+  Server.profile(MT);
+  ASSERT_TRUE(MT.children().count("tuscheduler"));
+  EXPECT_TRUE(MT.child("tuscheduler").children().count(FooCpp));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -164,6 +164,17 @@
   stop();
   EXPECT_THAT(Tracer.takeMetric("lsp_latency", MethodName), testing::SizeIs(1));
 }
+
+TEST_F(LSPTest, RecordsMemoryUsage) {
+  trace::TestTracer Tracer;
+  auto &Client = start();
+  EXPECT_THAT(Tracer.takeMetric("memory_usage", "clangd_server"),
+  testing::SizeIs(0));
+  Client.notify("", {});
+  stop();
+  EXPECT_THAT(Tracer.takeMetric("memory_usage", "clangd_server"),
+  testing::SizeIs(1));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -25,6 +25,7 @@
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
 #include "support/Function.h"
+#include "support/MemoryTree.h"
 #include "support/ThreadsafeFS.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
@@ -340,6 +341,9 @@
   LLVM_NODISCARD bool
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
+  /// Builds a nested representation of memory used by components.
+  void profile(MemoryTree &MT) const;
+
 private:
   void formatCode(PathRef File, llvm::StringRef Code,
   ArrayRef Ranges,
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -28,6 +28,7 @@
 #include "refactor/Tweak.h"
 #include "support/Logger.h"
 #include "support/Markup.h"
+#include "support/MemoryTree.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "clang/Format/Format.h"
@@ -824,5 +825,12 @@
   BackgroundIdx->blockUntilIdleForTest(TimeoutSeconds));
 }
 
+void ClangdServer::profile(MemoryTree &MT) const {
+  if (DynamicIdx)
+DynamicIdx->profile(MT.child("dynamic_index"));
+  if (BackgroundIdx)
+BackgroundIdx->profile(MT.child("background_index"));
+  WorkScheduler.profile(MT.child("tuscheduler"));
+}
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "ClangdLSPServer.h"
+#include "ClangdServer.h"
 #include "CodeComplete.h"
 #include "Diagnostics.h"
 #include "DraftStore.h"
@@ -26,6 +27,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"

[PATCH] D88417: [clangd] Record memory usages after each notification

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet requested review of this revision.
kadircet added a comment.

Bad news, I was testing this with remote-index, hence background-index was 
turned off. Unfortunately traversing all of the slabs in `FileSymbols` takes 
quite a while in this case (~15ms for LLVM).

I don't think it is feasible to do this on every notification now, as this 
implies an extra 15ms latency for interactive requests like code 
completion/signature help due to the delay between didChange notification and 
codeCompletion request.

> We should watch the timing here carefully and consider guarding it - apart 
> from the minimum time interval we discussed, we could have a check whether 
> metric tracing is actually enabled in a meaningful way.

I've also added early exit for non-tracing case. But I think we should still 
change this to be periodic or once every N calls. WDYT?




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:182
+Server.Server->profile(MT);
+trace::recordMemoryUsage(MT, "clangd_server");
 return true;

sammccall wrote:
> (Sorry, I suspect we discussed this and I forgot)
> Is there a reason at this point to put knowledge of the core metric in 
> trace:: rather than define it here locally in ClangdLSPServer?
> (Sorry, I suspect we discussed this and I forgot)

Not really.

> Is there a reason at this point to put knowledge of the core metric in 
> trace:: rather than define it here locally in ClangdLSPServer?

`ClangdLSPServer` didnt feel like the appropriate place for that logic. 
Moreover other embedders of ClangdServer could benefit from traversal logic if 
it is defined in a lower level than ClangdLSPServer.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:168
   elog("Notification {0} before initialization", Method);
-else if (Method == "$/cancelRequest")
+  return true;
+}

sammccall wrote:
> this change is a bit puzzling - makes it look like there are some cases where 
> we specifically want/don't want to record. why?
it was to ensure we have a `ClangdServer` instance we can query for memory 
usage.

will revert as moving profiling into `happy case` makes it obselete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88417

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


[PATCH] D89036: [clangd] Add more incomplete_type diagnostics that could be fixed by include-fixer.

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Tests seem to be failing on premerge bots:

- https://reviews.llvm.org/harbormaster/unit/view/177841/
- https://reviews.llvm.org/harbormaster/unit/view/177842/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89036

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


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

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D69560#2292505 , @whisperity wrote:

> I'd like to resurrect the discussion about this. Unfortunately, the concept 
> of `experimental-` group (in D76545 ) has 
> fallen silent, too. We will present the results of this analysis soon at IEEE 
> SCAM (Source Code Analysis and Manipulation) 2020 
> . While a previous submission about this topic was 
> rejected on the grounds of not being in line with the conference's usual, 
> hyper-formalised nature, with one reviewer //especially// praising the paper 
> for its nice touch with the empirical world and the fact that neither 
> argument swaps (another checker worked on by a colleague) nor the 
> interactions of this issue with the type system (this checker) was really 
> investigated in the literature for C++ before, we've tailored both the paper 
> and the implementation based on reviewer comments from the scientific world, 
> and the comments here.
> The reviews were mostly favourable, excl. comments about the lack of 
> formalisation and the unfortunate lack of modelling for template 
> instantiations. Such a cold cut, however, //only// introduces false negatives 
> into the result set. Which is fine, as the users will never see those 
> non-existent reports!

Congrats on the SCAM acceptance, I hope the presentation goes well!

> In D69560#1936574 , @aaron.ballman 
> wrote:
>
>> This is a check that is almost impossible to comply with when developing new 
>> code because it is insufficiently clear on what constitutes "related" 
>> parameters.
>
> I agree the CppCG is rather vague about this. From an angle, it seems 
> intentional... "relatedness" is hard to pin down formally, it might vary from 
> one "module" to the next even in the same project. In a subsequent patch to 
> this, I've given a few good examples as to what can be reasonably culled by 
> relatedness heuristics. They filter a good chunk of the results, letting go 
> of most of the trivially "valid (but maybe nonsense) if swapped" functions 
> (min, max, find, etc.)

I agree that the vagueness seems intentional. That's usually reasonable when 
you want coding guidelines for a human to check, but doesn't help for 
production-quality automated checking. Do you happen to know how many false 
positives the check currently issues without that heuristic?

> In D69560#1936574 , @aaron.ballman 
> wrote:
>
>> Two adjacent types in a function parameter list is an incredibly common 
>> situation that arises naturally when writing code [...] and designing around 
>> that from scratch is not always possible.
>
> I see the reasoning behind this. However, this feels more like a motivation 
> //against// the rule itself, and not the checker.

Correct, it's definitely a motivation against the rule itself.

> We can debate the justification for the rule's existence, but (and correct me 
> if I'm wrong) so far I have not seen any tool (that's publicly available, and 
> is for C(++), etc...) that attempts to check your code satisfying this 
> particular rule.

I'm not aware of any either. However, an indictment of the rule being too 
ambiguous is also an indictment of any checkers implementing that rule because 
they're going to have a higher failure rate than if the rule was not ambiguous.

> In D69560#1936574 , @aaron.ballman 
> wrote:
>
>> (especially for constructors, where your parameter order has to match the 
>> declaration order within the class)
>
> CMIIW, but I believe this statement is not true. Aggregate initialisation 
> does not care about your constructors, and yes, takes arguments in the order 
> of fields. However, once you have a user-defined constructor, you should be 
> able to define your parameters in any order you like. The only thing you 
> //should// match is that the //member-init-exprs// of the constructor are 
> evaluated in order of field declarations, not in the order you wrote them.

My point is that it's far more common to match all three orders even though you 
don't have to. e.g.,

  // Common, correct
  class C {
int a, b;
float c;
  
  public:
C(int a_, int b_, float c_) : a(a_), b(b_), c(c_) {}
  };
  
  // Usually held as a code smell, but correct and not commonly diagnosed
  class C {
int a, b;
float c;
  
  public:
C(int a_, float c_, int b_) : a(a_), b(b_), c(c_) {}
  };
  
  // Incorrect, commonly diagnosed
  class C {
int a, b;
float c;
  
  public:
C(int a_, float c_, int b_) : a(a_), c(c_), b(b_) {}
  };



> But trespassing that rule already emits a compiler warning, and in reality, 
> the trespass only causes an issue if there is a data dependency between your 
> fields. You //should// ensure your //member-init-exprs// are in the right 
> order (to guard that a later change intr

[PATCH] D89036: [clangd] Add more incomplete_type diagnostics that could be fixed by include-fixer.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 296961.
hokein added a comment.

Fix the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89036

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -705,11 +705,18 @@
   $nested[[X::]]Nested n;
 }
 class Y : $base[[public ns::X]] {};
-int main() {
-  ns::X *x;
+void test(ns::X *x, ns::X& ref_x) {
   x$access[[->]]f();
   auto& $type[[[]]a] = *x;
+
+  ns::X $incomplete[[var]];
+  $tag[[ref_x]]->f();
+  $use[[ns::X()]];
+  $sizeof[[sizeof]](ns::X);
+  for (auto it : $for[[ref_x]]);
 }
+
+ns::X $return[[func]]() {}
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.ExtraArgs.push_back("-std=c++17");
@@ -739,7 +746,37 @@
"incomplete type 'ns::X' where a complete type is 
required"),
   DiagName("incomplete_type"),
   WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-  "Add include \"x.h\" for symbol ns::X");
+  "Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("incomplete"),
+ "variable has incomplete type 'ns::X'"),
+DiagName("typecheck_decl_incomplete_type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("tag"), "incomplete definition of type 'ns::X'"),
+  DiagName("typecheck_incomplete_tag"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X"))),
+  AllOf(
+  Diag(Test.range("use"), "invalid use of incomplete type 
'ns::X'"),
+  DiagName("invalid_incomplete_type_use"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("sizeof"), "invalid application of 'sizeof' to 
"
+   "an incomplete type 'ns::X'"),
+DiagName("sizeof_alignof_incomplete_or_sizeless_type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("for"),
+ "cannot use incomplete type 'ns::X' as a range"),
+DiagName("for_range_incomplete_type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("return"),
+ "incomplete result type 'ns::X' in function definition"),
+DiagName("func_def_incomplete_result"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X");
 }
 
 TEST(IncludeFixerTest, NoSuggestIncludeWhenNoDefinitionInHeader) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -72,6 +72,12 @@
   case diag::err_incomplete_base_class:
   case diag::err_incomplete_member_access:
   case diag::err_incomplete_type:
+  case diag::err_typecheck_decl_incomplete_type:
+  case diag::err_typecheck_incomplete_tag:
+  case diag::err_invalid_incomplete_type_use:
+  case diag::err_sizeof_alignof_incomplete_or_sizeless_type:
+  case diag::err_for_range_incomplete_type:
+  case diag::err_func_def_incomplete_result:
 // Incomplete type diagnostics should have a QualType argument for the
 // incomplete type.
 for (unsigned Idx = 0; Idx < Info.getNumArgs(); ++Idx) {


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -705,11 +705,18 @@
   $nested[[X::]]Nested n;
 }
 class Y : $base[[public ns::X]] {};
-int main() {
-  ns::X *x;
+void test(ns::X *x, ns::X& ref_x) {
   x$access[[->]]f();
   auto& $type[[[]]a] = *x;
+
+  ns::X $incomplete[[var]];
+  $tag[[ref_x]]->f();
+  $use[[ns::X()]];
+  $sizeof[[sizeof]](ns::X);
+  for (auto it : $for[[ref_x]]);
 }
+
+ns::X $return[[func]]() {}
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.ExtraArgs.push_back("-std=c++17");
@@ -739,7 +746,37 @@
"incomplete type

[PATCH] D89036: [clangd] Add more incomplete_type diagnostics that could be fixed by include-fixer.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D89036#2319320 , @kadircet wrote:

> Tests seem to be failing on premerge bots:
>
> - https://reviews.llvm.org/harbormaster/unit/view/177841/
> - https://reviews.llvm.org/harbormaster/unit/view/177842/

opps, sorry -- I made a few minor changes without rerunning the test, it should 
be fixed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89036

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


[PATCH] D89045: [AST][RecoveryExpr] Don't perform early typo correction in C.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
hokein requested review of this revision.

The dependent mechanism for C error-recovery is mostly finished,
this is the only place we have missed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89045

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@
 int unary_address = &(a + 1);
 
 // CHECK:   VarDecl {{.*}} ternary 'int' cinit
-// CHECK-NEXT:  `-RecoveryExpr {{.*}}
+// CHECK-NEXT:  `-ConditionalOperator {{.*}}
 // CHECK-NEXT:|-DeclRefExpr {{.*}} 'a'
-// CHECK-NEXT:|-TypoExpr {{.*}}
+// CHECK-NEXT:|-RecoveryExpr {{.*}}
 // CHECK-NEXT:`-DeclRefExpr {{.*}} 'a'
-// FIXME: The TypoExpr should never be print, and should be downgraded to
-// RecoveryExpr -- typo correction is performed too early in C-only codepath,
-// which makes no correction when clang finishes the full expr 
(Sema::Sema::ActOnFinishFullExpr).
-// this will be fixed when we support dependent mechanism and delayed typo 
correction for C.
 int ternary = a ? undef : a;
 
 void test1() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8558,7 +8558,7 @@
 SourceLocation ColonLoc,
 Expr *CondExpr, Expr *LHSExpr,
 Expr *RHSExpr) {
-  if (!getLangOpts().CPlusPlus) {
+  if (!Context.isDependenceAllowed()) {
 // C cannot handle TypoExpr nodes in the condition because it
 // doesn't handle dependent types properly, so make sure any TypoExprs have
 // been dealt with before checking the operands.


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@
 int unary_address = &(a + 1);
 
 // CHECK:   VarDecl {{.*}} ternary 'int' cinit
-// CHECK-NEXT:  `-RecoveryExpr {{.*}}
+// CHECK-NEXT:  `-ConditionalOperator {{.*}}
 // CHECK-NEXT:|-DeclRefExpr {{.*}} 'a'
-// CHECK-NEXT:|-TypoExpr {{.*}}
+// CHECK-NEXT:|-RecoveryExpr {{.*}}
 // CHECK-NEXT:`-DeclRefExpr {{.*}} 'a'
-// FIXME: The TypoExpr should never be print, and should be downgraded to
-// RecoveryExpr -- typo correction is performed too early in C-only codepath,
-// which makes no correction when clang finishes the full expr (Sema::Sema::ActOnFinishFullExpr).
-// this will be fixed when we support dependent mechanism and delayed typo correction for C.
 int ternary = a ? undef : a;
 
 void test1() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8558,7 +8558,7 @@
 SourceLocation ColonLoc,
 Expr *CondExpr, Expr *LHSExpr,
 Expr *RHSExpr) {
-  if (!getLangOpts().CPlusPlus) {
+  if (!Context.isDependenceAllowed()) {
 // C cannot handle TypoExpr nodes in the condition because it
 // doesn't handle dependent types properly, so make sure any TypoExprs have
 // been dealt with before checking the operands.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89046: [AST] Build recovery expression by default for all language.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, arphaman, kbarton, nemanjai.
Herald added a project: clang.
hokein requested review of this revision.

Not intent to land it now, we need to run internal experiments to make
sure this is not crashy.

It is ready for review, all changes are diagnostic adjustments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89046

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/builtins-ppc-error.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/Index/complete-switch.c
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/Parser/objc-foreach-syntax.m
  clang/test/Sema/__try.c
  clang/test/Sema/enum.c
  clang/test/Sema/typo-correction.c

Index: clang/test/Sema/typo-correction.c
===
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -14,9 +14,9 @@
   // expected-error {{use of undeclared identifier 'b'}}
 
 int foobar;  // expected-note {{'foobar' declared here}}
-a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
-  // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
-  // expected-error {{initializer element is not a compile-time constant}}
+new_a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \
+  // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
+  // expected-error {{initializer element is not a compile-time constant}}
 
 struct ContainerStuct {
   enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}
@@ -50,10 +50,10 @@
   cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
 }
 
-extern long afunction(int); // expected-note {{'afunction' declared here}}
+extern long afunction(int);
 void fn2() {
-  f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
-afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
+  f(THIS_IS_AN_ERROR,   // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
+afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'}}
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -100,7 +100,9 @@
 // PR7911
 extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
 void PR7911F() {
-  switch (PR7911V); // expected-error {{statement requires expression of integer type}}
+  switch (PR7911V)
+; // expected-error {{statement requires expression of integer type}} \
+// expected-warning {{switch statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
 }
 
 char test5[__has_feature(enumerator_attributes) ? 1 : -1];
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -50,9 +50,9 @@
 }  // expected-error{{expected '__except' or '__finally' block}}
 
 void TEST() {
-  __except ( FilterExpression() ) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
-// expected-error{{too few arguments to function call, expected 1, have 0}}
-
+  __except (FilterExpression()) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
+// expected-error{{too few arguments to function call, expected 1, have 0}} \
+// expected-error{{expected ';' after expression}}
   }
 }
 
Index: clang/test/Parser/objc-foreach-syntax.m
===
--- clang/test/Parser/objc-foreach-syntax.m
+++ clang/test/Parser/objc-foreach-syntax.m
@@ -21,5 +21,9 @@
 
 
 static int test7(id keys) {
-  for (id key; in keys) ;  // expected-error {{use of undeclared identifier 'in'}}
+  // FIXME: would be nice to suppress the secondary diagnostics.
+  for (id key; in keys)
+; // expected-error {{use of undeclared identifier 'in'}} \
+   // expected-error {{expected ';' in 'for' statement specifier}} \
+   // expected-warning {{expression result unused}}
 }
Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -10,7 +10,7 @@
 #pragm

[PATCH] D88737: [AIX] Turn -fdata-sections on by default in Clang

2020-10-08 Thread Jason Liu via Phabricator via cfe-commits
jasonliu updated this revision to Diff 296965.

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

https://reviews.llvm.org/D88737

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-data-sections.c
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  lld/Common/TargetOptionsCommandFlags.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/test/CodeGen/PowerPC/aix-alias.ll
  llvm/test/CodeGen/PowerPC/aix-bytestring.ll
  llvm/test/CodeGen/PowerPC/aix-extern-weak.ll
  llvm/test/CodeGen/PowerPC/aix-extern.ll
  llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
  llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll
  llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
  llvm/test/CodeGen/PowerPC/aix-return55.ll
  llvm/test/CodeGen/PowerPC/aix-weak.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-used.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-visibility.ll
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/lto/lto.cpp
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -698,7 +698,8 @@
   Triple ModuleTriple(M->getTargetTriple());
   std::string CPUStr, FeaturesStr;
   TargetMachine *Machine = nullptr;
-  const TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  const TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(ModuleTriple);
 
   if (ModuleTriple.getArch()) {
 CPUStr = codegen::getCPUStr();
Index: llvm/tools/lto/lto.cpp
===
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -218,7 +218,8 @@
 
 lto_module_t lto_module_create(const char* path) {
   lto_initialize();
-  llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  llvm::TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(Triple());
   ErrorOr> M =
   LTOModule::createFromFile(*LTOContext, StringRef(path), Options);
   if (!M)
@@ -228,7 +229,8 @@
 
 lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
   lto_initialize();
-  llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  llvm::TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(Triple());
   ErrorOr> M = LTOModule::createFromOpenFile(
   *LTOContext, fd, StringRef(path), size, Options);
   if (!M)
@@ -241,7 +243,8 @@
  size_t map_size,
  off_t offset) {
   lto_initialize();
-  llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  llvm::TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(Triple());
   ErrorOr> M = LTOModule::createFromOpenFileSlice(
   *LTOContext, fd, StringRef(path), map_size, offset, Options);
   if (!M)
@@ -251,7 +254,8 @@
 
 lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
   lto_initialize();
-  llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  llvm::TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(Triple());
   ErrorOr> M =
   LTOModule::createFromBuffer(*LTOContext, mem, length, Options);
   if (!M)
@@ -263,7 +267,8 @@
  size_t length,
  const char *path) {
   lto_initialize();
-  llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  llvm::TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(Triple());
   ErrorOr> M = LTOModule::createFromBuffer(
   *LTOContext, mem, length, Options, StringRef(path));
   if (!M)
@@ -274,7 +279,8 @@
 lto_module_t lto_module_create_in_local_context(const void *mem, size_t length,
 const char *path) {
   lto_initialize();
-  llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
+  llvm::TargetOptions Options =
+  codegen::InitTargetOptionsFromCodeGenFlags(Triple());
 
   // Create a local context. Ownership will be transferred to LTOModule.
   std::unique_ptr Context = std::make_unique();
@@

[PATCH] D88737: [AIX] Turn -fdata-sections on by default in Clang

2020-10-08 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: lld/Common/TargetOptionsCommandFlags.cpp:17
+llvm::TargetOptions
+lld::initTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple) {
+  return llvm::codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);

MaskRay wrote:
> jasonliu wrote:
> > MaskRay wrote:
> > > Currently lld does not need Triple. Consider not changing the signature 
> > > of `initTargetOptionsFromCodeGenFlags`.
> > This function acts like a forwarder for 
> > llvm::codegen::InitTargetOptionsFromCodeGenFlags.
> > I think it still makes sense to change the signature in this case to 
> > minimize the different variation of the function, as those variations cause 
> > confusion to people. 
> > I will change the name to match the LLVM style.
> If you want to change `InitTargetOptionsFromCodeGenFlags` in an incompatible 
> way, you can by the way rename it to `initTarget*`.
> 
> lld functions should always stick with the `camelCase` rule. If there is no 
> meaningful triple, I'd prefer leave out the parameter.
Sorry, didn't realize lld has this `camelCase` rule. 
I don't have a better naming for it, so I will just leave the function 
signature untouched. 


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

https://reviews.llvm.org/D88737

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


[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).

2020-10-08 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: llvm/include/llvm/Analysis/TargetLibraryInfo.h:91
 Accelerate, // Use Accelerate framework.
+LIBMVEC,// GLIBC Vector Math library.
 MASSV,  // IBM MASS vector library.

nemanjai wrote:
> fpetrogalli wrote:
> > Can we call this LIBMVEC-X86? Libmvec itself is supposed to support other 
> > architectures, I can see list of mappings for each of the supported targets.
> > 
> > Then, the logic of selecting the correct one in the frontent clang would 
> > depend on the value of `-fvec-lib=libmvec` plus the value of `-target`.
> So if I follow correctly, we can choose the various vendor-specific libraries 
> as well as `libmvec` which itself has target-specific ports.
> 
> Would it make sense to just add an overload of `addVectorizableFunctions()` 
> that would consider the `Triple` and remove any entries from `VectorDescs` 
> that the target doesn't support? Or even more specifically, simply add the 
> `Triple` argument to `addVectorizableFunctionsFromVecLib()` and call 
> something like `removeLIBMVECEntriesForTarget(const Triple &T)` that would do 
> the job.
> 
> And of course, if the triple isn't provided and the user is targeting an 
> architecture that doesn't provide some entry, that is just user error.
The overload of the `addVectorizableFunctions()` might be feasible,  but for 
the sake of simplicity I think that having `LIBMVEC_` in `enum 
VectorLibrary`  for each of the  to support would avoid having to deal 
with overload of methods. Given that these lists are static, I'd rather see 
them explicitly instead of having them filled up by add/remove methods. 

All in all, I think it is easier to add the logic for the target triple in 
clang as it is just a matter of modifying the changes in `BackendUtils.cpp` 
(warning, pseudocode ahead):

```
  case CodeGenOptions::LIBMVEC: 
switch(Triple) {
case X:
   
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::LIBMVEC_X);
 break
case Y:
   
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::LIBMVEC_Y);
break;
case ...
}
break;
```






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

https://reviews.llvm.org/D88154

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


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a subscriber: hans.
yaxunl added a comment.

I can help you commit it to trunk. For cherrypick to release branch, we may 
need help of @hans


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88949

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


[PATCH] D89046: [AST] Build recovery expression by default for all language.

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 296968.
hokein added a comment.

fix unexpected format changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89046

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/builtins-ppc-error.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/Index/complete-switch.c
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/Parser/objc-foreach-syntax.m
  clang/test/Sema/__try.c
  clang/test/Sema/enum.c
  clang/test/Sema/typo-correction.c

Index: clang/test/Sema/typo-correction.c
===
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -14,9 +14,9 @@
   // expected-error {{use of undeclared identifier 'b'}}
 
 int foobar;  // expected-note {{'foobar' declared here}}
-a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
-  // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
-  // expected-error {{initializer element is not a compile-time constant}}
+new_a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \
+  // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
+  // expected-error {{initializer element is not a compile-time constant}}
 
 struct ContainerStuct {
   enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}
@@ -50,10 +50,10 @@
   cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
 }
 
-extern long afunction(int); // expected-note {{'afunction' declared here}}
+extern long afunction(int);
 void fn2() {
-  f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
-afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
+  f(THIS_IS_AN_ERROR,   // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
+afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'}}
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -100,7 +100,8 @@
 // PR7911
 extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
 void PR7911F() {
-  switch (PR7911V); // expected-error {{statement requires expression of integer type}}
+  switch (PR7911V); // expected-error {{statement requires expression of integer type}} \
+// expected-warning {{switch statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
 }
 
 char test5[__has_feature(enumerator_attributes) ? 1 : -1];
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -50,9 +50,9 @@
 }  // expected-error{{expected '__except' or '__finally' block}}
 
 void TEST() {
-  __except ( FilterExpression() ) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
-// expected-error{{too few arguments to function call, expected 1, have 0}}
-
+  __except (FilterExpression()) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
+// expected-error{{too few arguments to function call, expected 1, have 0}} \
+// expected-error{{expected ';' after expression}}
   }
 }
 
Index: clang/test/Parser/objc-foreach-syntax.m
===
--- clang/test/Parser/objc-foreach-syntax.m
+++ clang/test/Parser/objc-foreach-syntax.m
@@ -21,5 +21,8 @@
 
 
 static int test7(id keys) {
-  for (id key; in keys) ;  // expected-error {{use of undeclared identifier 'in'}}
+  // FIXME: would be nice to suppress the secondary diagnostics.
+  for (id key; in keys) ;  // expected-error {{use of undeclared identifier 'in'}} \
+   // expected-error {{expected ';' in 'for' statement specifier}} \
+   // expected-warning {{expression result unused}}
 }
Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -10,7 +10,7 @@
 #pragma omp declare variant // expected-error {{expected '(' after 'declare variant'}}
 #pragma omp declare variant( // expected-error {{e

[PATCH] D88886: [Clang][unittests][NFC] Break up test in Callbacks.cpp

2020-10-08 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp updated this revision to Diff 296970.
stefanp added a comment.

Added the missing header file.
Added the license comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

Files:
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCallExpr.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCommon.h
  
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCompoundAssignOperator.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksLeaf.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
@@ -0,0 +1,200 @@
+//===- unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.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 "CallbacksCommon.h"
+
+TEST(RecursiveASTVisitor, StmtCallbacks_TraverseUnaryOperator) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
+  });
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S,
+ [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void test() {
+  1;
+  -2;
+  3;
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
+  WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(3)
+)txt"));
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
+  R"txt(
+WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
+WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt CompoundStmt
+)txt"));
+}
+
+TEST(RecursiveASTVisitor,
+ StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
+  });
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S,
+ [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;
+}
+
+bool WalkUpFromExpr(Expr *E) {
+  recordCallback(__func__, E,
+ [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
+  return true;
+}
+
+bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
+  });
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void test() {
+  1;
+  -2;
+  3;
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+WalkUpFromExpr IntegerLiteral(1)
+  WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromUnaryOperator UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
+  WalkUpFromExpr IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromExpr IntegerLiteral(3)
+  WalkUpFromStmt IntegerLiteral(3)
+)txt"));
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
+  R"txt(
+WalkUpFromExpr IntegerLiteral(1)
+  WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromExpr IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryOperator UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
+Wa

[PATCH] D88088: [clang] improve accuracy of ExprMutAnalyzer

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM though I may have spotted a potential improvement (it can be handled in a 
follow-up if you want).




Comment at: clang/lib/Analysis/ExprMutationAnalyzer.cpp:61
+  // below.
+  auto const ConditionalOperator = conditionalOperator(anyOf(
+  hasTrueExpression(ignoringParens(canResolveToExpr(InnerMatcher))),

Do you also want to handle the binary conditional operator (a GNU extension 
like `a ? : b`)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88088

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


[PATCH] D88414: [clangd] Introduce memory dumping to FileIndex, FileSymbols and BackgroundIndex

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 296971.
kadircet added a comment.

- Fix a bug in FileSymbols profiling.
- Add unittests to ensure tree structure is as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88414

Files:
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -22,20 +22,25 @@
 #include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
+#include "index/SymbolID.h"
 #include "support/Threading.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Allocator.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 
 using ::testing::_;
 using ::testing::AllOf;
 using ::testing::Contains;
 using ::testing::ElementsAre;
+using ::testing::Gt;
 using ::testing::IsEmpty;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -88,6 +93,13 @@
   return std::make_unique(std::move(Slab).build());
 }
 
+std::unique_ptr relSlab(llvm::ArrayRef Rels) {
+  RelationSlab::Builder RelBuilder;
+  for (auto &Rel : Rels)
+RelBuilder.insert(Rel);
+  return std::make_unique(std::move(RelBuilder).build());
+}
+
 TEST(FileSymbolsTest, UpdateAndGet) {
   FileSymbols FS;
   EXPECT_THAT(runFuzzyFind(*FS.buildIndex(IndexType::Light), ""), IsEmpty());
@@ -637,6 +649,50 @@
 EXPECT_TRUE(Shard->Cmd.hasValue());
   }
 }
+
+TEST(FileIndexTest, Profile) {
+  FileIndex FI;
+
+  auto FileName = testPath("foo.cpp");
+  auto AST = TestTU::withHeaderCode("int a;").build();
+  FI.updateMain(FileName, AST);
+  FI.updatePreamble(FileName, "v1", AST.getASTContext(),
+AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
+
+  llvm::BumpPtrAllocator Alloc;
+  MemoryTree MT(&Alloc);
+  FI.profile(MT);
+  ASSERT_THAT(MT.children(),
+  UnorderedElementsAre(Pair("preamble", _), Pair("main_file", _)));
+
+  ASSERT_THAT(MT.child("preamble").children(),
+  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  ASSERT_THAT(MT.child("main_file").children(),
+  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+
+  ASSERT_THAT(MT.child("preamble").child("index").total(), Gt(0U));
+  ASSERT_THAT(MT.child("main_file").child("index").total(), Gt(0U));
+}
+
+TEST(FileSymbolsTest, Profile) {
+  FileSymbols FS;
+  FS.update("f1", numSlab(1, 2), nullptr, nullptr, false);
+  FS.update("f2", nullptr, refSlab(SymbolID("1"), "f1"), nullptr, false);
+  FS.update("f3", nullptr, nullptr,
+relSlab({{SymbolID("1"), RelationKind::BaseOf, SymbolID("2")}}),
+false);
+  llvm::BumpPtrAllocator Alloc;
+  MemoryTree MT(&Alloc);
+  FS.profile(MT);
+  ASSERT_THAT(MT.children(), UnorderedElementsAre(Pair("f1", _), Pair("f2", _),
+  Pair("f3", _)));
+  EXPECT_THAT(MT.child("f1").children(), ElementsAre(Pair("symbols", _)));
+  EXPECT_THAT(MT.child("f1").total(), Gt(0U));
+  EXPECT_THAT(MT.child("f2").children(), ElementsAre(Pair("references", _)));
+  EXPECT_THAT(MT.child("f2").total(), Gt(0U));
+  EXPECT_THAT(MT.child("f3").children(), ElementsAre(Pair("relations", _)));
+  EXPECT_THAT(MT.child("f3").total(), Gt(0U));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -21,6 +21,7 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Not;
+using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
 
 namespace clang {
@@ -872,5 +873,18 @@
   EXPECT_EQ(S.LastIdle, 2000u);
 }
 
+TEST(BackgroundIndex, Profile) {
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  BackgroundIndex Idx(FS, CDB, [](llvm::StringRef) { return nullptr; },
+  /*Opts=*/{});
+
+  llvm::BumpPtrAllocator Alloc;
+  MemoryTree MT(&Alloc);
+  Idx.profile(MT);
+  ASSERT_THAT(MT.children(),
+  UnorderedElementsAre(Pair("symbols", _), Pair("index", _)));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/FileIndex.h
=

[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-10-08 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 296972.
Xiangling_L marked an inline comment as done.
Xiangling_L added a comment.

Remove emit errors for oversized long long bitfield and related testcase;


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

https://reviews.llvm.org/D87029

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-bitfield-alignment.cpp

Index: clang/test/Layout/aix-bitfield-alignment.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-bitfield-alignment.cpp
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+struct A {
+  bool b : 3;
+  unsigned char c : 2;
+  unsigned short s : 6;
+};
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT:  0:0-2 |   _Bool b
+// CHECK-NEXT:  0:3-4 |   unsigned char c
+// CHECK-NEXT: 0:5-10 |   unsigned short s
+// CHECK-NEXT:| [sizeof=4, dsize=4, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=4, nvalign=4, preferrednvalign=4]
+
+struct B {
+  char c;
+  int : 0;
+};
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct B
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:| [sizeof=4, dsize=4, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=4, nvalign=4, preferrednvalign=4]
+
+struct C {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+};
+
+int c = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK32: 4:0-7 |   unsigned long a7
+// CHECK32:   | [sizeof=8, dsize=8, align=4, preferredalign=4,
+// CHECK32:   |  nvsize=8, nvalign=4, preferrednvalign=4]
+// CHECK64: 3:1-8 |   unsigned long a7
+// CHECK64:   | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK64:   |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+#pragma align(packed)
+struct C1 {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+};
+#pragma align(reset)
+
+int c1 = sizeof(C1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C1
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK-NEXT:  3:1-8 |   unsigned long a7
+// CHECK-NEXT:| [sizeof=5, dsize=5, align=1, preferredalign=1,
+// CHECK-NEXT:|  nvsize=5, nvalign=1, preferrednvalign=1]
+
+#pragma pack(4)
+struct C2 {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+};
+#pragma pack(pop)
+
+int c2 = sizeof(C2);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C2
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK-NEXT:  3:1-8 |   unsigned long a7
+// CHECK-NEXT:| [sizeof=8, dsize=8, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=8, nvalign=4, preferrednvalign=4]
+
+typedef __attribute__((aligned(32))) short mySHORT;
+struct D {
+  char c : 8;
+  mySHORT : 0;
+};
+
+int d = sizeof(D);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct D
+// CHECK-NEXT:  0:0-7 |   char c
+// CHECK-NEXT:   32:- |   mySHORT
+// CHECK-NEXT:| [sizeof=32, dsize=32, align=32, preferredalign=32,
+// CHECK-NEXT:|  nvsize=32, nvalign=32, preferrednvalign=32]
+
+typedef __attribute__((aligned(32))) long myLONG;
+struct D1 {
+  char c : 8;
+  myLONG : 0;
+};
+
+int d1 = sizeof(D1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct D1
+// CHECK-NEXT:  0:0-7 |   char c
+// CHECK-NEXT:   32:- |   myLONG
+// CHECK-

[PATCH] D54943: WIP [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt:37
+  clangLex
+  clangSerialization
   clangTidy

Why do serialization and lex need to be pulled in?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp:46
+
+void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
+  const auto ConstType = hasType(isConstQualified());

Should this check only fire in C++? I'm sort of on the fence. It's a C++ core 
guideline, so it stands to reason it should be disabled for C code. But 
const-correctness is a thing in C too. WDYT?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp:105
+
+  // Each variable can only in one category: Value, Pointer, Reference.
+  // Analysis can be controlled for every category.

can only in -> can only be in


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D88949#2319392 , @yaxunl wrote:

> I can help you commit it to trunk. For cherrypick to release branch, we may 
> need help of @hans

It's most likely too late for 11.0.0, but I will put it on my list of 11.0.1 
candidates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88949

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


[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-10-08 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps marked 2 inline comments as done.
alanphipps added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1169
+createBranchRegion(S->getCond(), BodyCount,
+   subtractCounters(CondCount, BodyCount));
   }

vsk wrote:
> If `theWhileStmt->getCond()` is-a BinaryOperator, it would not be considered 
> an instrumented condition and no branch region would be created here. OTOH, 
> if the condition is instrumented (e.g. as it would be in `while (x);`), a 
> branch region would be created.
> 
> Is this the expected outcome? It seems a little bit inconsistent compared to 
> either a) allowing the RecursiveASTVisitor to identify expressions that 
> require branch regions, or b) guaranteeing that each while statement comes 
> with a branch region for its condition.
> 
> I have the same question about the `createBranchRegion` calls in VisitDoStmt, 
> VisitForStmt, etc. (But I'm not concerned about the calls to 
> `createBranchRegion` in VisitBinL{And,Or} and VisitSwitch*.)
Right, that's the expected outcome, but I think I see what you're saying in 
that it could be confusing to call "createBranchRegion()" that may not actually 
create a branch region in some cases.  

I could move the check for isInstrumentedCondition() out of 
createBranchRegion() to make it clear that a branch region is only created for 
when that is TRUE, but I wanted to encapsulate as much as I could in the 
function to avoid duplication.  Perhaps it would be better to rename 
"createBranchRegion()" to something more like 
"createBranchRegionForInstrumentedCond()"?

The same behavior exists for VisitBinL{And,Or} since those conditions could 
also be nested BinaryOperators.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1277
+// Create Branch Region around condition.
+createBranchRegion(S->getCond(), BodyCount,
+   subtractCounters(LoopCount, BodyCount));

vsk wrote:
> Is the condition of a CXXForRangeStmt something that's visible to the user? 
> It looks more like a clang implementation detail (but I could be mistaken).
Technically the condition isn't visible, per se, but the range-based construct 
implies a branchable condition that other vendors do track, so I still think 
it's useful to show it.


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

https://reviews.llvm.org/D84467

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


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Geoff Levner via Phabricator via cfe-commits
glevner added a comment.

Good enough for us... Thanks, @hans and @yaxunl!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88949

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


[PATCH] D88984: Prefer libc++ headers in the -isysroot over the toolchain

2020-10-08 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added reviewers: rsmith, teemperor.
dexonsmith added a comment.

Hmm, that's right, to support user-provided libc++ headers it's simpler if we 
prefer the toolchain / next-to-clang.

The reason we need to invert it is transitional. The status quo is that we have 
no headers in the SDKs (either internally or publicly). We want to move the 
headers from the toolchain to the SDK. For [reasons], in some internal contexts 
we'll have headers both places for a small number of years, where the SDK 
headers should be preferred if both exist.

Some ideas:

- Add a command-line option to decide whether to check the SDK or next-to-clang 
first. Maybe we can restrict it to a `-cc1` option.
- Make the default behaviour configurable, and potentially use a different 
default in the Apple CMake cache.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88984

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


[PATCH] D88949: DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9225543e844: DeferredDiagnosticsEmitter crashes (authored 
by glevner, committed by yaxunl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88949

Files:
  clang/lib/Sema/UsedDeclVisitor.h


Index: clang/lib/Sema/UsedDeclVisitor.h
===
--- clang/lib/Sema/UsedDeclVisitor.h
+++ clang/lib/Sema/UsedDeclVisitor.h
@@ -67,10 +67,13 @@
   void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
 if (E->getOperatorDelete())
   asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete());
-QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
-if (const RecordType *DestroyedRec = Destroyed->getAs()) {
-  CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
-  asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+QualType DestroyedOrNull = E->getDestroyedType();
+if (!DestroyedOrNull.isNull()) {
+  QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
+  if (const RecordType *DestroyedRec = Destroyed->getAs()) {
+CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
+asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+  }
 }
 
 Inherited::VisitCXXDeleteExpr(E);


Index: clang/lib/Sema/UsedDeclVisitor.h
===
--- clang/lib/Sema/UsedDeclVisitor.h
+++ clang/lib/Sema/UsedDeclVisitor.h
@@ -67,10 +67,13 @@
   void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
 if (E->getOperatorDelete())
   asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete());
-QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
-if (const RecordType *DestroyedRec = Destroyed->getAs()) {
-  CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
-  asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+QualType DestroyedOrNull = E->getDestroyedType();
+if (!DestroyedOrNull.isNull()) {
+  QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
+  if (const RecordType *DestroyedRec = Destroyed->getAs()) {
+CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
+asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+  }
 }
 
 Inherited::VisitCXXDeleteExpr(E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b922554 - DeferredDiagnosticsEmitter crashes

2020-10-08 Thread Yaxun Liu via cfe-commits

Author: Geoff Levner
Date: 2020-10-08T11:42:21-04:00
New Revision: b9225543e844bee5091aa16108e0c54bd2abe485

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

LOG: DeferredDiagnosticsEmitter crashes

Patch VisitCXXDeleteExpr() in clang::UsedDeclVisitor to avoid it crashing
when the expression's destroyed type is null. According to the comments
in CXXDeleteExpr::getDestroyedType(), this can happen when the type to
delete is a dependent type.

Patch by Geoff Levner.

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

Added: 


Modified: 
clang/lib/Sema/UsedDeclVisitor.h

Removed: 




diff  --git a/clang/lib/Sema/UsedDeclVisitor.h 
b/clang/lib/Sema/UsedDeclVisitor.h
index d207e07f451a..c33d30478e2a 100644
--- a/clang/lib/Sema/UsedDeclVisitor.h
+++ b/clang/lib/Sema/UsedDeclVisitor.h
@@ -67,10 +67,13 @@ class UsedDeclVisitor : public 
EvaluatedExprVisitor {
   void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
 if (E->getOperatorDelete())
   asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete());
-QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
-if (const RecordType *DestroyedRec = Destroyed->getAs()) {
-  CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
-  asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+QualType DestroyedOrNull = E->getDestroyedType();
+if (!DestroyedOrNull.isNull()) {
+  QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
+  if (const RecordType *DestroyedRec = Destroyed->getAs()) {
+CXXRecordDecl *Record = cast(DestroyedRec->getDecl());
+asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+  }
 }
 
 Inherited::VisitCXXDeleteExpr(E);



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


[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-10-08 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd564409946a5: [OpenMP] Change CMake Configuration to Build 
for Highest CUDA Architecture by… (authored by jhuber6).
Herald added a subscriber: mgorny.

Changed prior to commit:
  https://reviews.llvm.org/D87946?vs=295120&id=296989#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87946

Files:
  clang/CMakeLists.txt
  openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt


Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -67,9 +67,14 @@
 
   set(omp_data_objects ${devicertl_common_directory}/src/omp_data.cu)
 
-  # Get the compute capability the user requested or use SM_35 by default.
-  # SM_35 is what clang uses by default.
-  set(default_capabilities 35)
+  # Build library support for the highest compute capability the system 
supports
+  # and always build support for sm_35 by default
+  if (${LIBOMPTARGET_DEP_CUDA_ARCH} EQUAL 35)
+set(default_capabilities 35)
+  else()
+  set(default_capabilities "35,${LIBOMPTARGET_DEP_CUDA_ARCH}")
+  endif()
+
   if (DEFINED LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITY)
 set(default_capabilities ${LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITY})
 libomptarget_warning_say("LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITY is 
deprecated, please use LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES")
Index: openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
===
--- openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -117,6 +117,18 @@
 endif()
 find_package(CUDA QUIET)
 
+# Try to get the highest Nvidia GPU architecture the system supports
+if (CUDA_FOUND)
+  cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
+  string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH_OUTPUT ${CUDA_ARCH_FLAGS})
+  if (NOT DEFINED CUDA_ARCH_MATCH_OUTPUT OR "${CMAKE_MATCH_1}" LESS 35)
+libomptarget_warning_say("Setting Nvidia GPU architecture support for 
OpenMP target runtime library to sm_35 by default")
+set(LIBOMPTARGET_DEP_CUDA_ARCH "35")
+  else()
+set(LIBOMPTARGET_DEP_CUDA_ARCH "${CMAKE_MATCH_1}")
+  endif()
+endif()
+
 set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDA_FOUND})
 set(LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
 
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -305,13 +305,26 @@
 # OpenMP offloading requires at least sm_35 because we use shuffle instructions
 # to generate efficient code for reductions and the atomicMax instruction on
 # 64-bit integers in the implementation of conditional lastprivate.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
-  "Default architecture for OpenMP offloading to Nvidia GPUs.")
-string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
-  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+set(CUDA_ARCH_FLAGS "sm_35")
+
+# Try to find the highest Nvidia GPU architecture the system supports
+if (NOT DEFINED CLANG_OPENMP_NVPTX_DEFAULT_ARCH)
+  find_package(CUDA QUIET)
+  if (CUDA_FOUND)
+cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
+  endif()
+else()
+  set(CUDA_ARCH_FLAGS ${CLANG_OPENMP_NVPTX_DEFAULT_ARCH})
+endif()
+
+string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH ${CUDA_ARCH_FLAGS})
+if (NOT DEFINED CUDA_ARCH_MATCH OR "${CMAKE_MATCH_1}" LESS 35)
   set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
+  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+else()
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH ${CUDA_ARCH_MATCH} CACHE STRING
+"Default architecture for OpenMP offloading to Nvidia GPUs.")
 endif()
 
 set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")


Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -67,9 +67,14 @@
 
   set(omp_data_objects ${devicertl_common_directory}/src/omp_data.cu)
 
-  # Get the compute capability the user requested or use SM_35 by default.
-  # SM_35 is what clang uses by default.
-  set(default_capabilities 35)
+  # Build library support for the highest compute capability the system supports
+  # and always build support for sm_35 by defa

[clang] d564409 - [OpenMP] Change CMake Configuration to Build for Highest CUDA Architecture by Default

2020-10-08 Thread via cfe-commits

Author: Joseph Huber
Date: 2020-10-08T12:09:34-04:00
New Revision: d564409946a5a13cb6391fc0fec54dcbd6f6d249

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

LOG: [OpenMP] Change CMake Configuration to Build for Highest CUDA Architecture 
by Default

Summary:
This patch changes the CMake files for Clang and Libomptarget to query the
system for its supported CUDA architecture. This makes it much easier for the
user to build optimal code without needing to set the flags manually. This
relies on the now deprecated FindCUDA method in CMake, but full support for
architecture detection is only availible in CMake >3.18

Reviewers: jdoerfert ye-luo

Subscribers: cfe-commits guansong mgorny openmp-commits sstefan1 yaxunl

Tags: #clang #OpenMP

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

Added: 


Modified: 
clang/CMakeLists.txt
openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c308328c3ee4..900ef0a4d737 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -305,13 +305,26 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
 # OpenMP offloading requires at least sm_35 because we use shuffle instructions
 # to generate efficient code for reductions and the atomicMax instruction on
 # 64-bit integers in the implementation of conditional lastprivate.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
-  "Default architecture for OpenMP offloading to Nvidia GPUs.")
-string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
-  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+set(CUDA_ARCH_FLAGS "sm_35")
+
+# Try to find the highest Nvidia GPU architecture the system supports
+if (NOT DEFINED CLANG_OPENMP_NVPTX_DEFAULT_ARCH)
+  find_package(CUDA QUIET)
+  if (CUDA_FOUND)
+cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
+  endif()
+else()
+  set(CUDA_ARCH_FLAGS ${CLANG_OPENMP_NVPTX_DEFAULT_ARCH})
+endif()
+
+string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH ${CUDA_ARCH_FLAGS})
+if (NOT DEFINED CUDA_ARCH_MATCH OR "${CMAKE_MATCH_1}" LESS 35)
   set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
+  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+else()
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH ${CUDA_ARCH_MATCH} CACHE STRING
+"Default architecture for OpenMP offloading to Nvidia GPUs.")
 endif()
 
 set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")

diff  --git 
a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake 
b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
index 05742bd4fbf7..f6bfadcaf0b3 100644
--- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -117,6 +117,18 @@ if (CUDA_TOOLKIT_ROOT_DIR)
 endif()
 find_package(CUDA QUIET)
 
+# Try to get the highest Nvidia GPU architecture the system supports
+if (CUDA_FOUND)
+  cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS)
+  string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH_OUTPUT ${CUDA_ARCH_FLAGS})
+  if (NOT DEFINED CUDA_ARCH_MATCH_OUTPUT OR "${CMAKE_MATCH_1}" LESS 35)
+libomptarget_warning_say("Setting Nvidia GPU architecture support for 
OpenMP target runtime library to sm_35 by default")
+set(LIBOMPTARGET_DEP_CUDA_ARCH "35")
+  else()
+set(LIBOMPTARGET_DEP_CUDA_ARCH "${CMAKE_MATCH_1}")
+  endif()
+endif()
+
 set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDA_FOUND})
 set(LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
 

diff  --git a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt 
b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
index ca9e75953ff4..425c674fb11e 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -67,9 +67,14 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
 
   set(omp_data_objects ${devicertl_common_directory}/src/omp_data.cu)
 
-  # Get the compute capability the user requested or use SM_35 by default.
-  # SM_35 is what clang uses by default.
-  set(default_capabilities 35)
+  # Build library support for the highest compute capability the system 
supports
+  # and always build support for sm_35 by default
+  if (${LIBOMPTARGET_DEP_CUDA_ARCH} EQUAL 35)
+set(default_capabilities 35)
+  else()
+  set(default_capabilities "35,${LIBOMPTARGET_DEP_CUDA_ARCH}")
+  endif()
+
   if (DEFINED LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITY)
 set(defau

[PATCH] D88929: [OpenMP] Change CMake Configuration to Build for Highest CUDA Architecture by Default

2020-10-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 closed this revision.
jhuber6 added a comment.

Screwed up and put the wrong revision in the commit message. Closed in 
rGd564409946a5a13cb6391fc0fec54dcbd6f6d249 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88929

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


[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-10-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 reopened this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

Closed accidentally, had the wrong revision link in another patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87946

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


[PATCH] D87279: [clang] Fix handling of physical registers in inline assembly operands.

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:2095
+if (!GCCReg.empty() && !PhysRegOutputs.insert(GCCReg).second)
+  CGM.Error(S.getAsmLoc(), "Multiple outputs to hard register: " + GCCReg);
+

Diagnostics in Clang are typically not grammatically correct, so I think it 
should be `multiple` instead of `Multiple`.


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

https://reviews.llvm.org/D87279

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


[PATCH] D88814: [clangd] Enable partial namespace matches for workspace symbols

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 296992.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Switch from substring to subscope matching.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88814

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -126,28 +126,43 @@
   TU.AdditionalFiles["foo.h"] = R"cpp(
   namespace ans1 {
 int ai1;
-  namespace ans2 {
-int ai2;
-  }
+namespace ans2 {
+  int ai2;
+  namespace ans3 {
+int ai3;
+  }
+}
   }
   )cpp";
   TU.Code = R"cpp(
   #include "foo.h"
   )cpp";
   EXPECT_THAT(getSymbols(TU, "a"),
-  UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"),
-   QName("ans1::ans2"),
-   QName("ans1::ans2::ai2")));
+  UnorderedElementsAre(
+  QName("ans1"), QName("ans1::ai1"), QName("ans1::ans2"),
+  QName("ans1::ans2::ai2"), QName("ans1::ans2::ans3"),
+  QName("ans1::ans2::ans3::ai3")));
   EXPECT_THAT(getSymbols(TU, "::"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "::a"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "ans1::"),
-  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2"),
+   QName("ans1::ans2::ai2"),
+   QName("ans1::ans2::ans3"),
+   QName("ans1::ans2::ans3::ai3")));
+  EXPECT_THAT(getSymbols(TU, "ans2::"),
+  UnorderedElementsAre(QName("ans1::ans2::ai2"),
+   QName("ans1::ans2::ans3"),
+   QName("ans1::ans2::ans3::ai3")));
   EXPECT_THAT(getSymbols(TU, "::ans1"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "::ans1::"),
   UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
   EXPECT_THAT(getSymbols(TU, "::ans1::ans2"), ElementsAre(QName("ans1::ans2")));
   EXPECT_THAT(getSymbols(TU, "::ans1::ans2::"),
-  ElementsAre(QName("ans1::ans2::ai2")));
+  ElementsAre(QName("ans1::ans2::ai2"), QName("ans1::ans2::ans3")));
+
+  // Ensure sub-sequence matching works.
+  EXPECT_THAT(getSymbols(TU, "ans1::ans3::ai"),
+  UnorderedElementsAre(QName("ans1::ans2::ans3::ai3")));
 }
 
 TEST(WorkspaceSymbols, AnonymousNamespace) {
@@ -256,6 +271,17 @@
   EXPECT_THAT(getSymbols(TU, "::"), ElementsAre(QName("func"), QName("ns")));
 }
 
+TEST(WorkspaceSymbols, RankingPartialNamespace) {
+  TestTU TU;
+  TU.Code = R"cpp(
+namespace ns1 {
+  namespace ns2 { struct Foo {}; }
+}
+namespace ns2 { struct FooB {}; })cpp";
+  EXPECT_THAT(getSymbols(TU, "ns2::f"),
+  ElementsAre(QName("ns2::FooB"), QName("ns1::ns2::Foo")));
+}
+
 TEST(WorkspaceSymbols, WithLimit) {
   TestTU TU;
   TU.AdditionalFiles["foo.h"] = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -18,10 +18,14 @@
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Index/IndexingAction.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include 
 
 #define DEBUG_TYPE "FindSymbols"
 
@@ -38,6 +42,28 @@
   }
 };
 
+// Returns true if \p Query can be found as a sub-sequence inside \p Scope.
+bool approximateScopeMatch(llvm::StringRef Scope, llvm::StringRef Query) {
+  // An empty query always matches the scope.
+  if (Query.empty())
+return true;
+  // Query is non-empty, so cannot be matched.
+  if (Scope.empty())
+return false;
+
+  assert(Scope.endswith("::"));
+  assert(Query.endswith("::"));
+  while (!Scope.empty() && !Query.empty()) {
+auto Colons = Scope.find("::");
+assert(Colons != llvm::StringRef::npos);
+
+llvm::StringRef LeadingSpecifier = Scope.slice(0, Colons + 2);
+Scope = Scope.slice(Colons + 2, llvm::StringRef::npos);
+Query.consume_front(LeadingSpecifier);
+  }
+  return Query.empty();
+}
+
 } // namespace
 
 llvm::Expected indexToLSPLocation(const SymbolLocation &Loc,
@@ -71,44 +97,54 @@
   if (Query.empty() || !Index)
 return Result;
 
+

[PATCH] D88814: [clangd] Enable partial namespace matches for workspace symbols

2020-10-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:44
 
+// Returns true if \p Query can be found as a sub-scope inside \p Scope.
+bool approximateScopeMatch(llvm::StringRef Scope,

sammccall wrote:
> kadircet wrote:
> > sammccall wrote:
> > > I had a little trouble following this...
> > > It seems a little simpler (fewer vars to track) if we avoid the up-front 
> > > split on scopes.
> > > 
> > > ```
> > > assert(Scope.empty() || Scope.endswith("::")); // or handle in some way
> > > // Walk through Scope, consuming matching tokens from Query.
> > > StringRef First;
> > > while (!Scope.empty() && !Query.empty()) {
> > >   tie(First, Scope) = Scope.split("::");
> > >   if (Query.front() == First)
> > > Query = Query.drop_front();
> > > }
> > > return Query.empty(); // all components of query matched
> > > ```
> > > 
> > > in fact we can avoid preprocessing query too:
> > > 
> > > ```
> > > // Query is just a StringRef
> > > assert(Scope.empty() || Scope.endswith("::")); // or handle in some way
> > > assert(Query.empty() || Query.endswith("::"));
> > > 
> > > // Walk through Scope, consuming matching tokens from Query.
> > > StringRef First;
> > > while (!Scope.empty() && !Query.empty()) {
> > >   tie(First, Scope) = Scope.split("::");
> > >   Query.consume_front(StringRef(First.data(), First.size() + 2) 
> > > /*Including ::*/);
> > > }
> > > return Query.empty(); // all components of query matched
> > > ```
> > Yes but they would do different things. I believe the confusion is caused 
> > by usage of `sub-scope` without a clear definition.  The codes you've 
> > suggested are performing sub-sequence matches rather than sub-string(i.e. 
> > we are looking for a contigious segment in `Scope` that matches `Query`).
> > 
> > I believe a query of the form `a::c::` shouldn't be matched by `a::b::c::`. 
> > I can try simplifying the logic, but it would be nice to agree on the 
> > behaviour :D.
> > 
> > Sorry if I miscommunicated this so far.
> Ah right, I was indeed misreading the code. Let's have some definitions...
> 
> given query `a::b::Foo` with scope `a::b::`
> 
> | | a::b:: | `W::a::b::` | `a::X::b::` | `a::b::Y` |
> | exact | * | | | |
> | prefix |*| | | * |
> | suffix | *|* | | |
> | substring | * | * | | * |
> | subsequence | * | * | * | * |
> 
> These support correcting different types of "errors":
>  - exact: none
>  - prefix: may omit namespaces immediately before Foo
>  - suffix: query may be rooted anywhere (other than global ns)
>  - substring: query rooted anywhere, omit namespaces before Foo
>  - subsequence: may omit any component
> 
> We know "exact" is too strict.
> 
> I think "prefix" and by extension "substring" aren't particularly compelling 
> rules as the "immediately before Foo" requirement is arbitrary.
> Why does `a::b::Foo` match `a::b::c::Foo` and not `a::c::b::Foo`? In each 
> case we've omitted a namespace inside the query, the only difference is what 
> it's sandwiched between.
> 
> Suffix makes intuitive sense, it accepts strings that make sense *somewhere* 
> in the codebase.
> Subsequence makes intuitive sense too: you're allowed to forget uninteresting 
> components, similar to how fuzzy-match lets you omit uninteresting words.
> 
> I'd prefer one of those and don't really mind which - I'd assumed subsequence 
> was intended. Suffix is way easier to implement though :-)
Thanks for the nice table :D

I was mainly shying away from subsequence as I thought it would be too loose, 
but I suppose it is okay thinking about the fuzzyfind logic. So I've changed 
the implementation to be that way, while adding some tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88814

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


[PATCH] D88659: [FE]Split SuitableAlign into two parts

2020-10-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D88659#2318203 , @jyknight wrote:

> It seems like on AIX, `__BIGGEST_ALIGNMENT__` should just be set to 16, then. 
> I'm not sure why you want it to be 8?



  /// Return the alignment that is suitable for storing any
  /// object with a fundamental alignment requirement.

Vector types have extended (not fundamental) alignment on AIX, because `malloc` 
is not guaranteed to return addresses that are 16-byte aligned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88659

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


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

2020-10-08 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

I think it makes sense - IIUC, for most of the clang tests, noundef won't be 
the attribute of interest.
For brevity of tests, I think the change is fine.


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] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-08 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 296994.
eduucaldas added a comment.

- [SyntaxTree] Provide iterator for `List` that iterates through 
`ElementAndDelimiter`s even for not well-defined lists.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include 
@@ -294,45 +295,102 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
+syntax::List::ElementAndDelimiter
+syntax::List::getWithDelimiter(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  if (!Next)
+return {Element, nullptr};
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return {Element, nullptr};
+  case syntax::NodeRole::ListDelimiter:
+return {Element, cast(Next)};
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
+  }
+}
 
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterDelimiter(syntax::Leaf *Delimiter) {
+  assert(Delimiter && Delimiter->getRole() == syntax::NodeRole::ListDelimiter);
+  auto *List = cast(Delimiter->getParent());
+  auto *Next = Delimiter->getNextSibling();
+  if (!Next) {
+switch (List->getTerminationKind()) {
+// List is separated and ends with delimiter
+// => missing last ElementAndDelimiter.
+case syntax::List::TerminationKind::Separated:
+  return llvm::Optional>(
+  {nullptr, nullptr});
+case syntax::List::TerminationKind::Terminated:
+case syntax::List::TerminationKind::MaybeTerminated:
+  return None;
 }
   }
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // Consecutive Delimiters => missing Element
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(Next)});
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
+  }
+}
+
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterElement(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  // a  b, x => End of list, this was the last ElementAndDelimiter.
+  if (!Next)
+return None;
+
+  switch (Next->getRole()) {
+  // x  b, c => next ElementAndDelimiter starts with 'b'.
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // a  x, c => next ElementAndDelimiter starts after ','.
+  case syntax::NodeRole::ListDelimiter:
+return getElementAndDelimiterAfterDelimiter(cast(Next));
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
-}
-break;
+}
+
+syntax::List::ElementAndDelimiterIterator syntax::List::getEnd() {
+  return llvm::Optional>(None);
+}
+
+syntax::List::ElementAndDelimiterIterator syntax::List::getBegin() {
+  auto *First = getFirstChild();
+  if (!First)
+return getEnd();
+  switch (First->getRole()) {
+  case syntax::NodeRole::ListElement:
+return llvm::Optional>(getWithDelimiter(First));
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(First)});
+  default:
+llvm_unreachable(
+"A list can have only elements and de

[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-08 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 296996.
eduucaldas added a comment.

Better comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include 
@@ -294,89 +295,111 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
+syntax::List::ElementAndDelimiter
+syntax::List::getWithDelimiter(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  if (!Next)
+return {Element, nullptr};
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return {Element, nullptr};
+  case syntax::NodeRole::ListDelimiter:
+return {Element, cast(Next)};
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterDelimiter(syntax::Leaf *Delimiter) {
+  assert(Delimiter && Delimiter->getRole() == syntax::NodeRole::ListDelimiter);
+  auto *List = cast(Delimiter->getParent());
+  auto *Next = Delimiter->getNextSibling();
+  if (!Next) {
+switch (List->getTerminationKind()) {
+// List is separated and ends with delimiter
+// => missing last ElementAndDelimiter.
+case syntax::List::TerminationKind::Separated:
+  return llvm::Optional>(
+  {nullptr, nullptr});
+case syntax::List::TerminationKind::Terminated:
+case syntax::List::TerminationKind::MaybeTerminated:
+  return None;
 }
-break;
   }
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // Consecutive Delimiters => missing Element
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(Next)});
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
-
-  return Children;
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// ignoring delimiters
-std::vector syntax::List::getElementsAsNodes() {
-  if (!getFirstChild())
-return {};
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterElement(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  // a  b, x => End of list, this was the last ElementAndDelimiter.
+  if (!Next)
+return None;
 
-  std::vector Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back(ElementWithoutDelimiter);
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back(ElementWithoutDelimiter);
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable("A list has only elements or delimiters.");
-}
+  switch (Next->getRole()) {
+  // x  b, c => next ElementAndDelimiter starts with 'b'.
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // a  x, c => next ElementAndDelimiter starts after ','.
+  case syntax::NodeRole::ListDelimiter:
+

[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-08 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 297001.
eduucaldas added a comment.

Reorganize methods to minimize diffs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include 
@@ -294,89 +295,111 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
+syntax::List::ElementAndDelimiter
+syntax::List::getWithDelimiter(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  if (!Next)
+return {Element, nullptr};
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return {Element, nullptr};
+  case syntax::NodeRole::ListDelimiter:
+return {Element, cast(Next)};
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterDelimiter(syntax::Leaf *Delimiter) {
+  assert(Delimiter && Delimiter->getRole() == syntax::NodeRole::ListDelimiter);
+  auto *List = cast(Delimiter->getParent());
+  auto *Next = Delimiter->getNextSibling();
+  if (!Next) {
+switch (List->getTerminationKind()) {
+// List is separated and ends with delimiter
+// => missing last ElementAndDelimiter.
+case syntax::List::TerminationKind::Separated:
+  return llvm::Optional>(
+  {nullptr, nullptr});
+case syntax::List::TerminationKind::Terminated:
+case syntax::List::TerminationKind::MaybeTerminated:
+  return None;
 }
-break;
   }
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // Consecutive Delimiters => missing Element
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(Next)});
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
-
-  return Children;
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// ignoring delimiters
-std::vector syntax::List::getElementsAsNodes() {
-  if (!getFirstChild())
-return {};
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterElement(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  // a  b, x => End of list, this was the last ElementAndDelimiter.
+  if (!Next)
+return None;
 
-  std::vector Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back(ElementWithoutDelimiter);
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back(ElementWithoutDelimiter);
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable("A list has only elements or delimiters.");
-}
+  switch (Next->getRole()) {
+  // x  b, c => next ElementAndDelimiter starts with 'b'.
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // a  x, c => next ElementAndDelimiter starts after ','.
+  case syntax::NodeR

[PATCH] D89001: [clang] Don't look into for C++ headers if they are found alongside the toolchain

2020-10-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 297000.
ldionne added a comment.

Try to fix test failure on Linux


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89001

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/lib/.keep
  clang/test/Driver/darwin-header-search-libcxx.cpp

Index: clang/test/Driver/darwin-header-search-libcxx.cpp
===
--- clang/test/Driver/darwin-header-search-libcxx.cpp
+++ clang/test/Driver/darwin-header-search-libcxx.cpp
@@ -13,39 +13,57 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-NONE %s
 // CHECK-LIBCXX-NONE: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 
-// Check with only headers alongside the installation (those should be used,
-// but we should still add /usr/include/c++/v1 after to preserve legacy).
+// Check with only headers alongside the installation (those should be used).
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: --sysroot="" \
-// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
+// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:   --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
 // CHECK-LIBCXX-TOOLCHAIN-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
-// CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "/usr/include/c++/v1"
+// CHECK-LIBCXX-TOOLCHAIN-1-NOT: "-internal-isystem" "/usr/include/c++/v1"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \
-// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
+// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:   -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \
+// RUN:   --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
 // CHECK-LIBCXX-TOOLCHAIN-2: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-LIBCXX-TOOLCHAIN-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-TOOLCHAIN-2-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+
+// Check with only headers in the sysroot (those should be used).
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
+// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
+// RUN:   -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \
+// RUN:   --check-prefix=CHECK-LIBCXX-SYSROOT-1 %s
+// CHECK-LIBCXX-SYSROOT-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-SYSROOT-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+// CHECK-LIBCXX-SYSROOT-1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 
 // Check with both headers in the sysroot and headers alongside the installation
-// (the headers in  should be added after the toolchain headers).
-// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence.
+// (the headers in the toolchain should be preferred over the  headers).
+// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence
+// over --sysroot.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
+// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
 // RUN:   -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
 // RUN:   --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
 //
@@ -54,8 +72,8 @@
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: --sysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
+// RUN: --sysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \

[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2020-10-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: steakhal, NoQ, martong, vsavchenko.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.

During pointer dereferencing CastRetrievedVal uses wrong type from the Store 
after type punning. Namely, the pointer casts to another type and then assigns 
with a value of one more another type. It produces NonLoc value when Loc is 
expected.

Example for visibility:

  void foo(char ***c, int *i) {
*(unsigned**)c = (unsigned*)i; // type punning
***c; // uses 'unsigned**' from the Store instead of 'char***'
  }

Fixes: https://bugs.llvm.org/show_bug.cgi?id=37503


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89055

Files:
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/nonloc-as-loc-crash.c
  clang/test/Analysis/string.c
  clang/test/Analysis/svalbuilder-float-cast.c


Index: clang/test/Analysis/svalbuilder-float-cast.c
===
--- clang/test/Analysis/svalbuilder-float-cast.c
+++ clang/test/Analysis/svalbuilder-float-cast.c
@@ -4,13 +4,9 @@
 
 void SymbolCast_of_float_type_aux(int *p) {
   *p += 0;
-  // FIXME: Ideally, all unknown values should be symbolicated.
-  clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
-
+  clang_analyzer_denote(*p, "$x");
   *p += 1;
-  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
-  // FIXME: Ideally, this should be $x + 1.
-  clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
+  clang_analyzer_express(*p); // expected-warning{{$x + 1}}
 }
 
 void SymbolCast_of_float_type() {
Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,16 @@
 strcpy(x, y); // no-warning
 }
 
+// PR37503
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char 
*)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
+
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/test/Analysis/nonloc-as-loc-crash.c
===
--- /dev/null
+++ clang/test/Analysis/nonloc-as-loc-crash.c
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+void test(int *a, char ***b, float *c) {
+  *(unsigned char **)b = (unsigned char *)a;
+  if (**b == 0) // no-crash
+;
+
+  *(unsigned char **)b = (unsigned char *)c;
+  if (**b == 0) // no-crash
+;
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -426,12 +426,17 @@
   // We might need to do that for non-void pointers as well.
   // FIXME: We really need a single good function to perform casts for us
   // correctly every time we need it.
-  if (castTy->isPointerType() && !castTy->isVoidPointerType())
+  if (castTy->isPointerType() && !castTy->isVoidPointerType()) {
 if (const auto *SR = dyn_cast_or_null(V.getAsRegion())) {
-  QualType sr = SR->getSymbol()->getType();
-  if (!hasSameUnqualifiedPointeeType(sr, castTy))
-  return loc::MemRegionVal(castRegion(SR, castTy));
+QualType sr = SR->getSymbol()->getType();
+if (!hasSameUnqualifiedPointeeType(sr, castTy))
+return loc::MemRegionVal(castRegion(SR, castTy));
 }
+// Next fixes pointer dereference using type different from its initial one
+// See PR37503 for details
+if (const auto *SR = dyn_cast_or_null(V.getAsRegion()))
+  return loc::MemRegionVal(castRegion(SR, castTy));
+  }
 
   return svalBuilder.dispatchCast(V, castTy);
 }


Index: clang/test/Analysis/svalbuilder-float-cast.c
===
--- clang/test/Analysis/svalbuilder-float-cast.c
+++ clang/test/Analysis/svalbuilder-float-cast.c
@@ -4,13 +4,9 @@
 
 void SymbolCast_of_float_type_aux(int *p) {
   *p += 0;
-  // FIXME: Ideally, all unknown values should be symbolicated.
-  clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
-
+  clang_analyzer_denote(*p, "$x");
   *p += 1;
-  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
-  // FIXME: Ideally, this should be $x + 1.
-  clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
+  clang_analyzer_express(*p); // expected-warning{{$x + 1}}
 }
 
 void Sym

[PATCH] D88780: Allow interfaces to operate on in-memory buffers with no source location info.

2020-10-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This looks reasonable, I am guessing we can't test this b/c it would only come 
up in a cling use case?

Was there ever a design document that Hal and JF were asking for? I was reading 
through the cfe-dev thread and I don't see it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88780

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


[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-08 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 297006.
eduucaldas added a comment.

Replace `auto .. = std::vector();` with `std::vector ..;`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include 
@@ -294,89 +295,111 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
+syntax::List::ElementAndDelimiter
+syntax::List::getWithDelimiter(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  if (!Next)
+return {Element, nullptr};
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return {Element, nullptr};
+  case syntax::NodeRole::ListDelimiter:
+return {Element, cast(Next)};
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterDelimiter(syntax::Leaf *Delimiter) {
+  assert(Delimiter && Delimiter->getRole() == syntax::NodeRole::ListDelimiter);
+  auto *List = cast(Delimiter->getParent());
+  auto *Next = Delimiter->getNextSibling();
+  if (!Next) {
+switch (List->getTerminationKind()) {
+// List is separated and ends with delimiter
+// => missing last ElementAndDelimiter.
+case syntax::List::TerminationKind::Separated:
+  return llvm::Optional>(
+  {nullptr, nullptr});
+case syntax::List::TerminationKind::Terminated:
+case syntax::List::TerminationKind::MaybeTerminated:
+  return None;
 }
-break;
   }
+  switch (Next->getRole()) {
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // Consecutive Delimiters => missing Element
+  case syntax::NodeRole::ListDelimiter:
+return llvm::Optional>(
+{nullptr, cast(Next)});
+  default:
+llvm_unreachable(
+"A list can have only elements and delimiters as children.");
   }
-
-  return Children;
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// ignoring delimiters
-std::vector syntax::List::getElementsAsNodes() {
-  if (!getFirstChild())
-return {};
+llvm::Optional>
+syntax::List::getElementAndDelimiterAfterElement(syntax::Node *Element) {
+  assert(Element && Element->getRole() == syntax::NodeRole::ListElement);
+  auto *Next = Element->getNextSibling();
+  // a  b, x => End of list, this was the last ElementAndDelimiter.
+  if (!Next)
+return None;
 
-  std::vector Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back(ElementWithoutDelimiter);
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back(ElementWithoutDelimiter);
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable("A list has only elements or delimiters.");
-}
+  switch (Next->getRole()) {
+  // x  b, c => next ElementAndDelimiter starts with 'b'.
+  case syntax::NodeRole::ListElement:
+return getWithDelimiter(Next);
+
+  // a  x, c => next ElementAndDelimiter starts after ','.

[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-10-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 297003.
jhuber6 added a subscriber: ABataev.
jhuber6 added a comment.

Removing the _loc suffix. The Mapper API hasn't been officially released in 
Clang 11.x so we're still free to make changes. Currently working on augmenting 
the mapper API with variable declaration information so we can associate mapped 
pointers with their source names if the user specified debug locations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87946

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_06.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_08.cpp
  clang/test/OpenMP/target_map_codegen_09.cpp
  clang/test/OpenMP/target_map_codegen_10.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_16.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_19.cpp
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_21.cpp
  clang/test/OpenMP/target_map_codegen_22.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_24.cpp
  clang/test/OpenMP/target_map_codegen_25.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_30.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_33.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/Open

[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-10-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 297008.
jhuber6 added a comment.

Updating tests after landing D88594 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll

Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -888,313 +888,313 @@
 ; CHECK: declare dso_local i32 @omp_pause_resource_all(i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
+; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels()
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_begin(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_begin(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end(%struct.ident_t*) #0
+; CHECK-NEXT: declare vo

[PATCH] D88298: Fix MaterializeTemporaryExpr's type when its an incomplete array.

2020-10-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

*PING!*  Any feedback?


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

https://reviews.llvm.org/D88298

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


[PATCH] D88833: [clang-tidy] Do not warn on pointer decays in system macros

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D88833#2319118 , @fiesh wrote:

> @aaron.ballman valid point.  It would seem natural to diagnose both since the 
> user is voluntarily causing the decay?

I'm on the fence. If the argument to the function is one that's defined by a 
system header, you could argue that the user isn't voluntarily causing the 
decay -- they're using the API they were given by the system. If you're calling 
a user-defined function with that argument, then you could say that the user 
could change their function signature to remove the decay. If you're calling a 
system-defined function with that argument, then there's really nothing the 
user can do except add a cast that they'll likely view as useless. So at the 
very least, I think if the function declaration and the argument to the 
function are in a system header, then we shouldn't warn.

I think for a user-declared function, my intuition is that using an argument 
from a system header which causes decay is pretty uncommon but that we should 
follow the same behavior for the argument as we do for predefined expressions 
like `__PRETTY_FUNCTION__`. Because the argument is outside of the user's 
control, asking them to jump through hoops with their function declaration 
seems like it wouldn't likely add a lot of value. However, I'm not firmly tied 
to that. For user-declared functions, I just want to make sure we treat 
`__PRETTY_FUNCTION__` and `SYS_STRING` consistently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88833

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


[clang] 64c0792 - [clang][feature] Add cxx_abi_relative_vtable feature

2020-10-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-10-08T10:30:54-07:00
New Revision: 64c0792946b792839b2f39e4e208fdd7398aaea0

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

LOG: [clang][feature] Add cxx_abi_relative_vtable feature

This will be enabled if relative vtables is enabled.

Differential revision: https://reviews.llvm.org/D85924

Added: 
clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp

Modified: 
clang/include/clang/Basic/Features.def

Removed: 




diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index 999bcb7e2e29..302c56763c39 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -256,5 +256,7 @@ EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 
+FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && 
LangOpts.RelativeCXXABIVTables)
+
 #undef EXTENSION
 #undef FEATURE

diff  --git a/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp 
b/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
new file mode 100644
index ..d0f0c27b09d3
--- /dev/null
+++ b/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ 
-fexperimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ 
-fno-experimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c 
-fexperimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+
+#if __has_feature(cxx_abi_relative_vtable)
+int has_relative_vtable();
+#else
+int has_no_relative_vtable();
+#endif
+
+// RELATIVE-VTABLE: has_relative_vtable
+// NO-RELATIVE-VTABLE: has_no_relative_vtable



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


[PATCH] D85924: [clang][feature] Add cxx_abi_relative_vtable feature

2020-10-08 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64c0792946b7: [clang][feature] Add cxx_abi_relative_vtable 
feature (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85924

Files:
  clang/include/clang/Basic/Features.def
  clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp


Index: clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ 
-fexperimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ 
-fno-experimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c 
-fexperimental-relative-c++-abi-vtables -o - | FileCheck %s 
--check-prefix=NO-RELATIVE-VTABLE
+
+#if __has_feature(cxx_abi_relative_vtable)
+int has_relative_vtable();
+#else
+int has_no_relative_vtable();
+#endif
+
+// RELATIVE-VTABLE: has_relative_vtable
+// NO-RELATIVE-VTABLE: has_no_relative_vtable
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -256,5 +256,7 @@
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 
+FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && 
LangOpts.RelativeCXXABIVTables)
+
 #undef EXTENSION
 #undef FEATURE


Index: clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -o - | FileCheck %s --check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -fexperimental-relative-c++-abi-vtables -o - | FileCheck %s --check-prefix=RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -fno-experimental-relative-c++-abi-vtables -o - | FileCheck %s --check-prefix=NO-RELATIVE-VTABLE
+// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c -fexperimental-relative-c++-abi-vtables -o - | FileCheck %s --check-prefix=NO-RELATIVE-VTABLE
+
+#if __has_feature(cxx_abi_relative_vtable)
+int has_relative_vtable();
+#else
+int has_no_relative_vtable();
+#endif
+
+// RELATIVE-VTABLE: has_relative_vtable
+// NO-RELATIVE-VTABLE: has_no_relative_vtable
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -256,5 +256,7 @@
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 
+FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables)
+
 #undef EXTENSION
 #undef FEATURE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88833: [clang-tidy] Do not warn on pointer decays in system macros

2020-10-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I think the current behavior should instead be configurable, with a way to 
opt-in into weaker guarantees.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88833

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


[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-08 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added a comment.

This is quite low priority, compared to the other branches of work, but it was 
almost ready work, so I decided to polish it and send it to review now.




Comment at: clang/include/clang/Tooling/Syntax/Tree.h:238-273
+  class ElementAndDelimiterIterator
+  : public llvm::iterator_facade_base> {
+  public:
+ElementAndDelimiterIterator(llvm::Optional> ED)
+: EDI(ED) {}

Should we hide some of this? Most of the member functions are a couple of 
lines, so I decided not to. What is your opinion?



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:275-276
+
+  ElementAndDelimiterIterator getBegin();
+  ElementAndDelimiterIterator getEnd();
+

I chose to leave it as `getBegin` and `getEnd` instead  of 
`getElementsAndDelimitersBegin`. I did this because the return type of those 
methods already tells us that we're getting an `ElementAndDelimiterIterator`. 

What do you think?



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:312-319
+
+private:
+  // Auxiliary methods for implementing `ElementAndDelimiterIterator`.
+  static ElementAndDelimiter getWithDelimiter(Node *Element);
+  static llvm::Optional>
+  getElementAndDelimiterAfterDelimiter(Leaf *Delimiter);
+  static llvm::Optional>

These are all private static methods, should we hide them from the header?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

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


[clang] a15bd0b - [AIX] Add REQUIRES for powerpc test. NFC

2020-10-08 Thread David Green via cfe-commits

Author: David Green
Date: 2020-10-08T18:40:09+01:00
New Revision: a15bd0bfc20c2b2955c59450a67b6e8efe89c708

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

LOG: [AIX] Add REQUIRES for powerpc test. NFC

Added: 


Modified: 
clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp

Removed: 




diff  --git a/clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp 
b/clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
index 0fccce650094..ef424cdb7d41 100644
--- a/clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ b/clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
 // RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
 



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


[PATCH] D87451: add new option -mignore-xcoff-visibility

2020-10-08 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Hello. I added a power-pc REQUIRES clause to the new clang test here in 
a15bd0bfc20c2b2955c59450a67b6e8efe89c708 
. Hope 
that looks OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2020-10-08 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping* Any objections to this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-08 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:139
+
+  switch (E->getStmtClass()) {
+  case Stmt::UnaryOperatorClass: {

sepavloff wrote:
> Actually this is not correct, because subclass relations are not preserved in 
> this case. For instance, `CompounsAssignmentOperator` is not handled, as it 
> does not return `BinaryOperatorClass`.
> 
> I would recommend using `Expr::getFPFeaturesInEffect` or adding similar 
> method.
That's much cleaner. Sorry I missed that earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88913

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


[PATCH] D88833: [clang-tidy] Do not warn on pointer decays in system macros

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D88833#2319799 , @lebedev.ri wrote:

> I think the current behavior should instead be configurable, with a way to 
> opt-in into weaker guarantees.

I think that's a good idea, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88833

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


[clang] 3cc1f1f - [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-10-08 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2020-10-08T14:00:22-04:00
New Revision: 3cc1f1fc1d97952136185f4eafb827694875de17

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

LOG: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

Summary:
Replace the OpenMP Runtime Library functions used in CGOpenMPRuntimeGPU
for OpenMP device code generation with ones in OMPKinds.def and use
OMPIRBuilder for generating runtime calls. This allows us to
consolidate more OpenMP code generation into the OMPIRBuilder. Future
additions to the GPU runtime functions should now go in OMPKinds.def

Reviewers: jdoerfert

Subscribers: aaron.ballman cfe-commits guansong llvm-commits sstefan1 yaxunl

Tags: #OpenMP #LLVM #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/OpenMP/nvptx_parallel_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/test/Transforms/OpenMP/add_attributes.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index 41fa9f5345aa..e39c2e11390e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -306,6 +306,9 @@ class CGOpenMPRuntime {
   CodeGenModule &CGM;
   StringRef FirstSeparator, Separator;
 
+  /// An OpenMP-IR-Builder instance.
+  llvm::OpenMPIRBuilder OMPBuilder;
+
   /// Constructor allowing to redefine the name separator for the variables.
   explicit CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator,
StringRef Separator);
@@ -386,8 +389,6 @@ class CGOpenMPRuntime {
   llvm::Value *getCriticalRegionLock(StringRef CriticalName);
 
 private:
-  /// An OpenMP-IR-Builder instance.
-  llvm::OpenMPIRBuilder OMPBuilder;
 
   /// Map for SourceLocation and OpenMP runtime library debug locations.
   typedef llvm::DenseMap OpenMPDebugLocMapTy;

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 5d1856f4f5e7..3c4849aa0970 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -28,97 +28,6 @@ using namespace CodeGen;
 using namespace llvm::omp;
 
 namespace {
-enum OpenMPRTLFunctionNVPTX {
-  /// Call to void __kmpc_kernel_init(kmp_int32 thread_limit,
-  /// int16_t RequiresOMPRuntime);
-  OMPRTL_NVPTX__kmpc_kernel_init,
-  /// Call to void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized);
-  OMPRTL_NVPTX__kmpc_kernel_deinit,
-  /// Call to void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
-  /// int16_t RequiresOMPRuntime);
-  OMPRTL_NVPTX__kmpc_spmd_kernel_init,
-  /// Call to void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime);
-  OMPRTL_NVPTX__kmpc_spmd_kernel_deinit_v2,
-  /// Call to void __kmpc_kernel_prepare_parallel(void
-  /// *outlined_function);
-  OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
-  /// Call to bool __kmpc_kernel_parallel(void **outlined_function);
-  OMPRTL_NVPTX__kmpc_kernel_parallel,
-  /// Call to void __kmpc_kernel_end_parallel();
-  OMPRTL_NVPTX__kmpc_kernel_end_parallel,
-  /// Call to void __kmpc_serialized_parallel(ident_t *loc, kmp_int32
-  /// global_tid);
-  OMPRTL_NVPTX__kmpc_serialized_parallel,
-  /// Call to void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32
-  /// global_tid);
-  OMPRTL_NVPTX__kmpc_end_serialized_parallel,
-  /// Call to int32_t __kmpc_shuffle_int32(int32_t element,
-  /// int16_t lane_offset, int16_t warp_size);
-  OMPRTL_NVPTX__kmpc_shuffle_int32,
-  /// Call to int64_t __kmpc_shuffle_int64(int64_t element,
-  /// int16_t lane_offset, int16_t warp_size);
-  OMPRTL_NVPTX__kmpc_shuffle_int64,
-  /// Call to __kmpc_nvptx_parallel_reduce_nowait_v2(ident_t *loc, kmp_int32
-  /// global_tid, kmp_int32 num_vars, size_t reduce_size, void* reduce_data,
-  /// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
-  /// lane_offset, int16_t shortCircuit),
-  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
-  OMPRTL_NVPTX__kmpc_nvptx_parallel_reduce_nowait_v2,
-  /// Call to __kmpc_nvptx_teams_reduce_nowait_v2(ident_t *loc, kmp_int32
-  /// global_tid, void *global_buffer, int32_t num_of_records, void*
-  /// reduce_data,
-  /// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
-  /// lane_offset, int16_t shortCircuit),
-  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num), void
-  /// (*kmp_ListToGlobalCpyFctPtr)(void *buffer, int idx, void *reduce_data),
-  /// void (*kmp_GlobalToListCpyFctPtr)(void *buffer, int idx,
-  /// void *reduce_data), void (*kmp_GlobalToListCpyPtrsFctPtr)(void *buffer,
-  /// int idx, void

[PATCH] D88936: [HWAsan][NewPM] Handle hwasan like other sanitizers

2020-10-08 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

To what extent does the IR change? My only concern is the right codegen is 
still produced.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88936

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


[PATCH] D88936: [HWAsan][NewPM] Handle hwasan like other sanitizers

2020-10-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

diff for hwasan + -O1:

14a15

> @__hwasan_shadow = external global [0 x i8]

72a74,109

> declare void @__hwasan_loadN(i64, i64)
>
> declare void @__hwasan_load1(i64)
>
> declare void @__hwasan_load2(i64)
>
> declare void @__hwasan_load4(i64)
>
> declare void @__hwasan_load8(i64)
>
> declare void @__hwasan_load16(i64)
>
> declare void @__hwasan_storeN(i64, i64)
>
> declare void @__hwasan_store1(i64)
>
> declare void @__hwasan_store2(i64)
>
> declare void @__hwasan_store4(i64)
>
> declare void @__hwasan_store8(i64)
>
> declare void @__hwasan_store16(i64)
>
> declare void @__hwasan_tag_memory(i8*, i8, i64)
>
> declare i8 @__hwasan_generate_tag()
>
> declare i8* @__hwasan_memmove(i8*, i8*, i64)
>
> declare i8* @__hwasan_memcpy(i8*, i8*, i64)
>
> declare i8* @__hwasan_memset(i8*, i32, i64)
>
> declare void @__hwasan_handle_vfork(i64)

diff for khwasan + -O1:

7a8

> @__hwasan_shadow = external global [0 x i8]

34,35c35,36
<   call void asm sideeffect "int3\0Anopl 66(%rax)", "{rdi}"(i64 %4)

<   unreachable
---

>   call void asm sideeffect "int3\0Anopl 98(%rax)", "{rdi}"(i64 %4)
>   br label %27

51c52

< 27:   ; preds = %22
-

> 27:   ; preds = %16, %22

60a62,97

> declare void @__hwasan_loadN_noabort(i64, i64)
>
> declare void @__hwasan_load1_noabort(i64)
>
> declare void @__hwasan_load2_noabort(i64)
>
> declare void @__hwasan_load4_noabort(i64)
>
> declare void @__hwasan_load8_noabort(i64)
>
> declare void @__hwasan_load16_noabort(i64)
>
> declare void @__hwasan_storeN_noabort(i64, i64)
>
> declare void @__hwasan_store1_noabort(i64)
>
> declare void @__hwasan_store2_noabort(i64)
>
> declare void @__hwasan_store4_noabort(i64)
>
> declare void @__hwasan_store8_noabort(i64)
>
> declare void @__hwasan_store16_noabort(i64)
>
> declare void @__hwasan_tag_memory(i8*, i8, i64)
>
> declare i8 @__hwasan_generate_tag()
>
> declare i8* @memmove(i8*, i8*, i64)
>
> declare i8* @memcpy(i8*, i8*, i64)
>
> declare i8* @memset(i8*, i32, i64)

Looks like the IR is the (mostly) same, just some declarations cleaned up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88936

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


[libunwind] 504bc07 - [runtimes] Use int main(int, char**) consistently in tests

2020-10-08 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-10-08T14:28:13-04:00
New Revision: 504bc07d1afc7bad7b980a977141696ec8298e7e

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

LOG: [runtimes] Use int main(int, char**) consistently in tests

This is needed when running the tests in Freestanding mode, where main()
isn't treated specially. In Freestanding, main() doesn't get mangled as
extern "C", so whatever runtime we're using fails to find the entry point.

One way to solve this problem is to define a symbol alias from __Z4mainiPPc
to _main, however this requires all definitions of main() to have the same
mangling. Hence this commit.

Added: 

libcxx/test/std/strings/string.view/string.view.io/stream_insert_decl_present.compile.pass.cpp
libunwind/test/alignment.compile.pass.cpp

Modified: 
libcxx/test/libcxx/depr/depr.c.headers/math_h.compile.pass.cpp
libcxx/test/libcxx/depr/depr.c.headers/stdint_h.std_types_t.compile.pass.cpp

libcxx/test/libcxx/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp

libcxx/test/libcxx/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp

libcxx/test/libcxx/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp
libcxx/test/libcxx/min_max_macros.compile.pass.cpp
libcxx/test/libcxx/no_assert_include.compile.pass.cpp
libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp
libcxx/test/libcxx/selftest/compile.fail.cpp/compile-error.compile.fail.cpp

libcxx/test/libcxx/selftest/compile.fail.cpp/compile-success.compile.fail.cpp
libcxx/test/libcxx/selftest/compile.pass.cpp/compile-error.compile.pass.cpp

libcxx/test/libcxx/selftest/compile.pass.cpp/compile-success.compile.pass.cpp
libcxx/test/libcxx/selftest/compile.pass.cpp/link-error.compile.pass.cpp
libcxx/test/libcxx/selftest/compile.pass.cpp/run-error.compile.pass.cpp
libcxx/test/libcxx/selftest/fail.cpp/compile-success.fail.cpp
libcxx/test/libcxx/selftest/fail.cpp/no-diagnostics-unmarked.fail.cpp
libcxx/test/libcxx/selftest/fail.cpp/right-diagnostic.fail.cpp
libcxx/test/libcxx/selftest/fail.cpp/wrong-diagnostic.fail.cpp
libcxx/test/libcxx/selftest/link.fail.cpp/compile-error.link.fail.cpp
libcxx/test/libcxx/selftest/link.fail.cpp/link-error.link.fail.cpp
libcxx/test/libcxx/selftest/link.fail.cpp/link-success.link.fail.cpp
libcxx/test/libcxx/selftest/link.pass.cpp/compile-error.link.pass.cpp
libcxx/test/libcxx/selftest/link.pass.cpp/link-error.link.pass.cpp
libcxx/test/libcxx/selftest/link.pass.cpp/link-success.link.pass.cpp
libcxx/test/libcxx/selftest/link.pass.cpp/run-error.link.pass.cpp
libcxx/test/libcxx/selftest/pass.cpp/compile-error.pass.cpp
libcxx/test/libcxx/selftest/pass.cpp/link-error.pass.cpp
libcxx/test/libcxx/selftest/pass.cpp/run-error.pass.cpp
libcxx/test/libcxx/selftest/pass.cpp/run-success.pass.cpp
libcxx/test/libcxx/selftest/pass.cpp/werror.pass.cpp
libcxx/test/libcxx/selftest/pass.mm/compile-error.pass.mm
libcxx/test/libcxx/selftest/pass.mm/link-error.pass.mm
libcxx/test/libcxx/selftest/pass.mm/no-arc.pass.mm
libcxx/test/libcxx/selftest/pass.mm/run-error.pass.mm
libcxx/test/libcxx/selftest/pass.mm/run-success.pass.mm
libcxx/test/libcxx/selftest/pass.mm/use-objective-cxx.pass.mm
libcxx/test/libcxx/selftest/run.fail.cpp/compile-error.run.fail.cpp
libcxx/test/libcxx/selftest/run.fail.cpp/link-error.run.fail.cpp
libcxx/test/libcxx/selftest/run.fail.cpp/run-error.run.fail.cpp
libcxx/test/libcxx/selftest/run.fail.cpp/run-success.run.fail.cpp
libcxx/test/libcxx/selftest/sh.cpp/werror.sh.cpp
libcxx/test/libcxx/selftest/verify.cpp/no-diagnostics-unmarked.verify.cpp
libcxx/test/libcxx/selftest/verify.cpp/no-werror.verify.cpp
libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp

libcxx/test/libcxx/utilities/function.objects/abi_bug_cxx03_cxx11_example.sh.cpp

libcxx/test/libcxx/utilities/function.objects/func.wrap/depr_in_cxx03.verify.cpp

libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp

libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
libcxx/test/std/input.output/iostream.objects/init.pass.cpp

libcxx/test/std/language.support/support.dynamic/destroying_delete_t.pass.cpp

libcxx/test/std/language.support/support.dynamic/destroying_delete_t_declaration.pass.cpp
libcxx/test/std/namespace/addressable_functions.sh.cpp
libcxx/test/std/numerics/bit/bit.pow.two/ceil2.fail.cpp
libcxx/test/std/numerics/bit/bit.pow.two/ceil2.pass.cpp
libcxx/test/std/numerics/bit/bit.pow.two/floor2.pass.cpp
libcxx/test/std/numerics/bit/bit.pow.two/ispow2.pass.cpp
libcxx/test/std/numerics/bit/bit.pow.two/log2p1.pass.cpp
libcxx/test/std/numerics/bit/bit

[PATCH] D88936: [HWAsan][NewPM] Handle hwasan like other sanitizers

2020-10-08 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

I see. LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88936

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


[PATCH] D88314: Added llvm-string-referencing check

2020-10-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this check! Have you run the check over LLVM to see 
how much it reports? One of the concerns I have with this is that it's not 
always appropriate to replace a `const std::string&` with an `llvm::StringRef` 
and so I'm wondering what the "false positive" rate is for the check. For 
instance, there are `std::string` member functions that don't exist on 
`StringRef` so the fix-it will introduce compile errors, or switching the 
parameter type will cause additional unnecessary conversions.




Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp:23
+void StringReferencingCheck::registerMatchers(MatchFinder *Finder) {
+  // create a matcher looking for const std::string& parameters
+  auto Matcher =

Comments should be grammatical with capital letters and punctuation (here and 
elsewhere in the patch).

Also, I don't think we should register this check for the handful of C files.



Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp:25
+  auto Matcher =
+  parmVarDecl(hasType(references(namedDecl(
+  hasName("string"), isInStdNamespace(, // std::string&

Do we want to ignore parameters of a virtual function under the assumption that 
changing the parameter type may be dangerous?



Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp:26
+  parmVarDecl(hasType(references(namedDecl(
+  hasName("string"), isInStdNamespace(, // std::string&
+  hasType(references(qualType(isConstQualified(, // const

Instead of checking `isInStdNamespace()`, you can use 
`hasName("::std::string")`.



Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp:35
+void StringReferencingCheck::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  Inserter.registerPreprocessor(PP);

You can elide the identifiers `SM` and `ModuleExpanderPP` to shorten the 
declaration (since the names aren't used anyway).



Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp:50
+  // Generate diagnostics and fix
+  diag(ParamBegin, "Use of const std::string & is discouraged in the LLVM "
+   "Programmer's Manual");

clang-tidy diagnostics are not supposed to be grammatical, so it should not 
start with a capital letter and shouldn't use terminating punctuation, etc. How 
about something like: `parameter of type 'const std::string &' could 
potentially be replaced with 'llvm::StringRef'`?



Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp:52
+   "Programmer's Manual");
+  diag(ParamBegin, "replace parameter %0 type with llvm::StringRef",
+   DiagnosticIDs::Note)

I don't think the note helps a whole lot, you could attach the fix-it to the 
warning itself. However, we usually only add a fix-it when we can be sure that 
the change will continue to compile and I don't know that's the case here.



Comment at: clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.h:26
+class StringReferencingCheck : public ClangTidyCheck {
+  const llvm::StringRef BoundNodeId = "string_reference";
+

I think this can be hidden in the implementation file rather than exposed in 
the header. Also, can you pick a more descriptive name, like `ParamID` or 
something?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvm-string-referencing.rst:6
+
+FIXME: Describe what patterns does the check detect and why. Give examples.

Can you add some documentation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88314

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


  1   2   >