[PATCH] D51802: [clangd] Make advanceTo() faster on Posting Lists

2018-09-10 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




Comment at: clang-tools-extra/clangd/index/dex/Iterator.cpp:41
 assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
+if (peek() >= ID)
+  return;

Maybe add a short comment that this gives performance boost?
Otherwise this looks redundant when reading the code


https://reviews.llvm.org/D51802



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


[PATCH] D51847: Print corrent dependency path on Windows

2018-09-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: zturner.
Herald added a subscriber: cfe-commits.

Before:
main.o: main.c ../include/lib\test.h

After:
main.o: main.c ../include/lib/test.h


Repository:
  rC Clang

https://reviews.llvm.org/D51847

Files:
  lib/Frontend/DependencyFile.cpp


Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -386,28 +386,29 @@
 /// for Windows file-naming info.
 static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
+  std::string &NativePath = llvm::sys::path::convert_to_slash(Filename);   
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
 // NMake, that are legal in a Windows filespec, and that could cause
 // misinterpretation of the dependency string.
-if (Filename.find_first_of(" #${}^!") != StringRef::npos)
-  OS << '\"' << Filename << '\"';
+if (NativePath.find_first_of(" #${}^!") != StringRef::npos)
+  OS << '\"' << NativePath << '\"';
 else
-  OS << Filename;
+  OS << NativePath;
 return;
   }
   assert(OutputFormat == DependencyOutputFormat::Make);
-  for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
-if (Filename[i] == '#') // Handle '#' the broken gcc way.
+  for (unsigned i = 0, e = NativePath.size(); i != e; ++i) {
+if (NativePath[i] == '#') // Handle '#' the broken gcc way.
   OS << '\\';
-else if (Filename[i] == ' ') { // Handle space correctly.
+else if (NativePath[i] == ' ') { // Handle space correctly.
   OS << '\\';
   unsigned j = i;
-  while (j > 0 && Filename[--j] == '\\')
+  while (j > 0 && NativePath[--j] == '\\')
 OS << '\\';
-} else if (Filename[i] == '$') // $ is escaped by $$.
+} else if (NativePath[i] == '$') // $ is escaped by $$.
   OS << '$';
-OS << Filename[i];
+OS << NativePath[i];
   }
 }
 


Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -386,28 +386,29 @@
 /// for Windows file-naming info.
 static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
+  std::string &NativePath = llvm::sys::path::convert_to_slash(Filename);	
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
 // NMake, that are legal in a Windows filespec, and that could cause
 // misinterpretation of the dependency string.
-if (Filename.find_first_of(" #${}^!") != StringRef::npos)
-  OS << '\"' << Filename << '\"';
+if (NativePath.find_first_of(" #${}^!") != StringRef::npos)
+  OS << '\"' << NativePath << '\"';
 else
-  OS << Filename;
+  OS << NativePath;
 return;
   }
   assert(OutputFormat == DependencyOutputFormat::Make);
-  for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
-if (Filename[i] == '#') // Handle '#' the broken gcc way.
+  for (unsigned i = 0, e = NativePath.size(); i != e; ++i) {
+if (NativePath[i] == '#') // Handle '#' the broken gcc way.
   OS << '\\';
-else if (Filename[i] == ' ') { // Handle space correctly.
+else if (NativePath[i] == ' ') { // Handle space correctly.
   OS << '\\';
   unsigned j = i;
-  while (j > 0 && Filename[--j] == '\\')
+  while (j > 0 && NativePath[--j] == '\\')
 OS << '\\';
-} else if (Filename[i] == '$') // $ is escaped by $$.
+} else if (NativePath[i] == '$') // $ is escaped by $$.
   OS << '$';
-OS << Filename[i];
+OS << NativePath[i];
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51847: Print corrent dependency path on Windows

2018-09-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 164620.
xbolva00 added a comment.

Remove some dead code


https://reviews.llvm.org/D51847

Files:
  lib/Frontend/DependencyFile.cpp


Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -386,28 +386,26 @@
 /// for Windows file-naming info.
 static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
+  std::string &NativePath = llvm::sys::path::convert_to_slash(Filename);
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
 // NMake, that are legal in a Windows filespec, and that could cause
 // misinterpretation of the dependency string.
-if (Filename.find_first_of(" #${}^!") != StringRef::npos)
-  OS << '\"' << Filename << '\"';
+if (NativePath.find_first_of(" #${}^!") != StringRef::npos)
+  OS << '\"' << NativePath << '\"';
 else
-  OS << Filename;
+  OS << NativePath;
 return;
   }
   assert(OutputFormat == DependencyOutputFormat::Make);
-  for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
-if (Filename[i] == '#') // Handle '#' the broken gcc way.
+  for (unsigned i = 0, e = NativePath.size(); i != e; ++i) {
+if (NativePath[i] == '#') // Handle '#' the broken gcc way.
   OS << '\\';
-else if (Filename[i] == ' ') { // Handle space correctly.
+else if (NativePath[i] == ' ') // Handle space correctly.
   OS << '\\';
-  unsigned j = i;
-  while (j > 0 && Filename[--j] == '\\')
-OS << '\\';
-} else if (Filename[i] == '$') // $ is escaped by $$.
+else if (NativePath[i] == '$') // $ is escaped by $$.
   OS << '$';
-OS << Filename[i];
+OS << NativePath[i];
   }
 }
 


Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -386,28 +386,26 @@
 /// for Windows file-naming info.
 static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
+  std::string &NativePath = llvm::sys::path::convert_to_slash(Filename);
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
 // NMake, that are legal in a Windows filespec, and that could cause
 // misinterpretation of the dependency string.
-if (Filename.find_first_of(" #${}^!") != StringRef::npos)
-  OS << '\"' << Filename << '\"';
+if (NativePath.find_first_of(" #${}^!") != StringRef::npos)
+  OS << '\"' << NativePath << '\"';
 else
-  OS << Filename;
+  OS << NativePath;
 return;
   }
   assert(OutputFormat == DependencyOutputFormat::Make);
-  for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
-if (Filename[i] == '#') // Handle '#' the broken gcc way.
+  for (unsigned i = 0, e = NativePath.size(); i != e; ++i) {
+if (NativePath[i] == '#') // Handle '#' the broken gcc way.
   OS << '\\';
-else if (Filename[i] == ' ') { // Handle space correctly.
+else if (NativePath[i] == ' ') // Handle space correctly.
   OS << '\\';
-  unsigned j = i;
-  while (j > 0 && Filename[--j] == '\\')
-OS << '\\';
-} else if (Filename[i] == '$') // $ is escaped by $$.
+else if (NativePath[i] == '$') // $ is escaped by $$.
   OS << '$';
-OS << Filename[i];
+OS << NativePath[i];
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5244
+   false))
+CmdArgs.push_back("-fvisibility-inlines-hidden");
+

Huh, does this actually affect whether functions get dllexported or not?


https://reviews.llvm.org/D51340



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


[PATCH] D51802: [clangd] Make advanceTo() faster on Posting Lists

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164623.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Add a short comment on why calling `lower_bound` is redundant. Also, don't 
spend extra line on return by inverting the condition.


https://reviews.llvm.org/D51802

Files:
  clang-tools-extra/clangd/index/dex/Iterator.cpp


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -38,7 +38,10 @@
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
 assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
-Index = std::lower_bound(Index, std::end(Documents), ID);
+// If current ID is beyond requested one, iterator is already in the right
+// state.
+if (peek() < ID)
+  Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 
   DocID peek() const override {


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -38,7 +38,10 @@
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
 assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
-Index = std::lower_bound(Index, std::end(Documents), ID);
+// If current ID is beyond requested one, iterator is already in the right
+// state.
+if (peek() < ID)
+  Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 
   DocID peek() const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

All flags in the m_x86_Features_Group, i.e. -msse, -mavx and so on are all 
supported. I'm just curious to hear what it is that you need from -march?


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[clang-tools-extra] r341781 - [clangd] Make advanceTo() faster on Posting Lists

2018-09-10 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 10 00:57:28 2018
New Revision: 341781

URL: http://llvm.org/viewvc/llvm-project?rev=341781&view=rev
Log:
[clangd] Make advanceTo() faster on Posting Lists

If the current element is already beyond advanceTo()'s DocID, just
return instead of doing binary search. This simple optimization saves up
to 6-7% performance,

Reviewed By: ilya-biryukov

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp?rev=341781&r1=341780&r2=341781&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp Mon Sep 10 00:57:28 
2018
@@ -38,7 +38,10 @@ public:
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
 assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
-Index = std::lower_bound(Index, std::end(Documents), ID);
+// If current ID is beyond requested one, iterator is already in the right
+// state.
+if (peek() < ID)
+  Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 
   DocID peek() const override {


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


[PATCH] D51802: [clangd] Make advanceTo() faster on Posting Lists

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341781: [clangd] Make advanceTo() faster on Posting Lists 
(authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51802?vs=164623&id=164625#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51802

Files:
  clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp


Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
@@ -38,7 +38,10 @@
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
 assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
-Index = std::lower_bound(Index, std::end(Documents), ID);
+// If current ID is beyond requested one, iterator is already in the right
+// state.
+if (peek() < ID)
+  Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 
   DocID peek() const override {


Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
@@ -38,7 +38,10 @@
   /// or higher than the given one.
   void advanceTo(DocID ID) override {
 assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
-Index = std::lower_bound(Index, std::end(Documents), ID);
+// If current ID is beyond requested one, iterator is already in the right
+// state.
+if (peek() < ID)
+  Index = std::lower_bound(Index, std::end(Documents), ID);
   }
 
   DocID peek() const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51391: [clang-cl,PCH] Add support for #pragma hdrstop

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:2862
+  Opts.PCHWithHdrStopCreate =
+  Args.getLastArgValue(OPT_pch_through_hdrstop_EQ) == "create";
   Opts.PCHThroughHeader = Args.getLastArgValue(OPT_pch_through_header_EQ);

mikerice wrote:
> hans wrote:
> > hmm, what if the value is not "create", but also not "use" but something 
> > else? maybe that should be diagnosed, or maybe the flag should be split 
> > into two?
> I am not totally happy with this but I thought one option might be a little 
> better than two.  It would be equivalent to create two options 
> OPT_pch_through_hdrstop_create and OPT_pch_through_hdrstop_use if that seems 
> better (or more usual) to everyone.  I added a diagnostic if the value is not 
> "create" or "use".  A user should never see that though if the front end and 
> driver as in sync.
Thinking about it again, having two separate flags seems more common to me.


https://reviews.llvm.org/D51391



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> Currently the problem is, there are again some tests out there that rely on
>  CodeCompeleteOrdinaryName to be called even when getting overloads at an 
> unknown
>  parameter type

CodeCompleteExpression works just fine there. Unknown parameter type should not 
block code completion.
The idea is that anywhere except the start of the argument expression, we need 
to call **only** signature help. At the start of the argument, we have to call 
both signature help and code completion.
All existing tests pass with the following diff:

  --- a/lib/Parse/ParseExpr.cpp
  +++ b/lib/Parse/ParseExpr.cpp
  @@ -1659,12 +1659,19 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
   
 if (OpKind == tok::l_paren || !LHS.isInvalid()) {
   if (Tok.isNot(tok::r_paren)) {
  -  if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
  -QualType PreferredType = Actions.ProduceCallSignatureHelp(
  -getCurScope(), LHS.get(), ArgExprs, 
PT.getOpenLocation());
  -Actions.CodeCompleteExpression(getCurScope(), PreferredType);
  -  })) {
  +  auto Completer = [&] {
  +QualType PreferredType = Actions.ProduceCallSignatureHelp(
  +getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
  +Actions.CodeCompleteExpression(getCurScope(), PreferredType);
  +CalledOverloadCompletion = true;
  +  };
  +  if (ParseExpressionList(ArgExprs, CommaLocs, Completer)) {
   (void)Actions.CorrectDelayedTyposInExpr(LHS);
  +if (PP.isCodeCompletionReached() && !CalledOverloadCompletion) {
  +  CalledOverloadCompletion = true;
  +  Actions.ProduceCallSignatureHelp(
  +  getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
  +}
   LHS = ExprError();
 } else if (LHS.isInvalid()) {
   for (auto &E : ArgExprs)

Please note there are other places where signature help methods 
(ProduceCallSignatureHelp and ProduceConstructorSignatureHelp) are called, we 
need to handle all of them. List of files that have those calls:

- lib/Parse/ParseExprCXX.cpp
- lib/Parse/ParseOpenMP.cpp
- lib/Parse/ParseExpr.cpp
- lib/Parse/ParseDecl.cpp




Comment at: include/clang/Parse/Parser.h:219
+  /// make sure CodeComleteCall is only called at the deepest level.
+  bool CalledOverloadCompletion = false;
+

NIT: rename to `CalledSignatureHelp`, this shouldn't affect completion


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51774: [clangd] NFC: Rename DexIndex to Dex

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164629.
kbobyrev marked an inline comment as done.

https://reviews.llvm.org/D51774

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/SymbolYAML.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/DexTests.cpp
  clang-tools-extra/unittests/clangd/TestIndex.h

Index: clang-tools-extra/unittests/clangd/TestIndex.h
===
--- clang-tools-extra/unittests/clangd/TestIndex.h
+++ clang-tools-extra/unittests/clangd/TestIndex.h
@@ -12,10 +12,6 @@
 
 #include "index/Index.h"
 #include "index/Merge.h"
-#include "index/dex/DexIndex.h"
-#include "index/dex/Iterator.h"
-#include "index/dex/Token.h"
-#include "index/dex/Trigram.h"
 
 namespace clang {
 namespace clangd {
Index: clang-tools-extra/unittests/clangd/DexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexTests.cpp
@@ -1,4 +1,4 @@
-//===-- DexIndexTests.cpp  *- C++ -*---===//
+//===-- DexTests.cpp  -*- C++ -*---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -12,7 +12,7 @@
 #include "TestIndex.h"
 #include "index/Index.h"
 #include "index/Merge.h"
-#include "index/dex/DexIndex.h"
+#include "index/dex/Dex.h"
 #include "index/dex/Iterator.h"
 #include "index/dex/Token.h"
 #include "index/dex/Trigram.h"
@@ -46,7 +46,7 @@
   return IDs;
 }
 
-TEST(DexIndexIterators, DocumentIterator) {
+TEST(DexIterators, DocumentIterator) {
   const PostingList L = {4, 7, 8, 20, 42, 100};
   auto DocIterator = create(L);
 
@@ -69,7 +69,7 @@
   EXPECT_TRUE(DocIterator->reachedEnd());
 }
 
-TEST(DexIndexIterators, AndWithEmpty) {
+TEST(DexIterators, AndWithEmpty) {
   const PostingList L0;
   const PostingList L1 = {0, 5, 7, 10, 42, 320, 9000};
 
@@ -82,7 +82,7 @@
   EXPECT_THAT(consumeIDs(*AndWithEmpty), ElementsAre());
 }
 
-TEST(DexIndexIterators, AndTwoLists) {
+TEST(DexIterators, AndTwoLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
 
@@ -106,7 +106,7 @@
   And->advanceTo(9001);
 }
 
-TEST(DexIndexIterators, AndThreeLists) {
+TEST(DexIterators, AndThreeLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
   const PostingList L2 = {1, 4, 7, 11, 30, 60, 320, 9000};
@@ -120,7 +120,7 @@
   EXPECT_TRUE(And->reachedEnd());
 }
 
-TEST(DexIndexIterators, OrWithEmpty) {
+TEST(DexIterators, OrWithEmpty) {
   const PostingList L0;
   const PostingList L1 = {0, 5, 7, 10, 42, 320, 9000};
 
@@ -134,7 +134,7 @@
   ElementsAre(0U, 5U, 7U, 10U, 42U, 320U, 9000U));
 }
 
-TEST(DexIndexIterators, OrTwoLists) {
+TEST(DexIterators, OrTwoLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
 
@@ -167,7 +167,7 @@
   ElementsAre(0U, 4U, 5U, 7U, 10U, 30U, 42U, 60U, 320U, 9000U));
 }
 
-TEST(DexIndexIterators, OrThreeLists) {
+TEST(DexIterators, OrThreeLists) {
   const PostingList L0 = {0, 5, 7, 10, 42, 320, 9000};
   const PostingList L1 = {0, 4, 7, 10, 30, 60, 320, 9000};
   const PostingList L2 = {1, 4, 7, 11, 30, 60, 320, 9000};
@@ -197,7 +197,7 @@
 // etc iterators) appear. However, it is not exhaustive and it would be
 // beneficial to implement automatic generation (e.g. fuzzing) of query trees
 // for more comprehensive testing.
-TEST(DexIndexIterators, QueryTree) {
+TEST(DexIterators, QueryTree) {
   //
   //  +-+
   //  |And Iterator:1, 5|
@@ -254,7 +254,7 @@
   EXPECT_TRUE(Root->reachedEnd());
 }
 
-TEST(DexIndexIterators, StringRepresentation) {
+TEST(DexIterators, StringRepresentation) {
   const PostingList L0 = {4, 7, 8, 20, 42, 100};
   const PostingList L1 = {1, 3, 5, 8, 9};
   const PostingList L2 = {1, 5, 7, 9};
@@ -272,7 +272,7 @@
 "END] [{1}, 3, 5, 8, 9, END]))");
 }
 
-TEST(DexIndexIterators, Limit) {
+TEST(DexIterators, Limit) {
   const PostingList L0 = {3, 6, 7, 20, 42, 100};
   const PostingList L1 = {1, 3, 5, 6, 7, 30, 100};
   const PostingList L2 = {0, 3, 5, 7, 8, 100};
@@ -292,7 +292,7 @@
   EXPECT_THAT(consumeIDs(*AndIterator), ElementsAre(3, 7));
 }
 
-TEST(DexIndexIterators, True) {
+TEST(DexIterators, True) {
   auto TrueIterator = createTrue(0U);
   EXPECT_TRUE(TrueIterator->reachedEnd());
   EXPECT_THAT(consumeIDs(*TrueIterator), ElementsAre());
@@ -305,7 +305,7 @@
   EXPECT_THAT(consumeIDs(*AndIterator), ElementsAre(1, 2, 5));
 }
 
-TEST(DexIndexIterators, Boost) {
+TEST(DexIterators, Boost) {
   auto BoostIterator = createBoost(createTrue

[clang-tools-extra] r341784 - [clangd] NFC: Rename DexIndex to Dex

2018-09-10 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 10 01:23:53 2018
New Revision: 341784

URL: http://llvm.org/viewvc/llvm-project?rev=341784&view=rev
Log:
[clangd] NFC: Rename DexIndex to Dex

Also, cleanup some redundant includes.

Reviewed By: sammccall

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

Added:
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.h
clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
Removed:
clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp
clang-tools-extra/trunk/clangd/index/dex/DexIndex.h
clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/TestIndex.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=341784&r1=341783&r2=341784&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Sep 10 01:23:53 2018
@@ -46,7 +46,7 @@ add_clang_library(clangDaemon
   index/SymbolCollector.cpp
   index/SymbolYAML.cpp
 
-  index/dex/DexIndex.cpp
+  index/dex/Dex.cpp
   index/dex/Iterator.cpp
   index/dex/Trigram.cpp
 

Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp?rev=341784&r1=341783&r2=341784&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp Mon Sep 10 01:23:53 2018
@@ -11,7 +11,7 @@
 #include "Index.h"
 #include "Serialization.h"
 #include "Trace.h"
-#include "dex/DexIndex.h"
+#include "dex/Dex.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Errc.h"
@@ -225,7 +225,7 @@ std::unique_ptr loadIndex(l
   if (!Slab)
 return nullptr;
   trace::Span Tracer("BuildIndex");
-  return UseDex ? dex::DexIndex::build(std::move(*Slab), URISchemes)
+  return UseDex ? dex::Dex::build(std::move(*Slab), URISchemes)
 : MemIndex::build(std::move(*Slab), RefSlab());
 }
 

Added: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Dex.cpp?rev=341784&view=auto
==
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp (added)
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp Mon Sep 10 01:23:53 2018
@@ -0,0 +1,270 @@
+//===--- Dex.cpp - Dex Symbol Index Implementation --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Dex.h"
+#include "FileDistance.h"
+#include "FuzzyMatch.h"
+#include "Logger.h"
+#include "Quality.h"
+#include "llvm/ADT/StringSet.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace dex {
+
+namespace {
+
+// Returns the tokens which are given symbol's characteristics. Currently, the
+// generated tokens only contain fuzzy matching trigrams and symbol's scope,
+// but in the future this will also return path proximity tokens and other
+// types of tokens such as symbol type (if applicable).
+// Returns the tokens which are given symbols's characteristics. For example,
+// trigrams and scopes.
+// FIXME(kbobyrev): Support more token types:
+// * Types
+// * Namespace proximity
+std::vector generateSearchTokens(const Symbol &Sym) {
+  std::vector Result = generateIdentifierTrigrams(Sym.Name);
+  Result.emplace_back(Token::Kind::Scope, Sym.Scope);
+  // Skip token generation for symbols with unknown declaration location.
+  if (!Sym.CanonicalDeclaration.FileURI.empty())
+for (const auto &ProximityURI :
+ generateProximityURIs(Sym.CanonicalDeclaration.FileURI))
+  Result.emplace_back(Token::Kind::ProximityURI, ProximityURI);
+  return Result;
+}
+
+// Constructs BOOST iterators for Path Proximities.
+std::vector> createFileProximityIterators(
+llvm::ArrayRef ProximityPaths,
+llvm::ArrayRef URISchemes,
+const llvm::DenseMap &InvertedIndex) {
+  std::vector> BoostingIterators;
+  // Deduplicate parent URIs extracted from the ProximityPaths.
+  llvm::StringSet<> ParentURIs;
+  llvm::StringMap Sources;
+  for (const auto &Path : ProximityPaths) {
+Sources[Path] = SourceParams();
+auto PathURI = URI::create(Path, URISchemes);

[PATCH] D51774: [clangd] NFC: Rename DexIndex to Dex

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE341784: [clangd] NFC: Rename DexIndex to Dex (authored by 
omtcyfz, committed by ).
Herald added a subscriber: mgrang.

Changed prior to commit:
  https://reviews.llvm.org/D51774?vs=164629&id=164630#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51774

Files:
  clangd/CMakeLists.txt
  clangd/index/SymbolYAML.cpp
  clangd/index/dex/Dex.cpp
  clangd/index/dex/Dex.h
  clangd/index/dex/DexIndex.cpp
  clangd/index/dex/DexIndex.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/DexIndexTests.cpp
  unittests/clangd/DexTests.cpp
  unittests/clangd/TestIndex.h

Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -46,7 +46,7 @@
   index/SymbolCollector.cpp
   index/SymbolYAML.cpp
 
-  index/dex/DexIndex.cpp
+  index/dex/Dex.cpp
   index/dex/Iterator.cpp
   index/dex/Trigram.cpp
 
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -13,7 +13,6 @@
 #include "RIFF.h"
 #include "Trace.h"
 #include "index/SymbolYAML.h"
-#include "index/dex/DexIndex.h"
 #include "clang/Basic/Version.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
Index: clangd/index/dex/Dex.h
===
--- clangd/index/dex/Dex.h
+++ clangd/index/dex/Dex.h
@@ -0,0 +1,113 @@
+//===--- Dex.h - Dex Symbol Index Implementation *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines Dex - a symbol index implementation based on query iterators
+// over symbol tokens, such as fuzzy matching trigrams, scopes, types, etc.
+// While consuming more memory and having longer build stage due to
+// preprocessing, Dex will have substantially lower latency. It will also allow
+// efficient symbol searching which is crucial for operations like code
+// completion, and can be very important for a number of different code
+// transformations which will be eventually supported by Clangd.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H
+
+#include "Iterator.h"
+#include "Token.h"
+#include "Trigram.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "index/SymbolCollector.h"
+
+namespace clang {
+namespace clangd {
+namespace dex {
+
+/// In-memory Dex trigram-based index implementation.
+// FIXME(kbobyrev): Introduce serialization and deserialization of the symbol
+// index so that it can be loaded from the disk. Since static index is not
+// changed frequently, it's safe to assume that it has to be built only once
+// (when the clangd process starts). Therefore, it can be easier to store built
+// index on disk and then load it if available.
+class Dex : public SymbolIndex {
+public:
+  // All symbols must outlive this index.
+  template 
+  Dex(Range &&Symbols, llvm::ArrayRef Schemes)
+  : URISchemes(Schemes) {
+// If Schemes don't contain any items, fall back to SymbolCollector's
+// default URI schemes.
+if (URISchemes.empty()) {
+  SymbolCollector::Options Opts;
+  URISchemes = Opts.URISchemes;
+}
+for (auto &&Sym : Symbols)
+  this->Symbols.push_back(&Sym);
+buildIndex();
+  }
+  // Symbols are owned by BackingData, Index takes ownership.
+  template 
+  Dex(Range &&Symbols, Payload &&BackingData,
+  llvm::ArrayRef URISchemes)
+  : Dex(std::forward(Symbols), URISchemes) {
+KeepAlive = std::shared_ptr(
+std::make_shared(std::move(BackingData)), nullptr);
+  }
+
+  /// Builds an index from a slab. The index takes ownership of the slab.
+  static std::unique_ptr
+  build(SymbolSlab Slab, llvm::ArrayRef URISchemes) {
+return llvm::make_unique(Slab, std::move(Slab), URISchemes);
+  }
+
+  bool
+  fuzzyFind(const FuzzyFindRequest &Req,
+llvm::function_ref Callback) const override;
+
+  void lookup(const LookupRequest &Req,
+  llvm::function_ref Callback) const override;
+
+  void refs(const RefsRequest &Req,
+llvm::function_ref Callback) const override;
+
+  size_t estimateMemoryUsage() const override;
+
+private:
+  void buildIndex();
+
+  /// Stores symbols sorted in the descending order of symbol quality..
+  std::vector Symbols;
+  /// SymbolQuality[I] is the quality of Symbols[I].
+  std::vector SymbolQuality;
+  llvm::DenseMap LookupTable;
+  /// Inverted index is a mapping from the search token to the p

r341786 - ReleaseNotes: update links to use https

2018-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Sep 10 01:51:25 2018
New Revision: 341786

URL: http://llvm.org/viewvc/llvm-project?rev=341786&view=rev
Log:
ReleaseNotes: update links to use https

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=341786&r1=341785&r2=341786&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Sep 10 01:51:25 2018
@@ -6,13 +6,13 @@ Clang 8.0.0 (In-Progress) Release Notes
:local:
:depth: 2
 
-Written by the `LLVM Team `_
+Written by the `LLVM Team `_
 
 .. warning::
 
These are in-progress notes for the upcoming Clang 8 release.
Release notes for previous releases can be found on
-   `the Download Page `_.
+   `the Download Page `_.
 
 Introduction
 
@@ -22,18 +22,18 @@ frontend, part of the LLVM Compiler Infr
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
-documentation `_. All LLVM
+documentation `_. All LLVM
 releases may be downloaded from the `LLVM releases web
-site `_.
+site `_.
 
 For more information about Clang or LLVM, including information about the
-latest release, please see the `Clang Web Site `_ or the
-`LLVM Web Site `_.
+latest release, please see the `Clang Web Site `_ or 
the
+`LLVM Web Site `_.
 
 Note that if you are reading this file from a Subversion checkout or the
 main Clang web page, this document applies to the *next* release, not
 the current one. To see the release notes for a specific release, please
-see the `releases page `_.
+see the `releases page `_.
 
 What's New in Clang 8.0.0?
 ==
@@ -193,7 +193,7 @@ Additional Information
 ==
 
 A wide variety of additional information is available on the `Clang web
-page `_. The web page contains versions of the
+page `_. The web page contains versions of the
 API documentation which are up-to-date with the Subversion version of
 the source code. You can access versions of these documents specific to
 this release by going into the "``clang/docs/``" directory in the Clang
@@ -201,4 +201,4 @@ tree.
 
 If you have any questions or comments about Clang, please feel free to
 contact us via the `mailing
-list `_.
+list `_.


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


[clang-tools-extra] r341787 - ReleaseNotes: update links to use https

2018-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Sep 10 01:52:04 2018
New Revision: 341787

URL: http://llvm.org/viewvc/llvm-project?rev=341787&view=rev
Log:
ReleaseNotes: update links to use https

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=341787&r1=341786&r2=341787&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon Sep 10 01:52:04 2018
@@ -6,13 +6,13 @@ Extra Clang Tools 8.0.0 (In-Progress) Re
:local:
:depth: 3
 
-Written by the `LLVM Team `_
+Written by the `LLVM Team `_
 
 .. warning::
 
These are in-progress notes for the upcoming Extra Clang Tools 8 release.
Release notes for previous releases can be found on
-   `the Download Page `_.
+   `the Download Page `_.
 
 Introduction
 
@@ -21,16 +21,16 @@ This document contains the release notes
 Clang release 8.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
-site `_.
+site `_.
 
 For more information about Clang or LLVM, including information about
-the latest release, please see the `Clang Web Site `_ or
-the `LLVM Web Site `_.
+the latest release, please see the `Clang Web Site `_ 
or
+the `LLVM Web Site `_.
 
 Note that if you are reading this file from a Subversion checkout or the
 main Clang web page, this document applies to the *next* release, not
 the current one. To see the release notes for a specific release, please
-see the `releases page `_.
+see the `releases page `_.
 
 What's New in Extra Clang Tools 8.0.0?
 ==


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


[libcxx] r341789 - ReleaseNotes: update links to use https

2018-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Sep 10 01:57:12 2018
New Revision: 341789

URL: http://llvm.org/viewvc/llvm-project?rev=341789&view=rev
Log:
ReleaseNotes: update links to use https

Modified:
libcxx/trunk/docs/ReleaseNotes.rst

Modified: libcxx/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/ReleaseNotes.rst?rev=341789&r1=341788&r2=341789&view=diff
==
--- libcxx/trunk/docs/ReleaseNotes.rst (original)
+++ libcxx/trunk/docs/ReleaseNotes.rst Mon Sep 10 01:57:12 2018
@@ -6,13 +6,13 @@ Libc++ 8.0.0 (In-Progress) Release Notes
:local:
:depth: 2
 
-Written by the `Libc++ Team `_
+Written by the `Libc++ Team `_
 
 .. warning::
 
These are in-progress notes for the upcoming libc++ 8 release.
Release notes for previous releases can be found on
-   `the Download Page `_.
+   `the Download Page `_.
 
 Introduction
 
@@ -21,16 +21,16 @@ This document contains the release notes
 part of the LLVM Compiler Infrastructure, release 8.0.0. Here we describe the
 status of libc++ in some detail, including major improvements from the previous
 release and new feature work. For the general LLVM release notes, see `the LLVM
-documentation `_. All LLVM releases may
-be downloaded from the `LLVM releases web site `_.
+documentation `_. All LLVM releases 
may
+be downloaded from the `LLVM releases web site `_.
 
 For more information about libc++, please see the `Libc++ Web Site
-`_ or the `LLVM Web Site `_.
+`_ or the `LLVM Web Site `_.
 
 Note that if you are reading this file from a Subversion checkout or the
 main Libc++ web page, this document applies to the *next* release, not
 the current one. To see the release notes for a specific release, please
-see the `releases page `_.
+see the `releases page `_.
 
 What's New in Libc++ 8.0.0?
 ===


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


r341790 - [Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function parameters

2018-09-10 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Sep 10 02:03:22 2018
New Revision: 341790

URL: http://llvm.org/viewvc/llvm-project?rev=341790&view=rev
Log:
[Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function 
parameters

New check added to the checker which checks whether iterator parameters of 
template functions typed by the same template parameter refer to the same 
container.

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


Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/invalidated-iterator.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=341790&r1=341789&r2=341790&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Sep 10 
02:03:22 2018
@@ -309,12 +309,16 @@ def DeleteWithNonVirtualDtorChecker : Ch
"destructor in their base class">,
   DescFile<"DeleteWithNonVirtualDtorChecker.cpp">;
 
+def InvalidatedIteratorChecker : Checker<"InvalidatedIterator">,
+  HelpText<"Check for use of invalidated iterators">,
+  DescFile<"IteratorChecker.cpp">;
+
 def IteratorRangeChecker : Checker<"IteratorRange">,
   HelpText<"Check for iterators used outside their valid ranges">,
   DescFile<"IteratorChecker.cpp">;
 
-def InvalidatedIteratorChecker : Checker<"InvalidatedIterator">,
-  HelpText<"Check for use of invalidated iterators">,
+def MismatchedIteratorChecker : Checker<"MismatchedIterator">,
+  HelpText<"Check for use of iterators of different containers where iterators 
of the same container are expected">,
   DescFile<"IteratorChecker.cpp">;
 
 def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=341790&r1=341789&r2=341790&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon Sep 10 
02:03:22 2018
@@ -198,6 +198,7 @@ class IteratorChecker
  eval::Assume> {
 
   std::unique_ptr OutOfRangeBugType;
+  std::unique_ptr MismatchedBugType;
   std::unique_ptr InvalidatedBugType;
 
   void handleComparison(CheckerContext &C, const SVal &RetVal, const SVal 
&LVal,
@@ -221,8 +222,14 @@ class IteratorChecker
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
+  void verifyMatch(CheckerContext &C, const SVal &Iter1,
+   const SVal &Iter2) const;
+
   void reportOutOfRangeBug(const StringRef &Message, const SVal &Val,
CheckerContext &C, ExplodedNode *ErrNode) const;
+  void reportMismatchedBug(const StringRef &Message, const SVal &Val1,
+   const SVal &Val2, CheckerContext &C,
+   ExplodedNode *ErrNode) const;
   void reportInvalidatedBug(const StringRef &Message, const SVal &Val,
 CheckerContext &C, ExplodedNode *ErrNode) const;
 
@@ -231,6 +238,7 @@ public:
 
   enum CheckKind {
 CK_IteratorRangeChecker,
+CK_MismatchedIteratorChecker,
 CK_InvalidatedIteratorChecker,
 CK_NumCheckKinds
   };
@@ -312,6 +320,8 @@ const ContainerData *getContainerData(Pr
 ProgramStateRef setContainerData(ProgramStateRef State, const MemRegion *Cont,
  const ContainerData &CData);
 bool hasLiveIterators(ProgramStateRef State, const MemRegion *Cont);
+bool isBoundThroughLazyCompoundVal(const Environment &Env,
+   const MemRegion *Reg);
 bool isOutOfRange(ProgramStateRef State, const IteratorPosition &Pos);
 bool isZero(ProgramStateRef State, const NonLoc &Val);
 } // namespace
@@ -320,6 +330,9 @@ IteratorChecker::IteratorChecker() {
   OutOfRangeBugType.reset(
   new BugType(this, "Iterator out of range", "Misuse of STL APIs"));
   OutOfRangeBugType->setSuppressOnSink(true);
+  MismatchedBugType.reset(
+  new BugType(this, "Iterator(s) mismatched", "Misuse of STL APIs"));
+  MismatchedBugType->setSuppressOnSink(true);
   InvalidatedBugType.reset(
   new BugType(this, "Iterator invalidated", "Misuse of STL APIs"));
   InvalidatedBugType->setSuppressOnSink(true);
@@ -368,6 +381,65 @@ void IteratorChecker::checkPreCall(const
 verifyDereference(C, Call.getArgSVal(0));
   }
 }
+  } else if (

[PATCH] D32845: [Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function parameters

2018-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
baloghadamsoftware marked an inline comment as done.
Closed by commit rC341790: [Analyzer] Iterator Checker - Part 4: Mismatched 
iterator checker for function… (authored by baloghadamsoftware, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D32845?vs=163671&id=164631#toc

Repository:
  rC Clang

https://reviews.llvm.org/D32845

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/invalidated-iterator.cpp

Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -198,6 +198,7 @@
  eval::Assume> {
 
   std::unique_ptr OutOfRangeBugType;
+  std::unique_ptr MismatchedBugType;
   std::unique_ptr InvalidatedBugType;
 
   void handleComparison(CheckerContext &C, const SVal &RetVal, const SVal &LVal,
@@ -221,16 +222,23 @@
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
+  void verifyMatch(CheckerContext &C, const SVal &Iter1,
+   const SVal &Iter2) const;
+
   void reportOutOfRangeBug(const StringRef &Message, const SVal &Val,
CheckerContext &C, ExplodedNode *ErrNode) const;
+  void reportMismatchedBug(const StringRef &Message, const SVal &Val1,
+   const SVal &Val2, CheckerContext &C,
+   ExplodedNode *ErrNode) const;
   void reportInvalidatedBug(const StringRef &Message, const SVal &Val,
 CheckerContext &C, ExplodedNode *ErrNode) const;
 
 public:
   IteratorChecker();
 
   enum CheckKind {
 CK_IteratorRangeChecker,
+CK_MismatchedIteratorChecker,
 CK_InvalidatedIteratorChecker,
 CK_NumCheckKinds
   };
@@ -312,14 +320,19 @@
 ProgramStateRef setContainerData(ProgramStateRef State, const MemRegion *Cont,
  const ContainerData &CData);
 bool hasLiveIterators(ProgramStateRef State, const MemRegion *Cont);
+bool isBoundThroughLazyCompoundVal(const Environment &Env,
+   const MemRegion *Reg);
 bool isOutOfRange(ProgramStateRef State, const IteratorPosition &Pos);
 bool isZero(ProgramStateRef State, const NonLoc &Val);
 } // namespace
 
 IteratorChecker::IteratorChecker() {
   OutOfRangeBugType.reset(
   new BugType(this, "Iterator out of range", "Misuse of STL APIs"));
   OutOfRangeBugType->setSuppressOnSink(true);
+  MismatchedBugType.reset(
+  new BugType(this, "Iterator(s) mismatched", "Misuse of STL APIs"));
+  MismatchedBugType->setSuppressOnSink(true);
   InvalidatedBugType.reset(
   new BugType(this, "Iterator invalidated", "Misuse of STL APIs"));
   InvalidatedBugType->setSuppressOnSink(true);
@@ -368,6 +381,65 @@
 verifyDereference(C, Call.getArgSVal(0));
   }
 }
+  } else if (!isa(&Call)) {
+// The main purpose of iterators is to abstract away from different
+// containers and provide a (maybe limited) uniform access to them.
+// This implies that any correctly written template function that
+// works on multiple containers using iterators takes different
+// template parameters for different containers. So we can safely
+// assume that passing iterators of different containers as arguments
+// whose type replaces the same template parameter is a bug.
+//
+// Example:
+// template
+// void f(I1 first1, I1 last1, I2 first2, I2 last2);
+// 
+// In this case the first two arguments to f() must be iterators must belong
+// to the same container and the last to also to the same container but
+// not neccessarily to the same as the first two.
+
+if (!ChecksEnabled[CK_MismatchedIteratorChecker])
+  return;
+
+const auto *Templ = Func->getPrimaryTemplate();
+if (!Templ)
+  return;
+
+const auto *TParams = Templ->getTemplateParameters();
+const auto *TArgs = Func->getTemplateSpecializationArgs();
+
+// Iterate over all the template parameters
+for (size_t I = 0; I < TParams->size(); ++I) {
+  const auto *TPDecl = dyn_cast(TParams->getParam(I));
+  if (!TPDecl)
+continue;
+
+  if (TPDecl->isParameterPack())
+continue;
+
+  const auto TAType = TArgs->get(I).getAsType();
+  if (!isIteratorType(TAType))
+continue;
+
+  SVal LHS = UndefinedVal();
+
+  // For every template parameter which is an iterator type in the
+  // instantiation look for all functions' parameters' type by it and
+  // check whether they belong to the same container
+  for (auto J = 0U; J < Func->getNumParams(); ++J

r341791 - [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers

2018-09-10 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Sep 10 02:04:27 2018
New Revision: 341791

URL: http://llvm.org/viewvc/llvm-project?rev=341791&view=rev
Log:
[Analyzer] Iterator Checker - Part 5: Move Assignment of Containers

If a container is moved by its move assignment operator, according to the 
standard all their iterators except the past-end iterators remain valid but 
refer to the new container. This patch introduces support for this case in the 
iterator checkers.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=341791&r1=341790&r2=341791&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon Sep 10 
02:04:27 2018
@@ -114,6 +114,10 @@ public:
 return IteratorPosition(Cont, Valid, NewOf);
   }
 
+  IteratorPosition reAssign(const MemRegion *NewCont) const {
+return IteratorPosition(NewCont, Valid, Offset);
+  }
+
   bool operator==(const IteratorPosition &X) const {
 return Cont == X.Cont && Valid == X.Valid && Offset == X.Offset;
   }
@@ -218,7 +222,9 @@ class IteratorChecker
  const SVal &Cont) const;
   void assignToContainer(CheckerContext &C, const Expr *CE, const SVal &RetVal,
  const MemRegion *Cont) const;
-  void handleAssign(CheckerContext &C, const SVal &Cont) const;
+  void handleAssign(CheckerContext &C, const SVal &Cont,
+const Expr *CE = nullptr,
+const SVal &OldCont = UndefinedVal()) const;
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
@@ -315,6 +321,17 @@ ProgramStateRef relateIteratorPositions(
 bool Equal);
 ProgramStateRef invalidateAllIteratorPositions(ProgramStateRef State,
const MemRegion *Cont);
+ProgramStateRef reassignAllIteratorPositions(ProgramStateRef State,
+ const MemRegion *Cont,
+ const MemRegion *NewCont);
+ProgramStateRef reassignAllIteratorPositionsUnless(ProgramStateRef State,
+   const MemRegion *Cont,
+   const MemRegion *NewCont,
+   SymbolRef Offset,
+   BinaryOperator::Opcode Opc);
+ProgramStateRef rebaseSymbolInIteratorPositionsIf(
+ProgramStateRef State, SValBuilder &SVB, SymbolRef OldSym,
+SymbolRef NewSym, SymbolRef CondSym, BinaryOperator::Opcode Opc);
 const ContainerData *getContainerData(ProgramStateRef State,
   const MemRegion *Cont);
 ProgramStateRef setContainerData(ProgramStateRef State, const MemRegion *Cont,
@@ -454,7 +471,12 @@ void IteratorChecker::checkPostCall(cons
 const auto Op = Func->getOverloadedOperator();
 if (isAssignmentOperator(Op)) {
   const auto *InstCall = dyn_cast(&Call);
-  handleAssign(C, InstCall->getCXXThisVal());
+  if (Func->getParamDecl(0)->getType()->isRValueReferenceType()) {
+handleAssign(C, InstCall->getCXXThisVal(), Call.getOriginExpr(),
+ Call.getArgSVal(0));
+  } else {
+handleAssign(C, InstCall->getCXXThisVal());
+  }
 } else if (isSimpleComparisonOperator(Op)) {
   if (const auto *InstCall = dyn_cast(&Call)) {
 handleComparison(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
@@ -503,9 +525,6 @@ void IteratorChecker::checkPostCall(cons
   return;
 
 auto State = C.getState();
-// Already bound to container?
-if (getIteratorPosition(State, Call.getReturnValue()))
-  return;
 
 if (const auto *InstCall = dyn_cast(&Call)) {
   if (isBeginCall(Func)) {
@@ -520,6 +539,10 @@ void IteratorChecker::checkPostCall(cons
   }
 }
 
+// Already bound to container?
+if (getIteratorPosition(State, Call.getReturnValue()))
+  return;
+
 // Copy-like and move constructors
 if (isa(&Call) && Call.getNumArgs() == 1) {
   if (const auto *Pos = getIteratorPosition(State, Call.getArgSVal(0))) {
@@ -981,7 +1004,8 @@ void IteratorChecker::assignToContainer(
   C.addTransition(State);
 }
 
-void IteratorChecker::handleAssign(CheckerContext &C, const SVal &Cont) const {
+void IteratorChecker::handleAssign(CheckerContext &C, const SVal &Cont,
+   const Expr *CE, const SVal &OldCont) const {
   const auto *ContRe

[PATCH] D32859: [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers

2018-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341791: [Analyzer] Iterator Checker - Part 5: Move 
Assignment of Containers (authored by baloghadamsoftware, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D32859?vs=163725&id=164632#toc

Repository:
  rC Clang

https://reviews.llvm.org/D32859

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -114,6 +114,10 @@
 return IteratorPosition(Cont, Valid, NewOf);
   }
 
+  IteratorPosition reAssign(const MemRegion *NewCont) const {
+return IteratorPosition(NewCont, Valid, Offset);
+  }
+
   bool operator==(const IteratorPosition &X) const {
 return Cont == X.Cont && Valid == X.Valid && Offset == X.Offset;
   }
@@ -218,7 +222,9 @@
  const SVal &Cont) const;
   void assignToContainer(CheckerContext &C, const Expr *CE, const SVal &RetVal,
  const MemRegion *Cont) const;
-  void handleAssign(CheckerContext &C, const SVal &Cont) const;
+  void handleAssign(CheckerContext &C, const SVal &Cont,
+const Expr *CE = nullptr,
+const SVal &OldCont = UndefinedVal()) const;
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
@@ -315,6 +321,17 @@
 bool Equal);
 ProgramStateRef invalidateAllIteratorPositions(ProgramStateRef State,
const MemRegion *Cont);
+ProgramStateRef reassignAllIteratorPositions(ProgramStateRef State,
+ const MemRegion *Cont,
+ const MemRegion *NewCont);
+ProgramStateRef reassignAllIteratorPositionsUnless(ProgramStateRef State,
+   const MemRegion *Cont,
+   const MemRegion *NewCont,
+   SymbolRef Offset,
+   BinaryOperator::Opcode Opc);
+ProgramStateRef rebaseSymbolInIteratorPositionsIf(
+ProgramStateRef State, SValBuilder &SVB, SymbolRef OldSym,
+SymbolRef NewSym, SymbolRef CondSym, BinaryOperator::Opcode Opc);
 const ContainerData *getContainerData(ProgramStateRef State,
   const MemRegion *Cont);
 ProgramStateRef setContainerData(ProgramStateRef State, const MemRegion *Cont,
@@ -454,7 +471,12 @@
 const auto Op = Func->getOverloadedOperator();
 if (isAssignmentOperator(Op)) {
   const auto *InstCall = dyn_cast(&Call);
-  handleAssign(C, InstCall->getCXXThisVal());
+  if (Func->getParamDecl(0)->getType()->isRValueReferenceType()) {
+handleAssign(C, InstCall->getCXXThisVal(), Call.getOriginExpr(),
+ Call.getArgSVal(0));
+  } else {
+handleAssign(C, InstCall->getCXXThisVal());
+  }
 } else if (isSimpleComparisonOperator(Op)) {
   if (const auto *InstCall = dyn_cast(&Call)) {
 handleComparison(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
@@ -503,9 +525,6 @@
   return;
 
 auto State = C.getState();
-// Already bound to container?
-if (getIteratorPosition(State, Call.getReturnValue()))
-  return;
 
 if (const auto *InstCall = dyn_cast(&Call)) {
   if (isBeginCall(Func)) {
@@ -520,6 +539,10 @@
   }
 }
 
+// Already bound to container?
+if (getIteratorPosition(State, Call.getReturnValue()))
+  return;
+
 // Copy-like and move constructors
 if (isa(&Call) && Call.getNumArgs() == 1) {
   if (const auto *Pos = getIteratorPosition(State, Call.getArgSVal(0))) {
@@ -981,7 +1004,8 @@
   C.addTransition(State);
 }
 
-void IteratorChecker::handleAssign(CheckerContext &C, const SVal &Cont) const {
+void IteratorChecker::handleAssign(CheckerContext &C, const SVal &Cont,
+   const Expr *CE, const SVal &OldCont) const {
   const auto *ContReg = Cont.getAsRegion();
   if (!ContReg)
 return;
@@ -998,6 +1022,65 @@
 State = invalidateAllIteratorPositions(State, ContReg);
   }
 
+  // In case of move, iterators of the old container (except the past-end
+  // iterators) remain valid but refer to the new container
+  if (!OldCont.isUndef()) {
+const auto *OldContReg = OldCont.getAsRegion();
+if (OldContReg) {
+  while (const auto *CBOR = OldContReg->getAs()) {
+OldContReg = CBOR->getSuperRegion();
+  }
+  const auto OldCData = getContainerData(State, OldContReg);
+  if (OldCData) {
+if (const auto OldEndSym = OldCData->getE

r341792 - [Analyzer] Iterator Checker - Part 6: Mismatched iterator checker for constructors and comparisons

2018-09-10 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Sep 10 02:05:31 2018
New Revision: 341792

URL: http://llvm.org/viewvc/llvm-project?rev=341792&view=rev
Log:
[Analyzer] Iterator Checker - Part 6: Mismatched iterator checker for 
constructors and comparisons

Extension of the mismatched iterator checker for constructors taking range of 
first..last (first and last must be iterators of the same container) and also 
for comparisons of iterators of different containers (one does not compare 
iterators of different containers, since the set of iterators is partially 
ordered, there are no relations between iterators of different containers, 
except that they are always non-equal).

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=341792&r1=341791&r2=341792&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon Sep 10 
02:05:31 2018
@@ -236,6 +236,9 @@ class IteratorChecker
   void reportMismatchedBug(const StringRef &Message, const SVal &Val1,
const SVal &Val2, CheckerContext &C,
ExplodedNode *ErrNode) const;
+  void reportMismatchedBug(const StringRef &Message, const SVal &Val,
+   const MemRegion *Reg, CheckerContext &C,
+   ExplodedNode *ErrNode) const;
   void reportInvalidatedBug(const StringRef &Message, const SVal &Val,
 CheckerContext &C, ExplodedNode *ErrNode) const;
 
@@ -276,6 +279,7 @@ namespace {
 
 bool isIteratorType(const QualType &Type);
 bool isIterator(const CXXRecordDecl *CRD);
+bool isComparisonOperator(OverloadedOperatorKind OK);
 bool isBeginCall(const FunctionDecl *Func);
 bool isEndCall(const FunctionDecl *Func);
 bool isAssignmentOperator(OverloadedOperatorKind OK);
@@ -397,8 +401,48 @@ void IteratorChecker::checkPreCall(const
   } else {
 verifyDereference(C, Call.getArgSVal(0));
   }
+} else if (ChecksEnabled[CK_MismatchedIteratorChecker] &&
+   isComparisonOperator(Func->getOverloadedOperator())) {
+  // Check for comparisons of iterators of different containers
+  if (const auto *InstCall = dyn_cast(&Call)) {
+if (Call.getNumArgs() < 1)
+  return;
+
+if (!isIteratorType(InstCall->getCXXThisExpr()->getType()) ||
+!isIteratorType(Call.getArgExpr(0)->getType()))
+  return;
+
+verifyMatch(C, InstCall->getCXXThisVal(), Call.getArgSVal(0));
+  } else {
+if (Call.getNumArgs() < 2)
+  return;
+
+if (!isIteratorType(Call.getArgExpr(0)->getType()) ||
+!isIteratorType(Call.getArgExpr(1)->getType()))
+  return;
+
+verifyMatch(C, Call.getArgSVal(0), Call.getArgSVal(1));
+  }
 }
-  } else if (!isa(&Call)) {
+  } else if (isa(&Call)) {
+// Check match of first-last iterator pair in a constructor of a container
+if (Call.getNumArgs() < 2)
+  return;
+
+const auto *Ctr = cast(Call.getDecl());
+if (Ctr->getNumParams() < 2)
+  return;
+
+if (Ctr->getParamDecl(0)->getName() != "first" ||
+Ctr->getParamDecl(1)->getName() != "last")
+  return;
+
+if (!isIteratorType(Call.getArgExpr(0)->getType()) ||
+!isIteratorType(Call.getArgExpr(1)->getType()))
+  return;
+
+verifyMatch(C, Call.getArgSVal(0), Call.getArgSVal(1));
+  } else {
 // The main purpose of iterators is to abstract away from different
 // containers and provide a (maybe limited) uniform access to them.
 // This implies that any correctly written template function that
@@ -1102,6 +1146,16 @@ void IteratorChecker::reportMismatchedBu
   C.emitReport(std::move(R));
 }
 
+void IteratorChecker::reportMismatchedBug(const StringRef &Message,
+  const SVal &Val, const MemRegion 
*Reg,
+  CheckerContext &C,
+  ExplodedNode *ErrNode) const {
+  auto R = llvm::make_unique(*MismatchedBugType, Message, ErrNode);
+  R->markInteresting(Val);
+  R->markInteresting(Reg);
+  C.emitReport(std::move(R));
+}
+
 void IteratorChecker::reportInvalidatedBug(const StringRef &Message,
const SVal &Val, CheckerContext &C,
ExplodedNode *ErrNode) const {
@@ -1173,6 +1227,11 @@ bool isIterator(const CXXRecordDecl *CRD
  HasPostIncrOp && HasDerefOp;
 }
 
+bool isComparisonOperator(OverloadedOperatorKind OK) {
+  return OK == OO_EqualEqual || OK == OO_ExclaimEqual || OK == OO_Less ||
+ OK == OO_Les

[PATCH] D32860: [Analyzer] Iterator Checker - Part 6: Mismatched iterator checker for constructors and comparisons

2018-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341792: [Analyzer] Iterator Checker - Part 6: Mismatched 
iterator checker for… (authored by baloghadamsoftware, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D32860?vs=163736&id=164635#toc

Repository:
  rC Clang

https://reviews.llvm.org/D32860

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -236,6 +236,9 @@
   void reportMismatchedBug(const StringRef &Message, const SVal &Val1,
const SVal &Val2, CheckerContext &C,
ExplodedNode *ErrNode) const;
+  void reportMismatchedBug(const StringRef &Message, const SVal &Val,
+   const MemRegion *Reg, CheckerContext &C,
+   ExplodedNode *ErrNode) const;
   void reportInvalidatedBug(const StringRef &Message, const SVal &Val,
 CheckerContext &C, ExplodedNode *ErrNode) const;
 
@@ -276,6 +279,7 @@
 
 bool isIteratorType(const QualType &Type);
 bool isIterator(const CXXRecordDecl *CRD);
+bool isComparisonOperator(OverloadedOperatorKind OK);
 bool isBeginCall(const FunctionDecl *Func);
 bool isEndCall(const FunctionDecl *Func);
 bool isAssignmentOperator(OverloadedOperatorKind OK);
@@ -397,8 +401,48 @@
   } else {
 verifyDereference(C, Call.getArgSVal(0));
   }
+} else if (ChecksEnabled[CK_MismatchedIteratorChecker] &&
+   isComparisonOperator(Func->getOverloadedOperator())) {
+  // Check for comparisons of iterators of different containers
+  if (const auto *InstCall = dyn_cast(&Call)) {
+if (Call.getNumArgs() < 1)
+  return;
+
+if (!isIteratorType(InstCall->getCXXThisExpr()->getType()) ||
+!isIteratorType(Call.getArgExpr(0)->getType()))
+  return;
+
+verifyMatch(C, InstCall->getCXXThisVal(), Call.getArgSVal(0));
+  } else {
+if (Call.getNumArgs() < 2)
+  return;
+
+if (!isIteratorType(Call.getArgExpr(0)->getType()) ||
+!isIteratorType(Call.getArgExpr(1)->getType()))
+  return;
+
+verifyMatch(C, Call.getArgSVal(0), Call.getArgSVal(1));
+  }
 }
-  } else if (!isa(&Call)) {
+  } else if (isa(&Call)) {
+// Check match of first-last iterator pair in a constructor of a container
+if (Call.getNumArgs() < 2)
+  return;
+
+const auto *Ctr = cast(Call.getDecl());
+if (Ctr->getNumParams() < 2)
+  return;
+
+if (Ctr->getParamDecl(0)->getName() != "first" ||
+Ctr->getParamDecl(1)->getName() != "last")
+  return;
+
+if (!isIteratorType(Call.getArgExpr(0)->getType()) ||
+!isIteratorType(Call.getArgExpr(1)->getType()))
+  return;
+
+verifyMatch(C, Call.getArgSVal(0), Call.getArgSVal(1));
+  } else {
 // The main purpose of iterators is to abstract away from different
 // containers and provide a (maybe limited) uniform access to them.
 // This implies that any correctly written template function that
@@ -1102,6 +1146,16 @@
   C.emitReport(std::move(R));
 }
 
+void IteratorChecker::reportMismatchedBug(const StringRef &Message,
+  const SVal &Val, const MemRegion *Reg,
+  CheckerContext &C,
+  ExplodedNode *ErrNode) const {
+  auto R = llvm::make_unique(*MismatchedBugType, Message, ErrNode);
+  R->markInteresting(Val);
+  R->markInteresting(Reg);
+  C.emitReport(std::move(R));
+}
+
 void IteratorChecker::reportInvalidatedBug(const StringRef &Message,
const SVal &Val, CheckerContext &C,
ExplodedNode *ErrNode) const {
@@ -1173,6 +1227,11 @@
  HasPostIncrOp && HasDerefOp;
 }
 
+bool isComparisonOperator(OverloadedOperatorKind OK) {
+  return OK == OO_EqualEqual || OK == OO_ExclaimEqual || OK == OO_Less ||
+ OK == OO_LessEqual || OK == OO_Greater || OK == OO_GreaterEqual;
+}
+
 bool isBeginCall(const FunctionDecl *Func) {
   const auto *IdInfo = Func->getIdentifier();
   if (!IdInfo)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r341793 - [Analyzer] Iterator Checker - Part 7: Support for push and pop operations

2018-09-10 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Sep 10 02:06:31 2018
New Revision: 341793

URL: http://llvm.org/viewvc/llvm-project?rev=341793&view=rev
Log:
[Analyzer] Iterator Checker - Part 7: Support for push and pop operations

This patch adds support for the following operations in the iterator checkers: 
push_back, push_front, emplace_back, emplace_front, pop_back and pop_front. 
This affects iterator range checks (range is extended after push and emplace 
and reduced after pop operations) and invalidation checks (according to the 
standard).

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
cfe/trunk/test/Analysis/invalidated-iterator.cpp
cfe/trunk/test/Analysis/iterator-range.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=341793&r1=341792&r2=341793&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon Sep 10 
02:06:31 2018
@@ -72,6 +72,7 @@
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 
 #include 
 
@@ -225,6 +226,10 @@ class IteratorChecker
   void handleAssign(CheckerContext &C, const SVal &Cont,
 const Expr *CE = nullptr,
 const SVal &OldCont = UndefinedVal()) const;
+  void handlePushBack(CheckerContext &C, const SVal &Cont) const;
+  void handlePopBack(CheckerContext &C, const SVal &Cont) const;
+  void handlePushFront(CheckerContext &C, const SVal &Cont) const;
+  void handlePopFront(CheckerContext &C, const SVal &Cont) const;
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
@@ -282,6 +287,12 @@ bool isIterator(const CXXRecordDecl *CRD
 bool isComparisonOperator(OverloadedOperatorKind OK);
 bool isBeginCall(const FunctionDecl *Func);
 bool isEndCall(const FunctionDecl *Func);
+bool isPushBackCall(const FunctionDecl *Func);
+bool isEmplaceBackCall(const FunctionDecl *Func);
+bool isPopBackCall(const FunctionDecl *Func);
+bool isPushFrontCall(const FunctionDecl *Func);
+bool isEmplaceFrontCall(const FunctionDecl *Func);
+bool isPopFrontCall(const FunctionDecl *Func);
 bool isAssignmentOperator(OverloadedOperatorKind OK);
 bool isSimpleComparisonOperator(OverloadedOperatorKind OK);
 bool isAccessOperator(OverloadedOperatorKind OK);
@@ -289,6 +300,9 @@ bool isDereferenceOperator(OverloadedOpe
 bool isIncrementOperator(OverloadedOperatorKind OK);
 bool isDecrementOperator(OverloadedOperatorKind OK);
 bool isRandomIncrOrDecrOperator(OverloadedOperatorKind OK);
+bool hasSubscriptOperator(ProgramStateRef State, const MemRegion *Reg);
+bool frontModifiable(ProgramStateRef State, const MemRegion *Reg);
+bool backModifiable(ProgramStateRef State, const MemRegion *Reg);
 BinaryOperator::Opcode getOpcode(const SymExpr *SE);
 const RegionOrSymbol getRegionOrSymbol(const SVal &Val);
 const ProgramStateRef processComparison(ProgramStateRef State,
@@ -325,6 +339,9 @@ ProgramStateRef relateIteratorPositions(
 bool Equal);
 ProgramStateRef invalidateAllIteratorPositions(ProgramStateRef State,
const MemRegion *Cont);
+ProgramStateRef invalidateIteratorPositions(ProgramStateRef State,
+SymbolRef Offset,
+BinaryOperator::Opcode Opc);
 ProgramStateRef reassignAllIteratorPositions(ProgramStateRef State,
  const MemRegion *Cont,
  const MemRegion *NewCont);
@@ -561,6 +578,18 @@ void IteratorChecker::checkPostCall(cons
   }
 }
   } else {
+if (const auto *InstCall = dyn_cast(&Call)) {
+  if (isPushBackCall(Func) || isEmplaceBackCall(Func)) {
+handlePushBack(C, InstCall->getCXXThisVal());
+  } else if (isPopBackCall(Func)) {
+handlePopBack(C, InstCall->getCXXThisVal());
+  } else if (isPushFrontCall(Func) || isEmplaceFrontCall(Func)) {
+handlePushFront(C, InstCall->getCXXThisVal());
+  } else if (isPopFrontCall(Func)) {
+handlePopFront(C, InstCall->getCXXThisVal());
+  }
+}
+
 const auto *OrigExpr = Call.getOriginExpr();
 if (!OrigExpr)
   return;
@@ -653,9 +682,13 @@ void IteratorChecker::ch

[PATCH] D32902: [Analyzer] Iterator Checker - Part 7: Support for push and pop operations

2018-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
baloghadamsoftware marked an inline comment as done.
Closed by commit rL341793: [Analyzer] Iterator Checker - Part 7: Support for 
push and pop operations (authored by baloghadamsoftware, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D32902?vs=163984&id=164636#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32902

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
  cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
  cfe/trunk/test/Analysis/invalidated-iterator.cpp
  cfe/trunk/test/Analysis/iterator-range.cpp

Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -265,6 +265,8 @@
 
 void push_back(const T &value);
 void push_back(T &&value);
+template
+void emplace_back(Args&&... args);
 void pop_back();
 
 T &operator[](size_t n) {
@@ -319,10 +321,14 @@
 
 void push_back(const T &value);
 void push_back(T &&value);
+template
+void emplace_back(Args&&... args);
 void pop_back();
 
 void push_front(const T &value);
 void push_front(T &&value);
+template
+void emplace_front(Args&&... args);
 void pop_front();
 
 iterator begin() { return iterator(_start); }
@@ -373,10 +379,14 @@
 
 void push_back(const T &value);
 void push_back(T &&value);
+template
+void emplace_back(Args&&... args);
 void pop_back();
 
 void push_front(const T &value);
 void push_front(T &&value);
+template
+void emplace_front(Args&&... args);
 void pop_front();
 
 T &operator[](size_t n) {
@@ -431,6 +441,8 @@
 
 void push_front(const T &value);
 void push_front(T &&value);
+template
+void emplace_front(Args&&... args);
 void pop_front();
 
 iterator begin() { return iterator(_start); }
Index: cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
===
--- cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
+++ cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
@@ -19,6 +19,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:554 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:566 {{Called C++ object pointer is null}}
 #endif
 }
Index: cfe/trunk/test/Analysis/invalidated-iterator.cpp
===
--- cfe/trunk/test/Analysis/invalidated-iterator.cpp
+++ cfe/trunk/test/Analysis/invalidated-iterator.cpp
@@ -30,3 +30,170 @@
   FL1 = FL2;
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
+
+void good_push_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend();
+  L.push_back(n);
+  *i0; // no-warning
+  --i1; // no-warning
+}
+
+void good_push_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.push_back(n);
+  *i0; // no-warning
+}
+
+void bad_push_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.push_back(n);
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_push_back_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin(), i1 = D.cend();
+  D.push_back(n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_emplace_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend();
+  L.emplace_back(n);
+  *i0; // no-warning
+  --i1; // no-warning
+}
+
+void good_emplace_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.emplace_back(n);
+  *i0; // no-warning
+}
+
+void bad_emplace_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.emplace_back(n);
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_emplace_back_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin(), i1 = D.cend();
+  D.emplace_back(n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_pop_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend(), i2 = i1--;
+  L.pop_back();
+  *i0; // no-warning
+  *i2; // no-warning
+}
+
+void bad_pop_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend(), i2 = i1--;
+  L.pop_back();
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_pop_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend(), i2 = i1--;
+  V.pop_

r341794 - [Analyzer] Iterator Checker - Part 8: Support for assign, clear, insert, emplace and erase operations

2018-09-10 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Sep 10 02:07:47 2018
New Revision: 341794

URL: http://llvm.org/viewvc/llvm-project?rev=341794&view=rev
Log:
[Analyzer] Iterator Checker - Part 8: Support for assign, clear, insert, 
emplace and erase operations

This patch adds support for the following operations in the iterator checkers: 
assign, clear, insert, insert_after, emplace, emplace_after, erase and 
erase_after. This affects mismatched iterator checks ("this" and parameter must 
match) and invalidation checks (according to the standard).

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
cfe/trunk/test/Analysis/invalidated-iterator.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=341794&r1=341793&r2=341794&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon Sep 10 
02:07:47 2018
@@ -198,7 +198,7 @@ public:
 
 class IteratorChecker
 : public Checker,
+ check::PostStmt, check::Bind,
  check::LiveSymbols, check::DeadSymbols,
  eval::Assume> {
 
@@ -226,13 +226,23 @@ class IteratorChecker
   void handleAssign(CheckerContext &C, const SVal &Cont,
 const Expr *CE = nullptr,
 const SVal &OldCont = UndefinedVal()) const;
+  void handleClear(CheckerContext &C, const SVal &Cont) const;
   void handlePushBack(CheckerContext &C, const SVal &Cont) const;
   void handlePopBack(CheckerContext &C, const SVal &Cont) const;
   void handlePushFront(CheckerContext &C, const SVal &Cont) const;
   void handlePopFront(CheckerContext &C, const SVal &Cont) const;
+  void handleInsert(CheckerContext &C, const SVal &Iter) const;
+  void handleErase(CheckerContext &C, const SVal &Iter) const;
+  void handleErase(CheckerContext &C, const SVal &Iter1,
+   const SVal &Iter2) const;
+  void handleEraseAfter(CheckerContext &C, const SVal &Iter) const;
+  void handleEraseAfter(CheckerContext &C, const SVal &Iter1,
+const SVal &Iter2) const;
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
+  void verifyMatch(CheckerContext &C, const SVal &Iter,
+   const MemRegion *Cont) const;
   void verifyMatch(CheckerContext &C, const SVal &Iter1,
const SVal &Iter2) const;
 
@@ -262,6 +272,9 @@ public:
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const;
+  void checkPostStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
+  void checkPostStmt(const DeclStmt *DS, CheckerContext &C) const;
   void checkPostStmt(const MaterializeTemporaryExpr *MTE,
  CheckerContext &C) const;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const;
@@ -287,12 +300,18 @@ bool isIterator(const CXXRecordDecl *CRD
 bool isComparisonOperator(OverloadedOperatorKind OK);
 bool isBeginCall(const FunctionDecl *Func);
 bool isEndCall(const FunctionDecl *Func);
+bool isAssignCall(const FunctionDecl *Func);
+bool isClearCall(const FunctionDecl *Func);
 bool isPushBackCall(const FunctionDecl *Func);
 bool isEmplaceBackCall(const FunctionDecl *Func);
 bool isPopBackCall(const FunctionDecl *Func);
 bool isPushFrontCall(const FunctionDecl *Func);
 bool isEmplaceFrontCall(const FunctionDecl *Func);
 bool isPopFrontCall(const FunctionDecl *Func);
+bool isInsertCall(const FunctionDecl *Func);
+bool isEraseCall(const FunctionDecl *Func);
+bool isEraseAfterCall(const FunctionDecl *Func);
+bool isEmplaceCall(const FunctionDecl *Func);
 bool isAssignmentOperator(OverloadedOperatorKind OK);
 bool isSimpleComparisonOperator(OverloadedOperatorKind OK);
 bool isAccessOperator(OverloadedOperatorKind OK);
@@ -339,9 +358,18 @@ ProgramStateRef relateIteratorPositions(
 bool Equal);
 ProgramStateRef invalidateAllIteratorPositions(ProgramStateRef State,
const MemRegion *Cont);
+ProgramStateRef
+invalidateAllIteratorPositionsExcept(ProgramStateRef State,
+ const MemRegion *Cont, SymbolRef Offset,
+ BinaryOperator::Opcode Opc);
 ProgramStateRef invalidateIteratorPositions(ProgramStateRef State,
  

[PATCH] D32904: [Analyzer] Iterator Checker - Part 8: Support for assign, clear, insert, emplace and erase operations

2018-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341794: [Analyzer] Iterator Checker - Part 8: Support for 
assign, clear, insert… (authored by baloghadamsoftware, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D32904?vs=164006&id=164637#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32904

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
  cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
  cfe/trunk/test/Analysis/invalidated-iterator.cpp

Index: cfe/trunk/test/Analysis/invalidated-iterator.cpp
===
--- cfe/trunk/test/Analysis/invalidated-iterator.cpp
+++ cfe/trunk/test/Analysis/invalidated-iterator.cpp
@@ -31,6 +31,56 @@
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
+void bad_assign_list1(std::list &L, int n) {
+  auto i0 = L.cbegin();
+  L.assign(10, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_assign_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin();
+  V.assign(10, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_assign_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin();
+  D.assign(10, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_assign_forward_list1(std::forward_list &FL, int n) {
+  auto i0 = FL.cbegin();
+  FL.assign(10, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_clear_list1(std::list &L) {
+  auto i0 = L.cend();
+  L.clear();
+  --i0; // no-warning
+}
+
+void bad_clear_list1(std::list &L) {
+  auto i0 = L.cbegin(), i1 = L.cend();
+  L.clear();
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_clear_vector1(std::vector &V) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.clear();
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_clear_deque1(std::deque &D) {
+  auto i0 = D.cbegin(), i1 = D.cend();
+  D.clear();
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
 void good_push_back_list1(std::list &L, int n) {
   auto i0 = L.cbegin(), i1 = L.cend();
   L.push_back(n);
@@ -197,3 +247,153 @@
   FL.pop_front();
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
+
+void good_insert_list1(std::list &L, int n) {
+  auto i1 = L.cbegin(), i0 = i1++;
+  L.insert(i1, n);
+  *i0; // no-warning
+  *i1; // no-warning
+}
+
+void good_insert_vector1(std::vector &V, int n) {
+  auto i1 = V.cbegin(), i0 = i1++;
+  V.insert(i1, n);
+  *i0; // no-warning
+}
+
+void bad_insert_vector1(std::vector &V, int n) {
+  auto i1 = V.cbegin(), i0 = i1++;
+  V.insert(i1, n);
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_insert_deque1(std::deque &D, int n) {
+  auto i1 = D.cbegin(), i0 = i1++;
+  D.insert(i1, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_emplace_list1(std::list &L, int n) {
+  auto i1 = L.cbegin(), i0 = i1++;
+  L.emplace(i1, n);
+  *i0; // no-warning
+  *i1; // no-warning
+}
+
+void good_emplace_vector1(std::vector &V, int n) {
+  auto i1 = V.cbegin(), i0 = i1++;
+  V.emplace(i1, n);
+  *i0; // no-warning
+}
+
+void bad_emplace_vector1(std::vector &V, int n) {
+  auto i1 = V.cbegin(), i0 = i1++;
+  V.emplace(i1, n);
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_emplace_deque1(std::deque &D, int n) {
+  auto i1 = D.cbegin(), i0 = i1++;
+  D.emplace(i1, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_erase_list1(std::list &L) {
+  auto i2 = L.cbegin(), i0 = i2++, i1 = i2++;
+  L.erase(i1);
+  *i0; // no-warning
+  *i2; // no-warning
+}
+
+void bad_erase_list1(std::list &L) {
+  auto i0 = L.cbegin();
+  L.erase(i0);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_erase_vector1(std::vector &V) {
+  auto i2 = V.cbegin(), i0 = i2++, i1 = i2++;
+  V.erase(i1);
+  *i0; // no-warning
+}
+
+void bad_erase_vector1(std::vector &V) {
+  auto i1 = V.cbegin(), i0 = i1++;
+  V.erase(i0);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_erase_deque1(std::deque &D) {
+  auto i2 = D.cbegin(), i0 = i2++, i1 = i2++;
+  D.erase(i1);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+  *i2; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_erase_list2(std::list &L) {
+  auto i3 = L.cbegin(), i0 = i3++, i1 = i3++, i2 = i3++;
+  L.erase(i1, i3);
+  *i0; // n

[PATCH] D51628: [clangd] Implement a Proof-of-Concept tool for symbol index exploration

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:39
+
+// FIXME(kbobyrev): Make this an actual REPL: probably use LLVM Command Line
+// library for parsing flags and arguments.

kbobyrev wrote:
> ilya-biryukov wrote:
> > Maybe we could expose `CommandLineParser` from 
> > `llvm/lib/Support/CommandLine.cpp` as a public API and use it here?
> > Not sure if there are any obstacles to doing so or how much work is it, 
> > though.
> > E.g. `cl::opt` seem to rely on being registered in the global parser and 
> > I'm not sure if there's an easy way out of it.
> Yes, that might be tricky. I have thought about a few options, e.g. consuming 
> the first token from the input string as the command and dispatching 
> arguments parsed via `CommandLineParser` manually (discarding those which are 
> not accepted by provided command, etc). There are still few complications: 
> help wouldn't be separate and easily accessible (unless hardcoded, which is 
> suboptimal).
> 
> Another approach I could think of would be simplifying the interface of each 
> command so that it would be easily parsed:
> 
> * `> fuzzy-find request.json`: this would require `FuzzyFindRequest` JSON 
> (de)serialization implementation, but that would be useful for the benchmark 
> tool, too
> * `> lookup-id symbolid`
> * `> load symbol.yaml`/`swap symbol.yaml`
> * `> density-hist`
> * `> tokens-distribution`
> * `> dense-tokens`
> * `> sparse-tokens`
> 
> And also a generic `> help` for the short reference of each command. Out of 
> all these commands, only Fuzzy Find request would benefit a lot from a proper 
> parsing of arguments, having JSON file representation might not be ideal, but 
> it looks OK for the first iteration for me. Fuzzy Find request would 
> presumably be one of the most used commands, though, but then again, we could 
> iterate if that is not really convinient.
The single-argument and no-arg commands certainly look nice. However, creating 
a separate file for each fuzzy-find request feels like a pain.

Have you tried prototyping parsing with `CommandLineParser `? What are the 
complications to exposing it from LLVM? 


https://reviews.llvm.org/D51628



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


r341795 - [Analyzer] Commit fix for rL341790/rC341790

2018-09-10 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Sep 10 02:19:54 2018
New Revision: 341795

URL: http://llvm.org/viewvc/llvm-project?rev=341795&view=rev
Log:
[Analyzer] Commit fix for rL341790/rC341790

Test file was accidentally not added for rL341790/rC341790 and subsequant 
patches.


Added:
cfe/trunk/test/Analysis/mismatched-iterator.cpp

Added: cfe/trunk/test/Analysis/mismatched-iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/mismatched-iterator.cpp?rev=341795&view=auto
==
--- cfe/trunk/test/Analysis/mismatched-iterator.cpp (added)
+++ cfe/trunk/test/Analysis/mismatched-iterator.cpp Mon Sep 10 02:19:54 2018
@@ -0,0 +1,175 @@
+// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,alpha.cplusplus.MismatchedIterator 
-analyzer-config aggressive-binary-operation-simplification=true 
-analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,alpha.cplusplus.MismatchedIterator 
-analyzer-config aggressive-binary-operation-simplification=true 
-analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void good_insert1(std::vector &v, int n) {
+  v.insert(v.cbegin(), n); // no-warning
+}
+
+
+void good_insert2(std::vector &v, int len, int n) {
+  v.insert(v.cbegin(), len, n); // no-warning
+}
+
+void good_insert3(std::vector &v1, std::vector &v2) {
+  v1.insert(v1.cbegin(), v2.cbegin(), v2.cend()); // no-warning
+}
+
+void good_insert4(std::vector &v, int len, int n) {
+  v.insert(v.cbegin(), {n-1, n, n+1}); // no-warning
+}
+
+void good_insert_find(std::vector &v, int n, int m) {
+  auto i = std::find(v.cbegin(), v.cend(), n);
+  v.insert(i, m); // no-warning
+}
+
+void good_erase1(std::vector &v) {
+  v.erase(v.cbegin()); // no-warning
+}
+
+void good_erase2(std::vector &v) {
+  v.erase(v.cbegin(), v.cend()); // no-warning
+}
+
+void good_emplace(std::vector &v, int n) {
+  v.emplace(v.cbegin(), n); // no-warning
+}
+
+void good_ctor(std::vector &v) {
+  std::vector new_v(v.cbegin(), v.cend()); // no-warning
+}
+
+void good_find(std::vector &v, int n) {
+  std::find(v.cbegin(), v.cend(), n); // no-warning
+}
+
+void good_find_first_of(std::vector &v1, std::vector &v2) {
+  std::find_first_of(v1.cbegin(), v1.cend(), v2.cbegin(), v2.cend()); // 
no-warning
+}
+
+void good_copy(std::vector &v1, std::vector &v2, int n) {
+  std::copy(v1.cbegin(), v1.cend(), v2.begin()); // no-warning
+}
+
+void good_move_find1(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cbegin();
+  v1 = std::move(v2);
+  std::find(i0, v1.cend(), n); // no-warning
+}
+
+void bad_insert1(std::vector &v1, std::vector &v2, int n) {
+  v2.insert(v1.cbegin(), n); // expected-warning{{Container accessed using 
foreign iterator argument}}
+}
+
+void bad_insert2(std::vector &v1, std::vector &v2, int len, int n) {
+  v2.insert(v1.cbegin(), len, n); // expected-warning{{Container accessed 
using foreign iterator argument}}
+}
+
+void bad_insert3(std::vector &v1, std::vector &v2) {
+  v2.insert(v1.cbegin(), v2.cbegin(), v2.cend()); // 
expected-warning{{Container accessed using foreign iterator argument}}
+  v1.insert(v1.cbegin(), v1.cbegin(), v2.cend()); // 
expected-warning{{Iterators of different containers used where the same 
container is expected}}
+  v1.insert(v1.cbegin(), v2.cbegin(), v1.cend()); // 
expected-warning{{Iterators of different containers used where the same 
container is expected}}
+}
+
+void bad_insert4(std::vector &v1, std::vector &v2, int len, int n) {
+  v2.insert(v1.cbegin(), {n-1, n, n+1}); // expected-warning{{Container 
accessed using foreign iterator argument}}
+}
+
+void bad_erase1(std::vector &v1, std::vector &v2) {
+  v2.erase(v1.cbegin()); // expected-warning{{Container accessed using foreign 
iterator argument}}
+}
+
+void bad_erase2(std::vector &v1, std::vector &v2) {
+  v2.erase(v2.cbegin(), v1.cend()); // expected-warning{{Container accessed 
using foreign iterator argument}}
+  v2.erase(v1.cbegin(), v2.cend()); // expected-warning{{Container accessed 
using foreign iterator argument}}
+  v2.erase(v1.cbegin(), v1.cend()); // expected-warning{{Container accessed 
using foreign iterator argument}}
+}
+
+void bad_emplace(std::vector &v1, std::vector &v2, int n) {
+  v2.emplace(v1.cbegin(), n); // expected-warning{{Container accessed using 
foreign iterator argument}}
+}
+
+void good_move_find2(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = --v2.cend();
+  v1 = std::move(v2);
+  std::find(i0, v1.cend(), n); // no-warning
+}
+
+void good_move_find3(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cend();
+  v1 = std::move(v2);
+  v2.push_back(n);
+  std::find(v2.cbegin(), i0, n); // no-warning
+}
+
+void good_comparison(std::vector &v) {
+  if (v.cbegin() == v.cend()) {} // no-warning
+}
+
+void bad_ctor(std::vector &v1, std::vector &v2) {
+ 

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-10 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5244
+   false))
+CmdArgs.push_back("-fvisibility-inlines-hidden");
+

hans wrote:
> Huh, does this actually affect whether functions get dllexported or not?
Sorry, what you want to ask?

This will used to not add dllexport attr in L5690 of SemaDeclCXX.cpp.



https://reviews.llvm.org/D51340



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


[PATCH] D51628: [clangd] Implement a Proof-of-Concept tool for symbol index exploration

2018-09-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

A tool like this will be a useful addition!

I think the big high-level questions are:

- UI: a REPL seems like a good model, but we need a more user-friendly way to 
read commands
- Testing: need a plan for either a) testing the commands or b) keeping the 
commands simple/readable enough that we can get away without testing them.

I suspect a good design links these questions together (e.g. by establishing a 
simple pattern for reading/printing to keep the eval part simple, and 
read/print is most of the UI).

I'm not sure I agree this should be deferred until later.




Comment at: clang-tools-extra/clangd/CMakeLists.txt:75
 add_subdirectory(global-symbol-builder)
+add_subdirectory(dexplorer)

if this is coupled to dex, and dex has its own directory, this should be a 
subdirectory I think



Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:27
+
+llvm::cl::opt YAMLSymbolCollection(
+"symbol-collection-file",

please avoid mentioning YAML, as we now have multiple formats.
"index file"?



Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:41
+// library for parsing flags and arguments.
+// FIXME(kbobyrev): Ideas for commands:
+// * fuzzy find symbol given a set of properties

find references



Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:62
+
+  llvm::outs() << "Scopes (comma-separated list):\n";
+  if (llvm::Optional Line = LE.readLine()) {

Agree with the concerns about the usability of this model, a command-like model 
would be nicer.
If we want to start with something simple without worrying too much about 
complex inputs, maybe just accept queries one-per-line and don't allow the 
other options to be set yet?

Otherwise it seems like all of this is likely to need to be replaced in a 
backwards-incompatible way...



Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:122
+   << " ms.\n";
+  // FIXME(kbobyrev): Allow specifying which fields the user wants to see: e.g.
+  // origin of the symbol (CanonicalDeclaration path), #References, etc.

I'm not sure this will actually be a good UX.
Maybe just make sure you always include the symbol ID so the user can get 
details?



Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:147
+
+  // FIXME(kbobyrev): Wrap time measurements into something like
+  // measureTime(Function, Arguments...).

kbobyrev wrote:
> ilya-biryukov wrote:
> > +1 to this FIXME.
> > 
> > Something like:
> > ```
> > template 
> > auto reportTime(StringRef Name, Func F) -> decltype(F()) {
> >   auto Result = F();
> >   llvm::outs() << Name << " took " << ...
> >   return Result;
> > } 
> > ```
> > 
> > The code calling this API would be quite readable:
> > ```
> > auto Index = reportTime("Build stage", []() { 
> >   return buildStaticIndex(...);
> > });
> > ```
> Ah, this looks really clean! I had few ideas of how to do that, but I 
> couldn't converge to a reasonable solution which wouldn't look like abusing 
> C++ to me :) Thanks!
+1 - could you add this in this patch? would improve readability already


https://reviews.llvm.org/D51628



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


[clang-tools-extra] r341797 - [clangd] Fix async index loading (from r341376).

2018-09-10 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Sep 10 03:00:47 2018
New Revision: 341797

URL: http://llvm.org/viewvc/llvm-project?rev=341797&view=rev
Log:
[clangd] Fix async index loading (from r341376).

Summary:
This wasn't actually async (due to std::future destructor blocking).
If it were, we would have clean shutdown issues if main returned
and destroyed Placeholder before the thread is done with it.

We could attempt to avoid any blocking by using shared_ptr or weak_ptr tricks so
the thread can detect Placeholder's destruction, but there are other potential
issues (e.g. loadIndex does tracing, and we'll destroy the tracer...)
Instead, once LSPServer::run returns, we wait for the index to finish loading
before exiting. Performance is not critical in this situation.

Reviewers: ilya-biryukov

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

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

Modified:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=341797&r1=341796&r2=341797&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Mon Sep 10 03:00:47 2018
@@ -270,14 +270,17 @@ int main(int argc, char *argv[]) {
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
+  std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !YamlSymbolFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new 
SwapIndex(llvm::make_unique()));
-runAsync([Placeholder, &Opts] {
+AsyncIndexLoad = runAsync([Placeholder, &Opts] {
   if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
+if (RunSynchronously)
+  AsyncIndexLoad.wait();
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;


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


[PATCH] D51674: [clangd] Fix async index loading (from r341376).

2018-09-10 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341797: [clangd] Fix async index loading (from r341376). 
(authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51674?vs=164012&id=164638#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51674

Files:
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -270,14 +270,17 @@
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
+  std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !YamlSymbolFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new 
SwapIndex(llvm::make_unique()));
-runAsync([Placeholder, &Opts] {
+AsyncIndexLoad = runAsync([Placeholder, &Opts] {
   if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
+if (RunSynchronously)
+  AsyncIndexLoad.wait();
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -270,14 +270,17 @@
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
+  std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !YamlSymbolFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new SwapIndex(llvm::make_unique()));
-runAsync([Placeholder, &Opts] {
+AsyncIndexLoad = runAsync([Placeholder, &Opts] {
   if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
+if (RunSynchronously)
+  AsyncIndexLoad.wait();
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

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

In https://reviews.llvm.org/D51038#1228618, @ilya-biryukov wrote:

> > Currently the problem is, there are again some tests out there that rely on
> >  CodeCompeleteOrdinaryName to be called even when getting overloads at an 
> > unknown
> >  parameter type
>
> CodeCompleteExpression works just fine there. Unknown parameter type should 
> not block code completion.
>  The idea is that anywhere except the start of the argument expression, we 
> need to call **only** signature help. At the start of the argument, we have 
> to call both signature help and code completion.


Yeah you are right, I thought I could check whether I am inside a parameter or 
not by looking at qual type, which was apparently wrong :D

But, unfortunately, there were still tests failing which was caused by printing 
of completion strings for overloaded methods with optional parameters. It was 
trying to access Text field, which is not defined for Optional parameters.
Since it didn't print optional parameters in the original behavior I kept it 
that way. Can send it as a different patch if need be.


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

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

- Change "inside parameter" checking and fix completion string printing for 
optional parameters.
- Update tests.


Repository:
  rC Clang

https://reviews.llvm.org/D51038

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/function-overloads.cpp
  test/Index/complete-block-property-assignment.m

Index: test/Index/complete-block-property-assignment.m
===
--- test/Index/complete-block-property-assignment.m
+++ test/Index/complete-block-property-assignment.m
@@ -60,13 +60,20 @@
 // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s
-// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
+// CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1)
 @end
Index: test/CodeCompletion/function-overloads.cpp
===
--- /dev/null
+++ test/CodeCompletion/function-overloads.cpp
@@ -0,0 +1,27 @@
+int f(int i, int j = 2, int k = 5);
+int f(float x, float y...);
+
+class A {
+ public:
+  A(int, int, int);
+};
+
+void test() {
+  A a(f(1, 2, 3, 4), 2, 3);
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
+// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
+// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
+// CHECK-CC2: OVERLOAD: [#int#]f(float x, float y)
+// CHECK-CC2-NOT: OVERLOAD: [#int#]f(int i)
+// CHECK-CC3: OVERLOAD: A(<#int#>, int, int)
+// CHECK-CC3: OVERLOAD: A(<#const A &#>)
+// CHECK-CC3: OVERLOAD: A(<#A &&#>)
+// CHECK-CC4: OVERLOAD: A(int, <#int#>, int)
Index: lib/Sema/CodeCompleteConsumer.cpp
===
--- lib/Sema/CodeCompleteConsumer.cpp
+++ lib/Sema/CodeCompleteConsumer.cpp
@@ -619,6 +619,9 @@
   OS << "<#" << C.Text << "#>";
   break;
 
+case CodeCompletionString::CK_Optional:
+  break;
+
 default: OS << C.Text; break;
 }
   }
Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -416,14 +416,20 @@
 CommaLocsTy CommaLocs;
 
 SourceLocation LParLoc = T.getOpenLocation();
-if (ParseExpressionList(
-Exprs, CommaLocs, [this, OmpPrivParm, LParLoc, &Exprs] {
-  QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
-  getCurScope(),
-  OmpPrivParm->getType()->getCanonicalTypeInternal(),
-  OmpPrivParm->getLocation(), Exprs, LParLoc);
-  Actions.CodeCompleteExpression(getCurScope(), Preferr

[PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added reviewers: ilya-biryukov, ioeric, sammccall.
kbobyrev added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.

JSON (de)serialization of `FuzzyFindRequest` might be useful for both 
https://reviews.llvm.org/D51090 and https://reviews.llvm.org/D51628. Also, this 
allows precise logging of the fuzzy find requests.


https://reviews.llvm.org/D51852

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h

Index: clang-tools-extra/clangd/index/Index.h
===
--- clang-tools-extra/clangd/index/Index.h
+++ clang-tools-extra/clangd/index/Index.h
@@ -19,8 +19,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/StringSaver.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -253,11 +255,13 @@
   SymbolFlag Flags = SymbolFlag::None;
   /// FIXME: also add deprecation message and fixit?
 };
-inline Symbol::SymbolFlag  operator|(Symbol::SymbolFlag A, Symbol::SymbolFlag  B) {
+inline Symbol::SymbolFlag operator|(Symbol::SymbolFlag A,
+Symbol::SymbolFlag B) {
   return static_cast(static_cast(A) |
  static_cast(B));
 }
-inline Symbol::SymbolFlag &operator|=(Symbol::SymbolFlag &A, Symbol::SymbolFlag B) {
+inline Symbol::SymbolFlag &operator|=(Symbol::SymbolFlag &A,
+  Symbol::SymbolFlag B) {
   return A = A | B;
 }
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S);
@@ -435,7 +439,7 @@
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = UINT_MAX;
+  size_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
@@ -450,6 +454,8 @@
   }
   bool operator!=(const FuzzyFindRequest &Req) const { return !(*this == Req); }
 };
+bool fromJSON(const llvm::json::Value &Value, FuzzyFindRequest &Request);
+llvm::json::Value toJSON(const FuzzyFindRequest &Request);
 
 struct LookupRequest {
   llvm::DenseSet IDs;
Index: clang-tools-extra/clangd/index/Index.cpp
===
--- clang-tools-extra/clangd/index/Index.cpp
+++ clang-tools-extra/clangd/index/Index.cpp
@@ -79,10 +79,9 @@
 }
 
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
-  auto It = std::lower_bound(Symbols.begin(), Symbols.end(), ID,
- [](const Symbol &S, const SymbolID &I) {
-   return S.ID < I;
- });
+  auto It = std::lower_bound(
+  Symbols.begin(), Symbols.end(), ID,
+  [](const Symbol &S, const SymbolID &I) { return S.ID < I; });
   if (It != Symbols.end() && It->ID == ID)
 return It;
   return Symbols.end();
@@ -175,6 +174,35 @@
   return Index;
 }
 
+bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request) {
+  json::ObjectMapper O(Parameters);
+  llvm::Optional MaxCandidateCount;
+  bool OK =
+  O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
+  O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
+  O.map("ProximityPaths", Request.ProximityPaths) &&
+  O.map("MaxCandidateCount", MaxCandidateCount);
+  if (MaxCandidateCount)
+Request.MaxCandidateCount = MaxCandidateCount.getValue();
+  return OK;
+}
+
+llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
+  auto Result = json::Object{
+  {"Query", Request.Query},
+  {"Scopes", json::Array{Request.Scopes}},
+  {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
+  {"ProximityPaths", json::Array{Request.ProximityPaths}},
+  };
+  // Typically, MaxCandidateCount is either maximum size_t value or something
+  // small. Since LLVM JSON serializer only supports int64_t, try to cast to
+  // int64_t and make this field "optional".
+  if (Request.MaxCandidateCount <= std::numeric_limits::max())
+Result["MaxCandidateCount"] =
+static_cast(Request.MaxCandidateCount);
+  return Result;
+}
+
 bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,
   llvm::function_ref CB) const {
   return snapshot()->fuzzyFind(R, CB);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1381,8 +1381,7 @@
 Req.Scopes = QueryScopes;
 

[PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

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



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1384
 Req.ProximityPaths.push_back(FileName);
-vlog("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", Req.Query,
- llvm::join(Req.Scopes.begin(), Req.Scopes.end(), ","));
+vlog("Code complete: fuzzyFind({0})", toJSON(Req));
 

{0:2} for prettyprinting



Comment at: clang-tools-extra/clangd/index/Index.cpp:198
+  // Typically, MaxCandidateCount is either maximum size_t value or something
+  // small. Since LLVM JSON serializer only supports int64_t, try to cast to
+  // int64_t and make this field "optional".

Can we explain this in simpler semantic terms?
e.g. `// A huge limit means no limit, leave it out.`



Comment at: clang-tools-extra/clangd/index/Index.h:258
 };
-inline Symbol::SymbolFlag  operator|(Symbol::SymbolFlag A, Symbol::SymbolFlag  
B) {
+inline Symbol::SymbolFlag operator|(Symbol::SymbolFlag A,
+Symbol::SymbolFlag B) {

please fix your editor to only format changed lines


https://reviews.llvm.org/D51852



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Parse/Parser.h:217
 
+  /// Gets set to true after calling ProduceSignaturehelp, it is for a
+  /// workaround to make sure ProduceSignatureHelp is only called at the 
deepest

s/ProduceSignaturehelp/ProduceSignatureHelp



Comment at: lib/Parse/ParseDecl.cpp:2325
+  if (ThisVarDecl && PP.isCodeCompletionReached())
+ConstructorCompleter(true);
   Actions.ActOnInitializerError(ThisDecl);

Maybe call signature help here directly and remove param from lamdba?
Having a parameter in lambda adds both makes the lamdba body more complicated 
and adds extra state that we have to reason about.

Same for the other calls.


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates

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

Sync with HEAD.


https://reviews.llvm.org/D51539

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -10,11 +10,11 @@
 #include "Annotations.h"
 #include "TestIndex.h"
 #include "TestTU.h"
-#include "gmock/gmock.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 using testing::_;
@@ -58,11 +58,11 @@
   auto Token = std::make_shared();
   std::weak_ptr WeakToken = Token;
 
-  SwapIndex S(
-  llvm::make_unique(SymbolSlab(), RefSlab(), std::move(Token)));
-  EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive.
+  SwapIndex S(llvm::make_unique(
+  SymbolSlab(), RefSlab(), std::move(Token), /*BackingDataSize=*/0));
+  EXPECT_FALSE(WeakToken.expired());  // Current MemIndex keeps it alive.
   S.reset(llvm::make_unique()); // Now the MemIndex is destroyed.
-  EXPECT_TRUE(WeakToken.expired());  // So the token is too.
+  EXPECT_TRUE(WeakToken.expired());   // So the token is too.
 }
 
 TEST(MemIndexTest, MemIndexDeduplicate) {
@@ -281,7 +281,7 @@
 FileURI("unittest:///test2.cc"));
 }
 
-MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References,  "") {
+MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") {
   return (arg.IncludeHeader == IncludeHeader) && (arg.References == References);
 }
 
Index: clang-tools-extra/clangd/index/dex/Dex.h
===
--- clang-tools-extra/clangd/index/dex/Dex.h
+++ clang-tools-extra/clangd/index/dex/Dex.h
@@ -55,17 +55,21 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  Dex(Range &&Symbols, Payload &&BackingData,
+  Dex(Range &&Symbols, Payload &&BackingData, size_t BackingDataSize,
   llvm::ArrayRef URISchemes)
   : Dex(std::forward(Symbols), URISchemes) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from a slab. The index takes ownership of the slab.
   static std::unique_ptr
   build(SymbolSlab Slab, llvm::ArrayRef URISchemes) {
-return llvm::make_unique(Slab, std::move(Slab), URISchemes);
+// Store Slab size before it is moved.
+const auto BackingDataSize = Slab.bytes();
+return llvm::make_unique(Slab, std::move(Slab), BackingDataSize,
+  URISchemes);
   }
 
   bool
@@ -96,6 +100,8 @@
   /// during the fuzzyFind process.
   llvm::DenseMap InvertedIndex;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 
   std::vector URISchemes;
 };
Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -227,15 +227,13 @@
 }
 
 size_t Dex::estimateMemoryUsage() const {
-  size_t Bytes =
-  LookupTable.size() * sizeof(std::pair);
-  Bytes += SymbolQuality.size() * sizeof(std::pair);
-  Bytes += InvertedIndex.size() * sizeof(Token);
-
-  for (const auto &P : InvertedIndex) {
+  size_t Bytes = Symbols.size() * sizeof(const Symbol *);
+  Bytes += SymbolQuality.size() * sizeof(float);
+  Bytes += LookupTable.getMemorySize();
+  Bytes += InvertedIndex.getMemorySize();
+  for (const auto &P : InvertedIndex)
 Bytes += P.second.size() * sizeof(DocID);
-  }
-  return Bytes;
+  return Bytes + BackingDataSize;
 }
 
 std::vector generateProximityURIs(llvm::StringRef URIPath) {
Index: clang-tools-extra/clangd/index/MemIndex.h
===
--- clang-tools-extra/clangd/index/MemIndex.h
+++ clang-tools-extra/clangd/index/MemIndex.h
@@ -30,11 +30,13 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData)
+  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData,
+   size_t BackingDataSize)
   : MemIndex(std::forward(Symbols),
  std::forward(Refs)) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->Backing

[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates

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

Remove accidental formatting changes.


https://reviews.llvm.org/D51539

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -10,11 +10,11 @@
 #include "Annotations.h"
 #include "TestIndex.h"
 #include "TestTU.h"
-#include "gmock/gmock.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 using testing::_;
@@ -58,11 +58,11 @@
   auto Token = std::make_shared();
   std::weak_ptr WeakToken = Token;
 
-  SwapIndex S(
-  llvm::make_unique(SymbolSlab(), RefSlab(), std::move(Token)));
-  EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive.
+  SwapIndex S(llvm::make_unique(
+  SymbolSlab(), RefSlab(), std::move(Token), /*BackingDataSize=*/0));
+  EXPECT_FALSE(WeakToken.expired());  // Current MemIndex keeps it alive.
   S.reset(llvm::make_unique()); // Now the MemIndex is destroyed.
-  EXPECT_TRUE(WeakToken.expired());  // So the token is too.
+  EXPECT_TRUE(WeakToken.expired());   // So the token is too.
 }
 
 TEST(MemIndexTest, MemIndexDeduplicate) {
Index: clang-tools-extra/clangd/index/dex/Dex.h
===
--- clang-tools-extra/clangd/index/dex/Dex.h
+++ clang-tools-extra/clangd/index/dex/Dex.h
@@ -55,17 +55,21 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  Dex(Range &&Symbols, Payload &&BackingData,
+  Dex(Range &&Symbols, Payload &&BackingData, size_t BackingDataSize,
   llvm::ArrayRef URISchemes)
   : Dex(std::forward(Symbols), URISchemes) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from a slab. The index takes ownership of the slab.
   static std::unique_ptr
   build(SymbolSlab Slab, llvm::ArrayRef URISchemes) {
-return llvm::make_unique(Slab, std::move(Slab), URISchemes);
+// Store Slab size before it is moved.
+const auto BackingDataSize = Slab.bytes();
+return llvm::make_unique(Slab, std::move(Slab), BackingDataSize,
+  URISchemes);
   }
 
   bool
@@ -96,6 +100,8 @@
   /// during the fuzzyFind process.
   llvm::DenseMap InvertedIndex;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 
   std::vector URISchemes;
 };
Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -227,15 +227,13 @@
 }
 
 size_t Dex::estimateMemoryUsage() const {
-  size_t Bytes =
-  LookupTable.size() * sizeof(std::pair);
-  Bytes += SymbolQuality.size() * sizeof(std::pair);
-  Bytes += InvertedIndex.size() * sizeof(Token);
-
-  for (const auto &P : InvertedIndex) {
+  size_t Bytes = Symbols.size() * sizeof(const Symbol *);
+  Bytes += SymbolQuality.size() * sizeof(float);
+  Bytes += LookupTable.getMemorySize();
+  Bytes += InvertedIndex.getMemorySize();
+  for (const auto &P : InvertedIndex)
 Bytes += P.second.size() * sizeof(DocID);
-  }
-  return Bytes;
+  return Bytes + BackingDataSize;
 }
 
 std::vector generateProximityURIs(llvm::StringRef URIPath) {
Index: clang-tools-extra/clangd/index/MemIndex.h
===
--- clang-tools-extra/clangd/index/MemIndex.h
+++ clang-tools-extra/clangd/index/MemIndex.h
@@ -30,11 +30,13 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData)
+  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData,
+   size_t BackingDataSize)
   : MemIndex(std::forward(Symbols),
  std::forward(Refs)) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from slabs. The index takes ownership of the data.
@@ -58,6 +60,8 @@
   // A map from symbol ID to symbol refs, support query by IDs.
   llvm::DenseMap> Refs;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 };
 
 } // namespace clangd
Inde

[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates

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



Comment at: clang-tools-extra/clangd/index/Index.h:512
  llvm::function_ref) const override;
+
   void lookup(const LookupRequest &,

nit: I'd avoid irrelevant changes.



Comment at: clang-tools-extra/clangd/index/MemIndex.cpp:20
+  // Store Slab size before it is moved.
+  const auto BackingDataSize = Slab.bytes();
   auto Data = std::make_pair(std::move(Slab), std::move(Refs));

Include `Refs` slab size?



Comment at: clang-tools-extra/clangd/index/MemIndex.cpp:76
 size_t MemIndex::estimateMemoryUsage() const {
-  return Index.getMemorySize();
+  return Index.getMemorySize() + BackingDataSize;
 }

Include `Refs` size?


https://reviews.llvm.org/D51539



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


[PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164648.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Revert unrelated formatting changes, simplify the comment.


https://reviews.llvm.org/D51852

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h


Index: clang-tools-extra/clangd/index/Index.h
===
--- clang-tools-extra/clangd/index/Index.h
+++ clang-tools-extra/clangd/index/Index.h
@@ -19,8 +19,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/StringSaver.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -435,7 +437,7 @@
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = UINT_MAX;
+  size_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
@@ -450,6 +452,8 @@
   }
   bool operator!=(const FuzzyFindRequest &Req) const { return !(*this == Req); 
}
 };
+bool fromJSON(const llvm::json::Value &Value, FuzzyFindRequest &Request);
+llvm::json::Value toJSON(const FuzzyFindRequest &Request);
 
 struct LookupRequest {
   llvm::DenseSet IDs;
Index: clang-tools-extra/clangd/index/Index.cpp
===
--- clang-tools-extra/clangd/index/Index.cpp
+++ clang-tools-extra/clangd/index/Index.cpp
@@ -175,6 +175,33 @@
   return Index;
 }
 
+bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request) {
+  json::ObjectMapper O(Parameters);
+  llvm::Optional MaxCandidateCount;
+  bool OK =
+  O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
+  O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
+  O.map("ProximityPaths", Request.ProximityPaths) &&
+  O.map("MaxCandidateCount", MaxCandidateCount);
+  if (MaxCandidateCount)
+Request.MaxCandidateCount = MaxCandidateCount.getValue();
+  return OK;
+}
+
+llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
+  auto Result = json::Object{
+  {"Query", Request.Query},
+  {"Scopes", json::Array{Request.Scopes}},
+  {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
+  {"ProximityPaths", json::Array{Request.ProximityPaths}},
+  };
+  // A huge limit means no limit, leave it out.
+  if (Request.MaxCandidateCount <= std::numeric_limits::max())
+Result["MaxCandidateCount"] =
+static_cast(Request.MaxCandidateCount);
+  return Result;
+}
+
 bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,
   llvm::function_ref CB) const {
   return snapshot()->fuzzyFind(R, CB);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1381,8 +1381,7 @@
 Req.Scopes = QueryScopes;
 // FIXME: we should send multiple weighted paths here.
 Req.ProximityPaths.push_back(FileName);
-vlog("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", Req.Query,
- llvm::join(Req.Scopes.begin(), Req.Scopes.end(), ","));
+vlog("Code complete: fuzzyFind({0:2})", toJSON(Req));
 
 if (SpecFuzzyFind)
   SpecFuzzyFind->NewReq = Req;


Index: clang-tools-extra/clangd/index/Index.h
===
--- clang-tools-extra/clangd/index/Index.h
+++ clang-tools-extra/clangd/index/Index.h
@@ -19,8 +19,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/StringSaver.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -435,7 +437,7 @@
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = UINT_MAX;
+  size_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
@@ -450,6 +452,8 @@
   }
   bool operator!=(const FuzzyFindRequest &Req) const { return !(*this == Req); }
 };
+bool fromJSON(const llvm::json::Value &Value, FuzzyFindRequest &Request);
+llvm::json::Value toJSON(const FuzzyFindRequest &Request);
 
 struct LookupRequest {
   llvm::DenseSet IDs;
Index: clang-tools-extra/clangd/index/Index.cpp
===

[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.
ilya-biryukov added inline comments.



Comment at: lib/Sema/CodeCompleteConsumer.cpp:622
 
+case CodeCompletionString::CK_Optional:
+  break;

This change is really sneaky and unrelated to the rest of the patch. It should 
definitely be done separately from this patch.

Could you give more details on what fails exactly instead? Can we update the 
test instead?


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51297: [docs] Create a guide for Vim users on how to setup Clangd

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

In https://reviews.llvm.org/D51297#1228441, @kbobyrev wrote:

> In https://reviews.llvm.org/D51297#1225546, @ilya-biryukov wrote:
>
> > I would stamp this from my side, but concerns whether we should recommend 
> > YCM's LSP-based completer instead are probably still there.
> >  @sammccall, WDYT?
>
>
> Yes, I can see your point, but I think this is better than nothing (which we 
> currently have). Also, having the guide in LanguageClient-neovim Wiki might 
> be easier for the users since they can change something (e.g. when the plugin 
> is updated and the docs become outdated) and have an easier time finding out 
> about the option.
>
> Would love to hear some feedback from @ioeric and @sammccall.


I also support having some instructions/pointers on editor integration. That 
said, I think we should have a section "Editor integration" with a list of 
editor clients that are known to work with clangd, instead of having a section 
just for vim. Something like:

  #Editor (or client?) integration
  
  ##Vim
  Some LSP clients that are known to work with clangd:
   - nvim, LanguageClient-neovim ..
   - ...
  
  ## vscode
  
  ## emacs?

What do you think?


https://reviews.llvm.org/D51297



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

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

- Resolve discussions.


Repository:
  rC Clang

https://reviews.llvm.org/D51038

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/function-overloads.cpp
  test/Index/complete-block-property-assignment.m

Index: test/Index/complete-block-property-assignment.m
===
--- test/Index/complete-block-property-assignment.m
+++ test/Index/complete-block-property-assignment.m
@@ -60,13 +60,20 @@
 // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s
-// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
+// CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1)
 @end
Index: test/CodeCompletion/function-overloads.cpp
===
--- /dev/null
+++ test/CodeCompletion/function-overloads.cpp
@@ -0,0 +1,27 @@
+int f(int i, int j = 2, int k = 5);
+int f(float x, float y...);
+
+class A {
+ public:
+  A(int, int, int);
+};
+
+void test() {
+  A a(f(1, 2, 3, 4), 2, 3);
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
+// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
+// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
+// CHECK-CC2: OVERLOAD: [#int#]f(float x, float y)
+// CHECK-CC2-NOT: OVERLOAD: [#int#]f(int i)
+// CHECK-CC3: OVERLOAD: A(<#int#>, int, int)
+// CHECK-CC3: OVERLOAD: A(<#const A &#>)
+// CHECK-CC3: OVERLOAD: A(<#A &&#>)
+// CHECK-CC4: OVERLOAD: A(int, <#int#>, int)
Index: lib/Sema/CodeCompleteConsumer.cpp
===
--- lib/Sema/CodeCompleteConsumer.cpp
+++ lib/Sema/CodeCompleteConsumer.cpp
@@ -619,6 +619,9 @@
   OS << "<#" << C.Text << "#>";
   break;
 
+case CodeCompletionString::CK_Optional:
+  break;
+
 default: OS << C.Text; break;
 }
   }
Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -416,14 +416,20 @@
 CommaLocsTy CommaLocs;
 
 SourceLocation LParLoc = T.getOpenLocation();
-if (ParseExpressionList(
-Exprs, CommaLocs, [this, OmpPrivParm, LParLoc, &Exprs] {
-  QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
-  getCurScope(),
-  OmpPrivParm->getType()->getCanonicalTypeInternal(),
-  OmpPrivParm->getLocation(), Exprs, LParLoc);
-  Actions.CodeCompleteExpression(getCurScope(), PreferredType);
-})) {
+auto Completer = [this, OmpPrivParm, LParLoc, &Exprs]() {

[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Parse/ParseExpr.cpp:1663
 if (Tok.isNot(tok::r_paren)) {
-  if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
-QualType PreferredType = Actions.ProduceCallSignatureHelp(
-getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
-Actions.CodeCompleteExpression(getCurScope(), PreferredType);
-  })) {
+  auto Completer = [&]() {
+QualType PreferredType = Actions.ProduceCallSignatureHelp(

NIT: inline completer.



Comment at: lib/Parse/ParseExpr.cpp:1663
 if (Tok.isNot(tok::r_paren)) {
-  if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
-QualType PreferredType = Actions.ProduceCallSignatureHelp(
-getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
-Actions.CodeCompleteExpression(getCurScope(), PreferredType);
-  })) {
+  auto Completer = [&]() {
+QualType PreferredType = Actions.ProduceCallSignatureHelp(

ilya-biryukov wrote:
> NIT: inline completer.
Maybe inline this into lambda body again?
Now that it's not called outside it, we don't need a variable anymore.



Comment at: lib/Parse/ParseExprCXX.cpp:2827
 if (Tok.isNot(tok::r_paren)) {
+  ParsedType TypeRep =
+  Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();

ActOnTypeName is called at a different point now, please move it back into the 
lambda.



Comment at: lib/Parse/ParseExprCXX.cpp:2830
   CommaLocsTy CommaLocs;
-  if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
-ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(),
-   DeclaratorInfo).get();
-QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
-getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
-DeclaratorInfo.getEndLoc(), ConstructorArgs, 
ConstructorLParen);
-Actions.CodeCompleteExpression(getCurScope(), PreferredType);
-  })) {
+  auto Completer = [&]() {
+QualType PreferredType = Actions.ProduceConstructorSignatureHelp(

Same here: maybe inline the lambda into the call to keep the changes minimal?



Comment at: lib/Parse/ParseOpenMP.cpp:419
 SourceLocation LParLoc = T.getOpenLocation();
-if (ParseExpressionList(
-Exprs, CommaLocs, [this, OmpPrivParm, LParLoc, &Exprs] {
-  QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
-  getCurScope(),
-  OmpPrivParm->getType()->getCanonicalTypeInternal(),
-  OmpPrivParm->getLocation(), Exprs, LParLoc);
-  Actions.CodeCompleteExpression(getCurScope(), PreferredType);
-})) {
+auto Completer = [this, OmpPrivParm, LParLoc, &Exprs]() {
+  QualType PreferredType = Actions.ProduceConstructorSignatureHelp(

Same here: maybe inline the lambda?


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51853: Merge two attribute diagnostics into one

2018-09-10 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic created this revision.
asavonic added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Merged the recently added `err_attribute_argument_negative` diagnostic
with existing `err_attribute_requires_positive_integer` diagnostic:
the former allows only strictly positive integer, while the latter
also allows zero.


Repository:
  rC Clang

https://reviews.llvm.org/D51853

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/SemaOpenCL/invalid-kernel-attrs.cl


Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -38,8 +38,8 @@
 kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // 
expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}}
 kernel __attribute__((intel_reqd_sub_group_size(8))) 
__attribute__((intel_reqd_sub_group_size(16))) void kernel16() {}  
//expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied 
with different parameters}}
 
-__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} 
//expected-error{{negative argument is not allowed for 'work_group_size_hint' 
attribute}}
-__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // 
expected-error{{negative argument is not allowed for 'reqd_work_group_size' 
attribute}}
+__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} 
//expected-error{{'work_group_size_hint' attribute requires a non-negative 
integral compile time constant expression}}
+__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // 
expected-error{{'reqd_work_group_size' attribute requires a non-negative 
integral compile time constant expression}}
 
 // 4294967294 is a negative integer if treated as signed.
 // Should compile successfully, since we expect an unsigned.
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -304,7 +304,7 @@
 if (Val <= 0) {
   S.Diag(A.getRange().getBegin(),
  diag::err_attribute_requires_positive_integer)
-  << A;
+  << A << /* positive */ 0;
   return nullptr;
 }
 UnrollFactor = Val;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -254,7 +254,8 @@
   }
 
   if (StrictlyUnsigned && I.isSigned() && I.isNegative()) {
-S.Diag(getAttrLoc(AI), diag::err_attribute_argument_negative) << AI;
+S.Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
+<< AI << /*non-negative*/ 1;
 return false;
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2497,7 +2497,8 @@
 def err_attribute_bad_neon_vector_size : Error<
   "Neon vector size must be 64 or 128 bits">;
 def err_attribute_requires_positive_integer : Error<
-  "%0 attribute requires a positive integral compile time constant 
expression">;
+  "%0 attribute requires a %select{positive|non-negative}1 "
+  "integral compile time constant expression">;
 def err_attribute_requires_opencl_version : Error<
   "%0 attribute requires OpenCL version %1%select{| or above}2">;
 def warn_unsupported_target_attribute
@@ -2530,8 +2531,6 @@
   "constant|a string|an identifier}1">;
 def err_attribute_argument_outof_range : Error<
   "%0 attribute requires integer constant between %1 and %2 inclusive">;
-def err_attribute_argument_negative : Error<
-  "negative argument is not allowed for %0 attribute">;
 def err_init_priority_object_attr : Error<
   "can only use 'init_priority' attribute on file-scope definitions "
   "of objects of class type">;


Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -38,8 +38,8 @@
 kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}}
 kernel __attribute__((intel_reqd_sub_group_size(8))) __attribute__((intel_reqd_sub_group_size(16))) void kernel16() {}  //expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied with different parameters}}
 
-__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} //expected-error{{negative argument is not allowed for 'work_group_size_hint' attribute}}
-__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // expected-error{{negative argument is not allowed for 'reqd_work_group_size' attribute}}
+__kernel __attribute__

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-09-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth added a comment.
This revision is now accepted and ready to land.

Ups, sorry i overlooked.

I applied your changes to the current version of the const check, and 
everything seems fine. The false negative is gone.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619



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


[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164653.
kbobyrev marked 2 inline comments as done.

https://reviews.llvm.org/D51539

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -10,11 +10,11 @@
 #include "Annotations.h"
 #include "TestIndex.h"
 #include "TestTU.h"
-#include "gmock/gmock.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 using testing::_;
@@ -58,11 +58,11 @@
   auto Token = std::make_shared();
   std::weak_ptr WeakToken = Token;
 
-  SwapIndex S(
-  llvm::make_unique(SymbolSlab(), RefSlab(), std::move(Token)));
-  EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive.
+  SwapIndex S(llvm::make_unique(
+  SymbolSlab(), RefSlab(), std::move(Token), /*BackingDataSize=*/0));
+  EXPECT_FALSE(WeakToken.expired());  // Current MemIndex keeps it alive.
   S.reset(llvm::make_unique()); // Now the MemIndex is destroyed.
-  EXPECT_TRUE(WeakToken.expired());  // So the token is too.
+  EXPECT_TRUE(WeakToken.expired());   // So the token is too.
 }
 
 TEST(MemIndexTest, MemIndexDeduplicate) {
Index: clang-tools-extra/clangd/index/dex/Dex.h
===
--- clang-tools-extra/clangd/index/dex/Dex.h
+++ clang-tools-extra/clangd/index/dex/Dex.h
@@ -55,17 +55,21 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  Dex(Range &&Symbols, Payload &&BackingData,
+  Dex(Range &&Symbols, Payload &&BackingData, size_t BackingDataSize,
   llvm::ArrayRef URISchemes)
   : Dex(std::forward(Symbols), URISchemes) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from a slab. The index takes ownership of the slab.
   static std::unique_ptr
   build(SymbolSlab Slab, llvm::ArrayRef URISchemes) {
-return llvm::make_unique(Slab, std::move(Slab), URISchemes);
+// Store Slab size before it is moved.
+const auto BackingDataSize = Slab.bytes();
+return llvm::make_unique(Slab, std::move(Slab), BackingDataSize,
+  URISchemes);
   }
 
   bool
@@ -96,6 +100,8 @@
   /// during the fuzzyFind process.
   llvm::DenseMap InvertedIndex;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 
   std::vector URISchemes;
 };
Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -227,15 +227,13 @@
 }
 
 size_t Dex::estimateMemoryUsage() const {
-  size_t Bytes =
-  LookupTable.size() * sizeof(std::pair);
-  Bytes += SymbolQuality.size() * sizeof(std::pair);
-  Bytes += InvertedIndex.size() * sizeof(Token);
-
-  for (const auto &P : InvertedIndex) {
+  size_t Bytes = Symbols.size() * sizeof(const Symbol *);
+  Bytes += SymbolQuality.size() * sizeof(float);
+  Bytes += LookupTable.getMemorySize();
+  Bytes += InvertedIndex.getMemorySize();
+  for (const auto &P : InvertedIndex)
 Bytes += P.second.size() * sizeof(DocID);
-  }
-  return Bytes;
+  return Bytes + BackingDataSize;
 }
 
 std::vector generateProximityURIs(llvm::StringRef URIPath) {
Index: clang-tools-extra/clangd/index/MemIndex.h
===
--- clang-tools-extra/clangd/index/MemIndex.h
+++ clang-tools-extra/clangd/index/MemIndex.h
@@ -30,11 +30,13 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData)
+  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData,
+   size_t BackingDataSize)
   : MemIndex(std::forward(Symbols),
  std::forward(Refs)) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from slabs. The index takes ownership of the data.
@@ -58,6 +60,8 @@
   // A map from symbol ID to symbol refs, support query by IDs.
   llvm::DenseMap> Refs;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 };
 
 } // namespace clangd
Index: clang-tools-extra/cl

[PATCH] D51220: [clang-tidy] run-clang-tidy fails using python 3.7

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

Unicode works both with python3 and python2 (but seemed to work before too).

Otherwise LG




Comment at: clang-tidy/tool/run-clang-tidy.py:169
   failed_files.append(name)
-
-if is_py2:

The patch does not apply clean to master because of this part. Could you please 
recheck that?



Comment at: clang-tidy/tool/run-clang-tidy.py:171
+  sys.stdout.write(' '.join(invocation) + '\n' + output.decode('utf-8') + 
'\n')
   if err:
+sys.stderr.write(err.decode('utf-8') + '\n')

please use `len(err)` here instead, python3 does not work.


https://reviews.llvm.org/D51220



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


[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked an inline comment as done.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/Index.h:512
  llvm::function_ref) const override;
+
   void lookup(const LookupRequest &,

ioeric wrote:
> nit: I'd avoid irrelevant changes.
This one is out of sync; fixed in the previous update :)


https://reviews.llvm.org/D51539



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


[clang-tools-extra] r341800 - [clangd] Add symbol slab size to index memory consumption estimates

2018-09-10 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 10 04:46:07 2018
New Revision: 341800

URL: http://llvm.org/viewvc/llvm-project?rev=341800&view=rev
Log:
[clangd] Add symbol slab size to index memory consumption estimates

Currently, `SymbolIndex::estimateMemoryUsage()` returns the "overhead"
estimate, i.e. the estimate of the Index data structure excluding
backing data (such as Symbol Slab and Reference Slab). This patch
propagates information about paired data size where necessary.

Reviewed By: ioeric, sammccall

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

Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/clangd/index/MemIndex.h
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.h
clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=341800&r1=341799&r2=341800&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Mon Sep 10 04:46:07 2018
@@ -127,11 +127,18 @@ std::unique_ptr FileSymbols
 }
   }
 
+  size_t StorageSize = RefsStorage.size() * sizeof(Ref);
+  for (const auto &Slab : SymbolSlabs)
+StorageSize += Slab->bytes();
+  for (const auto &RefSlab : RefSlabs)
+StorageSize += RefSlab->bytes();
+
   // Index must keep the slabs and contiguous ranges alive.
   return llvm::make_unique(
   llvm::make_pointee_range(AllSymbols), std::move(AllRefs),
   std::make_tuple(std::move(SymbolSlabs), std::move(RefSlabs),
-  std::move(RefsStorage)));
+  std::move(RefsStorage)),
+  StorageSize);
 }
 
 void FileIndex::update(PathRef Path, ASTContext *AST,

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=341800&r1=341799&r2=341800&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Mon Sep 10 04:46:07 2018
@@ -16,8 +16,11 @@ namespace clang {
 namespace clangd {
 
 std::unique_ptr MemIndex::build(SymbolSlab Slab, RefSlab Refs) {
+  // Store Slab size before it is moved.
+  const auto BackingDataSize = Slab.bytes() + Refs.bytes();
   auto Data = std::make_pair(std::move(Slab), std::move(Refs));
-  return llvm::make_unique(Data.first, Data.second, std::move(Data));
+  return llvm::make_unique(Data.first, Data.second, std::move(Data),
+ BackingDataSize);
 }
 
 bool MemIndex::fuzzyFind(
@@ -70,7 +73,7 @@ void MemIndex::refs(const RefsRequest &R
 }
 
 size_t MemIndex::estimateMemoryUsage() const {
-  return Index.getMemorySize();
+  return Index.getMemorySize() + Refs.getMemorySize() + BackingDataSize;
 }
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.h?rev=341800&r1=341799&r2=341800&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.h Mon Sep 10 04:46:07 2018
@@ -30,11 +30,13 @@ public:
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData)
+  MemIndex(SymbolRange &&Symbols, RefRange &&Refs, Payload &&BackingData,
+   size_t BackingDataSize)
   : MemIndex(std::forward(Symbols),
  std::forward(Refs)) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from slabs. The index takes ownership of the data.
@@ -58,6 +60,8 @@ private:
   // A map from symbol ID to symbol refs, support query by IDs.
   llvm::DenseMap> Refs;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 };
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Dex.cpp?rev=341800&r1=341799&r2=341800&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp Mon Sep 10 04:46:07 2018
@@ -227,15 +227,13 @@ void Dex::refs(const RefsRequest &Req,
 }
 
 size_t Dex::estimateMemoryUsage() const {
-  size

[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341800: [clangd] Add symbol slab size to index memory 
consumption estimates (authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51539?vs=164653&id=164654#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51539

Files:
  clang-tools-extra/trunk/clangd/index/FileIndex.cpp
  clang-tools-extra/trunk/clangd/index/MemIndex.cpp
  clang-tools-extra/trunk/clangd/index/MemIndex.h
  clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
  clang-tools-extra/trunk/clangd/index/dex/Dex.h
  clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp
@@ -127,11 +127,18 @@
 }
   }
 
+  size_t StorageSize = RefsStorage.size() * sizeof(Ref);
+  for (const auto &Slab : SymbolSlabs)
+StorageSize += Slab->bytes();
+  for (const auto &RefSlab : RefSlabs)
+StorageSize += RefSlab->bytes();
+
   // Index must keep the slabs and contiguous ranges alive.
   return llvm::make_unique(
   llvm::make_pointee_range(AllSymbols), std::move(AllRefs),
   std::make_tuple(std::move(SymbolSlabs), std::move(RefSlabs),
-  std::move(RefsStorage)));
+  std::move(RefsStorage)),
+  StorageSize);
 }
 
 void FileIndex::update(PathRef Path, ASTContext *AST,
Index: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp
@@ -16,8 +16,11 @@
 namespace clangd {
 
 std::unique_ptr MemIndex::build(SymbolSlab Slab, RefSlab Refs) {
+  // Store Slab size before it is moved.
+  const auto BackingDataSize = Slab.bytes() + Refs.bytes();
   auto Data = std::make_pair(std::move(Slab), std::move(Refs));
-  return llvm::make_unique(Data.first, Data.second, std::move(Data));
+  return llvm::make_unique(Data.first, Data.second, std::move(Data),
+ BackingDataSize);
 }
 
 bool MemIndex::fuzzyFind(
@@ -70,7 +73,7 @@
 }
 
 size_t MemIndex::estimateMemoryUsage() const {
-  return Index.getMemorySize();
+  return Index.getMemorySize() + Refs.getMemorySize() + BackingDataSize;
 }
 
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
@@ -227,15 +227,13 @@
 }
 
 size_t Dex::estimateMemoryUsage() const {
-  size_t Bytes =
-  LookupTable.size() * sizeof(std::pair);
-  Bytes += SymbolQuality.size() * sizeof(std::pair);
-  Bytes += InvertedIndex.size() * sizeof(Token);
-
-  for (const auto &P : InvertedIndex) {
+  size_t Bytes = Symbols.size() * sizeof(const Symbol *);
+  Bytes += SymbolQuality.size() * sizeof(float);
+  Bytes += LookupTable.getMemorySize();
+  Bytes += InvertedIndex.getMemorySize();
+  for (const auto &P : InvertedIndex)
 Bytes += P.second.size() * sizeof(DocID);
-  }
-  return Bytes;
+  return Bytes + BackingDataSize;
 }
 
 std::vector generateProximityURIs(llvm::StringRef URIPath) {
Index: clang-tools-extra/trunk/clangd/index/dex/Dex.h
===
--- clang-tools-extra/trunk/clangd/index/dex/Dex.h
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.h
@@ -55,17 +55,21 @@
   }
   // Symbols are owned by BackingData, Index takes ownership.
   template 
-  Dex(Range &&Symbols, Payload &&BackingData,
+  Dex(Range &&Symbols, Payload &&BackingData, size_t BackingDataSize,
   llvm::ArrayRef URISchemes)
   : Dex(std::forward(Symbols), URISchemes) {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
+this->BackingDataSize = BackingDataSize;
   }
 
   /// Builds an index from a slab. The index takes ownership of the slab.
   static std::unique_ptr
   build(SymbolSlab Slab, llvm::ArrayRef URISchemes) {
-return llvm::make_unique(Slab, std::move(Slab), URISchemes);
+// Store Slab size before it is moved.
+const auto BackingDataSize = Slab.bytes();
+return llvm::make_unique(Slab, std::move(Slab), BackingDataSize,
+  URISchemes);
   }
 
   bool
@@ -96,6 +100,8 @@
   /// during the fuzzyFind process.
   llvm::DenseMap InvertedIndex;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
+  // Size of memory retained by KeepAlive.
+  size_t BackingDataSize = 0;
 
   std::vector URISchemes;
 };
Index: clang-tools-extra/trunk/clangd/index/MemIndex.h
===
--- clang-tools-extra/trunk/clangd/inde

[clang-tools-extra] r341802 - [clangd] Implement FuzzyFindRequest JSON (de)serialization

2018-09-10 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 10 04:51:05 2018
New Revision: 341802

URL: http://llvm.org/viewvc/llvm-project?rev=341802&view=rev
Log:
[clangd] Implement FuzzyFindRequest JSON (de)serialization

JSON (de)serialization of `FuzzyFindRequest` might be useful for both
D51090 and D51628. Also, this allows precise logging of the fuzzy find
requests.

Reviewed By: sammccall

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=341802&r1=341801&r2=341802&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Mon Sep 10 04:51:05 2018
@@ -1381,8 +1381,7 @@ private:
 Req.Scopes = QueryScopes;
 // FIXME: we should send multiple weighted paths here.
 Req.ProximityPaths.push_back(FileName);
-vlog("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", Req.Query,
- llvm::join(Req.Scopes.begin(), Req.Scopes.end(), ","));
+vlog("Code complete: fuzzyFind({0:2})", toJSON(Req));
 
 if (SpecFuzzyFind)
   SpecFuzzyFind->NewReq = Req;

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=341802&r1=341801&r2=341802&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Mon Sep 10 04:51:05 2018
@@ -175,6 +175,33 @@ std::shared_ptr SwapIndex::
   return Index;
 }
 
+bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request) {
+  json::ObjectMapper O(Parameters);
+  llvm::Optional MaxCandidateCount;
+  bool OK =
+  O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
+  O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
+  O.map("ProximityPaths", Request.ProximityPaths) &&
+  O.map("MaxCandidateCount", MaxCandidateCount);
+  if (MaxCandidateCount)
+Request.MaxCandidateCount = MaxCandidateCount.getValue();
+  return OK;
+}
+
+llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
+  auto Result = json::Object{
+  {"Query", Request.Query},
+  {"Scopes", json::Array{Request.Scopes}},
+  {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
+  {"ProximityPaths", json::Array{Request.ProximityPaths}},
+  };
+  // A huge limit means no limit, leave it out.
+  if (Request.MaxCandidateCount <= std::numeric_limits::max())
+Result["MaxCandidateCount"] =
+static_cast(Request.MaxCandidateCount);
+  return Result;
+}
+
 bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,
   llvm::function_ref CB) const {
   return snapshot()->fuzzyFind(R, CB);

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=341802&r1=341801&r2=341802&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Sep 10 04:51:05 2018
@@ -19,8 +19,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/StringSaver.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -435,7 +437,7 @@ struct FuzzyFindRequest {
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = UINT_MAX;
+  size_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
@@ -450,6 +452,8 @@ struct FuzzyFindRequest {
   }
   bool operator!=(const FuzzyFindRequest &Req) const { return !(*this == Req); 
}
 };
+bool fromJSON(const llvm::json::Value &Value, FuzzyFindRequest &Request);
+llvm::json::Value toJSON(const FuzzyFindRequest &Request);
 
 struct LookupRequest {
   llvm::DenseSet IDs;


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


[PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341802: [clangd] Implement FuzzyFindRequest JSON 
(de)serialization (authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51852?vs=164648&id=164655#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51852

Files:
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/index/Index.cpp
  clang-tools-extra/trunk/clangd/index/Index.h


Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -1381,8 +1381,7 @@
 Req.Scopes = QueryScopes;
 // FIXME: we should send multiple weighted paths here.
 Req.ProximityPaths.push_back(FileName);
-vlog("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", Req.Query,
- llvm::join(Req.Scopes.begin(), Req.Scopes.end(), ","));
+vlog("Code complete: fuzzyFind({0:2})", toJSON(Req));
 
 if (SpecFuzzyFind)
   SpecFuzzyFind->NewReq = Req;
Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -19,8 +19,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/StringSaver.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -435,7 +437,7 @@
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = UINT_MAX;
+  size_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
@@ -450,6 +452,8 @@
   }
   bool operator!=(const FuzzyFindRequest &Req) const { return !(*this == Req); 
}
 };
+bool fromJSON(const llvm::json::Value &Value, FuzzyFindRequest &Request);
+llvm::json::Value toJSON(const FuzzyFindRequest &Request);
 
 struct LookupRequest {
   llvm::DenseSet IDs;
Index: clang-tools-extra/trunk/clangd/index/Index.cpp
===
--- clang-tools-extra/trunk/clangd/index/Index.cpp
+++ clang-tools-extra/trunk/clangd/index/Index.cpp
@@ -175,6 +175,33 @@
   return Index;
 }
 
+bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request) {
+  json::ObjectMapper O(Parameters);
+  llvm::Optional MaxCandidateCount;
+  bool OK =
+  O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
+  O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
+  O.map("ProximityPaths", Request.ProximityPaths) &&
+  O.map("MaxCandidateCount", MaxCandidateCount);
+  if (MaxCandidateCount)
+Request.MaxCandidateCount = MaxCandidateCount.getValue();
+  return OK;
+}
+
+llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
+  auto Result = json::Object{
+  {"Query", Request.Query},
+  {"Scopes", json::Array{Request.Scopes}},
+  {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
+  {"ProximityPaths", json::Array{Request.ProximityPaths}},
+  };
+  // A huge limit means no limit, leave it out.
+  if (Request.MaxCandidateCount <= std::numeric_limits::max())
+Result["MaxCandidateCount"] =
+static_cast(Request.MaxCandidateCount);
+  return Result;
+}
+
 bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,
   llvm::function_ref CB) const {
   return snapshot()->fuzzyFind(R, CB);


Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -1381,8 +1381,7 @@
 Req.Scopes = QueryScopes;
 // FIXME: we should send multiple weighted paths here.
 Req.ProximityPaths.push_back(FileName);
-vlog("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", Req.Query,
- llvm::join(Req.Scopes.begin(), Req.Scopes.end(), ","));
+vlog("Code complete: fuzzyFind({0:2})", toJSON(Req));
 
 if (SpecFuzzyFind)
   SpecFuzzyFind->NewReq = Req;
Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -19,8 +19,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/StringSaver

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-09-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.
Herald added a subscriber: Szelethus.



Comment at: clang-tidy/utils/ExprMutationAnalyzer.h:38
+  const Stmt *findDeclMutation(ArrayRef Matches);
+  const Stmt *findDeclMutation(const Decl *Dec);
+

@shuaiwang, @JonasToth hi.
Is it very intentional that this `findDeclMutation()` is private?

Is there some other way i should be doing if i have a statement `S`,
a declRefExpr `D`, and i want to find the statement `Q`, which mutates
the underlying variable to which the declRefExpr `D` refers?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679



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


[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

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



Comment at: clang-tidy/utils/ExprMutationAnalyzer.h:38
+  const Stmt *findDeclMutation(ArrayRef Matches);
+  const Stmt *findDeclMutation(const Decl *Dec);
+

lebedev.ri wrote:
> @shuaiwang, @JonasToth hi.
> Is it very intentional that this `findDeclMutation()` is private?
> 
> Is there some other way i should be doing if i have a statement `S`,
> a declRefExpr `D`, and i want to find the statement `Q`, which mutates
> the underlying variable to which the declRefExpr `D` refers?
(the statement `Q` within the statement `S`, of course)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679



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


[libcxxabi] r341812 - Creating release candidate rc3 from release_700 branch

2018-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Sep 10 05:17:27 2018
New Revision: 341812

URL: http://llvm.org/viewvc/llvm-project?rev=341812&view=rev
Log:
Creating release candidate rc3 from release_700 branch

Added:
libcxxabi/tags/RELEASE_700/rc3/   (props changed)
  - copied from r341811, libcxxabi/branches/release_70/

Propchange: libcxxabi/tags/RELEASE_700/rc3/
--
svn:mergeinfo = /libcxxabi/trunk:339865


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


[libcxx] r341811 - Creating release candidate rc3 from release_700 branch

2018-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Sep 10 05:17:20 2018
New Revision: 341811

URL: http://llvm.org/viewvc/llvm-project?rev=341811&view=rev
Log:
Creating release candidate rc3 from release_700 branch

Added:
libcxx/tags/RELEASE_700/rc3/   (props changed)
  - copied from r341810, libcxx/branches/release_70/

Propchange: libcxx/tags/RELEASE_700/rc3/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Mon Sep 10 05:17:20 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:339431,339675,339697,339702,339741-339743,339794,339804,339816,339874,340406,340544,340609,340823


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


[libunwind] r341818 - Creating release candidate rc3 from release_700 branch

2018-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Sep 10 05:18:15 2018
New Revision: 341818

URL: http://llvm.org/viewvc/llvm-project?rev=341818&view=rev
Log:
Creating release candidate rc3 from release_700 branch

Added:
libunwind/tags/RELEASE_700/rc3/   (props changed)
  - copied from r341817, libunwind/branches/release_70/

Propchange: libunwind/tags/RELEASE_700/rc3/
--
svn:mergeinfo = /libunwind/trunk:339217


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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Sema/CodeCompleteConsumer.cpp:622
 
+case CodeCompletionString::CK_Optional:
+  break;

ilya-biryukov wrote:
> This change is really sneaky and unrelated to the rest of the patch. It 
> should definitely be done separately from this patch.
> 
> Could you give more details on what fails exactly instead? Can we update the 
> test instead?
As Kadir mentioned offline this actually LG, we shouldn't read `C.Text` for 
CK_Optional chunks.

Maybe leave a FIXME that we could actually print the `CodeCompletionString` 
from the optional chunk? 


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51855: [constexpr] Fix ICE when memcpy() is given a pointer to an incomplete array

2018-09-10 Thread Petr Pavlu via Phabricator via cfe-commits
petpav01 created this revision.
petpav01 added a reviewer: rsmith.
Herald added a reviewer: javed.absar.
Herald added subscribers: cfe-commits, kristof.beyls.

Trying to compile the following example results in a clang crash:

  $ cat char.c
  void *memcpy(void *, const void *, unsigned int);
  extern char array2[];
  extern char array[];
  void test(void) { memcpy(&array, &array2, 9 * sizeof(char)); }
  
  $ ./llvm/build/bin/clang -target armv8a-none-eabi -c char.c
  clang-8: /work/llvm/lib/Support/APInt.cpp:1785: static void 
llvm::APInt::udivrem(const llvm::APInt&, uint64_t, llvm::APInt&, uint64_t&): 
Assertion `RHS != 0 && "Divide by zero?"' failed.
  [...]

The problem occurs since rC338941 . The 
change added support for constant evaluation of `__builtin_memcpy/memmove()` 
but it does not always cope well with incomplete types.

The AST for the `memcpy()` call looks as follows:

  CallExpr 0x7416d0 'void *'
  |-ImplicitCastExpr 0x7416b8 'void *(*)(void *, const void *, unsigned int)' 

  | `-DeclRefExpr 0x741518 'void *(void *, const void *, unsigned int)' 
Function 0x741198 'memcpy' 'void *(void *, const void *, unsigned int)'
  |-ImplicitCastExpr 0x741710 'void *' 
  | `-UnaryOperator 0x741598 'char (*)[]' prefix '&' cannot overflow
  |   `-DeclRefExpr 0x741540 'char []' lvalue Var 0x741358 'array' 'char []'
  |-ImplicitCastExpr 0x741728 'const void *' 
  | `-UnaryOperator 0x7415e0 'char (*)[]' prefix '&' cannot overflow
  |   `-DeclRefExpr 0x7415b8 'char []' lvalue Var 0x741298 'array2' 'char []'
  `-BinaryOperator 0x741668 'unsigned int' '*'
|-ImplicitCastExpr 0x741650 'unsigned int' 
| `-IntegerLiteral 0x741600 'int' 9
`-UnaryExprOrTypeTraitExpr 0x741630 'unsigned int' sizeof 'char'

The following happens in `PointerExprEvaluator::VisitBuiltinCallExpr()`, label 
`Builtin::BI__builtin_memcpy`:

- Types `T` and `SrcT` are determined as:

  IncompleteArrayType 0x741250 'char []'
  `-BuiltinType 0x6ff430 'char'

- Method `ASTContext::getTypeSizeInChars()` is called to obtain size of type 
`T`. It returns 0 because the type is incomplete. The result is stored in 
variable `TSize`.
- Following call to `llvm::APInt::udivrem(OrigN, TSize, N, Remainder)` fails 
because it attempts a divide by zero.

The proposed patch fixes the problem by adding a check that no incomplete type 
is getting copied prior to the call to `ASTContext::getTypeSizeInChars()`.


Repository:
  rC Clang

https://reviews.llvm.org/D51855

Files:
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ExprConstant.cpp
  test/CodeGen/builtin-memfns.c
  test/SemaCXX/constexpr-string.cpp


Index: test/SemaCXX/constexpr-string.cpp
===
--- test/SemaCXX/constexpr-string.cpp
+++ test/SemaCXX/constexpr-string.cpp
@@ -370,4 +370,31 @@
   // designators until we have a long enough matching size, if both designators
   // point to the start of their respective final elements.
   static_assert(test_derived_to_base(2) == 3434); // expected-error 
{{constant}} expected-note {{in call}}
+
+  // Check that when address-of an array is passed to a tested function the
+  // array can be fully copied.
+  constexpr int test_address_of_const_array_type() {
+int arr[4] = {1, 2, 3, 4};
+__builtin_memmove(&arr, &arr, sizeof(arr));
+return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3];
+  }
+  static_assert(test_address_of_const_array_type() == 1234);
+
+  // Check that an incomplete array is rejected.
+  constexpr int test_incomplete_array_type() { // expected-error {{never 
produces a constant}}
+extern int arr[];
+__builtin_memmove(arr, arr, 4 * sizeof(arr[0]));
+// expected-note@-1 2{{'memmove' not supported: source is not a contiguous 
array of at least 4 elements of type 'int'}}
+return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3];
+  }
+  static_assert(test_incomplete_array_type() == 1234); // expected-error 
{{constant}} expected-note {{in call}}
+
+  // Check that a pointer to an incomplete array is rejected.
+  constexpr int test_address_of_incomplete_array_type() { // expected-error 
{{never produces a constant}}
+extern int arr[];
+__builtin_memmove(&arr, &arr, 4 * sizeof(arr[0]));
+// expected-note@-1 2{{cannot constant evaluate 'memmove' between objects 
of incomplete type 'int []'}}
+return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3];
+  }
+  static_assert(test_address_of_incomplete_array_type() == 1234); // 
expected-error {{constant}} expected-note {{in call}}
 }
Index: test/CodeGen/builtin-memfns.c
===
--- test/CodeGen/builtin-memfns.c
+++ test/CodeGen/builtin-memfns.c
@@ -111,3 +111,10 @@
   memcpy(&d, (char *)&e.a, sizeof(e));
 }
 
+// CHECK-LABEL: @test12
+extern char dest_array[];
+extern char src_array[];
+void test12() {
+  // CHECK: call void @llvm.memcpy{{.*}}(
+  memcpy(&dest_array, &dest_array, 2);

[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:2827
 if (Tok.isNot(tok::r_paren)) {
+  ParsedType TypeRep =
+  Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();

ilya-biryukov wrote:
> ActOnTypeName is called at a different point now, please move it back into 
> the lambda.
As discussed offline, this actually LG.
It's weird that result of `ActOnTypeName` seems to be only needed for code 
completion and it's called even when completion is disabled.

However, this was the case before the patch as well


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

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

- Inline completers.


Repository:
  rC Clang

https://reviews.llvm.org/D51038

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/function-overloads.cpp
  test/Index/complete-block-property-assignment.m

Index: test/Index/complete-block-property-assignment.m
===
--- test/Index/complete-block-property-assignment.m
+++ test/Index/complete-block-property-assignment.m
@@ -60,13 +60,20 @@
 // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s
-// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
+// CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1)
 @end
Index: test/CodeCompletion/function-overloads.cpp
===
--- /dev/null
+++ test/CodeCompletion/function-overloads.cpp
@@ -0,0 +1,27 @@
+int f(int i, int j = 2, int k = 5);
+int f(float x, float y...);
+
+class A {
+ public:
+  A(int, int, int);
+};
+
+void test() {
+  A a(f(1, 2, 3, 4), 2, 3);
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
+// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
+// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
+// CHECK-CC2: OVERLOAD: [#int#]f(float x, float y)
+// CHECK-CC2-NOT: OVERLOAD: [#int#]f(int i)
+// CHECK-CC3: OVERLOAD: A(<#int#>, int, int)
+// CHECK-CC3: OVERLOAD: A(<#const A &#>)
+// CHECK-CC3: OVERLOAD: A(<#A &&#>)
+// CHECK-CC4: OVERLOAD: A(int, <#int#>, int)
Index: lib/Sema/CodeCompleteConsumer.cpp
===
--- lib/Sema/CodeCompleteConsumer.cpp
+++ lib/Sema/CodeCompleteConsumer.cpp
@@ -619,6 +619,10 @@
   OS << "<#" << C.Text << "#>";
   break;
 
+// FIXME: We can also print optional parameters of an overload.
+case CodeCompletionString::CK_Optional:
+  break;
+
 default: OS << C.Text; break;
 }
   }
Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -417,13 +417,20 @@
 
 SourceLocation LParLoc = T.getOpenLocation();
 if (ParseExpressionList(
-Exprs, CommaLocs, [this, OmpPrivParm, LParLoc, &Exprs] {
+Exprs, CommaLocs, [this, OmpPrivParm, LParLoc, &Exprs]() {
   QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
   getCurScope(),
   OmpPrivParm->getType()->getCanonicalTypeInternal(),
   OmpPrivParm->getLocation(), Exprs, LParLoc);
+  CalledSignatureHelp = true;
   Actions.CodeCompleteExpression(g

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5244
+   false))
+CmdArgs.push_back("-fvisibility-inlines-hidden");
+

takuto.ikuta wrote:
> hans wrote:
> > Huh, does this actually affect whether functions get dllexported or not?
> Sorry, what you want to ask?
> 
> This will used to not add dllexport attr in L5690 of SemaDeclCXX.cpp.
> 
Oops, I didn't see that. I'm glad to see this is looking so simple :-)

Actually, I don't think we should the same flag name for this, since "hidden" 
is an ELF concept, not a COFF one, just that we should match the behaviour of 
the flag.

Hmm, or do people use -fvisibility-inlines-hidden on MinGW or something? Where 
does the hidden-dllimport.cpp file come from?

Also, is it the case that -fvisibility-inlines-hidden just ignores the problem 
of static local variables? If that's the case we can probably do it too, we 
just have to be sure, and document it eventually.



https://reviews.llvm.org/D51340



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 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.

Thanks! LGTM




Comment at: lib/Parse/ParseExprCXX.cpp:1687
 if (Tok.isNot(tok::r_paren)) {
-  if (ParseExpressionList(Exprs, CommaLocs, [&] {
-QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
-getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
-DS.getEndLoc(), Exprs, T.getOpenLocation());
-Actions.CodeCompleteExpression(getCurScope(), PreferredType);
-  })) {
+  auto Completer = [&]() {
+QualType PreferredType = Actions.ProduceConstructorSignatureHelp(

NIT: inline this last completer.


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@hans I want to target precisely a given CPU when using `clang-cl`. The options 
in the `m_x86_Features_Group` are too granular. It is easier to just add 
`-march=skylake` on the cmd-line. Is there any other way?


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

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

- One last completer


Repository:
  rC Clang

https://reviews.llvm.org/D51038

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/function-overloads.cpp
  test/Index/complete-block-property-assignment.m

Index: test/Index/complete-block-property-assignment.m
===
--- test/Index/complete-block-property-assignment.m
+++ test/Index/complete-block-property-assignment.m
@@ -60,13 +60,20 @@
 // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s
-// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
+// CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1)
 @end
Index: test/CodeCompletion/function-overloads.cpp
===
--- /dev/null
+++ test/CodeCompletion/function-overloads.cpp
@@ -0,0 +1,27 @@
+int f(int i, int j = 2, int k = 5);
+int f(float x, float y...);
+
+class A {
+ public:
+  A(int, int, int);
+};
+
+void test() {
+  A a(f(1, 2, 3, 4), 2, 3);
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
+// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
+// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
+// CHECK-CC2: OVERLOAD: [#int#]f(float x, float y)
+// CHECK-CC2-NOT: OVERLOAD: [#int#]f(int i)
+// CHECK-CC3: OVERLOAD: A(<#int#>, int, int)
+// CHECK-CC3: OVERLOAD: A(<#const A &#>)
+// CHECK-CC3: OVERLOAD: A(<#A &&#>)
+// CHECK-CC4: OVERLOAD: A(int, <#int#>, int)
Index: lib/Sema/CodeCompleteConsumer.cpp
===
--- lib/Sema/CodeCompleteConsumer.cpp
+++ lib/Sema/CodeCompleteConsumer.cpp
@@ -619,6 +619,10 @@
   OS << "<#" << C.Text << "#>";
   break;
 
+// FIXME: We can also print optional parameters of an overload.
+case CodeCompletionString::CK_Optional:
+  break;
+
 default: OS << C.Text; break;
 }
   }
Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -422,8 +422,15 @@
   getCurScope(),
   OmpPrivParm->getType()->getCanonicalTypeInternal(),
   OmpPrivParm->getLocation(), Exprs, LParLoc);
+  CalledSignatureHelp = true;
   Actions.CodeCompleteExpression(getCurScope(), PreferredType);
 })) {
+  if (PP.isCodeCompletionReached() && !CalledSignatureHelp) {
+Actions.ProduceConstructorSignatureHelp(
+getCurScope(), OmpPrivParm->getType()->getCanonicalTypeInternal(),
+OmpPr

[PATCH] D51857: HIP: Remove reference to irif

2018-09-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added a reviewer: yaxunl.
Herald added a subscriber: wdng.

This is no longer separately installed.


https://reviews.llvm.org/D51857

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-device-libs.hip


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,7 +21,7 @@
 
 
 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}irif.amdgcn.bc"
+// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -82,7 +82,7 @@
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";
 
 BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,7 +21,7 @@
 
 
 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}irif.amdgcn.bc"
+// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -82,7 +82,7 @@
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";
 
 BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51807: Remove all uses of DIFlagBlockByrefStruct from Clang

2018-09-10 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision as: JDevlieghere.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks Adrian, LGTM!


https://reviews.llvm.org/D51807



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


[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> I also agree with you regarding options. A pattern I've observed (in some 
> infamous large codebase ;) is that warnings for deprecated symbols are 
> disabled in the compile command as they can introduce too much noise during 
> build, although it would make sense to show these warnings when user edits 
> the code (most of the time). I think there can be other diagnostics that are 
> more desirable as editor diagnostics than as compiler warnings/errors.

What kind of option are we talking about? (1) A flag to clangd or (2) a 
completely different way to expose deprecated methods (i.e. **not** 
diagnostics)?
If (1),  users already have a way to enable this by adding this flag when 
producing `compile_commands.json`. Not sure if adding a flag to clangd for 
tampering with one special-cased clang arg carries its weight, however produces 
`compile_commands.json` can set the flags they care about.
(2) does seem useful and https://reviews.llvm.org/D51724 is a good example of 
it.  As we have discussed recently, we could expose this as a form of semantic 
syntax highlighting (not available in clangd or LSP currently).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51747



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


r341824 - [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Sep 10 06:46:28 2018
New Revision: 341824

URL: http://llvm.org/viewvc/llvm-project?rev=341824&view=rev
Log:
[clang] Make sure codecompletion is called for calls even when inside a token.

Summary:
Currently CodeCompleteCall only gets called after a comma or parantheses. This
patch makes sure it is called even at the cases like:
```foo(1^);```

Reviewers: ilya-biryukov, ioeric, hokein

Reviewed By: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

Added:
cfe/trunk/test/CodeCompletion/function-overloads.cpp
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/test/Index/complete-block-property-assignment.m

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=341824&r1=341823&r2=341824&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Sep 10 06:46:28 2018
@@ -214,6 +214,11 @@ class Parser : public CodeCompletionHand
   /// should not be set directly.
   bool InMessageExpression;
 
+  /// Gets set to true after calling ProduceSignatureHelp, it is for a
+  /// workaround to make sure ProduceSignatureHelp is only called at the 
deepest
+  /// function call.
+  bool CalledSignatureHelp = false;
+
   /// The "depth" of the template parameters currently being parsed.
   unsigned TemplateParameterDepth;
 

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=341824&r1=341823&r2=341824&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Sep 10 06:46:28 2018
@@ -2305,6 +2305,7 @@ Decl *Parser::ParseDeclarationAfterDecla
   QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
   getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(),
   ThisDecl->getLocation(), Exprs, T.getOpenLocation());
+  CalledSignatureHelp = true;
   Actions.CodeCompleteExpression(getCurScope(), PreferredType);
 };
 if (ThisVarDecl) {
@@ -2317,6 +2318,12 @@ Decl *Parser::ParseDeclarationAfterDecla
 }
 
 if (ParseExpressionList(Exprs, CommaLocs, ExprListCompleter)) {
+  if (ThisVarDecl && PP.isCodeCompletionReached() && !CalledSignatureHelp) 
{
+Actions.ProduceConstructorSignatureHelp(
+getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(),
+ThisDecl->getLocation(), Exprs, T.getOpenLocation());
+CalledSignatureHelp = true;
+  }
   Actions.ActOnInitializerError(ThisDecl);
   SkipUntil(tok::r_paren, StopAtSemi);
 } else {

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=341824&r1=341823&r2=341824&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Sep 10 06:46:28 2018
@@ -1652,6 +1652,7 @@ Parser::ParsePostfixExpressionSuffix(Exp
   if (Tok.is(tok::code_completion)) {
 QualType PreferredType = Actions.ProduceCallSignatureHelp(
 getCurScope(), LHS.get(), None, PT.getOpenLocation());
+CalledSignatureHelp = true;
 Actions.CodeCompleteExpression(getCurScope(), PreferredType);
 cutOffParsing();
 return ExprError();
@@ -1662,9 +1663,19 @@ Parser::ParsePostfixExpressionSuffix(Exp
   if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
 QualType PreferredType = Actions.ProduceCallSignatureHelp(
 getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
+CalledSignatureHelp = true;
 Actions.CodeCompleteExpression(getCurScope(), PreferredType);
   })) {
 (void)Actions.CorrectDelayedTyposInExpr(LHS);
+// If we got an error when parsing expression list, we don't call
+// the CodeCompleteCall handler inside the parser. So call it here
+// to make sure we get overload suggestions even when we are in the
+// middle of a parameter.
+if (PP.isCodeCompletionReached() && !CalledSignatureHelp) {
+  Actions.ProduceCallSignatureHelp(getCurScope(), LHS.get(),
+   ArgExprs, PT.getOpenLocation());
+  CalledSignatureHelp = true;
+}
 LHS = ExprError();
   } else if (LHS.isInvalid()) {

[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Okay, that sounds good to me.

Please also add a test for this in test/Driver/cl-options.c in the "Accept 
"core" clang options" section.


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341824: [clang] Make sure codecompletion is called for calls 
even when inside a token. (authored by kadircet, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51038

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Parse/ParseOpenMP.cpp
  cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
  cfe/trunk/test/CodeCompletion/function-overloads.cpp
  cfe/trunk/test/Index/complete-block-property-assignment.m

Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -214,6 +214,11 @@
   /// should not be set directly.
   bool InMessageExpression;
 
+  /// Gets set to true after calling ProduceSignatureHelp, it is for a
+  /// workaround to make sure ProduceSignatureHelp is only called at the deepest
+  /// function call.
+  bool CalledSignatureHelp = false;
+
   /// The "depth" of the template parameters currently being parsed.
   unsigned TemplateParameterDepth;
 
Index: cfe/trunk/test/Index/complete-block-property-assignment.m
===
--- cfe/trunk/test/Index/complete-block-property-assignment.m
+++ cfe/trunk/test/Index/complete-block-property-assignment.m
@@ -60,13 +60,20 @@
 // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s
-// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s
 // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
+// CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1)
 @end
Index: cfe/trunk/test/CodeCompletion/function-overloads.cpp
===
--- cfe/trunk/test/CodeCompletion/function-overloads.cpp
+++ cfe/trunk/test/CodeCompletion/function-overloads.cpp
@@ -0,0 +1,27 @@
+int f(int i, int j = 2, int k = 5);
+int f(float x, float y...);
+
+class A {
+ public:
+  A(int, int, int);
+};
+
+void test() {
+  A a(f(1, 2, 3, 4), 2, 3);
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
+// CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
+// CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
+// CHECK-CC2: OVERLOAD: [#int#]f(float x, float y)
+// CHECK-CC2-NOT: OVERLOAD: [#int#]f(int i)
+// CHECK-CC3: OVERLOAD: A(<#int#>, int, int)
+// CHECK-CC3: OVERLOAD: A(<#const A &#>)
+// CHECK-CC3: OVERLOAD: A(<#A &&#>)
+// CHECK-CC4: OVERLOAD: A(int, <#int#>, int)
Index: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
===
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
@@ -619,6 +619,10 @@
 

[PATCH] D51488: [Sema][NFC] Small cleanup - remove dead code from ActOnCallExpr() ?

2018-09-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Sorry for the delay - I was busy with other things for past two weeks.




Comment at: Sema/SemaExpr.cpp:5338
 Context.DependentTy, VK_RValue, RParenLoc);
   } else {
 

JDevlieghere wrote:
> While you're at it you might as well remove the else branch here.
Sorry, I am not following. Do you mean just refactoring?

```
if a
  foo
else
  bar

```
->
```
if a
  foo

bar
```

Or do you really mean removing the else branch? I don't see how that would be 
NFC.


Repository:
  rC Clang

https://reviews.llvm.org/D51488



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


[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.

2018-09-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D51747#1227921, @ioeric wrote:

> In https://reviews.llvm.org/D51747#1227089, @ilya-biryukov wrote:
>
> > > ! In https://reviews.llvm.org/D51747#1227719, @kadircet wrote:
> > > 
> > >> ! In https://reviews.llvm.org/D51747#1227089, @ilya-biryukov wrote:
> > > 
> > > Not sure if it's fine to hijack our own diagnostic-specific flags in to 
> > > clang command args.
> > > 
> > > Cons that I see:
> > > 
> > > 1. There is no way for the users to turn them off if they find them 
> > > non-useful. If we add a way, it would be more config parameters which 
> > > overlap with other mechanism that we have - compiler flags.
> > > 2. Users who are used to having them as warnings will now see them as 
> > > notes. Again, no way to tweak this behavior.
> > > 
> > >   What's our use-case? Maybe we should ask the clients to add 
> > > -Wdeprecated if they care about those?
> > > 
> > >   PS In case I'm missing the context here, please let me know.
> >
> > Agree with you, I think it would be better to provide it as an option. 
> > https://reviews.llvm.org/D51724 with this one we added a way to show 
> > deprecated symbols on code completion responses and wanted to move forward 
> > with showing the ones that are already in existing code.
>
>
> I also agree with you regarding options. A pattern I've observed (in some 
> infamous large codebase ;) is that warnings for deprecated symbols are 
> disabled in the compile command as they can introduce too much noise during 
> build, although it would make sense to show these warnings when user edits 
> the code (most of the time). I think there can be other diagnostics that are 
> more desirable as editor diagnostics than as compiler warnings/errors.


So I'll be (somewhat) the naysayer regarding options. 
We still have to choose a default, and almost everyone will use it, including 
those who don't like it. So we still need the best possible default, and 
shouldn't let talk of options distract from this.
Most of the value of adding an option is: if someone complains, we can tell 
them to go away :-) One possible corollary is: we shouldn't add the option 
until someone complains. I'm not 100% sure about that, though - not totally 
opposed to an option here.

But if we add an option, we need to decide what the *other* option should be 
too, and this isn't obvious (should it be "suppress deprecation warnings" or 
"use compilation database as-is"?

My vote for default behavior would be: add -Wdeprecated, and if deprecation 
diagnostics are **errors**, downgrade them to warnings. (Or better add 
`-Wdeprecated -Wno-error=deprecated`).
But I'm biased by mostly using -Wno-deprecated -Werror codebases, if I didn't 
I'd probably prefer to just respect the compile-commands.

(I'm not a fan of the downgrade-to-note behavior: notes do not carry the 
connotation of "bad", and deprecation warnings can have notes attached 
themselves which is confusing).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51747



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


[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.

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



Comment at: clangd/ClangdServer.cpp:535
   // Inject the resource dir.
   // FIXME: Don't overwrite it if it's already there.
   C->CommandLine.push_back("-resource-dir=" + ResourceDir);

can you add a comment that these flags work with both gcc and clang-cl driver 
modes?
It seems to be true. This is an important invariant (I should add a test for 
it) that isn't obvious (there's no test today because we didn't know about 
clang-cl at the time)



Comment at: clangd/ClangdServer.cpp:537
   C->CommandLine.push_back("-resource-dir=" + ResourceDir);
+  C->CommandLine.push_back("-Wdeprecated-declarations");
   return std::move(*C);

as noted above I think we should also have -Wno-error=deprecated-declarations

(do you want all of -Wdeprecated, actually?)



Comment at: clangd/Diagnostics.cpp:299
+D.Severity =
+D.Category == "Deprecations" ? DiagnosticsEngine::Note : DiagLevel;
 return D;

not sure what the concrete benefits are from using Note rather than Warning. 
It's semantically iffy, so if we do this it should have a comment justifying it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51747



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


[PATCH] D51039: [clangd] Add unittests for D51038

2018-09-10 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:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51039



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


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 164666.
aganea added a comment.

Updated diff with coverage test as requested.


Repository:
  rC Clang

https://reviews.llvm.org/D51806

Files:
  include/clang/Driver/Options.td
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -610,6 +610,7 @@
 // RUN: -flto \
 // RUN: -fmerge-all-constants \
 // RUN: -no-canonical-prefixes \
+// RUN: -march=skylake \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, 
Group;
 def mwatchos_simulator_version_min_EQ : Joined<["-"], 
"mwatchos-simulator-version-min=">;
 def mwatchsimulator_version_min_EQ : Joined<["-"], 
"mwatchsimulator-version-min=">, Alias;
-def march_EQ : Joined<["-"], "march=">, Group;
+def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -610,6 +610,7 @@
 // RUN: -flto \
 // RUN: -fmerge-all-constants \
 // RUN: -no-canonical-prefixes \
+// RUN: -march=skylake \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1931,7 +1931,7 @@
 def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, Group;
 def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-version-min=">;
 def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias;
-def march_EQ : Joined<["-"], "march=">, Group;
+def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

2018-09-10 Thread Yvan Roux via cfe-commits
Hi Kirill,

This commit broke ARMV8 buildbots, logs are available here:
http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6493/steps/build%20stage%201/logs/stdio

Thanks
Yvan
On Mon, 10 Sep 2018 at 13:52, Kirill Bobyrev via Phabricator via
llvm-commits  wrote:
>
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL341802: [clangd] Implement FuzzyFindRequest JSON 
> (de)serialization (authored by omtcyfz, committed by ).
> Herald added a subscriber: llvm-commits.
>
> Changed prior to commit:
>   https://reviews.llvm.org/D51852?vs=164648&id=164655#toc
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D51852
>
> Files:
>   clang-tools-extra/trunk/clangd/CodeComplete.cpp
>   clang-tools-extra/trunk/clangd/index/Index.cpp
>   clang-tools-extra/trunk/clangd/index/Index.h
>
>
> Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
> ===
> --- clang-tools-extra/trunk/clangd/CodeComplete.cpp
> +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
> @@ -1381,8 +1381,7 @@
>  Req.Scopes = QueryScopes;
>  // FIXME: we should send multiple weighted paths here.
>  Req.ProximityPaths.push_back(FileName);
> -vlog("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])", Req.Query,
> - llvm::join(Req.Scopes.begin(), Req.Scopes.end(), ","));
> +vlog("Code complete: fuzzyFind({0:2})", toJSON(Req));
>
>  if (SpecFuzzyFind)
>SpecFuzzyFind->NewReq = Req;
> Index: clang-tools-extra/trunk/clangd/index/Index.h
> ===
> --- clang-tools-extra/trunk/clangd/index/Index.h
> +++ clang-tools-extra/trunk/clangd/index/Index.h
> @@ -19,8 +19,10 @@
>  #include "llvm/ADT/SmallVector.h"
>  #include "llvm/ADT/StringExtras.h"
>  #include "llvm/ADT/StringRef.h"
> +#include "llvm/Support/JSON.h"
>  #include "llvm/Support/StringSaver.h"
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -435,7 +437,7 @@
>std::vector Scopes;
>/// \brief The number of top candidates to return. The index may choose to
>/// return more than this, e.g. if it doesn't know which candidates are 
> best.
> -  size_t MaxCandidateCount = UINT_MAX;
> +  size_t MaxCandidateCount = std::numeric_limits::max();
>/// If set to true, only symbols for completion support will be considered.
>bool RestrictForCodeCompletion = false;
>/// Contextually relevant files (e.g. the file we're code-completing in).
> @@ -450,6 +452,8 @@
>}
>bool operator!=(const FuzzyFindRequest &Req) const { return !(*this == 
> Req); }
>  };
> +bool fromJSON(const llvm::json::Value &Value, FuzzyFindRequest &Request);
> +llvm::json::Value toJSON(const FuzzyFindRequest &Request);
>
>  struct LookupRequest {
>llvm::DenseSet IDs;
> Index: clang-tools-extra/trunk/clangd/index/Index.cpp
> ===
> --- clang-tools-extra/trunk/clangd/index/Index.cpp
> +++ clang-tools-extra/trunk/clangd/index/Index.cpp
> @@ -175,6 +175,33 @@
>return Index;
>  }
>
> +bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest 
> &Request) {
> +  json::ObjectMapper O(Parameters);
> +  llvm::Optional MaxCandidateCount;
> +  bool OK =
> +  O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) 
> &&
> +  O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) 
> &&
> +  O.map("ProximityPaths", Request.ProximityPaths) &&
> +  O.map("MaxCandidateCount", MaxCandidateCount);
> +  if (MaxCandidateCount)
> +Request.MaxCandidateCount = MaxCandidateCount.getValue();
> +  return OK;
> +}
> +
> +llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
> +  auto Result = json::Object{
> +  {"Query", Request.Query},
> +  {"Scopes", json::Array{Request.Scopes}},
> +  {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
> +  {"ProximityPaths", json::Array{Request.ProximityPaths}},
> +  };
> +  // A huge limit means no limit, leave it out.
> +  if (Request.MaxCandidateCount <= std::numeric_limits::max())
> +Result["MaxCandidateCount"] =
> +static_cast(Request.MaxCandidateCount);
> +  return Result;
> +}
> +
>  bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,
>llvm::function_ref CB) const 
> {
>return snapshot()->fuzzyFind(R, CB);
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

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



Comment at: clang-tidy/utils/ExprMutationAnalyzer.h:38
+  const Stmt *findDeclMutation(ArrayRef Matches);
+  const Stmt *findDeclMutation(const Decl *Dec);
+

lebedev.ri wrote:
> lebedev.ri wrote:
> > @shuaiwang, @JonasToth hi.
> > Is it very intentional that this `findDeclMutation()` is private?
> > 
> > Is there some other way i should be doing if i have a statement `S`,
> > a declRefExpr `D`, and i want to find the statement `Q`, which mutates
> > the underlying variable to which the declRefExpr `D` refers?
> (the statement `Q` within the statement `S`, of course)
@shuaiwang after a disscussion about this in IRC with @JonasToth, i have filed 
https://bugs.llvm.org/show_bug.cgi?id=3
But i'm failing to CC you there. Are you not registered in the bugzilla?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679



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


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[clang-tools-extra] r341830 - [clangd] Add unittests for D51038

2018-09-10 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Sep 10 07:22:42 2018
New Revision: 341830

URL: http://llvm.org/viewvc/llvm-project?rev=341830&view=rev
Log:
[clangd] Add unittests for D51038

Reviewers: ilya-biryukov, ioeric, hokein

Reviewed By: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

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

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=341830&r1=341829&r2=341830&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Mon Sep 10 
07:22:42 2018
@@ -1917,6 +1917,56 @@ TEST(CompletionTest, DeprecatedResults)
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, InsideArgument) {
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1+^); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1^); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1^0); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int bar(int x, int y);
+  int main() { bar(foo(2, 3^)); }
+)cpp");
+EXPECT_THAT(Results.signatures, ElementsAre(Sig("foo(int x, int y) -> 
void",
+{"int x", "int y"})));
+EXPECT_EQ(1, Results.activeParameter);
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@hans Just an after thought: maybe we should prevent usage of `-march=` and 
`/arch:` at the same time. What do you think? I can add another patch for that 
purpose.


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[PATCH] D51039: [clangd] Add unittests for D51038

2018-09-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341830: [clangd] Add unittests for D51038 (authored by 
kadircet, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51039?vs=163968&id=164668#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51039

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


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1917,6 +1917,56 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, InsideArgument) {
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1+^); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1^); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1^0); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int bar(int x, int y);
+  int main() { bar(foo(2, 3^)); }
+)cpp");
+EXPECT_THAT(Results.signatures, ElementsAre(Sig("foo(int x, int y) -> 
void",
+{"int x", "int y"})));
+EXPECT_EQ(1, Results.activeParameter);
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1917,6 +1917,56 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, InsideArgument) {
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1+^); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1^); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int main() { foo(1^0); }
+)cpp");
+EXPECT_THAT(
+Results.signatures,
+ElementsAre(Sig("foo(int x) -> void", {"int x"}),
+Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+EXPECT_EQ(0, Results.activeParameter);
+  }
+  {
+const auto Results = signatures(R"cpp(
+  void foo(int x);
+  void foo(int x, int y);
+  int bar(int x, int y);
+  int main() { bar(foo(2, 3^)); }
+)cpp");
+EXPECT_THAT(Results.signatures, ElementsAre(Sig("foo(int x, int y) -> void",
+{"int x", "int y"})));
+EXPECT_EQ(1, Results.activeParameter);
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r341832 - [clangd] Unbreak buildbots after r341802

2018-09-10 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 10 07:31:38 2018
New Revision: 341832

URL: http://llvm.org/viewvc/llvm-project?rev=341832&view=rev
Log:
[clangd] Unbreak buildbots after r341802

Solution: use std::move when returning result from toJSON(...).

Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=341832&r1=341831&r2=341832&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Mon Sep 10 07:31:38 2018
@@ -199,7 +199,7 @@ llvm::json::Value toJSON(const FuzzyFind
   if (Request.MaxCandidateCount <= std::numeric_limits::max())
 Result["MaxCandidateCount"] =
 static_cast(Request.MaxCandidateCount);
-  return Result;
+  return std::move(Result);
 }
 
 bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,


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


r341833 - Prevent cpu-specific/cpu-dispatch from giong on a lambda.

2018-09-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Sep 10 07:31:56 2018
New Revision: 341833

URL: http://llvm.org/viewvc/llvm-project?rev=341833&view=rev
Log:
Prevent cpu-specific/cpu-dispatch from giong on a lambda.

It is non-sensical to use cpu-specific/cpu-dispatch multiversioning
on a lambda, so prevent it when trying to add the attribute.

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=341833&r1=341832&r2=341833&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Sep 10 07:31:56 2018
@@ -1842,6 +1842,14 @@ static void handleRestrictAttr(Sema &S,
 
 static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   FunctionDecl *FD = cast(D);
+
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->getParent()->isLambda()) {
+  S.Diag(AL.getLoc(), diag::err_attribute_dll_lambda) << AL;
+  return;
+}
+  }
+
   if (!checkAttributeAtLeastNumArgs(S, AL, 1))
 return;
 

Modified: cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp?rev=341833&r1=341832&r2=341833&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp Mon Sep 10 07:31:56 2018
@@ -109,3 +109,6 @@ int __attribute__((cpu_specific(sandybri
 
 // Ensure Cpp Spelling works.
 [[clang::cpu_specific(ivybridge,atom)]] int CppSpelling(){}
+
+// expected-error@+1 {{lambda cannot be declared 'cpu_dispatch'}}
+auto x = []() __attribute__((cpu_dispatch(atom))) {};


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


[PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D51806#1228893, @aganea wrote:

> @hans Just an after thought: maybe we should prevent usage of `-march=` and 
> `/arch:` at the same time. What do you think? I can add another patch for 
> that purpose.


Hmm, yes, at least we should warn or do something smart. Currently it doesn't 
look like they'd interact well together in x86::getX86TargetCPU


Repository:
  rC Clang

https://reviews.llvm.org/D51806



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


[PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

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

In https://reviews.llvm.org/D51852#1228883, @yroux wrote:

> Hi Kirill,
>
> This commit broke ARMV8 buildbots, logs are available here:
>  
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6493/steps/build%20stage%201/logs/stdio
>
> Thanks
> Yvan


Hi! Apologies for inconvenience, https://reviews.llvm.org/rL341832 should solve 
the issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D51852



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


[PATCH] D51488: [Sema][NFC] Small cleanup - remove dead code from ActOnCallExpr() ?

2018-09-10 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: Sema/SemaExpr.cpp:5338
 Context.DependentTy, VK_RValue, RParenLoc);
   } else {
 

jkorous wrote:
> JDevlieghere wrote:
> > While you're at it you might as well remove the else branch here.
> Sorry, I am not following. Do you mean just refactoring?
> 
> ```
> if a
>   foo
> else
>   bar
> 
> ```
> ->
> ```
> if a
>   foo
> 
> bar
> ```
> 
> Or do you really mean removing the else branch? I don't see how that would be 
> NFC.
Yup, that's what I meant. since we have a return anyway. 


Repository:
  rC Clang

https://reviews.llvm.org/D51488



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


Re: [PATCH] D51852: [clangd] Implement FuzzyFindRequest JSON (de)serialization

2018-09-10 Thread Yvan Roux via cfe-commits
On Mon, 10 Sep 2018 at 16:36, Kirill Bobyrev via Phabricator
 wrote:
>
> kbobyrev added a comment.
>
> In https://reviews.llvm.org/D51852#1228883, @yroux wrote:
>
> > Hi Kirill,
> >
> > This commit broke ARMV8 buildbots, logs are available here:
> >  
> > http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/6493/steps/build%20stage%201/logs/stdio
> >
> > Thanks
> > Yvan
>
>
> Hi! Apologies for inconvenience, https://reviews.llvm.org/rL341832 should 
> solve the issue.

build on his way, but the issue is fixed, Index.cpp compiles with a warning now:

[5/100] Building CXX object
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/index/Index.cpp.o
/home/buildslave/buildslave/clang-cmake-armv8-quick/llvm/tools/clang/tools/extra/clangd/index/Index.cpp:199:33:
warning: comparison of constant 9223372036854775807 with expression of
type 'const size_t' (aka 'const unsigned int') is always true
[-Wtautological-constant-out-of-range-compare]
  if (Request.MaxCandidateCount <= std::numeric_limits::max())
  ~ ^  ~~~
1 warning generated.

Thanks for the quick fix.


> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D51852
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.

2018-09-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> Most of the value of adding an option is: if someone complains, we can tell 
> them to go away :-) One possible corollary is: we shouldn't add the option 
> until someone complains. I'm not 100% sure about that, though - not totally 
> opposed to an option here.

Any thoughts on tampering with provided compile args in the first place? Is it 
fine for clangd to be opinionated about the warnings we choose to always show 
to the users?
E.g. I'm a big fan of various uninitialized warnings, but nevertheless don't 
think clangd should force them on everyone.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51747



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


[PATCH] D51847: Print correctly dependency paths on Windows

2018-09-10 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a subscriber: xbolva00.
zturner added a comment.

What prints this? How do you exercise this codepath?


https://reviews.llvm.org/D51847



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


[PATCH] D51832: [clang-tidy/checks] Update objc-property-declaration check to allow arbitrary acronyms and initialisms 🔧

2018-09-10 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

This is fine, but please update the comments (and docs?) to make it clear that 
we no longer enforce camelCase but allow aRBiTraRYcAsE now.




Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:28-31
 // For StandardProperty the naming style is 'lowerCamelCase'.
 // For CategoryProperty especially in categories of system class,
 // to avoid naming conflict, the suggested naming style is
 // 'abc_lowerCamelCase' (adding lowercase prefix followed by '_').

These comments are no longer accurate.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:73-74
+  //
+  // Disallow names of this form:
+  // LongString
   std::string StartMatcher = UsedInMatcher ? "::" : "^";

Just to be clear, this also allows things like aRbITRaRyCapS, right? We should 
comment that this is explicitly by design.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:113-115
   // the property name should be in Lower Camel Case like
   // 'lowerCamelCase'
+  unless(matchesName(validPropertyNameRegex(true

This comment is no longer accurate.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51832



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


[PATCH] D51544: [OpenCL] Split opencl-c.h header

2018-09-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D51544#1227336, @asavonic wrote:

> In https://reviews.llvm.org/D51544#1227313, @Anastasia wrote:
>
> > Currently the main header still contains everything, so the size of the PCH 
> > won't change.
>
>
> The idea is that we don't pre-compile the whole opencl-c.h, we split
>  it into several headers (3 of them are target independent) and
>  pre-compile them instead.
>
> With this approach, we can reuse target-independent PCHs (common,
>  fp16, fp64) and only duplicate target-specific PCHs if needed
>  (opencl-c-platform.h).
>
> The idea is basically:
>
> 1. Compile target-independent headers into modules:
>   - opencl-c-common.h -> opencl-c-common.pcm
>   - opencl-c-fp16.h -> opencl-c-fp16.pcm
>   - opencl-c-fp64.h -> opencl-c-fp64.pcm
> 2. Implicitly include opencl-c.h (plain header), which has the following 
> content:
>
>
>
>   #include "opencl-c-common.h"
>   #if cl_khr_fp16
>   #include "opencl-c-fp16.h"
>   #endif
>   #if cl_khr_fp64
>   #include "opencl-c-fp16.h"
>   #endif
>   #include "opencl-c-platform.h"
>   
>
> When compiler reaches an #include statement in opencl-c.h, it loads a
>  corresponding PCH. Headers that were not pre-compiled are included as
>  usual.


Ok, I see. It seems reasonable. I am not sure if `opencl-c-platform` is the 
right name, since it seems some of the bits are just version/extension 
dependent there and not the platform? But perhaps if you add some description 
with guidelines on what should be put in each header, it should be fine.


Repository:
  rC Clang

https://reviews.llvm.org/D51544



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


[PATCH] D51860: [clangd] NFC: Use uint32_t for FuzzyFindRequest limits

2018-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added reviewers: ioeric, sammccall.
kbobyrev added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.

https://reviews.llvm.org/D51860

Files:
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h


Index: clang-tools-extra/clangd/index/Index.h
===
--- clang-tools-extra/clangd/index/Index.h
+++ clang-tools-extra/clangd/index/Index.h
@@ -437,7 +437,7 @@
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = std::numeric_limits::max();
+  uint32_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
Index: clang-tools-extra/clangd/index/Index.cpp
===
--- clang-tools-extra/clangd/index/Index.cpp
+++ clang-tools-extra/clangd/index/Index.cpp
@@ -177,29 +177,25 @@
 
 bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request) {
   json::ObjectMapper O(Parameters);
-  llvm::Optional MaxCandidateCount;
+  int64_t MaxCandidateCount;
   bool OK =
   O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
+  O.map("MaxCandidateCount", MaxCandidateCount) &&
   O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
-  O.map("ProximityPaths", Request.ProximityPaths) &&
-  O.map("MaxCandidateCount", MaxCandidateCount);
-  if (MaxCandidateCount)
-Request.MaxCandidateCount = MaxCandidateCount.getValue();
+  O.map("ProximityPaths", Request.ProximityPaths);
+  if (OK)
+Request.MaxCandidateCount = MaxCandidateCount;
   return OK;
 }
 
 llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
-  auto Result = json::Object{
+  return json::Object{
   {"Query", Request.Query},
   {"Scopes", json::Array{Request.Scopes}},
+  {"MaxCandidateCount", Request.MaxCandidateCount},
   {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
   {"ProximityPaths", json::Array{Request.ProximityPaths}},
   };
-  // A huge limit means no limit, leave it out.
-  if (Request.MaxCandidateCount <= std::numeric_limits::max())
-Result["MaxCandidateCount"] =
-static_cast(Request.MaxCandidateCount);
-  return std::move(Result);
 }
 
 bool SwapIndex::fuzzyFind(const FuzzyFindRequest &R,


Index: clang-tools-extra/clangd/index/Index.h
===
--- clang-tools-extra/clangd/index/Index.h
+++ clang-tools-extra/clangd/index/Index.h
@@ -437,7 +437,7 @@
   std::vector Scopes;
   /// \brief The number of top candidates to return. The index may choose to
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = std::numeric_limits::max();
+  uint32_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.
   bool RestrictForCodeCompletion = false;
   /// Contextually relevant files (e.g. the file we're code-completing in).
Index: clang-tools-extra/clangd/index/Index.cpp
===
--- clang-tools-extra/clangd/index/Index.cpp
+++ clang-tools-extra/clangd/index/Index.cpp
@@ -177,29 +177,25 @@
 
 bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request) {
   json::ObjectMapper O(Parameters);
-  llvm::Optional MaxCandidateCount;
+  int64_t MaxCandidateCount;
   bool OK =
   O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
+  O.map("MaxCandidateCount", MaxCandidateCount) &&
   O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
-  O.map("ProximityPaths", Request.ProximityPaths) &&
-  O.map("MaxCandidateCount", MaxCandidateCount);
-  if (MaxCandidateCount)
-Request.MaxCandidateCount = MaxCandidateCount.getValue();
+  O.map("ProximityPaths", Request.ProximityPaths);
+  if (OK)
+Request.MaxCandidateCount = MaxCandidateCount;
   return OK;
 }
 
 llvm::json::Value toJSON(const FuzzyFindRequest &Request) {
-  auto Result = json::Object{
+  return json::Object{
   {"Query", Request.Query},
   {"Scopes", json::Array{Request.Scopes}},
+  {"MaxCandidateCount", Request.MaxCandidateCount},
   {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
   {"ProximityPaths", json::Array{Request.ProximityPaths}},
   };
-  // A huge limit means no limit, leave it out.
-  if (Request.MaxCandidateCount <= std::numeric_limits::max())
-Result["MaxCandidateCount"] =
-static_cast(Request.MaxCandid

[PATCH] D51860: [clangd] NFC: Use uint32_t for FuzzyFindRequest limits

2018-09-10 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-tools-extra/clangd/index/Index.cpp:186
+  O.map("ProximityPaths", Request.ProximityPaths);
+  if (OK)
+Request.MaxCandidateCount = MaxCandidateCount;

I think we should not set `Request.MaxCandidateCount` if `MaxCandidateCount` is 
greater than `std::numeric_limits::max()`?



Comment at: clang-tools-extra/clangd/index/Index.h:440
   /// return more than this, e.g. if it doesn't know which candidates are best.
-  size_t MaxCandidateCount = std::numeric_limits::max();
+  uint32_t MaxCandidateCount = std::numeric_limits::max();
   /// If set to true, only symbols for completion support will be considered.

Or use `unsigned`?


https://reviews.llvm.org/D51860



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


[PATCH] D51084: Implement -Watomic-implicit-seq-cst

2018-09-10 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: lib/Sema/SemaChecking.cpp:10974
+  if (E->IgnoreParenImpCasts()->getType()->isAtomicType())
+return;
   CheckImplicitConversion(S, E->IgnoreParenImpCasts(), S.Context.BoolTy, CC);

jfb wrote:
> rjmccall wrote:
> > Can you explain this one?
> It would produce duplicate warnings of `!`, `&&`, `||`, and condition for `? 
> :`. Bool-like conversion is a special case of implicit conversion, which we 
> already check elsewhere.
I see, makes sense.


Repository:
  rC Clang

https://reviews.llvm.org/D51084



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


[PATCH] D50246: [RISCV] Add support for computing sysroot for riscv32-unknown-elf

2018-09-10 Thread Kristina Brooks via Phabricator via cfe-commits
kristina reopened this revision.
kristina added a comment.
This revision is now accepted and ready to land.

Seems to be causing a test failure for someone (per comment in 
https://reviews.llvm.org/rL341655), reopened it for now.


Repository:
  rC Clang

https://reviews.llvm.org/D50246



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


Re: [PATCH] D51806: [clang-cl] Enable -march

2018-09-10 Thread Nico Weber via cfe-commits
On Mon, Sep 10, 2018 at 10:33 AM Hans Wennborg via Phabricator via
cfe-commits  wrote:

> hans added a comment.
>
> In https://reviews.llvm.org/D51806#1228893, @aganea wrote:
>
> > @hans Just an after thought: maybe we should prevent usage of `-march=`
> and `/arch:` at the same time. What do you think? I can add another patch
> for that purpose.
>
>
> Hmm, yes, at least we should warn or do something smart. Currently it
> doesn't look like they'd interact well together in x86::getX86TargetCPU
>

Wouldn't you get an "unused arg" for /arch if you use -march and /arch at
the same time?


>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D51806
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >