[PATCH] D62238: [CodeComplete] Complete a lambda when preferred type is a function

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200876.
ilya-biryukov added a comment.

- Remove a leftover from name check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62238

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/lambdas.cpp

Index: clang/test/CodeCompletion/lambdas.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/lambdas.cpp
@@ -0,0 +1,53 @@
+template 
+struct function {
+};
+
+
+void test() {
+  void (*x)(int, double) = nullptr;
+
+  function y = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:7:28 %s -o - | FileCheck -check-prefix=CHECK-1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:35 %s -o - | FileCheck -check-prefix=CHECK-1 %s
+  // CHECK-1: COMPLETION: Pattern : [<#=#>](int <#parameter#>, double <#parameter#>){<#body#>}
+
+  // == Placeholders for suffix types must be placed properly.
+  function z = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:15:36 %s -o - | FileCheck -check-prefix=CHECK-2 %s
+  // CHECK-2: COMPLETION: Pattern : [<#=#>](void (* <#parameter#>)(int)){<#body#>}
+
+  // == No need for a parameter list if function has no parameters.
+  function a = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:20:24 %s -o - | FileCheck -check-prefix=CHECK-3 %s
+  // CHECK-3: COMPLETION: Pattern : [<#=#>]{<#body#>}
+}
+
+template 
+struct vector {};
+
+void test2() {
+  // == Try to preserve types as written.
+  function)> a = {};
+
+  using function_typedef = function)>;
+  function_typedef b = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:30:35 %s -o - | FileCheck -check-prefix=CHECK-4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:33:24 %s -o - | FileCheck -check-prefix=CHECK-4 %s
+  // CHECK-4: COMPLETION: Pattern : [<#=#>](vector <#parameter#>){<#body#>}
+}
+
+// Check another common function wrapper name.
+template  struct unique_function {};
+
+void test3() {
+  unique_function a = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:43:31 %s -o - | FileCheck -check-prefix=CHECK-5 %s
+  // CHECK-5: COMPLETION: Pattern : [<#=#>]{<#body#>}
+}
+
+template  struct weird_function {};
+void test4() {
+  weird_function b = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:50:35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
+  // CHECK-6-NOT: COMPLETION: Pattern : [<#=
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4108,6 +4108,69 @@
   Results.ExitScope();
 }
 
+/// Try to find a corresponding FunctionProtoType for function-like types (e.g.
+/// function pointers, std::function, etc).
+static const FunctionProtoType *TryDeconstructFunctionLike(QualType T) {
+  assert(!T.isNull());
+  // Try to extract first template argument from std::function<> and similar.
+  // Note we only handle the sugared types, they closely match what users wrote.
+  // We explicitly choose to not handle ClassTemplateSpecializationDecl.
+  if (auto *Specialization = T->getAs()) {
+if (Specialization->getNumArgs() != 1)
+  return nullptr;
+const TemplateArgument &Argument = Specialization->getArg(0);
+if (Argument.getKind() != TemplateArgument::Type)
+  return nullptr;
+return Argument.getAsType()->getAs();
+  }
+  // Handle other cases.
+  if (T->isPointerType())
+T = T->getPointeeType();
+  return T->getAs();
+}
+
+/// Adds a pattern completion for a lambda expression with the specified
+/// parameter types and placeholders for parameter names.
+static void AddLambdaCompletion(ResultBuilder &Results,
+llvm::ArrayRef Parameters,
+const LangOptions &LangOpts) {
+  CodeCompletionBuilder Completion(Results.getAllocator(),
+   Results.getCodeCompletionTUInfo());
+  // []() {}
+  Completion.AddChunk(CodeCompletionString::CK_LeftBracket);
+  Completion.AddPlaceholderChunk("=");
+  Completion.AddChunk(CodeCompletionString::CK_RightBracket);
+  if (!Parameters.empty()) {
+Completion.AddChunk(CodeCompletionString::CK_LeftParen);
+bool First = true;
+for (auto Parameter : Parameters) {
+  if (!First)
+Completion.AddChunk(CodeCompletionString::ChunkKind::CK_Comma);
+  else
+First = false;
+
+  constexpr llvm::StringLiteral NamePlaceholder = "!#!NAME_GOES_HERE!#!";
+  std::string Type = NamePlaceholder;
+  Parameter.getAsStringInternal(Type, PrintingPolicy(LangOpts));
+  llvm::StringRef Prefix, Suffix;
+  s

[PATCH] D62288: [clangd-vscode] Do not customize uri converters in vscode

2019-05-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Clangd is already resolving symlinks on the server side, therefore
there is no more need to handle it in client side. This was also resulting in
breakages whenever index contained a symbol coming from a non-existent file(like
a generated file), e.g. during workspace symbols whole response was dropped
since stat had failed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62288

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -87,17 +87,6 @@
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a 
symlink tree to build in,
-// and when navigating to the included file, clangd passes its path 
inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve 
the
-// symlinks where needed (or if this causes problems for other 
workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -87,17 +87,6 @@
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a symlink tree to build in,
-// and when navigating to the included file, clangd passes its path inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve the
-// symlinks where needed (or if this causes problems for other workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62270: [Driver] Move the "-o OUT -x TYPE SRC.c" flags to the end of -cc1

2019-05-23 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Nice, lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62270



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


[PATCH] D59415: Do not resolve directory junctions for `-fdiagnostics-absolute-paths` on Windows.

2019-05-23 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Thanks! This looks good to me.

I'm still a bit nervous about "mklink" in the test, but let's land this and see 
if the bots can handle it.


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

https://reviews.llvm.org/D59415



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


[PATCH] D62276: lld-link, clang: Treat non-existent input files as possible spellos for option flags

2019-05-23 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Beautiful!

Want to add a line to docs/ReleaseNotes.rst too? :-)




Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:177
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
-  "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
+  "unknown argument ignored in clang-cl '%0', did you mean '%1'?">,
   InGroup;

(grammar nit: I think this is a comma splice 
(https://en.wikipedia.org/wiki/Comma_splice)  so I believe a semicolon would be 
better. On the other hand, we seem to do this a lot already and I'm not a 
native speaker so maybe it's fine.)



Comment at: clang/include/clang/Driver/Driver.h:398
+  /// Check that the file referenced by Value exists. If it doesn't,
+  /// issue a diagnostic and return false.
+  bool DiagnoseInputExistence(const llvm::opt::DerivedArgList &Args,

Should the comment say what TypoCorrect does?



Comment at: clang/lib/Driver/Driver.cpp:2024
+if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
+ExcludedFlagsBitmask) <= 1) {
+  Diag(clang::diag::err_drv_no_such_file_with_suggestion)

indentation looks funny; clang-format?



Comment at: lld/COFF/Driver.cpp:218
+  else
+error(Error + "; did you mean '" + Nearest + "'");
+} else

I like the semicolon better, but it seems we use comma in other places?


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

https://reviews.llvm.org/D62276



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


[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-23 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 200878.
skan added a comment.

make test case  consider Windows path separators


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

https://reviews.llvm.org/D62115

Files:
  lib/Frontend/HeaderIncludeGen.cpp
  test/Frontend/clang_H_opt.c


Index: test/Frontend/clang_H_opt.c
===
--- /dev/null
+++ test/Frontend/clang_H_opt.c
@@ -0,0 +1,41 @@
+// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "../Index/Inputs/empty.h"
+#include "Inputs/empty.h"
+#include "./Inputs/empty.h"
+#include "././Inputs/empty.h"
+#include "./Inputs/empty.h"
+// CHECK: .
+// CHECK-SAME: ../Index/Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ./Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ././Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ./Inputs/empty.h
+
+#if defined(_WIN32) || defined(_WIN64)
+#include "..\Index\Inputs\empty.h"
+#include "Inputs\empty.h"
+#include ".\Inputs\empty.h"
+#include ".\.\Inputs\empty.h"
+#include ".\Inputs\empty.h"
+#else
+#include "../Index/Inputs/empty.h"
+#include "Inputs/empty.h"
+#include "./Inputs/empty.h"
+#include "././Inputs/empty.h"
+#include "./Inputs/empty.h"
+// CHECK: .
+// CHECK-SAME: ..{{\/|}}Index{{\/|}}Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|}}Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|}}.{{\/|}}Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|}}Inputs{{\/|}}empty.h
+#endif
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -51,6 +51,10 @@
 static void PrintHeaderInfo(raw_ostream *OutputFile, StringRef Filename,
 bool ShowDepth, unsigned CurrentIncludeDepth,
 bool MSStyle) {
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"))
+Filename = Filename.substr(2);
+
   // Write to a temporary string to avoid unnecessary flushing on errs().
   SmallString<512> Pathname(Filename);
   if (!MSStyle)


Index: test/Frontend/clang_H_opt.c
===
--- /dev/null
+++ test/Frontend/clang_H_opt.c
@@ -0,0 +1,41 @@
+// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "../Index/Inputs/empty.h"
+#include "Inputs/empty.h"
+#include "./Inputs/empty.h"
+#include "././Inputs/empty.h"
+#include "./Inputs/empty.h"
+// CHECK: .
+// CHECK-SAME: ../Index/Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ./Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ././Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ./Inputs/empty.h
+
+#if defined(_WIN32) || defined(_WIN64)
+#include "..\Index\Inputs\empty.h"
+#include "Inputs\empty.h"
+#include ".\Inputs\empty.h"
+#include ".\.\Inputs\empty.h"
+#include ".\Inputs\empty.h"
+#else
+#include "../Index/Inputs/empty.h"
+#include "Inputs/empty.h"
+#include "./Inputs/empty.h"
+#include "././Inputs/empty.h"
+#include "./Inputs/empty.h"
+// CHECK: .
+// CHECK-SAME: ..{{\/|}}Index{{\/|}}Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|}}Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|}}.{{\/|}}Inputs{{\/|}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|}}Inputs{{\/|}}empty.h
+#endif
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -51,6 +51,10 @@
 static void PrintHeaderInfo(raw_ostream *OutputFile, StringRef Filename,
 bool ShowDepth, unsigned CurrentIncludeDepth,
 bool MSStyle) {
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"))
+Filename = Filename.substr(2);
+
   // Write to a temporary string to avoid unnecessary flushing on errs().
   SmallString<512> Pathname(Filename);
   if (!MSStyle)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50147: clang-format: support external styles

2019-05-23 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.
Herald added a project: clang.

In D50147#1310146 , @sammccall wrote:

> In D50147#1309880 , @Typz wrote:
>
> > ping?
>
>
> Sorry for losing track of this.
>
> I think `-style=` is a logical extension of the current options. 
> I'm less sure of supporting it in BasedOnStyle, but happy to go either way.


To keep traceability and ensure consistency, storing a clang-format file in 
each repository is still required. So BasedOnStyle is actually the feature we 
need, and from our POV the -style= extension is a side effect :-)

> Referring to styles by names in installed style directories seems like a 
> relatively marginal feature that would need a more careful design, e.g.:
> 
> - respecting platform conventions

I knew this one was coming: the patch is clearly not complete on this aspect, 
but I pushed it already to get an early feedback on the generic goal/approach.
This definitely needs some fixing, and to be honest I was hoping there was 
already something in LLVM code base on this topic (e.g. list of standard path, 
access to base installation path...) : I tried to look. but did not find 
anything yet. Any advice?

> - supporting build-time configuration

I thought of injecting the platform-specific path list through the build sytem 
as well. And this would allow overriding it with any other path list as 
appropriate.

> - understanding how distro packaging is going to work

I don't understand what you mean exactly. With build-time configuration, the 
package can be customized  to look in the appropriate places for the specific 
distribution.

Can you please clarify the issues you see?

> - thinking about addressing the resulting fragmentation as .clang-format 
> files are shared but the referenced files are not Within a tightly controlled 
> organization, these things are less of an issue. We've had luck simply making 
> local changes to support different styles for these scenarios, though that's 
> not ideal.

Our organization is not so controlled, but we want to ease the deployment and 
maintenance of the styles, hence this approach.
(by the way, ideally I would like to eventually further extend this patch to 
support retrieval of external styles through url : e.g. to get style from a 
central server, through http, git)

> One possibility to reduce the scope here: search for unknown names on under 
> `$CLANG_FORMAT_STYLES` if the variable is set. That way it can be set by 
> administrators within an org if appropriate, but clang-format doesn't have to 
> have opinions about the policy here, and all binaries still behave the same.

I don't think having no search path by default (if the env var does not exist 
or is empty) is so nice, but I can definitely add such an environment variable 
override.


Repository:
  rC Clang

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

https://reviews.llvm.org/D50147



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


r361461 - [CodeComplete] Complete a lambda when preferred type is a function

2019-05-23 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu May 23 00:45:35 2019
New Revision: 361461

URL: http://llvm.org/viewvc/llvm-project?rev=361461&view=rev
Log:
[CodeComplete] Complete a lambda when preferred type is a function

Summary: Uses a heuristic to detect std::function and friends.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeCompletion/lambdas.cpp
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=361461&r1=361460&r2=361461&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu May 23 00:45:35 2019
@@ -4108,6 +4108,69 @@ static void AddEnumerators(ResultBuilder
   Results.ExitScope();
 }
 
+/// Try to find a corresponding FunctionProtoType for function-like types (e.g.
+/// function pointers, std::function, etc).
+static const FunctionProtoType *TryDeconstructFunctionLike(QualType T) {
+  assert(!T.isNull());
+  // Try to extract first template argument from std::function<> and similar.
+  // Note we only handle the sugared types, they closely match what users 
wrote.
+  // We explicitly choose to not handle ClassTemplateSpecializationDecl.
+  if (auto *Specialization = T->getAs()) {
+if (Specialization->getNumArgs() != 1)
+  return nullptr;
+const TemplateArgument &Argument = Specialization->getArg(0);
+if (Argument.getKind() != TemplateArgument::Type)
+  return nullptr;
+return Argument.getAsType()->getAs();
+  }
+  // Handle other cases.
+  if (T->isPointerType())
+T = T->getPointeeType();
+  return T->getAs();
+}
+
+/// Adds a pattern completion for a lambda expression with the specified
+/// parameter types and placeholders for parameter names.
+static void AddLambdaCompletion(ResultBuilder &Results,
+llvm::ArrayRef Parameters,
+const LangOptions &LangOpts) {
+  CodeCompletionBuilder Completion(Results.getAllocator(),
+   Results.getCodeCompletionTUInfo());
+  // []() {}
+  Completion.AddChunk(CodeCompletionString::CK_LeftBracket);
+  Completion.AddPlaceholderChunk("=");
+  Completion.AddChunk(CodeCompletionString::CK_RightBracket);
+  if (!Parameters.empty()) {
+Completion.AddChunk(CodeCompletionString::CK_LeftParen);
+bool First = true;
+for (auto Parameter : Parameters) {
+  if (!First)
+Completion.AddChunk(CodeCompletionString::ChunkKind::CK_Comma);
+  else
+First = false;
+
+  constexpr llvm::StringLiteral NamePlaceholder = "!#!NAME_GOES_HERE!#!";
+  std::string Type = NamePlaceholder;
+  Parameter.getAsStringInternal(Type, PrintingPolicy(LangOpts));
+  llvm::StringRef Prefix, Suffix;
+  std::tie(Prefix, Suffix) = llvm::StringRef(Type).split(NamePlaceholder);
+  Prefix = Prefix.rtrim();
+  Suffix = Suffix.ltrim();
+
+  Completion.AddTextChunk(Completion.getAllocator().CopyString(Prefix));
+  Completion.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Completion.AddPlaceholderChunk("parameter");
+  Completion.AddTextChunk(Completion.getAllocator().CopyString(Suffix));
+};
+Completion.AddChunk(CodeCompletionString::CK_RightParen);
+  }
+  Completion.AddChunk(CodeCompletionString::CK_LeftBrace);
+  Completion.AddPlaceholderChunk("body");
+  Completion.AddChunk(CodeCompletionString::CK_RightBrace);
+
+  Results.AddResult(Completion.TakeString());
+}
+
 /// Perform code-completion in an expression context when we know what
 /// type we're looking for.
 void Sema::CodeCompleteExpression(Scope *S,
@@ -4169,6 +4232,14 @@ void Sema::CodeCompleteExpression(Scope
   if (CodeCompleter->includeMacros())
 AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false,
 PreferredTypeIsPointer);
+
+  // Complete a lambda expression when preferred type is a function.
+  if (!Data.PreferredType.isNull() && getLangOpts().CPlusPlus11) {
+if (const FunctionProtoType *F =
+TryDeconstructFunctionLike(Data.PreferredType))
+  AddLambdaCompletion(Results, F->getParamTypes(), getLangOpts());
+  }
+
   HandleCodeCompleteResults(this, CodeCompleter, 
Results.getCompletionContext(),
 Results.data(), Results.size());
 }

Added: cfe/trunk/test/CodeCompletion/lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/lambdas.cpp?rev=361461&view=auto
==
--- cfe/trunk/test/CodeCompletion/lambdas.cpp (added)
+++ cfe/trunk/test/CodeCompletion/lambdas.cpp Thu May 23 00:45:35 2019
@@ -0,0 +1,53 @@
+template 
+struct function {
+};
+
+
+void test() {
+  void (*x)(int,

[PATCH] D62238: [CodeComplete] Complete a lambda when preferred type is a function

2019-05-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361461: [CodeComplete] Complete a lambda when preferred type 
is a function (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62238?vs=200876&id=200880#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62238

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/lambdas.cpp

Index: cfe/trunk/test/CodeCompletion/lambdas.cpp
===
--- cfe/trunk/test/CodeCompletion/lambdas.cpp
+++ cfe/trunk/test/CodeCompletion/lambdas.cpp
@@ -0,0 +1,53 @@
+template 
+struct function {
+};
+
+
+void test() {
+  void (*x)(int, double) = nullptr;
+
+  function y = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:7:28 %s -o - | FileCheck -check-prefix=CHECK-1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:35 %s -o - | FileCheck -check-prefix=CHECK-1 %s
+  // CHECK-1: COMPLETION: Pattern : [<#=#>](int <#parameter#>, double <#parameter#>){<#body#>}
+
+  // == Placeholders for suffix types must be placed properly.
+  function z = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:15:36 %s -o - | FileCheck -check-prefix=CHECK-2 %s
+  // CHECK-2: COMPLETION: Pattern : [<#=#>](void (* <#parameter#>)(int)){<#body#>}
+
+  // == No need for a parameter list if function has no parameters.
+  function a = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:20:24 %s -o - | FileCheck -check-prefix=CHECK-3 %s
+  // CHECK-3: COMPLETION: Pattern : [<#=#>]{<#body#>}
+}
+
+template 
+struct vector {};
+
+void test2() {
+  // == Try to preserve types as written.
+  function)> a = {};
+
+  using function_typedef = function)>;
+  function_typedef b = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:30:35 %s -o - | FileCheck -check-prefix=CHECK-4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:33:24 %s -o - | FileCheck -check-prefix=CHECK-4 %s
+  // CHECK-4: COMPLETION: Pattern : [<#=#>](vector <#parameter#>){<#body#>}
+}
+
+// Check another common function wrapper name.
+template  struct unique_function {};
+
+void test3() {
+  unique_function a = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:43:31 %s -o - | FileCheck -check-prefix=CHECK-5 %s
+  // CHECK-5: COMPLETION: Pattern : [<#=#>]{<#body#>}
+}
+
+template  struct weird_function {};
+void test4() {
+  weird_function b = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:50:35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
+  // CHECK-6-NOT: COMPLETION: Pattern : [<#=
+}
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -4108,6 +4108,69 @@
   Results.ExitScope();
 }
 
+/// Try to find a corresponding FunctionProtoType for function-like types (e.g.
+/// function pointers, std::function, etc).
+static const FunctionProtoType *TryDeconstructFunctionLike(QualType T) {
+  assert(!T.isNull());
+  // Try to extract first template argument from std::function<> and similar.
+  // Note we only handle the sugared types, they closely match what users wrote.
+  // We explicitly choose to not handle ClassTemplateSpecializationDecl.
+  if (auto *Specialization = T->getAs()) {
+if (Specialization->getNumArgs() != 1)
+  return nullptr;
+const TemplateArgument &Argument = Specialization->getArg(0);
+if (Argument.getKind() != TemplateArgument::Type)
+  return nullptr;
+return Argument.getAsType()->getAs();
+  }
+  // Handle other cases.
+  if (T->isPointerType())
+T = T->getPointeeType();
+  return T->getAs();
+}
+
+/// Adds a pattern completion for a lambda expression with the specified
+/// parameter types and placeholders for parameter names.
+static void AddLambdaCompletion(ResultBuilder &Results,
+llvm::ArrayRef Parameters,
+const LangOptions &LangOpts) {
+  CodeCompletionBuilder Completion(Results.getAllocator(),
+   Results.getCodeCompletionTUInfo());
+  // []() {}
+  Completion.AddChunk(CodeCompletionString::CK_LeftBracket);
+  Completion.AddPlaceholderChunk("=");
+  Completion.AddChunk(CodeCompletionString::CK_RightBracket);
+  if (!Parameters.empty()) {
+Completion.AddChunk(CodeCompletionString::CK_LeftParen);
+bool First = true;
+for (auto Parameter : Parameters) {
+  if (!First)
+Completion.AddChunk(CodeCompletionString::ChunkKind::CK

[clang-tools-extra] r361464 - [clangd-vscode] Bump versions dependencies. NFC

2019-05-23 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu May 23 01:06:24 2019
New Revision: 361464

URL: http://llvm.org/viewvc/llvm-project?rev=361464&view=rev
Log:
[clangd-vscode] Bump versions dependencies. NFC

Result of running 'npm audit fix', which tracks security vulnerabilities.

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json?rev=361464&r1=361463&r2=361464&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json Thu 
May 23 01:06:24 2019
@@ -1,6 +1,6 @@
 {
 "name": "vscode-clangd",
-"version": "0.0.10",
+"version": "0.0.12",
 "lockfileVersion": 1,
 "requires": true,
 "dependencies": {
@@ -489,9 +489,9 @@
 "dev": true
 },
 "fstream": {
-"version": "1.0.11",
-"resolved": 
"https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz";,
-"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
+"version": "1.0.12",
+"resolved": 
"https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz";,
+"integrity": 
"sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
 "dev": true,
 "requires": {
 "graceful-fs": "^4.1.2",
@@ -1401,9 +1401,9 @@
 },
 "dependencies": {
 "glob": {
-"version": "7.1.3",
-"resolved": 
"https://registry.npmjs.org/glob/-/glob-7.1.3.tgz";,
-"integrity": 
"sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
+"version": "7.1.4",
+"resolved": 
"https://registry.npmjs.org/glob/-/glob-7.1.4.tgz";,
+"integrity": 
"sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
 "dev": true,
 "requires": {
 "fs.realpath": "^1.0.0",
@@ -1413,15 +1413,6 @@
 "once": "^1.3.0",
 "path-is-absolute": "^1.0.0"
 }
-},
-"minimatch": {
-"version": "3.0.4",
-"resolved": 
"https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz";,
-"integrity": 
"sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
-"dev": true,
-"requires": {
-"brace-expansion": "^1.1.7"
-}
 }
 }
 },
@@ -1547,13 +1538,13 @@
 }
 },
 "tar": {
-"version": "2.2.1",
-"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz";,
-"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
+"version": "2.2.2",
+"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz";,
+"integrity": 
"sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==",
 "dev": true,
 "requires": {
 "block-stream": "*",
-"fstream": "^1.0.2",
+"fstream": "^1.0.12",
 "inherits": "2"
 }
 },


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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-05-23 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1017
+  let LangOpts = [SYCL];
+  let Documentation = [Undocumented];
+}

bader wrote:
> Anastasia wrote:
> > Ok, I thought the earlier request was not to add undocumented attributes 
> > with the spelling?
> > 
> > Also did `__kernel` attribute not work at the end?
> > 
> > I can't quite get where the current disconnect comes from but I find it 
> > extremely unhelpful.
> Hi @Anastasia, let me try to help.
> 
> > Ok, I thought the earlier request was not to add undocumented attributes 
> > with the spelling?
> 
> Right. @Fznamznon, could you document `sycl_kernel` attribute, please?
> 
> > Also did __kernel attribute not work at the end?
> 
> Maria left a comment with the summary of our experiment: 
> https://reviews.llvm.org/D60455#1472705. There is a link to pull request, 
> where @keryell and @agozillon expressed preference to have separate SYCL 
> attributes. Let me copy their feedback here:
> 
> @keryell :
> 
> > Thank you for the experiment.
> > That looks like a straight forward change.
> > The interesting part is that it does not expose any advantage from reusing 
> > OpenCL __kernel marker So I am not more convinced that it is the way to 
> > go, because we would use any other keyword or attribute and it would be the 
> > same...
> > 
> 
> @agozillon :
> 
> > Just my two cents, I think a separation of concerns and having separate 
> > attributes will simplify things long-term.
> > 
> > While possibly similar just now, the SYCL specification is evolving and may 
> > end up targeting more than just OpenCL. So the semantics of the attributes 
> > may end up being quite different, even if at the moment the SYCL attribute 
> > is there mostly just to mark something for outlining.
> > 
> > If it doesn't then the case for refactoring and merging them in a future 
> > patch could be brought up again.
> 
> To summarize: we don't have good arguments to justify re-use of OpenCL 
> `__kernel` keyword for SYCL mode requested by @aaron.ballman here 
> https://reviews.llvm.org/D60455#1469150.
> 
> > I can't quite get where the current disconnect comes from but I find it 
> > extremely unhelpful.
> 
> Let me know how I can help here.
> 
> Additional note. I've submitted initial version of SYCL compiler design 
> document to the GItHub: 
> https://github.com/intel/llvm/blob/sycl/sycl/doc/SYCL_compiler_and_runtime_design.md.
>  Please, take a look and let me know if you have questions.
>> Ok, I thought the earlier request was not to add undocumented attributes 
>> with the spelling?
> Right. @Fznamznon, could you document sycl_kernel attribute, please?

Do we really need add documentation for attribute which is not presented in 
SYCL spec and used for internal implementation details only because it has 
spelling?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D62288: [clangd-vscode] Do not customize uri converters in vscode

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM, this improves the paths produced for generated files inside 
`bazel-genfiles`, we now point to the 
`/my/project/bazel-genfiles/path/to/some.proto.h` instead of 
`/path/to/bazel/internals//path/to/some.proto.h`




Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:3
 import * as vscodelc from 'vscode-languageclient';
 import { realpathSync } from 'fs';
 

NIT: remove this import, we don't need it anymore


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62288



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


[PATCH] D36226: Added a RealFileSystem implementation that does not rely on global CWD.

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov abandoned this revision.
ilya-biryukov added a subscriber: sammccall.
ilya-biryukov added a comment.

abandoning in favor of the change landed by @sammccall that resolves uses 
absolute paths instead of `at`-family functions.


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

https://reviews.llvm.org/D36226



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


[PATCH] D37813: clang-format: better handle namespace macros

2019-05-23 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D37813#1512317 , @Typz wrote:

> The patch goal is indeed to indent the content of namespace-macro blocks like 
> the content of any 'regular' namespace. So it should look like the content of 
> a namespace, possibly depending on the choose style options. To sumarize, 
> here is a detailed summary of the observable differences between macros vs 
> normal namespace.
>
> **Without this patch**, clang-format does not understand the macro call 
> actually defines a namespace, thus:
>
> - the content of the namespace-macro block is indented, even when 
> `Style.NamespaceIndentation = FormatStyle::NI_None` ``` lang=cpp TESTSUITE(A) 
> { int i;  // <--- should not be indented } namespace B { int 
> j; } ```
> - similarly for nested namespaces, when  `Style.NamespaceIndentation = 
> FormatStyle::NI_Inner` : ``` lang=cpp TESTSUITE(A) { TESTSUITE(B) { int i;
> // <--- should be indented 2-chars only } } namespace C { 
> namespace D { int j; } } ```
> - There is no automatic fix of namespace end comment when 
> `Style.FixNamespaceComments = true` ``` lang=cpp TESTSUITE(A) { int i; }  
>// <--- should have a namespace end comment namespace B { 
> int j; } // namespace B ```
> - Multiple nested namespaces are not compacted when `Style.CompactNamespaces 
> = true` ``` lang=cpp TESTSUITE(A) { TESTSUITE(B) { //<--- should 
> be merged with previous line int i; } } // <--- 
> should be merged with previous line (and have a "combined" namespace end 
> comment) namespace A { namespace B { int j; } // namespace A::B ```
>
>   ---
>
>   **This patch fixes all these points**, which hopefully leads to the exact 
> same formatting when using the namespace keyword or the namespace-macros: ``` 
> lang=cpp // Style.NamespaceIndentation = FormatStyle::NI_None TESTSUITE(A) { 
> int i; } namespace B { int j; }
>
>   // Style.NamespaceIndentation = FormatStyle::NI_Inner TESTSUITE(A) { 
> TESTSUITE(B) { int i; } } namespace C { namespace D { int j; } }
>
>   // Style.FixNamespaceComments = true TESTSUITE(A) { int i; } // 
> TESTSUITE(A) namespace B { int j; } // namespace B
>
>   // Style.CompactNamespaces = true TESTSUITE(A) { TESTSUITE(B) { int i; }} 
> // TESTSUITE(A::B) namespace A { namespace B { int j; }} // namespace A::B ```
>
>   I did not see any issue in my testing or reviewing the code, but if you see 
> a place in the tests where it does not match this, please point it out !


Ah, wow, I see what confused me now:
In the fixNamespaceEndComment tests you use an indent that clang-format would 
not produce. Can you please fix that, otherwise I find this super confusing :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813



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


[PATCH] D62293: [modules] Add PP callbacks for entering and leaving a submodule.

2019-05-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: rsmith, bruno.
Herald added subscribers: jsji, dexonsmith, kbarton, nemanjai.
Herald added a project: clang.

Our usecase is that we would like to support making some modules visible 
(without corresponding #includes) while building a module.

Experimental implementation here: 
https://github.com/root-project/root/pull/3850/commits/cef39111ccff432e32db84952d0bb9b3aac8c7d5


Repository:
  rC Clang

https://reviews.llvm.org/D62293

Files:
  include/clang/Lex/PPCallbacks.h
  lib/Lex/PPLexerChange.cpp


Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -689,6 +689,8 @@
 BuildingSubmoduleStack.push_back(
 BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
   PendingModuleMacroNames.size()));
+if (Callbacks)
+  Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
 return;
   }
 
@@ -733,6 +735,9 @@
   BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
 PendingModuleMacroNames.size()));
 
+  if (Callbacks)
+Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
+
   // Switch to this submodule as the current submodule.
   CurSubmoduleState = &State;
 
@@ -773,6 +778,10 @@
 // are tracking macro visibility, don't build any, and preserve the list
 // of pending names for the surrounding submodule.
 BuildingSubmoduleStack.pop_back();
+
+if (Callbacks)
+  Callbacks->LeftSubmodule(ForPragma);
+
 makeModuleVisible(LeavingMod, ImportLoc);
 return LeavingMod;
   }
@@ -857,6 +866,9 @@
 
   BuildingSubmoduleStack.pop_back();
 
+  if (Callbacks)
+Callbacks->LeftSubmodule(ForPragma);
+
   // A nested #include makes the included submodule visible.
   makeModuleVisible(LeavingMod, ImportLoc);
   return LeavingMod;
Index: include/clang/Lex/PPCallbacks.h
===
--- include/clang/Lex/PPCallbacks.h
+++ include/clang/Lex/PPCallbacks.h
@@ -388,6 +388,13 @@
Imported, FileType);
   }
 
+  void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
+bool ForPragma) override {
+First->EnteredSubmodule(M, ImportLoc, ForPragma);
+Second->EnteredSubmodule(M, ImportLoc, ForPragma);
+  }
+
+
   void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
 const Module *Imported) override {
 First->moduleImport(ImportLoc, Path, Imported);


Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -689,6 +689,8 @@
 BuildingSubmoduleStack.push_back(
 BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
   PendingModuleMacroNames.size()));
+if (Callbacks)
+  Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
 return;
   }
 
@@ -733,6 +735,9 @@
   BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
 PendingModuleMacroNames.size()));
 
+  if (Callbacks)
+Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
+
   // Switch to this submodule as the current submodule.
   CurSubmoduleState = &State;
 
@@ -773,6 +778,10 @@
 // are tracking macro visibility, don't build any, and preserve the list
 // of pending names for the surrounding submodule.
 BuildingSubmoduleStack.pop_back();
+
+if (Callbacks)
+  Callbacks->LeftSubmodule(ForPragma);
+
 makeModuleVisible(LeavingMod, ImportLoc);
 return LeavingMod;
   }
@@ -857,6 +866,9 @@
 
   BuildingSubmoduleStack.pop_back();
 
+  if (Callbacks)
+Callbacks->LeftSubmodule(ForPragma);
+
   // A nested #include makes the included submodule visible.
   makeModuleVisible(LeavingMod, ImportLoc);
   return LeavingMod;
Index: include/clang/Lex/PPCallbacks.h
===
--- include/clang/Lex/PPCallbacks.h
+++ include/clang/Lex/PPCallbacks.h
@@ -388,6 +388,13 @@
Imported, FileType);
   }
 
+  void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
+bool ForPragma) override {
+First->EnteredSubmodule(M, ImportLoc, ForPragma);
+Second->EnteredSubmodule(M, ImportLoc, ForPragma);
+  }
+
+
   void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
 const Module *Imported) override {
 First->moduleImport(ImportLoc, Path, Imported);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361467 - Enable queue_t and clk_event_t comparisons in C++ mode

2019-05-23 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu May 23 02:20:08 2019
New Revision: 361467

URL: http://llvm.org/viewvc/llvm-project?rev=361467&view=rev
Log:
Enable queue_t and clk_event_t comparisons in C++ mode

Support queue_t and clk_event_t comparisons in C++ for OpenCL mode, to
preserve backwards compatibility with OpenCL C.

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/clk_event_t.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=361467&r1=361466&r2=361467&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu May 23 02:20:08 2019
@@ -10808,7 +10808,7 @@ QualType Sema::CheckCompareOperands(Expr
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200) {
+  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }

Modified: cfe/trunk/test/SemaOpenCL/clk_event_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clk_event_t.cl?rev=361467&r1=361466&r2=361467&view=diff
==
--- cfe/trunk/test/SemaOpenCL/clk_event_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/clk_event_t.cl Thu May 23 02:20:08 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 // Taken from opencl-c.h
 #define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))


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


[PATCH] D62208: [OpenCL] Enable queue_t and clk_event_t comparisons in C++ mode

2019-05-23 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361467: Enable queue_t and clk_event_t comparisons in C++ 
mode (authored by svenvh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62208?vs=200534&id=200895#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62208

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaOpenCL/clk_event_t.cl


Index: cfe/trunk/test/SemaOpenCL/clk_event_t.cl
===
--- cfe/trunk/test/SemaOpenCL/clk_event_t.cl
+++ cfe/trunk/test/SemaOpenCL/clk_event_t.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 // Taken from opencl-c.h
 #define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -10808,7 +10808,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200) {
+  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }


Index: cfe/trunk/test/SemaOpenCL/clk_event_t.cl
===
--- cfe/trunk/test/SemaOpenCL/clk_event_t.cl
+++ cfe/trunk/test/SemaOpenCL/clk_event_t.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 // Taken from opencl-c.h
 #define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -10808,7 +10808,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200) {
+  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361468 - Delete default constructors, copy constructors, move constructors, copy assignment, move assignment operators on Expr, Stmt and Decl

2019-05-23 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Thu May 23 02:22:43 2019
New Revision: 361468

URL: http://llvm.org/viewvc/llvm-project?rev=361468&view=rev
Log:
Delete default constructors, copy constructors, move constructors, copy 
assignment, move assignment operators on Expr, Stmt and Decl

Reviewers: ilya-biryukov, rsmith

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=361468&r1=361467&r2=361468&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu May 23 02:22:43 2019
@@ -368,6 +368,13 @@ private:
 return ModuleOwnershipKind::Unowned;
   }
 
+public:
+  Decl() = delete;
+  Decl(const Decl&) = delete;
+  Decl(Decl &&) = delete;
+  Decl &operator=(const Decl&) = delete;
+  Decl &operator=(Decl&&) = delete;
+
 protected:
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
   : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=361468&r1=361467&r2=361468&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu May 23 02:22:43 2019
@@ -108,6 +108,13 @@ struct SubobjectAdjustment {
 class Expr : public ValueStmt {
   QualType TR;
 
+public:
+  Expr() = delete;
+  Expr(const Expr&) = delete;
+  Expr(Expr &&) = delete;
+  Expr &operator=(const Expr&) = delete;
+  Expr &operator=(Expr&&) = delete;
+
 protected:
   Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=361468&r1=361467&r2=361468&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu May 23 02:22:43 2019
@@ -1040,6 +1040,12 @@ protected:
   explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
 
 public:
+  Stmt() = delete;
+  Stmt(const Stmt &) = delete;
+  Stmt(Stmt &&) = delete;
+  Stmt &operator=(const Stmt &) = delete;
+  Stmt &operator=(Stmt &&) = delete;
+
   Stmt(StmtClass SC) {
 static_assert(sizeof(*this) <= 8,
   "changing bitfields changed sizeof(Stmt)");
@@ -1054,11 +1060,6 @@ public:
 return static_cast(StmtBits.sClass);
   }
 
-  Stmt(const Stmt &) = delete;
-  Stmt(Stmt &&) = delete;
-  Stmt &operator=(const Stmt &) = delete;
-  Stmt &operator=(Stmt &&) = delete;
-
   const char *getStmtClassName() const;
 
   bool isOMPStructuredBlock() const { return StmtBits.IsOMPStructuredBlock; }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=361468&r1=361467&r2=361468&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu May 23 02:22:43 2019
@@ -1134,9 +1134,10 @@ llvm::Function *CodeGenFunction::generat
 return F;
 
   llvm::SmallVector ArgTys;
-  llvm::SmallVector Params;
-  Params.emplace_back(Ctx, nullptr, SourceLocation(), 
&Ctx.Idents.get("buffer"),
-  Ctx.VoidPtrTy, ImplicitParamDecl::Other);
+  FunctionArgList Args;
+  Args.push_back(ImplicitParamDecl::Create(
+  Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"), Ctx.VoidPtrTy,
+  ImplicitParamDecl::Other));
   ArgTys.emplace_back(Ctx.VoidPtrTy);
 
   for (unsigned int I = 0, E = Layout.Items.size(); I < E; ++I) {
@@ -1145,17 +1146,13 @@ llvm::Function *CodeGenFunction::generat
   continue;
 
 QualType ArgTy = getOSLogArgType(Ctx, Size);
-Params.emplace_back(
+Args.push_back(ImplicitParamDecl::Create(
 Ctx, nullptr, SourceLocation(),
 &Ctx.Idents.get(std::string("arg") + llvm::to_string(I)), ArgTy,
-ImplicitParamDecl::Other);
+ImplicitParamDecl::Other));
 ArgTys.emplace_back(ArgTy);
   }
 
-  FunctionArgList Args;
-  for (auto &P : Params)
-Args.push_back(&P);
-
   QualType ReturnTy = Ctx.VoidTy;
   QualType FuncionTy = Ctx.getFunctionType(ReturnTy, ArgTys, {});
 
@@ -1188,7 +1185,7 @@ llvm::Function *CodeGenFunction::generat
   auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   CharUnits Offset;
-  Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(&Params[0]), "buf"),
+  Address 

[PATCH] D62187: Delete default constructors, copy constructors, move constructors, copy assignment, move assignment operators on Expr, Stmt and Decl

2019-05-23 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
gribozavr marked an inline comment as done.
Closed by commit rC361468: Delete default constructors, copy constructors, move 
constructors, copy… (authored by gribozavr, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62187?vs=200684&id=200896#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62187

Files:
  include/clang/AST/DeclBase.h
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  lib/CodeGen/CGBuiltin.cpp

Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -1040,6 +1040,12 @@
   explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
 
 public:
+  Stmt() = delete;
+  Stmt(const Stmt &) = delete;
+  Stmt(Stmt &&) = delete;
+  Stmt &operator=(const Stmt &) = delete;
+  Stmt &operator=(Stmt &&) = delete;
+
   Stmt(StmtClass SC) {
 static_assert(sizeof(*this) <= 8,
   "changing bitfields changed sizeof(Stmt)");
@@ -1054,11 +1060,6 @@
 return static_cast(StmtBits.sClass);
   }
 
-  Stmt(const Stmt &) = delete;
-  Stmt(Stmt &&) = delete;
-  Stmt &operator=(const Stmt &) = delete;
-  Stmt &operator=(Stmt &&) = delete;
-
   const char *getStmtClassName() const;
 
   bool isOMPStructuredBlock() const { return StmtBits.IsOMPStructuredBlock; }
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -108,6 +108,13 @@
 class Expr : public ValueStmt {
   QualType TR;
 
+public:
+  Expr() = delete;
+  Expr(const Expr&) = delete;
+  Expr(Expr &&) = delete;
+  Expr &operator=(const Expr&) = delete;
+  Expr &operator=(Expr&&) = delete;
+
 protected:
   Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Index: include/clang/AST/DeclBase.h
===
--- include/clang/AST/DeclBase.h
+++ include/clang/AST/DeclBase.h
@@ -368,6 +368,13 @@
 return ModuleOwnershipKind::Unowned;
   }
 
+public:
+  Decl() = delete;
+  Decl(const Decl&) = delete;
+  Decl(Decl &&) = delete;
+  Decl &operator=(const Decl&) = delete;
+  Decl &operator=(Decl&&) = delete;
+
 protected:
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
   : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1134,9 +1134,10 @@
 return F;
 
   llvm::SmallVector ArgTys;
-  llvm::SmallVector Params;
-  Params.emplace_back(Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"),
-  Ctx.VoidPtrTy, ImplicitParamDecl::Other);
+  FunctionArgList Args;
+  Args.push_back(ImplicitParamDecl::Create(
+  Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"), Ctx.VoidPtrTy,
+  ImplicitParamDecl::Other));
   ArgTys.emplace_back(Ctx.VoidPtrTy);
 
   for (unsigned int I = 0, E = Layout.Items.size(); I < E; ++I) {
@@ -1145,17 +1146,13 @@
   continue;
 
 QualType ArgTy = getOSLogArgType(Ctx, Size);
-Params.emplace_back(
+Args.push_back(ImplicitParamDecl::Create(
 Ctx, nullptr, SourceLocation(),
 &Ctx.Idents.get(std::string("arg") + llvm::to_string(I)), ArgTy,
-ImplicitParamDecl::Other);
+ImplicitParamDecl::Other));
 ArgTys.emplace_back(ArgTy);
   }
 
-  FunctionArgList Args;
-  for (auto &P : Params)
-Args.push_back(&P);
-
   QualType ReturnTy = Ctx.VoidTy;
   QualType FuncionTy = Ctx.getFunctionType(ReturnTy, ArgTys, {});
 
@@ -1188,7 +1185,7 @@
   auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   CharUnits Offset;
-  Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(&Params[0]), "buf"),
+  Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(Args[0]), "buf"),
   BufferAlignment);
   Builder.CreateStore(Builder.getInt8(Layout.getSummaryByte()),
   Builder.CreateConstByteGEP(BufAddr, Offset++, "summary"));
@@ -1208,7 +1205,7 @@
 if (!Size.getQuantity())
   continue;
 
-Address Arg = GetAddrOfLocalVar(&Params[I]);
+Address Arg = GetAddrOfLocalVar(Args[I]);
 Address Addr = Builder.CreateConstByteGEP(BufAddr, Offset, "argData");
 Addr = Builder.CreateBitCast(Addr, Arg.getPointer()->getType(),
  "argDataCast");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53941: [clangd][wip] Add 'related information' to diagnostics. Does not work for built-in notes

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov abandoned this revision.
ilya-biryukov added a subscriber: sammccall.
ilya-biryukov added a comment.
Herald added a project: clang.

Abandoning, same functionality landed in separate revision by @sammccall


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D53941



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


[PATCH] D60465: [ASTImporter] Error handling fix in ImportDefinition_New.

2019-05-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 200901.
balazske added a comment.

Rebase to current master.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60465

Files:
  lib/AST/ASTImporter.cpp


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -8358,18 +8358,16 @@
 }
 
 Error ASTImporter::ImportDefinition(Decl *From) {
-  ExpectedDecl ToOrErr = Import(From);
-  if (!ToOrErr)
-return ToOrErr.takeError();
-  Decl *To = *ToOrErr;
+  Decl *To;
+  if (Error Err = importInto(To, From))
+return Err;
 
-  auto *FromDC = cast(From);
   ASTNodeImporter Importer(*this);
 
   if (auto *ToRecord = dyn_cast(To)) {
 if (!ToRecord->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToRecord,
+  cast(From), ToRecord,
   ASTNodeImporter::IDK_Everything);
 }
   }
@@ -8377,14 +8375,14 @@
   if (auto *ToEnum = dyn_cast(To)) {
 if (!ToEnum->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToEnum, ASTNodeImporter::IDK_Everything);
+  cast(From), ToEnum, ASTNodeImporter::IDK_Everything);
 }
   }
 
   if (auto *ToIFace = dyn_cast(To)) {
 if (!ToIFace->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToIFace,
+  cast(From), ToIFace,
   ASTNodeImporter::IDK_Everything);
 }
   }
@@ -8392,12 +8390,15 @@
   if (auto *ToProto = dyn_cast(To)) {
 if (!ToProto->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToProto,
+  cast(From), ToProto,
   ASTNodeImporter::IDK_Everything);
 }
   }
 
-  return Importer.ImportDeclContext(FromDC, true);
+  if (auto *FromDC = dyn_cast(From))
+return Importer.ImportDeclContext(FromDC, true);
+
+  return Error::success();
 }
 
 Expected ASTImporter::Import(DeclarationName FromName) {


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -8358,18 +8358,16 @@
 }
 
 Error ASTImporter::ImportDefinition(Decl *From) {
-  ExpectedDecl ToOrErr = Import(From);
-  if (!ToOrErr)
-return ToOrErr.takeError();
-  Decl *To = *ToOrErr;
+  Decl *To;
+  if (Error Err = importInto(To, From))
+return Err;
 
-  auto *FromDC = cast(From);
   ASTNodeImporter Importer(*this);
 
   if (auto *ToRecord = dyn_cast(To)) {
 if (!ToRecord->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToRecord,
+  cast(From), ToRecord,
   ASTNodeImporter::IDK_Everything);
 }
   }
@@ -8377,14 +8375,14 @@
   if (auto *ToEnum = dyn_cast(To)) {
 if (!ToEnum->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToEnum, ASTNodeImporter::IDK_Everything);
+  cast(From), ToEnum, ASTNodeImporter::IDK_Everything);
 }
   }
 
   if (auto *ToIFace = dyn_cast(To)) {
 if (!ToIFace->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToIFace,
+  cast(From), ToIFace,
   ASTNodeImporter::IDK_Everything);
 }
   }
@@ -8392,12 +8390,15 @@
   if (auto *ToProto = dyn_cast(To)) {
 if (!ToProto->getDefinition()) {
   return Importer.ImportDefinition(
-  cast(FromDC), ToProto,
+  cast(From), ToProto,
   ASTNodeImporter::IDK_Everything);
 }
   }
 
-  return Importer.ImportDeclContext(FromDC, true);
+  if (auto *FromDC = dyn_cast(From))
+return Importer.ImportDeclContext(FromDC, true);
+
+  return Error::success();
 }
 
 Expected ASTImporter::Import(DeclarationName FromName) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60465: [ASTImporter] Error handling fix in ImportDefinition_New.

2019-05-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D60465



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


[PATCH] D60465: [ASTImporter] Error handling fix in ImportDefinition_New.

2019-05-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Maybe this patch can be abandoned, the correction is already made (when every 
_New was removed).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60465



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


[PATCH] D37813: clang-format: better handle namespace macros

2019-05-23 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> Ah, wow, I see what confused me now:
>  In the fixNamespaceEndComment tests you use an indent that clang-format 
> would not produce. Can you please fix that, otherwise I find this super 
> confusing :)

Can you point a specific exemple (in code) ?

There are many tests related to fixNamespaceEndComment(), which look fine to me 
and which in many cases are copied from similarly indented test cases with 
standard namespace's...
(Or was it an earlier problem, and I should fix all these existing test cases 
as well?)


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813



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


[clang-tools-extra] r361475 - [clangd-vscode] Do not customize uri converters in vscode

2019-05-23 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu May 23 02:58:29 2019
New Revision: 361475

URL: http://llvm.org/viewvc/llvm-project?rev=361475&view=rev
Log:
[clangd-vscode] Do not customize uri converters in vscode

Summary:
Clangd is already resolving symlinks on the server side, therefore
there is no more need to handle it in client side. This was also resulting in
breakages whenever index contained a symbol coming from a non-existent file(like
a generated file), e.g. during workspace symbols whole response was dropped
since stat had failed.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts?rev=361475&r1=361474&r2=361475&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Thu 
May 23 02:58:29 2019
@@ -1,6 +1,5 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
-import { realpathSync } from 'fs';
 
 /**
  * Method to get workspace configuration option
@@ -87,17 +86,6 @@ export function activate(context: vscode
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a 
symlink tree to build in,
-// and when navigating to the included file, clangd passes its path 
inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve 
the
-// symlinks where needed (or if this causes problems for other 
workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };


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


[PATCH] D62288: [clangd-vscode] Do not customize uri converters in vscode

2019-05-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 200909.
kadircet marked an inline comment as done.
kadircet added a comment.

- Delete unusued import


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62288

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -1,6 +1,5 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
-import { realpathSync } from 'fs';
 
 /**
  * Method to get workspace configuration option
@@ -87,17 +86,6 @@
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a 
symlink tree to build in,
-// and when navigating to the included file, clangd passes its path 
inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve 
the
-// symlinks where needed (or if this causes problems for other 
workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -1,6 +1,5 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
-import { realpathSync } from 'fs';
 
 /**
  * Method to get workspace configuration option
@@ -87,17 +86,6 @@
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a symlink tree to build in,
-// and when navigating to the included file, clangd passes its path inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve the
-// symlinks where needed (or if this causes problems for other workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62288: [clangd-vscode] Do not customize uri converters in vscode

2019-05-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361475: [clangd-vscode] Do not customize uri converters in 
vscode (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62288?vs=200909&id=200913#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62288

Files:
  clangd/clients/clangd-vscode/src/extension.ts


Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -1,6 +1,5 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
-import { realpathSync } from 'fs';
 
 /**
  * Method to get workspace configuration option
@@ -87,17 +86,6 @@
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a 
symlink tree to build in,
-// and when navigating to the included file, clangd passes its path 
inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve 
the
-// symlinks where needed (or if this causes problems for other 
workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };


Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -1,6 +1,5 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
-import { realpathSync } from 'fs';
 
 /**
  * Method to get workspace configuration option
@@ -87,17 +86,6 @@
 fileEvents: vscode.workspace.createFileSystemWatcher(filePattern)
 },
 initializationOptions: { clangdFileStatus: true },
-// Resolve symlinks for all files provided by clangd.
-// This is a workaround for a bazel + clangd issue - bazel produces a symlink tree to build in,
-// and when navigating to the included file, clangd passes its path inside the symlink tree
-// rather than its filesystem path.
-// FIXME: remove this once clangd knows enough about bazel to resolve the
-// symlinks where needed (or if this causes problems for other workflows).
-uriConverters: {
-code2Protocol: (value: vscode.Uri) => value.toString(),
-protocol2Code: (value: string) =>
-vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath))
-},
 // Do not switch to output window when clangd returns output
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62282: [X86] Add ENQCMD intrinsics.

2019-05-23 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: lib/Headers/enqcmdintrin.h:21
+
+static __inline__ int _DEFAULT_FN_ATTRS
+_enqcmd (void *__dst, const void *__src)

Please add doxygen comments describing the intrinsics


Repository:
  rC Clang

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

https://reviews.llvm.org/D62282



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


[PATCH] D62298: [CodeComplete] Override completion items are filtered by funciton names

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added a project: clang.

We put only the function name into "typed text" chunks now, previously
the whole signature was "typed text".

This leads to meaningful fuzzy match scores, giving better signals to
compare with other completion items.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62298

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+void TurnDeclarationToText(const CodeCompletionString &CCS,
+   CodeCompletionBuilder &Result) {
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  TurnDeclarationToText(*Chunk.Optional, Result);
+  continue;
+}
+if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+  Result.AddTypedTextChunk(Chunk.Text);
+else
+  Result.AddTextChunk(Chunk.Text);
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  // For overrides all chunks go into the result, none are informative.
+  TurnDeclarationToText(*CCS, Result);
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTextChunk("override");
   return Result.TakeString();
 }
 


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+void TurnDeclarationToText(const CodeCompletionString &CCS,
+   CodeCompletionBuilder &Result) {
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  TurnDeclarationToText(*Chunk.Optional, Result);
+  continue;
+}
+if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+  Result.AddTypedTextChunk(Chunk.Text);
+else
+  Result.AddTextChunk(Chunk.Text);
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompleti

[PATCH] D62298: [CodeComplete] Override completion items are filtered by funciton names

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Will need to update the test before landing, but wanted to share the 
implementation right away


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62299: [PR41567][Sema] Fixed cast kind in addr space conversions

2019-05-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added a subscriber: ebevhan.

This change sets missing cast kind correctly in the address space conversion 
case.


https://reviews.llvm.org/D62299

Files:
  lib/Sema/SemaCast.cpp
  test/CodeGenOpenCLCXX/addrspace-conversion.cl


Index: test/CodeGenOpenCLCXX/addrspace-conversion.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/addrspace-conversion.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 
-o - | FileCheck %s
+
+void bar(__generic volatile unsigned int* ptr)
+{
+  //CHECK: addrspacecast i32 addrspace(4)* %{{.+}} to i32 addrspace(1)*
+  auto gptr = (__global volatile unsigned int*)ptr;
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2428,6 +2428,10 @@
 tcr = TryAddressSpaceCast(Self, SrcExpr, DestType, /*CStyle*/ true, msg);
 if (SrcExpr.isInvalid())
   return;
+
+if (isValidCast(tcr))
+  Kind = CK_AddressSpaceConversion;
+
 if (tcr == TC_NotApplicable) {
   // ... or if that is not possible, a static_cast, ignoring const, ...
   tcr = TryStaticCast(Self, SrcExpr, DestType, CCK, OpRange, msg, Kind,


Index: test/CodeGenOpenCLCXX/addrspace-conversion.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/addrspace-conversion.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+void bar(__generic volatile unsigned int* ptr)
+{
+  //CHECK: addrspacecast i32 addrspace(4)* %{{.+}} to i32 addrspace(1)*
+  auto gptr = (__global volatile unsigned int*)ptr;
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2428,6 +2428,10 @@
 tcr = TryAddressSpaceCast(Self, SrcExpr, DestType, /*CStyle*/ true, msg);
 if (SrcExpr.isInvalid())
   return;
+
+if (isValidCast(tcr))
+  Kind = CK_AddressSpaceConversion;
+
 if (tcr == TC_NotApplicable) {
   // ... or if that is not possible, a static_cast, ignoring const, ...
   tcr = TryStaticCast(Self, SrcExpr, DestType, CCK, OpRange, msg, Kind,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62093: [analyzer] List checkers in 3 categories: released, alpha, developer

2019-05-23 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp:527-530
+// developer checkers even in the alpha output. For example,
+// alpha.cplusplus.IteratorModeling is a modeling checker, hence it's 
hidden
+// by default, and users (even when the user is a developer of an alpha
+// checker) shouldn't normally tinker with whether they should be enabled.

Szelethus wrote:
> NoQ wrote:
> > Hmm, just thought about this: by this logic, should we hide all `core` 
> > checkers? Because we don't really support users tinkering with whether they 
> > should be enabled :)
> Thats actually a very cool idea. We should totally do that!
Well umm. In a sense, sure, but wouldn't we want to display the checker 
descriptions at least? Let's not rush this for now.


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

https://reviews.llvm.org/D62093



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


[PATCH] D62298: [CodeComplete] Override completion items are filtered by funciton names

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200924.
ilya-biryukov added a comment.

- Use the old name for the helper function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+static void PrintOverrideString(const CodeCompletionString &CCS,
+CodeCompletionBuilder &Result) {
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  PrintOverrideString(*Chunk.Optional, Result);
+  continue;
+}
+if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+  Result.AddTypedTextChunk(Chunk.Text);
+else
+  Result.AddTextChunk(Chunk.Text);
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  // For overrides all chunks go into the result, none are informative.
+  PrintOverrideString(*CCS, Result);
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTextChunk("override");
   return Result.TakeString();
 }
 


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+static void PrintOverrideString(const CodeCompletionString &CCS,
+CodeCompletionBuilder &Result) {
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  PrintOverrideString(*Chunk.Optional, Result);
+  continue;
+}
+if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+  Result.AddTypedTextChunk(Chunk.Text);
+else
+  Result.AddTextChunk(Chunk.Text);
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {

[PATCH] D62298: [CodeComplete] Override completion items are filtered by funciton names

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200926.
ilya-biryukov added a comment.

- Update the tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp


Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -20,14 +20,18 @@
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
+// Runs completion at v^oid.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:4 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
+// Runs completion at vo^id.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3-NOT: COMPLETION: Pattern : override
+//
 // Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
-// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) 
override{{$}}
-// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 4) const 
override{{$}}
+// CHECK-CC4-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) 
override{{$}}
+// CHECK-CC4-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+static void PrintOverrideString(const CodeCompletionString &CCS,
+CodeCompletionBuilder &Result) {
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  PrintOverrideString(*Chunk.Optional, Result);
+  continue;
+}
+if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+  Result.AddTypedTextChunk(Chunk.Text);
+else
+  Result.AddTextChunk(Chunk.Text);
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  // For overrides all chunks go into the result, none are informative.
+  PrintOverrideString(*CCS, Result);
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTextChunk("override");
   return Result.TakeString();
 }
 


Index: clang/test/CodeCo

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry for so many changes, this is ready for review now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200927.
ilya-biryukov added a comment.

- Simplify negative tests a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp


Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -20,14 +20,16 @@
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
+// Runs completion at v^oid.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:4 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
+// Runs completion at vo^id.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3-NOT: override
+//
 // Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
-// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) 
override{{$}}
-// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4-NOT: override
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+static void PrintOverrideString(const CodeCompletionString &CCS,
+CodeCompletionBuilder &Result) {
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  PrintOverrideString(*Chunk.Optional, Result);
+  continue;
+}
+if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+  Result.AddTypedTextChunk(Chunk.Text);
+else
+  Result.AddTextChunk(Chunk.Text);
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  // For overrides all chunks go into the result, none are informative.
+  PrintOverrideString(*CCS, Result);
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTextChunk("override");
   return Result.TakeString();
 }
 


Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -20,14 +20,16 @@
 // CHECK-CC1: COMPLETION: Pattern : vo

[PATCH] D37813: clang-format: better handle namespace macros

2019-05-23 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: unittests/Format/NamespaceEndCommentsFixerTest.cpp:582
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"} // TESTSUITE()",

All of the fixNamespaceEndComments tests are indented, but standard llvm style 
doesn't indent in namespaces at all iiuc.


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-05-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

//**Design question**//: since you are not aware what functions are to be run 
on a device while parsing them, at what point do you plan to diagnose the 
invalid behavior from the standard C++ i.e. using function pointers in kernel 
code is likely to cause issues?

Also do you need to outline the data structures too? For example classes used 
on device are not allowed to have virtual function.




Comment at: clang/include/clang/Basic/Attr.td:1017
+  let LangOpts = [SYCL];
+  let Documentation = [Undocumented];
+}

Fznamznon wrote:
> bader wrote:
> > Anastasia wrote:
> > > Ok, I thought the earlier request was not to add undocumented attributes 
> > > with the spelling?
> > > 
> > > Also did `__kernel` attribute not work at the end?
> > > 
> > > I can't quite get where the current disconnect comes from but I find it 
> > > extremely unhelpful.
> > Hi @Anastasia, let me try to help.
> > 
> > > Ok, I thought the earlier request was not to add undocumented attributes 
> > > with the spelling?
> > 
> > Right. @Fznamznon, could you document `sycl_kernel` attribute, please?
> > 
> > > Also did __kernel attribute not work at the end?
> > 
> > Maria left a comment with the summary of our experiment: 
> > https://reviews.llvm.org/D60455#1472705. There is a link to pull request, 
> > where @keryell and @agozillon expressed preference to have separate SYCL 
> > attributes. Let me copy their feedback here:
> > 
> > @keryell :
> > 
> > > Thank you for the experiment.
> > > That looks like a straight forward change.
> > > The interesting part is that it does not expose any advantage from 
> > > reusing OpenCL __kernel marker So I am not more convinced that it is 
> > > the way to go, because we would use any other keyword or attribute and it 
> > > would be the same...
> > > 
> > 
> > @agozillon :
> > 
> > > Just my two cents, I think a separation of concerns and having separate 
> > > attributes will simplify things long-term.
> > > 
> > > While possibly similar just now, the SYCL specification is evolving and 
> > > may end up targeting more than just OpenCL. So the semantics of the 
> > > attributes may end up being quite different, even if at the moment the 
> > > SYCL attribute is there mostly just to mark something for outlining.
> > > 
> > > If it doesn't then the case for refactoring and merging them in a future 
> > > patch could be brought up again.
> > 
> > To summarize: we don't have good arguments to justify re-use of OpenCL 
> > `__kernel` keyword for SYCL mode requested by @aaron.ballman here 
> > https://reviews.llvm.org/D60455#1469150.
> > 
> > > I can't quite get where the current disconnect comes from but I find it 
> > > extremely unhelpful.
> > 
> > Let me know how I can help here.
> > 
> > Additional note. I've submitted initial version of SYCL compiler design 
> > document to the GItHub: 
> > https://github.com/intel/llvm/blob/sycl/sycl/doc/SYCL_compiler_and_runtime_design.md.
> >  Please, take a look and let me know if you have questions.
> >> Ok, I thought the earlier request was not to add undocumented attributes 
> >> with the spelling?
> > Right. @Fznamznon, could you document sycl_kernel attribute, please?
> 
> Do we really need add documentation for attribute which is not presented in 
> SYCL spec and used for internal implementation details only because it has 
> spelling?
> 
> Ok, I thought the earlier request was not to add undocumented 
> attributes with the spelling?
> 
> Right. @Fznamznon, could you document sycl_kernel attribute, please?
> 
> Do we really need add documentation for attribute which is not presented in 
> SYCL spec and used for internal implementation details only because it has 
> spelling?



You are adding an attribute that is exposed to the programmers that use clang 
to compile their code, so unless you come up with some way to reject it in the 
non-toolchain mode it has to be documented. And for clang it will become 
"hidden" SYCL dialect so absolutely not different to `__kernel`.

Another aspect to consider is that clang used `TypePrinter` in diagnostics and 
even though printing entire function signature is rare it might appear in 
diagnostics and the programmer should have a way to understand what the "alien" 
construct is. This is where clang documentation will help.



Comment at: clang/include/clang/Basic/Attr.td:1017
+  let LangOpts = [SYCL];
+  let Documentation = [Undocumented];
+}

Anastasia wrote:
> Fznamznon wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > Ok, I thought the earlier request was not to add undocumented 
> > > > attributes with the spelling?
> > > > 
> > > > Also did `__kernel` attribute not work at the end?
> > > > 
> > > > I can't quite get where the current disconnect comes from but I find it 
> > > > extremely unhelpful.
> > > Hi @Anastasia, let me try to help.
> > > 
> > > > Ok, I thought the earlier request was not to a

[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!

Please address the minor nitpicks suggested here in your final commit.




Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:16
+//   -Builtins.def, containing builtins functions requiring special handling.
+//   -opencl-c.h, containing OpenCL type definitions and builtins functions
+//which have few overloads.

I don't think we plan to modify `opencl-c.h` due to compatibility issues. I 
think we should factor out functionality that will be required by both 
`TableGen` mode and regular include mode into something like `opencl-common.h`.



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:66
+//===--===//
+//  OpenCL/C classes for types
+//===--===//

OpenCL/C -> OpenCL C



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:106
+//===--===//
+//  OpenCL/C class for builtin functions
+//===--===//

-> OpenCL C



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:168
+//===--===//
+// Definitions of OpenCL/C types
+//===--===//

-> OpenCL C



Comment at: clang/test/SemaOpenCL/builtin-new.cl:18
+
+kernel void basic_extension(global uint* out) {
+  out[0] = get_sub_group_size();

basic_extension  -> basic_subgroup


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

https://reviews.llvm.org/D60763



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


[PATCH] D62197: [OpenCL] Fix file-scope const sampler variable for 2.0

2019-05-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

Makes sense. LGTM! Thanks!


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

https://reviews.llvm.org/D62197



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


[clang-tools-extra] r361486 - [clangd] Bump vscode extension version

2019-05-23 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu May 23 04:58:03 2019
New Revision: 361486

URL: http://llvm.org/viewvc/llvm-project?rev=361486&view=rev
Log:
[clangd] Bump vscode extension version

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json?rev=361486&r1=361485&r2=361486&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json (original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json Thu May 
23 04:58:03 2019
@@ -2,7 +2,7 @@
 "name": "vscode-clangd",
 "displayName": "vscode-clangd",
 "description": "Clang Language Server",
-"version": "0.0.12",
+"version": "0.0.13",
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {


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


[clang-tools-extra] r361487 - [clang-tidy] New check calling out uses of +new in Objective-C code

2019-05-23 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Thu May 23 05:01:26 2019
New Revision: 361487

URL: http://llvm.org/viewvc/llvm-project?rev=361487&view=rev
Log:
[clang-tidy] New check calling out uses of +new in Objective-C code

Summary:
Google's Objective-C style guide forbids calling or overriding +new to 
instantiate objects. This check warns on violations.

Style guide reference: 
https://google.github.io/styleguide/objcguide.html#do-not-use-new

Patch by Michael Wyman.

Reviewers: benhamilton, aaron.ballman, JonasToth, gribozavr, ilya-biryukov, 
stephanemoore, mwyman

Reviewed By: aaron.ballman, gribozavr, stephanemoore, mwyman

Subscribers: stephanemoore, xazax.hun, Eugene.Zelenko, mgorny, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/google/AvoidNSObjectNewCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/AvoidNSObjectNewCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-nsobject-new.rst
clang-tools-extra/trunk/test/clang-tidy/google-objc-avoid-nsobject-new.m
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Added: clang-tools-extra/trunk/clang-tidy/google/AvoidNSObjectNewCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidNSObjectNewCheck.cpp?rev=361487&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidNSObjectNewCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidNSObjectNewCheck.cpp Thu May 
23 05:01:26 2019
@@ -0,0 +1,130 @@
+//===--- AvoidNSObjectNewCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidNSObjectNewCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+static bool isMessageExpressionInsideMacro(const ObjCMessageExpr *Expr) {
+  SourceLocation ReceiverLocation = Expr->getReceiverRange().getBegin();
+  if (ReceiverLocation.isMacroID())
+return true;
+
+  SourceLocation SelectorLocation = Expr->getSelectorStartLoc();
+  if (SelectorLocation.isMacroID())
+return true;
+
+  return false;
+}
+
+// Walk up the class hierarchy looking for an -init method, returning true
+// if one is found and has not been marked unavailable.
+static bool isInitMethodAvailable(const ObjCInterfaceDecl *ClassDecl) {
+  while (ClassDecl != nullptr) {
+for (const auto *MethodDecl : ClassDecl->instance_methods()) {
+  if (MethodDecl->getSelector().getAsString() == "init")
+return !MethodDecl->isUnavailable();
+}
+ClassDecl = ClassDecl->getSuperClass();
+  }
+
+  // No -init method found in the class hierarchy. This should occur only 
rarely
+  // in Objective-C code, and only really applies to classes not derived from
+  // NSObject.
+  return false;
+}
+
+// Returns the string for the Objective-C message receiver. Keeps any generics
+// included in the receiver class type, which are stripped if the class type is
+// used. While the generics arguments will not make any difference to the
+// returned code at this time, the style guide allows them and they should be
+// left in any fix-it hint.
+static StringRef getReceiverString(SourceRange ReceiverRange,
+   const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  CharSourceRange CharRange = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(ReceiverRange), SM, LangOpts);
+  return Lexer::getSourceText(CharRange, SM, LangOpts);
+}
+
+static FixItHint getCallFixItHint(const ObjCMessageExpr *Expr,
+  const SourceManager &SM,
+  const LangOptions &LangOpts) {
+  // Check whether the messaged class has a known factory method to use instead
+  // of -init.
+  StringRef Receiver =
+  getReceiverString(Expr->getReceiverRange(), SM, LangOpts);
+  // Some classes should use standard factory methods instead of alloc/init.
+  std::map ClassToFactoryMethodMap = {{"NSDate", "date"},
+{"NSNull", 
"null"}};
+  auto FoundClassFactory

[PATCH] D61350: [clang-tidy] New check calling out uses of +new in Objective-C code

2019-05-23 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361487: [clang-tidy] New check calling out uses of +new in 
Objective-C code (authored by gribozavr, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61350?vs=200824&id=200931#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61350

Files:
  clang-tidy/google/AvoidNSObjectNewCheck.cpp
  clang-tidy/google/AvoidNSObjectNewCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-nsobject-new.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-nsobject-new.m

Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/NamespaceCommentCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidNSObjectNewCheck.h"
 #include "AvoidThrowingObjCExceptionCheck.h"
 #include "AvoidUnderscoreInGoogletestNameCheck.h"
 #include "DefaultArgumentsCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-nsobject-new");
 CheckFactories.registerCheck(
 "google-objc-avoid-throwing-exception");
 CheckFactories.registerCheck(
Index: clang-tidy/google/AvoidNSObjectNewCheck.h
===
--- clang-tidy/google/AvoidNSObjectNewCheck.h
+++ clang-tidy/google/AvoidNSObjectNewCheck.h
@@ -0,0 +1,38 @@
+//===--- AvoidNSObjectNewCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_AVOIDNSOBJECTNEWCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_AVOIDNSOBJECTNEWCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+/// This check finds Objective-C code that uses +new to create object instances,
+/// or overrides +new in classes. Both are forbidden by Google's Objective-C
+/// style guide.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/google-avoid-nsobject-new.html
+class AvoidNSObjectNewCheck : public ClangTidyCheck {
+public:
+  AvoidNSObjectNewCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace objc
+} // namespace google
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_AVOIDNSOBJECTNEWCHECK_H
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyGoogleModule
   AvoidCStyleCastsCheck.cpp
+  AvoidNSObjectNewCheck.cpp
   AvoidThrowingObjCExceptionCheck.cpp
   AvoidUnderscoreInGoogletestNameCheck.cpp
   DefaultArgumentsCheck.cpp
Index: clang-tidy/google/AvoidNSObjectNewCheck.cpp
===
--- clang-tidy/google/AvoidNSObjectNewCheck.cpp
+++ clang-tidy/google/AvoidNSObjectNewCheck.cpp
@@ -0,0 +1,130 @@
+//===--- AvoidNSObjectNewCheck.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidNSObjectNewCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+static bool isMessageExpressionInsideMacro(const ObjCMessageExpr *Expr) {
+  SourceLocation ReceiverLocation = Expr->getReceiverRange().getBegin();
+  if (ReceiverLocation.isMacroID())
+return true;
+
+  SourceLocation SelectorLocation = Expr->getSel

[clang-tools-extra] r361488 - [clangd] Also update package-lock.json

2019-05-23 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu May 23 05:02:14 2019
New Revision: 361488

URL: http://llvm.org/viewvc/llvm-project?rev=361488&view=rev
Log:
[clangd] Also update package-lock.json

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json?rev=361488&r1=361487&r2=361488&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package-lock.json Thu 
May 23 05:02:14 2019
@@ -1,6 +1,6 @@
 {
 "name": "vscode-clangd",
-"version": "0.0.12",
+"version": "0.0.13",
 "lockfileVersion": 1,
 "requires": true,
 "dependencies": {


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


clang extra refactor tweaks link patch

2019-05-23 Thread Rudolf Kastl via cfe-commits
A pretty trivial patch to successfully build clang.
--- clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt.old	2019-05-23 06:35:07.247867697 +0200
+++ clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt	2019-05-23 06:35:59.810341911 +0200
@@ -19,4 +19,5 @@
   clangAST
   clangDaemon
   clangToolingCore
+  clangBasic
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:46
+
+  StringRef Message = "no explanation";
+  if (Case.Explanation) {

ymandel wrote:
> ilya-biryukov wrote:
> > ymandel wrote:
> > > ilya-biryukov wrote:
> > > > The users will see this for every case without explanation, right?
> > > > I'd expect the rules without explanation to be somewhat common, maybe 
> > > > don't show any message at all in that case?
> > > There's no option to call `diag()` without a message.  We could pass an 
> > > empty string , but that may be confusing given the way the message is 
> > > concatenated here:
> > > https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp#L204
> > > 
> > > So, no matter what, there will be some message to go w/ the diagnostic. I 
> > > figure that being explicit about the lack of explanation is better than 
> > > an empty string, but don't feel strongly about this.
> > Ah, so all the options are bad. I can see why you had this design in 
> > transformers in the first place.
> > I wonder if we should check the explanations are always set for rewrite 
> > rules inside the clang-tidy transformation?
> > Ah, so all the options are bad. I can see why you had this design in 
> > transformers in the first place.
> Heh. indeed.
> 
> > I wonder if we should check the explanations are always set for rewrite 
> > rules inside the clang-tidy transformation?> Quoted Text
> 
> I would have thought so, but AFAIK, most folks who write one-off 
> transformations use clang-tidy, rather than writing a standalone tool. They 
> just ignore the diagnostics, i gather.  Transformer may shift that somewhat 
> if we improve the experience of writing a (throwaway) standalone tool, but 
> for the time being I think we can't assume that.
> 
We should focus on minimizing maintenance cost for long-term fixes rather than 
one-off transformations. The cost of passing an empty string to a required 
explanation field for one-off transformations is rather small and falls into 
the hands of a person writing the check, the cost of constantly finding and 
fixing the long-lived upstream checks that don't have explanation (leading to 
bad user experience) is high and will probably fall into the hands of 
`clang-tidy` maintainers in addition to people writing the checks.

FWIW, having a new API of top of plain transformers should be better than 
`clang-tidy` for those writing one-off transformations in the long run. I don't 
think `clang-tidy` was ever designed to cover to cover those use-cases, even 
though today it seems to be the fastest way to do those.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61386



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-23 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:46
+
+  StringRef Message = "no explanation";
+  if (Case.Explanation) {

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > ymandel wrote:
> > > > ilya-biryukov wrote:
> > > > > The users will see this for every case without explanation, right?
> > > > > I'd expect the rules without explanation to be somewhat common, maybe 
> > > > > don't show any message at all in that case?
> > > > There's no option to call `diag()` without a message.  We could pass an 
> > > > empty string , but that may be confusing given the way the message is 
> > > > concatenated here:
> > > > https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp#L204
> > > > 
> > > > So, no matter what, there will be some message to go w/ the diagnostic. 
> > > > I figure that being explicit about the lack of explanation is better 
> > > > than an empty string, but don't feel strongly about this.
> > > Ah, so all the options are bad. I can see why you had this design in 
> > > transformers in the first place.
> > > I wonder if we should check the explanations are always set for rewrite 
> > > rules inside the clang-tidy transformation?
> > > Ah, so all the options are bad. I can see why you had this design in 
> > > transformers in the first place.
> > Heh. indeed.
> > 
> > > I wonder if we should check the explanations are always set for rewrite 
> > > rules inside the clang-tidy transformation?> Quoted Text
> > 
> > I would have thought so, but AFAIK, most folks who write one-off 
> > transformations use clang-tidy, rather than writing a standalone tool. They 
> > just ignore the diagnostics, i gather.  Transformer may shift that somewhat 
> > if we improve the experience of writing a (throwaway) standalone tool, but 
> > for the time being I think we can't assume that.
> > 
> We should focus on minimizing maintenance cost for long-term fixes rather 
> than one-off transformations. The cost of passing an empty string to a 
> required explanation field for one-off transformations is rather small and 
> falls into the hands of a person writing the check, the cost of constantly 
> finding and fixing the long-lived upstream checks that don't have explanation 
> (leading to bad user experience) is high and will probably fall into the 
> hands of `clang-tidy` maintainers in addition to people writing the checks.
> 
> FWIW, having a new API of top of plain transformers should be better than 
> `clang-tidy` for those writing one-off transformations in the long run. I 
> don't think `clang-tidy` was ever designed to cover to cover those use-cases, 
> even though today it seems to be the fastest way to do those.
Agreed on all points. I'll send a followup that enforces that constraint.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61386



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


Re: clang extra refactor tweaks link patch

2019-05-23 Thread Roman Lebedev via cfe-commits
It might be best to submit the patch to phabricator so it does not get lost.
https://llvm.org/docs/Phabricator.html

On Thu, May 23, 2019 at 3:13 PM Rudolf Kastl via cfe-commits
 wrote:
>
> A pretty trivial patch to successfully build clang.
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62303: [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous.
Herald added a project: clang.

See the added test for an example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62303

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexTypeSourceInfo.cpp


Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,43 @@
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
+  void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+   SourceLocation TemplNameLoc,
+   CXXRecordDecl *ResolvedClass,
+   bool IsTypeAlias) {
+if (ResolvedClass) {
+  // In presence of type aliases, the resolved class was never written in
+  // the code so don't report it.
+  if (!IsTypeAlias && (!ResolvedClass->isImplicit() ||
+   IndexCtx.shouldIndexImplicitInstantiation())) {
+IndexCtx.handleReference(ResolvedClass, TemplNameLoc, Parent, ParentDC,
  SymbolRoleSet(), Relations);
+return;
+  }
 }
-return true;
+if (const TemplateDecl *D = TemplName.getAsTemplateDecl())
+  IndexCtx.handleReference(D, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
   }
 
   bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+T->isTypeAlias());
+return true;
   }
 
   bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+/*IsTypeAlias=*/false);
+return true;
   }
 
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -497,6 +497,17 @@
   ElementsAre(Sym("Foo"), Sym("Foo")));
 }
 
+TEST(LocateSymbol, TemplateTypedefs) {
+  auto T = Annotations(R"cpp(
+template  struct function {};
+template  using callback = function;
+
+c^allback foo;
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  EXPECT_THAT(locateSymbolAt(AST, T.point()), ElementsAre(Sym("callback")));
+}
+
 TEST(LocateSymbol, RelPathsInCompileCommand) {
   // The source is in "/clangd-test/src".
   // We build in "/clangd-test/build".


Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,43 @@
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
+  void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+   SourceLocation TemplNameLoc,
+   CXXRecordDecl *ResolvedClass,
+   bool IsTypeAlias) {
+if (ResolvedClass) {
+  // In presence of type aliases, the resolved class was never writte

Re: [PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-23 Thread Ilya Biryukov via cfe-commits
Maybe go with a runtime parameter (of type llvm::function_ref) instead of
the template parameter?
In any non-trivial example, the runtime costs of another function pointer
should be negligible given that we need to parse the ASTs, run the
matchers, etc.

On Wed, May 22, 2019 at 10:48 PM Penzin, Petr  wrote:

> It does not like some part of that instantiation, I am not sure which one
> yet. Let’s see what I can do about it.
>
>
>
> -Petr
>
>
>
> *From:* Yitzhak Mandelbaum [mailto:yitzh...@google.com]
> *Sent:* Wednesday, May 22, 2019 1:37 PM
> *To:* reviews+d61774+public+f458bb6144ae8...@reviews.llvm.org
> *Cc:* Ilya Biryukov ; Penzin, Petr <
> petr.pen...@intel.com>; llvm-comm...@lists.llvm.org; Michał Górny <
> mgo...@gentoo.org>; cfe-commits ; Theko
> Lekena ; Nicolas Lesser ;
> Han Shen 
> *Subject:* Re: [PATCH] D61774: [LibTooling] Add RangeSelector library for
> defining source ranges based on bound AST nodes.
>
>
>
> I'm confused by the error given that getStatementsRange is a function
> name.  I don't have Visual Studio -- can you find a fix and send a patch? I
> wonder if taking the address explicitly is enough?  Or, if you know how to
> trigger this error in clang or gcc, I can fix it myself.
>
>
>
> On Wed, May 22, 2019 at 4:31 PM Petr Penzin via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
> penzn added inline comments.
>
>
> 
> Comment at: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp:229
> +RangeSelector tooling::statements(StringRef ID) {
> +  return RelativeSelector(ID);
> +}
> 
> Sorry for posting here, haven't gotten my bugzilla access yet (requested
> though).
>
> This breaks with Visual Studio 2017 (15.7.6):
>
> RangeSelector.cpp(229): error C2971:
> '`anonymous-namespace'::RelativeSelector': template parameter 'Func':
> 'getStatementsRange': a variable with non-static storage duration cannot be
> used as a non-type argument
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D61774/new/
>
> https://reviews.llvm.org/D61774
>
>
>

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


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200943.
djtodoro added a comment.

-Add a negative test for -O0


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

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,19 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
+// Unsupported: -O0 + '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O0 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=NO-ATTR
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,8 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  if (Opts.OptimizationLevel > 0)
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTai

[PATCH] D48961: [Index] Add indexing support for MACROs.

2019-05-23 Thread Marco Bubke via Phabricator via cfe-commits
marcobubke added a comment.
Herald added a subscriber: dexonsmith.
Herald added a project: clang.

This changset is not handling #ifdef MACRO, defined(MACRO) etc. in he 
PPCallbacks. Is there any intention to omit them or do you simply forgot them?


Repository:
  rC Clang

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

https://reviews.llvm.org/D48961



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


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200950.
djtodoro added a comment.

-Add `SPDefCache` to speed up the process
-Add additional assertions that will improve quality of the code


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

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,10 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  /// Cache function definitions relevant to use for parameters mutation
+  /// analysis.
+  llvm::DenseMap SPDefCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPDefCache only in the case when the debug entry values option
+  // is set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPDefCache[cast(D)].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3880,6 +3887,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4454,6 +4466,29 @@
   TheCU->setDWOId(Signature);
 }
 
+/// Analyzes each function parameter to determine whether it is constant
+/// throughout the function body.
+static void analyzeParametersModification(
+ASTContext &Ctx,
+llvm::DenseMap &SPDefCache,
+llvm::DenseMap &ParamCache) {
+  for (auto &SP : SPDefCache) {
+auto *FD = SP.first;
+assert(FD->hasBody() && "Functions must have body here");
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
+  if (FuncAnalyzer.isMutated(Parm))
+continue;
+
+  auto I = ParamCache.find(Parm);
+  assert(I != ParamCache.end() && "Parameters should be already cached");
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+
 void CGDebugInfo::finalize() {
   // Creating types might create further types - invalidating the current
   // element and the size(), so don't cache/reference them.
@@ -4526,6 +4561,10 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
+// This will be used to emit debug entry values.
+analyzeParametersModification(CGM.getContext(), SPDefCache, ParamCache);
+
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,10 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  /// Cache function definitions relevant to use for parameters mutation
+  /// analysis.
+  llvm::DenseMap SPDefCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPDefCache only in the case when the debug entry values option
+  // is set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPDefCache[cast(D)].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitte

Re: clang extra refactor tweaks link patch

2019-05-23 Thread Rudolf Kastl via cfe-commits
did: https://reviews.llvm.org/D62309

Am Do., 23. Mai 2019 um 14:44 Uhr schrieb Roman Lebedev :
>
> It might be best to submit the patch to phabricator so it does not get lost.
> https://llvm.org/docs/Phabricator.html
>
> On Thu, May 23, 2019 at 3:13 PM Rudolf Kastl via cfe-commits
>  wrote:
> >
> > A pretty trivial patch to successfully build clang.
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3154
+/// The result contains only 'typed text' and 'text' chunks.
+static void PrintOverrideString(const CodeCompletionString &CCS,
+CodeCompletionBuilder &Result) {

change name to `printOverrideString`



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3166
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);

I believe it is sensible to make resulttype a typed text as well, because 
people might start typing the function signature instead of name if they are 
not familiar with the feature



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3182
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTextChunk("override");
   return Result.TakeString();

I believe we should  make `override` a typed text as well.



Comment at: clang/test/CodeCompletion/overrides.cpp:23
 //
-// Runs completion at vo^id.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
+// Runs completion at v^oid.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:4 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s

either restore this to original version(if we decide to make return type a 
typed_text as well) or get rid of the void keyword completely and only keep 
`v`? because at first sight it looks like we are triggering on return type :D



Comment at: clang/test/CodeCompletion/overrides.cpp:26
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}

why move this ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62309: Fix linking of the refactor tweaks directory

2019-05-23 Thread Rudolf Kastl via Phabricator via cfe-commits
che666 created this revision.
che666 added a reviewer: clang-tools-extra.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, 
ilya-biryukov, mgorny.
Herald added a project: clang.

Currently it seems that the linked libs in CMakelists for the refactor tweaks 
directory is incomplete leading to:

FAILED: lib64/libclangDaemonTweaks.so.9svn 
: && /usr/bin/c++ -fPIC -O2 -g -pipe -Wall -Werror=format-security 
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions 
-fstack-protector-strong -grecord-gcc-switches 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic 
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC 
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -pedantic -Wno-long-long -O2 -g -DNDEBUG  -Wl,-z,relro 
-Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld 
-Wl,-z,defs -Wl,-z,nodelete   
-Wl,-rpath-link,/builddir/build/BUILD/clang-r361395/_build/./lib64  -Wl,-O3 
-Wl,--gc-sections -shared -Wl,-soname,libclangDaemonTweaks.so.9svn -o 
lib64/libclangDaemonTweaks.so.9svn 
tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RawStringLiteral.cpp.o
 
tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o
  lib64/libclangAST.so.9svn lib64/libclangDaemon.so.9svn 
lib64/libclangToolingCore.so.9svn /usr/lib64/libLLVM-9svn.so && :
/usr/bin/ld: 
tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RawStringLiteral.cpp.o:
 in function `clang::clangd::(anonymous 
namespace)::RawStringLiteral::prepare(clang::clangd::Tweak::Selection const&)':
/builddir/build/BUILD/clang-r361395/_build/../tools/extra/clangd/refactor/tweaks/RawStringLiteral.cpp:60:
 undefined reference to 
`clang::SourceManager::isBeforeInTranslationUnit(clang::SourceLocation, 
clang::SourceLocation) const'
/usr/bin/ld: 
/builddir/build/BUILD/clang-r361395/_build/../tools/extra/clangd/refactor/tweaks/RawStringLiteral.cpp:64:
 undefined reference to 
`clang::SourceManager::getCharacterData(clang::SourceLocation, bool*) const'
collect2: error: ld returned 1 exit status

The above patch fixes the problem.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D62309

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


Index: clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -19,4 +19,5 @@
   clangAST
   clangDaemon
   clangToolingCore
+  clangBasic
   )


Index: clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-r361395/tools/extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -19,4 +19,5 @@
   clangAST
   clangDaemon
   clangToolingCore
+  clangBasic
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62309: Fix linking of the refactor tweaks directory

2019-05-23 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.

Thank you!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62309



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


[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-05-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Tests?




Comment at: lib/CodeGen/CGOpenMPRuntime.h:1628
+  /// Return whether the unified_shared_memory has been specified.
+  virtual bool hasRequiresUnifiedSharedMemory();
 };

Do we need to make it virtual?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3166
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);

kadircet wrote:
> I believe it is sensible to make resulttype a typed text as well, because 
> people might start typing the function signature instead of name if they are 
> not familiar with the feature
Yeah, I can see why that looks appealing (return type is the prefix of 
completion item, so it feels most natural to type it), but that's exactly what 
renders the fuzzy match scores unreliable. Other items are matched by name, so 
to give the match scores a meaningful interpretation across different 
completion items we should match by name whenever we can.

Reasons why it felt like matching names instead of return types is better:
1) some return types are incredibly common, e.g. `bool` and `void`. If they are 
part of the typed text, the users can either (1) type `void` or `bool` and get 
too many results (tried that in `PPCallbacks` descendants) or (2) type the 
function name and get the override completions will be penalized because the 
name of the function is too far away in the text we try to match.
2) it feels like remembering names of functions you want to override is more 
common than remembering return types of functions you to override.




Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3182
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTextChunk("override");
   return Result.TakeString();

kadircet wrote:
> I believe we should  make `override` a typed text as well.
Agree that would be nice and I actually tried it. But it didn't work: we can 
only have one typed text chunk, e.g. `clangd` will break if there are more than 
one and maybe other tools have this assumption too.

Would be nice to allow this (by fixing the code to not have this assumption, I 
guess), but I'd avoid doing this in this patch. Should I add a FIXME?



Comment at: clang/test/CodeCompletion/overrides.cpp:26
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}

kadircet wrote:
> why move this ?
Order matters for `-NOT` matches and I believe it was wrong before (given 
checks marked with `CHECK-CC1`)

E.g. 
```
// CHECK: a
// CHECK-NOT: b
```
will match without error against 
```
b
a
```
and give an error on
```
b
a
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62309: Fix linking of the refactor tweaks directory

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.

Thanks for the fix! A few nit-picky comments about the process, in case you'll 
be interested in sending more patches to LLVM.

Could you please upload the patch with full context and based on the upstream 
monorepo or svn repo (see instructions here 
)?
The current patch mentions `clang-r361395` directory, it should normally be 
stripped.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62309



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-23 Thread Pierre via Phabricator via cfe-commits
Pierre updated this revision to Diff 200961.
Pierre marked 4 inline comments as done.

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

https://reviews.llvm.org/D60763

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/OpenCLBuiltins.td
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/builtin-new.cl
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -80,6 +80,7 @@
 void EmitTestPragmaAttributeSupportedAttributes(llvm::RecordKeeper &Records,
 llvm::raw_ostream &OS);
 
+void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 } // end namespace clang
 
 #endif
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -61,7 +61,8 @@
   GenDiagDocs,
   GenOptDocs,
   GenDataCollectors,
-  GenTestPragmaAttributeSupportedAttributes
+  GenTestPragmaAttributeSupportedAttributes,
+  GenClangOpenCLBuiltins,
 };
 
 namespace {
@@ -163,7 +164,9 @@
 clEnumValN(GenTestPragmaAttributeSupportedAttributes,
"gen-clang-test-pragma-attribute-supported-attributes",
"Generate a list of attributes supported by #pragma clang "
-   "attribute for testing purposes")));
+   "attribute for testing purposes"),
+clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
+   "Generate OpenCL builtin handlers")));
 
 cl::opt
 ClangComponent("clang-component",
@@ -293,6 +296,9 @@
   case GenTestPragmaAttributeSupportedAttributes:
 EmitTestPragmaAttributeSupportedAttributes(Records, OS);
 break;
+  case GenClangOpenCLBuiltins:
+EmitClangOpenCLBuiltins(Records, OS);
+break;
   }
 
   return false;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- /dev/null
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -0,0 +1,325 @@
+//===- ClangOpenCLBuiltinEmitter.cpp - Generate Clang OpenCL Builtin handling
+//=-*- C++ -*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This tablegen backend emits code allowing to check whether a function
+// belongs to OpenCL builtin functions. In the following case, all overloads
+// of this function are added to the LookupResult.
+// The code is generated in "OpenCLBuiltins.inc" and included by Clang
+// SemaLookup.cpp
+//
+// The resolution of a function name and its overload is follwing these steps:
+// for the function "cos", which has the overloads:
+//- float   cos(float)
+//- double  cos(double)
+//
+// 1-  = isOpenCLBuiltin("cos")
+// 2- OpenCLBuiltins[Index - Index + Len] contains the pairs
+//   of the overloads of "cos".
+// 3- OpenCLSignature[SignatureIndex, SignatureIndex + SignatureLen] contains
+//  one of the signaures of "cos". This OpenCLSignature table can be
+//  referenced by other functions, i.e. "sin", since multiple functions
+//  can have the same signature.
+//===--===//
+
+#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
+#include 
+
+using namespace llvm;
+
+namespace {
+class BuiltinNameEmitter {
+public:
+  BuiltinNameEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions/ structures allowing to check
+  // whether a function is part of OpenCL builtin functions.
+  void Emit();
+
+private:
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+  // The output file we are writing to.
+  raw_ostream &OS;

[PATCH] D62312: [ASTImporter] Added visibility context check for CXXRecordDecl.

2019-05-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

ASTImporter makes now difference between classes with same name in different
translation units if these are not visible outside. These classes are not linked
into one decl chain.


Repository:
  rC Clang

https://reviews.llvm.org/D62312

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterVisibilityTest.cpp

Index: unittests/AST/ASTImporterVisibilityTest.cpp
===
--- unittests/AST/ASTImporterVisibilityTest.cpp
+++ unittests/AST/ASTImporterVisibilityTest.cpp
@@ -31,6 +31,10 @@
   using DeclTy = VarDecl;
   BindableMatcher operator()() { return varDecl(hasName("v")); }
 };
+struct GetClassPattern {
+  using DeclTy = CXXRecordDecl;
+  BindableMatcher operator()() { return cxxRecordDecl(hasName("X")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -41,6 +45,9 @@
 const auto *ExternV = "extern int v;";
 const auto *StaticV = "static int v;";
 const auto *AnonV = "namespace { extern int v; }";
+// CXXRecordDecl:
+auto *ExternC = "class X;";
+auto *AnonC = "namespace { class X; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -84,14 +91,19 @@
 // Manual instantiation of the fixture with each type.
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
-// Value-parameterized test for the first type.
+using ImportClassesVisibilityChain = ImportVisibilityChain;
+// Value-parameterized test for functions.
 TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
-// Value-parameterized test for the second type.
+// Value-parameterized test for variables.
 TEST_P(ImportVariablesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for classes.
+TEST_P(ImportClassesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 
 // Automatic instantiation of the value-parameterized tests.
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
@@ -110,6 +122,11 @@
 // provided but they must have the same linkage.  See also the test
 // ImportVariableChainInC which test for this special C Lang case.
 ::testing::Values(ExternV, AnonV)), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportClassesVisibilityChain,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(ExternC, AnonC)), );
 
 // First value in tuple: Compile options.
 // Second value in tuple: Tuple with informations for the test.
@@ -169,6 +186,7 @@
 };
 using ImportFunctionsVisibility = ImportVisibility;
 using ImportVariablesVisibility = ImportVisibility;
+using ImportClassesVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -184,6 +202,13 @@
 TEST_P(ImportVariablesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// CXXRecordDecl.
+TEST_P(ImportClassesVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportClassesVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -214,6 +239,14 @@
   std::make_tuple(AnonV, ExternV, ExpectNotLink),
   std::make_tuple(AnonV, StaticV, ExpectNotLink),
   std::make_tuple(AnonV, AnonV, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportClassesVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(std::make_tuple(ExternC, ExternC, ExpectLink),
+  std::make_tuple(ExternC, AnonC, ExpectNotLink),
+  std::make_tuple(AnonC, ExternC, ExpectNotLink),
+  std::make_tuple(AnonC, AnonC, ExpectNotLink))), );
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2559,6 +2559,9 @@
   if (!IsStructuralMatch(D, FoundRecord, false))
 continue;
 
+if (!hasSameVisibilityContext(FoundRecord, D))
+  continue;
+
 if (IsStructuralMatch(D, FoundRecord)) {
   RecordDecl *FoundDef = FoundRecord->getDefinition();
   if (D->isThisDeclarationADefinition() && FoundDef) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62303: [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang/lib/Index/IndexTypeSourceInfo.cpp:140
+   bool IsTypeAlias) {
+if (ResolvedClass) {
+  // In presence of type aliases, the resolved class was never written in

why not merge with next condition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62303



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


[PATCH] D59253: [AIX][libcxx] AIX system headers need stdint.h and inttypes.h to be re-enterable when macro _STD_TYPES_T is defined

2019-05-23 Thread Xing Xue via Phabricator via cfe-commits
xingxue updated this revision to Diff 200967.
xingxue added a comment.
Herald added subscribers: jsji, jfb.

Added test case `stdint_h.sh.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59253

Files:
  clang/lib/Headers/inttypes.h
  clang/lib/Headers/stdint.h
  libcxx/include/inttypes.h
  libcxx/include/stdint.h
  libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp

Index: libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp
===
--- /dev/null
+++ libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp
@@ -0,0 +1,268 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// AIX system headers need stdint.h to be re-enterable when macro _STD_TYPES_T
+// is defined. This test case tests that after including sys/types.h which
+// defines macro _STD_TYPES_T, includes stdint.h, and then undefines
+// _STD_TYPES_T, stdint.h can be entered to get to macros like UINT32_MAX.
+//
+// REQUIRES: aix
+// RUN: %compile -c
+// RUN: %compile -c -D_XOPEN_SOURCE=700
+
+// test 
+//
+// Test that limits macros are available when  is included with
+// or without macro _XOPEN_SOUECE=700.
+
+#include 
+#include 
+
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined
+#endif
+
+#ifndef INT_FAST16_MIN
+#error INT_FAST16_MIN not defined
+#endif
+
+#ifndef INT_FAST32_MIN
+#error INT_FAST32_MIN not defined
+#endif
+
+#ifndef INT_FAST64_MIN
+#error INT_FAST64_MIN not defined
+#endif
+
+#ifndef INT_FAST8_MAX
+#error INT_FAST8_MAX not defined
+#endif
+
+#ifndef INT_FAST16_MAX
+#error INT_FAST16_MAX not defined
+#endif
+
+#ifndef INT_FAST32_MAX
+#error INT_FAST32_MAX not defined
+#endif
+
+#ifndef INT_FAST64_MAX
+#error INT_FAST64_MAX not defined
+#endif
+
+#ifndef UINT_FAST8_MAX
+#error UINT_FAST8_MAX not defined
+#endif
+
+#ifndef UINT_FAST16_MAX
+#error UINT_FAST16_MAX not defined
+#endif
+
+#ifndef UINT_FAST32_MAX
+#error UINT_FAST32_MAX not defined
+#endif
+
+#ifndef UINT_FAST64_MAX
+#error UINT_FAST64_MAX not defined
+#endif
+
+#ifndef INTPTR_MIN
+#error INTPTR_MIN not defined
+#endif
+
+#ifndef INTPTR_MAX
+#error INTPTR_MAX not defined
+#endif
+
+#ifndef UINTPTR_MAX
+#error UINTPTR_MAX not defined
+#endif
+
+#ifndef INTMAX_MIN
+#error INTMAX_MIN not defined
+#endif
+
+#ifndef INTMAX_MAX
+#error INTMAX_MAX not defined
+#endif
+
+#ifndef UINTMAX_MAX
+#error UINTMAX_MAX not defined
+#endif
+
+#ifndef PTRDIFF_MIN
+#error PTRDIFF_MIN not defined
+#endif
+
+#ifndef PTRDIFF_MAX
+#error PTRDIFF_MAX not defined
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#error SIG_ATOMIC_MIN not defined
+#endif
+
+#ifndef SIG_ATOMIC_MAX
+#error SIG_ATOMIC_MAX not defined
+#endif
+
+#ifndef SIZE_MAX
+#error SIZE_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WINT_MIN
+#error WINT_MIN not defined
+#endif
+
+#ifndef WINT_MAX
+#error WINT_MAX not defined
+#endif
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not define

[PATCH] D62201: [LibTooling] Address post-commit feedback for r361152

2019-05-23 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

I think this build broke the `-DLLVM_BUILD_LLVM_DYLIB=ON 
-DLLVM_LINK_LLVM_DYLIB=ON` build. e.g 
https://ci.chromium.org/p/wasm/builders/ci/linux/6457

  FAILED: tools/clang/unittests/Tooling/ToolingTests 
  : && 
/b/swarming/w/ir/cache/builder/src/src/work/v8/v8/third_party/llvm-build/Release+Asserts/bin/clang++
   -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections 
-fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3  
-Wl,-allow-shlib-undefined-Wl,-O3 -Wl,--gc-sections 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ASTSelectionTest.cpp.o
 tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CastExprTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CompilationDatabaseTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/DiagnosticsYamlTest.cpp.o
 tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/FixItTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/HeaderIncludesTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LexicallyOrderedRecursiveASTVisitorTest.cpp.o
 tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LookupTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/QualTypeNamesTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RangeSelectorTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Attr.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Class.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ConstructExpr.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXMemberCall.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/DeclRefExpr.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ImplicitCtor.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPostOrder.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPreOrder.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/IntegerLiteral.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/LambdaExpr.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ParenExpr.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/TraversalScope.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestDeclVisitor.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestPostOrderVisitor.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestTypeLocVisitor.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RefactoringActionRulesTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RefactoringCallbacksTest.cpp.o
 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RefactoringTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ReplacementsYamlTest.cpp.o
 tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RewriterTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/SourceCodeTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/StencilTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ToolingTest.cpp.o 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/TransformerTest.cpp.o 
 

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Summarizing the offline discussion, the final results we want in the long run 
is a completion item of the form:

- Displayed to the user: `override foo(int a, int b)`
- Inserted into the editor: `return_type foo(int a, int b) override`
- Filtered by `override foo` (that allows to filter with `override` or `foo`, 
giving reasonably good ranking)

It's **almost** possible to achieve this with the current abstractions, but we 
don't have completion string chunks that are printed but not shown to the user 
(we need those for `return_type` and `override` at the of the completion label).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D59628: Add support for __attribute__((objc_class_stub))

2019-05-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: clang/include/clang/Basic/Attr.td:297
 def CUDA : LangOpt<"CUDA">;
-def COnly : LangOpt<"CPlusPlus", 1>;
+def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
 def CPlusPlus : LangOpt<"CPlusPlus">;

This compiles? I would have assumed that it would have to be `def COnly : 
LangOpt<"COnly", [{!LangOpts.CPlusPlus}]>;`

(If it compiles as-is, that's fine, I just wasn't aware that you could use 
string syntax for code blocks.)


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

https://reviews.llvm.org/D59628



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


[PATCH] D62320: Fix LLVM_LINK_LLVM_DYLIB build after rC361285

2019-05-23 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, aheejin, mgorny.
Herald added a project: clang.

All the other unittests I can find specify LLVMTestingSupport in
target_link_libraries not as part of LLVM_LINK_COMPONENTS.

I'm how/why this fixes the build issue, but its consistent with
other uses.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62320

Files:
  clang/unittests/Tooling/CMakeLists.txt


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
-  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
@@ -71,6 +70,7 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactor
+  LLVMTestingSupport
   )
 
 


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
-  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
@@ -71,6 +70,7 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactor
+  LLVMTestingSupport
   )
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62320: Fix LLVM_LINK_LLVM_DYLIB build after rC361285

2019-05-23 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this. Might want to wait for Nico's response, though, since 
the original change was at his suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62320



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


r361502 - Work around a Visual C++ bug.

2019-05-23 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu May 23 08:07:46 2019
New Revision: 361502

URL: http://llvm.org/viewvc/llvm-project?rev=361502&view=rev
Log:
Work around a Visual C++ bug.

Using a static function as a template parameter gets a bogus compile-time
error with Visual Studio 2017, prior to version 15.8. Our current
minimum-version requirement is a particular update to VS2015, and we
assume all Visual Studio 2017 versions are usable. This patch makes the
code buildable with older versions of VS2017, and can be reverted after
we upgrade the minimum version sometime in the future.

Description of the Microsoft bug:
https://developercommunity.visualstudio.com/content/problem/25334/error-code-c2971-when-specifying-a-function-as-the.html

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

Modified:
cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp?rev=361502&r1=361501&r2=361502&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp Thu May 23 08:07:46 2019
@@ -218,37 +218,47 @@ public:
 };
 } // namespace
 
+// FIXME: Change the following functions from being in an anonymous namespace
+// to static functions, after the minimum Visual C++ has _MSC_VER >= 1915
+// (equivalent to Visual Studio 2017 v15.8 or higher). Using the anonymous
+// namespace works around a bug in earlier versions.
+namespace {
 // Returns the range of the statements (all source between the braces).
-static CharSourceRange getStatementsRange(const MatchResult &,
-  const CompoundStmt &CS) {
+CharSourceRange getStatementsRange(const MatchResult &,
+   const CompoundStmt &CS) {
   return CharSourceRange::getCharRange(CS.getLBracLoc().getLocWithOffset(1),
CS.getRBracLoc());
 }
+} // namespace
 
 RangeSelector tooling::statements(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the source between the call's parentheses.
-static CharSourceRange getCallArgumentsRange(const MatchResult &Result,
- const CallExpr &CE) {
+CharSourceRange getCallArgumentsRange(const MatchResult &Result,
+  const CallExpr &CE) {
   return CharSourceRange::getCharRange(
   findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts())
   .getLocWithOffset(1),
   CE.getRParenLoc());
 }
+} // namespace
 
 RangeSelector tooling::callArgs(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the elements of the initializer list. Includes all
 // source between the braces.
-static CharSourceRange getElementsRange(const MatchResult &,
-const InitListExpr &E) {
+CharSourceRange getElementsRange(const MatchResult &,
+ const InitListExpr &E) {
   return CharSourceRange::getCharRange(E.getLBraceLoc().getLocWithOffset(1),
E.getRBraceLoc());
 }
+} // namespace
 
 RangeSelector tooling::initListElements(StringRef ID) {
   return RelativeSelector(ID);


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


Re: [PATCH] D62201: [LibTooling] Address post-commit feedback for r361152

2019-05-23 Thread Yitzhak Mandelbaum via cfe-commits
Fixed in https://reviews.llvm.org/D62320

On Thu, May 23, 2019 at 10:44 AM Sam Clegg via Phabricator <
revi...@reviews.llvm.org> wrote:

> sbc100 added a comment.
>
> I think this build broke the `-DLLVM_BUILD_LLVM_DYLIB=ON
> -DLLVM_LINK_LLVM_DYLIB=ON` build. e.g
> https://ci.chromium.org/p/wasm/builders/ci/linux/6457
>
>   FAILED: tools/clang/unittests/Tooling/ToolingTests
>   : &&
> /b/swarming/w/ir/cache/builder/src/src/work/v8/v8/third_party/llvm-build/Release+Asserts/bin/clang++
>  -fPIC -fvisibility-inlines-hidden -Werror=date-time
> -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual
> -Wmissing-field-initializers -pedantic -Wno-long-long
> -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type
> -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion
> -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common
> -Woverloaded-virtual -Wno-nested-anon-types -O3
> -Wl,-allow-shlib-undefined-Wl,-O3 -Wl,--gc-sections
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ASTSelectionTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CastExprTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CompilationDatabaseTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/DiagnosticsYamlTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/FixItTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/HeaderIncludesTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LexicallyOrderedRecursiveASTVisitorTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LookupTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/QualTypeNamesTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RangeSelectorTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Attr.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Class.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ConstructExpr.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXMemberCall.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/DeclRefExpr.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ImplicitCtor.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPostOrder.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPreOrder.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/IntegerLiteral.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/LambdaExpr.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ParenExpr.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/TraversalScope.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestDeclVisitor.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestPostOrderVisitor.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestTypeLocVisitor.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RefactoringActionRulesTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RefactoringCallbacksTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RefactoringTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ReplacementsYamlTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RewriterTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/SourceCodeTest.cpp.o
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/StencilTe

Re: [PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-23 Thread Yitzhak Mandelbaum via cfe-commits
Sounds good. I'll send a fix shortly. Found another bug too (captured a
StringRef in a lambda) -- shall i bundle the fixes?

On Thu, May 23, 2019 at 9:01 AM Ilya Biryukov  wrote:

> Maybe go with a runtime parameter (of type llvm::function_ref) instead of
> the template parameter?
> In any non-trivial example, the runtime costs of another function pointer
> should be negligible given that we need to parse the ASTs, run the
> matchers, etc.
>
> On Wed, May 22, 2019 at 10:48 PM Penzin, Petr 
> wrote:
>
>> It does not like some part of that instantiation, I am not sure which one
>> yet. Let’s see what I can do about it.
>>
>>
>>
>> -Petr
>>
>>
>>
>> *From:* Yitzhak Mandelbaum [mailto:yitzh...@google.com]
>> *Sent:* Wednesday, May 22, 2019 1:37 PM
>> *To:* reviews+d61774+public+f458bb6144ae8...@reviews.llvm.org
>> *Cc:* Ilya Biryukov ; Penzin, Petr <
>> petr.pen...@intel.com>; llvm-comm...@lists.llvm.org; Michał Górny <
>> mgo...@gentoo.org>; cfe-commits ; Theko
>> Lekena ; Nicolas Lesser ;
>> Han Shen 
>> *Subject:* Re: [PATCH] D61774: [LibTooling] Add RangeSelector library
>> for defining source ranges based on bound AST nodes.
>>
>>
>>
>> I'm confused by the error given that getStatementsRange is a function
>> name.  I don't have Visual Studio -- can you find a fix and send a patch? I
>> wonder if taking the address explicitly is enough?  Or, if you know how to
>> trigger this error in clang or gcc, I can fix it myself.
>>
>>
>>
>> On Wed, May 22, 2019 at 4:31 PM Petr Penzin via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>> penzn added inline comments.
>>
>>
>> 
>> Comment at: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp:229
>> +RangeSelector tooling::statements(StringRef ID) {
>> +  return RelativeSelector(ID);
>> +}
>> 
>> Sorry for posting here, haven't gotten my bugzilla access yet (requested
>> though).
>>
>> This breaks with Visual Studio 2017 (15.7.6):
>>
>> RangeSelector.cpp(229): error C2971:
>> '`anonymous-namespace'::RelativeSelector': template parameter 'Func':
>> 'getStatementsRange': a variable with non-static storage duration cannot be
>> used as a non-type argument
>>
>>
>> Repository:
>>   rL LLVM
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D61774/new/
>>
>> https://reviews.llvm.org/D61774
>>
>>
>>
>
> --
> Regards,
> Ilya Biryukov
>


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


[PATCH] D62202: Work around a Visual C++ bug

2019-05-23 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361502: Work around a Visual C++ bug. (authored by 
probinson, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62202?vs=200516&id=200978#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62202

Files:
  cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp


Index: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -218,37 +218,47 @@
 };
 } // namespace
 
+// FIXME: Change the following functions from being in an anonymous namespace
+// to static functions, after the minimum Visual C++ has _MSC_VER >= 1915
+// (equivalent to Visual Studio 2017 v15.8 or higher). Using the anonymous
+// namespace works around a bug in earlier versions.
+namespace {
 // Returns the range of the statements (all source between the braces).
-static CharSourceRange getStatementsRange(const MatchResult &,
-  const CompoundStmt &CS) {
+CharSourceRange getStatementsRange(const MatchResult &,
+   const CompoundStmt &CS) {
   return CharSourceRange::getCharRange(CS.getLBracLoc().getLocWithOffset(1),
CS.getRBracLoc());
 }
+} // namespace
 
 RangeSelector tooling::statements(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the source between the call's parentheses.
-static CharSourceRange getCallArgumentsRange(const MatchResult &Result,
- const CallExpr &CE) {
+CharSourceRange getCallArgumentsRange(const MatchResult &Result,
+  const CallExpr &CE) {
   return CharSourceRange::getCharRange(
   findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts())
   .getLocWithOffset(1),
   CE.getRParenLoc());
 }
+} // namespace
 
 RangeSelector tooling::callArgs(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the elements of the initializer list. Includes all
 // source between the braces.
-static CharSourceRange getElementsRange(const MatchResult &,
-const InitListExpr &E) {
+CharSourceRange getElementsRange(const MatchResult &,
+ const InitListExpr &E) {
   return CharSourceRange::getCharRange(E.getLBraceLoc().getLocWithOffset(1),
E.getRBraceLoc());
 }
+} // namespace
 
 RangeSelector tooling::initListElements(StringRef ID) {
   return RelativeSelector(ID);


Index: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -218,37 +218,47 @@
 };
 } // namespace
 
+// FIXME: Change the following functions from being in an anonymous namespace
+// to static functions, after the minimum Visual C++ has _MSC_VER >= 1915
+// (equivalent to Visual Studio 2017 v15.8 or higher). Using the anonymous
+// namespace works around a bug in earlier versions.
+namespace {
 // Returns the range of the statements (all source between the braces).
-static CharSourceRange getStatementsRange(const MatchResult &,
-  const CompoundStmt &CS) {
+CharSourceRange getStatementsRange(const MatchResult &,
+   const CompoundStmt &CS) {
   return CharSourceRange::getCharRange(CS.getLBracLoc().getLocWithOffset(1),
CS.getRBracLoc());
 }
+} // namespace
 
 RangeSelector tooling::statements(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the source between the call's parentheses.
-static CharSourceRange getCallArgumentsRange(const MatchResult &Result,
- const CallExpr &CE) {
+CharSourceRange getCallArgumentsRange(const MatchResult &Result,
+  const CallExpr &CE) {
   return CharSourceRange::getCharRange(
   findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts())
   .getLocWithOffset(1),
   CE.getRParenLoc());
 }
+} // namespace
 
 RangeSelector tooling::callArgs(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the elements of the initializer list. Includes all
 // source between the braces.
-static CharSourceRange getElementsRange(const MatchResult &,
-const InitListExpr &E) {
+CharSourceRange getElementsRange(const MatchResult &

Re: [PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-23 Thread Yitzhak Mandelbaum via cfe-commits
Given that we'll need to store the function reference, is
llvm::function_ref still the way to go? The comments seem to warn away from
storing function_refs.

On Thu, May 23, 2019 at 11:06 AM Yitzhak Mandelbaum 
wrote:

> Sounds good. I'll send a fix shortly. Found another bug too (captured a
> StringRef in a lambda) -- shall i bundle the fixes?
>
> On Thu, May 23, 2019 at 9:01 AM Ilya Biryukov 
> wrote:
>
>> Maybe go with a runtime parameter (of type llvm::function_ref) instead of
>> the template parameter?
>> In any non-trivial example, the runtime costs of another function pointer
>> should be negligible given that we need to parse the ASTs, run the
>> matchers, etc.
>>
>> On Wed, May 22, 2019 at 10:48 PM Penzin, Petr 
>> wrote:
>>
>>> It does not like some part of that instantiation, I am not sure which
>>> one yet. Let’s see what I can do about it.
>>>
>>>
>>>
>>> -Petr
>>>
>>>
>>>
>>> *From:* Yitzhak Mandelbaum [mailto:yitzh...@google.com]
>>> *Sent:* Wednesday, May 22, 2019 1:37 PM
>>> *To:* reviews+d61774+public+f458bb6144ae8...@reviews.llvm.org
>>> *Cc:* Ilya Biryukov ; Penzin, Petr <
>>> petr.pen...@intel.com>; llvm-comm...@lists.llvm.org; Michał Górny <
>>> mgo...@gentoo.org>; cfe-commits ; Theko
>>> Lekena ; Nicolas Lesser ;
>>> Han Shen 
>>> *Subject:* Re: [PATCH] D61774: [LibTooling] Add RangeSelector library
>>> for defining source ranges based on bound AST nodes.
>>>
>>>
>>>
>>> I'm confused by the error given that getStatementsRange is a function
>>> name.  I don't have Visual Studio -- can you find a fix and send a patch? I
>>> wonder if taking the address explicitly is enough?  Or, if you know how to
>>> trigger this error in clang or gcc, I can fix it myself.
>>>
>>>
>>>
>>> On Wed, May 22, 2019 at 4:31 PM Petr Penzin via Phabricator <
>>> revi...@reviews.llvm.org> wrote:
>>>
>>> penzn added inline comments.
>>>
>>>
>>> 
>>> Comment at: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp:229
>>> +RangeSelector tooling::statements(StringRef ID) {
>>> +  return RelativeSelector(ID);
>>> +}
>>> 
>>> Sorry for posting here, haven't gotten my bugzilla access yet (requested
>>> though).
>>>
>>> This breaks with Visual Studio 2017 (15.7.6):
>>>
>>> RangeSelector.cpp(229): error C2971:
>>> '`anonymous-namespace'::RelativeSelector': template parameter 'Func':
>>> 'getStatementsRange': a variable with non-static storage duration cannot be
>>> used as a non-type argument
>>>
>>>
>>> Repository:
>>>   rL LLVM
>>>
>>> CHANGES SINCE LAST ACTION
>>>   https://reviews.llvm.org/D61774/new/
>>>
>>> https://reviews.llvm.org/D61774
>>>
>>>
>>>
>>
>> --
>> Regards,
>> Ilya Biryukov
>>
>


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


r361504 - [Driver] Try normalized triple when looking for C++ libraries

2019-05-23 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu May 23 08:23:16 2019
New Revision: 361504

URL: http://llvm.org/viewvc/llvm-project?rev=361504&view=rev
Log:
[Driver] Try normalized triple when looking for C++ libraries

This addresses the issue introduced in r361432 where we would only
try effective triple but not the normalized one as we do for other
runtimes.

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

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=361504&r1=361503&r2=361504&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu May 23 08:23:16 2019
@@ -80,6 +80,11 @@ ToolChain::ToolChain(const Driver &D, co
 llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
 if (getVFS().exists(P))
   getLibraryPaths().push_back(P.str());
+
+P.assign(D.Dir);
+llvm::sys::path::append(P, "..", "lib", Triple.str(), "c++");
+if (getVFS().exists(P))
+  getLibraryPaths().push_back(P.str());
   }
 
   P.assign(D.ResourceDir);


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


[PATCH] D62286: [Driver] Try normalized triple when looking for C++ libraries

2019-05-23 Thread Petr Hosek 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 rC361504: [Driver] Try normalized triple when looking for C++ 
libraries (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62286?vs=200873&id=200982#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62286

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -80,6 +80,11 @@
 llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
 if (getVFS().exists(P))
   getLibraryPaths().push_back(P.str());
+
+P.assign(D.Dir);
+llvm::sys::path::append(P, "..", "lib", Triple.str(), "c++");
+if (getVFS().exists(P))
+  getLibraryPaths().push_back(P.str());
   }
 
   P.assign(D.ResourceDir);


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -80,6 +80,11 @@
 llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
 if (getVFS().exists(P))
   getLibraryPaths().push_back(P.str());
+
+P.assign(D.Dir);
+llvm::sys::path::append(P, "..", "lib", Triple.str(), "c++");
+if (getVFS().exists(P))
+  getLibraryPaths().push_back(P.str());
   }
 
   P.assign(D.ResourceDir);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-23 Thread Yitzhak Mandelbaum via cfe-commits
Actually, someone already committed a fix: https://reviews.llvm.org/D62202

I can still make this change if it seems worthwhile, but its not strictly
necessary at this point.

On Thu, May 23, 2019 at 11:14 AM Yitzhak Mandelbaum 
wrote:

> Given that we'll need to store the function reference, is
> llvm::function_ref still the way to go? The comments seem to warn away from
> storing function_refs.
>
> On Thu, May 23, 2019 at 11:06 AM Yitzhak Mandelbaum 
> wrote:
>
>> Sounds good. I'll send a fix shortly. Found another bug too (captured a
>> StringRef in a lambda) -- shall i bundle the fixes?
>>
>> On Thu, May 23, 2019 at 9:01 AM Ilya Biryukov 
>> wrote:
>>
>>> Maybe go with a runtime parameter (of type llvm::function_ref) instead
>>> of the template parameter?
>>> In any non-trivial example, the runtime costs of another function
>>> pointer should be negligible given that we need to parse the ASTs, run the
>>> matchers, etc.
>>>
>>> On Wed, May 22, 2019 at 10:48 PM Penzin, Petr 
>>> wrote:
>>>
 It does not like some part of that instantiation, I am not sure which
 one yet. Let’s see what I can do about it.



 -Petr



 *From:* Yitzhak Mandelbaum [mailto:yitzh...@google.com]
 *Sent:* Wednesday, May 22, 2019 1:37 PM
 *To:* reviews+d61774+public+f458bb6144ae8...@reviews.llvm.org
 *Cc:* Ilya Biryukov ; Penzin, Petr <
 petr.pen...@intel.com>; llvm-comm...@lists.llvm.org; Michał Górny <
 mgo...@gentoo.org>; cfe-commits ; Theko
 Lekena ; Nicolas Lesser ;
 Han Shen 
 *Subject:* Re: [PATCH] D61774: [LibTooling] Add RangeSelector library
 for defining source ranges based on bound AST nodes.



 I'm confused by the error given that getStatementsRange is a function
 name.  I don't have Visual Studio -- can you find a fix and send a patch? I
 wonder if taking the address explicitly is enough?  Or, if you know how to
 trigger this error in clang or gcc, I can fix it myself.



 On Wed, May 22, 2019 at 4:31 PM Petr Penzin via Phabricator <
 revi...@reviews.llvm.org> wrote:

 penzn added inline comments.


 
 Comment at: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp:229
 +RangeSelector tooling::statements(StringRef ID) {
 +  return RelativeSelector(ID);
 +}
 
 Sorry for posting here, haven't gotten my bugzilla access yet
 (requested though).

 This breaks with Visual Studio 2017 (15.7.6):

 RangeSelector.cpp(229): error C2971:
 '`anonymous-namespace'::RelativeSelector': template parameter 'Func':
 'getStatementsRange': a variable with non-static storage duration cannot be
 used as a non-type argument


 Repository:
   rL LLVM

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

 https://reviews.llvm.org/D61774



>>>
>>> --
>>> Regards,
>>> Ilya Biryukov
>>>
>>


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


[PATCH] D62279: Use LTO capable linker

2019-05-23 Thread Wink Saville via Phabricator via cfe-commits
winksaville added a comment.

Adding libcxxabi worked and `ninja stage2-distribution` succeeded but I then 
ran `ninja check-all` and from within stage2-bins/ but that failed:

  [1072/1526] cd 
/home/wink/prgs/llvm/llvm-project/build-dist-use-lto-capable-linker-and-add-libcxxabi/tools/clang/stage2-bins/runtimes/runtimes-bins
 && /usr/bin/cmake --build 
/home/wink/prgs/llvm/llvm-project/build-dist-use-lto-capable-linker-and-add-libcxxabi/tools/clang/stage2-bins/runtimes/runtimes-bins/
 --target check-runtimes --config RelWithDebInfo
  ninja: error: 
'/home/wink/prgs/llvm/llvm-project/build-dist-use-lto-capable-linker-and-add-libcxxabi/tools/clang/stage2-bins/lib/libgtest.a',
 needed by 
'compiler-rt/lib/asan/tests/ASAN_INST_TEST_OBJECTS.gtest-all.cc.x86_64-calls.o',
 missing and no known rule to make it
  FAILED: runtimes/CMakeFiles/check-runtimes 
  cd 
/home/wink/prgs/llvm/llvm-project/build-dist-use-lto-capable-linker-and-add-libcxxabi/tools/clang/stage2-bins/runtimes/runtimes-bins
 && /usr/bin/cmake --build 
/home/wink/prgs/llvm/llvm-project/build-dist-use-lto-capable-linker-and-add-libcxxabi/tools/clang/stage2-bins/runtimes/runtimes-bins/
 --target check-runtimes --config RelWithDebInfo

I've add gtest_main and gtest to  CLANG_BOOTSTRAP_TARGETS as a guess, because 
that's where check-all is defined:

   # Expose stage2 targets through the stage1 build configuration.
   set(CLANG_BOOTSTRAP_TARGETS
  +  gtest_main
  +  gtest
 check-all
 check-llvm
 check-clang
 llvm-config
 test-suite
 test-depends
 llvm-test-depends
 clang-test-depends
 distribution
 install-distribution

My guess is likely wrong, what do you advise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62279



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


r361505 - [analyzer][NFC] Prettify some RUN: lines in test files.

2019-05-23 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Thu May 23 08:49:04 2019
New Revision: 361505

URL: http://llvm.org/viewvc/llvm-project?rev=361505&view=rev
Log:
[analyzer][NFC] Prettify some RUN: lines in test files.

This is a test commit in disguise.

Modified:
cfe/trunk/test/Analysis/bsd-string.c
cfe/trunk/test/Analysis/bstring.c
cfe/trunk/test/Analysis/cstring-plist.c
cfe/trunk/test/Analysis/null-deref-ps-region.c
cfe/trunk/test/Analysis/string.c

Modified: cfe/trunk/test/Analysis/bsd-string.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/bsd-string.c?rev=361505&r1=361504&r2=361505&view=diff
==
--- cfe/trunk/test/Analysis/bsd-string.c (original)
+++ cfe/trunk/test/Analysis/bsd-string.c Thu May 23 08:49:04 2019
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.cstring.NullArg,alpha.unix.cstring,debug.ExprInspection
 -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring.NullArg \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection
 
 #define NULL ((void *)0)
 

Modified: cfe/trunk/test/Analysis/bstring.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/bstring.c?rev=361505&r1=361504&r2=361505&view=diff
==
--- cfe/trunk/test/Analysis/bstring.c (original)
+++ cfe/trunk/test/Analysis/bstring.c Thu May 23 08:49:04 2019
@@ -1,7 +1,30 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection 
-analyzer-store=region -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS 
-analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection 
-analyzer-store=region -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DVARIANT 
-analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection 
-analyzer-store=region -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT 
-analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection 
-analyzer-store=region -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -DVARIANT \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS -DVARIANT \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
 
 //===--===
 // Declarations

Modified: cfe/trunk/test/Analysis/cstring-plist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cstring-plist.c?rev=361505&r1=361504&r2=361505&view=diff
==
--- cfe/trunk/test/Analysis/cstring-plist.c (original)
+++ cfe/trunk/test/Analysis/cstring-plist.c Thu May 23 08:49:04 2019
@@ -1,6 +1,8 @@
 // RUN: rm -f %t
 // RUN: %clang_analyze_cc1 -fblocks \
-// RUN:   -analyzer-checker=core,unix.Malloc,unix.cstring.NullArg \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=unix.cstring.NullArg \
 // RUN:   -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds \
 // RUN:   -analyzer-output=plist -o %t %s
 // RUN: FileCheck -input-file %t %s

Modified: cfe/trunk/test/Analysis/null-deref-ps-region.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps-region.c?rev=361505&r1=361504&r2=361505&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-ps-region.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps-region.c Thu May 23 08:49:04 2019
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,unix,alpha.unix 
-std=gnu99 -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -verif

r361507 - Ensure builtins use the target default Calling Convention

2019-05-23 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu May 23 09:05:21 2019
New Revision: 361507

URL: http://llvm.org/viewvc/llvm-project?rev=361507&view=rev
Log:
Ensure builtins use the target default Calling Convention

r355317 changed builtins/allocation functions to use the default calling
convention in order to support platforms that use non-cdecl calling
conventions by default.

However the default calling convention is overridable on Windows 32 bit
implementations with some of the /G options. The intent is to permit the
user to set the calling convention of normal functions, however it
should NOT apply to builtins and C++ allocation functions.

This patch ensures that the builtin/allocation functions always use the
Target specific Calling Convention, ignoring the user overridden version
of said default.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenCXX/builtin-calling-conv.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=361507&r1=361506&r2=361507&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu May 23 09:05:21 2019
@@ -2395,7 +2395,8 @@ public:
 
   /// Retrieves the default calling convention for the current target.
   CallingConv getDefaultCallingConvention(bool IsVariadic,
-  bool IsCXXMethod) const;
+  bool IsCXXMethod,
+  bool IsBuiltin = false) const;
 
   /// Retrieves the "canonical" template name that refers to a
   /// given template.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=361507&r1=361506&r2=361507&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu May 23 09:05:21 2019
@@ -9627,8 +9627,8 @@ QualType ASTContext::GetBuiltinType(unsi
 
   bool Variadic = (TypeStr[0] == '.');
 
-  FunctionType::ExtInfo EI(
-  getDefaultCallingConvention(Variadic, /*IsCXXMethod=*/false));
+  FunctionType::ExtInfo EI(getDefaultCallingConvention(
+  Variadic, /*IsCXXMethod=*/false, /*IsBuiltin=*/true));
   if (BuiltinInfo.isNoReturn(Id)) EI = EI.withNoReturn(true);
 
 
@@ -10005,34 +10005,39 @@ void ASTContext::forEachMultiversionedFu
 }
 
 CallingConv ASTContext::getDefaultCallingConvention(bool IsVariadic,
-bool IsCXXMethod) const {
+bool IsCXXMethod,
+bool IsBuiltin) const {
   // Pass through to the C++ ABI object
   if (IsCXXMethod)
 return ABI->getDefaultMethodCallConv(IsVariadic);
 
-  switch (LangOpts.getDefaultCallingConv()) {
-  case LangOptions::DCC_None:
-break;
-  case LangOptions::DCC_CDecl:
-return CC_C;
-  case LangOptions::DCC_FastCall:
-if (getTargetInfo().hasFeature("sse2") && !IsVariadic)
-  return CC_X86FastCall;
-break;
-  case LangOptions::DCC_StdCall:
-if (!IsVariadic)
-  return CC_X86StdCall;
-break;
-  case LangOptions::DCC_VectorCall:
-// __vectorcall cannot be applied to variadic functions.
-if (!IsVariadic)
-  return CC_X86VectorCall;
-break;
-  case LangOptions::DCC_RegCall:
-// __regcall cannot be applied to variadic functions.
-if (!IsVariadic)
-  return CC_X86RegCall;
-break;
+  // Builtins ignore user-specified default calling convention and remain the
+  // Target's default calling convention.
+  if (!IsBuiltin) {
+switch (LangOpts.getDefaultCallingConv()) {
+case LangOptions::DCC_None:
+  break;
+case LangOptions::DCC_CDecl:
+  return CC_C;
+case LangOptions::DCC_FastCall:
+  if (getTargetInfo().hasFeature("sse2") && !IsVariadic)
+return CC_X86FastCall;
+  break;
+case LangOptions::DCC_StdCall:
+  if (!IsVariadic)
+return CC_X86StdCall;
+  break;
+case LangOptions::DCC_VectorCall:
+  // __vectorcall cannot be applied to variadic functions.
+  if (!IsVariadic)
+return CC_X86VectorCall;
+  break;
+case LangOptions::DCC_RegCall:
+  // __regcall cannot be applied to variadic functions.
+  if (!IsVariadic)
+return CC_X86RegCall;
+  break;
+}
   }
   return Target->getDefaultCallingConv(TargetInfo::CCMT_Unknown);
 }

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=361507&r1=361506&r2=361507&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (origin

[PATCH] D62328: [LibTooling] Fix dangling references in RangeSelector.

2019-05-23 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: ilya-biryukov, gribozavr.
Herald added a project: clang.

RangeSelector had a number of cases of capturing a StringRef in a lambda, which
lead to dangling references. This change converts all uses in the API of
`StringRef` to `std::string` to avoid this problem. `std::string` in the API is
a reasonable choice, because the combinators are always storing the string
beyond the life of the combinator construction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62328

Files:
  clang/include/clang/Tooling/Refactoring/RangeSelector.h
  clang/lib/Tooling/Refactoring/RangeSelector.cpp

Index: clang/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- clang/lib/Tooling/Refactoring/RangeSelector.cpp
+++ clang/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -104,7 +104,7 @@
   return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
 }
 
-RangeSelector tooling::node(StringRef ID) {
+RangeSelector tooling::node(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
@@ -115,7 +115,7 @@
   };
 }
 
-RangeSelector tooling::statement(StringRef ID) {
+RangeSelector tooling::statement(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
@@ -143,11 +143,11 @@
   };
 }
 
-RangeSelector tooling::range(StringRef BeginID, StringRef EndID) {
-  return tooling::range(node(BeginID), node(EndID));
+RangeSelector tooling::range(std::string BeginID, std::string EndID) {
+  return tooling::range(node(std::move(BeginID)), node(std::move(EndID)));
 }
 
-RangeSelector tooling::member(StringRef ID) {
+RangeSelector tooling::member(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
@@ -159,7 +159,7 @@
   };
 }
 
-RangeSelector tooling::name(StringRef ID) {
+RangeSelector tooling::name(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected N = getNode(Result.Nodes, ID);
 if (!N)
@@ -205,7 +205,7 @@
   std::string ID;
 
 public:
-  RelativeSelector(StringRef ID) : ID(ID) {}
+  RelativeSelector(std::string ID) : ID(std::move(ID)) {}
 
   Expected operator()(const MatchResult &Result) {
 Expected N = getNode(Result.Nodes, ID);
@@ -231,8 +231,8 @@
 }
 } // namespace
 
-RangeSelector tooling::statements(StringRef ID) {
-  return RelativeSelector(ID);
+RangeSelector tooling::statements(std::string ID) {
+  return RelativeSelector(std::move(ID));
 }
 
 namespace {
@@ -246,8 +246,8 @@
 }
 } // namespace
 
-RangeSelector tooling::callArgs(StringRef ID) {
-  return RelativeSelector(ID);
+RangeSelector tooling::callArgs(std::string ID) {
+  return RelativeSelector(std::move(ID));
 }
 
 namespace {
@@ -260,8 +260,8 @@
 }
 } // namespace
 
-RangeSelector tooling::initListElements(StringRef ID) {
-  return RelativeSelector(ID);
+RangeSelector tooling::initListElements(std::string ID) {
+  return RelativeSelector(std::move(ID));
 }
 
 RangeSelector tooling::expansion(RangeSelector S) {
Index: clang/include/clang/Tooling/Refactoring/RangeSelector.h
===
--- clang/include/clang/Tooling/Refactoring/RangeSelector.h
+++ clang/include/clang/Tooling/Refactoring/RangeSelector.h
@@ -17,9 +17,9 @@
 
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include 
+#include 
 
 namespace clang {
 namespace tooling {
@@ -35,19 +35,19 @@
 RangeSelector range(RangeSelector Begin, RangeSelector End);
 
 /// Convenience version of \c range where end-points are bound nodes.
-RangeSelector range(StringRef BeginID, StringRef EndID);
+RangeSelector range(std::string BeginID, std::string EndID);
 
 /// Selects a node, including trailing semicolon (for non-expression
 /// statements). \p ID is the node's binding in the match result.
-RangeSelector node(StringRef ID);
+RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting
 /// expression statements. \p ID is the node's binding in the match result.
-RangeSelector statement(StringRef ID);
+RangeSelector statement(std::string ID);
 
 /// Given a \c MemberExpr, selects the member token. \p ID is the node's
 /// binding in the match result.
-RangeSelector member(StringRef ID);
+RangeSelector member(std::string ID);
 
 /// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr or \c
 /// CxxCtorInitializer) selects the name's token.  Only selects the final
@@ -56,19 +56,19 @@
 /// it selects only `baz`.
 ///
 /// \param ID is the node's binding in the match result.
-RangeSelector name(StringRef ID);
+RangeSelector name(std::string ID);
 
 // Given a \c CallExpr (b

[PATCH] D62329: [ASTImporter] Structural eq: handle DependentScopeDeclRefExpr

2019-05-23 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.

Structural equivalence did not handle dependent template args properly
when the arg contained a DependentScopeDeclRefExpr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62329

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -892,5 +892,143 @@
   EXPECT_FALSE(testStructuralMatch(First, Second));
 }
 
+struct StructuralEquivalenceDependentTemplateArgsTest
+: StructuralEquivalenceTemplateTest {};
+
+TEST_F(StructuralEquivalenceDependentTemplateArgsTest,
+   SameStructsInDependentArgs) {
+  std::string Code =
+  R"(
+  template 
+  struct S1;
+
+  template 
+  struct enable_if;
+
+  struct S
+  {
+template >::type>
+void f();
+  };
+  )";
+  auto t = makeDecls(Code, Code, Lang_CXX11,
+   functionTemplateDecl(hasName("f")));
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceDependentTemplateArgsTest,
+   DifferentStructsInDependentArgs) {
+  std::string Code =
+  R"(
+  template 
+  struct S1;
+
+  template 
+  struct S2;
+
+  template 
+  struct enable_if;
+  )";
+  auto t = makeDecls(Code + R"(
+  struct S
+  {
+template >::type>
+void f();
+  };
+  )",
+   Code + R"(
+  struct S
+  {
+template >::type>
+void f();
+  };
+  )",
+   Lang_CXX11,
+   functionTemplateDecl(hasName("f")));
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceDependentTemplateArgsTest,
+   SameStructsInDependentScopeDeclRefExpr) {
+  std::string Code =
+  R"(
+  template 
+  struct S1;
+
+  template 
+  struct enable_if;
+
+  struct S
+  {
+template ::value>::type>
+void f();   // DependentScopeDeclRefExpr:
+  };
+  )";
+  auto t = makeDecls(Code, Code, Lang_CXX11,
+   functionTemplateDecl(hasName("f")));
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceDependentTemplateArgsTest,
+   DifferentStructsInDependentScopeDeclRefExpr) {
+  std::string Code =
+  R"(
+  template 
+  struct S1;
+
+  template 
+  struct S2;
+
+  template 
+  struct enable_if;
+  )";
+  auto t = makeDecls(Code + R"(
+  struct S
+  {
+template ::value>::type>
+void f();   // DependentScopeDeclRefExpr:
+  };
+  )",
+   Code + R"(
+  struct S
+  {
+template ::value>::type>
+void f();
+  };
+  )",
+   Lang_CXX,
+   functionTemplateDecl(hasName("f")));
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceDependentTemplateArgsTest,
+   DifferentValueInDependentScopeDeclRefExpr) {
+  std::string Code =
+  R"(
+  template 
+  struct S1;
+
+  template 
+  struct enable_if;
+  )";
+  auto t = makeDecls(Code + R"(
+  struct S
+  {
+template ::value1>::type>
+void f();   // DependentScopeDeclRefExpr:
+  };
+  )",
+   Code + R"(
+  struct S
+  {
+template ::value2>::type>
+void f();
+  };
+  )",
+   Lang_CXX,
+   functionTemplateDecl(hasName("f")));
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -73,6 +73,7 @@
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
@@ -100,6 +101,51 @@
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  const TemplateArgument &Arg1,
  const TemplateArgument &Arg2);
+static bool IsStructurallyEquivalent(St

[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-23 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 200998.
gchatelet added a comment.

- Use no-builtin instead of no-runtime-for.
- Use one attribute per runtime function to make merging easier.

The patch is still WIP and needs more work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Target/X86/X86SelectionDAGInfo.cpp
  llvm/test/CodeGen/X86/memcpy.ll

Index: llvm/test/CodeGen/X86/memcpy.ll
===
--- llvm/test/CodeGen/X86/memcpy.ll
+++ llvm/test/CodeGen/X86/memcpy.ll
@@ -7,7 +7,7 @@
 
 
 ; Variable memcpy's should lower to calls.
-define i8* @test1(i8* %a, i8* %b, i64 %n) nounwind {
+define void @test1(i8* %a, i8* %b, i64 %n) nounwind {
 ; LINUX-LABEL: test1:
 ; LINUX:   # %bb.0: # %entry
 ; LINUX-NEXT:jmp memcpy # TAILCALL
@@ -17,11 +17,11 @@
 ; DARWIN-NEXT:jmp _memcpy ## TAILCALL
 entry:
 	tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %b, i64 %n, i1 0 )
-	ret i8* %a
+  ret void
 }
 
 ; Variable memcpy's should lower to calls.
-define i8* @test2(i64* %a, i64* %b, i64 %n) nounwind {
+define void @test2(i64* %a, i64* %b, i64 %n) nounwind {
 ; LINUX-LABEL: test2:
 ; LINUX:   # %bb.0: # %entry
 ; LINUX-NEXT:jmp memcpy # TAILCALL
@@ -33,7 +33,25 @@
 	%tmp14 = bitcast i64* %a to i8*
 	%tmp25 = bitcast i64* %b to i8*
 	tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %tmp14, i8* align 8 %tmp25, i64 %n, i1 0 )
-	ret i8* %tmp14
+  ret void
+}
+
+; Variable length memcpy's with disabled runtime should lower to repmovsb.
+define void @memcpy_no_runtime(i8* %a, i8* %b, i64 %n) nounwind {
+; LINUX-LABEL: memcpy_no_runtime:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:movq %rdx, %rcx
+; LINUX-NEXT:rep;movsb (%rsi), %es:(%rdi)
+; LINUX-NEXT:retq
+;
+; DARWIN-LABEL: memcpy_no_runtime:
+; DARWIN:   ## %bb.0: ## %entry
+; DARWIN-NEXT:movq %rdx, %rcx
+; DARWIN-NEXT:rep;movsb (%rsi), %es:(%rdi)
+; DARWIN-NEXT:retq
+entry:
+	tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %b, i64 %n, i1 0 ) "no-builtin-memcpy"
+  ret void
 }
 
 ; Large constant memcpy's should lower to a call when optimizing for size.
Index: llvm/lib/Target/X86/X86SelectionDAGInfo.cpp
===
--- llvm/lib/Target/X86/X86SelectionDAGInfo.cpp
+++ llvm/lib/Target/X86/X86SelectionDAGInfo.cpp
@@ -314,5 +314,9 @@
   Size.getValueType(), Align, isVolatile,
   AlwaysInline, DstPtrInfo, SrcPtrInfo);
 
+  /// Handle runtime sizes through repmovsb when we AlwaysInline.
+  if (AlwaysInline)
+return emitRepmovs(Subtarget, DAG, dl, Chain, Dst, Src, Size, MVT::i8);
+
   return SDValue();
 }
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -96,6 +96,14 @@
   return II;
 }
 
+static void ForwardAttribute(const Function *F, StringRef Attribute,
+ CallInst *CI) {
+  if (F->hasFnAttribute(Attribute)) {
+CI->addAttribute(AttributeList::FunctionIndex,
+ F->getFnAttribute(Attribute));
+  }
+}
+
 CallInst *IRBuilderBase::
 CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
  bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag,
@@ -103,7 +111,8 @@
   Ptr = getCastedInt8PtrValue(Ptr);
   Value *Ops[] = {Ptr, Val, Size, getInt1(isVolatile)};
   Type *Tys[] = { Ptr->getType(), Size->getType() };
-  Module *M = BB->getParent()->getParent();
+  Function *F = BB->getParent();
+  Module *M = F->getParent();
   Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
 
   CallInst *CI = createCallHelper(TheFn, Ops, this);
@@ -121,6 +130,8 @@
   if (NoAliasTag)
 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
 
+  ForwardAttribute(F, "no-builtin-memset", CI);
+
   return CI;
 }
 
@@ -165,7 +176,8 @@
 
   Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)};
   Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
-  Module *M = BB->getParent()->getParent();
+  Function *F = BB->getParent();
+  Module *M = F->getParent();
   Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys);
 
   CallInst *CI = createCallHelper(TheFn, Ops, this);
@@ -190,6 +202,8 @@
   if (NoAliasTag)
 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
 
+  ForwardAttribute(F, "no-builtin-memcpy", CI);
+
   return CI;
 }
 
@@ -245,7 +259,8 @@
 
   Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)};
   Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
-  Module *M = BB->getParent

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201000.
ilya-biryukov added a comment.
Herald added subscribers: arphaman, jkorous.

- Make first letter of the helper function lowercase
- New model: everything before name is a text chunk, everything after it is 
typed chunk
- Test the filter text produced by clangd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp

Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,23 +11,17 @@
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vfo
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vfo
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
+// Runs completion at vf^o
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
-//
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
-// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
-// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,49 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+   std::string &BeforeName,
+   std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature,
+ NameAndSignature);
+  continue;
+}
+if (!SeenTypedChunk && Chunk.Kind == CodeCompletionString::CK_TypedText)
+  SeenTypedChunk = true;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType) {
+  assert(!SeenTypedChunk);
+  BeforeName += " ";
+}
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

I think that's a good step forward, although not yet ideal. The typed chunk now 
contains everything starting function name and ending with `override`, so one 
gets both nice prefix match scores when typing a function and possibility to 
say `override` to get all completion items that do overrides.




Comment at: clang/test/CodeCompletion/overrides.cpp:29
-//
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s

I've removed this to avoid dealing with the error return code (`vfo` is 
unresolved, so clang produces error there).
Happy to bring it back if you feel it's important


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

After landing this, will try to add new presentation options for completion 
items here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


r361510 - [CodeComplete] Only show lambda completions if patterns are requested

2019-05-23 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu May 23 09:39:26 2019
New Revision: 361510

URL: http://llvm.org/viewvc/llvm-project?rev=361510&view=rev
Log:
[CodeComplete] Only show lambda completions if patterns are requested

This is a trivial follow-up to r361461, so sending without review.

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/lambdas.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=361510&r1=361509&r2=361510&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu May 23 09:39:26 2019
@@ -4134,6 +4134,8 @@ static const FunctionProtoType *TryDecon
 static void AddLambdaCompletion(ResultBuilder &Results,
 llvm::ArrayRef Parameters,
 const LangOptions &LangOpts) {
+  if (!Results.includeCodePatterns())
+return;
   CodeCompletionBuilder Completion(Results.getAllocator(),
Results.getCodeCompletionTUInfo());
   // []() {}

Modified: cfe/trunk/test/CodeCompletion/lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/lambdas.cpp?rev=361510&r1=361509&r2=361510&view=diff
==
--- cfe/trunk/test/CodeCompletion/lambdas.cpp (original)
+++ cfe/trunk/test/CodeCompletion/lambdas.cpp Thu May 23 09:39:26 2019
@@ -51,3 +51,12 @@ void test4() {
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:50:35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
   // CHECK-6-NOT: COMPLETION: Pattern : [<#=
 }
+
+void test5() {
+  // Completions are only added when -code-completion-patterns are enabled.
+  function b = {};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:57:24 %s -o - | FileCheck -check-prefix=CHECK-7 %s
+  // CHECK-7: COMPLETION: Pattern : [<#=
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:57:24 %s -o - | 
FileCheck -check-prefix=CHECK-8 %s
+  // CHECK-8-NOT: COMPLETION: Pattern : [<#=
+}


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


[PATCH] D62312: [ASTImporter] Added visibility context check for CXXRecordDecl.

2019-05-23 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Minor comments, I am going to run `check-lldb` now.




Comment at: unittests/AST/ASTImporterVisibilityTest.cpp:34
 };
+struct GetClassPattern {
+  using DeclTy = CXXRecordDecl;

`GetCXXRecordPattern` feels more consistent.



Comment at: unittests/AST/ASTImporterVisibilityTest.cpp:49
+// CXXRecordDecl:
+auto *ExternC = "class X;";
+auto *AnonC = "namespace { class X; }";

`const`? It is not consistent w/ the previous declarations. 



Comment at: unittests/AST/ASTImporterVisibilityTest.cpp:50
+auto *ExternC = "class X;";
+auto *AnonC = "namespace { class X; }";
 

`const`? It is not consistent w/ the previous declarations. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D62312



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


[PATCH] D62328: [LibTooling] Fix dangling references in RangeSelector.

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62328



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


[PATCH] D62303: [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201002.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Address a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62303

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexTypeSourceInfo.cpp


Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,41 @@
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
- SymbolRoleSet(), Relations);
+  void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+   SourceLocation TemplNameLoc,
+   CXXRecordDecl *ResolvedClass,
+   bool IsTypeAlias) {
+// In presence of type aliases, the resolved class was never written in
+// the code so don't report it.
+if (!IsTypeAlias && ResolvedClass &&
+(!ResolvedClass->isImplicit() ||
+ IndexCtx.shouldIndexImplicitInstantiation())) {
+  IndexCtx.handleReference(ResolvedClass, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
+} else if (const TemplateDecl *D = TemplName.getAsTemplateDecl()) {
+  IndexCtx.handleReference(D, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
 }
-return true;
   }
 
   bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+T->isTypeAlias());
+return true;
   }
 
   bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+/*IsTypeAlias=*/false);
+return true;
   }
 
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -497,6 +497,17 @@
   ElementsAre(Sym("Foo"), Sym("Foo")));
 }
 
+TEST(LocateSymbol, TemplateTypedefs) {
+  auto T = Annotations(R"cpp(
+template  struct function {};
+template  using callback = function;
+
+c^allback foo;
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  EXPECT_THAT(locateSymbolAt(AST, T.point()), ElementsAre(Sym("callback")));
+}
+
 TEST(LocateSymbol, RelPathsInCompileCommand) {
   // The source is in "/clangd-test/src".
   // We build in "/clangd-test/build".


Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,41 @@
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
- SymbolRoleSet(), Relations);
+  void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+   SourceLocation TemplNameLoc,
+   CXXRecordDecl *ResolvedClass,
+   bool IsTypeA

[PATCH] D62303: [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Index/IndexTypeSourceInfo.cpp:140
+   bool IsTypeAlias) {
+if (ResolvedClass) {
+  // In presence of type aliases, the resolved class was never written in

kadircet wrote:
> why not merge with next condition?
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62303



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


[clang-tools-extra] r361511 - [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu May 23 09:48:47 2019
New Revision: 361511

URL: http://llvm.org/viewvc/llvm-project?rev=361511&view=rev
Log:
[Index] Fix reported references in presence of template type aliases

Summary: See the added test for an example.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp?rev=361511&r1=361510&r2=361511&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp Thu May 23 09:48:47 
2019
@@ -497,6 +497,17 @@ TEST(LocateSymbol, Ambiguous) {
   ElementsAre(Sym("Foo"), Sym("Foo")));
 }
 
+TEST(LocateSymbol, TemplateTypedefs) {
+  auto T = Annotations(R"cpp(
+template  struct function {};
+template  using callback = function;
+
+c^allback foo;
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  EXPECT_THAT(locateSymbolAt(AST, T.point()), ElementsAre(Sym("callback")));
+}
+
 TEST(LocateSymbol, RelPathsInCompileCommand) {
   // The source is in "/clangd-test/src".
   // We build in "/clangd-test/build".


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


r361511 - [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu May 23 09:48:47 2019
New Revision: 361511

URL: http://llvm.org/viewvc/llvm-project?rev=361511&view=rev
Log:
[Index] Fix reported references in presence of template type aliases

Summary: See the added test for an example.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp

Modified: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp?rev=361511&r1=361510&r2=361511&view=diff
==
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp Thu May 23 09:48:47 2019
@@ -133,29 +133,41 @@ public:
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
- SymbolRoleSet(), Relations);
+  void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+   SourceLocation TemplNameLoc,
+   CXXRecordDecl *ResolvedClass,
+   bool IsTypeAlias) {
+// In presence of type aliases, the resolved class was never written in
+// the code so don't report it.
+if (!IsTypeAlias && ResolvedClass &&
+(!ResolvedClass->isImplicit() ||
+ IndexCtx.shouldIndexImplicitInstantiation())) {
+  IndexCtx.handleReference(ResolvedClass, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
+} else if (const TemplateDecl *D = TemplName.getAsTemplateDecl()) {
+  IndexCtx.handleReference(D, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
 }
-return true;
   }
 
   bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+T->isTypeAlias());
+return true;
   }
 
   bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+/*IsTypeAlias=*/false);
+return true;
   }
 
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {


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


[PATCH] D62303: [Index] Fix reported references in presence of template type aliases

2019-05-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361511: [Index] Fix reported references in presence of 
template type aliases (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62303?vs=201002&id=201003#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62303

Files:
  cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
  clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp


Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
===
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,41 @@
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
- SymbolRoleSet(), Relations);
+  void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+   SourceLocation TemplNameLoc,
+   CXXRecordDecl *ResolvedClass,
+   bool IsTypeAlias) {
+// In presence of type aliases, the resolved class was never written in
+// the code so don't report it.
+if (!IsTypeAlias && ResolvedClass &&
+(!ResolvedClass->isImplicit() ||
+ IndexCtx.shouldIndexImplicitInstantiation())) {
+  IndexCtx.handleReference(ResolvedClass, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
+} else if (const TemplateDecl *D = TemplName.getAsTemplateDecl()) {
+  IndexCtx.handleReference(D, TemplNameLoc, Parent, ParentDC,
+   SymbolRoleSet(), Relations);
 }
-return true;
   }
 
   bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+T->isTypeAlias());
+return true;
   }
 
   bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
-return HandleTemplateSpecializationTypeLoc(TL);
+auto *T = TL.getTypePtr();
+if (!T)
+  return true;
+HandleTemplateSpecializationTypeLoc(
+T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+/*IsTypeAlias=*/false);
+return true;
   }
 
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
Index: clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
@@ -497,6 +497,17 @@
   ElementsAre(Sym("Foo"), Sym("Foo")));
 }
 
+TEST(LocateSymbol, TemplateTypedefs) {
+  auto T = Annotations(R"cpp(
+template  struct function {};
+template  using callback = function;
+
+c^allback foo;
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  EXPECT_THAT(locateSymbolAt(AST, T.point()), ElementsAre(Sym("callback")));
+}
+
 TEST(LocateSymbol, RelPathsInCompileCommand) {
   // The source is in "/clangd-test/src".
   // We build in "/clangd-test/build".


Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
===
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,41 @@
 return true;
   }
 
-  template
-  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
-if (const auto *T = TL.getTypePtr()) {
-  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
-   ParentDC, SymbolRoleSet(), Relations);
-  return true;
-}
-  }
-  if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
- SymbolRoleSet(), Relations);
+  void HandleTemplate

Re: [PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-23 Thread Ilya Biryukov via cfe-commits
Either way looks good.
If we go with function_ref, we should definitely store a comment why
storing function_ref is fine there. Or use a function pointer to make it
even clearer that nothing cheesy is going on there.

On Thu, May 23, 2019 at 5:28 PM Yitzhak Mandelbaum 
wrote:

> Actually, someone already committed a fix: https://reviews.llvm.org/D62202
>
> I can still make this change if it seems worthwhile, but its not strictly
> necessary at this point.
>
> On Thu, May 23, 2019 at 11:14 AM Yitzhak Mandelbaum 
> wrote:
>
>> Given that we'll need to store the function reference, is
>> llvm::function_ref still the way to go? The comments seem to warn away from
>> storing function_refs.
>>
>> On Thu, May 23, 2019 at 11:06 AM Yitzhak Mandelbaum 
>> wrote:
>>
>>> Sounds good. I'll send a fix shortly. Found another bug too (captured a
>>> StringRef in a lambda) -- shall i bundle the fixes?
>>>
>>> On Thu, May 23, 2019 at 9:01 AM Ilya Biryukov 
>>> wrote:
>>>
 Maybe go with a runtime parameter (of type llvm::function_ref) instead
 of the template parameter?
 In any non-trivial example, the runtime costs of another function
 pointer should be negligible given that we need to parse the ASTs, run the
 matchers, etc.

 On Wed, May 22, 2019 at 10:48 PM Penzin, Petr 
 wrote:

> It does not like some part of that instantiation, I am not sure which
> one yet. Let’s see what I can do about it.
>
>
>
> -Petr
>
>
>
> *From:* Yitzhak Mandelbaum [mailto:yitzh...@google.com]
> *Sent:* Wednesday, May 22, 2019 1:37 PM
> *To:* reviews+d61774+public+f458bb6144ae8...@reviews.llvm.org
> *Cc:* Ilya Biryukov ; Penzin, Petr <
> petr.pen...@intel.com>; llvm-comm...@lists.llvm.org; Michał Górny <
> mgo...@gentoo.org>; cfe-commits ; Theko
> Lekena ; Nicolas Lesser ;
> Han Shen 
> *Subject:* Re: [PATCH] D61774: [LibTooling] Add RangeSelector library
> for defining source ranges based on bound AST nodes.
>
>
>
> I'm confused by the error given that getStatementsRange is a function
> name.  I don't have Visual Studio -- can you find a fix and send a patch? 
> I
> wonder if taking the address explicitly is enough?  Or, if you know how to
> trigger this error in clang or gcc, I can fix it myself.
>
>
>
> On Wed, May 22, 2019 at 4:31 PM Petr Penzin via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
> penzn added inline comments.
>
>
> 
> Comment at: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp:229
> +RangeSelector tooling::statements(StringRef ID) {
> +  return RelativeSelector(ID);
> +}
> 
> Sorry for posting here, haven't gotten my bugzilla access yet
> (requested though).
>
> This breaks with Visual Studio 2017 (15.7.6):
>
> RangeSelector.cpp(229): error C2971:
> '`anonymous-namespace'::RelativeSelector': template parameter 'Func':
> 'getStatementsRange': a variable with non-static storage duration cannot 
> be
> used as a non-type argument
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D61774/new/
>
> https://reviews.llvm.org/D61774
>
>
>

 --
 Regards,
 Ilya Biryukov

>>>

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


[PATCH] D59253: [AIX][libcxx] AIX system headers need stdint.h and inttypes.h to be re-enterable when macro _STD_TYPES_T is defined

2019-05-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: libcxx/include/stdint.h:16
+#endif // _STD_TYPES_T
 
 /*

I don't think that this will do what you want it to.
Is this a supported use case?

```
#include 
#define _STD_TYPES_T
#include 
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59253



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


[PATCH] D62215: Fixes to distribution example for X86_64 Arch Linux

2019-05-23 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D62215#1512849 , @winksaville wrote:

> IIRC, on linux if LTO is ON I had to use `ld.gold` for both stage 1 and 2, 
> although that maybe
>  just the way it ended up and it wasn't necessary. But I'll test whatever you 
> come up with.


I will try and spin up a VM today to try and test this on Linux using GNU ld 
for the stage 1. I don't usually do much work on Linux, but when I do I always 
setup `lld` as my system linker because it is way more efficient both in speed 
and memory usage. I don't think I've ever managed to get GNU ld to link a 
non-debug build of LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62215



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


[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-23 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 201004.
akhuang added a comment.

Add llvm IR test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-static-member.cpp
  llvm/test/DebugInfo/COFF/global-constants.ll

Index: llvm/test/DebugInfo/COFF/global-constants.ll
===
--- llvm/test/DebugInfo/COFF/global-constants.ll
+++ llvm/test/DebugInfo/COFF/global-constants.ll
@@ -3,18 +3,25 @@
 
 ; C++ source to regenerate:
 ; const int Test1 = 1;
+; struct Foo { static const int Test2 = 2; };
 ; int main() {
-;   return Test1;
+;   return Test1 + Foo::Test2;
 ; }
 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
 
-; ASM-LABEL:  .long 241  # Symbol subsection for globals
+; ASM-LABEL:  .long 241 # Symbol subsection for globals
 
-; ASM:.short {{.*-.*}}   # Record length
-; ASM:.short 4359# Record kind: S_CONSTANT
-; ASM-NEXT:   .long 4099 # Type
-; ASM-NEXT:   .byte 0x01, 0x00   # Value
-; ASM-NEXT:   .asciz "Test1" # Name
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM-NEXT:   .long 4099# Type
+; ASM-NEXT:   .byte 0x01, 0x00  # Value
+; ASM-NEXT:   .asciz "Test1"# Name
+
+; ASM:.short {{.*-.*}}  # Record length
+; ASM:.short 4359   # Record kind: S_CONSTANT
+; ASM:.long 4099# Type
+; ASM:.byte 0x02, 0x00  # Value
+; ASM:.asciz "Test2"# Name
 
 ; OBJ:CodeViewDebugInfo [
 ; OBJ:  Section: .debug$S
@@ -27,6 +34,12 @@
 ; OBJ-NEXT: Value: 1
 ; OBJ-NEXT: Name: Test1
 ; OBJ-NEXT:   }
+; OBJ:ConstantSym {
+; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
+; OBJ-NEXT: Type: const int (0x1003)
+; OBJ-NEXT: Value: 2
+; OBJ-NEXT: Name: Test2
+; OBJ-NEXT:   }
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
@@ -34,31 +47,39 @@
 target triple = "x86_64-pc-windows-msvc"
 
 ; Function Attrs: noinline norecurse nounwind optnone
-define dso_local i32 @main() #0 !dbg !13 {
+define dso_local i32 @main() #0 !dbg !19 {
 entry:
   %retval = alloca i32, align 4
   store i32 0, i32* %retval, align 4
-  ret i32 1, !dbg !16
+  ret i32 3, !dbg !22
 }
 
+attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!9, !10, !11}
-!llvm.ident = !{!12}
+!llvm.module.flags = !{!15, !16, !17}
+!llvm.ident = !{!18}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, nameTableKind: None)
-!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2b66a49044196d8b90d95d7d3b5246ccbe3abc05)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !10, nameTableKind: None)
+!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "77cff5e1c7b260440ed03b23c18809c3")
 !2 = !{}
 !3 = !{!4}
-!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
-!5 = distinct !DIGlobalVariable(name: "Test1", scope: !0, file: !6, line: 1, type: !7, isLocal: true, isDefinition: true)
-!6 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "0d5ef00bdd80bdb409a3deac9938f20d")
-!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
-!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!9 = !{i32 2, !"CodeView", i32 1}
-!10 = !{i32 2, !"Debug Info Version", i32 3}
-!11 = !{i32 1, !"wchar_size", i32 2}
-!12 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4a1902b6739e3087a03c0ac7ab85b640764e9335)"}
-!13 = distinct !DISubprogram(name: "main", scope: !6, file: !6, line: 3, type: !14, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
-!14 = !DISubroutineType(types: !15)
-!15 = !{!8}
-!16 = !DILoca

r361514 - [LibTooling] Fix dangling references in RangeSelector.

2019-05-23 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Thu May 23 10:11:33 2019
New Revision: 361514

URL: http://llvm.org/viewvc/llvm-project?rev=361514&view=rev
Log:
[LibTooling] Fix dangling references in RangeSelector.

Summary:
RangeSelector had a number of cases of capturing a StringRef in a lambda, which
lead to dangling references. This change converts all uses in the API of
`StringRef` to `std::string` to avoid this problem. `std::string` in the API is
a reasonable choice, because the combinators are always storing the string
beyond the life of the combinator construction.

Reviewers: ilya-biryukov, gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h?rev=361514&r1=361513&r2=361514&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h Thu May 23 
10:11:33 2019
@@ -17,9 +17,9 @@
 
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include 
+#include 
 
 namespace clang {
 namespace tooling {
@@ -35,19 +35,19 @@ inline RangeSelector charRange(CharSourc
 RangeSelector range(RangeSelector Begin, RangeSelector End);
 
 /// Convenience version of \c range where end-points are bound nodes.
-RangeSelector range(StringRef BeginID, StringRef EndID);
+RangeSelector range(std::string BeginID, std::string EndID);
 
 /// Selects a node, including trailing semicolon (for non-expression
 /// statements). \p ID is the node's binding in the match result.
-RangeSelector node(StringRef ID);
+RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting
 /// expression statements. \p ID is the node's binding in the match result.
-RangeSelector statement(StringRef ID);
+RangeSelector statement(std::string ID);
 
 /// Given a \c MemberExpr, selects the member token. \p ID is the node's
 /// binding in the match result.
-RangeSelector member(StringRef ID);
+RangeSelector member(std::string ID);
 
 /// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr or \c
 /// CxxCtorInitializer) selects the name's token.  Only selects the final
@@ -56,19 +56,19 @@ RangeSelector member(StringRef ID);
 /// it selects only `baz`.
 ///
 /// \param ID is the node's binding in the match result.
-RangeSelector name(StringRef ID);
+RangeSelector name(std::string ID);
 
 // Given a \c CallExpr (bound to \p ID), selects the arguments' source text 
(all
 // source between the call's parentheses).
-RangeSelector callArgs(StringRef ID);
+RangeSelector callArgs(std::string ID);
 
 // Given a \c CompoundStmt (bound to \p ID), selects the source of the
 // statements (all source between the braces).
-RangeSelector statements(StringRef ID);
+RangeSelector statements(std::string ID);
 
 // Given a \c InitListExpr (bound to \p ID), selects the range of the elements
 // (all source between the braces).
-RangeSelector initListElements(StringRef ID);
+RangeSelector initListElements(std::string ID);
 
 /// Selects the range from which `S` was expanded (possibly along with other
 /// source), if `S` is an expansion, and `S` itself, otherwise.  Corresponds to

Modified: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp?rev=361514&r1=361513&r2=361514&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp Thu May 23 10:11:33 2019
@@ -104,7 +104,7 @@ static SourceLocation findOpenParen(cons
   return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
 }
 
-RangeSelector tooling::node(StringRef ID) {
+RangeSelector tooling::node(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
@@ -115,7 +115,7 @@ RangeSelector tooling::node(StringRef ID
   };
 }
 
-RangeSelector tooling::statement(StringRef ID) {
+RangeSelector tooling::statement(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
@@ -143,11 +143,11 @@ RangeSelector tooling::range(RangeSelect
   };
 }
 
-RangeSelector tooling::range(StringRef BeginID, StringRef EndID) {
-  return tooling::range(node(BeginID), node(EndID));
+RangeSelector tooling::range(std::string BeginID, std::string EndID) {
+  return tooling::ran

[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-23 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked an inline comment as done.
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4385
+// Use the global scope for static members.
+DContext = getContextDescriptor(
+   cast(CGM.getContext().getTranslationUnitDecl()), TheCU);

dblaikie wrote:
> akhuang wrote:
> > @dblaikie I'm using the global scope here because if the class type is used 
> > as the scope it runs into the [[ 
> > https://github.com/llvm/llvm-project/blob/a2ee80b084e5c0b20364ed4379384706f5e059b1/llvm/lib/IR/DIBuilder.cpp#L630
> >  | assert message ]] `Context of a global variable should not be a type 
> > with identifier`. Is there a reason for the assert? 
> I think it's generally how LLVM handles definitions for the most part - 
> putting them at the global scope.
> 
> Though I'm confused by this patch - it has a source change in clang, but a 
> test in LLVM. Generally there should be testing to cover where the source 
> change is, I think?
yep, there should be a test for this - added now. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167



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


  1   2   >