[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 202888.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -765,6 +766,70 @@
  {std::string("bool"), std::string("T"), std::string("false")},
  };
}},
+  // Pointers to lambdas
+  {R"cpp(
+void foo() {
+  auto lamb = [](int T, bool B) -> bool { return T && B; };
+  auto *b = 
+  auto *[[^c]] = 
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Name = "c";
+ HI.Kind = SymbolKind::Variable;
+ HI.Definition = "auto *c = ";
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
+ return HI;
+   }},
+  // Lambda parameter with decltype reference
+  {R"cpp(
+auto lamb = [](int T, bool B) -> bool { return T && B; };
+void foo(decltype(lamb)& bar) {
+  [[ba^r]](0, false);
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Name = "bar";
+ HI.Kind = SymbolKind::Variable;
+ HI.Definition = "decltype(lamb) ";
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
+ return HI;
+   }},
+  // Lambda parameter with decltype
+  {R"cpp(
+auto lamb = [](int T, bool B) -> bool { return T && B; };
+void foo(decltype(lamb) bar) {
+  [[ba^r]](0, false);
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Name = "bar";
+ HI.Kind = SymbolKind::Variable;
+ HI.Definition = "decltype(lamb) bar";
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
+ return HI;
+   }},
   // Lambda variable
   {R"cpp(
 void foo() {
@@ -779,7 +844,12 @@
  HI.Name = "lamb";
  HI.Kind = SymbolKind::Variable;
  HI.Definition = "auto lamb = [](int T, bool B) -> bool {}";
- HI.Type = std::string("class (lambda)");
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
  return HI;
}},
   // Local variable in lambda
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -18,7 +18,9 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
@@ -619,6 +621,21 @@
  CharSourceRange::getCharRange(Loc, End));
 }
 
+static const FunctionDecl *getUnderlyingFunction(const Decl *D) {
+  // Extract lambda from variables.
+  if (const VarDecl *VD = llvm::dyn_cast(D)) {
+auto QT = VD->getType();
+while (!QT->getPointeeType().isNull())
+  QT = QT->getPointeeType();
+
+if (const auto *CD = QT->getAsCXXRecordDecl())
+  return CD->getLambdaCallOperator();
+  }
+
+  // Non-lambda functions.
+  return D->getAsFunction();
+}
+
 /// Generate a \p Hover object given the declaration \p D.
 static HoverInfo getHoverContents(const Decl *D) {
   HoverInfo HI;
@@ -653,13 +670,15 @@
   }
 
   // Fill in types and params.
-  if (const FunctionDecl *FD = D->getAsFunction()) {
+  if (const FunctionDecl *FD = getUnderlyingFunction(D)) {
 HI.ReturnType.emplace();
 llvm::raw_string_ostream OS(*HI.ReturnType);
 

[PATCH] D48116: [libclang] Allow skipping warnings from all included files

2019-06-04 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D48116



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


[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 4 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:819
 )cpp",
[](HoverInfo ) {
  HI.NamespaceScope = "";

sammccall wrote:
> I'm slightly nervous about the fact that "lambda" doesn't appear anywhere 
> here.
> 
> e.g. maybe the Type should be " bool(int, bool)" or so?
> Many lambdas are not interchangeable with "plain" functions references.
I've added the textual info to type. I don't think it is useful enough to put 
it as semantic info into the struct.

I believe it is rather a visual cue to the user, which seems pretty available 
in the "Type" field.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:831
+ };
  return HI;
}},

ilya-biryukov wrote:
> Could you add another test with even weirder types where we fail to show the 
> signature? To make sure we don't break when reaching the limitations of the 
> chosen approach and document what those limitations are.
> 
> Something like:
> ```
> auto a = [](int a) { return 10; };
> auto *b = 
> auto *c = 
> ```
> 
> We would fail to show the signature here, but it's totally ok to ignore it.
added cases, and changed code(a lot simpler now) to generate signatures for 
those cases as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814



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


[PATCH] D62591: [OpenCL][PR42031] Prevent deducing addr space in type alias.

2019-06-04 Thread Marco Antognini via Phabricator via cfe-commits
mantognini accepted this revision.
mantognini added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D62591



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


r362479 - [CodeComplete] Include more text into typed chunks of pattern completions

2019-06-04 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jun  4 02:26:08 2019
New Revision: 362479

URL: http://llvm.org/viewvc/llvm-project?rev=362479=rev
Log:
[CodeComplete] Include more text into typed chunks of pattern completions

Summary:
To allow filtering on any of the words in the editors.
In particular, the following completions were changed:
- 'using namespace <#name#>'
  Typed text before: 'using', after: 'using namespace'.
- 'else if (#)'
  Before: 'else', after: 'else if'.
- 'using typename <#qualifier#>::<#name#>'
  Before: 'using', after: 'using typename'.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
cfe/trunk/test/CodeCompletion/ordinary-name.cpp
cfe/trunk/test/Index/complete-stmt.c

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=362479=362478=362479=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Jun  4 02:26:08 2019
@@ -1919,9 +1919,7 @@ static void AddOrdinaryNameResults(Sema:
   Results.AddResult(Result(Builder.TakeString()));
 
   // Using directives
-  Builder.AddTypedTextChunk("using");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("namespace");
+  Builder.AddTypedTextChunk("using namespace");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("identifier");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -1964,9 +1962,7 @@ static void AddOrdinaryNameResults(Sema:
 
   // using typename qualifier::name (only in a dependent context)
   if (SemaRef.CurContext->isDependentContext()) {
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("typename");
+Builder.AddTypedTextChunk("using typename");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("qualifier");
 Builder.AddTextChunk("::");
@@ -2236,9 +2232,7 @@ static void AddOrdinaryNameResults(Sema:
 Results.AddResult(Result(Builder.TakeString()));
 
 // Using directives
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("namespace");
+Builder.AddTypedTextChunk("using namespace");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("identifier");
 Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -5201,9 +5195,7 @@ void Sema::CodeCompleteAfterIf(Scope *S)
   Results.AddResult(Builder.TakeString());
 
   // "else if" block
-  Builder.AddTypedTextChunk("else");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("if");
+  Builder.AddTypedTextChunk("else if");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
   if (getLangOpts().CPlusPlus)

Modified: cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp?rev=362479=362478=362479=diff
==
--- cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp (original)
+++ cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp Tue Jun  4 02:26:08 
2019
@@ -112,8 +112,8 @@ void foo() {
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
   // CHECK-CC2-NEXT: COMPLETION: wchar_t

Modified: cfe/trunk/test/CodeCompletion/ordinary-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name.cpp?rev=362479=362478=362479=diff
==
--- cfe/trunk/test/CodeCompletion/ordinary-name.cpp (original)
+++ cfe/trunk/test/CodeCompletion/ordinary-name.cpp Tue Jun  4 02:26:08 2019
@@ -102,8 +102,8 @@ void foo() {
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using 

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 202908.
serge-sans-paille added a comment.

- reorder registration to make sure options are correctly taken into account
- make LINK_POLLY_INTO_TOOLS obsolete in favor of just using 
LLVM_LINK_POLLY_INTO_TOOLS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446

Files:
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/CMakeLists.txt
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -162,6 +162,11 @@
 
 add_definitions( -D_GNU_SOURCE )
 
+
+register_llvm_extension(Polly)
+# Polly-ACC requires the NVPTX target to be present in the executable it is linked to
+set_property(TARGET bugpoint APPEND PROPERTY LLVM_COMPILER_EXTENSIONS LLVMTarget)
+
 add_subdirectory(docs)
 add_subdirectory(lib)
 

[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Is the compiler missing a check that these parameters are immediates?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362481: [clangd] Support offsets for parameters in 
signatureHelp (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62476?vs=201493=202884#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62476

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
  clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -314,6 +314,14 @@
 }
   }
 }
+if (auto *Help = TextDocument->getObject("signatureHelp")) {
+  if (auto *Info = Help->getObject("signatureInformation")) {
+if (auto *Parameter = Info->getObject("parameterInformation")) {
+  if (auto OffsetSupport = Parameter->getBoolean("labelOffsetSupport"))
+R.OffsetsInSignatureHelp = *OffsetSupport;
+}
+  }
+}
   }
   if (auto *Workspace = O->getObject("workspace")) {
 if (auto *Symbol = Workspace->getObject("symbol")) {
@@ -824,8 +832,14 @@
 }
 
 llvm::json::Value toJSON(const ParameterInformation ) {
-  assert(!PI.label.empty() && "parameter information label is required");
-  llvm::json::Object Result{{"label", PI.label}};
+  assert(PI.labelOffsets.hasValue() ||
+ !PI.labelString.empty() && "parameter information label is required");
+  llvm::json::Object Result;
+  if (PI.labelOffsets)
+Result["label"] =
+llvm::json::Array({PI.labelOffsets->first, PI.labelOffsets->second});
+  else
+Result["label"] = PI.labelString;
   if (!PI.documentation.empty())
 Result["documentation"] = PI.documentation;
   return std::move(Result);
Index: clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
===
--- clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
+++ clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
@@ -0,0 +1,50 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+# Start a session.
+{
+  "jsonrpc": "2.0",
+  "id": 0,
+  "method": "initialize",
+  "params": {
+"processId": 123,
+"rootPath": "clangd",
+"capabilities": {
+  "textDocument": {
+"signatureHelp": {
+  "signatureInformation": {
+"parameterInformation": {
+  "labelOffsetSupport": true
+}
+  }
+}
+  }
+},
+"trace": "off"
+  }
+}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void x(int);\nint main(){\nx("}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":2}}}
+#  CHECK: "id": 1,
+# CHECK-NEXT: "jsonrpc": "2.0",
+# CHECK-NEXT: "result": {
+# CHECK-NEXT:   "activeParameter": 0,
+# CHECK-NEXT:   "activeSignature": 0,
+# CHECK-NEXT:   "signatures": [
+# CHECK-NEXT: {
+# CHECK-NEXT:   "label": "x(int) -> void",
+# CHECK-NEXT:   "parameters": [
+# CHECK-NEXT: {
+# CHECK-NEXT:   "label": [
+# CHECK-NEXT: 2,
+# CHECK-NEXT: 5
+# CHECK-NEXT:]
+# CHECK-NEXT: }
+# CHECK-NEXT:   ]
+# CHECK-NEXT: }
+# CHECK-NEXT:   ]
+# CHECK-NEXT: }
+---
+{"jsonrpc":"2.0","id":10,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -28,6 +28,7 @@
 #include "FuzzyMatch.h"
 #include "Headers.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "Quality.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
@@ -56,6 +57,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
@@ -148,46 +150,6 @@
   llvm_unreachable("Unhandled CodeCompletionResult::ResultKind.");
 }
 
-/// Get the optional chunk as a string. This function is possibly recursive.
-///
-/// The parameter info for each parameter is appended to the Parameters.
-std::string 

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@beanz turns out the depdendency problem was just a matter of moving the 
`register_llvm_extension` call at the top of the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@philip.pfaffe : NewPM integeration actually works thanks to 
``Register${Name}Passes(llvm::PassBuilder )``. It's already used by Polly 
for NewPM integration and we mimic that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



___
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-06-04 Thread Pierre via Phabricator via cfe-commits
Pierre added a comment.

In D60763#1527870 , @thakis wrote:

> From what I can tell, the only client of OpenCLBuiltins.td is currently 
> lib/Sema. Do you expect that to change? If not, does it make more sense to 
> move the .td file to there?
>
> Do you expect OpenCLBuiltins.td to include other files in the future? At the 
> moment, the `-I ${CMAKE_CURRENT_SOURCE_DIR}/../../` bit in the cmake file 
> isn't needed for anything.


OpenCLBuiltins.td is currently only targeting lib/Sema and will be moved there.
 OpenCLBuiltins.td is not expected to include other files, this will be changed 
aswell.


Repository:
  rL LLVM

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] D62615: [CodeComplete] Include more text into typed chunks of pattern completions

2019-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362479: [CodeComplete] Include more text into typed chunks 
of pattern completions (authored by ibiryukov, committed by ).
Herald added subscribers: llvm-commits, arphaman.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D62615?vs=202001=202880#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62615

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
  cfe/trunk/test/CodeCompletion/ordinary-name.cpp
  cfe/trunk/test/Index/complete-stmt.c


Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -1919,9 +1919,7 @@
   Results.AddResult(Result(Builder.TakeString()));
 
   // Using directives
-  Builder.AddTypedTextChunk("using");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("namespace");
+  Builder.AddTypedTextChunk("using namespace");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("identifier");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -1964,9 +1962,7 @@
 
   // using typename qualifier::name (only in a dependent context)
   if (SemaRef.CurContext->isDependentContext()) {
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("typename");
+Builder.AddTypedTextChunk("using typename");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("qualifier");
 Builder.AddTextChunk("::");
@@ -2236,9 +2232,7 @@
 Results.AddResult(Result(Builder.TakeString()));
 
 // Using directives
-Builder.AddTypedTextChunk("using");
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddTextChunk("namespace");
+Builder.AddTypedTextChunk("using namespace");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("identifier");
 Builder.AddChunk(CodeCompletionString::CK_SemiColon);
@@ -5201,9 +5195,7 @@
   Results.AddResult(Builder.TakeString());
 
   // "else if" block
-  Builder.AddTypedTextChunk("else");
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-  Builder.AddTextChunk("if");
+  Builder.AddTypedTextChunk("else if");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddChunk(CodeCompletionString::CK_LeftParen);
   if (getLangOpts().CPlusPlus)
Index: cfe/trunk/test/Index/complete-stmt.c
===
--- cfe/trunk/test/Index/complete-stmt.c
+++ cfe/trunk/test/Index/complete-stmt.c
@@ -9,11 +9,11 @@
 
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test 
-code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE %s
 // CHECK-IF-ELSE: NotImplemented:{TypedText else}{HorizontalSpace  }{LeftBrace 
{}{VerticalSpace  }{Placeholder statements}{VerticalSpace  }{RightBrace }} (40)
-// CHECK-IF-ELSE: NotImplemented:{TypedText else}{HorizontalSpace  }{Text 
if}{HorizontalSpace  }{LeftParen (}{Placeholder expression}{RightParen 
)}{HorizontalSpace  }{LeftBrace {}{VerticalSpace  }{Placeholder 
statements}{VerticalSpace  }{RightBrace }} (40)
+// CHECK-IF-ELSE: NotImplemented:{TypedText else if}{HorizontalSpace  
}{LeftParen (}{Placeholder expression}{RightParen )}{HorizontalSpace  
}{LeftBrace {}{VerticalSpace  }{Placeholder statements}{VerticalSpace  
}{RightBrace }} (40)
 
 // RUN: c-index-test -code-completion-at=%s:7:4 %s | FileCheck 
-check-prefix=CHECK-IF-ELSE-SIMPLE %s
 // CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else} (40)
-// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else}{HorizontalSpace  
}{Text if}{HorizontalSpace  }{LeftParen (}{Placeholder expression}{RightParen 
)} (40)
+// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else if}{HorizontalSpace  
}{LeftParen (}{Placeholder expression}{RightParen )} (40)
 
 // RUN: c-index-test -code-completion-at=%s:6:1 %s | FileCheck 
-check-prefix=CHECK-STMT %s
 // CHECK-STMT: NotImplemented:{TypedText _Nonnull} (50)
Index: cfe/trunk/test/CodeCompletion/ordinary-name.cpp
===
--- cfe/trunk/test/CodeCompletion/ordinary-name.cpp
+++ cfe/trunk/test/CodeCompletion/ordinary-name.cpp
@@ -102,8 +102,8 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: 

[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop created this revision.
russell.gallop added reviewers: craig.topper, cfe-commits.
russell.gallop added a project: clang.

Some of these test cases were using a variable instead of a literal so were not 
generating the immediate form of the corresponding instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62850

Files:
  clang/test/CodeGen/builtins-x86.c


Index: clang/test/CodeGen/builtins-x86.c
===
--- clang/test/CodeGen/builtins-x86.c
+++ clang/test/CodeGen/builtins-x86.c
@@ -399,14 +399,14 @@
 #ifndef OPENCL
   (void) _mm_pause();
 #endif
-  tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, tmp_i);
-  tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, tmp_i);
-  tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, tmp_i);
-  tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, tmp_i);
-  tmp_V2i = __builtin_ia32_psradi(tmp_V2i, tmp_i);
-  tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, tmp_i);
-  tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, tmp_i);
-  tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, tmp_i);
+  tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psradi(tmp_V2i, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, imm_i_0_8);
   tmp_V1LLi = __builtin_ia32_pmuludq(tmp_V2i, tmp_V2i);
   tmp_V2LLi = __builtin_ia32_pmuludq128(tmp_V4i, tmp_V4i);
   tmp_V8s = __builtin_ia32_psraw128(tmp_V8s, tmp_V8s);
@@ -417,14 +417,14 @@
   tmp_V8s = __builtin_ia32_psllw128(tmp_V8s, tmp_V8s);
   tmp_V4i = __builtin_ia32_pslld128(tmp_V4i, tmp_V4i);
   tmp_V2LLi = __builtin_ia32_psllq128(tmp_V2LLi, tmp_V2LLi);
-  tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, tmp_i);
-  tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, tmp_i);
-  tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, tmp_i);
-  tmp_V8s = __builtin_ia32_psrlwi128(tmp_V8s, tmp_i);
-  tmp_V4i = __builtin_ia32_psrldi128(tmp_V4i, tmp_i);
-  tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, tmp_i);
-  tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, tmp_i);
-  tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, tmp_i);
+  tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, imm_i_0_8);
+  tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, imm_i_0_8);
+  tmp_V8s = __builtin_ia32_psrlwi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_psrldi128(tmp_V4i, imm_i_0_8);
+  tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, imm_i_0_8);
+  tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, imm_i_0_8);
   tmp_V4i = __builtin_ia32_pmaddwd128(tmp_V8s, tmp_V8s);
   (void) __builtin_ia32_monitor(tmp_vp, tmp_Ui, tmp_Ui);
   (void) __builtin_ia32_mwait(tmp_Ui, tmp_Ui);


Index: clang/test/CodeGen/builtins-x86.c
===
--- clang/test/CodeGen/builtins-x86.c
+++ clang/test/CodeGen/builtins-x86.c
@@ -399,14 +399,14 @@
 #ifndef OPENCL
   (void) _mm_pause();
 #endif
-  tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, tmp_i);
-  tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, tmp_i);
-  tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, tmp_i);
-  tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, tmp_i);
-  tmp_V2i = __builtin_ia32_psradi(tmp_V2i, tmp_i);
-  tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, tmp_i);
-  tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, tmp_i);
-  tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, tmp_i);
+  tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psradi(tmp_V2i, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, imm_i_0_8);
   tmp_V1LLi = __builtin_ia32_pmuludq(tmp_V2i, tmp_V2i);
   tmp_V2LLi = __builtin_ia32_pmuludq128(tmp_V4i, tmp_V4i);
   tmp_V8s = __builtin_ia32_psraw128(tmp_V8s, tmp_V8s);
@@ -417,14 +417,14 @@
   tmp_V8s = __builtin_ia32_psllw128(tmp_V8s, tmp_V8s);
   tmp_V4i = __builtin_ia32_pslld128(tmp_V4i, tmp_V4i);
   tmp_V2LLi = __builtin_ia32_psllq128(tmp_V2LLi, tmp_V2LLi);
-  tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, tmp_i);
-  tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, tmp_i);
-  tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, tmp_i);
-  tmp_V8s = __builtin_ia32_psrlwi128(tmp_V8s, tmp_i);
-  tmp_V4i = __builtin_ia32_psrldi128(tmp_V4i, tmp_i);
-  tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, tmp_i);
-  tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, tmp_i);
-  tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, tmp_i);
+  tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, 

[clang-tools-extra] r362489 - Fix Wshadow warning

2019-06-04 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jun  4 04:11:51 2019
New Revision: 362489

URL: http://llvm.org/viewvc/llvm-project?rev=362489=rev
Log:
Fix Wshadow warning

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

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=362489=362488=362489=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jun  4 04:11:51 2019
@@ -771,8 +771,8 @@ void ClangdLSPServer::onSignatureHelp(co
 return Reply(std::move(*Signature));
   // Strip out the offsets from signature help for
   // clients that only support string labels.
-  for (auto  : Signature->signatures) {
-for (auto  : Signature.parameters)
+  for (auto  : Signature->signatures) {
+for (auto  : SigInfo.parameters)
   Param.labelOffsets.reset();
   }
   return Reply(std::move(*Signature));


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


[PATCH] D62855: Implementation of auto type expansion.

2019-06-04 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel created this revision.
kuhnel added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, mgorny.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62855

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.h
  clang-tools-extra/clangd/test/code-action-request.test
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1971,6 +1971,28 @@
   }
 }
 
+TEST(GetDeductedType, KwAutoExpansion) {
+  struct Test {
+StringRef AnnotatedCode;
+const char *DeductedType;
+  } Tests[] = {
+  {"^auto i = 0;", "int"},
+  {"^auto f(){ return 1;};", "int"}
+  };
+  for (Test T : Tests) {
+Annotations File(T.AnnotatedCode);
+auto AST = TestTU::withCode(File.code()).build();
+ASSERT_TRUE(AST.getDiagnostics().empty()) << AST.getDiagnostics().begin()->Message;
+SourceManagerForFile SM("foo.cpp", File.code());
+
+for (Position Pos : File.points()) {
+  auto Location = sourceLocationInMainFile(SM.get(), Pos);
+  auto DeducedType = getDeducedType(AST, *Location);
+  EXPECT_EQ(DeducedType->getAsString(), T.DeductedType);
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -19,6 +19,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include "refactor/tweaks/ExpandAutoType.h"
 
 using llvm::Failed;
 using llvm::HasValue;
@@ -217,6 +218,111 @@
   checkTransform(ID, Input, Output);
 }
 
+TEST(TweakTest, ExpandAutoType) {
+  llvm::StringLiteral ID = "ExpandAutoType";
+
+  checkAvailable(ID, R"cpp(
+^a^u^t^o^ i = 0;
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+auto ^i^ ^=^ ^0^;^
+  )cpp");
+
+  llvm::StringLiteral Input = R"cpp(
+[[auto]] i = 0;
+  )cpp";
+  llvm::StringLiteral Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check primitive type
+  Input = R"cpp(
+au^to i = 0;
+  )cpp";
+  Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check classes and namespaces
+  Input = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+^auto C = testns::TestClass::SubClass();
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+testns::TestClass::SubClass C = testns::TestClass::SubClass();
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check that namespaces are shortened
+  Input = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { ^auto C = TestClass(); }
+}
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { TestClass C = TestClass(); }
+}
+  )cpp";
+  checkTransform(ID, Input, Output);
+}
+
+TEST(ExpandAutoType, GetNamespaceString) {
+  struct EATWrapper : ExpandAutoType {
+// to access the protected method
+using ExpandAutoType::getNamespaceString;
+  };
+  TestTU TU;
+  TU.Filename = "foo.cpp";
+  Annotations Code("namespace firstns{namespace secondns{ au^to i = 0;} }");
+  TU.Code = Code.code();
+  ParsedAST AST = TU.build();
+  ASSERT_TRUE(AST.getDiagnostics().empty());
+  auto Tree = SelectionTree(AST.getASTContext(), 
+*positionToOffset(Code.code(), Code.point()));
+  ASSERT_EQ("firstns::secondns", EATWrapper::getNamespaceString(Tree.commonAncestor()));
+}
+
+TEST(ExpandAutoType, ShortenNamespace) {
+  struct EATWrapper : ExpandAutoType {
+// to access the protected method
+using ExpandAutoType::shortenNamespace;
+  };
+
+  ASSERT_EQ("TestClass", 
+  EATWrapper::shortenNamespace("TestClass", ""));
+  
+  ASSERT_EQ("TestClass", 
+  EATWrapper::shortenNamespace("testnamespace::TestClass", "testnamespace"));
+  
+  ASSERT_EQ("namespace1::TestClass",
+  EATWrapper::shortenNamespace("namespace1::TestClass", "namespace2"));
+  
+  ASSERT_EQ("TestClass",
+  EATWrapper::shortenNamespace("testns1::testns2::TestClass", "testns1::testns2"));
+  
+  ASSERT_EQ(
+  "testns2::TestClass",
+  EATWrapper::shortenNamespace("testns1::testns2::TestClass", "testns1"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
+

[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

.. or?
Is this fixing a current test failure?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[clang-tools-extra] r362491 - Fix -Wparentheses warning. NFCI.

2019-06-04 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jun  4 04:31:45 2019
New Revision: 362491

URL: http://llvm.org/viewvc/llvm-project?rev=362491=rev
Log:
Fix -Wparentheses warning. NFCI.

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

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=362491=362490=362491=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Tue Jun  4 04:31:45 2019
@@ -832,8 +832,8 @@ llvm::json::Value toJSON(const Completio
 }
 
 llvm::json::Value toJSON(const ParameterInformation ) {
-  assert(PI.labelOffsets.hasValue() ||
- !PI.labelString.empty() && "parameter information label is required");
+  assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
+ "parameter information label is required");
   llvm::json::Object Result;
   if (PI.labelOffsets)
 Result["label"] =


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


Re: [clang-tools-extra] r362491 - Fix -Wparentheses warning. NFCI.

2019-06-04 Thread Ilya Biryukov via cfe-commits
Thanks! And sorry about this in the first place, I did not have this
warning enabled locally.

On Tue, Jun 4, 2019 at 1:28 PM Simon Pilgrim via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rksimon
> Date: Tue Jun  4 04:31:45 2019
> New Revision: 362491
>
> URL: http://llvm.org/viewvc/llvm-project?rev=362491=rev
> Log:
> Fix -Wparentheses warning. NFCI.
>
> Modified:
> clang-tools-extra/trunk/clangd/Protocol.cpp
>
> Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=362491=362490=362491=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
> +++ clang-tools-extra/trunk/clangd/Protocol.cpp Tue Jun  4 04:31:45 2019
> @@ -832,8 +832,8 @@ llvm::json::Value toJSON(const Completio
>  }
>
>  llvm::json::Value toJSON(const ParameterInformation ) {
> -  assert(PI.labelOffsets.hasValue() ||
> - !PI.labelString.empty() && "parameter information label is
> required");
> +  assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) &&
> + "parameter information label is required");
>llvm::json::Object Result;
>if (PI.labelOffsets)
>  Result["label"] =
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> .. or?

I'm not sure what you mean.

> Is this fixing a current test failure?

No. The test is not failing, but it is not doing what was intended as these 
builtins are for generating the immediate form of the corresponding instruction 
and they were generating actually generating a register form.

This test doesn't check the instructions generated are correct, but fixing that 
is a bigger task...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[clang-tools-extra] r362481 - [clangd] Support offsets for parameters in signatureHelp

2019-06-04 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jun  4 02:36:59 2019
New Revision: 362481

URL: http://llvm.org/viewvc/llvm-project?rev=362481=rev
Log:
[clangd] Support offsets for parameters in signatureHelp

Summary: Added to LSP in version 3.14

Reviewers: hokein

Reviewed By: hokein

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Added:
clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=362481=362480=362481=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jun  4 02:36:59 2019
@@ -360,6 +360,7 @@ void ClangdLSPServer::onInitialize(const
   Params.capabilities.HierarchicalDocumentSymbol;
   SupportFileStatus = Params.initializationOptions.FileStatus;
   HoverContentFormat = Params.capabilities.HoverContentFormat;
+  SupportsOffsetsInSignatureHelp = Params.capabilities.OffsetsInSignatureHelp;
   llvm::json::Object Result{
   {{"capabilities",
 llvm::json::Object{
@@ -761,7 +762,22 @@ void ClangdLSPServer::onCompletion(const
 void ClangdLSPServer::onSignatureHelp(const TextDocumentPositionParams ,
   Callback Reply) {
   Server->signatureHelp(Params.textDocument.uri.file(), Params.position,
-std::move(Reply));
+Bind(
+[this](decltype(Reply) Reply,
+   llvm::Expected Signature) {
+  if (!Signature)
+return Reply(Signature.takeError());
+  if (SupportsOffsetsInSignatureHelp)
+return Reply(std::move(*Signature));
+  // Strip out the offsets from signature help for
+  // clients that only support string labels.
+  for (auto  : Signature->signatures) {
+for (auto  : Signature.parameters)
+  Param.labelOffsets.reset();
+  }
+  return Reply(std::move(*Signature));
+},
+std::move(Reply)));
 }
 
 // Go to definition has a toggle function: if def and decl are distinct, then

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=362481=362480=362481=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Jun  4 02:36:59 2019
@@ -156,8 +156,9 @@ private:
   bool SupportFileStatus = false;
   /// Which kind of markup should we use in textDocument/hover responses.
   MarkupKind HoverContentFormat = MarkupKind::PlainText;
-
-  /// Store of the current versions of the open documents.
+  /// Whether the client supports offsets for parameter info labels.
+  bool SupportsOffsetsInSignatureHelp = false;
+  // Store of the current versions of the open documents.
   DraftStore DraftMgr;
 
   // The CDB is created by the "initialize" LSP method.

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=362481=362480=362481=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Jun  4 02:36:59 2019
@@ -28,6 +28,7 @@
 #include "FuzzyMatch.h"
 #include "Headers.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "Quality.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
@@ -56,6 +57,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
@@ -148,46 +150,6 @@ toCompletionItemKind(CodeCompletionResul
   llvm_unreachable("Unhandled CodeCompletionResult::ResultKind.");
 }
 
-/// Get the optional chunk as a string. This function is possibly recursive.
-///
-/// The parameter info for each parameter is 

[PATCH] D60691: [ARM] Replace fp-only-sp and d16 with fp64 and d32.

2019-06-04 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked an inline comment as done.
simon_tatham added a comment.

Hmm, yes, I see what you mean. It //looks// to me as if the problem is that 
`llvm::ARM::getFPUFeatures` is setting up a feature list including `+vfp4`, 
`-fp64` and `-d32` just as you'd expect, but when it's called from 
`clang::targets::ARMTargetInfo::initFeatureMap` in particular, that silently 
throws away any feature name in the list that doesn't start with `+`.

I suppose that means `getFPUFeatures` ought to be more careful, and add the 
more restricted feature `vfp4d16sp` in the first place instead of trying to do 
it by adding full `vfp4` and then taking pieces away.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60691



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


[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 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.

Please add a check for the type of variable being not null before landing. The 
other comment is not very important


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814



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


[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:628
+auto QT = VD->getType();
+while (!QT->getPointeeType().isNull())
+  QT = QT->getPointeeType();

We need a check for `!QT.isNull` here



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:831
+ };
  return HI;
}},

kadircet wrote:
> ilya-biryukov wrote:
> > Could you add another test with even weirder types where we fail to show 
> > the signature? To make sure we don't break when reaching the limitations of 
> > the chosen approach and document what those limitations are.
> > 
> > Something like:
> > ```
> > auto a = [](int a) { return 10; };
> > auto *b = 
> > auto *c = 
> > ```
> > 
> > We would fail to show the signature here, but it's totally ok to ignore it.
> added cases, and changed code(a lot simpler now) to generate signatures for 
> those cases as well.
Here's an example when the new approach falls short too:

```
auto a = [](int) { return 10; }
std::function b;
```

In general, are we ok with loosing all the information about the type that we 
drop?
One level of references and pointers seemed ok, dropping more is a bit more 
cheesy..

At the same time, either case is **so** rare that we probably don't care.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814



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


[PATCH] D62623: Reduce memory consumption of coverage dumps

2019-06-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 202896.
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.

Update comment + force reduced memory consumption.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62623

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp


Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1388,10 +1388,19 @@
   std::string FilenamesAndCoverageMappings;
   llvm::raw_string_ostream OS(FilenamesAndCoverageMappings);
   CoverageFilenamesSectionWriter(FilenameRefs).write(OS);
-  std::string RawCoverageMappings =
-  llvm::join(CoverageMappings.begin(), CoverageMappings.end(), "");
-  OS << RawCoverageMappings;
-  size_t CoverageMappingSize = RawCoverageMappings.size();
+
+  // Stream the content of CoverageMappings to OS while keeping
+  // memory consumption under control.
+  size_t CoverageMappingSize = 0;
+  for (auto  : CoverageMappings) {
+CoverageMappingSize += S.size();
+OS << S;
+S.clear();
+S.shrink_to_fit();
+  }
+  CoverageMappings.clear();
+  CoverageMappings.shrink_to_fit();
+
   size_t FilenamesSize = OS.str().size() - CoverageMappingSize;
   // Append extra zeroes if necessary to ensure that the size of the filenames
   // and coverage mappings is a multiple of 8.


Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1388,10 +1388,19 @@
   std::string FilenamesAndCoverageMappings;
   llvm::raw_string_ostream OS(FilenamesAndCoverageMappings);
   CoverageFilenamesSectionWriter(FilenameRefs).write(OS);
-  std::string RawCoverageMappings =
-  llvm::join(CoverageMappings.begin(), CoverageMappings.end(), "");
-  OS << RawCoverageMappings;
-  size_t CoverageMappingSize = RawCoverageMappings.size();
+
+  // Stream the content of CoverageMappings to OS while keeping
+  // memory consumption under control.
+  size_t CoverageMappingSize = 0;
+  for (auto  : CoverageMappings) {
+CoverageMappingSize += S.size();
+OS << S;
+S.clear();
+S.shrink_to_fit();
+  }
+  CoverageMappings.clear();
+  CoverageMappings.shrink_to_fit();
+
   size_t FilenamesSize = OS.str().size() - CoverageMappingSize;
   // Append extra zeroes if necessary to ensure that the size of the filenames
   // and coverage mappings is a multiple of 8.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48866: [clang-tidy] Add incorrect-pointer-cast checker

2019-06-04 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 202913.
steakhal marked 4 inline comments as done.
steakhal added a comment.

- Removed different signess related parts.
- Don't warn for the casts which are already covered by '-Wcast-align' check.
- Improved the diagnostic messages:
  - Now adds notes for the first incompatible members of structs.
  - Added alignment, size and type information to most of the warning messages.


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

https://reviews.llvm.org/D48866

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/IncorrectPointerCastCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/IncorrectPointerCastCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-incorrect-pointer-cast.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-incorrect-pointer-cast.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-incorrect-pointer-cast.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-incorrect-pointer-cast.cpp
@@ -0,0 +1,205 @@
+// RUN: %check_clang_tidy %s bugprone-incorrect-pointer-cast %t -- \
+// RUN:   -config="{CheckOptions: [{key: bugprone-incorrect-pointer-cast.WarnForDifferentSignedness, value: 1}]}" --
+
+bool b;
+char __attribute__((aligned(4))) a[16];
+
+struct S0 {
+  char a[16];
+};
+
+struct S01 {
+  char __attribute__((aligned(4))) a[16];
+  struct S0 __attribute__((aligned(4))) s0;
+};
+
+struct S1 {
+  int a;
+  int b;
+};
+
+struct S2 {
+  int a;
+};
+
+struct S3 {
+  int a;
+  double b;
+};
+
+struct S4 {
+  int x;
+  double y;
+};
+
+struct S5 {
+  double y;
+  int x;
+};
+
+struct __attribute__((aligned(16))) SAligned {
+  char buffer[16];
+};
+
+void initDouble(double *d) {
+  *d = 0.5;
+}
+
+void castCharToInt(void) {
+  char c = 'x';
+  b = (int *) // -Wcast-align already warns for this
+  b = reinterpret_cast(); // -Wcast-align does NOT warn for this
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'char' to 'int' may lead to access memory based on invalid memory layout; new type is wider (1) than the original type (4) [bugprone-incorrect-pointer-cast]
+}
+
+void castCharToSort(char c) {
+  b = (short *) // -Wcast-align already warns for this
+  b = reinterpret_cast(); // -Wcast-align does NOT warn for this
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'char' to 'short' may lead to access memory based on invalid memory layout; new type is wider (1) than the original type (2) [bugprone-incorrect-pointer-cast]
+}
+
+void castShortToInt(short s) {
+  b = (int *) // -Wcast-align already warns for this
+  b = reinterpret_cast(); // -Wcast-align does NOT warn for this
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'short' to 'int' may lead to access memory based on invalid memory layout; new type is wider (2) than the original type (4) [bugprone-incorrect-pointer-cast]
+}
+
+void castWideCharToLong(wchar_t wc) {
+  b = (long *) // -Wcast-align already warns for this
+  b = reinterpret_cast(); // -Wcast-align does NOT warn for this
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'wchar_t' to 'long' may lead to access memory based on invalid memory layout; new type is wider (4) than the original type (8) [bugprone-incorrect-pointer-cast]
+}
+
+void castFloatToDouble(float f) {
+  initDouble((double *)); // -Wcast-align already warns for this
+  initDouble(reinterpret_cast()); // -Wcast-align does NOT warn for this
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: cast from 'float' to 'double' may lead to access memory based on invalid memory layout; new type is wider (4) than the original type (8) [bugprone-incorrect-pointer-cast]
+}
+
+void castToS2(char *data, unsigned offset) {
+  b = (struct S2 *)(data + offset); // -Wcast-align already warns for this
+  b = reinterpret_cast(data + offset); // -Wcast-align does NOT warn for this
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'char' to 'struct S2' may lead to access memory based on invalid memory layout; new type is wider (1) than the original type (4) [bugprone-incorrect-pointer-cast]
+}
+
+void castS3ToS1(struct S3 s3) {
+  b = (struct S1 *)
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'struct S3' to 'struct S1' may lead to access memory based on invalid memory layout; struct members are incompatible [bugprone-incorrect-pointer-cast]
+  // CHECK-MESSAGES: :27:3: note: first incompatible member of S3 is declared here; at 64 bit offset with 16 bit width
+  // CHECK-MESSAGES: :18:3: note: first incompatible member of S1 is declared here; at 32 bit offset with 8 bit width
+
+  b = reinterpret_cast();
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: cast from 'struct S3' to 'struct S1' may lead to access memory based on invalid memory layout; struct 

[PATCH] D48866: [clang-tidy] Add incorrect-pointer-cast checker

2019-06-04 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D48866#1527540 , @lebedev.ri wrote:

> In D48866#1527506 , @steakhal wrote:
>
> > The problem with the `-Wcast-align` is that it will only fire for C-style 
> > bitcast expressions, not for `reinterpret_cast` ones. example 
> > 
> >  Does anyone know why is that behavior?
>
>
> Because `reinterpret_cast` is by definition allowed to perform these casts, 
> so it is assumed that no warning should be issued.
>  This part of the check i look forward to.


I still don't understand why should `-Wcast-align` issue warning only for 
c-style casts. What is the difference in the given example? What are the 
related paragraphs in the standard?
I assume in the example we violated the basic.lval/11 
 paragraph, so neither of those pointers 
are safely dereferencable.

In case we are casting from **char* ** we don't know what is the **dynamic 
type** of the object (same with std::byte, void * etc.). From my point of view 
the style of the cast is not important in this case, only the fact that both 
are performing bitcasts.
Have I missed something?


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

https://reviews.llvm.org/D48866



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


[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2019-06-04 Thread Richard Membarth via Phabricator via cfe-commits
richardmembarth added a comment.

Merging in two weeks is fine for me.

My assumption was that accepted patches are merged into upstream in a timely 
manner.
Maybe this is not how it works?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54258



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


[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D62845#1528791 , @gribozavr wrote:

> I'd suggest to add a separate file that covers the exact language modes 
> needed.
>
> The C++14 test that we have right now is about C++14-or-later, testing the 
> availability of std::make_unique.


The test file name ("modernize-make-unique-cxx14") indicates this test is for 
C++14, and since we change the existing `modernize-make-unique` test (which 
covers more cases) to C++14 or later, I think it is reasonable to restrict the 
`cxx14` test to run only on C++14. or am I missing anything?

> I'm also not sure what the intent behind these tests is. Maybe the right fix 
> is to add a constructor that can be called?

sorry, the check is too complicated to catch up, the test cases are testing the 
code path 
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp#L405.

Unfortunately, adding a default constructor doesn't fix the problem: the AST 
tree is different in C++14/17 and C++2a, which causes different behavior in the 
check.

e.g. `new NoCopyMoveCtor{}`

In C++14/17, it looks like below, the check thinks it is an aggregate 
initialization (with deleted copy/move constructor) and doesn't generate the 
fix.

  |-CXXNewExpr  'NoCopyMoveCtor *' Function 0x5614cfece8f0 
'operator new' 'void *(std::size_t)'
  | `-InitListExpr  'NoCopyMoveCtor'

However, in C++2a, the AST is like below, the check thinks it is a direct 
initialization with default constructor, and generate the fix.

  `-CXXNewExpr  'NoCopyMoveCtor *' Function 0x55c9b1b24ba0 
'operator new' 'void *(std::size_t)'
`-CXXConstructExpr  'NoCopyMoveCtor' 'void () noexcept' 
list zeroing




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845



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


[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D62845#1528887 , @hokein wrote:

> In D62845#1528791 , @gribozavr wrote:
>
> > I'd suggest to add a separate file that covers the exact language modes 
> > needed.
> >
> > The C++14 test that we have right now is about C++14-or-later, testing the 
> > availability of std::make_unique.
>
>
> The test file name ("modernize-make-unique-cxx14") indicates this test is for 
> C++14, and since we change the existing `modernize-make-unique` test (which 
> covers more cases) to C++14 or later, I think it is reasonable to restrict 
> the `cxx14` test to run only on C++14. or am I missing anything?


I think we should be looking at the intent of the test rather than its name.

The intent looks like testing how the check works when `std::make_unique` is 
available from the standard library (as opposed to some kind of replacement 
like `absl::make_unique`).  See the patch that introduced it: 
https://reviews.llvm.org/D43766

So modernize-make-unique-cxx14 is actually "C++14 or later".  (Probably it 
should be renamed.)

>> I'm also not sure what the intent behind these tests is. Maybe the right fix 
>> is to add a constructor that can be called?
> 
> sorry, the check is too complicated to catch up, the test cases are testing 
> the code path 
> https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp#L405.
> 
> Unfortunately, adding a default constructor doesn't fix the problem: the AST 
> tree is different in C++14/17 and C++2a, which causes different behavior in 
> the check.
> 
> e.g. `new NoCopyMoveCtor{}`
> 
> In C++14/17, it looks like below, the check thinks it is an aggregate 
> initialization (with deleted copy/move constructor) and doesn't generate the 
> fix.
> 
>   |-CXXNewExpr  'NoCopyMoveCtor *' Function 0x5614cfece8f0 
> 'operator new' 'void *(std::size_t)'
>   | `-InitListExpr  'NoCopyMoveCtor'
> 
> 
> However, in C++2a, the AST is like below, the check thinks it is a direct 
> initialization with default constructor, and generate the fix.
> 
>   `-CXXNewExpr  'NoCopyMoveCtor *' Function 0x55c9b1b24ba0 
> 'operator new' 'void *(std::size_t)'
> `-CXXConstructExpr  'NoCopyMoveCtor' 'void () 
> noexcept' list zeroing

I see.  Assuming it is desired behavior, I'd say for these cases we should 
create separate files that are specifically run in C++14 and 17, and another 
one for C++2a onward.

But is it desired behavior?  That is, can we generate a call to 
`std::make_unique` in C++14 in practice -- would it compile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845



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


[PATCH] D48866: [clang-tidy] Add incorrect-pointer-cast checker

2019-06-04 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked 8 inline comments as done.
steakhal added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/IncorrectPointerCastCheck.cpp:69-70
+ "cast from %0 to %1 may lead to access memory based on invalid "
+ "memory layout; pointed to type is strictly aligned than the "
+ "allocated type")
+<< SrcPointedType << DestPointedType;

lebedev.ri wrote:
> "*more* strictly aligned" perhaps?
> Similarly, specify the actual values.
Which metrics should I use? Bits or char units? For now I will stick to bits.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/IncorrectPointerCastCheck.cpp:98-107
+  } else if (WarnForDifferentSignedness &&
+ ((SrcPointedType->isSignedIntegerType() &&
+   DestPointedType->isUnsignedIntegerType()) ||
+  (SrcPointedType->isUnsignedIntegerType() &&
+   DestPointedType->isSignedIntegerType( {
+diag(castExpr->getBeginLoc(),
+ "cast from %0 to %1 may lead to access memory based on invalid "

lebedev.ri wrote:
> What does this mean?
> How can signedness affect memory layout?
You are right, signess difference is **explicitly** allowed in bitcasts. It has 
nothing to do with the actual memory layout. I thought it might be useful for 
detecting those cases too. It should be in a different checker in the future.
For now I've removed the related code from this checker.



Comment at: clang-tools-extra/clang-tidy/bugprone/IncorrectPointerCastCheck.h:18
+
+/// Warns for cases when pointer is cast and the pointed to type is 
incompatible
+/// with allocated memory area type. This may lead to access memory based on

lebedev.ri wrote:
> is cast*ed*
> s/pointed to/new/
Casted fixed now.

What do you think about **destination type** and **original type** instead of 
**new type**?



Comment at: clang-tools-extra/clang-tidy/bugprone/IncorrectPointerCastCheck.h:19
+/// Warns for cases when pointer is cast and the pointed to type is 
incompatible
+/// with allocated memory area type. This may lead to access memory based on
+/// invalid memory layout.

lebedev.ri wrote:
> How do you know anything about the actual `allocated memory area type`.
> You probably want to talk about the original type before cast.
You are right, fixed.


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

https://reviews.llvm.org/D48866



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


[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D62845#1529149 , @hokein wrote:

> > I think we should be looking at the intent of the test rather than its name.
> > 
> > The intent looks like testing how the check works when `std::make_unique` 
> > is available from the standard library (as opposed to some kind of 
> > replacement like `absl::make_unique`).  See the patch that introduced it: 
> > https://reviews.llvm.org/D43766
> > 
> > So modernize-make-unique-cxx14 is actually "C++14 or later".  (Probably it 
> > should be renamed.)
>
> yeap, it seems to me that "modernize-make-unique-cxx14" is redundant, 
> "modernize-make-unique" should cover what it tests, I believe. We also have 
> "modernize-make-unique-cxx11" which runs on C++11 mode only, maybe we just 
> repurpose the `modernize-make-unique-cxx14`, what do you think?


Fair enough.

>> I see.  Assuming it is desired behavior, I'd say for these cases we should 
>> create separate files that are specifically run in C++14 and 17, and another 
>> one for C++2a onward.
>> 
>> But is it desired behavior?  That is, can we generate a call to 
>> `std::make_unique` in C++14 in practice -- would it compile?
> 
> The fix is compilable for C++14, but it is tricky to support it:
> 
> 1. `new NoCopyMoveCtor{}`: the `make_unique` fix is compilable
> 2. `new NoCopyMoveCtor{1, 2}`: the `make_unique` fix is not compilable
> 
>   The AST for case 1) and 2)  are the same in C++14,  supporting that would 
> introduce hacky change to the logic here 
> .
>  I'd leave it as-is now.

Indeed, this is complicated.  Could you add tests for `new NoCopyMoveCtor{1, 
2}` with TODOs (the message suggests the user to do the impossible).




Comment at: clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx14.cpp:1
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- 
-- -I %S/Inputs/modernize-smart-ptr
+// RUN: %check_clang_tidy -std=c++14 %s modernize-make-unique %t -- -- -I 
%S/Inputs/modernize-smart-ptr
 

WDYT about merging two tests and adding run lines like this:

```
// RUN: %check_clang_tidy -std=c++14,c++17 -check-suffix=CXX_14_17 %s 
modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -D CXX_14_17=1
// RUN: %check_clang_tidy -std=c++2a -check-suffix=CXX_2A %s 
modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -DCXX_2A=1
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845



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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> Is the compiler missing a check that these parameters are immediates?

I don't think that there can be a check, or this would have been noticed.

I don't know whether this is possible and/or desirable. Do users use one 
version of the builtin and want the compiler to decide whether to use the 
immediate form?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 202940.
hokein marked 2 inline comments as done.
hokein added a comment.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845

Files:
  clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx14.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14,c++17 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
-// FIXME: Fix the test code in C++2a mode.
+// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 #include "initializer_list.h"
@@ -32,37 +31,6 @@
 
 struct Empty {};
 
-struct NoCopyMoveCtor {
-  NoCopyMoveCtor(const NoCopyMoveCtor &) = delete; // implies move ctor is deleted
-};
-
-struct NoCopyMoveCtorVisible {
-private:
-  NoCopyMoveCtorVisible(const NoCopyMoveCtorVisible&) = default;
-  NoCopyMoveCtorVisible(NoCopyMoveCtorVisible&&) = default;
-};
-
-struct OnlyMoveCtor {
-  OnlyMoveCtor() = default;
-  OnlyMoveCtor(OnlyMoveCtor&&) = default;
-  OnlyMoveCtor(const OnlyMoveCtor &) = delete;
-};
-
-struct OnlyCopyCtor {
-  OnlyCopyCtor(const OnlyCopyCtor&) = default;
-  OnlyCopyCtor(OnlyCopyCtor&&) = delete;
-};
-
-struct OnlyCopyCtorVisible {
-  OnlyCopyCtorVisible(const OnlyCopyCtorVisible &) = default;
-
-private:
-  OnlyCopyCtorVisible(OnlyCopyCtorVisible &&) = default;
-};
-
-struct ImplicitDeletedCopyCtor {
-  const OnlyMoveCtor ctor;
-};
 
 struct E {
   E(std::initializer_list);
@@ -314,33 +282,6 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = std::make_unique(Empty{});
 
-  // No fixes for classes with deleted copy constructors.
-  auto PNoCopyMoveCtor = std::unique_ptr(new NoCopyMoveCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use std::make_unique instead
-  // CHECK-FIXES: auto PNoCopyMoveCtor = std::unique_ptr(new NoCopyMoveCtor{});
-
-  auto PNoCopyMoveCtorVisible = std::unique_ptr(new NoCopyMoveCtorVisible{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead
-  // CHECK-FIXES: auto PNoCopyMoveCtorVisible = std::unique_ptr(new NoCopyMoveCtorVisible{});
-
-  auto POnlyMoveCtor = std::unique_ptr(new OnlyMoveCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
-  // CHECK-FIXES: auto POnlyMoveCtor = std::unique_ptr(new OnlyMoveCtor{});
-
-  // Fix for classes with classes with move constructor.
-  auto POnlyCopyCtor = std::unique_ptr(new OnlyCopyCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
-  // CHECK-FIXES: auto POnlyCopyCtor = std::unique_ptr(new OnlyCopyCtor{});
-
-   // Fix for classes with classes with move constructor.
-  auto POnlyCopyCtorVisible = std::unique_ptr(new OnlyCopyCtorVisible{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use std::make_unique instead
-  // CHECK-FIXES: auto POnlyCopyCtorVisible = std::unique_ptr(new OnlyCopyCtorVisible{});
-
-  auto PImplicitDeletedCopyCtor = std::unique_ptr(new ImplicitDeletedCopyCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
-  // CHECK-FIXES: auto PImplicitDeletedCopyCtor = std::unique_ptr(new ImplicitDeletedCopyCtor{});
-
   // Initialization with default constructor.
   std::unique_ptr PE1 = std::unique_ptr(new E{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
Index: clang-tools-extra/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp
@@ -0,0 +1,113 @@
+// RUN: %check_clang_tidy -std=c++14,c++17 -check-suffix=CXX-14-17 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -D CXX_14_17=1
+// RUN: %check_clang_tidy -std=c++2a -check-suffix=CXX-2A %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -D CXX_2A=1
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
+
+struct NoCopyMoveCtor {
+#ifdef CXX_2A
+  // C++2a requires to see the default constructor, otherwise it is illgal.
+  NoCopyMoveCtor() = default;
+#endif
+#ifdef CXX_14_17
+  int a, b;
+#endif
+  NoCopyMoveCtor(const NoCopyMoveCtor &) = delete; // implies move ctor is deleted
+};
+
+struct NoCopyMoveCtorVisible {
+#ifdef CXX_2A
+  NoCopyMoveCtorVisible() = default;
+#endif
+private:
+  NoCopyMoveCtorVisible(const NoCopyMoveCtorVisible&) = default;
+  

[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D62845#1529190 , @gribozavr wrote:

> In D62845#1529149 , @hokein wrote:
>
> > > I think we should be looking at the intent of the test rather than its 
> > > name.
> > > 
> > > The intent looks like testing how the check works when `std::make_unique` 
> > > is available from the standard library (as opposed to some kind of 
> > > replacement like `absl::make_unique`).  See the patch that introduced it: 
> > > https://reviews.llvm.org/D43766
> > > 
> > > So modernize-make-unique-cxx14 is actually "C++14 or later".  (Probably 
> > > it should be renamed.)
> >
> > yeap, it seems to me that "modernize-make-unique-cxx14" is redundant, 
> > "modernize-make-unique" should cover what it tests, I believe. We also have 
> > "modernize-make-unique-cxx11" which runs on C++11 mode only, maybe we just 
> > repurpose the `modernize-make-unique-cxx14`, what do you think?
>
>
> Fair enough.
>
> >> I see.  Assuming it is desired behavior, I'd say for these cases we should 
> >> create separate files that are specifically run in C++14 and 17, and 
> >> another one for C++2a onward.
> >> 
> >> But is it desired behavior?  That is, can we generate a call to 
> >> `std::make_unique` in C++14 in practice -- would it compile?
> > 
> > The fix is compilable for C++14, but it is tricky to support it:
> > 
> > 1. `new NoCopyMoveCtor{}`: the `make_unique` fix is compilable
> > 2. `new NoCopyMoveCtor{1, 2}`: the `make_unique` fix is not compilable
> > 
> >   The AST for case 1) and 2)  are the same in C++14,  supporting that would 
> > introduce hacky change to the logic here 
> > .
> >  I'd leave it as-is now.
>
> Indeed, this is complicated.  Could you add tests for `new NoCopyMoveCtor{1, 
> 2}` with TODOs (the message suggests the user to do the impossible).


Done, but note that adding extra data fields to the `NoCopyMoveCtor` is 
uncompilable in C++2a :(




Comment at: clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx14.cpp:1
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- 
-- -I %S/Inputs/modernize-smart-ptr
+// RUN: %check_clang_tidy -std=c++14 %s modernize-make-unique %t -- -- -I 
%S/Inputs/modernize-smart-ptr
 

gribozavr wrote:
> WDYT about merging two tests and adding run lines like this:
> 
> ```
> // RUN: %check_clang_tidy -std=c++14,c++17 -check-suffix=CXX_14_17 %s 
> modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -D CXX_14_17=1
> // RUN: %check_clang_tidy -std=c++2a -check-suffix=CXX_2A %s 
> modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -DCXX_2A=1
> ```
Good point, done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845



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


r362521 - [CodeGen][ObjC] Convert '[self alloc]' in a class method to a call to

2019-06-04 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue Jun  4 09:29:58 2019
New Revision: 362521

URL: http://llvm.org/viewvc/llvm-project?rev=362521=rev
Log:
[CodeGen][ObjC] Convert '[self alloc]' in a class method to a call to
'objc_alloc(self)'

Also convert '[[self alloc] init]' in a class method to a call to
'objc_alloc_init(self)'.

rdar://problem/50855121

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

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
cfe/trunk/test/CodeGenObjC/objc-alloc-init.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=362521=362520=362521=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Jun  4 09:29:58 2019
@@ -383,10 +383,12 @@ tryGenerateSpecializedMessageSend(CodeGe
 if (isClassMessage &&
 Runtime.shouldUseRuntimeFunctionsForAlloc() &&
 ResultType->isObjCObjectPointerType()) {
-// [Foo alloc] -> objc_alloc(Foo)
+// [Foo alloc] -> objc_alloc(Foo) or
+// [self alloc] -> objc_alloc(self)
 if (Sel.isUnarySelector() && Sel.getNameForSlot(0) == "alloc")
   return CGF.EmitObjCAlloc(Receiver, CGF.ConvertType(ResultType));
-// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo)
+// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo) or
+// [self allocWithZone:nil] -> objc_allocWithZone(self)
 if (Sel.isKeywordSelector() && Sel.getNumArgs() == 1 &&
 Args.size() == 1 && Args.front().getType()->isPointerType() &&
 Sel.getNameForSlot(0) == "allocWithZone") {
@@ -444,22 +446,38 @@ tryEmitSpecializedAllocInit(CodeGenFunct
   Sel.getNameForSlot(0) != "init")
 return None;
 
-  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'.
+  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]' or
+  // we are in an ObjC class method and 'receiver' is '[self alloc]'.
   auto *SubOME =
-  dyn_cast(OME->getInstanceReceiver()->IgnoreParens());
+  
dyn_cast(OME->getInstanceReceiver()->IgnoreParenCasts());
   if (!SubOME)
 return None;
   Selector SubSel = SubOME->getSelector();
-  if (SubOME->getReceiverKind() != ObjCMessageExpr::Class ||
-  !SubOME->getType()->isObjCObjectPointerType() ||
+
+  // Check if we are in an ObjC class method and the receiver expression is
+  // 'self'.
+  const Expr *SelfInClassMethod = nullptr;
+  if (const auto *CurMD = dyn_cast_or_null(CGF.CurFuncDecl))
+if (CurMD->isClassMethod())
+  if ((SelfInClassMethod = SubOME->getInstanceReceiver()))
+if (!SelfInClassMethod->isObjCSelfExpr())
+  SelfInClassMethod = nullptr;
+
+  if ((SubOME->getReceiverKind() != ObjCMessageExpr::Class &&
+   !SelfInClassMethod) || !SubOME->getType()->isObjCObjectPointerType() ||
   !SubSel.isUnarySelector() || SubSel.getNameForSlot(0) != "alloc")
 return None;
 
-  QualType ReceiverType = SubOME->getClassReceiver();
-  const ObjCObjectType *ObjTy = ReceiverType->getAs();
-  const ObjCInterfaceDecl *ID = ObjTy->getInterface();
-  assert(ID && "null interface should be impossible here");
-  llvm::Value *Receiver = CGF.CGM.getObjCRuntime().GetClass(CGF, ID);
+  llvm::Value *Receiver;
+  if (SelfInClassMethod) {
+Receiver = CGF.EmitScalarExpr(SelfInClassMethod);
+  } else {
+QualType ReceiverType = SubOME->getClassReceiver();
+const ObjCObjectType *ObjTy = ReceiverType->getAs();
+const ObjCInterfaceDecl *ID = ObjTy->getInterface();
+assert(ID && "null interface should be impossible here");
+Receiver = CGF.CGM.getObjCRuntime().GetClass(CGF, ID);
+  }
   return CGF.EmitObjCAllocInit(Receiver, CGF.ConvertType(OME->getType()));
 }
 
@@ -507,6 +525,10 @@ RValue CodeGenFunction::EmitObjCMessageE
   switch (E->getReceiverKind()) {
   case ObjCMessageExpr::Instance:
 ReceiverType = E->getInstanceReceiver()->getType();
+if (auto *OMD = dyn_cast_or_null(CurFuncDecl))
+  if (OMD->isClassMethod())
+if (E->getInstanceReceiver()->isObjCSelfExpr())
+  isClassMessage = true;
 if (retainSelf) {
   TryEmitResult ter = tryEmitARCRetainScalarExpr(*this,
E->getInstanceReceiver());

Modified: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m?rev=362521=362520=362521=diff
==
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m (original)
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m Tue Jun  4 
09:29:58 2019
@@ -150,6 +150,34 @@ float test_cannot_message_return_float(C
   return [c retain];
 }
 
+@interface TestSelf
++ 

[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

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

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -765,6 +766,70 @@
  {std::string("bool"), std::string("T"), std::string("false")},
  };
}},
+  // Pointers to lambdas
+  {R"cpp(
+void foo() {
+  auto lamb = [](int T, bool B) -> bool { return T && B; };
+  auto *b = 
+  auto *[[^c]] = 
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Name = "c";
+ HI.Kind = SymbolKind::Variable;
+ HI.Definition = "auto *c = ";
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
+ return HI;
+   }},
+  // Lambda parameter with decltype reference
+  {R"cpp(
+auto lamb = [](int T, bool B) -> bool { return T && B; };
+void foo(decltype(lamb)& bar) {
+  [[ba^r]](0, false);
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Name = "bar";
+ HI.Kind = SymbolKind::Variable;
+ HI.Definition = "decltype(lamb) ";
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
+ return HI;
+   }},
+  // Lambda parameter with decltype
+  {R"cpp(
+auto lamb = [](int T, bool B) -> bool { return T && B; };
+void foo(decltype(lamb) bar) {
+  [[ba^r]](0, false);
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.LocalScope = "foo::";
+ HI.Name = "bar";
+ HI.Kind = SymbolKind::Variable;
+ HI.Definition = "decltype(lamb) bar";
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
+ return HI;
+   }},
   // Lambda variable
   {R"cpp(
 void foo() {
@@ -779,7 +844,12 @@
  HI.Name = "lamb";
  HI.Kind = SymbolKind::Variable;
  HI.Definition = "auto lamb = [](int T, bool B) -> bool {}";
- HI.Type = std::string("class (lambda)");
+ HI.Type = " bool(int, bool)";
+ HI.ReturnType = "bool";
+ HI.Parameters = {
+ {std::string("int"), std::string("T"), llvm::None},
+ {std::string("bool"), std::string("B"), llvm::None},
+ };
  return HI;
}},
   // Local variable in lambda
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -19,7 +19,9 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
@@ -620,6 +622,23 @@
  CharSourceRange::getCharRange(Loc, End));
 }
 
+static const FunctionDecl *getUnderlyingFunction(const Decl *D) {
+  // Extract lambda from variables.
+  if (const VarDecl *VD = llvm::dyn_cast(D)) {
+auto QT = VD->getType();
+if (!QT.isNull()) {
+  while (!QT->getPointeeType().isNull())
+QT = QT->getPointeeType();
+
+  if (const auto *CD = QT->getAsCXXRecordDecl())
+return CD->getLambdaCallOperator();
+}
+  }
+
+  // Non-lambda functions.
+  return D->getAsFunction();
+}
+
 /// Generate a \p Hover object given the declaration \p D.
 static HoverInfo getHoverContents(const Decl *D) {
   HoverInfo HI;
@@ -654,13 +673,15 @@
   }
 
   // Fill in types and params.
-  if (const FunctionDecl *FD = D->getAsFunction()) {
+  if (const FunctionDecl *FD = getUnderlyingFunction(D)) {
 

[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:831
+ };
  return HI;
}},

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > Could you add another test with even weirder types where we fail to show 
> > > the signature? To make sure we don't break when reaching the limitations 
> > > of the chosen approach and document what those limitations are.
> > > 
> > > Something like:
> > > ```
> > > auto a = [](int a) { return 10; };
> > > auto *b = 
> > > auto *c = 
> > > ```
> > > 
> > > We would fail to show the signature here, but it's totally ok to ignore 
> > > it.
> > added cases, and changed code(a lot simpler now) to generate signatures for 
> > those cases as well.
> Here's an example when the new approach falls short too:
> 
> ```
> auto a = [](int) { return 10; }
> std::function b;
> ```
> 
> In general, are we ok with loosing all the information about the type that we 
> drop?
> One level of references and pointers seemed ok, dropping more is a bit more 
> cheesy..
> 
> At the same time, either case is **so** rare that we probably don't care.
are you talking about hovering over `x` ? I don't think AST contains 
information regarding that one. 

for a code like this:
```
auto foo = []() { return 5; };

template 
class Cls {};

Cls X;
```

This is the AST dump for variable X:
```
`-VarDecl 0x2b0e808  col:30 X 'Cls':'Cls' callinit
  `-CXXConstructExpr 0x2b12e80  'Cls':'Cls' 'void () noexcept'
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D59744#1529182 , @krytarowski wrote:

> In D59744#1527412 , @wxiao3 wrote:
>
> > Consider other Systems (e.g Darwin, PS4 and FreeBSD) don't want to spend 
> > any effort dealing with the ramifications of ABI breaks (as discussed in 
> > https://reviews.llvm.org/D60748) at present, I only fix the bug for Linux. 
> > If other system wants the fix, the only thing needed is to add a flag (like 
> > "IsLinuxABI" ) to enable it.
>
>
> CC @mgorny and @joerg - do we want this for NetBSD?


Probably yes. FWICS, gcc uses `%mm0` and `%mm1` on NetBSD while clang doesn't.


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

https://reviews.llvm.org/D59744



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


[PATCH] D62648: [Sema][Typo] Fix assertion failure for expressions with multiple typos

2019-06-04 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 202938.
dgoldman added a comment.

- Remove unused State variable


Repository:
  rC Clang

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

https://reviews.llvm.org/D62648

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-recursive.cpp

Index: test/Sema/typo-correction-recursive.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-recursive.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior:
+// - multiple typos in a single member call chain are all diagnosed
+// - no typos are diagnosed for multiple typos in an expression when not all
+//   typos can be corrected
+
+class DeepClass
+{
+public:
+  void trigger() const;  // expected-note {{'trigger' declared here}}
+};
+
+class Y
+{
+public:
+  const DeepClass& getX() const { return m_deepInstance; } // expected-note {{'getX' declared here}}
+  int getN() const { return m_n; }
+private:
+  DeepClass m_deepInstance;
+  int m_n;
+};
+
+class Z
+{
+public:
+  const Y& getY0() const { return m_y0; } // expected-note {{'getY0' declared here}}
+  const Y& getY1() const { return m_y1; }
+  const Y& getActiveY() const { return m_y0; }
+
+private:
+  Y m_y0;
+  Y m_y1;
+};
+
+Z z_obj;
+
+void testMultipleCorrections()
+{
+  z_obj.getY2(). // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}}
+getM().  // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}}
+triggee();   // expected-error {{no member named 'triggee' in 'DeepClass'; did you mean 'trigger'}}
+}
+
+void testNoCorrections()
+{
+  z_obj.getY2(). // expected-error {{no member named 'getY2' in 'Z'}}
+getM().
+thisDoesntSeemToMakeSense();
+}
+
+struct C {};
+struct D { int value; };
+struct A {
+  C get_me_a_C();
+};
+struct B {
+  D get_me_a_D(); // expected-note {{'get_me_a_D' declared here}}
+};
+class Scope {
+public:
+  A make_an_A();
+  B make_a_B(); // expected-note {{'make_a_B' declared here}}
+};
+
+Scope scope_obj;
+
+int testDiscardedCorrections() {
+  return scope_obj.make_an_E(). // expected-error {{no member named 'make_an_E' in 'Scope'; did you mean 'make_a_B'}}
+get_me_a_Z().value; // expected-error {{no member named 'get_me_a_Z' in 'B'; did you mean 'get_me_a_D'}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7680,6 +7680,59 @@
 return ExprFilter(Res.get());
   }
 
+  // Try to transform the given expression, looping through the correction
+  // candidates with `CheckAndAdvanceTypoExprCorrectionStreams`.
+  //
+  // Since correcting typos may intoduce new TypoExprs, this function
+  // checks for new TypoExprs and recurses if it finds any. Note that it will
+  // only succeed if it is able to correct all typos in the given expression.
+  ExprResult RecursiveTransformLoop(Expr *E) {
+ExprResult Res;
+while (true) {
+  Res = TryTransform(E);
+
+  // The transform was valid: check if there any new TypoExprs were created.
+  // If so, we need to recurse to check their validity.
+  if (!Res.isInvalid() && !TypoExprs.empty()) {
+Expr *FixedExpr = Res.get();
+auto SavedTypoExprs = TypoExprs;
+llvm::SmallSetVector RecursiveTypoExprs;
+TypoExprs = RecursiveTypoExprs;
+FindTypoExprs(TypoExprs).TraverseStmt(FixedExpr);
+
+// Recurse to handle newly created TypoExprs. If we're not able to
+// handle them, discard these TypoExprs.
+ExprResult RecurResult = RecursiveTransformLoop(FixedExpr);
+if (RecurResult.isInvalid()) {
+  Res = ExprError();
+  // Recursive corrections didn't work, wipe them away and don't add
+  // them to the TypoExprs set.
+  for (auto TE : TypoExprs) {
+TransformCache.erase(TE);
+SemaRef.clearDelayedTypo(TE);
+  }
+} else {
+  // TypoExpr is valid: add newly created TypoExprs since we were
+  // able to correct them.
+  Res = RecurResult;
+  SavedTypoExprs.set_union(TypoExprs);
+}
+
+TypoExprs = SavedTypoExprs;
+  }
+  // If the transform is still valid after checking for any new typos,
+  // it's good to go.
+  if (!Res.isInvalid())
+break;
+
+  // The transform was invalid, see if we have any TypoExprs with untried
+  // correction candidates.
+  if (!CheckAndAdvanceTypoExprCorrectionStreams())
+break;
+}
+return Res;
+  }
+
 public:
   TransformTypos(Sema , VarDecl *InitDecl, llvm::function_ref Filter)
   : BaseTransform(SemaRef), InitDecl(InitDecl), ExprFilter(Filter) {}
@@ -7707,16 +7760,7 @@
   ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
 
   ExprResult Transform(Expr *E) {
-ExprResult Res;
-

[clang-tools-extra] r362352 - [clangd] Add RelationSlab

2019-06-04 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Sun Jun  2 21:55:46 2019
New Revision: 362352

URL: http://llvm.org/viewvc/llvm-project?rev=362352=rev
Log:
[clangd] Add RelationSlab

Summary:
RelationSlab is a new index data structure that stores relations between
symbols.

Reviewers: kadircet

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

Tags: #clang

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

Added:
clang-tools-extra/trunk/clangd/index/Relation.cpp
clang-tools-extra/trunk/clangd/index/Relation.h
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/unittests/IndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=362352=362351=362352=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Sun Jun  2 21:55:46 2019
@@ -77,6 +77,7 @@ add_clang_library(clangDaemon
   index/MemIndex.cpp
   index/Merge.cpp
   index/Ref.cpp
+  index/Relation.cpp
   index/Serialization.cpp
   index/Symbol.cpp
   index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=362352=362351=362352=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Sun Jun  2 21:55:46 2019
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
 
 #include "Ref.h"
+#include "Relation.h"
 #include "Symbol.h"
 #include "SymbolID.h"
 #include "llvm/ADT/DenseSet.h"

Added: clang-tools-extra/trunk/clangd/index/Relation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Relation.cpp?rev=362352=auto
==
--- clang-tools-extra/trunk/clangd/index/Relation.cpp (added)
+++ clang-tools-extra/trunk/clangd/index/Relation.cpp Sun Jun  2 21:55:46 2019
@@ -0,0 +1,40 @@
+//===--- Relation.cpp *- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Relation.h"
+
+#include 
+
+namespace clang {
+namespace clangd {
+
+llvm::iterator_range
+RelationSlab::lookup(const SymbolID ,
+ index::SymbolRole Predicate) const {
+  auto IterPair = std::equal_range(Relations.begin(), Relations.end(),
+   Relation{Subject, Predicate, SymbolID{}},
+   [](const Relation , const Relation ) {
+ return std::tie(A.Subject, A.Predicate) <
+std::tie(B.Subject, B.Predicate);
+   });
+  return {IterPair.first, IterPair.second};
+}
+
+RelationSlab RelationSlab::Builder::build() && {
+  // Sort in SPO order.
+  std::sort(Relations.begin(), Relations.end());
+
+  // Remove duplicates.
+  Relations.erase(std::unique(Relations.begin(), Relations.end()),
+  Relations.end());
+
+  return RelationSlab{std::move(Relations)};
+}
+
+} // namespace clangd
+} // namespace clang

Added: clang-tools-extra/trunk/clangd/index/Relation.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Relation.h?rev=362352=auto
==
--- clang-tools-extra/trunk/clangd/index/Relation.h (added)
+++ clang-tools-extra/trunk/clangd/index/Relation.h Sun Jun  2 21:55:46 2019
@@ -0,0 +1,88 @@
+//===--- Relation.h --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_RELATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_RELATION_H
+
+#include "SymbolID.h"
+#include "SymbolLocation.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/iterator_range.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Represents a relation between two symbols.
+/// For an example "A is a base class of B" may be represented
+/// as { Subject = A, Predicate = RelationBaseOf, Object = B }.
+struct Relation {
+  SymbolID Subject;
+  index::SymbolRole 

[clang-tools-extra] r362353 - [clangd] Serialization support for RelationSlab

2019-06-04 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Sun Jun  2 22:07:52 2019
New Revision: 362353

URL: http://llvm.org/viewvc/llvm-project?rev=362353=rev
Log:
[clangd] Serialization support for RelationSlab

Summary: This builds on D59407 to provide YAML and RIFF serialization support.

Reviewers: kadircet

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/Serialization.cpp
clang-tools-extra/trunk/clangd/index/Serialization.h
clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp
clang-tools-extra/trunk/clangd/unittests/SerializationTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=362353=362352=362353=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Sun Jun  2 22:07:52 
2019
@@ -24,6 +24,29 @@ llvm::Error makeError(const llvm::Twine
   return llvm::make_error(Msg,
  llvm::inconvertibleErrorCode());
 }
+} // namespace
+
+RelationKind symbolRoleToRelationKind(index::SymbolRole Role) {
+  // SymbolRole is used to record relations in the index.
+  // Only handle the relations we actually store currently.
+  // If we start storing more relations, this list can be expanded.
+  switch (Role) {
+  case index::SymbolRole::RelationBaseOf:
+return RelationKind::BaseOf;
+  default:
+llvm_unreachable("Unsupported symbol role");
+  }
+}
+
+index::SymbolRole relationKindToSymbolRole(RelationKind Kind) {
+  switch (Kind) {
+  case RelationKind::BaseOf:
+return index::SymbolRole::RelationBaseOf;
+  }
+  llvm_unreachable("Invalid relation kind");
+}
+
+namespace {
 
 // IO PRIMITIVES
 // We use little-endian 32 bit ints, sometimes with variable-length encoding.
@@ -358,6 +381,28 @@ readRefs(Reader , llvm::ArrayRef(Kind));
+  OS << R.Object.raw();
+}
+
+Relation readRelation(Reader ) {
+  SymbolID Subject = Data.consumeID();
+  index::SymbolRole Predicate =
+  relationKindToSymbolRole(static_cast(Data.consume8()));
+  SymbolID Object = Data.consumeID();
+  return {Subject, Predicate, Object};
+}
+
 // FILE ENCODING
 // A file is a RIFF chunk with type 'CdIx'.
 // It contains the sections:
@@ -434,6 +479,17 @@ llvm::Expected readRIFF(llv
   return makeError("malformed or truncated refs");
 Result.Refs = std::move(Refs).build();
   }
+  if (Chunks.count("rela")) {
+Reader RelationsReader(Chunks.lookup("rela"));
+RelationSlab::Builder Relations;
+while (!RelationsReader.eof()) {
+  auto Relation = readRelation(RelationsReader);
+  Relations.insert(Relation);
+}
+if (RelationsReader.err())
+  return makeError("malformed or truncated relations");
+Result.Relations = std::move(Relations).build();
+  }
   return std::move(Result);
 }
 
@@ -483,6 +539,14 @@ void writeRIFF(const IndexFileOut ,
 }
   }
 
+  std::vector Relations;
+  if (Data.Relations) {
+for (const auto  : *Data.Relations) {
+  Relations.emplace_back(Relation);
+  // No strings to be interned in relations.
+}
+  }
+
   std::string StringSection;
   {
 llvm::raw_string_ostream StringOS(StringSection);
@@ -508,6 +572,16 @@ void writeRIFF(const IndexFileOut ,
 RIFF.Chunks.push_back({riff::fourCC("refs"), RefsSection});
   }
 
+  std::string RelationSection;
+  if (Data.Relations) {
+{
+  llvm::raw_string_ostream RelationOS{RelationSection};
+  for (const auto  : Relations)
+writeRelation(Relation, RelationOS);
+}
+RIFF.Chunks.push_back({riff::fourCC("rela"), RelationSection});
+  }
+
   std::string SrcsSection;
   {
 {
@@ -561,6 +635,7 @@ std::unique_ptr loadIndex(l
 
   SymbolSlab Symbols;
   RefSlab Refs;
+  RelationSlab Relations;
   {
 trace::Span Tracer("ParseIndex");
 if (auto I = readIndexFile(Buffer->get()->getBuffer())) {
@@ -568,6 +643,8 @@ std::unique_ptr loadIndex(l
 Symbols = std::move(*I->Symbols);
   if (I->Refs)
 Refs = std::move(*I->Refs);
+  if (I->Relations)
+Relations = std::move(*I->Relations);
 } else {
   llvm::errs() << "Bad Index: " << llvm::toString(I.takeError()) << "\n";
   return nullptr;
@@ -576,15 +653,17 @@ std::unique_ptr loadIndex(l
 
   size_t NumSym = Symbols.size();
   size_t NumRefs = Refs.numRefs();
+  size_t NumRelations = Relations.size();
 
   trace::Span Tracer("BuildIndex");
   auto Index = UseDex ? dex::Dex::build(std::move(Symbols), std::move(Refs))
   : MemIndex::build(std::move(Symbols), std::move(Refs));
   vlog("Loaded {0} from {1} with estimated memory usage {2} bytes\n"
"  - number of symbols: {3}\n"
-   "  - number of refs: {4}\n",
+   "  - number of refs: 

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-06-04 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 closed this revision.
jyu2 added a comment.

jyu2 committed rGb8fee677bf8e 
: Re-check 
in clang support gun asm goto after fixing tests. (authored by jyu2).


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

https://reviews.llvm.org/D56571



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


[clang-tools-extra] r362467 - [clangd] SymbolCollector support for relations

2019-06-04 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Mon Jun  3 21:25:44 2019
New Revision: 362467

URL: http://llvm.org/viewvc/llvm-project?rev=362467=rev
Log:
[clangd] SymbolCollector support for relations

Summary:
The only relation currently collected is RelationBaseOf, because this is
all we need for type hierarchy subtypes. Additional relations can be
collected in the future as the need arises.

This patch builds on D59407 and D62459.

Reviewers: kadircet

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.h
clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=362467=362466=362467=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Mon Jun  3 
21:25:44 2019
@@ -193,6 +193,11 @@ RefKind toRefKind(index::SymbolRoleSet R
   return static_cast(static_cast(RefKind::All) & Roles);
 }
 
+bool shouldIndexRelation(const index::SymbolRelation ) {
+  // We currently only index BaseOf relations, for type hierarchy subtypes.
+  return R.Roles & static_cast(index::SymbolRole::RelationBaseOf);
+}
+
 } // namespace
 
 SymbolCollector::SymbolCollector(Options Opts) : Opts(std::move(Opts)) {}
@@ -291,6 +296,16 @@ bool SymbolCollector::handleDeclOccurenc
   SM.getFileID(SpellingLoc) == SM.getMainFileID())
 ReferencedDecls.insert(ND);
 
+  auto ID = getSymbolID(ND);
+  if (!ID)
+return true;
+
+  // Note: we need to process relations for all decl occurrences, including
+  // refs, because the indexing code only populates relations for specific
+  // occurrences. For example, RelationBaseOf is only populated for the
+  // occurrence inside the base-specifier.
+  processRelations(*ND, *ID, Relations);
+
   bool CollectRef = static_cast(Opts.RefFilter) & Roles;
   bool IsOnlyRef =
   !(Roles & (static_cast(index::SymbolRole::Declaration) |
@@ -315,10 +330,6 @@ bool SymbolCollector::handleDeclOccurenc
   if (IsOnlyRef)
 return true;
 
-  auto ID = getSymbolID(ND);
-  if (!ID)
-return true;
-
   // FIXME: ObjCPropertyDecl are not properly indexed here:
   // - ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
   // not a NamedDecl.
@@ -338,6 +349,7 @@ bool SymbolCollector::handleDeclOccurenc
 
   if (Roles & static_cast(index::SymbolRole::Definition))
 addDefinition(*OriginalDecl, *BasicSymbol);
+
   return true;
 }
 
@@ -416,6 +428,37 @@ bool SymbolCollector::handleMacroOccuren
   return true;
 }
 
+void SymbolCollector::processRelations(
+const NamedDecl , const SymbolID ,
+ArrayRef Relations) {
+  // Store subtype relations.
+  if (!dyn_cast())
+return;
+
+  for (const auto  : Relations) {
+if (!shouldIndexRelation(R))
+  continue;
+
+const Decl *Object = R.RelatedSymbol;
+
+auto ObjectID = getSymbolID(Object);
+if (!ObjectID)
+  continue;
+
+// Record the relation.
+// TODO: There may be cases where the object decl is not indexed for some
+// reason. Those cases should probably be removed in due course, but for
+// now there are two possible ways to handle it:
+//   (A) Avoid storing the relation in such cases.
+//   (B) Store it anyways. Clients will likely lookup() the SymbolID
+//   in the index and find nothing, but that's a situation they
+//   probably need to handle for other reasons anyways.
+// We currently do (B) because it's simpler.
+this->Relations.insert(
+Relation{ID, index::SymbolRole::RelationBaseOf, *ObjectID});
+  }
+}
+
 void SymbolCollector::setIncludeLocation(const Symbol , SourceLocation Loc) {
   if (Opts.CollectIncludePath)
 if (shouldCollectIncludePath(S.SymInfo.Kind))

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.h?rev=362467=362466=362467=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.h (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.h Mon Jun  3 21:25:44 
2019
@@ -110,6 +110,7 @@ public:
 
   SymbolSlab takeSymbols() { return std::move(Symbols).build(); }
   RefSlab takeRefs() { return std::move(Refs).build(); }
+  RelationSlab takeRelations() { return std::move(Relations).build(); }
 
   void finish() override;
 
@@ -117,6 +118,8 @@ private:
   const Symbol *addDeclaration(const NamedDecl &, SymbolID,
bool IsMainFileSymbol);
   void addDefinition(const NamedDecl &, 

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 202950.
serge-sans-paille added a comment.

Take into account @philip.pfaffe remarks and improve support for new PM.

- harmonize static/dynamic loading, although two functions are still needed, 
one for dynamic loading and one for static loading (new PM)
- do not clutter the required API with extra namespaces

I've updated https://sergesanspaille.fedorapeople.org/bye.tgz to showcase a 
minimal example.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446

Files:
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/CMakeLists.txt
  polly/lib/Support/RegisterPasses.cpp
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
Index: polly/lib/Support/RegisterPasses.cpp
===
--- polly/lib/Support/RegisterPasses.cpp
+++ polly/lib/Support/RegisterPasses.cpp
@@ -234,7 

[PATCH] D62643: [CodeGen][ObjC] Convert '[self alloc]' in a class method to 'objc_alloc(self)'

2019-06-04 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ahatanak marked 2 inline comments as done.
Closed by commit rL362521: [CodeGen][ObjC] Convert [self alloc] in 
a class method to a call to (authored by ahatanak, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62643?vs=202821=202959#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62643

Files:
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
  cfe/trunk/test/CodeGenObjC/objc-alloc-init.m

Index: cfe/trunk/test/CodeGenObjC/objc-alloc-init.m
===
--- cfe/trunk/test/CodeGenObjC/objc-alloc-init.m
+++ cfe/trunk/test/CodeGenObjC/objc-alloc-init.m
@@ -23,14 +23,20 @@
 
 @interface Y : X
 +(void)meth;
+-(void)instanceMeth;
 @end
 
 @implementation Y
 +(void)meth {
   [[self alloc] init];
+  // OPTIMIZED: call i8* @objc_alloc_init(
+  // NOT_OPTIMIZED: call i8* @objc_alloc(
+}
+-(void)instanceMeth {
   // EITHER-NOT: call i8* @objc_alloc
   // EITHER: call {{.*}} @objc_msgSend
   // EITHER: call {{.*}} @objc_msgSend
+  [[self alloc] init];
 }
 @end
 
Index: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -150,6 +150,34 @@
   return [c retain];
 }
 
+@interface TestSelf
++ (instancetype)alloc;
++ (instancetype)allocWithZone:(void*)zone;
++ (id)classMeth;
+- (id)instanceMeth;
+@end
+
+@implementation TestSelf
+// CHECK-LABEL: define internal i8* @"\01+[TestSelf classMeth]"(
++ (id)classMeth {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_allocWithZone\(}}
+  // CALLS: {{call.*@objc_alloc\(}}
+  [self allocWithZone:nil];
+  return [self alloc];
+}
+// CHECK-LABEL: define internal i8* @"\01-[TestSelf instanceMeth]"(
+- (id)instanceMeth {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  [self allocWithZone:nil];
+  return [self alloc];
+}
+@end
+
 @interface NSString : NSObject
 + (void)retain_self;
 - (void)retain_super;
Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -383,10 +383,12 @@
 if (isClassMessage &&
 Runtime.shouldUseRuntimeFunctionsForAlloc() &&
 ResultType->isObjCObjectPointerType()) {
-// [Foo alloc] -> objc_alloc(Foo)
+// [Foo alloc] -> objc_alloc(Foo) or
+// [self alloc] -> objc_alloc(self)
 if (Sel.isUnarySelector() && Sel.getNameForSlot(0) == "alloc")
   return CGF.EmitObjCAlloc(Receiver, CGF.ConvertType(ResultType));
-// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo)
+// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo) or
+// [self allocWithZone:nil] -> objc_allocWithZone(self)
 if (Sel.isKeywordSelector() && Sel.getNumArgs() == 1 &&
 Args.size() == 1 && Args.front().getType()->isPointerType() &&
 Sel.getNameForSlot(0) == "allocWithZone") {
@@ -444,22 +446,38 @@
   Sel.getNameForSlot(0) != "init")
 return None;
 
-  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'.
+  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]' or
+  // we are in an ObjC class method and 'receiver' is '[self alloc]'.
   auto *SubOME =
-  dyn_cast(OME->getInstanceReceiver()->IgnoreParens());
+  dyn_cast(OME->getInstanceReceiver()->IgnoreParenCasts());
   if (!SubOME)
 return None;
   Selector SubSel = SubOME->getSelector();
-  if (SubOME->getReceiverKind() != ObjCMessageExpr::Class ||
-  !SubOME->getType()->isObjCObjectPointerType() ||
+
+  // Check if we are in an ObjC class method and the receiver expression is
+  // 'self'.
+  const Expr *SelfInClassMethod = nullptr;
+  if (const auto *CurMD = dyn_cast_or_null(CGF.CurFuncDecl))
+if (CurMD->isClassMethod())
+  if ((SelfInClassMethod = SubOME->getInstanceReceiver()))
+if (!SelfInClassMethod->isObjCSelfExpr())
+  SelfInClassMethod = nullptr;
+
+  if ((SubOME->getReceiverKind() != ObjCMessageExpr::Class &&
+   !SelfInClassMethod) || !SubOME->getType()->isObjCObjectPointerType() ||
   !SubSel.isUnarySelector() || SubSel.getNameForSlot(0) != "alloc")
 return None;
 
-  QualType ReceiverType = SubOME->getClassReceiver();
-  const ObjCObjectType *ObjTy = ReceiverType->getAs();
-  const ObjCInterfaceDecl *ID = ObjTy->getInterface();
-  assert(ID && "null interface should be impossible here");
-  llvm::Value 

[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 202922.
hokein added a comment.

Tests for C++2a.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845

Files:
  clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx14.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx2a.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14,c++17 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
-// FIXME: Fix the test code in C++2a mode.
+// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 #include "initializer_list.h"
@@ -32,37 +31,6 @@
 
 struct Empty {};
 
-struct NoCopyMoveCtor {
-  NoCopyMoveCtor(const NoCopyMoveCtor &) = delete; // implies move ctor is deleted
-};
-
-struct NoCopyMoveCtorVisible {
-private:
-  NoCopyMoveCtorVisible(const NoCopyMoveCtorVisible&) = default;
-  NoCopyMoveCtorVisible(NoCopyMoveCtorVisible&&) = default;
-};
-
-struct OnlyMoveCtor {
-  OnlyMoveCtor() = default;
-  OnlyMoveCtor(OnlyMoveCtor&&) = default;
-  OnlyMoveCtor(const OnlyMoveCtor &) = delete;
-};
-
-struct OnlyCopyCtor {
-  OnlyCopyCtor(const OnlyCopyCtor&) = default;
-  OnlyCopyCtor(OnlyCopyCtor&&) = delete;
-};
-
-struct OnlyCopyCtorVisible {
-  OnlyCopyCtorVisible(const OnlyCopyCtorVisible &) = default;
-
-private:
-  OnlyCopyCtorVisible(OnlyCopyCtorVisible &&) = default;
-};
-
-struct ImplicitDeletedCopyCtor {
-  const OnlyMoveCtor ctor;
-};
 
 struct E {
   E(std::initializer_list);
@@ -314,33 +282,6 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = std::make_unique(Empty{});
 
-  // No fixes for classes with deleted copy constructors.
-  auto PNoCopyMoveCtor = std::unique_ptr(new NoCopyMoveCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use std::make_unique instead
-  // CHECK-FIXES: auto PNoCopyMoveCtor = std::unique_ptr(new NoCopyMoveCtor{});
-
-  auto PNoCopyMoveCtorVisible = std::unique_ptr(new NoCopyMoveCtorVisible{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead
-  // CHECK-FIXES: auto PNoCopyMoveCtorVisible = std::unique_ptr(new NoCopyMoveCtorVisible{});
-
-  auto POnlyMoveCtor = std::unique_ptr(new OnlyMoveCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
-  // CHECK-FIXES: auto POnlyMoveCtor = std::unique_ptr(new OnlyMoveCtor{});
-
-  // Fix for classes with classes with move constructor.
-  auto POnlyCopyCtor = std::unique_ptr(new OnlyCopyCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
-  // CHECK-FIXES: auto POnlyCopyCtor = std::unique_ptr(new OnlyCopyCtor{});
-
-   // Fix for classes with classes with move constructor.
-  auto POnlyCopyCtorVisible = std::unique_ptr(new OnlyCopyCtorVisible{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use std::make_unique instead
-  // CHECK-FIXES: auto POnlyCopyCtorVisible = std::unique_ptr(new OnlyCopyCtorVisible{});
-
-  auto PImplicitDeletedCopyCtor = std::unique_ptr(new ImplicitDeletedCopyCtor{});
-  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
-  // CHECK-FIXES: auto PImplicitDeletedCopyCtor = std::unique_ptr(new ImplicitDeletedCopyCtor{});
-
   // Initialization with default constructor.
   std::unique_ptr PE1 = std::unique_ptr(new E{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
Index: clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx2a.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx2a.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy -std=c++2a %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
+
+struct NoCopyMoveCtor {
+  NoCopyMoveCtor() = default;
+  NoCopyMoveCtor(const NoCopyMoveCtor &) = delete; // implies move ctor is deleted
+};
+
+struct NoCopyMoveCtorVisible {
+  NoCopyMoveCtorVisible() = default;
+private:
+  NoCopyMoveCtorVisible(const NoCopyMoveCtorVisible&) = default;
+  NoCopyMoveCtorVisible(NoCopyMoveCtorVisible&&) = default;
+};
+
+struct OnlyMoveCtor {
+  OnlyMoveCtor() = default;
+  OnlyMoveCtor(OnlyMoveCtor&&) = default;
+  OnlyMoveCtor(const OnlyMoveCtor &) = delete;
+};
+
+struct OnlyCopyCtor {
+  OnlyCopyCtor() = default;
+  OnlyCopyCtor(const OnlyCopyCtor&) = default;
+  OnlyCopyCtor(OnlyCopyCtor&&) = delete;
+};
+
+struct OnlyCopyCtorVisible {
+  OnlyCopyCtorVisible() = default;
+  

[PATCH] D62856: [clangd] Also apply adjustArguments when returning fallback commands

2019-06-04 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.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62856

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp


Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -21,6 +21,7 @@
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
 using ::testing::Not;
+using ::testing::StartsWith;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -85,7 +86,8 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
+  "-fsyntax-only", StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
@@ -97,7 +99,8 @@
   Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6"));
+  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
+  "-fsyntax-only"));
 }
 
 TEST_F(OverlayCDBTest, Watch) {
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -173,6 +173,7 @@
   std::lock_guard Lock(Mutex);
   Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
  FallbackFlags.end());
+  adjustArguments(Cmd, ResourceDir);
   return Cmd;
 }
 


Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -21,6 +21,7 @@
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
 using ::testing::Not;
+using ::testing::StartsWith;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -85,7 +86,8 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
+  "-fsyntax-only", StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
@@ -97,7 +99,8 @@
   Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6"));
+  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
+  "-fsyntax-only"));
 }
 
 TEST_F(OverlayCDBTest, Watch) {
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -173,6 +173,7 @@
   std::lock_guard Lock(Mutex);
   Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
  FallbackFlags.end());
+  adjustArguments(Cmd, ResourceDir);
   return Cmd;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> I think we should be looking at the intent of the test rather than its name.
> 
> The intent looks like testing how the check works when `std::make_unique` is 
> available from the standard library (as opposed to some kind of replacement 
> like `absl::make_unique`).  See the patch that introduced it: 
> https://reviews.llvm.org/D43766
> 
> So modernize-make-unique-cxx14 is actually "C++14 or later".  (Probably it 
> should be renamed.)

yeap, it seems to me that "modernize-make-unique-cxx14" is redundant, 
"modernize-make-unique" should cover what it tests, I believe. We also have 
"modernize-make-unique-cxx11" which runs on C++11 mode only, maybe we just 
repurpose the `modernize-make-unique-cxx14`, what do you think?

> I see.  Assuming it is desired behavior, I'd say for these cases we should 
> create separate files that are specifically run in C++14 and 17, and another 
> one for C++2a onward.
> 
> But is it desired behavior?  That is, can we generate a call to 
> `std::make_unique` in C++14 in practice -- would it compile?

The fix is compilable for C++14, but it is tricky to support it:

1. `new NoCopyMoveCtor{}`: the `make_unique` fix is compilable
2. `new NoCopyMoveCtor{1, 2}`: the `make_unique` fix is not compilable

The AST for case 1) and 2)  are the same in C++14,  supporting that would 
introduce hacky change to the logic here 
.
 I'd leave it as-is now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845



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


[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:831
+ };
  return HI;
}},

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > ilya-biryukov wrote:
> > > > Could you add another test with even weirder types where we fail to 
> > > > show the signature? To make sure we don't break when reaching the 
> > > > limitations of the chosen approach and document what those limitations 
> > > > are.
> > > > 
> > > > Something like:
> > > > ```
> > > > auto a = [](int a) { return 10; };
> > > > auto *b = 
> > > > auto *c = 
> > > > ```
> > > > 
> > > > We would fail to show the signature here, but it's totally ok to ignore 
> > > > it.
> > > added cases, and changed code(a lot simpler now) to generate signatures 
> > > for those cases as well.
> > Here's an example when the new approach falls short too:
> > 
> > ```
> > auto a = [](int) { return 10; }
> > std::function b;
> > ```
> > 
> > In general, are we ok with loosing all the information about the type that 
> > we drop?
> > One level of references and pointers seemed ok, dropping more is a bit more 
> > cheesy..
> > 
> > At the same time, either case is **so** rare that we probably don't care.
> are you talking about hovering over `x` ? I don't think AST contains 
> information regarding that one. 
> 
> for a code like this:
> ```
> auto foo = []() { return 5; };
> 
> template 
> class Cls {};
> 
> Cls X;
> ```
> 
> This is the AST dump for variable X:
> ```
> `-VarDecl 0x2b0e808  col:30 X 'Cls (decltype(foo))>':'Cls' callinit
>   `-CXXConstructExpr 0x2b12e80  'Cls':'Cls ((lambda at a.cc:1:12))>' 'void () noexcept'
> ```
I'm talking about hovering over `b` and, as Sam mentioned, there's a good 
chance you don't have this information in the type and we need to look at 
`TypeLocs` instead.

Also agree with Sam, we don't want **any** complexity for that case. Just 
wanted to make sure we added a test like this just to make sure we have some 
idea of what's produced there and it does not crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814



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


[PATCH] D48116: [libclang] Allow skipping warnings from all included files

2019-06-04 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@jkorous, could you take a look or suggest someone who can review the libclang 
changes?
As mentioned before, I've reviewed the clang bits (which are now gone), but 
don't have much experience in `libclang` parts.


Repository:
  rC Clang

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

https://reviews.llvm.org/D48116



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


[clang-tools-extra] r362517 - [clangd] Minor cleanup. NFC

2019-06-04 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jun  4 09:19:11 2019
New Revision: 362517

URL: http://llvm.org/viewvc/llvm-project?rev=362517=rev
Log:
[clangd] Minor cleanup. NFC

Removed unused using declaration from TweakTests.cpp

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

Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=362517=362516=362517=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Tue Jun  4 09:19:11 
2019
@@ -21,7 +21,6 @@
 #include 
 
 using llvm::Failed;
-using llvm::HasValue;
 using llvm::Succeeded;
 
 namespace clang {


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


r362531 - PR42104: Support instantiations of lambdas that implicitly capture

2019-06-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jun  4 10:17:20 2019
New Revision: 362531

URL: http://llvm.org/viewvc/llvm-project?rev=362531=rev
Log:
PR42104: Support instantiations of lambdas that implicitly capture
packs.

Two changes:
 * Track odr-use via FunctionParmPackExprs to properly handle dependent
   odr-uses of packs in generic lambdas.
 * Do not instantiate implicit captures; instead, regenerate them by
   instantiating the body of the lambda. This is necessary to
   distinguish between cases where only one element of a pack is
   captured and cases where the entire pack is captured.

This reinstates r362358 (reverted in r362375) with a fix for an
uninitialized variable use in UpdateMarkingForLValueToRValue.

Added:
cfe/trunk/test/SemaTemplate/lambda-capture-pack.cpp
Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/ScopeInfo.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=362531=362530=362531=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue Jun  4 10:17:20 2019
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_SEMA_SCOPEINFO_H
 
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/CapturedStmt.h"
 #include "clang/Basic/LLVM.h"
@@ -913,7 +914,8 @@ public:
   ///   };
   /// }
   void addPotentialCapture(Expr *VarExpr) {
-assert(isa(VarExpr) || isa(VarExpr));
+assert(isa(VarExpr) || isa(VarExpr) ||
+   isa(VarExpr));
 PotentiallyCapturingExprs.push_back(VarExpr);
   }
 
@@ -965,13 +967,15 @@ public:
   ///  building such a node. So we need a rule that anyone can implement and 
get
   ///  exactly the same result".
   void markVariableExprAsNonODRUsed(Expr *CapturingVarExpr) {
-assert(isa(CapturingVarExpr)
-|| isa(CapturingVarExpr));
+assert(isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr));
 NonODRUsedCapturingExprs.insert(CapturingVarExpr);
   }
   bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const {
-assert(isa(CapturingVarExpr)
-  || isa(CapturingVarExpr));
+assert(isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr));
 return NonODRUsedCapturingExprs.count(CapturingVarExpr);
   }
   void removePotentialCapture(Expr *E) {
@@ -993,9 +997,8 @@ public:
   PotentialThisCaptureLocation.isValid();
   }
 
-  // When passed the index, returns the VarDecl and Expr associated
-  // with the index.
-  void getPotentialVariableCapture(unsigned Idx, VarDecl *, Expr *) const;
+  void visitPotentialCaptures(
+  llvm::function_ref Callback) const;
 };
 
 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy()

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=362531=362530=362531=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jun  4 10:17:20 2019
@@ -4181,6 +4181,7 @@ public:
   void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
   void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
   void MarkMemberReferenced(MemberExpr *E);
+  void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E);
   void MarkCaptureUsedInEnclosingContext(VarDecl *Capture, SourceLocation Loc,
  unsigned CapturingScopeIndex);
 

Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=362531=362530=362531=diff
==
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Tue Jun  4 10:17:20 2019
@@ -229,20 +229,20 @@ bool CapturingScopeInfo::isVLATypeCaptur
   return false;
 }
 
-void LambdaScopeInfo::getPotentialVariableCapture(unsigned Idx, VarDecl *,
-  Expr *) const {
-  assert(Idx < getNumPotentialVariableCaptures() &&
- "Index of potential capture must be within 0 to less than the "
- "number of captures!");
-  E = PotentiallyCapturingExprs[Idx];
-  if (DeclRefExpr *DRE = dyn_cast(E))
-VD = dyn_cast(DRE->getFoundDecl());
-  else if (MemberExpr *ME = dyn_cast(E))
-VD = dyn_cast(ME->getMemberDecl());
-  else
-llvm_unreachable("Only DeclRefExprs or MemberExprs 

[PATCH] D62856: [clangd] Also apply adjustArguments when returning fallback commands

2019-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362496: [clangd] Also apply adjustArguments when returning 
fallback commands (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62856?vs=202924=202925#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62856

Files:
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp


Index: 
clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -21,6 +21,7 @@
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
 using ::testing::Not;
+using ::testing::StartsWith;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -85,7 +86,8 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
+  "-fsyntax-only", StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
@@ -97,7 +99,8 @@
   Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6"));
+  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
+  "-fsyntax-only"));
 }
 
 TEST_F(OverlayCDBTest, Watch) {
Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
@@ -173,6 +173,7 @@
   std::lock_guard Lock(Mutex);
   Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
  FallbackFlags.end());
+  adjustArguments(Cmd, ResourceDir);
   return Cmd;
 }
 


Index: clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -21,6 +21,7 @@
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
 using ::testing::Not;
+using ::testing::StartsWith;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -85,7 +86,8 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
+  "-fsyntax-only", StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
@@ -97,7 +99,8 @@
   Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6"));
+  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
+  "-fsyntax-only"));
 }
 
 TEST_F(OverlayCDBTest, Watch) {
Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
@@ -173,6 +173,7 @@
   std::lock_guard Lock(Mutex);
   Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
  FallbackFlags.end());
+  adjustArguments(Cmd, ResourceDir);
   return Cmd;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-06-04 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

This commit breaks the NetBSD buildbot node.

http://lab.llvm.org:8011/builders/netbsd-amd64/builds/20359

The problem is that this patch hardcodes python specific binary name, while it 
has to be detected dynamically or ideally passed from CMake. Afair lit has a 
knowledge of too.

`​#!/usr/bin/env python` # <- unportable form

On NetBSD with pkgsrc this can be python2.7, but the name is not fixed.

Plase correct this.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62638



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


[clang-tools-extra] r362496 - [clangd] Also apply adjustArguments when returning fallback commands

2019-06-04 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Jun  4 06:38:36 2019
New Revision: 362496

URL: http://llvm.org/viewvc/llvm-project?rev=362496=rev
Log:
[clangd] Also apply adjustArguments when returning fallback commands

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=362496=362495=362496=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Tue Jun  4 
06:38:36 2019
@@ -173,6 +173,7 @@ tooling::CompileCommand OverlayCDB::getF
   std::lock_guard Lock(Mutex);
   Cmd.CommandLine.insert(Cmd.CommandLine.end(), FallbackFlags.begin(),
  FallbackFlags.end());
+  adjustArguments(Cmd, ResourceDir);
   return Cmd;
 }
 

Modified: 
clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp?rev=362496=362495=362496=diff
==
--- clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp 
(original)
+++ clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp 
Tue Jun  4 06:38:36 2019
@@ -21,6 +21,7 @@ using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
 using ::testing::Not;
+using ::testing::StartsWith;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -85,7 +86,8 @@ TEST_F(OverlayCDBTest, GetCompileCommand
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
+  "-fsyntax-only", StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
@@ -97,7 +99,8 @@ TEST_F(OverlayCDBTest, NoBase) {
   Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
-  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6"));
+  ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6",
+  "-fsyntax-only"));
 }
 
 TEST_F(OverlayCDBTest, Watch) {


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


Re: [PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2019-06-04 Thread Aaron Ballman via cfe-commits
On Tue, Jun 4, 2019 at 5:37 AM Richard Membarth via Phabricator
 wrote:
>
> richardmembarth added a comment.
>
> Merging in two weeks is fine for me.
>
> My assumption was that accepted patches are merged into upstream in a timely 
> manner.
> Maybe this is not how it works?

Your assumption is correct. Usually, if you don't have commit
privileges yet, you mention it once your patch is accepted so that the
reviewers know you need it committed on your behalf. The commit
usually happens same- or next-day. However, because I am traveling, I
don't have the ability to watch build bots and revert on your behalf
if anything goes wrong, which explains the delay on my part.

Sorry for the hassle.

~Aaron

>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D54258/new/
>
> https://reviews.llvm.org/D54258
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

We support non immediate on these because gcc does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


r362530 - [Syntax] Do not depend on llvm targets for Syntax tests. NFC

2019-06-04 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jun  4 10:15:48 2019
New Revision: 362530

URL: http://llvm.org/viewvc/llvm-project?rev=362530=rev
Log:
[Syntax] Do not depend on llvm targets for Syntax tests. NFC

They are not required and only slow down the build.

Modified:
cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt

Modified: cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt?rev=362530=362529=362530=diff
==
--- cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt Tue Jun  4 10:15:48 2019
@@ -1,5 +1,4 @@
 set(LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
   Support
   )
 


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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-06-04 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 202926.
lildmh added a comment.

Address Alexey's comment about mapping between function and user-defined mappers


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

https://reviews.llvm.org/D59474

Files:
  include/clang/AST/GlobalDecl.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/ModuleBuilder.cpp
  test/OpenMP/declare_mapper_codegen.cpp

Index: test/OpenMP/declare_mapper_codegen.cpp
===
--- test/OpenMP/declare_mapper_codegen.cpp
+++ test/OpenMP/declare_mapper_codegen.cpp
@@ -1,92 +1,418 @@
-///==///
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
 
+///==///
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: 

[PATCH] D55463: Introduce a source minimizer that reduces source to directives that might affect the dependency list for a compilation

2019-06-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Any reason this isn't tested via lit instead?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55463



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


[PATCH] D62782: Fix -Wdouble-promotion warnings.

2019-06-04 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem added a comment.

I'd modified `CMakeLists.txt` to add `-Wdouble-promotion` and removed this 
line: `-Wno-double-promotion # FIXME: remove me` ...


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D62782



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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> Then the test should be failing? Or is the current form also legal?

Hmm, __builtin_ia32_insertps128() errors if you pass a variable, but these 
don't (e.g.):
mytest.c:122:13: error: argument to '__builtin_ia32_insertps128' must be a 
constant integer

  tmp_V4f = __builtin_ia32_insertps128(tmp_V4f, tmp_V4f, tmp_i);

I'll have a look and see if there is a reason why these don't fail in the same 
way (which would make the test fail in it's current form).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-04 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added subscribers: mgorny, joerg.
krytarowski added a comment.

In D59744#1527412 , @wxiao3 wrote:

> Consider other Systems (e.g Darwin, PS4 and FreeBSD) don't want to spend any 
> effort dealing with the ramifications of ABI breaks (as discussed in 
> https://reviews.llvm.org/D60748) at present, I only fix the bug for Linux. If 
> other system wants the fix, the only thing needed is to add a flag (like 
> "IsLinuxABI" ) to enable it.


CC @mgorny and @joerg - do we want this for NetBSD?


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

https://reviews.llvm.org/D59744



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


[Diffusion] rL358949: [PowerPC] [Clang] Port MMX intrinsics and basic test cases to Power

2019-06-04 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.

/cfe/trunk/lib/Driver/ToolChains/PPCLinux.cpp:26 yes, it is currently Linux 
only. I think we can extend it to include other OS like AIX later if needed. 

https://reviews.llvm.org/rL358949



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


[PATCH] D62845: [clang-tidy] Fix make-unique tests on C++2a.

2019-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

Looks great, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62845



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


Re: [PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

2019-06-04 Thread Sam McCall via cfe-commits
AST dump doesn't traverse into typelocs, which is where x is.

That said, this particular case is not worth any complexity at all. Even
pointer-to-lambda is vanishingly rare.

Regarding dropping ref/pointer info: one option here is keeping the old
"class (lambda)&", and simply making sure we now populate return/params.
I'm not sure setting Type as if it were a function is actually clarifying.

If you don't want to do this, I'd suggest not unwrapping pointers, and
living with the lost ref qualifiers (only realistic case i can think of
where it matters is a by-ref capture of a lambda inside another lambda, and
i don't think anyone will notice if we pretend it's a value)

On Tue, Jun 4, 2019, 16:11 Kadir Cetinkaya via Phabricator <
revi...@reviews.llvm.org> wrote:

> kadircet added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:831
> + };
>   return HI;
> }},
> 
> ilya-biryukov wrote:
> > kadircet wrote:
> > > ilya-biryukov wrote:
> > > > Could you add another test with even weirder types where we fail to
> show the signature? To make sure we don't break when reaching the
> limitations of the chosen approach and document what those limitations are.
> > > >
> > > > Something like:
> > > > ```
> > > > auto a = [](int a) { return 10; };
> > > > auto *b = 
> > > > auto *c = 
> > > > ```
> > > >
> > > > We would fail to show the signature here, but it's totally ok to
> ignore it.
> > > added cases, and changed code(a lot simpler now) to generate
> signatures for those cases as well.
> > Here's an example when the new approach falls short too:
> >
> > ```
> > auto a = [](int) { return 10; }
> > std::function b;
> > ```
> >
> > In general, are we ok with loosing all the information about the type
> that we drop?
> > One level of references and pointers seemed ok, dropping more is a bit
> more cheesy..
> >
> > At the same time, either case is **so** rare that we probably don't care.
> are you talking about hovering over `x` ? I don't think AST contains
> information regarding that one.
>
> for a code like this:
> ```
> auto foo = []() { return 5; };
>
> template 
> class Cls {};
>
> Cls X;
> ```
>
> This is the AST dump for variable X:
> ```
> `-VarDecl 0x2b0e808  col:30 X 'Cls (decltype(foo))>':'Cls' callinit
>   `-CXXConstructExpr 0x2b12e80  'Cls (decltype(foo))>':'Cls' 'void () noexcept'
> ```
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D62814/new/
>
> https://reviews.llvm.org/D62814
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62856: [clangd] Also apply adjustArguments when returning fallback commands

2019-06-04 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/D62856/new/

https://reviews.llvm.org/D62856



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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D62850#1529081 , @russell.gallop 
wrote:

> > .. or?
>
> I'm not sure what you mean.
>
> > Is this fixing a current test failure?
>
> No. The test is not failing, but it is not doing what was intended as these 
> builtins are for generating the immediate form of the corresponding 
> instruction and they were generating actually generating a register form.


Then the test should be failing? Or is the current form also legal?

> This test doesn't check the instructions generated are correct, but fixing 
> that is a bigger task...



In D62850#1529197 , @russell.gallop 
wrote:

> > Is the compiler missing a check that these parameters are immediates?
>
> I don't think that there can be a check, or this would have been noticed.
>
> I don't know whether this is possible and/or desirable. Do users use one 
> version of the builtin and want the compiler to decide whether to use the 
> immediate form?


See https://llvm.org/docs/LangRef.html#parameter-attributes `immarg`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[PATCH] D60697: [ARM] Allow "-march=foo+fp" to vary with foo.

2019-06-04 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 202934.
SjoerdMeijer added a comment.

Hi Oliver, thanks for your comments!

This was the easy one, they have been added:

> I also don't see any tests for the negated forms of either feature.

The trouble begun with this:

> +fp.dp, but the FPU is already double-precision
>  +fp.dp, but no double-precision FPU exists (are there any FPUs which cause 
> this?)
>  +[no]fp or +[no]fp.dp for a CPU/arch which doesn't have any FPUs.

Because I found that basically none of this worked. The main reason was that we 
were always passing `generic`. To address that we at least have a chance of 
seeing a sensible CPU name, I have swapped the order of parsing -march and 
-mcpu. I.e., we parse -mcpu first, and pass that to `checkARMArchName`, which 
will eventually call `appendArchExtFeatures`. I think that makes more sense 
when we use the CPUname to query `getDefaultFPU`.

Then about the more fancy diagnostics (e.g. "fp.dp, but the FPU is already 
double-precision"): I've removed any attempt to throw clever diagnostics. I 
don't think, in general, that we provide this kind of service level. I.e., we 
need to do a lot more work here to avoid a meaningless, confusing, and thus 
useless  "--march=... not supported" error message when we provide +fp.dp on 
the -march when e.g. the CPU already enabled this.


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

https://reviews.llvm.org/D60697

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/test/Driver/armv8.1m.main.c
  clang/test/Driver/armv8.1m.main.s
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp

Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -484,22 +484,85 @@
   return StringRef();
 }
 
-StringRef ARM::getArchExtFeature(StringRef ArchExt) {
-  if (ArchExt.startswith("no")) {
-StringRef ArchExtBase(ArchExt.substr(2));
-for (const auto AE : ARCHExtNames) {
-  if (AE.NegFeature && ArchExtBase == AE.getName())
-return StringRef(AE.NegFeature);
-}
+static bool stripNegationPrefix(StringRef ) {
+  if (Name.startswith("no")) {
+Name = Name.substr(2);
+return true;
   }
+  return false;
+}
+
+StringRef ARM::getArchExtFeature(StringRef ArchExt) {
+  bool Negated = stripNegationPrefix(ArchExt);
   for (const auto AE : ARCHExtNames) {
 if (AE.Feature && ArchExt == AE.getName())
-  return StringRef(AE.Feature);
+  return StringRef(Negated ? AE.NegFeature : AE.Feature);
   }
 
   return StringRef();
 }
 
+static unsigned findDoublePrecisionFPU(unsigned InputFPUKind) {
+  const ARM::FPUName  = ARM::FPUNames[InputFPUKind];
+
+  // If the input FPU already supports double-precision, then there
+  // isn't any different FPU we can return here.
+  //
+  // The current available FPURestriction values are None (no
+  // restriction), D16 (only 16 d-regs) and SP_D16 (16 d-regs
+  // and single precision only); there's no value representing
+  // SP restriction without D16. So this test just means 'is it
+  // SP only?'.
+  if (InputFPU.Restriction != ARM::FPURestriction::SP_D16)
+return ARM::FK_INVALID;
+
+  // Otherwise, look for an FPU entry with all the same fields, except
+  // that SP_D16 has been replaced with just D16, representing adding
+  // double precision and not changing anything else.
+  for (const ARM::FPUName  : ARM::FPUNames) {
+if (CandidateFPU.FPUVer == InputFPU.FPUVer &&
+CandidateFPU.NeonSupport == InputFPU.NeonSupport &&
+CandidateFPU.Restriction == ARM::FPURestriction::D16) {
+  return CandidateFPU.ID;
+}
+  }
+
+  // nothing found
+  return ARM::FK_INVALID;
+}
+
+bool ARM::appendArchExtFeatures(
+  StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
+  std::vector ) {
+  StringRef StandardFeature = getArchExtFeature(ArchExt);
+  if (!StandardFeature.empty()) {
+Features.push_back(StandardFeature);
+return true;
+  }
+
+  const bool Negated = stripNegationPrefix(ArchExt);
+
+  if (CPU == "")
+CPU = "generic";
+
+  if (ArchExt == "fp" || ArchExt == "fp.dp") {
+unsigned FPUKind;
+if (ArchExt == "fp.dp") {
+  if (Negated) {
+Features.push_back("-fp64");
+return true;
+  }
+  FPUKind = findDoublePrecisionFPU(getDefaultFPU(CPU, AK));
+} else if (Negated) {
+  FPUKind = ARM::FK_NONE;
+} else {
+  FPUKind = getDefaultFPU(CPU, AK);
+}
+return ARM::getFPUFeatures(FPUKind, Features);
+  }
+  return false;
+}
+
 StringRef ARM::getHWDivName(unsigned HWDivKind) {
   for (const auto D : HWDivNames) {
 if (HWDivKind == D.ID)
Index: llvm/include/llvm/Support/ARMTargetParser.h
===
--- llvm/include/llvm/Support/ARMTargetParser.h
+++ llvm/include/llvm/Support/ARMTargetParser.h
@@ 

[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-06-04 Thread Nicola Zaghen via Phabricator via cfe-commits
Nicola added a comment.

A bit late to the review, but I've noticed a couple of issues with some of the 
implemented builtins:

- The fmin/fmax builtins are defined twice for scalar types, does this create 
problems in overload resolution when using them?
- The convert_ builtins don't have support for half types (which is present in 
the opencl-c.h header. Is that intended?


Repository:
  rL LLVM

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] D62363: [X86] Enable intrinsics that convert float and bf16 data to each other

2019-06-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D62363



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


[PATCH] D62363: [X86] Enable intrinsics that convert float and bf16 data to each other

2019-06-04 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.

Yup, doxygen LGTM - cheers




Comment at: lib/Headers/avx512bf16intrin.h:33
+
+/// Convert One BF16 Data to One Single Data.
+///

Single Float Data


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

https://reviews.llvm.org/D62363



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


[PATCH] D62830: [WebAssembly] Support Leak Sanitizer on Emscripten

2019-06-04 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added a comment.

LSan is supposed to be linked in to replace some C library functions, and does 
not change the generated LLVM IR code, so there is nothing to actually test in 
LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62830



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


r362537 - Factor out repeated code to build a DeclRefExpr and mark it referenced.

2019-06-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jun  4 11:30:46 2019
New Revision: 362537

URL: http://llvm.org/viewvc/llvm-project?rev=362537=rev
Log:
Factor out repeated code to build a DeclRefExpr and mark it referenced.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=362537=362536=362537=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jun  4 11:30:46 2019
@@ -4305,16 +4305,24 @@ public:
 bool isAddressOfOperand,
 const TemplateArgumentListInfo *TemplateArgs);
 
-  ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
-  ExprValueKind VK,
-  SourceLocation Loc,
-  const CXXScopeSpec *SS = nullptr);
-  ExprResult
+  DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
+SourceLocation Loc,
+const CXXScopeSpec *SS = nullptr);
+  DeclRefExpr *
   BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
const DeclarationNameInfo ,
const CXXScopeSpec *SS = nullptr,
NamedDecl *FoundD = nullptr,
+   SourceLocation TemplateKWLoc = SourceLocation(),
+   const TemplateArgumentListInfo *TemplateArgs = nullptr);
+  DeclRefExpr *
+  BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
+   const DeclarationNameInfo ,
+   NestedNameSpecifierLoc NNS,
+   NamedDecl *FoundD = nullptr,
+   SourceLocation TemplateKWLoc = SourceLocation(),
const TemplateArgumentListInfo *TemplateArgs = nullptr);
+
   ExprResult
   BuildAnonymousStructUnionMemberReference(
   const CXXScopeSpec ,

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=362537=362536=362537=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jun  4 11:30:46 2019
@@ -11475,7 +11475,7 @@ class RefBuilder: public ExprBuilder {
 
 public:
   Expr *build(Sema , SourceLocation Loc) const override {
-return assertNotNull(S.BuildDeclRefExpr(Var, VarType, VK_LValue, 
Loc).get());
+return assertNotNull(S.BuildDeclRefExpr(Var, VarType, VK_LValue, Loc));
   }
 
   RefBuilder(VarDecl *Var, QualType VarType)
@@ -12877,7 +12877,7 @@ void Sema::DefineImplicitLambdaToFunctio
 
   // Construct the body of the conversion function { return __invoke; }.
   Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->getType(),
-   VK_LValue, Conv->getLocation()).get();
+   VK_LValue, Conv->getLocation());
   assert(FunctionRef && "Can't refer to __invoke function?");
   Stmt *Return = BuildReturnStmt(Conv->getLocation(), FunctionRef).get();
   Conv->setBody(CompoundStmt::Create(Context, Return, Conv->getLocation(),

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=362537=362536=362537=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun  4 11:30:46 2019
@@ -1762,7 +1762,7 @@ Sema::ActOnStringLiteral(ArrayRef
   llvm_unreachable("unexpected literal operator lookup result");
 }
 
-ExprResult
+DeclRefExpr *
 Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
SourceLocation Loc,
const CXXScopeSpec *SS) {
@@ -1770,36 +1770,33 @@ Sema::BuildDeclRefExpr(ValueDecl *D, Qua
   return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
 }
 
+DeclRefExpr *
+Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
+   const DeclarationNameInfo ,
+   const CXXScopeSpec *SS, NamedDecl *FoundD,
+   SourceLocation TemplateKWLoc,
+   const TemplateArgumentListInfo *TemplateArgs) {
+  NestedNameSpecifierLoc NNS =
+  SS ? SS->getWithLocInContext(Context) : NestedNameSpecifierLoc();
+  return BuildDeclRefExpr(D, Ty, VK, NameInfo, NNS, FoundD, TemplateKWLoc,
+  TemplateArgs);
+}
+
 /// BuildDeclRefExpr - Build an expression that references a
 /// declaration that does not require a closure capture.
-ExprResult
+DeclRefExpr *
 Sema::BuildDeclRefExpr(ValueDecl *D, 

[PATCH] D62621: [LibTooling] Add insert/remove convenience functions for creating `ASTEdit`s.

2019-06-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added a comment.

Thanks for the review.

In D62621#1528714 , @ilya-biryukov 
wrote:

> Are there any corner cases with handling whitespace that we might want to 
> handle or document them if we don't handle them?
>  E.g. if the range ends up being a name of an expanded macro , it's probably 
> very easy to glue the macro name with whatever you're inserting.
>
>   #define FOO 1+2;
>   #define BAR 2+3;
>  
>   [[FOO]] // [[ ]] marks the selected range
>
>
> would `insertBefore([[FOO]], "BAR")` end up being `BARFOO` or `BAR FOO`?




In D62621#1528716 , @ilya-biryukov 
wrote:

> I guess the question also applies to `change`, although it did not occur to 
> me before.


Good questions.  The answer to both is that it depends on the `RangeSelector` 
used.  `change` itself takes exactly the range given it and modifies the source 
at that range.  Since these APIs are acting at the character level, I think it 
could be confusing to add token-level reasoning.  That said, we could add 
`RangeSelector`s and/or `TextGenerator`s that are smarter about this and 
ensure/add spaces around text as needed.  Since all changes should (in my 
opinion) be run through clang-format afterwards, there's no risk in adding 
extra whitespace.  For example, we could change `text()` to add whitespace on 
both sides of the argument, or add a new combinator `pad` which does that (and 
leave `text()` alone). So, for this example, the user would write 
`insertBefore([[FOO]], pad("BAR"))` and get `BAR FOO`.

We could similarly update `Stencil` to pad its output by default or somesuch.

WDYT?




Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:202
+
+/// Inserts \p Replacement after \p S, automatically calculating the end
+/// location of \p S.

ilya-biryukov wrote:
> Could you elaborate on what `calculating the end location of \p S` means?
> Is the fact that the end location is calculated specific to this function, 
> rather than `RangeSelector` in general?
> 
> The comment is very different from `insertBefore`, suggesting the function 
> behaves differently in practice.
> 
> 
I'm glad you bring this up, since I struggled with how best to express this.  
The point is that it handles the difference between CharRange and TokenRange 
and does the "right" thing. This kind of thing has bitten me and others in the 
past -- it's a pretty typical newbie error to mishandle the `SourceRange` of a 
node. 

That said, it is *not* doing anything more than `RangeSelector` already does, 
since `RangeSelector` is already built on `CharSourceRange` rather than 
`SourceRange`.  So, I'd be fine dropping this mention entirely, since it's 
really a property of the whole system.  That is, I could replace with
"Inserts \p Replacement after \p S, leaving the source selected by \S 
unchanged."

WDYT?

As for insertBefore -- since the beginning of a range is unambiguous, there's 
no need to say anything interesting there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62621



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


[PATCH] D60583: [AArch64] Implement Vector Funtion ABI name mangling.

2019-06-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert reopened this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Why/Where did we decide to clobber the attribute list with "non-existent 
function names"?

This seems to me like an ad-hoc implementation of the RFC that is currently 
discussed but committed before the discussion is finished.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60583



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


[PATCH] D60583: [AArch64] Implement Vector Funtion ABI name mangling.

2019-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D60583#1529885 , @jdoerfert wrote:

> In D60583#1529882 , @ABataev wrote:
>
> > In D60583#1529878 , @jdoerfert 
> > wrote:
> >
> > > Why/Where did we decide to clobber the attribute list with "non-existent 
> > > function names"?
> > >
> > > This seems to me like an ad-hoc implementation of the RFC that is 
> > > currently discussed but committed before the discussion is finished.
> >
> >
> > It has nothing to do with the RFC for a variant. It is a standard interface 
> > to communicate with the backend to generate vectorized versions of the 
> > functions. It relies on Vector ABI, provided by Intel and ARM, it follows 
> > the way it is implemented in GCC. There was an RFC for this long time ago 
> > which was accepted by the community and later implemented.
>
>
> The RFC states, in a nutshell, let us add one attribute to identify all 
> vector variants. This patch adds all vector variants as attributes. Clearly, 
> these things are related.


This new RFC just follows the scheme that was already accepted and implemented. 
As I understand, Francesco just wants to reuse the existing solution for SIMD 
isa of the pragma omp variant (or attribute clang variant)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60583



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


[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-06-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks!! Will fix as soon as i get to my desktop.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62638



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


[PATCH] D62445: [test] Fix plugin tests

2019-06-04 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: cfe/trunk/lib/Analysis/plugins/CMakeLists.txt:1
+if(LLVM_ENABLE_PLUGINS)
+  add_subdirectory(SampleAnalyzer)

nathanchance wrote:
> I think this should have a dependency on `CLANG_ENABLE_STATIC_ANALYZER` like 
> in `clang/test/CMakeLists.txt`, otherwise my build (which disables 
> `CLANG_ENABLE_STATIC_ANALYZER`) fails because these plugins are being added 
> to the build.
> 
> ```
> [2058/2605] Linking CXX shared module 
> lib/CheckerOptionHandlingAnalyzerPlugin.so
> FAILED: lib/CheckerOptionHandlingAnalyzerPlugin.so 
> : && /usr/bin/g++ -fPIC -O2 -march=native -mtune=native -fPIC 
> -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -w 
> -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
> -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,nodelete 
> -fuse-ld=gold   -Wl,-O3 -Wl,--gc-sections  
> -Wl,--version-script,"/tc-build2/build/llvm/stage1/tools/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports"
>  -shared  -o lib/CheckerOptionHandlingAnalyzerPlugin.so 
> tools/clang/lib/Analysis/plugins/CheckerOptionHandling/CMakeFiles/CheckerOptionHandlingAnalyzerPlugin.dir/CheckerOptionHandling.cpp.o
>   -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a lib/libclangAnalysis.a 
> lib/libclangAST.a -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend 
> lib/libLLVMSupport.a lib/libclangASTMatchers.a lib/libclangAST.a 
> lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a lib/libLLVMRemarks.a 
> lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a 
> lib/libLLVMDebugInfoMSF.a lib/libLLVMSupport.a -lz -lrt -ldl -lpthread -lm 
> lib/libLLVMDemangle.a && :
> /usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerCore
> /usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerFrontend
> collect2: error: ld returned 1 exit status
> [2059/2605] Building CXX object 
> tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
> [2060/2605] Linking CXX shared module 
> lib/CheckerDependencyHandlingAnalyzerPlugin.so
> FAILED: lib/CheckerDependencyHandlingAnalyzerPlugin.so 
> : && /usr/bin/g++ -fPIC -O2 -march=native -mtune=native -fPIC 
> -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -w 
> -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
> -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,nodelete 
> -fuse-ld=gold   -Wl,-O3 -Wl,--gc-sections  
> -Wl,--version-script,"/tc-build2/build/llvm/stage1/tools/clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports"
>  -shared  -o lib/CheckerDependencyHandlingAnalyzerPlugin.so 
> tools/clang/lib/Analysis/plugins/CheckerDependencyHandling/CMakeFiles/CheckerDependencyHandlingAnalyzerPlugin.dir/CheckerDependencyHandling.cpp.o
>   -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a lib/libclangAnalysis.a 
> lib/libclangAST.a -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend 
> lib/libLLVMSupport.a lib/libclangASTMatchers.a lib/libclangAST.a 
> lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a lib/libLLVMRemarks.a 
> lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a 
> lib/libLLVMDebugInfoMSF.a lib/libLLVMSupport.a -lz -lrt -ldl -lpthread -lm 
> lib/libLLVMDemangle.a && :
> /usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerCore
> /usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerFrontend
> collect2: error: ld returned 1 exit status
> [2061/2605] Building CXX object 
> tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CompilationDatabase.cpp.o
> [2062/2605] Linking CXX shared module lib/SampleAnalyzerPlugin.so
> FAILED: lib/SampleAnalyzerPlugin.so 
> : && /usr/bin/g++ -fPIC -O2 -march=native -mtune=native -fPIC 
> -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -w 
> -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
> -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,nodelete 
> -fuse-ld=gold   -Wl,-O3 -Wl,--gc-sections  
> -Wl,--version-script,"/tc-build2/build/llvm/stage1/tools/clang/lib/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports"
>  -shared  -o lib/SampleAnalyzerPlugin.so 
> tools/clang/lib/Analysis/plugins/SampleAnalyzer/CMakeFiles/SampleAnalyzerPlugin.dir/MainCallChecker.cpp.o
>   -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a lib/libclangAnalysis.a 
> lib/libclangAST.a -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend 
> lib/libLLVMSupport.a lib/libclangASTMatchers.a lib/libclangAST.a 
> lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a lib/libLLVMRemarks.a 
> lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a 
> lib/libLLVMDebugInfoMSF.a lib/libLLVMSupport.a -lz -lrt -ldl -lpthread -lm 
> lib/libLLVMDemangle.a && :
> /usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerCore
> 

[PATCH] D62648: [Sema][Typo] Fix assertion failure for expressions with multiple typos

2019-06-04 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 203011.
dgoldman added a comment.

- Move if empty check back


Repository:
  rC Clang

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

https://reviews.llvm.org/D62648

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-recursive.cpp

Index: test/Sema/typo-correction-recursive.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-recursive.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior:
+// - multiple typos in a single member call chain are all diagnosed
+// - no typos are diagnosed for multiple typos in an expression when not all
+//   typos can be corrected
+
+class DeepClass
+{
+public:
+  void trigger() const;  // expected-note {{'trigger' declared here}}
+};
+
+class Y
+{
+public:
+  const DeepClass& getX() const { return m_deepInstance; } // expected-note {{'getX' declared here}}
+  int getN() const { return m_n; }
+private:
+  DeepClass m_deepInstance;
+  int m_n;
+};
+
+class Z
+{
+public:
+  const Y& getY0() const { return m_y0; } // expected-note {{'getY0' declared here}}
+  const Y& getY1() const { return m_y1; }
+  const Y& getActiveY() const { return m_y0; }
+
+private:
+  Y m_y0;
+  Y m_y1;
+};
+
+Z z_obj;
+
+void testMultipleCorrections()
+{
+  z_obj.getY2(). // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}}
+getM().  // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}}
+triggee();   // expected-error {{no member named 'triggee' in 'DeepClass'; did you mean 'trigger'}}
+}
+
+void testNoCorrections()
+{
+  z_obj.getY2(). // expected-error {{no member named 'getY2' in 'Z'}}
+getM().
+thisDoesntSeemToMakeSense();
+}
+
+struct C {};
+struct D { int value; };
+struct A {
+  C get_me_a_C();
+};
+struct B {
+  D get_me_a_D(); // expected-note {{'get_me_a_D' declared here}}
+};
+class Scope {
+public:
+  A make_an_A();
+  B make_a_B(); // expected-note {{'make_a_B' declared here}}
+};
+
+Scope scope_obj;
+
+int testDiscardedCorrections() {
+  return scope_obj.make_an_E(). // expected-error {{no member named 'make_an_E' in 'Scope'; did you mean 'make_a_B'}}
+get_me_a_Z().value; // expected-error {{no member named 'get_me_a_Z' in 'B'; did you mean 'get_me_a_D'}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7680,6 +7680,61 @@
 return ExprFilter(Res.get());
   }
 
+  // Try to transform the given expression, looping through the correction
+  // candidates with `CheckAndAdvanceTypoExprCorrectionStreams`.
+  //
+  // Since correcting typos may intoduce new TypoExprs, this function
+  // checks for new TypoExprs and recurses if it finds any. Note that it will
+  // only succeed if it is able to correct all typos in the given expression.
+  ExprResult RecursiveTransformLoop(Expr *E) {
+ExprResult Res;
+while (true) {
+  Res = TryTransform(E);
+
+  // The transform was valid: check if there any new TypoExprs were created.
+  // If so, we need to recurse to check their validity.
+  if (!Res.isInvalid()) {
+Expr *FixedExpr = Res.get();
+auto SavedTypoExprs = TypoExprs;
+llvm::SmallSetVector RecursiveTypoExprs;
+TypoExprs = RecursiveTypoExprs;
+FindTypoExprs(TypoExprs).TraverseStmt(FixedExpr);
+
+if (!TypoExprs.empty()) {
+  // Recurse to handle newly created TypoExprs. If we're not able to
+  // handle them, discard these TypoExprs.
+  ExprResult RecurResult = RecursiveTransformLoop(FixedExpr);
+  if (RecurResult.isInvalid()) {
+Res = ExprError();
+// Recursive corrections didn't work, wipe them away and don't add
+// them to the TypoExprs set.
+for (auto TE : TypoExprs) {
+  TransformCache.erase(TE);
+  SemaRef.clearDelayedTypo(TE);
+}
+  } else {
+// TypoExpr is valid: add newly created TypoExprs since we were
+// able to correct them.
+Res = RecurResult;
+SavedTypoExprs.set_union(TypoExprs);
+  }
+}
+
+TypoExprs = SavedTypoExprs;
+  }
+  // If the transform is still valid after checking for any new typos,
+  // it's good to go.
+  if (!Res.isInvalid())
+break;
+
+  // The transform was invalid, see if we have any TypoExprs with untried
+  // correction candidates.
+  if (!CheckAndAdvanceTypoExprCorrectionStreams())
+break;
+}
+return Res;
+  }
+
 public:
   TransformTypos(Sema , VarDecl *InitDecl, llvm::function_ref Filter)
   : BaseTransform(SemaRef), InitDecl(InitDecl), ExprFilter(Filter) {}
@@ -7707,16 +7762,7 @@
   ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
 
   

[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-06-04 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 202984.
jcai19 added a comment.

Update test function names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61967

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe %t
+
+extern "C" int pipe(int pipefd[2]);
+
+void warning() {
+  int pipefd[2];
+  pipe(pipefd);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes [android-cloexec-pipe]
+  // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
+}
+
+namespace i {
+int pipe(int pipefd[2]);
+void noWarningInNamespace() {
+  int pipefd[2];
+  pipe(pipefd);
+}
+} // namespace i
+
+class C {
+public:
+  int pipe(int pipefd[2]);
+  void noWarningForMemberFunction() {
+int pipefd[2];
+pipe(pipefd);
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - android-cloexec-pipe
+
+android-cloexec-pipe
+
+
+This check detects usage of ``pipe()``. Using ``pipe()`` is not recommended, ``pipe2()`` is the
+suggested replacement. The check also adds the O_CLOEXEC flag that marks the file descriptor to
+be closed in child processes. Without this flag a sensitive file descriptor can be leaked to a
+child process, potentially into a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe(pipefd);
+
+Suggested replacement:
+
+.. code-block:: c++
+  pipe2(pipefd, O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,11 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  This check detects usage of ``pipe()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.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_ANDROID_CLOEXEC_PIPE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Suggests to replace calls to pipe() with calls to pipe2().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-pipe.html
+class CloexecPipeCheck : public CloexecCheck {
+public:
+  CloexecPipeCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
===
--- /dev/null
+++ 

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-06-04 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 202987.
kpn added a comment.

Address the rest of the review comments, hopefully.

I've lifted from mibintc's D62730  the enums 
for the exception behavior and rounding modes. The rest of that set of changes 
is better left to a separate ticket after all.

Since I now have those requested enums I've changed the relevant public 
functions to take them instead of an MDNode*.

There is no standalone or comprehensive IRBuilder documentation that I could 
find. I hope the references in comments back to the LangRef are good enough. I 
used the exact language from it to make it easier to reference said doc.


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

https://reviews.llvm.org/D53157

Files:
  include/llvm/IR/IRBuilder.h
  unittests/IR/IRBuilderTest.cpp

Index: unittests/IR/IRBuilderTest.cpp
===
--- unittests/IR/IRBuilderTest.cpp
+++ unittests/IR/IRBuilderTest.cpp
@@ -122,6 +122,70 @@
   EXPECT_FALSE(II->hasNoNaNs());
 }
 
+TEST_F(IRBuilderTest, ConstrainedFP) {
+  IRBuilder<> Builder(BB);
+  Value *V;
+  CallInst *Call;
+  IntrinsicInst *II;
+
+  V = Builder.CreateLoad(GV);
+
+  // See if we get constrained intrinsics instead of non-constrained
+  // instructions.
+  Builder.setIsFPConstrained(true);
+
+  V = Builder.CreateFAdd(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fadd);
+
+  V = Builder.CreateFSub(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fsub);
+
+  V = Builder.CreateFMul(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fmul);
+  
+  V = Builder.CreateFDiv(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fdiv);
+  
+  V = Builder.CreateFRem(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_frem);
+
+  // Verify the codepaths for setting and overriding the default metadata.
+  V = Builder.CreateFAdd(V, V);
+  ASSERT_TRUE(isa(V));
+  auto *CII = cast(V);
+  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
+  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
+
+  Builder.setDefaultConstrainedExcept(IRBuilderBase::CE_Ignore);
+  Builder.setDefaultConstrainedRounding(IRBuilderBase::CR_Upward);
+  V = Builder.CreateFAdd(V, V);
+  CII = cast(V);
+  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
+  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmUpward);
+
+  // Now override the defaults.
+  Call = Builder.CreateConstrainedFPBinOp(
+Intrinsic::experimental_constrained_fadd, V, V, nullptr, "",
+IRBuilderBase::CR_Dynamic, IRBuilderBase::CE_Strict);
+  CII = cast(Call);
+  EXPECT_EQ(CII->getIntrinsicID(), Intrinsic::experimental_constrained_fadd);
+  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
+  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
+
+  Builder.CreateRetVoid();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
 TEST_F(IRBuilderTest, Lifetime) {
   IRBuilder<> Builder(BB);
   AllocaInst *Var1 = Builder.CreateAlloca(Builder.getInt8Ty());
Index: include/llvm/IR/IRBuilder.h
===
--- include/llvm/IR/IRBuilder.h
+++ include/llvm/IR/IRBuilder.h
@@ -88,6 +88,30 @@
 class IRBuilderBase {
   DebugLoc CurDbgLocation;
 
+public:
+  /// Specifies the required exception behavior. This is only used when
+  /// when constrained floating point is enabled. See the LLVM Language
+  /// Reference Manual for details.
+  enum ConstrainedExceptKind {
+CE_Unspecified, ///< Use as a placeholder to not affect exception
+///< behavior.
+CE_Strict,  ///< This corresponds to "fpexcept.strict".
+CE_Ignore,  ///< This corresponds to "fpexcept.ignore".
+CE_MayTrap  ///< This corresponds to "fpexcept.maytrap".
+  };
+  /// Specifies the rounding mode to be assumed. This is only used when
+  /// when constrained floating point is enabled. See the LLVM Language
+  /// Reference Manual for details.
+  enum ConstrainedRoundingKind {
+CR_Unspecified, ///< Use as a placeholder to not affect rounding
+///< behavior.
+CR_Dynamic, ///< This corresponds to "fpround.dynamic".
+CR_ToNearest,   ///< This corresponds to "fpround.tonearest".
+CR_Downward,///< This corresponds to "fpround.downward".
+CR_Upward,  ///< This corresponds to "fpround.upward".
+CR_ToZero   ///< This corresponds to "fpround.tozero".
+  };
+
 protected:
   BasicBlock *BB;
   BasicBlock::iterator InsertPt;
@@ -96,12 +120,18 @@
   MDNode 

[PATCH] D62445: [test] Fix plugin tests

2019-06-04 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added inline comments.



Comment at: cfe/trunk/lib/Analysis/plugins/CMakeLists.txt:1
+if(LLVM_ENABLE_PLUGINS)
+  add_subdirectory(SampleAnalyzer)

I think this should have a dependency on `CLANG_ENABLE_STATIC_ANALYZER` like in 
`clang/test/CMakeLists.txt`, otherwise my build (which disables 
`CLANG_ENABLE_STATIC_ANALYZER`) fails because these plugins are being added to 
the build.

```
[2058/2605] Linking CXX shared module lib/CheckerOptionHandlingAnalyzerPlugin.so
FAILED: lib/CheckerOptionHandlingAnalyzerPlugin.so 
: && /usr/bin/g++ -fPIC -O2 -march=native -mtune=native -fPIC 
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -w -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,nodelete -fuse-ld=gold   -Wl,-O3 
-Wl,--gc-sections  
-Wl,--version-script,"/tc-build2/build/llvm/stage1/tools/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports"
 -shared  -o lib/CheckerOptionHandlingAnalyzerPlugin.so 
tools/clang/lib/Analysis/plugins/CheckerOptionHandling/CMakeFiles/CheckerOptionHandlingAnalyzerPlugin.dir/CheckerOptionHandling.cpp.o
  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a lib/libclangAnalysis.a 
lib/libclangAST.a -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend 
lib/libLLVMSupport.a lib/libclangASTMatchers.a lib/libclangAST.a 
lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a lib/libLLVMRemarks.a 
lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a 
lib/libLLVMDebugInfoMSF.a lib/libLLVMSupport.a -lz -lrt -ldl -lpthread -lm 
lib/libLLVMDemangle.a && :
/usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerCore
/usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerFrontend
collect2: error: ld returned 1 exit status
[2059/2605] Building CXX object 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
[2060/2605] Linking CXX shared module 
lib/CheckerDependencyHandlingAnalyzerPlugin.so
FAILED: lib/CheckerDependencyHandlingAnalyzerPlugin.so 
: && /usr/bin/g++ -fPIC -O2 -march=native -mtune=native -fPIC 
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -w -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,nodelete -fuse-ld=gold   -Wl,-O3 
-Wl,--gc-sections  
-Wl,--version-script,"/tc-build2/build/llvm/stage1/tools/clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports"
 -shared  -o lib/CheckerDependencyHandlingAnalyzerPlugin.so 
tools/clang/lib/Analysis/plugins/CheckerDependencyHandling/CMakeFiles/CheckerDependencyHandlingAnalyzerPlugin.dir/CheckerDependencyHandling.cpp.o
  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a lib/libclangAnalysis.a 
lib/libclangAST.a -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend 
lib/libLLVMSupport.a lib/libclangASTMatchers.a lib/libclangAST.a 
lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a lib/libLLVMRemarks.a 
lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a 
lib/libLLVMDebugInfoMSF.a lib/libLLVMSupport.a -lz -lrt -ldl -lpthread -lm 
lib/libLLVMDemangle.a && :
/usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerCore
/usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerFrontend
collect2: error: ld returned 1 exit status
[2061/2605] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CompilationDatabase.cpp.o
[2062/2605] Linking CXX shared module lib/SampleAnalyzerPlugin.so
FAILED: lib/SampleAnalyzerPlugin.so 
: && /usr/bin/g++ -fPIC -O2 -march=native -mtune=native -fPIC 
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -w -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,nodelete -fuse-ld=gold   -Wl,-O3 
-Wl,--gc-sections  
-Wl,--version-script,"/tc-build2/build/llvm/stage1/tools/clang/lib/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports"
 -shared  -o lib/SampleAnalyzerPlugin.so 
tools/clang/lib/Analysis/plugins/SampleAnalyzer/CMakeFiles/SampleAnalyzerPlugin.dir/MainCallChecker.cpp.o
  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a lib/libclangAnalysis.a 
lib/libclangAST.a -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend 
lib/libLLVMSupport.a lib/libclangASTMatchers.a lib/libclangAST.a 
lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a lib/libLLVMRemarks.a 
lib/libLLVMMC.a lib/libLLVMBinaryFormat.a lib/libLLVMDebugInfoCodeView.a 
lib/libLLVMDebugInfoMSF.a lib/libLLVMSupport.a -lz -lrt -ldl -lpthread -lm 
lib/libLLVMDemangle.a && :
/usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerCore
/usr/bin/ld.gold: error: cannot find -lclangStaticAnalyzerFrontend
collect2: error: ld returned 1 exit status
```


Repository:
  rL LLVM

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


[PATCH] D62830: [WebAssembly] Support Leak Sanitizer on Emscripten

2019-06-04 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added a comment.

It's not urgent, so I am willing to wait a day or two for commit access. If I 
still can't get access by then, I'll ask someone else to commit this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62830



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


[PATCH] D60583: [AArch64] Implement Vector Funtion ABI name mangling.

2019-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D60583#1529878 , @jdoerfert wrote:

> Why/Where did we decide to clobber the attribute list with "non-existent 
> function names"?
>
> This seems to me like an ad-hoc implementation of the RFC that is currently 
> discussed but committed before the discussion is finished.


It has nothing to do with the RFC for a variant. It is a standard interface to 
communicate with the backend to generate vectorized versions of the functions. 
It relies on Vector ABI, provided by Intel and ARM, it follows the way it is 
implemented in GCC. There was an RFC for this long time ago which was accepted 
by the community and later implemented.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60583



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


[PATCH] D60583: [AArch64] Implement Vector Funtion ABI name mangling.

2019-06-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D60583#1529882 , @ABataev wrote:

> In D60583#1529878 , @jdoerfert wrote:
>
> > Why/Where did we decide to clobber the attribute list with "non-existent 
> > function names"?
> >
> > This seems to me like an ad-hoc implementation of the RFC that is currently 
> > discussed but committed before the discussion is finished.
>
>
> It has nothing to do with the RFC for a variant. It is a standard interface 
> to communicate with the backend to generate vectorized versions of the 
> functions. It relies on Vector ABI, provided by Intel and ARM, it follows the 
> way it is implemented in GCC. There was an RFC for this long time ago which 
> was accepted by the community and later implemented.


The RFC states, in a nutshell, let us add one attribute to identify all vector 
variants. This patch adds all vector variants as attributes. Clearly, these 
things are related.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60583



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


[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-06-04 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py:1
+#!/usr/bin/env python
+

```
# something else then
#
#==- exploded-graph-rewriter.py - Simplifies the ExplodedGraph -*- python -*-==#
#
# 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
#
#======#
```
Whoops!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62638



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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> We support non immediate on these because gcc does.

Thanks. Your comment crossed in mid-air. Okay, so is this test worth changing, 
or should it have both versions (immediate and non-immediate)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> I'll have a look and see if there is a reason why these don't fail in the 
> same way (which would make the test fail in it's current form).

These do not have the "I" prefix (//  I   -> Required to constant fold to an 
integer constant expression.) in BuiltinsX86.def which is probably why they 
don't error.

Checking against the LLVM side, there is a comment in IntrinsicsX86.td:

  // Oddly these don't require an immediate due to a gcc compatibility issue.
  def int_x86_mmx_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi">,
  Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
 llvm_i32_ty], [IntrNoMem]>;

That comment was added recently by Craig in r355993. So it looks like they 
should work with either for compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D62850#1529588 , @russell.gallop 
wrote:

> > We support non immediate on these because gcc does.
>
> Thanks. Your comment crossed in mid-air. Okay, so is this test worth 
> changing, or should it have both versions (immediate and non-immediate)?


Both, i guess, with a comment as to why they are the way they are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62850



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


r362545 - Introduce Value::stripPointerCastsSameRepresentation

2019-06-04 Thread Johannes Doerfert via cfe-commits
Author: jdoerfert
Date: Tue Jun  4 13:21:46 2019
New Revision: 362545

URL: http://llvm.org/viewvc/llvm-project?rev=362545=rev
Log:
Introduce Value::stripPointerCastsSameRepresentation

This patch allows current users of Value::stripPointerCasts() to force
the result of the function to have the same representation as the value
it was called on. This is useful in various cases, e.g., (non-)null
checks.

In this patch only a single call site was adjusted to fix an existing
misuse that would cause nonnull where they may be wrong. Uses in
attribute deduction and other areas, e.g., D60047, are to be expected.

For a discussion on this topic, please see [0].

[0] http://lists.llvm.org/pipermail/llvm-dev/2018-December/128423.html

Reviewers: hfinkel, arsenm, reames

Subscribers: wdng, hiraditya, bollu, llvm-commits

Tags: #llvm

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

Modified:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl

Modified: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl?rev=362545=362544=362545=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl (original)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl Tue Jun  4 13:21:46 
2019
@@ -9,6 +9,6 @@ void foo() {
   // CHECK: [[REF:%.*]] = alloca i32
   // CHECK: store i32 1, i32* [[REF]]
   // CHECK: [[REG:%[0-9]+]] = addrspacecast i32* [[REF]] to i32 addrspace(4)*
-  // CHECK: call spir_func i32 @_Z3barRU3AS4Kj(i32 addrspace(4)* nonnull 
dereferenceable(4) [[REG]])
+  // CHECK: call spir_func i32 @_Z3barRU3AS4Kj(i32 addrspace(4)* 
dereferenceable(4) [[REG]])
   bar(1);
 }


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


[PATCH] D60974: Clang IFSO driver action.

2019-06-04 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 202976.
plotfi added a comment.

Adding a test for inheritance and constructors/destroctors. Also addressing 
feedback from @alexshap


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/class-template-specialization.cpp
  clang/test/InterfaceStubs/externstatic.c
  clang/test/InterfaceStubs/function-template-specialization.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/inline.h
  clang/test/InterfaceStubs/object.cpp
  clang/test/InterfaceStubs/public-hidden.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/virtual.cpp
  clang/test/InterfaceStubs/visibility.cpp
  clang/test/InterfaceStubs/weak.cpp

Index: clang/test/InterfaceStubs/weak.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/weak.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
+// RUN: FileCheck --check-prefix=CHECK-YAML %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
+// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+// CHECK: Symbols:
+// CHECK-NEXT:  _Z8weakFuncv: { Type: Func, Weak: true }
+// CHECK-NEXT:  _Z10strongFuncv: { Type: Func }
+
+// CHECK-YAML: Symbols:
+// CHECK-YAML-NEXT:   - Name:_Z8weakFuncv
+// CHECK-YAML-NEXT: Type:STT_FUNC
+// CHECK-YAML-NEXT: Binding: STB_WEAK
+// CHECK-YAML-NEXT:   - Name:_Z10strongFuncv
+// CHECK-YAML-NEXT: Type:STT_FUNC
+// CHECK-YAML-NEXT: Binding: STB_GLOBAL
+
+// CHECK-SYMBOLS: _Z10strongFuncv
+// CHECK-SYMBOLS: _Z8weakFuncv
+__attribute__((weak)) void weakFunc() {}
+int strongFunc() { return 42; }
Index: clang/test/InterfaceStubs/visibility.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/visibility.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden \
+// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden \
+// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | FileCheck %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | FileCheck %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-readelf -s - 2>&1 | \
+// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+// Always Be Hidden:
+// CHECK-CMD-HIDDEN-NOT: _Z6hiddenv
+// CHECK-NOT: _Z6hiddenv
+__attribute__((visibility("hidden"))) void hidden() {}
+
+// Always Be Visible:
+// CHECK-CMD-HIDDEN: _Z9nothiddenv
+// CHECK: _Z9nothiddenv
+__attribute__((visibility("default"))) void nothidden() {}
+
+// Do Whatever -fvisibility says:
+// CHECK-CMD-HIDDEN-NOT: _Z10cmdVisiblev
+// CHECK: _Z10cmdVisiblev
+void cmdVisible() {}
+
+// CHECK-SYMBOLS: DEFAULT{{.*}} _Z10cmdVisiblev
+// CHECK-SYMBOLS: HIDDEN {{.*}} _Z6hiddenv
+// CHECK-SYMBOLS: DEFAULT{{.*}} _Z9nothiddenv
Index: clang/test/InterfaceStubs/virtual.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/virtual.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck -check-prefix=CHECK-TAPI %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \
+// RUN: llvm-readelf -s - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+#define HIDDEN  __attribute__((__visibility__(("hidden"
+#define DEFAULT __attribute__((__visibility__(("default"
+
+// CHECK-TAPI-NOT: _ZNK1Q5func1Ev
+// CHECK-TAPI-NOT: _ZNK1Q5func2Ev
+// CHECK-SYMBOLS: NOTYPE  GLOBAL HIDDEN   {{.*}} 

[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-06-04 Thread Jian Cai via Phabricator via cfe-commits
jcai19 marked an inline comment as done.
jcai19 added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp:20
+  pipe2(pipefd, O_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'pipe2' should use O_CLOEXEC 
where possible [android-cloexec-pipe2]
+  // CHECK-FIXES: pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);

gribozavr wrote:
> jcai19 wrote:
> > gribozavr wrote:
> > > Same comment about the message as in D61967 -- the message should briefly 
> > > explain why the user should make this change. Users tend to ignore 
> > > warnings they don't understand.
> > > 
> > > "pipe2 should be called with O_CLOEXEC to avoid leaking file descriptors 
> > > to child processes"
> > It appeared to me that there was no easy way to change the warning message 
> > due to the way insertMacroFlag is implemented (called in  
> > CloexecPipe2Check::check(...) to add O_CLOEXEC flag when necessary). The 
> > function always issue a warning in the format of "%0 should use %1 where 
> > possible". So unless we parameterize the warning string (which could be 
> > solved by a different code change), we might end up implementing a similar 
> > function with different warning message, which creates extra work if we 
> > need to modify insertMacroFlag in the future. I am new to Clang so please 
> > let me know if there is a better way to udpate the warning message.
> I don't see an issue with parameterizing insertMacroFlag -- the current 
> message that it produces is not descriptive enough anyway, users tend to 
> ignore such messages.
I agree. But my point is insertMacroFlag is used by several other checks. 
Shouldn't we parameterize the warning message and update these checks together 
in a separate change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049



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


[PATCH] D62873: Avoid building analyzer plugins if CLANG_ENABLE_STATIC_ANALYZER is OFF

2019-06-04 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.
dim added reviewers: hintonda, dcoughlin, NoQ.
Herald added subscribers: dkrupp, donat.nagy, Szelethus, a.sidorin, 
baloghadamsoftware, mgorny.
Herald added a project: clang.

Attempting to build clang with CLANG_ENABLE_STATIC_ANALYZER=OFF fails
after rC362328 , because the new plugins 
under lib/Analysis/plugins are
dependent on the static analyzer libraries.

Add checks to disable building these if CLANG_ENABLE_STATIC_ANALYZER is
OFF.


Repository:
  rC Clang

https://reviews.llvm.org/D62873

Files:
  lib/Analysis/plugins/CMakeLists.txt
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -119,14 +119,12 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
-list(APPEND CLANG_TEST_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-  endif()
+if(LLVM_ENABLE_PLUGINS AND CLANG_ENABLE_STATIC_ANALYZER)
+  list(APPEND CLANG_TEST_DEPS
+SampleAnalyzerPlugin
+CheckerDependencyHandlingAnalyzerPlugin
+CheckerOptionHandlingAnalyzerPlugin
+)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
Index: lib/Analysis/plugins/CMakeLists.txt
===
--- lib/Analysis/plugins/CMakeLists.txt
+++ lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(LLVM_ENABLE_PLUGINS)
+if(LLVM_ENABLE_PLUGINS AND CLANG_ENABLE_STATIC_ANALYZER)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -119,14 +119,12 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
-list(APPEND CLANG_TEST_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-  endif()
+if(LLVM_ENABLE_PLUGINS AND CLANG_ENABLE_STATIC_ANALYZER)
+  list(APPEND CLANG_TEST_DEPS
+SampleAnalyzerPlugin
+CheckerDependencyHandlingAnalyzerPlugin
+CheckerOptionHandlingAnalyzerPlugin
+)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
Index: lib/Analysis/plugins/CMakeLists.txt
===
--- lib/Analysis/plugins/CMakeLists.txt
+++ lib/Analysis/plugins/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(LLVM_ENABLE_PLUGINS)
+if(LLVM_ENABLE_PLUGINS AND CLANG_ENABLE_STATIC_ANALYZER)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48680: Add missing visibility annotation for __base

2019-06-04 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Here's a standalone reproducer for the problem:

  $ cat exe.cpp
  #include 
  
  std::function f();
  
  int main() {
f()();
  }
  $ cat dso.cpp
  #include 
  
  __attribute__((visibility("default"))) std::function f() {
return [](){};
  }
  $ ~/l3/ra-cmake/bin/clang++ -fsanitize=cfi -fvisibility=hidden dso.cpp 
-shared -flto -fuse-ld=lld -Wl,-soname,dso.so -o dso.so -stdlib=libc++ 
-fno-rtti -fno-exceptions
  $ ~/l3/ra-cmake/bin/clang++ -fsanitize=cfi -fvisibility=hidden exe.cpp  -flto 
-fuse-ld=lld dso.so -stdlib=libc++
  $ LD_LIBRARY_PATH=.:$HOME/l3/ra-cmake/lib ./a.out 
  Illegal instruction

With this patch:

  $ LD_LIBRARY_PATH=.:$HOME/l3/ra-cmake/lib ./a.out 
  [no output]


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D48680



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


[PATCH] D62873: Avoid building analyzer plugins if CLANG_ENABLE_STATIC_ANALYZER is OFF

2019-06-04 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Experienced the same, updated my test build configuration to always force 
`CLANG_ENABLE_STATIC_ANALYZER` to On when building with tests. Maybe it's worth 
adding a warning about when Clang tests are being built?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62873



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


[PATCH] D62873: Avoid building analyzer plugins if CLANG_ENABLE_STATIC_ANALYZER is OFF

2019-06-04 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

Thanks for the quick fix, looks good to me!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62873



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


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-06-04 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 203012.
arphaman marked 7 inline comments as done.
arphaman added a comment.

Address review comments.


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

https://reviews.llvm.org/D60233

Files:
  clang/test/ClangScanDeps/Inputs/regular_cdb.json
  clang/test/ClangScanDeps/regular_cdb.cpp
  clang/tools/CMakeLists.txt
  clang/tools/clang-scan-deps/CMakeLists.txt
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- /dev/null
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -0,0 +1,216 @@
+//===-- ClangScanDeps.cpp - Implementation of clang-scan-deps -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/FrontendTool/Utils.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/JSONCompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/Options.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/Threading.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+/// A clang tool that runs the preprocessor only for the given compiler
+/// invocation.
+class PreprocessorOnlyTool : public tooling::ToolAction {
+public:
+  PreprocessorOnlyTool(StringRef WorkingDirectory)
+  : WorkingDirectory(WorkingDirectory) {}
+
+  bool runInvocation(std::shared_ptr Invocation,
+ FileManager *FileMgr,
+ std::shared_ptr PCHContainerOps,
+ DiagnosticConsumer *DiagConsumer) override {
+// Create a compiler instance to handle the actual work.
+CompilerInstance Compiler(std::move(PCHContainerOps));
+Compiler.setInvocation(std::move(Invocation));
+FileMgr->getFileSystemOpts().WorkingDir = WorkingDirectory;
+Compiler.setFileManager(FileMgr);
+
+// Create the compiler's actual diagnostics engine.
+Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
+if (!Compiler.hasDiagnostics())
+  return false;
+
+Compiler.createSourceManager(*FileMgr);
+
+auto Action = llvm::make_unique();
+const bool Result = Compiler.ExecuteAction(*Action);
+FileMgr->clearStatCache();
+return Result;
+  }
+
+private:
+  StringRef WorkingDirectory;
+};
+
+/// A proxy file system that doesn't call `chdir` when changing the working
+/// directory of a clang tool.
+class ProxyFileSystemWithoutChdir : public llvm::vfs::ProxyFileSystem {
+public:
+  ProxyFileSystemWithoutChdir(
+  llvm::IntrusiveRefCntPtr FS)
+  : ProxyFileSystem(std::move(FS)) {}
+
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+assert(!CWD.empty() && "empty CWD");
+return CWD;
+  }
+
+  std::error_code setCurrentWorkingDirectory(const Twine ) override {
+CWD = Path.str();
+return {};
+  }
+
+private:
+  std::string CWD;
+};
+
+/// The high-level implementation of the dependency discovery tool that runs on
+/// an individual worker thread.
+class DependencyScanningTool {
+public:
+  /// Construct a dependency scanning tool.
+  ///
+  /// \param Compilations The reference to the compilation database that's
+  /// used by the clang tool.
+  DependencyScanningTool(const tooling::CompilationDatabase )
+  : Compilations(Compilations) {
+PCHContainerOps = std::make_shared();
+BaseFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
+  }
+
+  /// Computes the dependencies for the given file.
+  ///
+  /// \returns True on error.
+  bool runOnFile(const std::string , StringRef CWD) {
+BaseFS->setCurrentWorkingDirectory(CWD);
+tooling::ClangTool Tool(Compilations, Input, PCHContainerOps, BaseFS);
+Tool.clearArgumentsAdjusters();
+Tool.setRestoreWorkingDir(false);
+PreprocessorOnlyTool Action(CWD);
+return Tool.run();
+  }
+
+private:
+  const tooling::CompilationDatabase 
+  std::shared_ptr PCHContainerOps;
+  /// The real filesystem used as a base for all the operations performed by the
+  /// tool.
+  llvm::IntrusiveRefCntPtr BaseFS;
+};
+
+llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
+ llvm::cl::Hidden);
+
+llvm::cl::OptionCategory DependencyScannerCategory("Tool options");
+
+llvm::cl::opt
+NumThreads("j", llvm::cl::Optional,
+   llvm::cl::desc("Number of worker threads to use (default: use "
+  

[PATCH] D62830: [WebAssembly] Support Leak Sanitizer on Emscripten

2019-06-04 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

I see. Do you want me to commit this, or you are gonna get a commit access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62830



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


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 203029.
serge-sans-paille added a comment.

- make it possible for client code to speicify the registration function for 
new PM, thanks @philip.pfaffe for the hint. @Meinersbur this should be ok now.


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

https://reviews.llvm.org/D61446

Files:
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/CMakeLists.txt
  polly/lib/CMakeLists.txt
  polly/lib/Support/RegisterPasses.cpp
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
Index: polly/lib/Support/RegisterPasses.cpp
===
--- polly/lib/Support/RegisterPasses.cpp
+++ polly/lib/Support/RegisterPasses.cpp
@@ -234,7 +234,6 @@
 cl::desc("Bail out on unprofitable SCoPs before rescheduling"), cl::Hidden,
 cl::init(true), cl::cat(PollyCategory));
 
-namespace polly {
 void initializePollyPasses(PassRegistry ) {
   

  1   2   >