[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-09-27 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

In https://reviews.llvm.org/D47233#1129810, @DHowett-MSFT wrote:

> We ran into some critical issues with this approach on x64. The pointers in 
> the exception record are supposed to be image-relative instead of absolute, 
> so I tried to make them absolute to libobjc2's load address, but I never 
> quite solved it.
>
> A slightly better-documented and cleaner version of the code you linked is 
> here 
> .


(For the reference of other people, since Dustin and I discussed this offline a 
while back)

This is fixed upstream.  We use a stack address as our base address and 
construct stack-variable-relative offsets.  This is safe to do because the only 
requirement for Win64 EH is that the pointers be relative to some arbitrary 
base and in the SEH model the throwing stack frame remains live until the last 
catch.


Repository:
  rC Clang

https://reviews.llvm.org/D47233



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


[PATCH] D52581: [AST] Revert mangling changes from r339428

2018-09-27 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

> I would have done the same for the GNUstep RTTI here, except I don't actually
>  see the code for that anywhere, and no tests seem to break either, so I
>  believe it's not upstreamed yet.

I'm not sure I understand this comment.  The compiler code is in LLVM and the 
tests that you've modified are the ones that would fail.  The corresponding 
code is upstreamed in the runtime, to generate EH metadata for the throw with 
the same mangling.  If you are going to change the mangling, please make sure 
that the existing mangling is preserved for EH when compiling for the GNUstep / 
Microsoft ABI on Windows.

I'm also deeply unconvinced by the idea that it's okay to have a `struct I` in 
one compilation unit and a `@class I` in another.  The `struct` version will 
not do any of the correct things with respect to memory management.  Code that 
has this idiom is very likely to be broken.


Repository:
  rC Clang

https://reviews.llvm.org/D52581



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


[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2018-09-27 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

The latest reland of this change still causes compilation crashes, see PR 
39094. I'll revert this change for now to fix compilation again.


Repository:
  rL LLVM

https://reviews.llvm.org/D45045



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


r343183 - Revert "[DebugInfo] Generate debug information for labels."

2018-09-27 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Sep 27 01:15:24 2018
New Revision: 343183

URL: http://llvm.org/viewvc/llvm-project?rev=343183&view=rev
Log:
Revert "[DebugInfo] Generate debug information for labels."

This reverts commit r343148.

It crashes on sanitizer-x86_64-linux-autoconf.

Removed:
cfe/trunk/test/CodeGen/debug-label-inline.c
cfe/trunk/test/CodeGen/debug-label.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=343183&r1=343182&r2=343183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 27 01:15:24 2018
@@ -3767,32 +3767,6 @@ CGDebugInfo::EmitDeclareOfAutoVariable(c
   return EmitDeclare(VD, Storage, llvm::None, Builder);
 }
 
-void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
-  assert(DebugKind >= codegenoptions::LimitedDebugInfo);
-  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
-
-  if (D->hasAttr())
-return;
-
-  auto *Scope = cast(LexicalBlockStack.back());
-  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
-
-  // Get location information.
-  unsigned Line = getLineNumber(D->getLocation());
-  unsigned Column = getColumnNumber(D->getLocation());
-
-  StringRef Name = D->getName();
-
-  // Create the descriptor for the label.
-  auto *L =
-  DBuilder.createLabel(Scope, Name, Unit, Line, 
CGM.getLangOpts().Optimize);
-
-  // Insert an llvm.dbg.label into the current block.
-  DBuilder.insertLabel(L,
-   llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
-   Builder.GetInsertBlock());
-}
-
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
   llvm::DIType *Ty) {
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=343183&r1=343182&r2=343183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Sep 27 01:15:24 2018
@@ -415,9 +415,6 @@ public:
llvm::Value *AI,
CGBuilderTy &Builder);
 
-  /// Emit call to \c llvm.dbg.label for an label.
-  void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder);
-
   /// Emit call to \c llvm.dbg.declare for an imported variable
   /// declaration in a block.
   void EmitDeclareOfBlockDeclRefVariable(

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=343183&r1=343182&r2=343183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Sep 27 01:15:24 2018
@@ -531,16 +531,6 @@ void CodeGenFunction::EmitLabel(const La
   }
 
   EmitBlock(Dest.getBlock());
-
-  // Emit debug info for labels.
-  if (CGDebugInfo *DI = getDebugInfo()) {
-if (CGM.getCodeGenOpts().getDebugInfo() >=
-codegenoptions::LimitedDebugInfo) {
-  DI->setLocation(D->getLocation());
-  DI->EmitLabel(D, Builder);
-}
-  }
-
   incrementProfileCounter(D->getStmt());
 }
 

Removed: cfe/trunk/test/CodeGen/debug-label-inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-label-inline.c?rev=343182&view=auto
==
--- cfe/trunk/test/CodeGen/debug-label-inline.c (original)
+++ cfe/trunk/test/CodeGen/debug-label-inline.c (removed)
@@ -1,28 +0,0 @@
-// This test will test the correctness of generating DILabel and
-// llvm.dbg.label when the label is in inlined functions.
-//
-// RUN: %clang_cc1 -O2 %s -o - -emit-llvm -debug-info-kind=limited | FileCheck 
%s
-inline int f1(int a, int b) {
-  int sum;
-
-top:
-  sum = a + b;
-  return sum;
-}
-
-extern int ga, gb;
-
-int f2(void) {
-  int result;
-
-  result = f1(ga, gb);
-  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg 
[[LABEL_LOCATION:!.*]]
-
-  return result;
-}
-
-// CHECK: distinct !DISubprogram(name: "f1", {{.*}}, retainedNodes: 
[[ELEMENTS:!.*]])
-// CHECK: [[ELEMENTS]] = !{{{.*}}, [[LABEL_METADATA]]}
-// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 8)
-// CHECK: [[INLINEDAT:!.*]] = distinct !DILocation(line: 18,
-// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 8, {{.*}}, inlinedAt: 
[[INLINEDAT]])

Removed: cfe/trunk/test/CodeGen/debug-label.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-label

[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2018-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka reopened this revision.
vitalybuka added a comment.

Reverted in r343183
https://bugs.llvm.org/show_bug.cgi?id=39094
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/29356/steps/build%20release%20tsan%20with%20clang/logs/stdio


Repository:
  rL LLVM

https://reviews.llvm.org/D45045



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


r343184 - [Sema] Handle __va_start for Windows/ARM64 in the same way as for ARM

2018-09-27 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Sep 27 01:24:15 2018
New Revision: 343184

URL: http://llvm.org/viewvc/llvm-project?rev=343184&view=rev
Log:
[Sema] Handle __va_start for Windows/ARM64 in the same way as for ARM

This fixes PR39090.

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/microsoft-varargs.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=343184&r1=343183&r2=343184&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 27 01:24:15 2018
@@ -929,6 +929,7 @@ Sema::CheckBuiltinFunctionCall(FunctionD
 break;
   case Builtin::BI__va_start: {
 switch (Context.getTargetInfo().getTriple().getArch()) {
+case llvm::Triple::aarch64:
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (SemaBuiltinVAStartARMMicrosoft(TheCall))

Modified: cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/microsoft-varargs.cpp?rev=343184&r1=343183&r2=343184&view=diff
==
--- cfe/trunk/test/SemaCXX/microsoft-varargs.cpp (original)
+++ cfe/trunk/test/SemaCXX/microsoft-varargs.cpp Thu Sep 27 01:24:15 2018
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s 
-verify
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only %s 
-verify
 // expected-no-diagnostics
 
 extern "C" {


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


[PATCH] D52571: [Sema] Handle __va_start for Windows/ARM64 in the same way as for ARM

2018-09-27 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343184: [Sema] Handle __va_start for Windows/ARM64 in the 
same way as for ARM (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52571?vs=167183&id=167244#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52571

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/SemaCXX/microsoft-varargs.cpp


Index: cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
===
--- cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
+++ cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s 
-verify
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only %s 
-verify
 // expected-no-diagnostics
 
 extern "C" {
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -929,6 +929,7 @@
 break;
   case Builtin::BI__va_start: {
 switch (Context.getTargetInfo().getTriple().getArch()) {
+case llvm::Triple::aarch64:
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (SemaBuiltinVAStartARMMicrosoft(TheCall))


Index: cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
===
--- cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
+++ cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only %s -verify
 // expected-no-diagnostics
 
 extern "C" {
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -929,6 +929,7 @@
 break;
   case Builtin::BI__va_start: {
 switch (Context.getTargetInfo().getTriple().getArch()) {
+case llvm::Triple::aarch64:
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (SemaBuiltinVAStartARMMicrosoft(TheCall))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52544: Improve diagnostics range reporting.

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/Diagnostics.cpp:55
   // Accept the first range that contains the location.
+  llvm::Optional PossibleRange;
   for (const auto &CR : D.getRanges()) {

nit: Maybe `FallbackRange`?



Comment at: unittests/clangd/ClangdUnitTests.cpp:82
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();

What is this `//with comments` for? Maybe explain it in the comment if it does 
something?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52544



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


[PATCH] D52589: [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: vsk, vitalybuka, filcab.

Repository:
  rC Clang

https://reviews.llvm.org/D52589

Files:
  test/CodeGen/catch-implicit-integer-conversions-basics.c
  test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-integer-truncations-basics.c
  test/CodeGen/catch-implicit-integer-truncations.c

Index: test/CodeGen/catch-implicit-integer-truncations.c
===
--- test/CodeGen/catch-implicit-integer-truncations.c
+++ test/CodeGen/catch-implicit-integer-truncations.c
@@ -6,16 +6,16 @@
 // CHECK-SANITIZE-ANYRECOVER: @[[UNSIGNED_INT:.*]] = {{.*}} c"'unsigned int'\00" }
 // CHECK-SANITIZE-ANYRECOVER: @[[UNSIGNED_CHAR:.*]] = {{.*}} c"'unsigned char'\00" }
 
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}* @[[UNSIGNED_INT]], {{.*}}* @[[UNSIGNED_CHAR]], i8 0 }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_TRUNCATION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}* @[[UNSIGNED_INT]], {{.*}}* @[[UNSIGNED_CHAR]], i8 0 }
 // CHECK-SANITIZE-ANYRECOVER: @[[SIGNED_INT:.*]] = {{.*}} c"'int'\00" }
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 }, {{.*}}* @[[SIGNED_INT]], {{.*}}* @[[UNSIGNED_CHAR]], i8 0 }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_200_TRUNCATION:.*]] = {{.*}}, i32 200, i32 10 }, {{.*}}* @[[SIGNED_INT]], {{.*}}* @[[UNSIGNED_CHAR]], i8 0 }
 // CHECK-SANITIZE-ANYRECOVER: @[[SIGNED_CHAR:.*]] = {{.*}} c"'signed char'\00" }
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 10 }, {{.*}}* @[[UNSIGNED_INT]], {{.*}}* @[[SIGNED_CHAR]], i8 0 }
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 10 }, {{.*}}* @[[SIGNED_INT]], {{.*}}* @[[SIGNED_CHAR]], i8 0 }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_300_TRUNCATION:.*]] = {{.*}}, i32 300, i32 10 }, {{.*}}* @[[UNSIGNED_INT]], {{.*}}* @[[SIGNED_CHAR]], i8 0 }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_400_TRUNCATION:.*]] = {{.*}}, i32 400, i32 10 }, {{.*}}* @[[SIGNED_INT]], {{.*}}* @[[SIGNED_CHAR]], i8 0 }
 
 // CHECK-SANITIZE-ANYRECOVER: @[[UINT32:.*]] = {{.*}} c"'uint32_t' (aka 'unsigned int')\00" }
 // CHECK-SANITIZE-ANYRECOVER: @[[UINT8:.*]] = {{.*}} c"'uint8_t' (aka 'unsigned char')\00" }
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 }, {{.*}}* @[[UINT32]], {{.*}}* @[[UINT8]], i8 0 }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_500_TRUNCATION:.*]] = {{.*}}, i32 500, i32 10 }, {{.*}}* @[[UINT32]], {{.*}}* @[[UINT8]], i8 0 }
 
 // == //
 // The expected true-positives. These are implicit conversions, and they truncate.
@@ -30,8 +30,8 @@
   // CHECK-SANITIZE: [[HANDLER_IMPLICIT_CONVERSION]]:
   // CHECK-SANITIZE-ANYRECOVER-NEXT: %[[EXTSRC:.*]] = zext i32 %[[SRC]] to i64, !nosanitize
   // CHECK-SANITIZE-ANYRECOVER-NEXT: %[[EXTDST:.*]] = zext i8 %[[DST]] to i64, !nosanitize
-  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_100]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
-  // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_100]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_100_TRUNCATION]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_100_TRUNCATION]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
   // CHECK-SANITIZE-TRAP-NEXT: call void @llvm.trap(){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT: unreachable, !nosanitize
   // CHECK-SANITIZE: [[CONT]]:
@@ -50,8 +50,8 @@
   // CHECK-SANITIZE: [[HANDLER_IMPLICIT_CONVERSION]]:
   // CHECK-SANITIZE-ANYRECOVER-NEXT: %[[EXTSRC:.*]] = zext i32 %[[SRC]] to i64, !nosanitize
   // CHECK-SANITIZE-ANYRECOVER-NEXT: %[[EXTDST:.*]] = zext i8 %[[DST]] to i64, !nosanitize
-  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_200]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
-  // CHECK-SANITIZE-RECOVER-NEXT: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_200]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_200_TRUNCATION]] to i8*), i64 %[[EXTSRC]], i64 %[[EXTDST]]){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT: call void @__

[PATCH] D52591: Fix Bug 39067: The keyword "try" in C++ function-try-blocks doesn't obey BraceWrapping settings

2018-09-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: sammccall, klimek, djasper, krasimir.
Herald added a subscriber: cfe-commits.

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


Repository:
  rC Clang

https://reviews.llvm.org/D52591

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2628,6 +2628,16 @@
"  A(X x)\n"
"  try : t(0) {} catch (...) {}\n"
"};"));
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterFunction = true;
+  EXPECT_EQ("void f()\n"
+"try\n"
+"{\n"
+"}",
+format("void f() try {\n"
+   "}", Style));
   EXPECT_EQ("class SomeClass {\n"
 "public:\n"
 "  SomeClass() EXCLUSIVE_LOCK_FUNCTION(mu_);\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1266,6 +1266,8 @@
   break;
 case tok::kw_try:
   // We arrive here when parsing function-try blocks.
+  if (Style.BraceWrapping.AfterFunction)
+addUnwrappedLine();
   parseTryCatch();
   return;
 case tok::identifier: {


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2628,6 +2628,16 @@
"  A(X x)\n"
"  try : t(0) {} catch (...) {}\n"
"};"));
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterFunction = true;
+  EXPECT_EQ("void f()\n"
+"try\n"
+"{\n"
+"}",
+format("void f() try {\n"
+   "}", Style));
   EXPECT_EQ("class SomeClass {\n"
 "public:\n"
 "  SomeClass() EXCLUSIVE_LOCK_FUNCTION(mu_);\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1266,6 +1266,8 @@
   break;
 case tok::kw_try:
   // We arrive here when parsing function-try blocks.
+  if (Style.BraceWrapping.AfterFunction)
+addUnwrappedLine();
   parseTryCatch();
   return;
 case tok::identifier: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51686: [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 167250.
Hahnfeld marked 2 inline comments as done.
Hahnfeld added a comment.

Add `const` per review comments.


https://reviews.llvm.org/D51686

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -30,6 +30,22 @@
 
 /// ###
 
+/// Check that -lomptarget-nvptx is passed to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NVLINK %s
+/// Check that the value of --libomptarget-nvptx-path is forwarded to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  --libomptarget-nvptx-path=/path/to/libomptarget/ \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHK-NVLINK,CHK-LIBOMPTARGET-NVPTX-PATH %s
+
+// CHK-NVLINK: nvlink
+// CHK-LIBOMPTARGET-NVPTX-PATH-SAME: "-L/path/to/libomptarget/"
+// CHK-NVLINK-SAME: "-lomptarget-nvptx"
+
+/// ###
+
 /// Check cubin file generation and usage by nvlink
 // RUN:   %clang -### -no-canonical-prefixes -target 
powerpc64le-unknown-linux-gnu -fopenmp=libomp \
 // RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
@@ -151,6 +167,11 @@
 // RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
 // RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+/// The user can override default detection using --libomptarget-nvptx-path=.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--libomptarget-nvptx-path=%S/Inputs/libomptarget \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
 // CHK-BCLIB-NOT: {{error:|warning:}}
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -511,6 +511,11 @@
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
+  // Assume that the directory specified with --libomptarget_nvptx_path
+  // contains the static library libomptarget-nvptx.a.
+  if (const Arg *A = Args.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("-L") + A->getValue()));
+
   // Add paths specified in LIBRARY_PATH environment variable as -L options.
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 
@@ -647,12 +652,9 @@
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
-// Add path to lib and/or lib64 folders.
-SmallString<256> DefaultLibPath =
-  llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath,
-Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+if (const Arg *A = 
DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+  LibraryPaths.push_back(A->getValue());
 
 // Add user defined library paths from LIBRARY_PATH.
 llvm::Optional LibPath =
@@ -665,6 +667,12 @@
 LibraryPaths.emplace_back(Path.trim());
 }
 
+// Add path to lib / lib64 folder.
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
 std::string LibOmpTargetName =
   "libomptarget-nvptx-" + GpuArch.str() + ".bc";
 bool FoundBCLibrary = false;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -596,6 +596,8 @@
   HelpText<"HIP device library">;
 def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def libomptarget_nvptx_path_EQ : Joined<["--"], "libomptarget-nvptx-path=">, 
Group,
+  HelpText<"Path to libomptarget-nvptx libraries">;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal output">;


Index: test/Driver/openmp-offload-gpu.c
=

[PATCH] D51686: [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:665
 
+// Add path to lib / lib64 folder.
+SmallString<256> DefaultLibPath =

Hahnfeld wrote:
> ABataev wrote:
> > You're changing the order of the lookup for the paths. Is this intended? If 
> > so, you need the test for this.
> Yes, that's explained in the summary.
> 
> I'll try to see if there is a way to test this, even if we can't expect 
> libomptarget-nvptx to be built together with Clang. At the moment I think 
> only `LIBRARY_PATH` is tested, I'm adding some for the new 
> `--libomptarget-nvptx-path`.
After some thoughts it seems impossible to reliably test this code path because 
the user can set `CLANG_LIBDIR_SUFFIX`.


https://reviews.llvm.org/D51686



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


[PATCH] D35170: [libcxx] Remove stray backticks from BuildingLibcxx.rst

2018-09-27 Thread Jakub Wilk via Phabricator via cfe-commits
jwilk added a comment.

Any reason this hasn't been merged yet?


https://reviews.llvm.org/D35170



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


[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 167255.
lebedev.ri marked 3 inline comments as done.
lebedev.ri added a comment.

- Split off the NFC preparatory changes.
- Rebased.


Repository:
  rC Clang

https://reviews.llvm.org/D50901

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/catch-implicit-integer-conversions-basics.c
  test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-integer-truncations-basics.c
  test/CodeGen/catch-implicit-integer-truncations.c
  test/CodeGen/catch-implicit-signed-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-signed-integer-truncations-basics.c
  test/CodeGen/catch-implicit-unsigned-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-unsigned-integer-truncations-basics.c
  test/CodeGenCXX/catch-implicit-integer-truncations.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -29,22 +29,37 @@
 // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope"
-// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-integer-truncation),?){6}"}}
+// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){7}"}}
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP
-// CHECK-implicit-conversion: "-fsanitize={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ???
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-implicit-conversion: "-fsanitize={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}} // ???
+// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-TRAP-NOT: "-fno-saniti

[PATCH] D52334: [clang-tidy] Build it even without static analyzer

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

There has been a commit that seems related: https://reviews.llvm.org/rL343168
@steveire could you please take a look at how it affects this patch?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334



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


[PATCH] D52595: [ARM] Alter test to account for change to armv6k default CPU

2018-09-27 Thread Peter Smith via Phabricator via cfe-commits
peter.smith created this revision.
peter.smith added reviewers: falstaff84, nickdesaulniers, rengolin, labrinea.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

Review https://reviews.llvm.org/D52594 will change the default in llvm for 
armv6k from the non-existent cpu arm1176jf-s to mpcore. The tests in 
arm-cortex-cpus.c need to be updated to account for this change.

The full discussion of why the change has been made can be found in 
https://reviews.llvm.org/D52594 and https://reviews.llvm.org/D18086


https://reviews.llvm.org/D52595

Files:
  test/Driver/arm-cortex-cpus.c


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -73,11 +73,11 @@
 
 // RUN: %clang -target armv6k -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K %s
 // RUN: %clang -target arm -march=armv6k -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K %s
-// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176j-s"
+// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "mpcore"
 
 // RUN: %clang -target armv6k -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K-THUMB %s
 // RUN: %clang -target arm -march=armv6k -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K-THUMB %s
-// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" 
"arm1176j-s"
+// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" 
"mpcore"
 
 // RUN: %clang -target armv6t2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6T2 %s
 // RUN: %clang -target arm -march=armv6t2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6T2 %s


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -73,11 +73,11 @@
 
 // RUN: %clang -target armv6k -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K %s
 // RUN: %clang -target arm -march=armv6k -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K %s
-// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176j-s"
+// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "mpcore"
 
 // RUN: %clang -target armv6k -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K-THUMB %s
 // RUN: %clang -target arm -march=armv6k -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K-THUMB %s
-// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" "arm1176j-s"
+// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" "mpcore"
 
 // RUN: %clang -target armv6t2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6T2 %s
 // RUN: %clang -target arm -march=armv6t2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6T2 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52047: [clangd] Add building benchmark and memory consumption tracking

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 167267.
kbobyrev added a comment.

Pass data from I/O to `readIndexFile(StringRef)`.


https://reviews.llvm.org/D52047

Files:
  clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp

Index: clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
===
--- clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
+++ clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
@@ -12,6 +12,7 @@
 #include "benchmark/benchmark.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -33,6 +34,25 @@
   return loadIndex(IndexFilename, {}, true);
 }
 
+SymbolSlab loadSlab() {
+  auto Buffer = llvm::MemoryBuffer::getFile(IndexFilename);
+  if (!Buffer) {
+llvm::errs() << "Can't open " << IndexFilename << '\n';
+exit(1);
+  }
+
+  auto Slab = readIndexFile((*Buffer)->getBuffer());
+  if (!Slab) {
+llvm::errs() << llvm::toString(Slab.takeError()) << '\n';
+exit(1);
+  } else if (!Slab->Symbols) {
+llvm::errs() << "Couldn't read symbol slab from the index file: "
+ << IndexFilename << '\n';
+exit(1);
+  }
+  return std::move(*Slab->Symbols);
+}
+
 // Reads JSON array of serialized FuzzyFindRequest's from user-provided file.
 std::vector extractQueriesFromLogs() {
   std::ifstream InputStream(RequestsFilename);
@@ -73,24 +93,81 @@
 for (const auto &Request : Requests)
   Mem->fuzzyFind(Request, [](const Symbol &S) {});
 }
-BENCHMARK(MemQueries);
+BENCHMARK(MemQueries)->Unit(benchmark::kMillisecond);
 
 static void DexQueries(benchmark::State &State) {
   const auto Dex = buildDex();
   const auto Requests = extractQueriesFromLogs();
   for (auto _ : State)
 for (const auto &Request : Requests)
   Dex->fuzzyFind(Request, [](const Symbol &S) {});
 }
-BENCHMARK(DexQueries);
+BENCHMARK(DexQueries)->Unit(benchmark::kMillisecond);
+
+// This is not a *real* benchmark: it shows size of built MemIndex (in bytes).
+// Same for the next "benchmark".
+// FIXME(kbobyrev): Track memory usage caused by different index parts:
+// SymbolSlab and RefSlabs, InverseIndex, PostingLists of different types for
+// Dex, etc.
+static void MemSize(benchmark::State &State) {
+  const auto Mem = buildMem();
+  for (auto _ : State)
+// Divide size of Mem by 1000 so that it will be correctly displayed in the
+// benchmark report (possible options for time units are ms, ns and us).
+State.SetIterationTime(/*double Seconds=*/Mem->estimateMemoryUsage() /
+   1000.0);
+  State.SetLabel("This tracks in-memory size of MemIndex (SymbolSlab + Index "
+ "overhead) in bytes");
+}
+BENCHMARK(MemSize)
+->UseManualTime()
+->Unit(benchmark::kMillisecond)
+->Iterations(1);
+
+static void DexSize(benchmark::State &State) {
+  const auto Dex = buildDex();
+
+  for (auto _ : State)
+State.SetIterationTime(Dex->estimateMemoryUsage() / 1000.0);
+  State.SetLabel("This tracks in-memory size of Dex (SymbolSlab + Index "
+ "overhead) in bytes");
+}
+BENCHMARK(DexSize)
+->UseManualTime()
+->Unit(benchmark::kMillisecond)
+->Iterations(1);
+
+static void DexOverhead(benchmark::State &State) {
+  const auto Slab = loadSlab();
+  const auto Dex = buildDex();
+  for (auto _ : State)
+State.SetIterationTime((Dex->estimateMemoryUsage() - Slab.bytes()) /
+   1000.0);
+  State.SetLabel("This tracks in-memory size of Dex Index overhead (and "
+ "excludes underlying SymbolSlab size) in bytes");
+}
+BENCHMARK(DexOverhead)
+->UseManualTime()
+->Unit(benchmark::kMillisecond)
+->Iterations(1);
+
+static void SymbolSlabLoading(benchmark::State &State) {
+  for (auto _ : State)
+benchmark::DoNotOptimize(loadSlab());
+}
+BENCHMARK(SymbolSlabLoading)->Unit(benchmark::kMillisecond);
+
+static void DexBuild(benchmark::State &State) {
+  auto Slab = loadSlab();
+  for (auto _ : State)
+benchmark::DoNotOptimize(dex::Dex::build(std::move(Slab), {}));
+}
+BENCHMARK(DexBuild)->Unit(benchmark::kMillisecond);
 
 } // namespace
 } // namespace clangd
 } // namespace clang
 
-// FIXME(kbobyrev): Add index building time benchmarks.
-// FIXME(kbobyrev): Add memory consumption "benchmarks" by manually measuring
-// in-memory index size and reporting it as time.
 // FIXME(kbobyrev): Create a logger wrapper to suppress debugging info printer.
 int main(int argc, char *argv[]) {
   if (argc < 3) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52549: [VFS] Add a VFS wrapper which avoids opening nonexistent files by reading dirs.

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

This looks like a great improvement. The design looks reasonable to me. The 
cache states were a bit confusing at first, but I think more documentation when 
polishing the prototype could help.

I'd be really interested in seeing some profiles before/after this optimization 
e.g. for clang or clangd.




Comment at: lib/Basic/AvoidStatsVFS.cpp:44
+
+class StatLessFS : public ProxyFileSystem {
+public:

`LessStatFS` sounds more accurate lol



Comment at: lib/Basic/AvoidStatsVFS.cpp:46
+public:
+  // In fact we only read a directory once we've wanted its contents several
+  // times. This avoids a common pattern:

The comment is very clear, but it's hard to tell how it relates to 
`ReadDirThreshold = 3`.



Comment at: lib/Basic/AvoidStatsVFS.cpp:186
+  //   - NormPath is a directory whose children can't be listed
+  bool populateCacheForDir(StringRef NormPath) {
+// First, just see if we have any work to do.

Is there any overhead for reading all parent directories, e.g. when directories 
are large? Or would they be read anyway somewhere else?


Repository:
  rC Clang

https://reviews.llvm.org/D52549



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


[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

LGTM, with a few nits and a question. Please wait a bit if @aaron.ballman or 
@george.karpenkov have any comments before committing.




Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:88
+bool isPointeeMutable(const Expr *Exp, const ASTContext &Context) {
+  if (const auto *PT = Exp->getType()->getAs()) {
+return !PT->getPointeeType().isConstant(Context);

you can elide the braces here



Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:101
+  return false;
+// Check whether returning non-const reference.
+if (const auto *RT =

Please make this a full sentence (adding `... the overloaded 'operator*' is 
returning ...` is enough.)



Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:227
+  // `Exp` can be *directly* mutated if the type of `Exp` is not const.
+  // Bail out early otherwise.
+  if (Exp->getType().isConstant(Context))

This comment is one sentence, just replace `const. Bail` with `const, bail`



Comment at: unittests/Analysis/ExprMutationAnalyzerTest.cpp:87
+  EXPECT_TRUE(isPointeeMutated(Results, AST));
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);

pointer is `const`, please remove the last `const`



Comment at: unittests/Analysis/ExprMutationAnalyzerTest.cpp:645
+  // TODO: this should work when casts of pointers are handled.
+  // EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "return x;");
 

I am confused. The `const int*` guarantees, that `x`-pointee is not mutated. 
Why shall this be diagnosed as a mutation?


Repository:
  rC Clang

https://reviews.llvm.org/D52219



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


[PATCH] D52598: [OpenCL] Fixed address space cast in C style cast of C++ parsing

2018-09-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, yaxunl.

C style cast in OpenCL C++ was ignoring the address space conversions from 
OpenCL C and as a result accepting incorrect code to compile. This commit adds 
correctness checking for address spaces. This makes all OpenCL C address space 
conversion tests from Sema passing in `-cl-std=c++` mode too. Error messages 
have to be changed to C++ style in multiple places, but semantics of the 
diagnostics stay the same.

**Note:** this doesn't fix C++ cast operators. OpenCL C++ s3.4.4 defines 
special address space cast operators that align with C++'s philosophy of safe 
casts. The motivation behind this is that address space casts might require 
address translation (denoted by the `addrspacecast` IR instruction). In order 
to avoid operations modifying the type or constness together with translation 
of addresses, a separate cast operator is introduced. We might still have to 
fix the semantics of address spaces in `static_cast`, `reinterpret_cast` and 
`const_cast` but it's currently unclear to me. I will address this as a 
separate patch.


https://reviews.llvm.org/D52598

Files:
  lib/Sema/SemaCast.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -9,46 +9,47 @@
   __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}}
 
   int *ip;
-// FIXME: Temporarily disable part of the test that doesn't work for C++ yet.
-#if !__OPENCL_CPP_VERSION__
-#if __OPENCL_C_VERSION__ < 200
+#if ((!__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ < 200))
   ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}}
   ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}}
   ip = &ci; // expected-error {{assigning '__constant int *' to 'int *' changes address space of pointer}}
 #else
   ip = gip;
   ip = &li;
-  ip = &ci; // expected-error {{assigning '__constant int *' to '__generic int *' changes address space of pointer}}
+  ip = &ci;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{assigning '__constant int *' to '__generic int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{assigning to '__generic int *' from incompatible type '__constant int *'}}
+#endif
 #endif
 }
 
-void explicit_cast(global int* g, local int* l, constant int* c, private int* p, const constant int *cc)
-{
-  g = (global int*) l;// expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
-  g = (global int*) c;// expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
-  g = (global int*) cc;   // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
-  g = (global int*) p;// expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
+void explicit_cast(__global int *g, __local int *l, __constant int *c, __private int *p, const __constant int *cc) {
+  g = (__global int *)l;  // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
+  g = (__global int *)c;  // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
+  g = (__global int *)cc; // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
+  g = (__global int *)p;  // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
 
-  l = (local int*) g; // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
-  l = (local int*) c; // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
-  l = (local int*) cc;// expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
-  l = (local int*) p; // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)g;  // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)c;  // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)cc; // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)p;  // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
 
-  c = (constant int*) g;  // expected-error {{casting '__global int *' to type '__constant int *' changes address space

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:21
+
+#define PRINT_DEBUG 1
+

kbobyrev wrote:
> Do you plan to submit the patch with debugging messages or are you just using 
> these for better local debugging experience?
> 
> If you plan to upload the patch with the messages, please use `LLVM_DEBUG` 
> (see `readability/IdentifierNamingCheck.cpp` for reference) and 
> `llvm::dbgs()` ([[ 
> https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden | 
> `` traits shouldn't be used ]] and should be replaced with their 
> LLVM counterparts: `llvm::outs()`, `llvm::errs()`, etc). Also, I believe the 
> messages should be more informative if you think debug info is really 
> important here.
No, they will be removed, just for the current prototyping. using `llvm::outs` 
and `llvm::errs` would have been better though ;)



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:323
+
+static std::string &TrimRight(std::string &str) {
+  auto it1 = std::find_if(str.rbegin(), str.rend(), [](char ch) {

kbobyrev wrote:
> `llvm::StringRef::rtrim()`?
> 
> Also, naming `str` should be at least `Str`, `it1` -> `It`, `ch` -> `Ch` (or 
> better `Symbol`) ...
`rtrim()` is a better fit, but introduces another copy. Do you think I should 
rater use `llvm::SmallString`?



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:331
+
+static std::string Concat(const std::vector &Decls,
+  StringRef Indent) {

kbobyrev wrote:
> Use `llvm::join` with `";\n" + Indent` as the `Separator`?
Yup, didn't know that one yet, thanks :)



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

kbobyrev wrote:
> How about `multiple declarations within a single statement hurts readability`?
s/hurts/reduces/? hurts sound a bit weird i think.

Lebedev wanted the number of decls in the diagnostic, would you include it or 
rather now?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167270.
JonasToth marked 6 inline comments as done.
JonasToth added a comment.

- move lexer stuff into LexerUtils
- remove custom string handling function
- address review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,354 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = &i;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = &i;
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 5 variables
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), TT2{42}, TT3;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+  // CHECK-FIXES: TemplatedType TT1(42);
+  // CHECK-FIXES: {{^  }}TemplatedType TT2{42};
+  // CHECK-FIXES: {{^  }}TemplatedType TT3;
+  //
+  TemplatedType *TT4(nullptr), TT5, **TT6 = nullptr, *const *const TT7{nullptr};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // TODO Fix this
+  // CHECK FIXES: TemplatedType *TT4(nullptr);
+  // CHECK FIXES: {{^  }}TemplatedType TT5;
+  // CHECK FIXES: {{^  }}TemplatedType **TT6 = nullptr;
+  // CHECK FIXES: {{^  }}TemplatedType *const *const TT7{nullptr};
+
+  TemplatedType **TT8(nullptr), TT9;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // TODO Fix this
+}
+
+void forbidden_transformations() {
+  for (int i = 0, j = 42; i < j; ++i)
+;
+}
+
+#define NULL 0
+#define MY_NICE_TYPE int **
+#define VAR_NAME(name) name##__LINE__
+#define A_BUNCH_OF_VARIABLES int m1 = 42, m2 = 43, m3 = 44;
+
+void macros() {
+  int *p1 = NULL, *p2 = NULL;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: in

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167282.
JonasToth marked 3 inline comments as done.
JonasToth added a comment.

- add space after clang-tidy in banner
- refactor slightly, add better in-code comments to explain whats happening, 
add more TODOs and FIXMEs


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,356 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = &i;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = &i;
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 5 variables
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), TT2{42}, TT3;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 3 variables
+  // CHECK-FIXES: TemplatedType TT1(42);
+  // CHECK-FIXES: {{^  }}TemplatedType TT2{42};
+  // CHECK-FIXES: {{^  }}TemplatedType TT3;
+  //
+  TemplatedType *TT4(nullptr), TT5, **TT6 = nullptr, *const *const TT7{nullptr};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 4 variables
+  // CHECK-FIXES: TemplatedType *TT4(nullptr);
+  // CHECK-FIXES: {{^  }}TemplatedType TT5;
+  // CHECK-FIXES: {{^  }}TemplatedType **TT6 = nullptr;
+  // CHECK-FIXES: {{^  }}TemplatedType *const *const TT7{nullptr};
+
+  TemplatedType **TT8(nullptr), *TT9;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: this statement declares 2 variables
+  // CHECK-FIXES: TemplatedType **T8(nullptr);
+  // CHECK-FIXES: {{^  }}TemplatedType *TT9;
+}
+
+void forbidden_transformations() {
+  for (int i = 0, j = 42; i < j; ++i)
+;
+}
+
+#define NULL 0
+#define MY_NICE_TYPE int **
+#define VAR_NAME(name) name##__LINE__
+#define A_BUNCH_OF_VARIABLES int m1 = 42, m2 = 43, m3 = 44;
+
+void macros() {
+  int *p1 = NULL, *p2 = NULL;
+  // C

[PATCH] D52544: Improve diagnostics range reporting.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: unittests/clangd/ClangdUnitTests.cpp:82
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();

ioeric wrote:
> What is this `//with comments` for? Maybe explain it in the comment if it 
> does something?
In the previous implementation we were highlighting the "//with comments" as it 
was the token at that location. But since this is an insertion and we are not 
going to replace that token it seemed confusing to highlight all the comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52544



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


[PATCH] D52544: Improve diagnostics range reporting.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 167283.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52544

Files:
  clangd/Diagnostics.cpp
  unittests/clangd/ClangdUnitTests.cpp


Index: unittests/clangd/ClangdUnitTests.cpp
===
--- unittests/clangd/ClangdUnitTests.cpp
+++ unittests/clangd/ClangdUnitTests.cpp
@@ -79,8 +79,9 @@
 int main() {
   $typo[[go\
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();
+  double bar = $type[["foo"]];
 }
   )cpp");
   EXPECT_THAT(
@@ -93,11 +94,16 @@
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 
'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
-  // This range is zero-width, and at the end of a line.
+  // This range is zero-width and insertion. Therefore make sure we are
+  // not expanding it into other tokens. Since we are not going to
+  // replace those.
   AllOf(Diag(Test.range("semicolon"), "expected ';' after expression"),
 WithFix(Fix(Test.range("semicolon"), ";", "insert ';'"))),
   // This range isn't provided by clang, we expand to the token.
-  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'")));
+  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'"),
+  Diag(Test.range("type"),
+   "cannot initialize a variable of type 'double' with an lvalue "
+   "of type 'const char [4]'")));
 }
 
 TEST(DiagnosticsTest, FlagsMatter) {
Index: clangd/Diagnostics.cpp
===
--- clangd/Diagnostics.cpp
+++ clangd/Diagnostics.cpp
@@ -52,17 +52,28 @@
   auto &M = D.getSourceManager();
   auto Loc = M.getFileLoc(D.getLocation());
   // Accept the first range that contains the location.
+  llvm::Optional FallbackRange;
   for (const auto &CR : D.getRanges()) {
 auto R = Lexer::makeFileCharRange(CR, M, L);
 if (locationInRange(Loc, R, M))
   return halfOpenToRange(M, R);
+// If there are no ranges that contain the location report the first range.
+if (!FallbackRange)
+  FallbackRange = halfOpenToRange(M, R);
   }
   // The range may be given as a fixit hint instead.
   for (const auto &F : D.getFixItHints()) {
 auto R = Lexer::makeFileCharRange(F.RemoveRange, M, L);
 if (locationInRange(Loc, R, M))
   return halfOpenToRange(M, R);
+// If there's a fixit that performs insertion, it has zero-width. Therefore
+// it can't contain the location of the diag, but it might be possible that
+// this should be reported as range. For example missing semicolon.
+if (!FallbackRange && R.getBegin() == R.getEnd())
+  FallbackRange = halfOpenToRange(M, R);
   }
+  if (FallbackRange)
+return *FallbackRange;
   // If no suitable range is found, just use the token at the location.
   auto R = Lexer::makeFileCharRange(CharSourceRange::getTokenRange(Loc), M, L);
   if (!R.isValid()) // Fall back to location only, let the editor deal with it.


Index: unittests/clangd/ClangdUnitTests.cpp
===
--- unittests/clangd/ClangdUnitTests.cpp
+++ unittests/clangd/ClangdUnitTests.cpp
@@ -79,8 +79,9 @@
 int main() {
   $typo[[go\
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();
+  double bar = $type[["foo"]];
 }
   )cpp");
   EXPECT_THAT(
@@ -93,11 +94,16 @@
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
-  // This range is zero-width, and at the end of a line.
+  // This range is zero-width and insertion. Therefore make sure we are
+  // not expanding it into other tokens. Since we are not going to
+  // replace those.
   AllOf(Diag(Test.range("semicolon"), "expected ';' after expression"),
 WithFix(Fix(Test.range("semicolon"), ";", "insert ';'"))),
   // This range isn't provided by clang, we expand to the token.
-  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'")));
+  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'"),
+  Diag(Test.range("type"),
+   "cannot initialize a variable of type 'double' with an lvalue "
+   "of type 'const char [4]'")));
 }
 
 TEST(DiagnosticsTest, FlagsMatter) {
Index: clangd/Diagnostics.cpp
===
--- clangd/Diagnostics.cpp
+++ clangd/Diagnostics.cpp
@@ -52,17 +52,28 @@
   auto &M = D.getSo

[clang-tools-extra] r343197 - Improve diagnostics range reporting.

2018-09-27 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu Sep 27 05:12:42 2018
New Revision: 343197

URL: http://llvm.org/viewvc/llvm-project?rev=343197&view=rev
Log:
Improve diagnostics range reporting.

Summary:
If we have some range information coming from clang diagnostic, promote
that one even if it doesn't contain diagnostic location inside.

Reviewers: sammccall, ioeric

Reviewed By: ioeric

Subscribers: ilya-biryukov, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp

Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=343197&r1=343196&r2=343197&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Thu Sep 27 05:12:42 2018
@@ -52,17 +52,28 @@ Range diagnosticRange(const clang::Diagn
   auto &M = D.getSourceManager();
   auto Loc = M.getFileLoc(D.getLocation());
   // Accept the first range that contains the location.
+  llvm::Optional FallbackRange;
   for (const auto &CR : D.getRanges()) {
 auto R = Lexer::makeFileCharRange(CR, M, L);
 if (locationInRange(Loc, R, M))
   return halfOpenToRange(M, R);
+// If there are no ranges that contain the location report the first range.
+if (!FallbackRange)
+  FallbackRange = halfOpenToRange(M, R);
   }
   // The range may be given as a fixit hint instead.
   for (const auto &F : D.getFixItHints()) {
 auto R = Lexer::makeFileCharRange(F.RemoveRange, M, L);
 if (locationInRange(Loc, R, M))
   return halfOpenToRange(M, R);
+// If there's a fixit that performs insertion, it has zero-width. Therefore
+// it can't contain the location of the diag, but it might be possible that
+// this should be reported as range. For example missing semicolon.
+if (!FallbackRange && R.getBegin() == R.getEnd())
+  FallbackRange = halfOpenToRange(M, R);
   }
+  if (FallbackRange)
+return *FallbackRange;
   // If no suitable range is found, just use the token at the location.
   auto R = Lexer::makeFileCharRange(CharSourceRange::getTokenRange(Loc), M, L);
   if (!R.isValid()) // Fall back to location only, let the editor deal with it.

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp?rev=343197&r1=343196&r2=343197&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp Thu Sep 27 
05:12:42 2018
@@ -79,8 +79,9 @@ TEST(DiagnosticsTest, DiagnosticRanges)
 int main() {
   $typo[[go\
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();
+  double bar = $type[["foo"]];
 }
   )cpp");
   EXPECT_THAT(
@@ -93,11 +94,16 @@ o]]();
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 
'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
-  // This range is zero-width, and at the end of a line.
+  // This range is zero-width and insertion. Therefore make sure we are
+  // not expanding it into other tokens. Since we are not going to
+  // replace those.
   AllOf(Diag(Test.range("semicolon"), "expected ';' after expression"),
 WithFix(Fix(Test.range("semicolon"), ";", "insert ';'"))),
   // This range isn't provided by clang, we expand to the token.
-  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'")));
+  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'"),
+  Diag(Test.range("type"),
+   "cannot initialize a variable of type 'double' with an lvalue "
+   "of type 'const char [4]'")));
 }
 
 TEST(DiagnosticsTest, FlagsMatter) {


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


[PATCH] D52544: Improve diagnostics range reporting.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343197: Improve diagnostics range reporting. (authored by 
kadircet, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52544

Files:
  clang-tools-extra/trunk/clangd/Diagnostics.cpp
  clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
@@ -79,8 +79,9 @@
 int main() {
   $typo[[go\
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();
+  double bar = $type[["foo"]];
 }
   )cpp");
   EXPECT_THAT(
@@ -93,11 +94,16 @@
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 
'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
-  // This range is zero-width, and at the end of a line.
+  // This range is zero-width and insertion. Therefore make sure we are
+  // not expanding it into other tokens. Since we are not going to
+  // replace those.
   AllOf(Diag(Test.range("semicolon"), "expected ';' after expression"),
 WithFix(Fix(Test.range("semicolon"), ";", "insert ';'"))),
   // This range isn't provided by clang, we expand to the token.
-  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'")));
+  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'"),
+  Diag(Test.range("type"),
+   "cannot initialize a variable of type 'double' with an lvalue "
+   "of type 'const char [4]'")));
 }
 
 TEST(DiagnosticsTest, FlagsMatter) {
Index: clang-tools-extra/trunk/clangd/Diagnostics.cpp
===
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp
@@ -52,17 +52,28 @@
   auto &M = D.getSourceManager();
   auto Loc = M.getFileLoc(D.getLocation());
   // Accept the first range that contains the location.
+  llvm::Optional FallbackRange;
   for (const auto &CR : D.getRanges()) {
 auto R = Lexer::makeFileCharRange(CR, M, L);
 if (locationInRange(Loc, R, M))
   return halfOpenToRange(M, R);
+// If there are no ranges that contain the location report the first range.
+if (!FallbackRange)
+  FallbackRange = halfOpenToRange(M, R);
   }
   // The range may be given as a fixit hint instead.
   for (const auto &F : D.getFixItHints()) {
 auto R = Lexer::makeFileCharRange(F.RemoveRange, M, L);
 if (locationInRange(Loc, R, M))
   return halfOpenToRange(M, R);
+// If there's a fixit that performs insertion, it has zero-width. Therefore
+// it can't contain the location of the diag, but it might be possible that
+// this should be reported as range. For example missing semicolon.
+if (!FallbackRange && R.getBegin() == R.getEnd())
+  FallbackRange = halfOpenToRange(M, R);
   }
+  if (FallbackRange)
+return *FallbackRange;
   // If no suitable range is found, just use the token at the location.
   auto R = Lexer::makeFileCharRange(CharSourceRange::getTokenRange(Loc), M, L);
   if (!R.isValid()) // Fall back to location only, let the editor deal with it.


Index: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
@@ -79,8 +79,9 @@
 int main() {
   $typo[[go\
 o]]();
-  foo()$semicolon[[]]
+  foo()$semicolon[[]]//with comments
   $unk[[unknown]]();
+  double bar = $type[["foo"]];
 }
   )cpp");
   EXPECT_THAT(
@@ -93,11 +94,16 @@
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
-  // This range is zero-width, and at the end of a line.
+  // This range is zero-width and insertion. Therefore make sure we are
+  // not expanding it into other tokens. Since we are not going to
+  // replace those.
   AllOf(Diag(Test.range("semicolon"), "expected ';' after expression"),
 WithFix(Fix(Test.range("semicolon"), ";", "insert ';'"))),
   // This range isn't provided by clang, we expand to the token.
-  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'")));
+  Diag(Test.range("unk"), "use of undeclared identifier 'unknown'"),
+  Diag(Test.range("type"),
+   "cannot initiali

[clang-tools-extra] r343198 - [clang-tidy] use CHECK-NOTES in tests for bugprone-forward-declaration-namespace

2018-09-27 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Thu Sep 27 05:17:59 2018
New Revision: 343198

URL: http://llvm.org/viewvc/llvm-project?rev=343198&view=rev
Log:
[clang-tidy] use CHECK-NOTES in tests for bugprone-forward-declaration-namespace

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: xazax.hun, cfe-commits

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

Modified:

clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp?rev=343198&r1=343197&r2=343198&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp
 Thu Sep 27 05:17:59 2018
@@ -3,19 +3,19 @@
 namespace {
 // This is a declaration in a wrong namespace.
 class T_A;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'na' [bugprone-forward-declaration-namespace]
-// CHECK-MESSAGES: note: a declaration of 'T_A' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but 
a definition with the same name 'T_A' found in another namespace '(global)' 
[bugprone-forward-declaration-namespace]
-// CHECK-MESSAGES: note: a definition of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'na' [bugprone-forward-declaration-namespace]
+// CHECK-NOTES: note: a declaration of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a 
definition with the same name 'T_A' found in another namespace '(global)' 
[bugprone-forward-declaration-namespace]
+// CHECK-NOTES: note: a definition of 'T_A' is found here
 }
 
 namespace na {
 // This is a declaration in a wrong namespace.
 class T_A;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'(anonymous)'
-// CHECK-MESSAGES: note: a declaration of 'T_A' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but 
a definition with the same name 'T_A' found in another namespace '(global)'
-// CHECK-MESSAGES: note: a definition of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'(anonymous)'
+// CHECK-NOTES: note: a declaration of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a 
definition with the same name 'T_A' found in another namespace '(global)'
+// CHECK-NOTES: note: a definition of 'T_A' is found here
 }
 
 class T_A;
@@ -25,8 +25,8 @@ class T_A {
 };
 
 class NESTED;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: no definition found for 'NESTED', 
but a definition with the same name 'NESTED' found in another namespace 
'(anonymous namespace)::nq::(anonymous)'
-// CHECK-MESSAGES: note: a definition of 'NESTED' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: no definition found for 'NESTED', but 
a definition with the same name 'NESTED' found in another namespace '(anonymous 
namespace)::nq::(anonymous)'
+// CHECK-NOTES: note: a definition of 'NESTED' is found here
 
 namespace {
 namespace nq {
@@ -38,10 +38,10 @@ class NESTED {};
 
 namespace na {
 class T_B;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
-// CHECK-MESSAGES: note: a declaration of 'T_B' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but 
a definition with the same name 'T_B' found in another namespace 'nb'
-// CHECK-MESSAGES: note: a definition of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
+// CHECK-NOTES: note: a declaration of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but a 
definition with the same name 'T_B' found in another namespace 'nb'
+// CHECK-NOTES: note: a definition of 'T_B' is found here
 }
 
 namespace nb {
@@ -56,10 +56,10 @@ class T_B {
 
 namespace na {
 class T_B;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
-// CHECK-MESSAGES: note: a declaration of 'T_B' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but 
a defi

[PATCH] D52185: [clang-tidy] use CHECK-NOTES in tests for bugprone-forward-declaration-namespace

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343198: [clang-tidy] use CHECK-NOTES in tests for 
bugprone-forward-declaration-namespace (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52185

Files:
  
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-forward-declaration-namespace.cpp
@@ -3,19 +3,19 @@
 namespace {
 // This is a declaration in a wrong namespace.
 class T_A;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'na' [bugprone-forward-declaration-namespace]
-// CHECK-MESSAGES: note: a declaration of 'T_A' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but 
a definition with the same name 'T_A' found in another namespace '(global)' 
[bugprone-forward-declaration-namespace]
-// CHECK-MESSAGES: note: a definition of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'na' [bugprone-forward-declaration-namespace]
+// CHECK-NOTES: note: a declaration of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a 
definition with the same name 'T_A' found in another namespace '(global)' 
[bugprone-forward-declaration-namespace]
+// CHECK-NOTES: note: a definition of 'T_A' is found here
 }
 
 namespace na {
 // This is a declaration in a wrong namespace.
 class T_A;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'(anonymous)'
-// CHECK-MESSAGES: note: a declaration of 'T_A' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but 
a definition with the same name 'T_A' found in another namespace '(global)'
-// CHECK-MESSAGES: note: a definition of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_A' is never 
referenced, but a declaration with the same name found in another namespace 
'(anonymous)'
+// CHECK-NOTES: note: a declaration of 'T_A' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_A', but a 
definition with the same name 'T_A' found in another namespace '(global)'
+// CHECK-NOTES: note: a definition of 'T_A' is found here
 }
 
 class T_A;
@@ -25,8 +25,8 @@
 };
 
 class NESTED;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: no definition found for 'NESTED', 
but a definition with the same name 'NESTED' found in another namespace 
'(anonymous namespace)::nq::(anonymous)'
-// CHECK-MESSAGES: note: a definition of 'NESTED' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: no definition found for 'NESTED', but 
a definition with the same name 'NESTED' found in another namespace '(anonymous 
namespace)::nq::(anonymous)'
+// CHECK-NOTES: note: a definition of 'NESTED' is found here
 
 namespace {
 namespace nq {
@@ -38,10 +38,10 @@
 
 namespace na {
 class T_B;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
-// CHECK-MESSAGES: note: a declaration of 'T_B' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but 
a definition with the same name 'T_B' found in another namespace 'nb'
-// CHECK-MESSAGES: note: a definition of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
+// CHECK-NOTES: note: a declaration of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but a 
definition with the same name 'T_B' found in another namespace 'nb'
+// CHECK-NOTES: note: a definition of 'T_B' is found here
 }
 
 namespace nb {
@@ -56,10 +56,10 @@
 
 namespace na {
 class T_B;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a declaration with the same name found in another namespace 'nb'
-// CHECK-MESSAGES: note: a declaration of 'T_B' is found here
-// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: no definition found for 'T_B', but 
a definition with the same name 'T_B' found in another namespace 'nb'
-// CHECK-MESSAGES: note: a definition of 'T_B' is found here
+// CHECK-NOTES: :[[@LINE-1]]:7: warning: declaration 'T_B' is never 
referenced, but a

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

Could you please update the patch against the current trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D50850



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


[clang-tools-extra] r343199 - [clang-tidy] use CHECK-NOTES in tests for bugprone-use-after-move

2018-09-27 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Thu Sep 27 05:22:48 2018
New Revision: 343199

URL: http://llvm.org/viewvc/llvm-project?rev=343199&view=rev
Log:
[clang-tidy] use CHECK-NOTES in tests for bugprone-use-after-move

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp?rev=343199&r1=343198&r2=343199&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp Thu Sep 
27 05:22:48 2018
@@ -125,8 +125,8 @@ void simple() {
   a.foo();
   A other_a = std::move(a);
   a.foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:15: note: move occurred here
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:15: note: move occurred here
 }
 
 // A warning should only be emitted for one use-after-move.
@@ -135,8 +135,8 @@ void onlyFlagOneUseAfterMove() {
   a.foo();
   A other_a = std::move(a);
   a.foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:15: note: move occurred here
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:15: note: move occurred here
   a.foo();
 }
 
@@ -146,8 +146,8 @@ void moveAfterMove() {
 A a;
 std::move(a);
 std::move(a);
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: 'a' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:15: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   // This is also true if the move itself turns into the use on the second loop
   // iteration.
@@ -155,9 +155,9 @@ void moveAfterMove() {
 A a;
 for (int i = 0; i < 10; ++i) {
   std::move(a);
-  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
-  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
+  // CHECK-NOTES: [[@LINE-1]]:17: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-NOTES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -166,8 +166,8 @@ void moveAfterMove() {
 void parameters(A a) {
   std::move(a);
   a.foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:3: note: move occurred here
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:3: note: move occurred here
 }
 
 void standardSmartPtr() {
@@ -180,22 +180,22 @@ void standardSmartPtr() {
 ptr.get();
 static_cast(ptr);
 *ptr;
-// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-5]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-5]]:5: note: move occurred here
   }
   {
 std::unique_ptr ptr;
 std::move(ptr);
 ptr->foo();
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   {
 std::unique_ptr ptr;
 std::move(ptr);
 ptr[0];
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   {
 std::shared_ptr ptr;
@@ -203,15 +203,15 @@ void standardSmartPtr() {
 ptr.get();
 static_cast(ptr);
 *ptr;
-// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-5]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-5]]:5: note: move occurred here
   }
   {
 std::shared_ptr ptr;
 std::move(ptr);
 ptr->foo();
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   

[PATCH] D52228: [clang-tidy] use CHECK-NOTES in tests for bugprone-use-after-move

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343199: [clang-tidy] use CHECK-NOTES in tests for 
bugprone-use-after-move (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52228

Files:
  clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
@@ -125,18 +125,18 @@
   a.foo();
   A other_a = std::move(a);
   a.foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:15: note: move occurred here
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:15: note: move occurred here
 }
 
 // A warning should only be emitted for one use-after-move.
 void onlyFlagOneUseAfterMove() {
   A a;
   a.foo();
   A other_a = std::move(a);
   a.foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:15: note: move occurred here
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:15: note: move occurred here
   a.foo();
 }
 
@@ -146,28 +146,28 @@
 A a;
 std::move(a);
 std::move(a);
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: 'a' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:15: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   // This is also true if the move itself turns into the use on the second loop
   // iteration.
   {
 A a;
 for (int i = 0; i < 10; ++i) {
   std::move(a);
-  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
-  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
+  // CHECK-NOTES: [[@LINE-1]]:17: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-NOTES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
 
 // Checks also works on function parameters that have a use-after move.
 void parameters(A a) {
   std::move(a);
   a.foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:3: note: move occurred here
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:3: note: move occurred here
 }
 
 void standardSmartPtr() {
@@ -180,38 +180,38 @@
 ptr.get();
 static_cast(ptr);
 *ptr;
-// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-5]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-5]]:5: note: move occurred here
   }
   {
 std::unique_ptr ptr;
 std::move(ptr);
 ptr->foo();
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   {
 std::unique_ptr ptr;
 std::move(ptr);
 ptr[0];
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   {
 std::shared_ptr ptr;
 std::move(ptr);
 ptr.get();
 static_cast(ptr);
 *ptr;
-// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-5]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:6: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-5]]:5: note: move occurred here
   }
   {
 std::shared_ptr ptr;
 std::move(ptr);
 ptr->foo();
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
   }
   {
 // std::weak_ptr<> cannot be dereferenced directly, so we only check that
@@ -252,8 +252,8 @@
 } ptr;
 std::move(ptr);
 ptr.get();
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved
-// CHECK-MESSAGES: [[@LIN

[PATCH] D52229: [clang-tidy] use CHECK-NOTES in tests for bugprone suspicious-enum-usage

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343201: [clang-tidy] use CHECK-NOTES in tests for bugprone 
suspicious-enum-usage (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52229

Files:
  
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
@@ -54,10 +54,10 @@
   int emptytest = EmptyVal | B;
   if (bestDay() | A)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
   if (I | Y)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: enum values are from different enum 
types
 }
 
 int dont_trigger() {
Index: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
@@ -10,23 +10,23 @@
   G = 63
 };
 
-// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but a literal is not power-of-2
-// CHECK-MESSAGES: :76:7: note: used here as a bitmask
+// CHECK-NOTES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but a literal is not power-of-2
+// CHECK-NOTES: :76:7: note: used here as a bitmask
 enum X {
   X = 8,
   Y = 16,
   Z = 4,
   ZZ = 3
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2 
[bugprone-suspicious-enum-usage]
-// CHECK-MESSAGES: :70:13: note: used here as a bitmask
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2 
[bugprone-suspicious-enum-usage]
+// CHECK-NOTES: :70:13: note: used here as a bitmask
 };
-// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but some literals are not power-of-2
-// CHECK-MESSAGES: :73:8: note: used here as a bitmask
+// CHECK-NOTES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but some literals are not power-of-2
+// CHECK-NOTES: :73:8: note: used here as a bitmask
 enum PP {
   P = 2,
   Q = 3,
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2
-  // CHECK-MESSAGES: :65:11: note: used here as a bitmask
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2
+  // CHECK-NOTES: :65:11: note: used here as a bitmask
   R = 4,
   S = 8,
   T = 16,
@@ -58,10 +58,10 @@
 int trigger() {
   if (bestDay() | A)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
   if (I | Y)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: enum values are from different enum 
types
   if (P + Q == R)
 return 1;
   else if ((S | R) == T)


Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
@@ -54,10 +54,10 @@
   int emptytest = EmptyVal | B;
   if (bestDay() | A)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types
+  // CHECK-NOTES: :[[@LINE-2]]:17: warning: enum values are from different enum types
   if (I | Y)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: enum values are from different enum types
 }
 
 int dont_trigger() {
Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
==

[clang-tools-extra] r343201 - [clang-tidy] use CHECK-NOTES in tests for bugprone suspicious-enum-usage

2018-09-27 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Thu Sep 27 05:30:44 2018
New Revision: 343201

URL: http://llvm.org/viewvc/llvm-project?rev=343201&view=rev
Log:
[clang-tidy] use CHECK-NOTES in tests for bugprone suspicious-enum-usage

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: xazax.hun, cfe-commits

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

Modified:

clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp?rev=343201&r1=343200&r2=343201&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
 Thu Sep 27 05:30:44 2018
@@ -10,23 +10,23 @@ enum A {
   G = 63
 };
 
-// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but a literal is not power-of-2
-// CHECK-MESSAGES: :76:7: note: used here as a bitmask
+// CHECK-NOTES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but a literal is not power-of-2
+// CHECK-NOTES: :76:7: note: used here as a bitmask
 enum X {
   X = 8,
   Y = 16,
   Z = 4,
   ZZ = 3
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2 
[bugprone-suspicious-enum-usage]
-// CHECK-MESSAGES: :70:13: note: used here as a bitmask
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2 
[bugprone-suspicious-enum-usage]
+// CHECK-NOTES: :70:13: note: used here as a bitmask
 };
-// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but some literals are not power-of-2
-// CHECK-MESSAGES: :73:8: note: used here as a bitmask
+// CHECK-NOTES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals) but some literals are not power-of-2
+// CHECK-NOTES: :73:8: note: used here as a bitmask
 enum PP {
   P = 2,
   Q = 3,
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2
-  // CHECK-MESSAGES: :65:11: note: used here as a bitmask
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask 
(contains mostly power-of-2 literals), but this literal is not a power-of-2
+  // CHECK-NOTES: :65:11: note: used here as a bitmask
   R = 4,
   S = 8,
   T = 16,
@@ -58,10 +58,10 @@ Days bestDay() {
 int trigger() {
   if (bestDay() | A)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
   if (I | Y)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: enum values are from different enum 
types
   if (P + Q == R)
 return 1;
   else if ((S | R) == T)

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp?rev=343201&r1=343200&r2=343201&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp 
Thu Sep 27 05:30:44 2018
@@ -54,10 +54,10 @@ int trigger() {
   int emptytest = EmptyVal | B;
   if (bestDay() | A)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:17: warning: enum values are from different 
enum types
   if (I | Y)
 return 1;
-  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different 
enum types
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: enum values are from different enum 
types
 }
 
 int dont_trigger() {


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


r343204 - [Lex] TokenConcatenation now takes const Preprocessor

2018-09-27 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Thu Sep 27 05:40:16 2018
New Revision: 343204

URL: http://llvm.org/viewvc/llvm-project?rev=343204&view=rev
Log:
[Lex] TokenConcatenation now takes const Preprocessor

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

Modified:
cfe/trunk/include/clang/Lex/TokenConcatenation.h
cfe/trunk/lib/Lex/TokenConcatenation.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h

Modified: cfe/trunk/include/clang/Lex/TokenConcatenation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenConcatenation.h?rev=343204&r1=343203&r2=343204&view=diff
==
--- cfe/trunk/include/clang/Lex/TokenConcatenation.h (original)
+++ cfe/trunk/include/clang/Lex/TokenConcatenation.h Thu Sep 27 05:40:16 2018
@@ -29,7 +29,7 @@ namespace clang {
   /// and ")" next to each other is safe.
   ///
   class TokenConcatenation {
-Preprocessor &PP;
+const Preprocessor &PP;
 
 enum AvoidConcatInfo {
   /// By default, a token never needs to avoid concatenation.  Most tokens
@@ -56,7 +56,7 @@ namespace clang {
 /// method.
 char TokenInfo[tok::NUM_TOKENS];
   public:
-TokenConcatenation(Preprocessor &PP);
+TokenConcatenation(const Preprocessor &PP);
 
 bool AvoidConcat(const Token &PrevPrevTok,
  const Token &PrevTok,

Modified: cfe/trunk/lib/Lex/TokenConcatenation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenConcatenation.cpp?rev=343204&r1=343203&r2=343204&view=diff
==
--- cfe/trunk/lib/Lex/TokenConcatenation.cpp (original)
+++ cfe/trunk/lib/Lex/TokenConcatenation.cpp Thu Sep 27 05:40:16 2018
@@ -67,7 +67,7 @@ bool TokenConcatenation::IsIdentifierStr
   return IsStringPrefix(StringRef(PP.getSpelling(Tok)), LangOpts.CPlusPlus11);
 }
 
-TokenConcatenation::TokenConcatenation(Preprocessor &pp) : PP(pp) {
+TokenConcatenation::TokenConcatenation(const Preprocessor &pp) : PP(pp) {
   memset(TokenInfo, 0, sizeof(TokenInfo));
 
   // These tokens have custom code in AvoidConcat.
@@ -126,7 +126,7 @@ TokenConcatenation::TokenConcatenation(P
 
 /// GetFirstChar - Get the first character of the token \arg Tok,
 /// avoiding calls to getSpelling where possible.
-static char GetFirstChar(Preprocessor &PP, const Token &Tok) {
+static char GetFirstChar(const Preprocessor &PP, const Token &Tok) {
   if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
 // Avoid spelling identifiers, the most common form of token.
 return II->getNameStart()[0];

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=343204&r1=343203&r2=343204&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
Thu Sep 27 05:40:16 2018
@@ -79,9 +79,9 @@ class FieldNode {
 protected:
   const FieldRegion *FR;
 
-  /// FieldNodes are never meant to be created on the heap, see
-  /// FindUninitializedFields::addFieldToUninits().
-  /* non-virtual */ ~FieldNode() = default;
+  // TODO: This destructor shouldn't be virtual, but breaks buildbots with
+  // -Werror -Wnon-virtual-dtor.
+  virtual ~FieldNode() = default;
 
 public:
   FieldNode(const FieldRegion *FR) : FR(FR) {}


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


[PATCH] D52547: Tell whether file/folder for include completions.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In https://reviews.llvm.org/D52547#1246701, @ilya-biryukov wrote:

> A drive-by comment.
>  Would it be cleaner to pass this information from clang? Relying on 
> completion label seems shaky.


Actually I also wanted to do that at first, but then wasn't really sure whether 
we should introduce a new contextkind or not, because it is more about lsp and 
wasn't sure if it would be widely applicable to have a distinction between 
file/directory(folder) as a completion context kind.
WDYT @sammccall , would introducing a new completion context carry its weight?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52547



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


[PATCH] D52502: [Lex] TokenConcatenation now takes const Preprocessor

2018-09-27 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343204: [Lex] TokenConcatenation now takes const 
Preprocessor (authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52502?vs=166927&id=167301#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52502

Files:
  cfe/trunk/include/clang/Lex/TokenConcatenation.h
  cfe/trunk/lib/Lex/TokenConcatenation.cpp
  
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h


Index: cfe/trunk/include/clang/Lex/TokenConcatenation.h
===
--- cfe/trunk/include/clang/Lex/TokenConcatenation.h
+++ cfe/trunk/include/clang/Lex/TokenConcatenation.h
@@ -29,7 +29,7 @@
   /// and ")" next to each other is safe.
   ///
   class TokenConcatenation {
-Preprocessor &PP;
+const Preprocessor &PP;
 
 enum AvoidConcatInfo {
   /// By default, a token never needs to avoid concatenation.  Most tokens
@@ -56,7 +56,7 @@
 /// method.
 char TokenInfo[tok::NUM_TOKENS];
   public:
-TokenConcatenation(Preprocessor &PP);
+TokenConcatenation(const Preprocessor &PP);
 
 bool AvoidConcat(const Token &PrevPrevTok,
  const Token &PrevTok,
Index: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
===
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
@@ -79,9 +79,9 @@
 protected:
   const FieldRegion *FR;
 
-  /// FieldNodes are never meant to be created on the heap, see
-  /// FindUninitializedFields::addFieldToUninits().
-  /* non-virtual */ ~FieldNode() = default;
+  // TODO: This destructor shouldn't be virtual, but breaks buildbots with
+  // -Werror -Wnon-virtual-dtor.
+  virtual ~FieldNode() = default;
 
 public:
   FieldNode(const FieldRegion *FR) : FR(FR) {}
Index: cfe/trunk/lib/Lex/TokenConcatenation.cpp
===
--- cfe/trunk/lib/Lex/TokenConcatenation.cpp
+++ cfe/trunk/lib/Lex/TokenConcatenation.cpp
@@ -67,7 +67,7 @@
   return IsStringPrefix(StringRef(PP.getSpelling(Tok)), LangOpts.CPlusPlus11);
 }
 
-TokenConcatenation::TokenConcatenation(Preprocessor &pp) : PP(pp) {
+TokenConcatenation::TokenConcatenation(const Preprocessor &pp) : PP(pp) {
   memset(TokenInfo, 0, sizeof(TokenInfo));
 
   // These tokens have custom code in AvoidConcat.
@@ -126,7 +126,7 @@
 
 /// GetFirstChar - Get the first character of the token \arg Tok,
 /// avoiding calls to getSpelling where possible.
-static char GetFirstChar(Preprocessor &PP, const Token &Tok) {
+static char GetFirstChar(const Preprocessor &PP, const Token &Tok) {
   if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
 // Avoid spelling identifiers, the most common form of token.
 return II->getNameStart()[0];


Index: cfe/trunk/include/clang/Lex/TokenConcatenation.h
===
--- cfe/trunk/include/clang/Lex/TokenConcatenation.h
+++ cfe/trunk/include/clang/Lex/TokenConcatenation.h
@@ -29,7 +29,7 @@
   /// and ")" next to each other is safe.
   ///
   class TokenConcatenation {
-Preprocessor &PP;
+const Preprocessor &PP;
 
 enum AvoidConcatInfo {
   /// By default, a token never needs to avoid concatenation.  Most tokens
@@ -56,7 +56,7 @@
 /// method.
 char TokenInfo[tok::NUM_TOKENS];
   public:
-TokenConcatenation(Preprocessor &PP);
+TokenConcatenation(const Preprocessor &PP);
 
 bool AvoidConcat(const Token &PrevPrevTok,
  const Token &PrevTok,
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
@@ -79,9 +79,9 @@
 protected:
   const FieldRegion *FR;
 
-  /// FieldNodes are never meant to be created on the heap, see
-  /// FindUninitializedFields::addFieldToUninits().
-  /* non-virtual */ ~FieldNode() = default;
+  // TODO: This destructor shouldn't be virtual, but breaks buildbots with
+  // -Werror -Wnon-virtual-dtor.
+  virtual ~FieldNode() = default;
 
 public:
   FieldNode(const FieldRegion *FR) : FR(FR) {}
Index: cfe/trunk/lib/Lex/TokenConcatenation.cpp
===
--- cfe/trunk/lib/Lex/TokenConcatenation.cpp
+++ cfe/trunk/lib/Lex/TokenConcatenation.cpp
@@ -67,7 +67,7 @@
   return IsStringPrefix(StringRef(PP.getSpelling(Tok)), LangOpts.CPlusPlus11);
 }
 
-TokenConcatenation::TokenConcatenation(Preprocessor &pp) : PP(pp) {
+TokenConcatenation::TokenConcatenation(const Preproce

[PATCH] D52334: [clang-tidy] Build it even without static analyzer

2018-09-27 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@JonasToth Once again - `clangStaticAnalyzerCheckers` is not `clangAnalysis`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334



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


r343205 - Revert untintentionally commited changes

2018-09-27 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Thu Sep 27 05:46:37 2018
New Revision: 343205

URL: http://llvm.org/viewvc/llvm-project?rev=343205&view=rev
Log:
Revert untintentionally commited changes

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=343205&r1=343204&r2=343205&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
Thu Sep 27 05:46:37 2018
@@ -79,9 +79,9 @@ class FieldNode {
 protected:
   const FieldRegion *FR;
 
-  // TODO: This destructor shouldn't be virtual, but breaks buildbots with
-  // -Werror -Wnon-virtual-dtor.
-  virtual ~FieldNode() = default;
+  /// FieldNodes are never meant to be created on the heap, see
+  /// FindUninitializedFields::addFieldToUninits().
+  /* non-virtual */ ~FieldNode() = default;
 
 public:
   FieldNode(const FieldRegion *FR) : FR(FR) {}


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


[PATCH] D52502: [Lex] TokenConcatenation now takes const Preprocessor

2018-09-27 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h:82-84
+  // TODO: This destructor shouldn't be virtual, but breaks buildbots with
+  // -Werror -Wnon-virtual-dtor.
+  virtual ~FieldNode() = default;

Commited accidentally, removed in rC343205.


Repository:
  rL LLVM

https://reviews.llvm.org/D52502



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


[PATCH] D52334: [clang-tidy] Build it even without static analyzer

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In https://reviews.llvm.org/D52334#1247809, @steveire wrote:

> @JonasToth Once again - `clangStaticAnalyzerCheckers` is not `clangAnalysis`. 
> Also, that commit changes the `mpi` plugin, which is excluded by this patch.


I pinged because of the MPI thing, i did not look further! Sry for noise then.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334



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


[PATCH] D51686: [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D51686



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


r343207 - [OpenCL] Improve extension-version.cl and to_addr_builtin.cl tests

2018-09-27 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep 27 06:20:29 2018
New Revision: 343207

URL: http://llvm.org/viewvc/llvm-project?rev=343207&view=rev
Log:
[OpenCL] Improve extension-version.cl and to_addr_builtin.cl tests

Add cl_khr_depth_images to extension-version.cl.

Extend to_addr_builtin.cl to additionally test the built-in methods
to_private and to_local, and test assignment with to_global to
incorrect types.

Patch by Alistair Davies.

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

Modified:
cfe/trunk/test/SemaOpenCL/extension-version.cl
cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=343207&r1=343206&r2=343207&view=diff
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Thu Sep 27 06:20:29 2018
@@ -283,6 +283,18 @@
 #pragma OPENCL EXTENSION cl_amd_media_ops2: enable
 
 #if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_depth_images
+#error "Missing cl_khr_depth_images define"
+#endif
+#else
+#ifdef cl_khr_depth_images
+#error "Incorrect cl_khr_depth_images define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_depth_images' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_depth_images: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
 #ifndef cl_intel_subgroups
 #error "Missing cl_intel_subgroups define"
 #endif

Modified: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl?rev=343207&r1=343206&r2=343207&view=diff
==
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl (original)
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Thu Sep 27 06:20:29 2018
@@ -5,6 +5,8 @@ void test(void) {
   global int *glob;
   local int *loc;
   constant int *con;
+  private int *priv;
+  global float *glob_wrong_ty;
   typedef constant int const_int_ty;
   const_int_ty *con_typedef;
 
@@ -46,6 +48,72 @@ void test(void) {
   // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
 #endif
 
+  loc = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{implicit declaration of function 'to_private' is 
invalid in OpenCL}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning 
to '__local int *' from 'int'}}
+#else
+  // expected-error@-5{{assigning 'int *' to '__local int *' changes address 
space of pointer}}
+  // expected-warning@-6{{passing non-generic address space pointer to 
to_private may cause dynamic conversion affecting performance}}
+#endif
+
+  loc = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{implicit declaration of function 'to_local' is invalid 
in OpenCL}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning 
to '__local int *' from 'int'}}
+  // expected-note@-4{{did you mean 'to_global'}}
+  // expected-note@13{{'to_global' declared here}}
+#else
+  // expected-warning@-7{{passing non-generic address space pointer to 
to_local may cause dynamic conversion affecting performance}}
+#endif
+
+  priv = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to 'int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning '__global int *' to 'int *' changes address 
space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
+#endif
+
+  priv = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to 'int *' from 'int'}}
+#else
+  // expected-warning@-4{{passing non-generic address space pointer to 
to_private may cause dynamic conversion affecting performance}}
+#endif
+
+
+  priv = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to 'int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning '__local int *' to 'int *' changes address 
space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_local may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to '__global int *' from 'int'}}
+#else
+  // expected-warning@-4{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0

[PATCH] D52020: [OpenCL] Improve extension-version.cl and to_addr_builtin.cl tests

2018-09-27 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343207: [OpenCL] Improve extension-version.cl and 
to_addr_builtin.cl tests (authored by svenvh, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52020?vs=165239&id=167302#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52020

Files:
  cfe/trunk/test/SemaOpenCL/extension-version.cl
  cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Index: cfe/trunk/test/SemaOpenCL/extension-version.cl
===
--- cfe/trunk/test/SemaOpenCL/extension-version.cl
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl
@@ -283,6 +283,18 @@
 #pragma OPENCL EXTENSION cl_amd_media_ops2: enable
 
 #if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_depth_images
+#error "Missing cl_khr_depth_images define"
+#endif
+#else
+#ifdef cl_khr_depth_images
+#error "Incorrect cl_khr_depth_images define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_depth_images' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_depth_images: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
 #ifndef cl_intel_subgroups
 #error "Missing cl_intel_subgroups define"
 #endif
Index: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
===
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
@@ -5,6 +5,8 @@
   global int *glob;
   local int *loc;
   constant int *con;
+  private int *priv;
+  global float *glob_wrong_ty;
   typedef constant int const_int_ty;
   const_int_ty *con_typedef;
 
@@ -46,12 +48,86 @@
   // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
 #endif
 
+  loc = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{implicit declaration of function 'to_private' is invalid in OpenCL}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
+#else
+  // expected-error@-5{{assigning 'int *' to '__local int *' changes address space of pointer}}
+  // expected-warning@-6{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
+#endif
+
+  loc = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{implicit declaration of function 'to_local' is invalid in OpenCL}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
+  // expected-note@-4{{did you mean 'to_global'}}
+  // expected-note@13{{'to_global' declared here}}
+#else
+  // expected-warning@-7{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
+#endif
+
+  priv = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning '__global int *' to 'int *' changes address space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
+#endif
+
+  priv = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
+#else
+  // expected-warning@-4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
+#endif
+
+
+  priv = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning '__local int *' to 'int *' changes address space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+#else
+  // expected-warning@-4{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning 'int *' to '__global int *' changes address space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to

[PATCH] D52611: [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52611

Files:
  clangd/index/MemIndex.cpp
  clangd/index/Merge.cpp
  clangd/index/dex/Dex.cpp

Index: clangd/index/dex/Dex.cpp
===
--- clangd/index/dex/Dex.cpp
+++ clangd/index/dex/Dex.cpp
@@ -12,6 +12,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 #include "llvm/ADT/StringSet.h"
 #include 
 #include 
@@ -139,6 +140,7 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  trace::Span Tracer("Dex fuzzyFind");
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
 
@@ -228,6 +230,7 @@
 
 void Dex::lookup(const LookupRequest &Req,
  llvm::function_ref Callback) const {
+  trace::Span Tracer("Dex lookup");
   for (const auto &ID : Req.IDs) {
 auto I = LookupTable.find(ID);
 if (I != LookupTable.end())
@@ -237,6 +240,7 @@
 
 void Dex::refs(const RefsRequest &Req,
llvm::function_ref Callback) const {
+  trace::Span Tracer("Dex refs");
   log("refs is not implemented.");
 }
 
Index: clangd/index/Merge.cpp
===
--- clangd/index/Merge.cpp
+++ clangd/index/Merge.cpp
@@ -9,6 +9,7 @@
 
 #include "Merge.h"
 #include "Logger.h"
+#include "Trace.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
@@ -38,6 +39,7 @@
  //a) if it's not in the dynamic slab, yield it directly
  //b) if it's in the dynamic slab, merge it and yield the result
  //  3) now yield all the dynamic symbols we haven't processed.
+ trace::Span Tracer("MergedIndex fuzzyFind");
  bool More = false; // We'll be incomplete if either source was.
  SymbolSlab::Builder DynB;
  More |= Dynamic->fuzzyFind(Req, [&](const Symbol &S) { DynB.insert(S); });
@@ -60,6 +62,7 @@
   void
   lookup(const LookupRequest &Req,
  llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex lookup");
 SymbolSlab::Builder B;
 
 Dynamic->lookup(Req, [&](const Symbol &S) { B.insert(S); });
@@ -80,6 +83,7 @@
 
   void refs(const RefsRequest &Req,
 llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex refs");
 // We don't want duplicated refs from the static/dynamic indexes,
 // and we can't reliably duplicate them because offsets may differ slightly.
 // We consider the dynamic index authoritative and report all its refs,
Index: clangd/index/MemIndex.cpp
===
--- clangd/index/MemIndex.cpp
+++ clangd/index/MemIndex.cpp
@@ -11,6 +11,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 
 namespace clang {
 namespace clangd {
@@ -28,6 +29,7 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  trace::Span Tracer("MemIndex fuzzyFind");
 
   TopN> Top(
   Req.Limit ? *Req.Limit : std::numeric_limits::max());
@@ -47,13 +49,16 @@
   if (Top.push({*Score * quality(*Sym), Sym}))
 More = true; // An element with smallest score was discarded.
   }
-  for (const auto &Item : std::move(Top).items())
+  auto Results = std::move(Top).items();
+  SPAN_ATTACH(Tracer, "results", static_cast(Results.size()));
+  for (const auto &Item : Results)
 Callback(*Item.second);
   return More;
 }
 
 void MemIndex::lookup(const LookupRequest &Req,
   llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex lookup");
   for (const auto &ID : Req.IDs) {
 auto I = Index.find(ID);
 if (I != Index.end())
@@ -63,6 +68,7 @@
 
 void MemIndex::refs(const RefsRequest &Req,
 llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex refs");
   for (const auto &ReqID : Req.IDs) {
 auto SymRefs = Refs.find(ReqID);
 if (SymRefs == Refs.end())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

A lot of good improvements and many test cases, thank you!

The comments are mostly nits.




Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

JonasToth wrote:
> kbobyrev wrote:
> > How about `multiple declarations within a single statement hurts 
> > readability`?
> s/hurts/reduces/? hurts sound a bit weird i think.
> 
> Lebedev wanted the number of decls in the diagnostic, would you include it or 
> rather now?
"decreases" is also fine. "hurts" is probably too strong, I agree.

Up to you. Personally, I don't see any value in having the diagnostic message 
saying "hey, you have 2 declarations within one statement, that's really bad!" 
or "hey, you have 5 declarations within one statement..." - in both cases the 
point is that there are *multiple* declarations. I also don't think it would 
make debugging easier because you also check the formatting, so you already 
imply that the correct number of declarations was detected.

I'm interested to know what @lebedev.ri thinks.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:39
+  const Stmt *const InitStmt = Node.getInit();
+  if (InitStmt)
+return InnerMatcher.matches(*InitStmt, Finder, Builder);

nit: `return InitStmt ? InnerMatcher... : false;`



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:65
+
+  for (int i = Indirections; i > 0; --i) {
+Start = findPreviousAnyTokenKind(Start, SM, LangOpts, tok::star, tok::amp);

`i`-> `I`

or even better `while (--Indirections)` since it's not used anywhere afterwards.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:68
+if (Start.isInvalid() || Start.isMacroID())
+  return SourceLocation();
+  }

Also, I don't think this should happen with the correct behavior. 
`llvm::Expected` looks like a better alternative for error handling here.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:78
+static int countIndirections(const Type *T, int Indirections = 0) {
+  assert(T && "Require non-null");
+  if (T->isPointerType() || T->isReferenceType())

nit: "Type has to be set for *countIndirections()*"? The wording is not 
optimal, but currently the assertion message doesn't say much about the error.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:93
+static bool IsMemberPointer(const VarDecl *D) {
+  if (D->getType()->isMemberPointerType() ||
+  D->getType()->isMemberDataPointerType() ||

just `return (Condition0 || Condition1 || Condition2);`



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:102
+static Optional>
+DeclSlice(const DeclStmt *DS, const SourceManager &SM,
+  const LangOptions &LangOpts) {

nit: naming (lowercase + more descriptive name/documentation about the returned 
value).



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:166
+VarDecl *CurrentDecl = dyn_cast(*It);
+assert(CurrentDecl && "Expect only VarDecls here");
+

This assertion message doesn't really give much information, too. Before you 
inspect the code closely (e.g. to understand what "here" refers to), it would 
be hard for other developers to understand what the issue might just by looking 
at the failed assertion message unless they are very familiar with the code.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:168
+
+// FIXME Memberpointer are not transformed correctly right now, thats
+// why they are treated as problematic here.

nit `FIXME:`. Also, ideally there would be an XFAIL test on that.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:173
+
+SourceLocation DeclEnd;
+if (CurrentDecl->hasInit())

nit: `const SourceLocation DeclEnd = findNextTerimator(CurrentDecl->hasInit() ? 
CurrentDecl->getINit()->getEndLoc() : CurrentDecl->getEndLoc(), SM, LagOpts);` 
(formatted with Clang-Format, of course, my snippet is messy :)

Up to you, though, I just think it would be slightly more readable.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:208
+static Optional>
+SourceFromRanges(const std::vector &Ranges,
+ const SourceManager &SM, const LangOptions &LangOpts) {

nit: `const std::vector &` -> `llvm::ArrayRef`

Also, probably `SourceFromRanges` -> `collectSourceText(Ranges, ...)`? This 
would probably be easier to read (otherwise it's easier to confuse with 
something like "get `SourceLocations` from `SourceRanges` when not looking at 
the function body).



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:211
+  std::vector Snippets;
+  Snippets.reserve(Ranges.

[PATCH] D52547: Tell whether file/folder for include completions.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D52547#1247794, @kadircet wrote:

> In https://reviews.llvm.org/D52547#1246701, @ilya-biryukov wrote:
>
> > A drive-by comment.
> >  Would it be cleaner to pass this information from clang? Relying on 
> > completion label seems shaky.
>
>
> Actually I also wanted to do that at first, but then wasn't really sure 
> whether we should introduce a new contextkind or not, because it is more 
> about lsp and wasn't sure if it would be widely applicable to have a 
> distinction between file/directory(folder) as a completion context kind.
>  WDYT @sammccall , would introducing a new completion context carry its 
> weight?


What Ilya proposes would indeed be cleaner - I think we could attach 
directory_entry or path/file_type to the completion result.

On the other hand while this is a hack, it's simple and it works, and the 
cleaner solution doesn't bring any concrete benefit at this point.

I think we should leave this be and revisit if we start querying headers from 
the index. (At that point we'll want more robust path info to deduplicate sema 
and index results).




Comment at: clangd/CodeComplete.cpp:352
   C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
+  if (Completion.Kind == CompletionItemKind::File &&
+  Completion.Name.back() == '/')

this probably deserves at least a comment mentioning that Sema could provide 
more semantic info here.



Comment at: clangd/Protocol.h:706-707
   File = 17,
   Reference = 18,
+  Folder = 19,
 };

This is a type outside of the core must-be-supported range, so we probably need 
to add the logic to ClangdLSPServer to respect the client capabilities (see 
`adjustKindToCapability`). This could be a separate patch, as it's basically 
plumbing.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52547



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


[PATCH] D52611: [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/index/Merge.cpp:42
  //  3) now yield all the dynamic symbols we haven't processed.
+ trace::Span Tracer("MergedIndex fuzzyFind");
  bool More = false; // We'll be incomplete if either source was.

might be fun to add static/dynamic/both counts



Comment at: clangd/index/dex/Dex.cpp:143
  "There must be no :: in query.");
+  trace::Span Tracer("Dex fuzzyFind");
   FuzzyMatcher Filter(Req.Query);

We should attach the query tree to the span here.

Right now that's not practical as the dump() representation holds the posting 
lists rather than their token, but maybe add a FIXME?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52611



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


[PATCH] D52547: Tell whether file/folder for include completions.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 167320.
kadircet marked 2 inline comments as done.
kadircet added a comment.

Preparing the patch to respect client capabilities.

- Add other itemkinds as well.
- Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52547

Files:
  clangd/CodeComplete.cpp
  clangd/Protocol.h
  unittests/clangd/CodeCompleteTests.cpp


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -2073,6 +2073,27 @@
   }
 }
 
+TEST(CompletionTest, IncludedCompletionKinds) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  std::string Subdir = testPath("sub");
+  std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  auto Results = completions(Server,
+  R"cpp(
+#include "^"
+  )cpp"
+  );
+  EXPECT_THAT(Results.Completions,
+  AllOf(Has("sub/", CompletionItemKind::Folder),
+Has("bar.h\"", CompletionItemKind::File)));
+}
+
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -704,6 +704,13 @@
   Color = 16,
   File = 17,
   Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
 };
 
 /// Defines whether the insert text in a completion item should be interpreted
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -349,6 +349,11 @@
   }
   Completion.Kind = toCompletionItemKind(
   C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
+  // Sema could provide more info on whether the completion was a file or
+  // folder.
+  if (Completion.Kind == CompletionItemKind::File &&
+  Completion.Name.back() == '/')
+Completion.Kind = CompletionItemKind::Folder;
   for (const auto &FixIt : C.SemaResult->FixIts) {
 Completion.FixIts.push_back(
 toTextEdit(FixIt, ASTCtx.getSourceManager(), 
ASTCtx.getLangOpts()));


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -2073,6 +2073,27 @@
   }
 }
 
+TEST(CompletionTest, IncludedCompletionKinds) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  std::string Subdir = testPath("sub");
+  std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  auto Results = completions(Server,
+  R"cpp(
+#include "^"
+  )cpp"
+  );
+  EXPECT_THAT(Results.Completions,
+  AllOf(Has("sub/", CompletionItemKind::Folder),
+Has("bar.h\"", CompletionItemKind::File)));
+}
+
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -704,6 +704,13 @@
   Color = 16,
   File = 17,
   Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
 };
 
 /// Defines whether the insert text in a completion item should be interpreted
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -349,6 +349,11 @@
   }
   Completion.Kind = toCompletionItemKind(
   C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
+  // Sema could provide more info on whether the completion was a file or
+  // folder.
+  if (Completion.Kind == CompletionItemKind::File &&
+  Completion.Name.back() == '/')
+Completion.Kind = CompletionItemKind::Folder;
   for (const auto &FixIt : C.SemaResult->FixIts) {
 Completion.FixIts.push_back(
 toTextEdit(FixIt, ASTCtx.getSourceManager(), ASTCtx.getLangOpts()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343220 - [AArch64][v8.5A] Test optional Armv8.5-A random number extension

2018-09-27 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Thu Sep 27 07:20:59 2018
New Revision: 343220

URL: http://llvm.org/viewvc/llvm-project?rev=343220&view=rev
Log:
[AArch64][v8.5A] Test optional Armv8.5-A random number extension

The implementation of this is in TargetParser, so we only need to add a
test for it in clang.

Patch by Pablo Barrio!

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


Added:
cfe/trunk/test/Driver/aarch64-rand.c

Added: cfe/trunk/test/Driver/aarch64-rand.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-rand.c?rev=343220&view=auto
==
--- cfe/trunk/test/Driver/aarch64-rand.c (added)
+++ cfe/trunk/test/Driver/aarch64-rand.c Thu Sep 27 07:20:59 2018
@@ -0,0 +1,13 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+rng %s 2>&1 
| FileCheck %s
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+rng %s 2>&1 
| FileCheck %s
+// CHECK: "-target-feature" "+rand"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+norng %s 
2>&1 | FileCheck %s --check-prefix=NORAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+norng %s 
2>&1 | FileCheck %s --check-prefix=NORAND
+// NORAND: "-target-feature" "-rand"
+
+// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | 
FileCheck %s --check-prefix=ABSENTRAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a %s 2>&1 | 
FileCheck %s --check-prefix=ABSENTRAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a %s 2>&1 | 
FileCheck %s --check-prefix=ABSENTRAND
+// ABSENTRAND-NOT: "-target-feature" "+rand"
+// ABSENTRAND-NOT: "-target-feature" "-rand"


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


[clang-tools-extra] r343221 - Tell whether file/folder for include completions.

2018-09-27 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu Sep 27 07:21:07 2018
New Revision: 343221

URL: http://llvm.org/viewvc/llvm-project?rev=343221&view=rev
Log:
Tell whether file/folder for include completions.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=343221&r1=343220&r2=343221&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Sep 27 07:21:07 2018
@@ -349,6 +349,11 @@ struct CodeCompletionBuilder {
   }
   Completion.Kind = toCompletionItemKind(
   C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
+  // Sema could provide more info on whether the completion was a file or
+  // folder.
+  if (Completion.Kind == CompletionItemKind::File &&
+  Completion.Name.back() == '/')
+Completion.Kind = CompletionItemKind::Folder;
   for (const auto &FixIt : C.SemaResult->FixIts) {
 Completion.FixIts.push_back(
 toTextEdit(FixIt, ASTCtx.getSourceManager(), 
ASTCtx.getLangOpts()));

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=343221&r1=343220&r2=343221&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Thu Sep 27 07:21:07 2018
@@ -704,6 +704,13 @@ enum class CompletionItemKind {
   Color = 16,
   File = 17,
   Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
 };
 
 /// Defines whether the insert text in a completion item should be interpreted

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=343221&r1=343220&r2=343221&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Sep 27 
07:21:07 2018
@@ -2073,6 +2073,27 @@ TEST(SignatureHelpTest, ConstructorIniti
   }
 }
 
+TEST(CompletionTest, IncludedCompletionKinds) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  std::string Subdir = testPath("sub");
+  std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  auto Results = completions(Server,
+  R"cpp(
+#include "^"
+  )cpp"
+  );
+  EXPECT_THAT(Results.Completions,
+  AllOf(Has("sub/", CompletionItemKind::Folder),
+Has("bar.h\"", CompletionItemKind::File)));
+}
+
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D52492: [AArch64][v8.5A] Test optional Armv8.5-A random number extension

2018-09-27 Thread Oliver Stannard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343220: [AArch64][v8.5A] Test optional Armv8.5-A random 
number extension (authored by olista01, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52492?vs=166909&id=167322#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52492

Files:
  test/Driver/aarch64-rand.c


Index: test/Driver/aarch64-rand.c
===
--- test/Driver/aarch64-rand.c
+++ test/Driver/aarch64-rand.c
@@ -0,0 +1,13 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+rng %s 2>&1 
| FileCheck %s
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+rng %s 2>&1 
| FileCheck %s
+// CHECK: "-target-feature" "+rand"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+norng %s 
2>&1 | FileCheck %s --check-prefix=NORAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+norng %s 
2>&1 | FileCheck %s --check-prefix=NORAND
+// NORAND: "-target-feature" "-rand"
+
+// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | 
FileCheck %s --check-prefix=ABSENTRAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a %s 2>&1 | 
FileCheck %s --check-prefix=ABSENTRAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a %s 2>&1 | 
FileCheck %s --check-prefix=ABSENTRAND
+// ABSENTRAND-NOT: "-target-feature" "+rand"
+// ABSENTRAND-NOT: "-target-feature" "-rand"


Index: test/Driver/aarch64-rand.c
===
--- test/Driver/aarch64-rand.c
+++ test/Driver/aarch64-rand.c
@@ -0,0 +1,13 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+rng %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+rng %s 2>&1 | FileCheck %s
+// CHECK: "-target-feature" "+rand"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+norng %s 2>&1 | FileCheck %s --check-prefix=NORAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a+norng %s 2>&1 | FileCheck %s --check-prefix=NORAND
+// NORAND: "-target-feature" "-rand"
+
+// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENTRAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a %s 2>&1 | FileCheck %s --check-prefix=ABSENTRAND
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.5a %s 2>&1 | FileCheck %s --check-prefix=ABSENTRAND
+// ABSENTRAND-NOT: "-target-feature" "+rand"
+// ABSENTRAND-NOT: "-target-feature" "-rand"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52547: Tell whether file/folder for include completions.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343221: Tell whether file/folder for include completions. 
(authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52547?vs=167320&id=167321#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52547

Files:
  clangd/CodeComplete.cpp
  clangd/Protocol.h
  unittests/clangd/CodeCompleteTests.cpp


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -704,6 +704,13 @@
   Color = 16,
   File = 17,
   Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
 };
 
 /// Defines whether the insert text in a completion item should be interpreted
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -349,6 +349,11 @@
   }
   Completion.Kind = toCompletionItemKind(
   C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
+  // Sema could provide more info on whether the completion was a file or
+  // folder.
+  if (Completion.Kind == CompletionItemKind::File &&
+  Completion.Name.back() == '/')
+Completion.Kind = CompletionItemKind::Folder;
   for (const auto &FixIt : C.SemaResult->FixIts) {
 Completion.FixIts.push_back(
 toTextEdit(FixIt, ASTCtx.getSourceManager(), 
ASTCtx.getLangOpts()));
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -2073,6 +2073,27 @@
   }
 }
 
+TEST(CompletionTest, IncludedCompletionKinds) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  std::string Subdir = testPath("sub");
+  std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  auto Results = completions(Server,
+  R"cpp(
+#include "^"
+  )cpp"
+  );
+  EXPECT_THAT(Results.Completions,
+  AllOf(Has("sub/", CompletionItemKind::Folder),
+Has("bar.h\"", CompletionItemKind::File)));
+}
+
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -704,6 +704,13 @@
   Color = 16,
   File = 17,
   Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
 };
 
 /// Defines whether the insert text in a completion item should be interpreted
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -349,6 +349,11 @@
   }
   Completion.Kind = toCompletionItemKind(
   C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
+  // Sema could provide more info on whether the completion was a file or
+  // folder.
+  if (Completion.Kind == CompletionItemKind::File &&
+  Completion.Name.back() == '/')
+Completion.Kind = CompletionItemKind::Folder;
   for (const auto &FixIt : C.SemaResult->FixIts) {
 Completion.FixIts.push_back(
 toTextEdit(FixIt, ASTCtx.getSourceManager(), ASTCtx.getLangOpts()));
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -2073,6 +2073,27 @@
   }
 }
 
+TEST(CompletionTest, IncludedCompletionKinds) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  std::string Subdir = testPath("sub");
+  std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  auto Results = completions(Server,
+  R"cpp(
+#include "^"
+  )cpp"
+  );
+  EXPECT_THAT(Results.Completions,
+  AllOf(Has("sub/", CompletionItemKind::Folder),
+Has("bar.h\"", CompletionItemKind::File)));
+}
+
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r343223 - [clangd] Make IncludeInserter less slow. NFC

2018-09-27 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Sep 27 07:27:02 2018
New Revision: 343223

URL: http://llvm.org/viewvc/llvm-project?rev=343223&view=rev
Log:
[clangd] Make IncludeInserter less slow. NFC

Modified:
clang-tools-extra/trunk/clangd/Headers.cpp
clang-tools-extra/trunk/clangd/Headers.h

Modified: clang-tools-extra/trunk/clangd/Headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=343223&r1=343222&r2=343223&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.cpp (original)
+++ clang-tools-extra/trunk/clangd/Headers.cpp Thu Sep 27 07:27:02 2018
@@ -126,6 +126,12 @@ IncludeStructure::includeDepth(llvm::Str
   return Result;
 }
 
+void IncludeInserter::addExisting(const Inclusion &Inc) {
+  IncludedHeaders.insert(Inc.Written);
+  if (!Inc.Resolved.empty())
+IncludedHeaders.insert(Inc.Resolved);
+}
+
 /// FIXME(ioeric): we might not want to insert an absolute include path if the
 /// path is not shortened.
 bool IncludeInserter::shouldInsertInclude(
@@ -133,12 +139,6 @@ bool IncludeInserter::shouldInsertInclud
   assert(DeclaringHeader.valid() && InsertedHeader.valid());
   if (FileName == DeclaringHeader.File || FileName == InsertedHeader.File)
 return false;
-  llvm::StringSet<> IncludedHeaders;
-  for (const auto &Inc : Inclusions) {
-IncludedHeaders.insert(Inc.Written);
-if (!Inc.Resolved.empty())
-  IncludedHeaders.insert(Inc.Resolved);
-  }
   auto Included = [&](llvm::StringRef Header) {
 return IncludedHeaders.find(Header) != IncludedHeaders.end();
   };

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=343223&r1=343222&r2=343223&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Thu Sep 27 07:27:02 2018
@@ -97,7 +97,7 @@ public:
 HeaderSearchInfo(HeaderSearchInfo),
 Inserter(FileName, Code, Style.IncludeStyle) {}
 
-  void addExisting(Inclusion Inc) { Inclusions.push_back(std::move(Inc)); }
+  void addExisting(const Inclusion &Inc);
 
   /// Checks whether to add an #include of the header into \p File.
   /// An #include will not be added if:
@@ -134,8 +134,8 @@ private:
   StringRef Code;
   StringRef BuildDir;
   HeaderSearch &HeaderSearchInfo;
-  std::vector Inclusions;
-  tooling::HeaderIncludes Inserter; // Computers insertion replacement.
+  llvm::StringSet<> IncludedHeaders; // Both written and resolved.
+  tooling::HeaderIncludes Inserter;  // Computers insertion replacement.
 };
 
 } // namespace clangd


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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

Also, regarding error handling and `llvm::Option` vs `llvm::Expected`: I think 
the case where the check most likely wouldn't be able to provide useful 
diagnostics and perform enough analysis is when there are macro expansions 
within inspected statement `SourceRange`. It might make sense to completely 
disable it in this case both because it's hard to do anything about the range 
transformation and because it seems to be hard to analyze this case. E.g. if 
the whole statement is expanded from a single macro and then the check would 
report on every macro usage (while the actual problem is in the macro itself). 
I don't know whether the check should support macros at all, it might make 
sense to mention this in the documentation and add few tests if we decide to go 
this way.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52611: [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clangd/index/dex/Dex.cpp:143
  "There must be no :: in query.");
+  trace::Span Tracer("Dex fuzzyFind");
   FuzzyMatcher Filter(Req.Query);

sammccall wrote:
> We should attach the query tree to the span here.
> 
> Right now that's not practical as the dump() representation holds the posting 
> lists rather than their token, but maybe add a FIXME?
Yes, that's an interesting topic. I was thinking about better dump format for 
queries for the `dexp` commands (namely, `find`): right now there's no API to 
pull even the query dump for the external callers, so this is another problem. 
For better format, I was thinking about adding either `LABEL` iterator or 
actually having `StringRef Iterator::label() const;` as most iterators are 
likely to have one. E.g. PostingList's can store the `Token` reference, but 
then we're likely to run into the memory issues so it can be disabled in all 
builds other than `DEBUG`. Other iterators are fine, because they are only 
constructed once per query and never stored afterwards.

And it would be very useful to see the full query structure for both debugging 
purposes and for understanding which queries are slow (and why). I thought 
about measuring distinct queries latency to have better statistics (latency 
histogram & distributions) to understand how to optimize Dex and improve 
performance.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52611



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


[PATCH] D52364: [clangd] Initial supoprt for cross-namespace global code completion.

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clangd/index/dex/Dex.cpp:171
   }
+  if (Req.AnyScope)
+ScopeIterators.push_back(createBoost(createTrue(Symbols.size()), 0.2));

Probably also check `!ScopeIterators.empty()`: otherwise the latency might 
increase for queries without any scope/any scope known to `Dex`.



Comment at: unittests/clangd/DexTests.cpp:557
 
+TEST(DexTest, WildcardScope) {
+  auto I =

Probably also add test which ensures that wildcard symbols are downranked in 
the presence of `Req.Scopes` (ProximityPathsBoosting test is probably the 
closest in this sense)? Isn't too important, but nice-to-have in the presence 
of `ScopesProximity` plans (judging from the `FIXME` in `FuzzyFindRequest`).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52364



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

kbobyrev wrote:
> JonasToth wrote:
> > kbobyrev wrote:
> > > How about `multiple declarations within a single statement hurts 
> > > readability`?
> > s/hurts/reduces/? hurts sound a bit weird i think.
> > 
> > Lebedev wanted the number of decls in the diagnostic, would you include it 
> > or rather now?
> "decreases" is also fine. "hurts" is probably too strong, I agree.
> 
> Up to you. Personally, I don't see any value in having the diagnostic message 
> saying "hey, you have 2 declarations within one statement, that's really 
> bad!" or "hey, you have 5 declarations within one statement..." - in both 
> cases the point is that there are *multiple* declarations. I also don't think 
> it would make debugging easier because you also check the formatting, so you 
> already imply that the correct number of declarations was detected.
> 
> I'm interested to know what @lebedev.ri thinks.
> I'm interested to know what @lebedev.ri thinks.

"This translation unit has an error. Can not continue" is also a diagnostic 
message.
Why are we not ok with that one, and want compiler to be a bit more specific?

Similarly here, why just point out that this code is bad as per the check,
without giving a little bit more info, that you already have?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


r343224 - [Tooling] Get rid of uses of llvm::Twine::str which is slow. NFC

2018-09-27 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Sep 27 07:50:24 2018
New Revision: 343224

URL: http://llvm.org/viewvc/llvm-project?rev=343224&view=rev
Log:
[Tooling] Get rid of uses of llvm::Twine::str which is slow. NFC

Modified:
cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp

Modified: cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp?rev=343224&r1=343223&r2=343224&view=diff
==
--- cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp (original)
+++ cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp Thu Sep 27 07:50:24 2018
@@ -10,6 +10,7 @@
 #include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/Support/FormatVariadic.h"
 
 namespace clang {
 namespace tooling {
@@ -181,7 +182,7 @@ bool IncludeCategoryManager::isMainHeade
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem) ||
   FileStem.startswith_lower(HeaderStem)) {
-llvm::Regex MainIncludeRegex((HeaderStem + Style.IncludeIsMainRegex).str(),
+llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,
  llvm::Regex::IgnoreCase);
 if (MainIncludeRegex.match(FileStem))
   return true;
@@ -275,8 +276,8 @@ HeaderIncludes::insert(llvm::StringRef I
   if ((IsAngled && StringRef(Inc.Name).startswith("<")) ||
   (!IsAngled && StringRef(Inc.Name).startswith("\"")))
 return llvm::None;
-  std::string Quoted = IsAngled ? ("<" + IncludeName + ">").str()
-: ("\"" + IncludeName + "\"").str();
+  std::string Quoted =
+  llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName);
   StringRef QuotedName = Quoted;
   int Priority = Categories.getIncludePriority(
   QuotedName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
@@ -293,7 +294,7 @@ HeaderIncludes::insert(llvm::StringRef I
 }
   }
   assert(InsertOffset <= Code.size());
-  std::string NewInclude = ("#include " + QuotedName + "\n").str();
+  std::string NewInclude = llvm::formatv("#include {0}\n", QuotedName);
   // When inserting headers at end of the code, also append '\n' to the code
   // if it does not end with '\n'.
   // FIXME: when inserting multiple #includes at the end of code, only one


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


[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 167326.
gtbercea added a comment.

Fix type of chunk size.


Repository:
  rC Clang

https://reviews.llvm.org/D52434

Files:
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -33,7 +33,7 @@
 l = i;
   }
 
-  #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
+ #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
   for(int i = 0; i < n; i++) {
 aa[i] += 1;
   }
@@ -82,7 +82,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -96,7 +96,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -112,7 +112,7 @@
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
 // CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -35,7 +35,7 @@
 l = i;
   }
 
-  #pragma omp target teams distribute parallel for map(tofrom: aa) num_teams(M) thread_limit(64)
+#pragma omp target teams distribute parallel for map(tofrom: aa) num_teams(M) thread_limit(64)
   for(int i = 0; i < n; i++) {
 aa[i] += 1;
   }
@@ -87,7 +87,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -101,7 +101,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -117,7 +117,7 @@
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
 // CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
Index: lib/CodeGen/CGStmtOpenMP.cpp

[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

https://reviews.llvm.org/D52434



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


[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Should we also change the default `schedule` to `static, 1`? I know that's not 
really needed for `teams distribute parallel for` (because the new default 
`dist_schedule` only leaves one iteration per thread), but this doesn't happen 
for `target parallel for`. Additionally it would make the intent more explicit 
and LLVM doesn't need to look through divisions needed to implement `static` 
without chunk. Just thinking aloud, not sure if that's worth it.


Repository:
  rC Clang

https://reviews.llvm.org/D52434



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

lebedev.ri wrote:
> kbobyrev wrote:
> > JonasToth wrote:
> > > kbobyrev wrote:
> > > > How about `multiple declarations within a single statement hurts 
> > > > readability`?
> > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > 
> > > Lebedev wanted the number of decls in the diagnostic, would you include 
> > > it or rather now?
> > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > 
> > Up to you. Personally, I don't see any value in having the diagnostic 
> > message saying "hey, you have 2 declarations within one statement, that's 
> > really bad!" or "hey, you have 5 declarations within one statement..." - in 
> > both cases the point is that there are *multiple* declarations. I also 
> > don't think it would make debugging easier because you also check the 
> > formatting, so you already imply that the correct number of declarations 
> > was detected.
> > 
> > I'm interested to know what @lebedev.ri thinks.
> > I'm interested to know what @lebedev.ri thinks.
> 
> "This translation unit has an error. Can not continue" is also a diagnostic 
> message.
> Why are we not ok with that one, and want compiler to be a bit more specific?
> 
> Similarly here, why just point out that this code is bad as per the check,
> without giving a little bit more info, that you already have?
> "This translation unit has an error. Can not continue" is also a diagnostic 
> message.
>Why are we not ok with that one, and want compiler to be a bit more specific?
>
> Similarly here, why just point out that this code is bad as per the check, 
> without giving a little bit more info, that you already have?

More information doesn't always equate into more understanding, especially when 
that information causes a distraction. For instance, you could argue that the 
type of the declared variables is also information we already have, but what 
purpose would it serve to tell it to the user?

Can you give an example where the specific number of declarations involved 
would help you to correct the diagnostic? I can't come up with one, so it feels 
to me like having the count is more of a distraction; especially given that 
there's no configurable threshold for "now you have too many declarations". I'd 
feel differently if there was a config option, because then the count is truly 
useful to know.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-09-27 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab created this revision.
filcab added reviewers: rjmccall, kcc, rsmith.

Repository:
  rC Clang

https://reviews.llvm.org/D52615

Files:
  include/clang/Driver/SanitizerArgs.h
  lib/Driver/SanitizerArgs.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -191,6 +191,24 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie -### -- %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE: 
-cc1{{.*}}-fsanitize-address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-OFF
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie -### -- %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-OFF
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-OFF-NOT: 
-cc1{{.*}}address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie 
-fsanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie 
-fsanitize-address-poison-class-member-array-new-cookie -### -- %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH: 
-cc1{{.*}}-fsanitize-address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie 
-fno-sanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH-OFF
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH-OFF-NOT: 
-cc1{{.*}}address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s 
--check-prefix=CHECK-ASAN-WITHOUT-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE
+// CHECK-ASAN-WITHOUT-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-NOT: 
-cc1{{.*}}address-poison-class-member-array-new-cookie
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
 // RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -724,6 +724,11 @@
 options::OPT_fsanitize_address_use_after_scope,
 options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
 
+AsanPoisonClassMemberOperatorNew = Args.hasFlag(
+options::OPT_fsanitize_address_poison_class_member_array_new_cookie,
+options::OPT_fno_sanitize_address_poison_class_member_array_new_cookie,
+AsanPoisonClassMemberOperatorNew);
+
 // As a workaround for a bug in gold 2.26 and earlier, dead stripping of
 // globals in ASan is disabled by default on ELF targets.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
@@ -897,6 +902,10 @@
   if (AsanUseAfterScope)
 CmdArgs.push_back("-fsanitize-address-use-after-scope");
 
+  if (AsanPoisonClassMemberOperatorNew)
+CmdArgs.push_back(
+"-fsanitize-address-poison-class-member-array-new-cookie");
+
   if (AsanGlobalsDeadStripping)
 CmdArgs.push_back("-fsanitize-address-globals-dead-stripping");
 
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -36,6 +36,7 @@
   int AsanFieldPadding = 0;
   bool SharedRuntime = false;
   bool AsanUseAfterScope = true;
+  bool AsanPoisonClassMemberOperat

[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, ioeric, ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds);
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -683,36 +735,6 @@
 };
 llvm::json::Value toJSON(const Hover &H);
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value &E, CompletionItemKind &Out) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::File) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value &E, std::vector &Out) {
+  if (auto *A = E.getAsArray()) {
+Out.clear();
+for (size_t I = 0; I < A->size(); ++I) {
+  CompletionItemKind KindOut;
+  if (fromJSON((*A)[I], KindOut))
+Out.push_back(KindOut);
+}
+return true;
+  }
+  return false;
+}
+
+bool fromJSON(const json::Value &Params, CompletionItemKindCapabilities &R) {
+  json::ObjectMapper O(Params

[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D52434#1248012, @Hahnfeld wrote:

> Should we also change the default `schedule` to `static, 1`? I know that's 
> not really needed for `teams distribute parallel for` (because the new 
> default `dist_schedule` only leaves one iteration per thread), but this 
> doesn't happen for `target parallel for`. Additionally it would make the 
> intent more explicit and LLVM doesn't need to look through divisions needed 
> to implement `static` without chunk. Just thinking aloud, not sure if that's 
> worth it.


That is the intention. I just took out that part from here to not confuse 
things since I wanted to have that as a separate patch. :)


Repository:
  rC Clang

https://reviews.llvm.org/D52434



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


[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a comment.

In https://reviews.llvm.org/D52434#1248032, @gtbercea wrote:

> That is the intention. I just took out that part from here to not confuse 
> things since I wanted to have that as a separate patch. :)


Ok, perfect. I was probably confused that the title still speaks about 
"schedules" (plural).


Repository:
  rC Clang

https://reviews.llvm.org/D52434



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


[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-09-27 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:305
   enum ImplicitConversionCheckKind : unsigned char {
-ICCK_IntegerTruncation = 0,
+ICCK_IntegerTruncation = 0, // Legacy, no longer used.
+ICCK_UnsignedIntegerTruncation = 1,

vitalybuka wrote:
> lebedev.ri wrote:
> > vitalybuka wrote:
> > > why do you need to keep it?
> > *Here* - for consistency with the compiler-rt part.
> > 
> > There - what about mismatch in the used clang version
> > (which still only produced the `(ImplicitConversionCheckKind)0`), and 
> > compiler-rt version
> > (which has `(ImplicitConversionCheckKind)1` and 
> > `(ImplicitConversionCheckKind)2`)?
> > Is it 100.00% guaranteed not to happen? I'm not so sure.
> I don't think we try support mismatched versions of clang and compiler-rt
We don't make a big effort in open source. But we try to at least make it work 
(check previous work on type_mismatch handler, before versions were 
introduced), or error "loudly" when linking (versioned checks).

I think having keeping the older check number free is a good thing and allows 
us to have binary compatibility with older objects (and keep supporting old 
object files (we *did* release llvm 7.0 with the old-type check)).

If we hadn't had a release in between, I'd be all for reusing.


Repository:
  rC Clang

https://reviews.llvm.org/D50901



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


[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 167332.
kadircet added a comment.

- Minimum CompletionItemKind is Text.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds);
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -683,36 +735,6 @@
 };
 llvm::json::Value toJSON(const Hover &H);
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value &E, CompletionItemKind &Out) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::Text) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value &E, std::vector &Out) {
+  if (auto *A = E.getAsArray()) {
+Out.clear();
+for (size_t I = 0; I < A->size(); ++I) {
+  CompletionItemKind KindOut;
+  if (fromJSON((*A)[I], KindOut))
+Out.push_back(KindOut);
+}
+return true;
+  }
+  return false;
+}
+
+bool fromJSON(const json::Value &Params, CompletionItemKindCapabilities &R) {
+  json::ObjectMapper O(Params);
+  return O && O.map("valueSet", R.

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

aaron.ballman wrote:
> lebedev.ri wrote:
> > kbobyrev wrote:
> > > JonasToth wrote:
> > > > kbobyrev wrote:
> > > > > How about `multiple declarations within a single statement hurts 
> > > > > readability`?
> > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > 
> > > > Lebedev wanted the number of decls in the diagnostic, would you include 
> > > > it or rather now?
> > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > 
> > > Up to you. Personally, I don't see any value in having the diagnostic 
> > > message saying "hey, you have 2 declarations within one statement, that's 
> > > really bad!" or "hey, you have 5 declarations within one statement..." - 
> > > in both cases the point is that there are *multiple* declarations. I also 
> > > don't think it would make debugging easier because you also check the 
> > > formatting, so you already imply that the correct number of declarations 
> > > was detected.
> > > 
> > > I'm interested to know what @lebedev.ri thinks.
> > > I'm interested to know what @lebedev.ri thinks.
> > 
> > "This translation unit has an error. Can not continue" is also a diagnostic 
> > message.
> > Why are we not ok with that one, and want compiler to be a bit more 
> > specific?
> > 
> > Similarly here, why just point out that this code is bad as per the check,
> > without giving a little bit more info, that you already have?
> > "This translation unit has an error. Can not continue" is also a diagnostic 
> > message.
> >Why are we not ok with that one, and want compiler to be a bit more specific?
> >
> > Similarly here, why just point out that this code is bad as per the check, 
> > without giving a little bit more info, that you already have?
> 
> More information doesn't always equate into more understanding, especially 
> when that information causes a distraction. For instance, you could argue 
> that the type of the declared variables is also information we already have, 
> but what purpose would it serve to tell it to the user?
> 
> Can you give an example where the specific number of declarations involved 
> would help you to correct the diagnostic? I can't come up with one, so it 
> feels to me like having the count is more of a distraction; especially given 
> that there's no configurable threshold for "now you have too many 
> declarations". I'd feel differently if there was a config option, because 
> then the count is truly useful to know.
Oh, but that's different: "This translation unit has an error. Can not 
continue" does not provide enough information for users to fix the issue, 
pointing out that there are *multiple* declarations per statement is definitely 
enough.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52617: [clangd] Make stable_partition on include candidates less slow. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.

stable_partition on objects is slow (due to copies). Do it on pointers
instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52617

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h


Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -145,7 +145,8 @@
   // include is used.
   // If we've bundled together overloads that have different sets of includes,
   // thse includes may not be accurate for all of them.
-  llvm::SmallVector Includes;
+  using IncludeCandidates = llvm::SmallVector;
+  IncludeCandidates Includes;
 
   /// Holds information about small corrections that needs to be done. Like
   /// converting '->' to '.' on member access.
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -320,6 +320,25 @@
   }
 };
 
+// Moves includes that do not need edits (i.e. already exist) to the front.
+CodeCompletion::IncludeCandidates
+moveNonInsertingIncludesToFront(CodeCompletion::IncludeCandidates Includes) {
+  if (Includes.size() <= 1)
+return Includes;
+  // stable_partition on objects is slow. Do it on pointers instead.
+  llvm::SmallVector Pointers;
+  for (auto &Inc : Includes)
+Pointers.push_back(&Inc);
+  std::stable_partition(Pointers.begin(), Pointers.end(),
+[](const CodeCompletion::IncludeCandidate *I) {
+  return !I->Insertion.hasValue();
+});
+  CodeCompletion::IncludeCandidates Results;
+  for (auto *Inc : Pointers)
+Results.push_back(std::move(*Inc));
+  return Results;
+}
+
 // Assembles a code completion out of a bundle of >=1 completion candidates.
 // Many of the expensive strings are only computed at this point, once we know
 // the candidate bundle is going to be returned.
@@ -393,24 +412,21 @@
 };
 bool ShouldInsert = C.headerToInsertIfAllowed().hasValue();
 // Calculate include paths and edits for all possible headers.
+llvm::SmallVector IncludeCandidates;
 for (const auto &Inc : C.RankedIncludeHeaders) {
   if (auto ToInclude = Inserted(Inc)) {
 CodeCompletion::IncludeCandidate Include;
 Include.Header = ToInclude->first;
 if (ToInclude->second && ShouldInsert)
   Include.Insertion = Includes.insert(ToInclude->first);
-Completion.Includes.push_back(std::move(Include));
+IncludeCandidates.push_back(std::move(Include));
   } else
 log("Failed to generate include insertion edits for adding header "
 "(FileURI='{0}', IncludeHeader='{1}') into {2}",
 C.IndexResult->CanonicalDeclaration.FileURI, Inc, FileName);
 }
-// Prefer includes that do not need edits (i.e. already exist).
-std::stable_partition(Completion.Includes.begin(),
-  Completion.Includes.end(),
-  [](const CodeCompletion::IncludeCandidate &I) {
-return !I.Insertion.hasValue();
-  });
+Completion.Includes =
+moveNonInsertingIncludesToFront(std::move(IncludeCandidates));
   }
 
   void add(const CompletionCandidate &C, CodeCompletionString *SemaCCS) {


Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -145,7 +145,8 @@
   // include is used.
   // If we've bundled together overloads that have different sets of includes,
   // thse includes may not be accurate for all of them.
-  llvm::SmallVector Includes;
+  using IncludeCandidates = llvm::SmallVector;
+  IncludeCandidates Includes;
 
   /// Holds information about small corrections that needs to be done. Like
   /// converting '->' to '.' on member access.
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -320,6 +320,25 @@
   }
 };
 
+// Moves includes that do not need edits (i.e. already exist) to the front.
+CodeCompletion::IncludeCandidates
+moveNonInsertingIncludesToFront(CodeCompletion::IncludeCandidates Includes) {
+  if (Includes.size() <= 1)
+return Includes;
+  // stable_partition on objects is slow. Do it on pointers instead.
+  llvm::SmallVector Pointers;
+  for (auto &Inc : Includes)
+Pointers.push_back(&Inc);
+  std::stable_partition(Pointers.begin(), Pointers.end(),
+[](const CodeCompletion::IncludeCandidate *I) {
+  return !I->Insertion.hasValue();
+});
+  CodeCompletion::IncludeCandidates Results;
+  for (auto *Inc : Pointers)
+Results.push_back(std::move(*Inc));
+  return R

[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-27 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

Yes, moving StdCLibraryFunctionsChecker to an always-loaded package is probably 
a better solution than adding this one particular dependency link. (Evaluating 
these functions may be useful for other checkers as well, although it does not 
seem to change the results of other regression tests.) As an alternative to 
moving this checker to either the core or the apiModeling package, we could add 
unix.StdCLibraryFunctions to the dozen or so loaded-by-default checkers listed 
in lib/Driver/ToolChains/Clang.cpp without moving it to a different package. 
Which of these options is the best?


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

There are testcases with macro around line 100 in the default tests. I
am not sure yet if `#define I_DECLS int i1, i2, i3;` should be
diagnosed, but the other cases should.

Am 27.09.2018 um 16:28 schrieb Kirill Bobyrev via Phabricator:

> kbobyrev added a comment.
> 
> Also, regarding error handling and `llvm::Option` vs `llvm::Expected`: I 
> think the case where the check most likely wouldn't be able to provide useful 
> diagnostics and perform enough analysis is when there are macro expansions 
> within inspected statement `SourceRange`. It might make sense to completely 
> disable it in this case both because it's hard to do anything about the range 
> transformation and because it seems to be hard to analyze this case. E.g. if 
> the whole statement is expanded from a single macro and then the check would 
> report on every macro usage (while the actual problem is in the macro 
> itself). I don't know whether the check should support macros at all, it 
> might make sense to mention this in the documentation and add few tests if we 
> decide to go this way.
> 
> Repository:
> 
>   rCTE Clang Tools Extra
> 
> https://reviews.llvm.org/D51949


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52595: [ARM] Alter test to account for change to armv6k default CPU

2018-09-27 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Thanks Peter. LGTM!


https://reviews.llvm.org/D52595



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

kbobyrev wrote:
> aaron.ballman wrote:
> > lebedev.ri wrote:
> > > kbobyrev wrote:
> > > > JonasToth wrote:
> > > > > kbobyrev wrote:
> > > > > > How about `multiple declarations within a single statement hurts 
> > > > > > readability`?
> > > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > > 
> > > > > Lebedev wanted the number of decls in the diagnostic, would you 
> > > > > include it or rather now?
> > > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > > 
> > > > Up to you. Personally, I don't see any value in having the diagnostic 
> > > > message saying "hey, you have 2 declarations within one statement, 
> > > > that's really bad!" or "hey, you have 5 declarations within one 
> > > > statement..." - in both cases the point is that there are *multiple* 
> > > > declarations. I also don't think it would make debugging easier because 
> > > > you also check the formatting, so you already imply that the correct 
> > > > number of declarations was detected.
> > > > 
> > > > I'm interested to know what @lebedev.ri thinks.
> > > > I'm interested to know what @lebedev.ri thinks.
> > > 
> > > "This translation unit has an error. Can not continue" is also a 
> > > diagnostic message.
> > > Why are we not ok with that one, and want compiler to be a bit more 
> > > specific?
> > > 
> > > Similarly here, why just point out that this code is bad as per the check,
> > > without giving a little bit more info, that you already have?
> > > "This translation unit has an error. Can not continue" is also a 
> > > diagnostic message.
> > >Why are we not ok with that one, and want compiler to be a bit more 
> > >specific?
> > >
> > > Similarly here, why just point out that this code is bad as per the 
> > > check, without giving a little bit more info, that you already have?
> > 
> > More information doesn't always equate into more understanding, especially 
> > when that information causes a distraction. For instance, you could argue 
> > that the type of the declared variables is also information we already 
> > have, but what purpose would it serve to tell it to the user?
> > 
> > Can you give an example where the specific number of declarations involved 
> > would help you to correct the diagnostic? I can't come up with one, so it 
> > feels to me like having the count is more of a distraction; especially 
> > given that there's no configurable threshold for "now you have too many 
> > declarations". I'd feel differently if there was a config option, because 
> > then the count is truly useful to know.
> Oh, but that's different: "This translation unit has an error. Can not 
> continue" does not provide enough information for users to fix the issue, 
> pointing out that there are *multiple* declarations per statement is 
> definitely enough.
I am personally against having the number in the diagnostic as well, it would 
only add value if the declarations are expanded from a macro.

@aaron.ballman Configuration of this check would be intersting but i would 
rather postpone that and have a basic working check first. Given that this aims 
to be utility-like to evaluate `const-correctness` and/or to be usable with 
other checks doing type transformations.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52611: [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 167336.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52611

Files:
  clangd/index/MemIndex.cpp
  clangd/index/Merge.cpp
  clangd/index/dex/Dex.cpp

Index: clangd/index/dex/Dex.cpp
===
--- clangd/index/dex/Dex.cpp
+++ clangd/index/dex/Dex.cpp
@@ -12,6 +12,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 #include "llvm/ADT/StringSet.h"
 #include 
 #include 
@@ -139,6 +140,8 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  // FIXME: attach the query tree to the trace span.
+  trace::Span Tracer("Dex fuzzyFind");
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
 
@@ -228,6 +231,7 @@
 
 void Dex::lookup(const LookupRequest &Req,
  llvm::function_ref Callback) const {
+  trace::Span Tracer("Dex lookup");
   for (const auto &ID : Req.IDs) {
 auto I = LookupTable.find(ID);
 if (I != LookupTable.end())
@@ -237,6 +241,7 @@
 
 void Dex::refs(const RefsRequest &Req,
llvm::function_ref Callback) const {
+  trace::Span Tracer("Dex refs");
   log("refs is not implemented.");
 }
 
Index: clangd/index/Merge.cpp
===
--- clangd/index/Merge.cpp
+++ clangd/index/Merge.cpp
@@ -9,6 +9,7 @@
 
 #include "Merge.h"
 #include "Logger.h"
+#include "Trace.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
@@ -38,19 +39,31 @@
  //a) if it's not in the dynamic slab, yield it directly
  //b) if it's in the dynamic slab, merge it and yield the result
  //  3) now yield all the dynamic symbols we haven't processed.
+ trace::Span Tracer("MergedIndex fuzzyFind");
  bool More = false; // We'll be incomplete if either source was.
  SymbolSlab::Builder DynB;
- More |= Dynamic->fuzzyFind(Req, [&](const Symbol &S) { DynB.insert(S); });
+ unsigned DynamicCount = 0;
+ unsigned StaticCount = 0;
+ unsigned MergedCount = 0;
+ More |= Dynamic->fuzzyFind(Req, [&](const Symbol &S) {
+   ++DynamicCount;
+   DynB.insert(S);
+ });
  SymbolSlab Dyn = std::move(DynB).build();
 
  DenseSet SeenDynamicSymbols;
  More |= Static->fuzzyFind(Req, [&](const Symbol &S) {
auto DynS = Dyn.find(S.ID);
+   ++StaticCount;
if (DynS == Dyn.end())
  return Callback(S);
+   ++MergedCount;
SeenDynamicSymbols.insert(S.ID);
Callback(mergeSymbol(*DynS, S));
  });
+ SPAN_ATTACH(Tracer, "dynamic", DynamicCount);
+ SPAN_ATTACH(Tracer, "static", StaticCount);
+ SPAN_ATTACH(Tracer, "merged", MergedCount);
  for (const Symbol &S : Dyn)
if (!SeenDynamicSymbols.count(S.ID))
  Callback(S);
@@ -60,6 +73,7 @@
   void
   lookup(const LookupRequest &Req,
  llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex lookup");
 SymbolSlab::Builder B;
 
 Dynamic->lookup(Req, [&](const Symbol &S) { B.insert(S); });
@@ -80,6 +94,7 @@
 
   void refs(const RefsRequest &Req,
 llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex refs");
 // We don't want duplicated refs from the static/dynamic indexes,
 // and we can't reliably duplicate them because offsets may differ slightly.
 // We consider the dynamic index authoritative and report all its refs,
Index: clangd/index/MemIndex.cpp
===
--- clangd/index/MemIndex.cpp
+++ clangd/index/MemIndex.cpp
@@ -11,6 +11,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 
 namespace clang {
 namespace clangd {
@@ -28,6 +29,7 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  trace::Span Tracer("MemIndex fuzzyFind");
 
   TopN> Top(
   Req.Limit ? *Req.Limit : std::numeric_limits::max());
@@ -47,13 +49,16 @@
   if (Top.push({*Score * quality(*Sym), Sym}))
 More = true; // An element with smallest score was discarded.
   }
-  for (const auto &Item : std::move(Top).items())
+  auto Results = std::move(Top).items();
+  SPAN_ATTACH(Tracer, "results", static_cast(Results.size()));
+  for (const auto &Item : Results)
 Callback(*Item.second);
   return More;
 }
 
 void MemIndex::lookup(const LookupRequest &Req,
   llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex lookup");
   for (const auto &ID : Req.IDs) {
 auto I = Index.find(ID);
 if (I != Index.end())
@@ -63,6 +68,7 @@
 
 void MemIndex::refs(const RefsRequest &Req,
 llv

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

JonasToth wrote:
> kbobyrev wrote:
> > aaron.ballman wrote:
> > > lebedev.ri wrote:
> > > > kbobyrev wrote:
> > > > > JonasToth wrote:
> > > > > > kbobyrev wrote:
> > > > > > > How about `multiple declarations within a single statement hurts 
> > > > > > > readability`?
> > > > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > > > 
> > > > > > Lebedev wanted the number of decls in the diagnostic, would you 
> > > > > > include it or rather now?
> > > > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > > > 
> > > > > Up to you. Personally, I don't see any value in having the diagnostic 
> > > > > message saying "hey, you have 2 declarations within one statement, 
> > > > > that's really bad!" or "hey, you have 5 declarations within one 
> > > > > statement..." - in both cases the point is that there are *multiple* 
> > > > > declarations. I also don't think it would make debugging easier 
> > > > > because you also check the formatting, so you already imply that the 
> > > > > correct number of declarations was detected.
> > > > > 
> > > > > I'm interested to know what @lebedev.ri thinks.
> > > > > I'm interested to know what @lebedev.ri thinks.
> > > > 
> > > > "This translation unit has an error. Can not continue" is also a 
> > > > diagnostic message.
> > > > Why are we not ok with that one, and want compiler to be a bit more 
> > > > specific?
> > > > 
> > > > Similarly here, why just point out that this code is bad as per the 
> > > > check,
> > > > without giving a little bit more info, that you already have?
> > > > "This translation unit has an error. Can not continue" is also a 
> > > > diagnostic message.
> > > >Why are we not ok with that one, and want compiler to be a bit more 
> > > >specific?
> > > >
> > > > Similarly here, why just point out that this code is bad as per the 
> > > > check, without giving a little bit more info, that you already have?
> > > 
> > > More information doesn't always equate into more understanding, 
> > > especially when that information causes a distraction. For instance, you 
> > > could argue that the type of the declared variables is also information 
> > > we already have, but what purpose would it serve to tell it to the user?
> > > 
> > > Can you give an example where the specific number of declarations 
> > > involved would help you to correct the diagnostic? I can't come up with 
> > > one, so it feels to me like having the count is more of a distraction; 
> > > especially given that there's no configurable threshold for "now you have 
> > > too many declarations". I'd feel differently if there was a config 
> > > option, because then the count is truly useful to know.
> > Oh, but that's different: "This translation unit has an error. Can not 
> > continue" does not provide enough information for users to fix the issue, 
> > pointing out that there are *multiple* declarations per statement is 
> > definitely enough.
> I am personally against having the number in the diagnostic as well, it would 
> only add value if the declarations are expanded from a macro.
> 
> @aaron.ballman Configuration of this check would be intersting but i would 
> rather postpone that and have a basic working check first. Given that this 
> aims to be utility-like to evaluate `const-correctness` and/or to be usable 
> with other checks doing type transformations.
Yeah, I wasn't suggesting a threshold config option for this patch so much as 
pointing out why I'm opposed to putting the count in the diagnostic.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167340.

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+// MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 -

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a subscriber: rsmith.
wzssyqa added a comment.

I updated N32 patch for clang.
Simon Atanasyan via Phabricator 
于2018年9月27日周四 下午8:23写道:

> atanasyan added a comment.
> 
> Could you please update the patch against the current trunk?
> 
> Repository:
> 
>   rC Clang
> 
> https://reviews.llvm.org/D50850


Repository:
  rC Clang

https://reviews.llvm.org/D50850



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


r343230 - [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Sep 27 09:12:32 2018
New Revision: 343230

URL: http://llvm.org/viewvc/llvm-project?rev=343230&view=rev
Log:
[OpenMP] Improve search for libomptarget-nvptx

When looking for the bclib Clang considered the default library
path first while it preferred directories in LIBRARY_PATH when
constructing the invocation of nvlink. The latter actually makes
more sense because during development it allows using a non-default
runtime library. So change the search for the bclib to start
looking in directories given by LIBRARY_PATH.
Additionally add a new option --libomptarget-nvptx-path= which
will be searched first. This will be handy for testing purposes.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=343230&r1=343229&r2=343230&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Sep 27 09:12:32 2018
@@ -596,6 +596,8 @@ def hip_device_lib_EQ : Joined<["--"], "
   HelpText<"HIP device library">;
 def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def libomptarget_nvptx_path_EQ : Joined<["--"], "libomptarget-nvptx-path=">, 
Group,
+  HelpText<"Path to libomptarget-nvptx libraries">;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal output">;

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=343230&r1=343229&r2=343230&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Sep 27 09:12:32 2018
@@ -511,6 +511,11 @@ void NVPTX::OpenMPLinker::ConstructJob(C
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
+  // Assume that the directory specified with --libomptarget_nvptx_path
+  // contains the static library libomptarget-nvptx.a.
+  if (const Arg *A = Args.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("-L") + A->getValue()));
+
   // Add paths specified in LIBRARY_PATH environment variable as -L options.
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 
@@ -647,12 +652,9 @@ void CudaToolChain::addClangTargetOption
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
-// Add path to lib and/or lib64 folders.
-SmallString<256> DefaultLibPath =
-  llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath,
-Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+if (const Arg *A = 
DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+  LibraryPaths.push_back(A->getValue());
 
 // Add user defined library paths from LIBRARY_PATH.
 llvm::Optional LibPath =
@@ -665,6 +667,12 @@ void CudaToolChain::addClangTargetOption
 LibraryPaths.emplace_back(Path.trim());
 }
 
+// Add path to lib / lib64 folder.
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
 std::string LibOmpTargetName =
   "libomptarget-nvptx-" + GpuArch.str() + ".bc";
 bool FoundBCLibrary = false;

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=343230&r1=343229&r2=343230&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Thu Sep 27 09:12:32 2018
@@ -30,6 +30,22 @@
 
 /// ###
 
+/// Check that -lomptarget-nvptx is passed to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NVLINK %s
+/// Check that the value of --libomptarget-nvptx-path is forwarded to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  --libomptarget-nvptx-path=/path/to/libomptarget/ \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHK-NVLINK,C

Re: [PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via cfe-commits
I updated N32 patch for clang.
Simon Atanasyan via Phabricator 
于2018年9月27日周四 下午8:23写道:
>
> atanasyan added a comment.
>
> Could you please update the patch against the current trunk?
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D50850
>
>
>


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


[PATCH] D51686: [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343230: [OpenMP] Improve search for libomptarget-nvptx 
(authored by Hahnfeld, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51686

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -30,6 +30,22 @@
 
 /// ###
 
+/// Check that -lomptarget-nvptx is passed to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NVLINK %s
+/// Check that the value of --libomptarget-nvptx-path is forwarded to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  --libomptarget-nvptx-path=/path/to/libomptarget/ \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHK-NVLINK,CHK-LIBOMPTARGET-NVPTX-PATH %s
+
+// CHK-NVLINK: nvlink
+// CHK-LIBOMPTARGET-NVPTX-PATH-SAME: "-L/path/to/libomptarget/"
+// CHK-NVLINK-SAME: "-lomptarget-nvptx"
+
+/// ###
+
 /// Check cubin file generation and usage by nvlink
 // RUN:   %clang -### -no-canonical-prefixes -target 
powerpc64le-unknown-linux-gnu -fopenmp=libomp \
 // RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
@@ -151,6 +167,11 @@
 // RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
 // RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+/// The user can override default detection using --libomptarget-nvptx-path=.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--libomptarget-nvptx-path=%S/Inputs/libomptarget \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
 // CHK-BCLIB-NOT: {{error:|warning:}}
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -511,6 +511,11 @@
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
+  // Assume that the directory specified with --libomptarget_nvptx_path
+  // contains the static library libomptarget-nvptx.a.
+  if (const Arg *A = Args.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("-L") + A->getValue()));
+
   // Add paths specified in LIBRARY_PATH environment variable as -L options.
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 
@@ -647,12 +652,9 @@
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
-// Add path to lib and/or lib64 folders.
-SmallString<256> DefaultLibPath =
-  llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath,
-Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+if (const Arg *A = 
DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+  LibraryPaths.push_back(A->getValue());
 
 // Add user defined library paths from LIBRARY_PATH.
 llvm::Optional LibPath =
@@ -665,6 +667,12 @@
 LibraryPaths.emplace_back(Path.trim());
 }
 
+// Add path to lib / lib64 folder.
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
 std::string LibOmpTargetName =
   "libomptarget-nvptx-" + GpuArch.str() + ".bc";
 bool FoundBCLibrary = false;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -596,6 +596,8 @@
   HelpText<"HIP device library">;
 def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def libomptarget_nvptx_path_EQ : Joined<["--"], "libomptarget-nvptx-path=">, 
Group,
+  HelpText<"Path to libomptarget-nvptx libraries">;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal outp

[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/ClangdLSPServer.cpp:108
+  if (Params.capabilities.textDocument.completion.completionItemKind)
+for (CompletionItemKind Kind : *Params.capabilities.textDocument.completion
+.completionItemKind->valueSet)

also check if valueSet is None before dereferencing it?



Comment at: clangd/Protocol.h:265
+};
+
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);

(nit: drop blank line for consistency)



Comment at: clangd/Protocol.h:274
+};
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);

wasn't obvious why this is necessary vs the default...
Maybe add a comment `// Discards unknown kinds` (and to SymbolKind)?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616



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


[PATCH] D52619: Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: atanasyan, rnk.
Herald added subscribers: cfe-commits, jrtc27, arichardson, sdardis.

`ld{{.*}}"` seems to match the complete line for me which is failing
the test. Only allow an optional `.exe` for Windows systems as most
other tests do.
Another possibility would be to collapse the greedy expression with
the next check to avoid matching the full line.


Repository:
  rC Clang

https://reviews.llvm.org/D52619

Files:
  test/Driver/mips-abi.c


Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"


Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52617: [clangd] Make stable_partition on include candidates less slow. NFC

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:325
+CodeCompletion::IncludeCandidates
+moveNonInsertingIncludesToFront(CodeCompletion::IncludeCandidates Includes) {
+  if (Includes.size() <= 1)

this seems a bit overly complicated. It does seem like a worry that this code 
is hot enough to optimize, especially compared to *generating* the list.

But I think we can do something simpler...



Comment at: clangd/CodeComplete.cpp:415
 // Calculate include paths and edits for all possible headers.
+llvm::SmallVector IncludeCandidates;
 for (const auto &Inc : C.RankedIncludeHeaders) {

if this is really hot, you might want to reserve(C.RankedIncludeHeaders.size())



Comment at: clangd/CodeComplete.cpp:422
   Include.Insertion = Includes.insert(ToInclude->first);
-Completion.Includes.push_back(std::move(Include));
+IncludeCandidates.push_back(std::move(Include));
   } else

What about
`(Include.Insertion ? InsertableCandidates : 
IncludeCandidates).push_back(std::move(Include))`

where `InsertableCandidates` is a vector declared above, and then just move it 
onto the end of the list after the loop?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52617



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


[PATCH] D52364: [clangd] Initial supoprt for cross-namespace global code completion.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/CodeComplete.cpp:1251
+  // from any scope.
+  std::pair, bool> QueryScopes;
   // Include-insertion and proximity scoring rely on the include structure.

consider splitting out AllScopes as a separate variable, and assign 
`std::tie(QueryScopes, AllScopes) = getQueryScopes(...)`, for readability



Comment at: clangd/index/Index.h:432
+  /// wildcard.
+  /// FIXME: support assigning different weight to each scope.
   std::vector Scopes;

ioeric wrote:
> sammccall wrote:
> > May not want a heavyweight API with explicit weights...
> > 
> > I think what we really **need** here is the ability to weight 
> > `clang::clangd::` > `clang::` > `` when you're in the scope of namespace 
> > clangd.
> > 
> > We could just say something like "the primary scope should come first" and 
> > do some FileDistance-like penalizing of the others...
> Changed the wording of `FIXME`.
> 
> > I think what we really need here is the ability to weight clang::clangd:: > 
> > clang:: > `` when you're in the scope of namespace clangd.
> It's unclear what this would mean for scopes from `using-namespace` 
> directives. But we can revisit when we get there.
Yeah, my hypothesis is that it doesn't matter much, as long as the 
using-namespaces are ranked lower than the enclosing namespaces, and above 
"any" namespaces.



Comment at: clangd/index/dex/Dex.cpp:171
   }
+  if (Req.AnyScope)
+ScopeIterators.push_back(createBoost(createTrue(Symbols.size()), 0.2));

kbobyrev wrote:
> Probably also check `!ScopeIterators.empty()`: otherwise the latency might 
> increase for queries without any scope/any scope known to `Dex`.
if there are no other scopes, the "naive" query tree will end up looking like 
and(..., or(boost(true)).

The or() will already be optimized away today.
I'd suggest you just remove the boost() here if req.scopes is empty (or better: 
make the boost 1) and we make "generic optimizations" take care of eliminating 
boosts with value 1, and dropping true when it's an argument to and()


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52364



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


[PATCH] D52581: [AST] Revert mangling changes from r339428

2018-09-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D52581#1247409, @theraven wrote:

> > I would have done the same for the GNUstep RTTI here, except I don't 
> > actually
> >  see the code for that anywhere, and no tests seem to break either, so I
> >  believe it's not upstreamed yet.
>
> I'm not sure I understand this comment.  The compiler code is in LLVM and the 
> tests that you've modified are the ones that would fail.  The corresponding 
> code is upstreamed in the runtime, to generate EH metadata for the throw with 
> the same mangling.  If you are going to change the mangling, please make sure 
> that the existing mangling is preserved for EH when compiling for the GNUstep 
> / Microsoft ABI on Windows.
>
> I'm also deeply unconvinced by the idea that it's okay to have a `struct I` 
> in one compilation unit and a `@class I` in another.  The `struct` version 
> will not do any of the correct things with respect to memory management.  
> Code that has this idiom is very likely to be broken.


Ah, it looks like it's sharing the C++ RTTI codepath. What I meant by tests 
specifically was ones like in https://reviews.llvm.org/D47233, where you're 
explicitly checking the RTTI generated for catch handlers. None of the tests 
that I'm modifying in this diff provide that sort of coverage, and no other 
tests break, so we don't have that coverage at all.

The header idiom is used by WebKit among others 
(https://github.com/WebKit/webkit/blob/d68641002aa054fd1f5fdf06d957be3912185e14/Source/WTF/wtf/Compiler.h#L291),
 so I think it's worth giving them the benefit of the doubt.

I'm assuming https://github.com/gnustep/libobjc2/blob/master/eh_win32_msvc.cc 
is the corresponding runtime code. I'll adjust the mangling of RTTI emission 
accordingly, but I also really think you should explicitly add regression tests 
in clang itself for the RTTI emission, otherwise it's liable to break in the 
future as well. (I'll try to add a few basic regression tests if I have the 
time.)


Repository:
  rC Clang

https://reviews.llvm.org/D52581



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


[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/FS.cpp:29
+PreambleFileStatusCache::lookup(llvm::StringRef File) const {
+  auto I = StatCache.find(File);
+  if (I != StatCache.end())

ioeric wrote:
> sammccall wrote:
> > lock
> After a second thought, I'm wondering if the mutex is necessary, if the cache 
> is only updated during preamble build in a single thread. The cache would 
> also remain the same in preamble reuses.
Indeed if you have the following sequencing:

 - one FS writes to the cache from one thread (or several but strictly 
sequenced)
 - sequence point (no writes after this point, no reads before)
 - several FSs read from the cache

then no lock is required, either for writer or reader.
The API doesn't particularly suggest this, so please explicitly document the 
threading model in the header.
(An API that would suggest it is to e.g. make the producing FS the top-level 
object, give it a &&-qualified method to retrieve the cache, and give the cache 
methods to retrieve the consuming FSes. But I think that's awkward here with 
the VFS interface)



Comment at: clangd/FS.cpp:48
+return File;
+  if (auto S = File->get()->status())
+StatCache.update(getUnderlyingFS(), std::move(*S));

ioeric wrote:
> sammccall wrote:
> > I'm not sure I get this: AFAICT (at least on linux) the status is never 
> > available on a newly opened file, so this will always be a stat() call, so 
> > we're just doing the work eagerly and caching it for later. Isn't this just 
> > moving the work around?
> > 
> > I'm sure you've verified this is important somehow, but a comment 
> > explaining how would be much appreciated :-)
> Files opened via `openFileForRead()` wouldn't usually trigger `status()` 
> calls on the wrap FS. And most header files are opened instead of `stat`ed.
> 
> Added comment explaining this.
Ah, OK.
The implementation comment is good, but this is significantly different from 
"caching stat calls" as described in the header files.

Maybe update the comment there: e.g. "Records status information for files 
open()ed or stat()ed during preamble build, so we can avoid stat()s on the 
underlying FS when reusing the preamble"



Comment at: clangd/FS.cpp:53
+  // likely to be cached in the underlying file system anyway.
+  if (auto S = File->get()->status())
+StatCache.update(getUnderlyingFS(), std::move(*S));

do you want to check if the file is already in the stat cache first?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419



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


[PATCH] D52620: Added Support for StatOnly Files in VFS.

2018-09-27 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, mgrang.

Some files are only Statted by Clang and not read. Clang mostly uses
them for checking the existence of some files and in rare cases uses the
value of the Status to proceed further (for example while loading
module files, it checks the sizes of some files).

This change adds support to represent files that are supposed to be only
statted by Clang.


Repository:
  rC Clang

https://reviews.llvm.org/D52620

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -553,8 +553,8 @@
   for (DirIter E; !EC && I != E; I.increment(EC))
 InputToCheck.push_back(I->path());
 
-  llvm::sort(InputToCheck);
-  llvm::sort(Expected);
+  llvm::sort(InputToCheck.begin(), InputToCheck.end());
+  llvm::sort(Expected.begin(), Expected.end());
   EXPECT_EQ(InputToCheck.size(), Expected.size());
 
   unsigned LastElt = std::min(InputToCheck.size(), Expected.size());
@@ -1063,15 +1063,50 @@
 TEST_F(InMemoryFileSystemTest, RecursiveIterationWithHardLink) {
   std::error_code EC;
   FS.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("content string"));
+  FS.addStatOnlyFile("/a/d", 0, 10);
   EXPECT_TRUE(FS.addHardLink("/c/d", "/a/b"));
   auto I = vfs::recursive_directory_iterator(FS, "/", EC);
   ASSERT_FALSE(EC);
   std::vector Nodes;
   for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
 Nodes.push_back(getPosixPath(I->path()));
   }
-  EXPECT_THAT(Nodes, testing::UnorderedElementsAre("/a", "/a/b", "/c", "/c/d"));
+  EXPECT_THAT(Nodes, testing::UnorderedElementsAre("/a", "/a/d", "/a/b",
+   "/c", "/c/d"));
+}
+
+TEST_F(InMemoryFileSystemTest, AddStatOnlyFileWithCorrectSize) {
+  FS.addStatOnlyFile("/a/b", 0, 10);
+  auto Stat = FS.status("/a/b");
+  EXPECT_EQ(Stat.get().getSize(), 10);
+}
+
+TEST_F(InMemoryFileSystemTest, AddMultipleFilesUnderStatOnlyFile) {
+  FS.addStatOnlyFile("/a/b", 0, 10);
+  EXPECT_FALSE(FS.addStatOnlyFile("/a/b", 0, 11));
+  EXPECT_TRUE(FS.addStatOnlyFile("/a/b", 0, 10));
+  EXPECT_FALSE(FS.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("content")));
+}
+
+TEST_F(InMemoryFileSystemTest, DeathWhenBufferRequestedForStatOnlyFile) {
+  FS.addStatOnlyFile("/a/b", 0, 10);
+  EXPECT_DEATH(FS.getBufferForFile("/a/b"),
+   "Cannot get buffer for StatOnlyFile");
+}
+
+TEST_F(InMemoryFileSystemTest, AddHardLinksToStatOnlyFile) {
+  FS.addStatOnlyFile("/target", 0, 10);
+  FS.addHardLink("/link1", "/target");
+  FS.addHardLink("/link2", "/link1");
+  EXPECT_THAT("/link1", IsHardLinkTo(&FS, "/target"));
+  EXPECT_THAT("/link2", IsHardLinkTo(&FS, "/target"));
+}
+
+TEST_F(InMemoryFileSystemTest, AddFileUnderHardLinkToStatOnlyFile) {
+  FS.addStatOnlyFile("/target", 0, 10);
+  FS.addHardLink("/link", "/target");
+  EXPECT_FALSE(FS.addFile("/link",  0, MemoryBuffer::getMemBuffer("content")));
 }
 
 // NOTE: in the tests below, we use '//root/' as our root directory, since it is
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -492,20 +492,26 @@
 class InMemoryFile : public InMemoryNode {
   Status Stat;
   std::unique_ptr Buffer;
+  bool StatOnlyFile;
 
 public:
-  InMemoryFile(Status Stat, std::unique_ptr Buffer)
+  InMemoryFile(Status Stat, std::unique_ptr Buffer,
+   bool StatOnlyFile)
   : InMemoryNode(Stat.getName(), IME_File), Stat(std::move(Stat)),
-Buffer(std::move(Buffer)) {}
+Buffer(std::move(Buffer)), StatOnlyFile(StatOnlyFile) {}
 
   /// Return the \p Status for this node. \p RequestedName should be the name
   /// through which the caller referred to this node. It will override
   /// \p Status::Name in the return value, to mimic the behavior of \p RealFile.
   Status getStatus(StringRef RequestedName) const {
 return Status::copyWithNewName(Stat, RequestedName);
   }
-  llvm::MemoryBuffer *getBuffer() const { return Buffer.get(); }
+  llvm::MemoryBuffer *getBuffer() const {
+assert(!StatOnlyFile && "Cannot get buffer for StatOnlyFile");
+return Buffer.get();
+  }
 
+  bool IsStatOnlyFile() const { return StatOnlyFile; }
   std::string toString(unsigned Indent) const override {
 return (std::string(Indent, ' ') + Stat.getName() + "\n").str();
   }
@@ -640,7 +646,8 @@
  Optional Group,
  Optional Type,
  Optional Perms,
- const detail::InMemoryFile *HardLinkTarget) {
+ const detail::InMemoryFile *HardLinkTarge

[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 167346.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+// Discards unknown CompletionItemKinds.
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds);
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -305,6 +357,7 @@
   /// value.
   llvm::Optional> valueSet;
 };
+// Discards unknown SymbolKinds.
 bool fromJSON(const llvm::json::Value &, std::vector &);
 bool fromJSON(const llvm::json::Value &, SymbolKindCapabilities &);
 SymbolKind adjustKindToCapability(SymbolKind Kind,
@@ -683,36 +736,6 @@
 };
 llvm::json::Value toJSON(const Hover &H);
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value &E, CompletionItemKind &Out) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::Text) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value &E, std::vector &Out) {
+  if (auto *A = E.getAsArray()) {
+Out.clear();
+fo

[clang-tools-extra] r343237 - Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu Sep 27 10:13:07 2018
New Revision: 343237

URL: http://llvm.org/viewvc/llvm-project?rev=343237&view=rev
Log:
Introduce completionItemKind capability support.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=343237&r1=343236&r2=343237&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Sep 27 10:13:07 2018
@@ -70,6 +70,14 @@ SymbolKindBitset defaultSymbolKinds() {
   return Defaults;
 }
 
+CompletionItemKindBitset defaultCompletionItemKinds() {
+  CompletionItemKindBitset Defaults;
+  for (size_t I = CompletionItemKindMin;
+   I <= static_cast(CompletionItemKind::Reference); ++I)
+Defaults.set(I);
+  return Defaults;
+}
+
 } // namespace
 
 void ClangdLSPServer::onInitialize(InitializeParams &Params) {
@@ -89,13 +97,20 @@ void ClangdLSPServer::onInitialize(Initi
   Params.capabilities.textDocument.publishDiagnostics.categorySupport;
 
   if (Params.capabilities.workspace && Params.capabilities.workspace->symbol &&
-  Params.capabilities.workspace->symbol->symbolKind) {
+  Params.capabilities.workspace->symbol->symbolKind &&
+  Params.capabilities.workspace->symbol->symbolKind->valueSet) {
 for (SymbolKind Kind :
  *Params.capabilities.workspace->symbol->symbolKind->valueSet) {
   SupportedSymbolKinds.set(static_cast(Kind));
 }
   }
 
+  if (Params.capabilities.textDocument.completion.completionItemKind &&
+  Params.capabilities.textDocument.completion.completionItemKind->valueSet)
+for (CompletionItemKind Kind : *Params.capabilities.textDocument.completion
+.completionItemKind->valueSet)
+  SupportedCompletionItemKinds.set(static_cast(Kind));
+
   reply(json::Object{
   {{"capabilities",
 json::Object{
@@ -347,8 +362,12 @@ void ClangdLSPServer::onCompletion(TextD
return replyError(List.takeError());
  CompletionList LSPList;
  LSPList.isIncomplete = List->HasMore;
- for (const auto &R : List->Completions)
-   LSPList.items.push_back(R.render(CCOpts));
+ for (const auto &R : List->Completions) {
+   CompletionItem C = R.render(CCOpts);
+   C.kind = adjustKindToCapability(
+   C.kind, SupportedCompletionItemKinds);
+   LSPList.items.push_back(std::move(C));
+ }
  return reply(std::move(LSPList));
});
 }
@@ -459,6 +478,7 @@ ClangdLSPServer::ClangdLSPServer(JSONOut
  : CompilationDB::makeDirectoryBased(
std::move(CompileCommandsDir))),
   CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()),
+  SupportedCompletionItemKinds(defaultCompletionItemKinds()),
   Server(new ClangdServer(CDB.getCDB(), FSProvider, /*DiagConsumer=*/*this,
   Opts)) {}
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=343237&r1=343236&r2=343237&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Thu Sep 27 10:13:07 2018
@@ -164,6 +164,8 @@ private:
   ClangdDiagnosticOptions DiagOpts;
   /// The supported kinds of the client.
   SymbolKindBitset SupportedSymbolKinds;
+  /// The supported completion item kinds of the client.
+  CompletionItemKindBitset SupportedCompletionItemKinds;
 
   // Store of the current versions of the open documents.
   DraftStore DraftMgr;

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=343237&r1=343236&r2=343237&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Sep 27 10:13:07 2018
@@ -496,6 +496,57 @@ json::Value toJSON(const Hover &H) {
   return std::move(Result);
 }
 
+bool fromJSON(const js

[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343237: Introduce completionItemKind capability support. 
(authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52616?vs=167346&id=167347#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+// Discards unknown CompletionItemKinds.
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds);
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -305,6 +357,7 @@
   /// value.
   llvm::Optional> valueSet;
 };
+// Discards unknown SymbolKinds.
 bool fromJSON(const llvm::json::Value &, std::vector &);
 bool fromJSON(const llvm::json::Value &, SymbolKindCapabilities &);
 SymbolKind adjustKindToCapability(SymbolKind Kind,
@@ -683,36 +736,6 @@
 };
 llvm::json::Value toJSON(const Hover &H);
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value &E, CompletionItemKind &Out) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::Text) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset &supportedCompletionItemKinds) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemK

[PATCH] D52619: Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D52619



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


r343239 - [analyzer] Highlight nodes which have error reports in them in red in exploded graph

2018-09-27 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 27 10:26:41 2018
New Revision: 343239

URL: http://llvm.org/viewvc/llvm-project?rev=343239&view=rev
Log:
[analyzer] Highlight nodes which have error reports in them in red in exploded 
graph

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=343239&r1=343238&r2=343239&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Sep 27 10:26:41 2018
@@ -2953,49 +2953,89 @@ template<>
 struct DOTGraphTraits : public DefaultDOTGraphTraits {
   DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
 
-  // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
-  // work.
-  static std::string getNodeAttributes(const ExplodedNode *N,
-   ExplodedGraph *G) {
-if (N->isSink())
-  return "color=red";
-return {};
-  }
-
-  static bool isNodeHidden(const ExplodedNode *N) {
-return N->isTrivial();
+  static bool nodeHasBugReport(const ExplodedNode *N) {
+BugReporter &BR = static_cast(
+  N->getState()->getStateManager().getOwningEngine())->getBugReporter();
+
+const auto EQClasses =
+llvm::make_range(BR.EQClasses_begin(), BR.EQClasses_end());
+
+for (const auto &EQ : EQClasses) {
+  for (const BugReport &Report : EQ) {
+if (Report.getErrorNode() == N)
+  return true;
+  }
+}
+return false;
   }
 
-  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
-std::string sbuf;
-llvm::raw_string_ostream Out(sbuf);
-
-// Find the first node which program point and tag has to be included in
-// the output.
+  /// \p PreCallback: callback before break.
+  /// \p PostCallback: callback after break.
+  /// \p Stop: stop iteration if returns {@code true}
+  /// \return Whether {@code Stop} ever returned {@code true}.
+  static bool traverseHiddenNodes(
+  const ExplodedNode *N,
+  llvm::function_ref PreCallback,
+  llvm::function_ref PostCallback,
+  llvm::function_ref Stop) {
 const ExplodedNode *FirstHiddenNode = N;
 while (FirstHiddenNode->pred_size() == 1 &&
isNodeHidden(*FirstHiddenNode->pred_begin())) {
   FirstHiddenNode = *FirstHiddenNode->pred_begin();
 }
-
-ProgramStateRef State = N->getState();
-
-// Dump program point for all the previously skipped nodes.
 const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
-
-  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
-Out << "\\lTag:" << Tag->getTagDescription();
+  if (Stop(OtherNode))
+return true;
 
   if (OtherNode == N)
 break;
 
   OtherNode = *OtherNode->succ_begin();
+}
+return false;
+  }
 
-  Out << "\\l\\l";
+  static std::string getNodeAttributes(const ExplodedNode *N,
+   ExplodedGraph *G) {
+SmallVector Out;
+auto Noop = [](const ExplodedNode*){};
+if (traverseHiddenNodes(N, Noop, Noop, &nodeHasBugReport)) {
+  Out.push_back("style=filled");
+  Out.push_back("fillcolor=red");
 }
 
+if (traverseHiddenNodes(N, Noop, Noop,
+[](const ExplodedNode *C) { return C->isSink(); }))
+  Out.push_back("color=blue");
+return llvm::join(Out, ",");
+  }
+
+  static bool isNodeHidden(const ExplodedNode *N) {
+return N->isTrivial();
+  }
+
+  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
+std::string sbuf;
+llvm::raw_string_ostream Out(sbuf);
+
+ProgramStateRef State = N->getState();
+
+// Dump program point for all the previously skipped nodes.
+traverseHiddenNodes(
+N,
+[&](const ExplodedNode *OtherNode) {
+  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
+  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
+Out << "\\lTag:" << Tag->getTagDescription();
+  if (N->isSink())
+Out << "\\lNode is sink\\l";
+  if (nodeHasBugReport(N))
+Out << "\\lBug report attached\\l";
+},
+[&](const ExplodedNode *OtherNode) { Out << "\\l\\l"; },
+[&](const ExplodedNode *N) { return false; });
+
 Out << "\\l\\|";
 
 Out << "StateID: ST" << State->getID() << ", NodeID: N" << N->getID(G)


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


[PATCH] D52584: [analyzer] Highlight nodes which have error reports in them in red in exploded graph

2018-09-27 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343239: [analyzer] Highlight nodes which have error reports 
in them in red in exploded… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52584?vs=167234&id=167349#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52584

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp

Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2953,49 +2953,89 @@
 struct DOTGraphTraits : public DefaultDOTGraphTraits {
   DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
 
-  // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
-  // work.
-  static std::string getNodeAttributes(const ExplodedNode *N,
-   ExplodedGraph *G) {
-if (N->isSink())
-  return "color=red";
-return {};
-  }
-
-  static bool isNodeHidden(const ExplodedNode *N) {
-return N->isTrivial();
+  static bool nodeHasBugReport(const ExplodedNode *N) {
+BugReporter &BR = static_cast(
+  N->getState()->getStateManager().getOwningEngine())->getBugReporter();
+
+const auto EQClasses =
+llvm::make_range(BR.EQClasses_begin(), BR.EQClasses_end());
+
+for (const auto &EQ : EQClasses) {
+  for (const BugReport &Report : EQ) {
+if (Report.getErrorNode() == N)
+  return true;
+  }
+}
+return false;
   }
 
-  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
-std::string sbuf;
-llvm::raw_string_ostream Out(sbuf);
-
-// Find the first node which program point and tag has to be included in
-// the output.
+  /// \p PreCallback: callback before break.
+  /// \p PostCallback: callback after break.
+  /// \p Stop: stop iteration if returns {@code true}
+  /// \return Whether {@code Stop} ever returned {@code true}.
+  static bool traverseHiddenNodes(
+  const ExplodedNode *N,
+  llvm::function_ref PreCallback,
+  llvm::function_ref PostCallback,
+  llvm::function_ref Stop) {
 const ExplodedNode *FirstHiddenNode = N;
 while (FirstHiddenNode->pred_size() == 1 &&
isNodeHidden(*FirstHiddenNode->pred_begin())) {
   FirstHiddenNode = *FirstHiddenNode->pred_begin();
 }
-
-ProgramStateRef State = N->getState();
-
-// Dump program point for all the previously skipped nodes.
 const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
-
-  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
-Out << "\\lTag:" << Tag->getTagDescription();
+  if (Stop(OtherNode))
+return true;
 
   if (OtherNode == N)
 break;
 
   OtherNode = *OtherNode->succ_begin();
+}
+return false;
+  }
 
-  Out << "\\l\\l";
+  static std::string getNodeAttributes(const ExplodedNode *N,
+   ExplodedGraph *G) {
+SmallVector Out;
+auto Noop = [](const ExplodedNode*){};
+if (traverseHiddenNodes(N, Noop, Noop, &nodeHasBugReport)) {
+  Out.push_back("style=filled");
+  Out.push_back("fillcolor=red");
 }
 
+if (traverseHiddenNodes(N, Noop, Noop,
+[](const ExplodedNode *C) { return C->isSink(); }))
+  Out.push_back("color=blue");
+return llvm::join(Out, ",");
+  }
+
+  static bool isNodeHidden(const ExplodedNode *N) {
+return N->isTrivial();
+  }
+
+  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
+std::string sbuf;
+llvm::raw_string_ostream Out(sbuf);
+
+ProgramStateRef State = N->getState();
+
+// Dump program point for all the previously skipped nodes.
+traverseHiddenNodes(
+N,
+[&](const ExplodedNode *OtherNode) {
+  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
+  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
+Out << "\\lTag:" << Tag->getTagDescription();
+  if (N->isSink())
+Out << "\\lNode is sink\\l";
+  if (nodeHasBugReport(N))
+Out << "\\lBug report attached\\l";
+},
+[&](const ExplodedNode *OtherNode) { Out << "\\l\\l"; },
+[&](const ExplodedNode *N) { return false; });
+
 Out << "\\l\\|";
 
 Out << "StateID: ST" << State->getID() << ", NodeID: N" << N->getID(G)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343240 - Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Sep 27 10:27:48 2018
New Revision: 343240

URL: http://llvm.org/viewvc/llvm-project?rev=343240&view=rev
Log:
Fix greedy FileCheck expression in test/Driver/mips-abi.c

'ld{{.*}}"' seems to match the complete line for me which is failing
the test. Only allow an optional '.exe' for Windows systems as most
other tests do.
Another possibility would be to collapse the greedy expression with
the next check to avoid matching the full line.

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

Modified:
cfe/trunk/test/Driver/mips-abi.c

Modified: cfe/trunk/test/Driver/mips-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=343240&r1=343239&r2=343240&view=diff
==
--- cfe/trunk/test/Driver/mips-abi.c (original)
+++ cfe/trunk/test/Driver/mips-abi.c Thu Sep 27 10:27:48 2018
@@ -169,7 +169,7 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
@@ -177,7 +177,7 @@
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
@@ -185,5 +185,5 @@
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"


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


[PATCH] D52619: Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343240: Fix greedy FileCheck expression in 
test/Driver/mips-abi.c (authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52619?vs=167344&id=167350#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52619

Files:
  cfe/trunk/test/Driver/mips-abi.c


Index: cfe/trunk/test/Driver/mips-abi.c
===
--- cfe/trunk/test/Driver/mips-abi.c
+++ cfe/trunk/test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"


Index: cfe/trunk/test/Driver/mips-abi.c
===
--- cfe/trunk/test/Driver/mips-abi.c
+++ cfe/trunk/test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50318: Support Swift in platform availability attribute

2018-09-27 Thread Jeff Muizelaar via Phabricator via cfe-commits
jrmuizel added a comment.

Review ping


Repository:
  rC Clang

https://reviews.llvm.org/D50318



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


[PATCH] D52589: [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c:7
+////
+// Unsigned case.
+////

This is a new test, not just cleanup?


Repository:
  rC Clang

https://reviews.llvm.org/D52589



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


[PATCH] D52589: [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for the review!




Comment at: test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c:7
+////
+// Unsigned case.
+////

vitalybuka wrote:
> This is a new test, not just cleanup?
Kind of both.
The follow-up adds a new tests here, so i have thought it should be split out 
too.


Repository:
  rC Clang

https://reviews.llvm.org/D52589



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


  1   2   >