[PATCH] D50447: [clang-tidy] Omit cases where loop variable is not used in loop body in performance-for-range-copy.

2018-08-10 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339415: [clang-tidy] Omit cases where loop variable is not 
used in loop body in (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50447

Files:
  clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp


Index: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "ForRangeCopyCheck.h"
+#include "../utils/DeclRefExprUtils.h"
 #include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
@@ -79,15 +80,27 @@
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
-  .isMutated(&LoopVar))
-return false;
-  diag(LoopVar.getLocation(),
-   "loop variable is copied but only used as const reference; consider "
-   "making it a const reference")
-  << utils::fixit::changeVarDeclToConst(LoopVar)
-  << utils::fixit::changeVarDeclToReference(LoopVar, Context);
-  return true;
+  // We omit the case where the loop variable is not used in the loop body. 
E.g.
+  //
+  // for (auto _ : benchmark_state) {
+  // }
+  //
+  // Because the fix (changing to `const auto &`) will introduce an unused
+  // compiler warning which can't be suppressed.
+  // Since this case is very rare, it is safe to ignore it.
+  if (!utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar) &&
+  !utils::decl_ref_expr::allDeclRefExprs(LoopVar, *ForRange.getBody(),
+ Context)
+   .empty()) {
+diag(LoopVar.getLocation(),
+ "loop variable is copied but only used as const reference; consider "
+ "making it a const reference")
+<< utils::fixit::changeVarDeclToConst(LoopVar)
+<< utils::fixit::changeVarDeclToReference(LoopVar, Context);
+return true;
+  }
+  return false;
 }
 
 } // namespace performance
Index: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
@@ -260,3 +260,8 @@
 bool result = ConstOperatorInvokee != Mutable();
   }
 }
+
+void IgnoreLoopVariableNotUsedInLoopBody() {
+  for (auto _ : View>()) {
+  }
+}


Index: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ForRangeCopyCheck.h"
+#include "../utils/DeclRefExprUtils.h"
 #include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
@@ -79,15 +80,27 @@
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
-  .isMutated(&LoopVar))
-return false;
-  diag(LoopVar.getLocation(),
-   "loop variable is copied but only used as const reference; consider "
-   "making it a const reference")
-  << utils::fixit::changeVarDeclToConst(LoopVar)
-  << utils::fixit::changeVarDeclToReference(LoopVar, Context);
-  return true;
+  // We omit the case where the loop variable is not used in the loop body. E.g.
+  //
+  // for (auto _ : benchmark_state) {
+  // }
+  //
+  // Because the fix (changing to `const auto &`) will introduce an unused
+  // compiler warning which can't be suppressed.
+  // Since this case is very rare, it is safe to ignore it.
+  if (!utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar) &&
+  !utils::decl_ref_expr::allDeclRefExprs(LoopVar, *ForRange.getBody(),
+ Context)
+   .empty()) {
+diag(LoopVar.getLocation(),
+ "loop variable is copied but only used as const reference; consider "
+ "making it a const reference")
+<< utils::fixit::changeVarDeclToConst(LoopVar)
+   

[clang-tools-extra] r339415 - [clang-tidy] Omit cases where loop variable is not used in loop body in

2018-08-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Aug 10 01:25:51 2018
New Revision: 339415

URL: http://llvm.org/viewvc/llvm-project?rev=339415&view=rev
Log:
[clang-tidy] Omit cases where loop variable is not used in loop body in
performance-for-range-copy check.

Summary:
The upstream change r336737 make the check too smart to fix the case
where loop variable could be used as `const auto&`.

But for the case below, changing to `const auto _` will introduce
an unused complier warning.

```
for (auto _ : state) {
  // no references for _.
}
```

This patch omit this case, and it is safe to do it as the case is very rare.

Reviewers: ilya-biryukov, alexfh

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp?rev=339415&r1=339414&r2=339415&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp Fri 
Aug 10 01:25:51 2018
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "ForRangeCopyCheck.h"
+#include "../utils/DeclRefExprUtils.h"
 #include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
@@ -79,15 +80,27 @@ bool ForRangeCopyCheck::handleCopyIsOnly
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
-  .isMutated(&LoopVar))
-return false;
-  diag(LoopVar.getLocation(),
-   "loop variable is copied but only used as const reference; consider "
-   "making it a const reference")
-  << utils::fixit::changeVarDeclToConst(LoopVar)
-  << utils::fixit::changeVarDeclToReference(LoopVar, Context);
-  return true;
+  // We omit the case where the loop variable is not used in the loop body. 
E.g.
+  //
+  // for (auto _ : benchmark_state) {
+  // }
+  //
+  // Because the fix (changing to `const auto &`) will introduce an unused
+  // compiler warning which can't be suppressed.
+  // Since this case is very rare, it is safe to ignore it.
+  if (!utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar) &&
+  !utils::decl_ref_expr::allDeclRefExprs(LoopVar, *ForRange.getBody(),
+ Context)
+   .empty()) {
+diag(LoopVar.getLocation(),
+ "loop variable is copied but only used as const reference; consider "
+ "making it a const reference")
+<< utils::fixit::changeVarDeclToConst(LoopVar)
+<< utils::fixit::changeVarDeclToReference(LoopVar, Context);
+return true;
+  }
+  return false;
 }
 
 } // namespace performance

Modified: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp?rev=339415&r1=339414&r2=339415&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp Fri 
Aug 10 01:25:51 2018
@@ -260,3 +260,8 @@ void PositiveConstNonMemberOperatorInvok
 bool result = ConstOperatorInvokee != Mutable();
   }
 }
+
+void IgnoreLoopVariableNotUsedInLoopBody() {
+  for (auto _ : View>()) {
+  }
+}


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


[PATCH] D50447: [clang-tidy] Omit cases where loop variable is not used in loop body in performance-for-range-copy.

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

It seems this ended up silently being a catch-all, with no option to control 
this behavior, and i don't see any comments discussing this..


Repository:
  rL LLVM

https://reviews.llvm.org/D50447



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


[clang-tools-extra] r339416 - [clangd] Fix a "-Wdangling-else" compiler warning in the test.

2018-08-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Aug 10 01:34:16 2018
New Revision: 339416

URL: http://llvm.org/viewvc/llvm-project?rev=339416&view=rev
Log:
[clangd] Fix a "-Wdangling-else" compiler warning in the test.

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=339416&r1=339415&r2=339416&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Fri Aug 10 
01:34:16 2018
@@ -1393,8 +1393,9 @@ TEST(CompletionTest, FixItForArrowToDot)
   ReplacementEdit.newText = ".";
   for (const auto &C : Results.Completions) {
 EXPECT_TRUE(C.FixIts.size() == 1u || C.Name == "AuxFunction");
-if (!C.FixIts.empty())
+if (!C.FixIts.empty()) {
   EXPECT_THAT(C.FixIts, ElementsAre(ReplacementEdit));
+}
   }
 }
 


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


[PATCH] D50555: [clangd] Introduce scoring mechanism for SignatureInformations.

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

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50555

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

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1438,6 +1438,28 @@
   }
 }
 
+TEST(SignatureHelpTest, OverloadsOrdering) {
+  const auto Results = signatures(R"cpp(
+void foo(int x);
+void foo(int x, float y);
+void foo(float x, int y);
+void foo(float x, float y);
+void foo(int x, int y = 0);
+int main() { foo(^); }
+  )cpp");
+  EXPECT_THAT(
+  Results.signatures,
+  ElementsAre(
+  Sig("foo(int x) -> void", {"int x"}),
+  Sig("foo(int x, int y = 0) -> void", {"int x", "int y = 0"}),
+  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
+  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
+  Sig("foo(float x, float y) -> void", {"float x", "float y"})));
+  // We always prefer the first signature.
+  EXPECT_EQ(0, Results.activeSignature);
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/Quality.h
===
--- clangd/Quality.h
+++ clangd/Quality.h
@@ -163,6 +163,17 @@
 /// LSP. (The highest score compares smallest so it sorts at the top).
 std::string sortText(float Score, llvm::StringRef Tiebreak = "");
 
+struct SignatureQualitySignals {
+  uint32_t NumberOfParameters = 0;
+  uint32_t NumberOfOptionalParameters = 0;
+  bool ContainsActiveParameter = false;
+  CodeCompleteConsumer::OverloadCandidate::CandidateKind Kind;
+
+  float evaluate() const;
+};
+llvm::raw_ostream &operator<<(llvm::raw_ostream &,
+  const SignatureQualitySignals &);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/Quality.cpp
===
--- clangd/Quality.cpp
+++ clangd/Quality.cpp
@@ -401,5 +401,36 @@
   return S;
 }
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
+  const SignatureQualitySignals &S) {
+  OS << formatv("=== Signature Quality: {0}\n", S.evaluate());
+  OS << formatv("\tNumber of parameters: {0}\n", S.NumberOfParameters);
+  OS << formatv("\tNumber of optional parameters: {0}\n",
+S.NumberOfOptionalParameters);
+  OS << formatv("\tContains active parameter: {0}\n",
+S.ContainsActiveParameter);
+  OS << formatv("\tKind: {0}\n", S.Kind);
+  return OS;
+}
+
+float SignatureQualitySignals::evaluate() const {
+  using OC = CodeCompleteConsumer::OverloadCandidate;
+  float score = 1;
+  score /= NumberOfParameters + 1;
+  if (ContainsActiveParameter)
+score *= 10;
+  switch (Kind) {
+  case OC::CK_Function:
+score *= 10;
+break;
+  case OC::CK_FunctionType:
+score *= 5;
+break;
+  case OC::CK_FunctionTemplate:
+break;
+  }
+  return score;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -128,16 +128,16 @@
 /// Get the optional chunk as a string. This function is possibly recursive.
 ///
 /// The parameter info for each parameter is appended to the Parameters.
-std::string
-getOptionalParameters(const CodeCompletionString &CCS,
-  std::vector &Parameters) {
+std::string getOptionalParameters(const CodeCompletionString &CCS,
+  std::vector &Parameters,
+  SignatureQualitySignals &Signal) {
   std::string Result;
   for (const auto &Chunk : CCS) {
 switch (Chunk.Kind) {
 case CodeCompletionString::CK_Optional:
   assert(Chunk.Optional &&
  "Expected the optional code completion string to be non-null.");
-  Result += getOptionalParameters(*Chunk.Optional, Parameters);
+  Result += getOptionalParameters(*Chunk.Optional, Parameters, Signal);
   break;
 case CodeCompletionString::CK_VerticalSpace:
   break;
@@ -153,6 +153,8 @@
   ParameterInformation Info;
   Info.label = Chunk.Text;
   Parameters.push_back(std::move(Info));
+  Signal.ContainsActiveParameter = true;
+  Signal.NumberOfOptionalParameters++;
   break;
 }
 default:
@@ -679,6 +681,24 @@
   llvm::unique_function ResultsCallback;
 };
 
+using SignatureInformationScore = float;
+using ScoredSignature =
+std::pair;
+struct ScoredSignatureGreater {
+  bool operator()(const ScoredSignature &L, const ScoredSignature &R) {
+// Ordering follows:
+// - High score is

[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

Complete the tests, finish the implementation.

One thought about prefix match suggestion: we should either make it more 
explicit for the index (e.g. introduce `prefixMatch` and dispatch `fuzzyMatch` 
to prefix matching in case query only contains one "true" symbol) or document 
this properly. While, as I wrote earlier, I totally support the idea of prefix 
matching queries of length 1 it might not align with some user expectations and 
it's also very implicit if we just generate tokens this way and don't mention 
it anywhere in the `DexIndex` implementation.

@ioeric, @ilya-biryukov any thoughts?


https://reviews.llvm.org/D50517

Files:
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/index/dex/Trigram.h
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -250,45 +250,60 @@
 }
 
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
-  EXPECT_THAT(generateIdentifierTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateIdentifierTrigrams("X86"),
+  trigramsAre({"x86", "x$$", "x8$", "86$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({"nl$", "n$$"}));
+
+  EXPECT_THAT(generateIdentifierTrigrams("n"), trigramsAre({"n$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("clangd"),
-  trigramsAre({"cla", "lan", "ang", "ngd"}));
+  trigramsAre({"cla", "lan", "ang", "ngd", "an$", "c$$", "cl$",
+   "ng$", "gd$", "la$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("abc_def"),
-  trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def"}));
+  EXPECT_THAT(
+  generateIdentifierTrigrams("abc_def"),
+  trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def", "a$$",
+   "ab$", "ad$", "bc$", "bd$", "cd$", "de$", "ef$"}));
 
   EXPECT_THAT(
   generateIdentifierTrigrams("a_b_c_d_e_"),
-  trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"}));
+  trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde",
+   "a$$", "ab$", "ac$", "bc$", "bd$", "cd$", "ce$", "de$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("unique_ptr"),
-  trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", "iqp",
-   "ipt", "que", "qup", "qpt", "uep", "ept", "ptr"}));
+  EXPECT_THAT(generateIdentifierTrigrams("unique_ptr"),
+  trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu",
+   "iqp", "ipt", "que", "qup", "qpt", "uep", "ept",
+   "ptr", "u$$", "un$", "up$", "ni$", "np$", "iq$",
+   "ip$", "qu$", "qp$", "ue$", "ep$", "pt$", "tr$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("TUDecl"),
-  trigramsAre({"tud", "tde", "ude", "dec", "ecl"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("IsOK"),
-  trigramsAre({"iso", "iok", "sok"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("abc_defGhij__klm"),
-  trigramsAre({
-  "abc", "abd", "abg", "ade", "adg", "adk", "agh", "agk", "bcd",
-  "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde", "cdg", "cdk",
-  "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl", "efg",
-  "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
-  "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm",
-  }));
+  trigramsAre({"tud", "tde", "ude", "dec", "ecl", "t$$", "tu$",
+   "td$", "ud$", "de$", "ec$", "cl$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("IsOK"),
+  trigramsAre({"iso", "iok", "sok", "i$$", "is$", "io$", "so$", "ok$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("abc_defGhij__klm"),
+  trigramsAre({"a$$", "abc", "abd", "abg", "ade", "adg", "adk", "agh",
+   "agk", "bcd", "bcg", "bde", "bdg", "bdk", "bgh", "bgk",
+   "cde", "cdg", "cdk", "cgh", "cgk", "def", "deg", "dek",
+   "dgh", "dgk", "dkl", "efg", "efk", "egh", "egk", "ekl",
+   "fgh", "fgk", "fkl", "ghi", "ghk", "gkl", "hij", "hik",
+   "hkl", "ijk", "ikl", "jkl", "klm", "ab$", "ad$", "ag$",
+   "bc$", "bd$", "bg$", "cd$", "cg$", "de$", "dg$", "dk$",
+   "ef$", "eg$", "ek$", "fg$", "fk$", "gh$", "gk$", "hi$",
+   "hk$", "ij$", "ik$", "jk$", "kl$", "lm$"}));
 }
 
 TEST(DexIndexTrigrams, QueryTrigrams) {
-  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateQueryTrigrams("c"), trigr

[PATCH] D50500: [clangd] Allow consuming limited number of items

2018-08-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/unittests/clangd/DexIndexTests.cpp:252
+  auto DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100));
+

nit: maybe use the default parameter here?



Comment at: clang-tools-extra/unittests/clangd/DexIndexTests.cpp:260
+
+  auto Root = createAnd(createAnd(create(L1), create(L2)),
+createOr(create(L3), create(L4), create(L5)));

The AND iterator case doesn't seem to add more coverage. Maybe drop?


https://reviews.llvm.org/D50500



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


[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:24
+
+  Finder->addMatcher(
+  nestedNameSpecifierLoc(loc(specifiesNamespace(namespaceDecl(

Actually that one is generally useful. Accessing the `foo::internal` from 
outside of `foo` is always a problem. Maybe this matcher can become 
configurable or just match on any `internal` access from outside the enclosing 
namespace.



Comment at: clang-tidy/abseil/NoInternalDepsCheck.h:21
+/// against doing so.
+/// Should not run on internal Abseil files or Abseil source code.
+///

Please make this a full sentence, like `This check should not be run on 
internal ...` (if that is grammatically correct)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50542



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


[PATCH] D50447: [clang-tidy] Omit cases where loop variable is not used in loop body in performance-for-range-copy.

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

Do you think it is a bad idea? If the variable is not used it is ok to
ignore it in this particular circumstance. Other warnings/check should
deal with such a situation IMHO.

Am 10.08.2018 um 10:29 schrieb Roman Lebedev via Phabricator:

> lebedev.ri added a comment.
> 
> It seems this ended up silently being a catch-all, with no option to control 
> this behavior, and i don't see any comments discussing this..
> 
> Repository:
> 
>   rL LLVM
> 
> https://reviews.llvm.org/D50447


Repository:
  rL LLVM

https://reviews.llvm.org/D50447



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


[PATCH] D50449: [clangd] Support textEdit in addition to insertText.

2018-08-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 160073.
kadircet marked 5 inline comments as done.
kadircet added a comment.
Herald added a subscriber: mgrang.

- Resolve discussions.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50449

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/SourceCodeTests.cpp

Index: unittests/clangd/SourceCodeTests.cpp
===
--- unittests/clangd/SourceCodeTests.cpp
+++ unittests/clangd/SourceCodeTests.cpp
@@ -37,6 +37,13 @@
   return Pos;
 }
 
+Range range(const std::pair p1, const std::pair p2) {
+  Range range;
+  range.start = position(p1.first, p1.second);
+  range.end = position(p2.first, p2.second);
+  return range;
+}
+
 TEST(SourceCodeTests, PositionToOffset) {
   // line out of bounds
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(-1, 2)), Failed());
@@ -119,6 +126,14 @@
   EXPECT_THAT(offsetToPosition(File, 30), Pos(2, 9)) << "out of bounds";
 }
 
+TEST(SourceCodeTests, IsRangeConsecutive) {
+  EXPECT_TRUE(IsRangeConsecutive(range({2, 2}, {2, 3}), range({2, 3}, {2, 4})));
+  EXPECT_FALSE(
+  IsRangeConsecutive(range({0, 2}, {0, 3}), range({2, 3}, {2, 4})));
+  EXPECT_FALSE(
+  IsRangeConsecutive(range({2, 2}, {2, 3}), range({2, 4}, {2, 5})));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1438,6 +1438,82 @@
   }
 }
 
+TEST(CompletionTest, RenderWithFixItMerged) {
+  TextEdit FixIt;
+  FixIt.range.end.character = 5;
+  FixIt.newText = "->";
+
+  CodeCompletion C;
+  C.Name = "x";
+  C.RequiredQualifier = "Foo::";
+  C.FixIts = {FixIt};
+  C.CompletionTokenRange.start.character = 5;
+
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+
+  auto R = C.render(Opts);
+  EXPECT_TRUE(R.textEdit);
+  EXPECT_EQ(R.textEdit->newText, "->Foo::x");
+  EXPECT_TRUE(R.additionalTextEdits.empty());
+}
+
+TEST(CompletionTest, RenderWithFixItNonMerged) {
+  TextEdit FixIt;
+  FixIt.range.end.character = 4;
+  FixIt.newText = "->";
+
+  CodeCompletion C;
+  C.Name = "x";
+  C.RequiredQualifier = "Foo::";
+  C.FixIts = {FixIt};
+  C.CompletionTokenRange.start.character = 5;
+
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+
+  auto R = C.render(Opts);
+  EXPECT_TRUE(R.textEdit);
+  EXPECT_EQ(R.textEdit->newText, "Foo::x");
+  EXPECT_THAT(R.additionalTextEdits, UnorderedElementsAre(FixIt));
+}
+
+TEST(CompletionTest, CompletionTokenRange) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  constexpr const char *TestCodes[] = {
+  R"cpp(
+class Auxilary {
+ public:
+  void AuxFunction();
+};
+void f() {
+  Auxilary x;
+  x.[[Aux]]^;
+}
+  )cpp",
+  R"cpp(
+class Auxilary {
+ public:
+  void AuxFunction();
+};
+void f() {
+  Auxilary x;
+  x.[[]]^;
+}
+  )cpp"};
+  for (const auto &Text : TestCodes) {
+Annotations TestCode(Text);
+auto Results = completions(Server, TestCode.code(), TestCode.point());
+
+EXPECT_EQ(Results.Completions.size(), 1u);
+EXPECT_THAT(Results.Completions.front().CompletionTokenRange, TestCode.range());
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -69,6 +69,7 @@
 TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
 const LangOptions &L);
 
+bool IsRangeConsecutive(const Range &Left, const Range &Right);
 } // namespace clangd
 } // namespace clang
 #endif
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp
+++ clangd/SourceCode.cpp
@@ -208,5 +208,10 @@
   return Result;
 }
 
+bool IsRangeConsecutive(const Range &Left, const Range &Right) {
+  return Left.end.line == Right.start.line &&
+ Left.end.character == Right.start.character;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -123,6 +123,9 @@
   /// converting '->' to '.' on member access.
   std::vector FixIts;
 
+  /// Holds the range of the token we are going to replace with this completion.
+  Range CompletionTokenRange;
+
   // Scores are used to rank completion items.
   struct Scores {
 // The score that items are ranked by.
Index: clangd/CodeComplete.cpp
===

[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/DurationDivisionCheck.cpp:32
+  hasImplicitDestinationType(qualType(unless(isInteger(,
+  unless(hasParent(cxxStaticCastExpr(,
+  this);

deannagarcia wrote:
> JonasToth wrote:
> > What about different kinds of casts, like C-Style casts?
> > Doesn't the `hasImplicitDestinationType` already remove the possibility for 
> > an cast as destination?
> I know the test fails without this line and flags the casts, so I'm pretty 
> sure it's necessary but I'm not exactly sure why hasImplicitDestinationType 
> doesn't catch it.
Ok. I can not help there. Just leave as is :)



Comment at: docs/clang-tidy/checks/abseil-duration-division.rst:8
+division of two `absl::Duration` objects returns an `int64` with any fractional
+component truncated toward 0.
+

deannagarcia wrote:
> JonasToth wrote:
> > Please add one more sentence, why this is something you don't want, so it 
> > gets clear that floating point contextes are the interesting here.
> Does this link work or do you still want more?
Link is enough!


https://reviews.llvm.org/D50389



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


[PATCH] D50449: [clangd] Support textEdit in addition to insertText.

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



Comment at: clangd/CodeComplete.cpp:1310
+  // other.
+  for (const auto &FixIt : FixIts) {
+if (IsRangeConsecutive(FixIt.range, LSP.textEdit->range)) {

ilya-biryukov wrote:
> Maybe keep the `reserve` call? (we could reserve one extra element, but 
> that's fine)
Actually we could have much more than one extra element, not for the current 
situation but may be in the future when we have more fixit completions.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50449



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

2018-08-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

As discussed offline with @ilya-biryukov, the better approach would be to 
prefix match first symbols of each distinct identifier piece instead of prefix 
matching (just looking at the first letter of the identifier) the whole 
identifier.

Example:

- Query: `"u"`
- Symbols: `"unique_ptr"`, `"user"`, `"super_user"`

Current implementation would match `"unique_ptr"` and `"user"` only.
Proposed implementation would match all three symbols, because the second piece 
of `"super_user"` starts with `u`.

This might be useful for codebases where e.g. each identifier starts with some 
project prefix (`ProjectInstruction`, `ProjectGraph`, etc). For C++, it's 
better to use namespaces instead of this naming which is not really great, but 
I am aware of the C++ projects which actually opt for such naming convention. 
However, in pure C this relatively common practice, e.g. a typical piece of 
code for GNOME might be

GtkOrientationorientation;
GtkWrapAllocationMode mode;
  
GtkWrapBoxSpreading   horizontal_spreading;
GtkWrapBoxSpreading   vertical_spreading;
  
guint16   vertical_spacing;
guint16   horizontal_spacing;
  
guint16   minimum_line_children;
guint16   natural_line_children;
  
GList*children;
  };

Also, this is better for macros, which can not be put into namespaces anyway 
and there's `BENCHMARK_UNREACHABLE` and so on.

I'll update the patch with the proposed solution.


https://reviews.llvm.org/D50517



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

Thanks for the patch!

In https://reviews.llvm.org/D50517#1194955, @kbobyrev wrote:

> Complete the tests, finish the implementation.
>
> One thought about prefix match suggestion: we should either make it more 
> explicit for the index (e.g. introduce `prefixMatch` and dispatch 
> `fuzzyMatch` to prefix matching in case query only contains one "true" 
> symbol) or document this properly. While, as I wrote earlier, I totally 
> support the idea of prefix matching queries of length 1 it might not align 
> with some user expectations and it's also very implicit if we just generate 
> tokens this way and don't mention it anywhere in the `DexIndex` 
> implementation.
>
> @ioeric, @ilya-biryukov any thoughts?


(copied my inline comment :)
We should definitely add documentation about it. It should be pretty simple 
IMO. As the behavior should be easy to infer from samples, and it shouldn't be 
too surprising for users, I think it would be OK to consider it as 
implementation detail (like details in how exactly trigrams are generated) 
without exposing new interfaces for them.




Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:26
 
-// FIXME(kbobyrev): Deal with short symbol symbol names. A viable approach 
would
-// be generating unigrams and bigrams here, too. This would prevent symbol 
index
-// from applying fuzzy matching on a tremendous number of symbols and allow
-// supplementary retrieval for short queries.
-//
-// Short names (total segment length <3 characters) are currently ignored.
+// FIXME(kbobyrev): Posting lists for incomplete trigrams (one/two symbols) are
+// likely to be very dense and hence require special attention so that the 
index

It's a nice to optimization have when we run into oversized posting lists, but 
this is not necessarily restricted to unigram posting lists. I think the FIXME 
should live near the general posting list code. I think it's probably also ok 
to leave it out; it's hard to forget if we do run into problem in the future ;)



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:74
+// symbol of the identifier.
+if (!FoundFirstSymbol) {
+  FoundFirstSymbol = true;

Could this be pulled out of the loop? I think what we want is just 
`LowercaseIdentifier[0]` right?

I'd probably also pulled that into a function, as the function body is getting 
larger.



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:87
+
+  Chars = {{LowercaseIdentifier[I], LowercaseIdentifier[J], END_MARKER, 
0}};
+  const auto Bigram = Token(Token::Kind::Trigram, Chars.data());

I think we could be more restrictive on bigram generation. I think a bigram 
prefix of identifier and a bigram prefix of the HEAD substring should work 
pretty well in practice. For example, for `StringStartsWith`, you would have 
`st$` and `ss$` (prefix of "SSW").

WDYT?



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:115
+// FIXME(kbobyrev): Correctly handle empty trigrams "$$$".
 std::vector generateQueryTrigrams(llvm::StringRef Query) {
   // Apply fuzzy matching text segmentation.

It seems to me that what we need for short queries is simply:
```
if (Query.empty()) {
   // return empty token
}
if (Query.size() == 1) return {Query + "$$"};
if (Query.size() == 2) return {Query + "$"};

// Longer queries...
```
?



Comment at: clang-tools-extra/clangd/index/dex/Trigram.h:39
+// member of Token even though it's Trigram-specific?
+const auto END_MARKER = '$';
+

Any reason why this should be exposed?



Comment at: clang-tools-extra/clangd/index/dex/Trigram.h:62
 /// belongs to more than one class it is only inserted once.
+// FIXME(kbobyrev): Document somewhere in DexIndex that for queries of size 1
+// it will do prefix matching instead of fuzzy matching on the identifier 
names,

The behavior should be easy to infer from samples. As long as it's not totally 
expected, I think it would be OK to consider treat as implementation detail 
(like details in how trigrams are generated).



Comment at: clang-tools-extra/clangd/index/dex/Trigram.h:74
+/// For short queries (Query contains less than 3 letters and digits) this
+/// returns a single trigram with all valid symbols.
 std::vector generateQueryTrigrams(llvm::StringRef Query);

I'm not quite sure what this means. Could you elaborate?


https://reviews.llvm.org/D50517



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

@ilya-biryukov I have changed the approach to the one we discussed before.


https://reviews.llvm.org/D50517

Files:
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/index/dex/Trigram.h
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -250,45 +250,61 @@
 }
 
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
-  EXPECT_THAT(generateIdentifierTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateIdentifierTrigrams("X86"),
+  trigramsAre({"x86", "x$$", "x8$", "86$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({"nl$", "n$$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("clangd"),
-  trigramsAre({"cla", "lan", "ang", "ngd"}));
+  EXPECT_THAT(generateIdentifierTrigrams("n"), trigramsAre({"n$$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("abc_def"),
-  trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def"}));
+  EXPECT_THAT(generateIdentifierTrigrams("clangd"),
+  trigramsAre({"cla", "lan", "ang", "ngd", "an$", "c$$", "cl$",
+   "ng$", "gd$", "la$"}));
 
   EXPECT_THAT(
-  generateIdentifierTrigrams("a_b_c_d_e_"),
-  trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"}));
+  generateIdentifierTrigrams("abc_def"),
+  trigramsAre({"a$$", "d$$", "abc", "abd", "ade", "bcd", "bde", "cde",
+   "def", "ab$", "ad$", "bc$", "bd$", "cd$", "de$", "ef$"}));
+
+  EXPECT_THAT(generateIdentifierTrigrams("a_b_c_d_e_"),
+  trigramsAre({"a$$", "b$$", "c$$", "d$$", "e$$", "abc", "abd",
+   "acd", "ace", "bcd", "bce", "bde", "cde", "ab$",
+   "ac$", "bc$", "bd$", "cd$", "ce$", "de$"}));
 
   EXPECT_THAT(
   generateIdentifierTrigrams("unique_ptr"),
-  trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", "iqp",
-   "ipt", "que", "qup", "qpt", "uep", "ept", "ptr"}));
+  trigramsAre({"u$$", "p$$", "uni", "unp", "upt", "niq", "nip", "npt",
+   "iqu", "iqp", "ipt", "que", "qup", "qpt", "uep", "ept",
+   "ptr", "un$", "up$", "ni$", "np$", "iq$", "ip$", "qu$",
+   "qp$", "ue$", "ep$", "pt$", "tr$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("TUDecl"),
-  trigramsAre({"tud", "tde", "ude", "dec", "ecl"}));
+  trigramsAre({"t$$", "d$$", "tud", "tde", "ude", "dec", "ecl",
+   "tu$", "td$", "ud$", "de$", "ec$", "cl$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("IsOK"),
-  trigramsAre({"iso", "iok", "sok"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("abc_defGhij__klm"),
-  trigramsAre({
-  "abc", "abd", "abg", "ade", "adg", "adk", "agh", "agk", "bcd",
-  "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde", "cdg", "cdk",
-  "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl", "efg",
-  "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
-  "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm",
-  }));
+  trigramsAre({"i$$", "o$$", "iso", "iok", "sok", "is$", "io$",
+   "so$", "ok$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("abc_defGhij__klm"),
+  trigramsAre(
+  {"a$$", "d$$", "g$$", "k$$", "abc", "abd", "abg", "ade", "adg", "adk",
+   "agh", "agk", "bcd", "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde",
+   "cdg", "cdk", "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl",
+   "efg", "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
+   "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm", "ab$", "ad$",
+   "ag$", "bc$", "bd$", "bg$", "cd$", "cg$", "de$", "dg$", "dk$", "ef$",
+   "eg$", "ek$", "fg$", "fk$", "gh$", "gk$", "hi$", "hk$", "ij$", "ik$",
+   "jk$", "kl$", "lm$"}));
 }
 
 TEST(DexIndexTrigrams, QueryTrigrams) {
-  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateQueryTrigrams("c"), trigramsAre({"c$$"}));
+  EXPECT_THAT(generateQueryTrigrams("cl"), trigramsAre({"cl$"}));
+  EXPECT_THAT(generateQueryTrigrams("cla"), trigramsAre({"cla"}));
 
-  EXPECT_THAT(generateQueryTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
 
   EXPECT_THAT(generateQueryTrigrams("clangd"),
   trigramsAre({"cla", "lan", "ang", "ngd"}));
Index: clang-tools-extra/clangd/index/dex/Trigram.h

[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

In https://reviews.llvm.org/D50517#1194976, @kbobyrev wrote:

> As discussed offline with @ilya-biryukov, the better approach would be to 
> prefix match first symbols of each distinct identifier piece instead of 
> prefix matching (just looking at the first letter of the identifier) the 
> whole identifier.
>
> Example:
>
> - Query: `"u"`
> - Symbols: `"unique_ptr"`, `"user"`, `"super_user"`
>
>   Current implementation would match `"unique_ptr"` and `"user"` only. 
> Proposed implementation would match all three symbols, because the second 
> piece of `"super_user"` starts with `u`.


I agree that this can be useful sometime, but I suspect it's relatively rare 
and might actually compromise ranking quality for the more common use case e.g. 
the first character users type is the first character of the expected 
identifier.


https://reviews.llvm.org/D50517



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

In https://reviews.llvm.org/D50517#1194976, @kbobyrev wrote:

> As discussed offline with @ilya-biryukov, the better approach would be to 
> prefix match first symbols of each distinct identifier piece instead of 
> prefix matching (just looking at the first letter of the identifier) the 
> whole identifier.
>
> Example:
>
> - Query: `"u"`
> - Symbols: `"unique_ptr"`, `"user"`, `"super_user"`
>
>   Current implementation would match `"unique_ptr"` and `"user"` only. 
> Proposed implementation would match all three symbols, because the second 
> piece of `"super_user"` starts with `u`.


And in the case where users want to match `super_user`, I think it's reasonable 
to have users type two more characters and match it with `use`.


https://reviews.llvm.org/D50517



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


r339420 - clang-cl: Support /guard:cf,nochecks

2018-08-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug 10 02:49:21 2018
New Revision: 339420

URL: http://llvm.org/viewvc/llvm-project?rev=339420&view=rev
Log:
clang-cl: Support /guard:cf,nochecks

This extension emits the guard cf table without inserting the
instrumentation. Currently that's what clang-cl does with /guard:cf
anyway, but this allows a user to request that explicitly.

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

Added:
cfe/trunk/test/CodeGen/cfguardtable.c
Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=339420&r1=339419&r2=339420&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Aug 10 02:49:21 2018
@@ -240,8 +240,8 @@ def _SLASH_Fi : CLCompileJoined<"Fi">,
 def _SLASH_Fo : CLCompileJoined<"Fo">,
   HelpText<"Set output object file, or directory (ends in / or \\) (with /c)">,
   MetaVarName<"">;
-def _SLASH_Guard : CLJoined<"guard:">,
-  HelpText<"Enable Control Flow Guard with /guard:cf">;
+def _SLASH_guard : CLJoined<"guard:">,
+  HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with 
/guard:cf,nochecks">;
 def _SLASH_GX : CLFlag<"GX">,
   HelpText<"Enable exception handling">;
 def _SLASH_GX_ : CLFlag<"GX-">,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=339420&r1=339419&r2=339420&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Aug 10 02:49:21 2018
@@ -460,7 +460,7 @@ void CodeGenModule::Release() {
   }
   if (CodeGenOpts.ControlFlowGuard) {
 // We want function ID tables for Control Flow Guard.
-getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1);
+getModule().addModuleFlag(llvm::Module::Warning, "cfguardtable", 1);
   }
   if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
 // We don't support LTO with 2 with different StrictVTablePointers

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=339420&r1=339419&r2=339420&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Aug 10 02:49:21 2018
@@ -5273,9 +5273,28 @@ void Clang::AddClangCLArgs(const ArgList
   CmdArgs.push_back("msvc");
   }
 
-  if (Args.hasArg(options::OPT__SLASH_Guard) &&
-  Args.getLastArgValue(options::OPT__SLASH_Guard).equals_lower("cf"))
-CmdArgs.push_back("-cfguard");
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
+SmallVector SplitArgs;
+StringRef(A->getValue()).split(SplitArgs, ",");
+bool Instrument = false;
+bool NoChecks = false;
+for (StringRef Arg : SplitArgs) {
+  if (Arg.equals_lower("cf"))
+Instrument = true;
+  else if (Arg.equals_lower("cf-"))
+Instrument = false;
+  else if (Arg.equals_lower("nochecks"))
+NoChecks = true;
+  else if (Arg.equals_lower("nochecks-"))
+NoChecks = false;
+  else
+D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << Arg;
+}
+// Currently there's no support emitting CFG instrumentation; the flag only
+// emits the table of address-taken functions.
+if (Instrument || NoChecks)
+  CmdArgs.push_back("-cfguard");
+  }
 }
 
 visualstudio::Compiler *Clang::getCLFallback() const {

Added: cfe/trunk/test/CodeGen/cfguardtable.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfguardtable.c?rev=339420&view=auto
==
--- cfe/trunk/test/CodeGen/cfguardtable.c (added)
+++ cfe/trunk/test/CodeGen/cfguardtable.c Fri Aug 10 02:49:21 2018
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -cfguard -emit-llvm %s -o - | FileCheck %s
+
+void f() {}
+
+// Check that the cfguardtable metadata flag gets set on the module.
+// CHECK: !"cfguardtable", i32 1}

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=339420&r1=339419&r2=339420&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Aug 10 02:49:21 2018
@@ -420,8 +420,6 @@
 // RUN: /Gr \
 // RUN: /GS \
 // RUN: /GT \
-// RUN: /guard:cf \
-// RUN: /

[PATCH] D50513: clang-cl: Support /guard:cf,nochecks

2018-08-10 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339420: clang-cl: Support /guard:cf,nochecks (authored by 
hans, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50513?vs=159927&id=160076#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50513

Files:
  cfe/trunk/include/clang/Driver/CLCompatOptions.td
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/CodeGen/cfguardtable.c
  cfe/trunk/test/Driver/cl-options.c

Index: cfe/trunk/test/CodeGen/cfguardtable.c
===
--- cfe/trunk/test/CodeGen/cfguardtable.c
+++ cfe/trunk/test/CodeGen/cfguardtable.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -cfguard -emit-llvm %s -o - | FileCheck %s
+
+void f() {}
+
+// Check that the cfguardtable metadata flag gets set on the module.
+// CHECK: !"cfguardtable", i32 1}
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -420,8 +420,6 @@
 // RUN: /Gr \
 // RUN: /GS \
 // RUN: /GT \
-// RUN: /guard:cf \
-// RUN: /guard:cf- \
 // RUN: /GX \
 // RUN: /Gv \
 // RUN: /Gz \
@@ -562,6 +560,18 @@
 // RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s
 // LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
 
+// RUN: %clang_cl  -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
+// RUN: %clang_cl /guard:cf- -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
+// NOCFGUARD-NOT: -guardcf
+
+// RUN: %clang_cl /guard:cf -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
+// RUN: %clang_cl /guard:cf,nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
+// RUN: %clang_cl /guard:nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
+// CFGUARD: -cfguard
+
+// RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
+// CFGUARDINVALID: invalid value 'foo' in '/guard:'
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -460,7 +460,7 @@
   }
   if (CodeGenOpts.ControlFlowGuard) {
 // We want function ID tables for Control Flow Guard.
-getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1);
+getModule().addModuleFlag(llvm::Module::Warning, "cfguardtable", 1);
   }
   if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
 // We don't support LTO with 2 with different StrictVTablePointers
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -5273,9 +5273,28 @@
   CmdArgs.push_back("msvc");
   }
 
-  if (Args.hasArg(options::OPT__SLASH_Guard) &&
-  Args.getLastArgValue(options::OPT__SLASH_Guard).equals_lower("cf"))
-CmdArgs.push_back("-cfguard");
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
+SmallVector SplitArgs;
+StringRef(A->getValue()).split(SplitArgs, ",");
+bool Instrument = false;
+bool NoChecks = false;
+for (StringRef Arg : SplitArgs) {
+  if (Arg.equals_lower("cf"))
+Instrument = true;
+  else if (Arg.equals_lower("cf-"))
+Instrument = false;
+  else if (Arg.equals_lower("nochecks"))
+NoChecks = true;
+  else if (Arg.equals_lower("nochecks-"))
+NoChecks = false;
+  else
+D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << Arg;
+}
+// Currently there's no support emitting CFG instrumentation; the flag only
+// emits the table of address-taken functions.
+if (Instrument || NoChecks)
+  CmdArgs.push_back("-cfguard");
+  }
 }
 
 visualstudio::Compiler *Clang::getCLFallback() const {
Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td
===
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td
@@ -240,8 +240,8 @@
 def _SLASH_Fo : CLCompileJoined<"Fo">,
   HelpText<"Set output object file, or directory (ends in / or \\) (with /c)">,
   MetaVarName<"">;
-def _SLASH_Guard : CLJoined<"guard:">,
-  HelpText<"Enable Control Flow Guard with /guard:cf">;
+def _SLASH_guard : CLJoined<"guard:">,
+  HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks">;
 def _SLASH_GX : CLFlag<"GX">,
   HelpText<"Enable exception handling">;
 def _SLASH_GX_ : CLFlag<"GX-">,

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-10 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld removed a reviewer: Hahnfeld.
Hahnfeld added a comment.

I feel like there is no progress in the discussion (here and off-list), partly 
because we might still not be talking about the same things. So I'm stepping 
down from this revision to unblock review from somebody else.

Here's my current understanding of the issue(s):

- `math.h` (or transitively included files) on both PowerPC and x86 contain 
inline assembly.
  - On x86 Clang directly bails out because the code is using the `x` input 
constraint which doesn't exist for NVPTX (-> `invalid input constraint 'x' in 
asm`).
  - From my understanding the header passes Sema analysis on PowerPC, but 
rejects CodeGen because the assembly instructions are invalid on NVPTX?
- This problem can be avoided (for testing purposes; including `math.h` should 
be fixed as well some day!) by explicitly declaring all needed math functions 
(like `extern double exp(double);`)
  - Without additional flags this makes Clang emit Intrinsic Functions 
 like `@llvm.exp.f64` 
for NVPTX.
  - That's because `IsMathErrnoDefault()` returns `false` for the Cuda 
ToolChain. This behaviour can be overwritten using `-fmath-errno` (the test 
case `nvptx_device_math_functions.c` uses this flag; I'm not sure why?)
- That at least looks to be producing correct IR in both cases which is then 
passed to the backend:
  1. For intrinsic functions (with some notable exceptions) the backend 
complains `Cannot select: [...] ExternalSymbol'exp'`.
- Some exceptions are `sqrt.f32`, `sqrt.f64`, `sin.f32` and `cos.f32`: The 
backend will directly lower them to the corresponding PTX instruction. 
Unfortunately there is none for `exp`...
  2. For "real" function calls (like `call double @exp(double %3)`) `nvlink` 
will throw `Undefined reference` errors.

This patch takes the following approach:

1. Avoid intrinsics for math builtins by passing `-fno-math-builtin` for device 
compilation.
2. Use the CUDA header to redirect math functions to their libdevice 
equivalents in the frontend, mostly just prefixed by `__nv_` (for example 
`exp(a)` -> `__nv_exp(a)`).

The downside of this approach is that LLVM doesn't recognize these function 
calls and doesn't perform optimizations to fold libcalls. For example `pow(a, 
2)` is transformed into a multiplication but `__nv_pow(a, 2)` is not.

In https://reviews.llvm.org/D47849#1124638, @Hahnfeld wrote:

> IMO this goes into the right direction, we should use the fast implementation 
> in libdevice.


So yeah, my comment seems to be outdated if these simple optimizations don't 
happen anymore with this patch: I don't want to use a fast `pow(a, 2)`, I don't 
want to call a library function for that at all.

We could of course make LLVM recognize the calls to libdevice and handle them 
the same way. But that's adding more workarounds to make this patch not regress 
on easy cases (in terms of transformations).
Another approach would be to make the NVPTX backend lower remaining calls of 
math functions to libdevice equivalents. I came across 
https://reviews.llvm.org/D34708 which seems to go into that direction (but 
doesn't work out-of-the-box after fixing some build errors, complaing about 
`Undefined external symbol`s because libdevice is optimized away as it wasn't 
needed before)...


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D50337: [clangd] DexIndex implementation prototype

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



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:29
+  // might be more efficient.
+  std::sort(begin(*Syms), end(*Syms), [](const Symbol *LHS, const Symbol *RHS) 
{
+return quality(*LHS) > quality(*RHS);

Calculating `quality` on each comparison can also get expensive. I think we 
could store the quality.



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:37
+for (const auto &Token : generateSearchTokens(*Sym)) {
+  if (!TempInvertedIndex.count(Token))
+TempInvertedIndex[Token] = {SymbolRank};

nit: use `try_emplace` to save one lookup? 



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:62
+  {
+std::lock_guard Lock(Mutex);
+More = Req.Query.size() >= 3 ? fuzzyFindLongQuery(Callback, Req)

I think we should let the helpers grab the lock. Some preparatory work doesn't 
require lock.

FWIW, I think the separation of short and long code paths is heading in a wrong 
direction. And it's also pretty hard to find a very clean abstraction here. For 
example, there is some overlaps in both functions, and `useCallback` seems a 
bit awkward. 

As all this would probably go away after D50517 anyway, I think we could try to 
get that patch landed and incorporate it into this patch? If you prefer to get 
this patch in first, please add `FIXME` somewhere to make it clear that the 
divergence is temporary.



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:82
+const auto *Sym = (*Symbols)[ID];
+const auto Score = Filter.match(Sym->Name);
+// Match scopes from the query.

nit: avoid `auto`here as the type of `Score` is not obvious here.



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:84
+// Match scopes from the query.
+// FIXME(kbobyrev): Use scope filtering before and iterate through the
+// posting list with the result. However, since the query might not contain

Put this `FIXME` on the for-loop level as iterating all symbols is the problem.

And I think the `FIXME` could simply be 
```
FIXME(...): This can be very expensive. We should first filter symbols by 
scopes (with scope iterators).
```

We can leave out the details/options as they are not interesting for most 
readers (as they are mostly concerns about scope filtering). In general, we 
should try to keep comments in documentation brief to keep the code shorter and 
easier to read.



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:94
+  continue;
+if (Score.hasValue()) {
+  // If the requested number of results is already retrieved but there

nit: `if (Score)`



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:95
+if (Score.hasValue()) {
+  // If the requested number of results is already retrieved but there
+  // are other symbols which match the criteria, just stop processing

The code here is trivial, so the comment seems redundant. 



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:102
+  }
+  Scores.push_back(std::make_pair(-*Score * quality(*Sym), Sym));
+}

For clarity, `- (*Score) * quality`. 

Please also comment on why we negate the number here?



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:175
+  // Sort retrieved symbol by Fuzzy Matching score.
+  std::sort(begin(Scores), end(Scores));
+

Shouldn't `Scores` already be sorted for both short query and long query?



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.h:12
+// over symbol tokens, such as fuzzy matching trigrams, scopes, types, etc. Dex
+// is supposed to be a drop-in replacement of MemIndex in the future: while
+// consuming more memory and having longer build stage due to preprocessing, 
Dex

nit: we don't really need to mention MemIndex here as it's likely to be 
replaced soon, and the comment will outdated then.

It's okay to mention why `Dex` is cool though :)



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.h:60
+private:
+  /// Constructs iterators over tokens extracted from the query and exhausts it
+  /// while applying Callback to each symbol in the order of decreasing quality

nit: The comment about implementation details should go with the 
implementation. Same below.



Comment at: clang-tools-extra/clangd/index/dex/DexIndex.h:65
+  const FuzzyFindRequest &Req) const;
+  /// Handles fuzzy matching requests with Req.Query.size() <= 3. This approach
+  /// currently does not use trigram index and query iterators and will be

`Req.Query.size() < 3`?



Comment at: clang-tools-extra/clangd/index/dex/Token.h:84
 
+

[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

Address a round of comments.

I have added few comments to get additional feedback before further changes are 
made.


https://reviews.llvm.org/D50517

Files:
  clang-tools-extra/clangd/index/dex/Iterator.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/index/dex/Trigram.h
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -250,45 +250,55 @@
 }
 
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
-  EXPECT_THAT(generateIdentifierTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateIdentifierTrigrams("X86"),
+  trigramsAre({"x86", "x$$", "x8$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({"nl$", "n$$"}));
+
+  EXPECT_THAT(generateIdentifierTrigrams("n"), trigramsAre({"n$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("clangd"),
-  trigramsAre({"cla", "lan", "ang", "ngd"}));
+  trigramsAre({"c$$", "cl$", "cla", "lan", "ang", "ngd"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("abc_def"),
-  trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def"}));
+  trigramsAre({"a$$", "d$$", "abc", "abd", "ade", "bcd", "bde",
+   "cde", "def", "ab$", "ad$", "de$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("a_b_c_d_e_"),
-  trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"}));
+  EXPECT_THAT(generateIdentifierTrigrams("a_b_c_d_e_"),
+  trigramsAre({"a$$", "b$$", "c$$", "d$$", "e$$", "abc", "abd",
+   "acd", "ace", "bcd", "bce", "bde", "cde", "ab$",
+   "ac$", "bc$", "bd$", "cd$", "ce$", "de$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("unique_ptr"),
-  trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", "iqp",
-   "ipt", "que", "qup", "qpt", "uep", "ept", "ptr"}));
+  EXPECT_THAT(generateIdentifierTrigrams("unique_ptr"),
+  trigramsAre({"u$$", "p$$", "uni", "unp", "upt", "niq", "nip",
+   "npt", "iqu", "iqp", "ipt", "que", "qup", "qpt",
+   "uep", "ept", "ptr", "un$", "up$", "pt$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("TUDecl"),
-  trigramsAre({"tud", "tde", "ude", "dec", "ecl"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("IsOK"),
-  trigramsAre({"iso", "iok", "sok"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("abc_defGhij__klm"),
-  trigramsAre({
-  "abc", "abd", "abg", "ade", "adg", "adk", "agh", "agk", "bcd",
-  "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde", "cdg", "cdk",
-  "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl", "efg",
-  "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
-  "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm",
-  }));
+  trigramsAre({"t$$", "d$$", "tud", "tde", "ude", "dec", "ecl",
+   "tu$", "td$", "de$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("IsOK"),
+  trigramsAre({"i$$", "o$$", "iso", "iok", "sok", "is$", "io$", "ok$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("abc_defGhij__klm"),
+  trigramsAre(
+  {"a$$", "d$$", "g$$", "k$$", "abc", "abd", "abg", "ade", "adg", "adk",
+   "agh", "agk", "bcd", "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde",
+   "cdg", "cdk", "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl",
+   "efg", "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
+   "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm", "ab$", "ad$",
+   "ag$", "de$", "dg$", "dk$", "gh$", "gk$", "kl$"}));
 }
 
 TEST(DexIndexTrigrams, QueryTrigrams) {
-  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateQueryTrigrams("c"), trigramsAre({"c$$"}));
+  EXPECT_THAT(generateQueryTrigrams("cl"), trigramsAre({"cl$"}));
+  EXPECT_THAT(generateQueryTrigrams("cla"), trigramsAre({"cla"}));
 
-  EXPECT_THAT(generateQueryTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
 
   EXPECT_THAT(generateQueryTrigrams("clangd"),
   trigramsAre({"cla", "lan", "ang", "ngd"}));
Index: clang-tools-extra/clangd/index/dex/Trigram.h
===
--- clang-tools-extra/clangd/index/dex/Trigram.h
+++ clang-tools-extra/clangd/index/dex/Trigram.h
@@ -44,6 +44,14 @@
 /// to the next character, move to the start

[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

2018-08-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:74
+// symbol of the identifier.
+if (!FoundFirstSymbol) {
+  FoundFirstSymbol = true;

ioeric wrote:
> Could this be pulled out of the loop? I think what we want is just 
> `LowercaseIdentifier[0]` right?
> 
> I'd probably also pulled that into a function, as the function body is 
> getting larger.
Same as elsewhere, if we have `__builtin_whatever` the it's not actually the 
first symbol of the lowercase identifier.



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:87
+
+  Chars = {{LowercaseIdentifier[I], LowercaseIdentifier[J], END_MARKER, 
0}};
+  const auto Bigram = Token(Token::Kind::Trigram, Chars.data());

ioeric wrote:
> I think we could be more restrictive on bigram generation. I think a bigram 
> prefix of identifier and a bigram prefix of the HEAD substring should work 
> pretty well in practice. For example, for `StringStartsWith`, you would have 
> `st$` and `ss$` (prefix of "SSW").
> 
> WDYT?
Good idea!



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:115
+// FIXME(kbobyrev): Correctly handle empty trigrams "$$$".
 std::vector generateQueryTrigrams(llvm::StringRef Query) {
   // Apply fuzzy matching text segmentation.

ioeric wrote:
> It seems to me that what we need for short queries is simply:
> ```
> if (Query.empty()) {
>// return empty token
> }
> if (Query.size() == 1) return {Query + "$$"};
> if (Query.size() == 2) return {Query + "$"};
> 
> // Longer queries...
> ```
> ?
That would mean that we expect the query to be "valid", i.e. only consist of 
letters and digits. My concern is about what happens if we have `"u_"` or 
something similar (`"_u", "_u_", "$u$"`, etc) - in that case we would actually 
still have to identify the first valid symbol for the trigram, process the 
string (trim it, etc) which looks very similar to what FuzzyMatching 
`calculateRoles` does.

The current approach is rather straightforward and generic, but I can try to 
change it if you want. My biggest concern is fighting some corner cases and 
ensuring that the query is "right" on the user (index) side, which might turn 
out to be more code and ensuring that the "state" is valid throughout the 
pipeline.



Comment at: clang-tools-extra/clangd/index/dex/Trigram.h:74
+/// For short queries (Query contains less than 3 letters and digits) this
+/// returns a single trigram with all valid symbols.
 std::vector generateQueryTrigrams(llvm::StringRef Query);

ioeric wrote:
> I'm not quite sure what this means. Could you elaborate?
Added an example and reflected in the other comment.


https://reviews.llvm.org/D50517



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

In https://reviews.llvm.org/D50517#1194990, @ioeric wrote:

> In https://reviews.llvm.org/D50517#1194976, @kbobyrev wrote:
>
> > As discussed offline with @ilya-biryukov, the better approach would be to 
> > prefix match first symbols of each distinct identifier piece instead of 
> > prefix matching (just looking at the first letter of the identifier) the 
> > whole identifier.
> >
> > Example:
> >
> > - Query: `"u"`
> > - Symbols: `"unique_ptr"`, `"user"`, `"super_user"`
> >
> >   Current implementation would match `"unique_ptr"` and `"user"` only. 
> > Proposed implementation would match all three symbols, because the second 
> > piece of `"super_user"` starts with `u`.
>
>
> And in the case where users want to match `super_user`, I think it's 
> reasonable to have users type two more characters and match it with `use`.


That would probably yield lower code completion quality for identifiers like 
`GtkWhatever` which might be very common in pure C projects and elsewhere. 
Also, Ilya mentioned that fuzzy matching filter would significantly increase 
the score of symbols which can be prefix matched and hence they would end up at 
the top if the quality is actually good. Another thing we can do is to boost 
prefix matched symbols if your concern is about them being removed after the 
initial filtering.

I'm personally leaning towards having unigrams for all segment starting 
symbols, but if you believe that it's certainly bad I can change that and in 
the future it will be rather trivial to switch if we decide to go backwards. 
What do you think?


https://reviews.llvm.org/D50517



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


[PATCH] D50502: [clangd] Initial cancellation mechanism for LSP requests.

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

I have left a few comments, but wanted to start with a higher-level design 
consideration.

I believe we should probably expose the cancellations in the ClangdServer API 
directly.
The reasons for that are:

1. We have an internal client that would also benefit from using the 
cancellation API and we should try to share as much code as possible between 
that and the rest of clangd.  Creating the cancellation cookies, stashing them 
in the context are all details that could be handled by ClangdServer so two 
clients don't have to do the same things.
2. `ClangdServer` seems like a natural layer for adding this, since it's a 
user-facing **async** API. It spawns async tasks, so it is a perfect place to 
provide a way to cancel the spawned tasks as well.

The concrete API that I propose is:

- Relevant methods of ClangdServer (we could start we code completion) that 
spawn async reqeuests returns a cancellation object that allows to cancel the 
spawned job:

  class TaskHandle {
void cancel();
  };
  
  class ClangdServer {
TaskHandle codeComplete(File, Position, Callback);
  };

- Users of the API are free to ignore the `TaskHandle` if they don't need to 
cancel the corresponding requests.
- If the users are capable of cancelling the request, they are responsible for 
keeping the `TaskHandle` around before the corresponding callback is called.
- If the request was cancelled, the `Callback` might receive the 
`TaskCancelledError` in the callback and should handle it accordingly.

The rest of the design LG, i.e.  the code that can actually be cancelled is 
responsible for checking `CancellationHandler::HasCancelled` and should return 
a corresponding error in the callback if it was cancelled.




Comment at: clangd/Cancellation.h:1
+//===--- Cancellation.h 
---*-C++-*-===//
+//

This file could use some comments about the API and samples of how it can be 
used.
Could probably be done after we finalize the design, though.



Comment at: clangd/Cancellation.h:22
+public:
+  static bool HasCancelled();
+  static Context LLVM_NODISCARD SetCurrentCancellationToken(

I think we might want to expose the context key for the cancellation primitive 
here.
The reason is that checking if request is cancelled is a common operation (i.e. 
I can imagine it being called on every few parsed ast node, etc.), so we'd want 
to keep the overhead of checking for cancellation very low.

Exposing a key in the context would allow to avoid doing the lookups in the 
context every time we need to check if request was cancelled.

Note that exposing `shared_ptr>` is probably not a great idea, 
since it'll allow to write into that object too. I suggest we go with a class 
that wraps it and only allows to read the value of the variable, i.e. only has 
`isCancelled` method.



Comment at: clangd/Cancellation.h:23
+  static bool HasCancelled();
+  static Context LLVM_NODISCARD SetCurrentCancellationToken(
+  std::shared_ptr> CancellationToken);

The `LLVM_NODISCARD` is misplaced. The current code applies the attribute to 
the type (i.e. `Context`), and we want to apply to the function.
There are two ways to do that:
1. `LLVM_NODISCARD static Context SetCurrentCancellationToken()`
2. `static Context SetCurrentCancellationToken LLVM_NODISCARD ()`

The first one is definitely less awkward and more widely used, so I suggest we 
stick to it



Comment at: clangd/Cancellation.h:25
+  std::shared_ptr> CancellationToken);
+  static llvm::Error GetCancellationError();
+};

NIT: use `lowerCamelCase` for function names (per [LLVM style 
guide](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly))



Comment at: clangd/Cancellation.h:36
+  std::error_code convertToErrorCode() const override {
+llvm_unreachable("Tried to get error code on TaskCancelledError");
+  }

It seems the contract for `ErrorInfo` actually requires this function to be 
implemented, so using `llvm_unreachable` doesn't seem right here.
We could get away without actually unique error codes by returning 
`llvm::inconvertibleErrorCode()`, though.



Comment at: clangd/ClangdLSPServer.cpp:76
+  return ID.kind() == json::Value::Number
+ ? utostr(static_cast(ID.getAsNumber().getValue()))
+ : std::string(ID.getAsString().getValue());

1. Maybe use `getAsInteger()` to convert directly to `int64_t`?
2. Maybe use `itostr` to avoid conversion from `int64` to `uint64`, which is 
undefined for negative numbers?
3. What if input is neither string nor number? Maybe add an assertion and check 
at the call-sites? That's a form of user input and we don't want clangd to 
crash in case of incorrect ones.

Alternatively, could we simply pipe the `json::Value`

[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like keys

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



Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:91-100
+  const QualType IterTy = CE->getArg(0)->getType();
+  const RecordDecl *RD =
+IterTy->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
+
+  if (RD->field_empty())
+return;
+

NoQ wrote:
> This heuristic ("the argument of `std::sort` is //a class whose first field 
> is of pointer type//") is quite wonky, do you have a plan on how to make it 
> more precise?
```
template< class RandomIt >
void sort( RandomIt first, RandomIt last );
```
Since `RandomIt` must satisfy [[ 
https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator | 
RandomAccesIterator ]], maybe you could obtain the value type with 
`std::iterator_traits::value_type`, and check whether it's a pointer type.


Repository:
  rC Clang

https://reviews.llvm.org/D50488



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like keys

2018-08-10 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:88
+
+  if (!II->getName().equals("sort"))
+return;

Brrr... `equals`. StringRef has a `==` and `!=` operator which accepts string 
literals on the other side, which would result in a more concise code.

Also, this heuristic can be applied without extra changes (apart from those 
mentioned by NoQ and might be mentioned later by others) to other sorting 
functions, such as `std::stable_sort` and `std::stable_partition`. Perhaps it 
would be worthy to enable checking those functions too.


Repository:
  rC Clang

https://reviews.llvm.org/D50488



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:74
+// symbol of the identifier.
+if (!FoundFirstSymbol) {
+  FoundFirstSymbol = true;

kbobyrev wrote:
> ioeric wrote:
> > Could this be pulled out of the loop? I think what we want is just 
> > `LowercaseIdentifier[0]` right?
> > 
> > I'd probably also pulled that into a function, as the function body is 
> > getting larger.
> Same as elsewhere, if we have `__builtin_whatever` the it's not actually the 
> first symbol of the lowercase identifier.
I would argue that I would start by typing "_" if I actually want 
`__builtin_whatever`. I'm also not sure if this is the case we should optimize 
for as well; __builtin symbols  are already penalized in code completion 
ranking.



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:115
+// FIXME(kbobyrev): Correctly handle empty trigrams "$$$".
 std::vector generateQueryTrigrams(llvm::StringRef Query) {
   // Apply fuzzy matching text segmentation.

kbobyrev wrote:
> ioeric wrote:
> > It seems to me that what we need for short queries is simply:
> > ```
> > if (Query.empty()) {
> >// return empty token
> > }
> > if (Query.size() == 1) return {Query + "$$"};
> > if (Query.size() == 2) return {Query + "$"};
> > 
> > // Longer queries...
> > ```
> > ?
> That would mean that we expect the query to be "valid", i.e. only consist of 
> letters and digits. My concern is about what happens if we have `"u_"` or 
> something similar (`"_u", "_u_", "$u$"`, etc) - in that case we would 
> actually still have to identify the first valid symbol for the trigram, 
> process the string (trim it, etc) which looks very similar to what 
> FuzzyMatching `calculateRoles` does.
> 
> The current approach is rather straightforward and generic, but I can try to 
> change it if you want. My biggest concern is fighting some corner cases and 
> ensuring that the query is "right" on the user (index) side, which might turn 
> out to be more code and ensuring that the "state" is valid throughout the 
> pipeline.
It's not clear what we would want to match with "*_", except for `u_` in 
`unique_ptr` (maybe).  

Generally, as short queries tend to match many more symbols, I think we should 
try to make them more restrictive and optimize for the most common use case. 


https://reviews.llvm.org/D50517



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


[PATCH] D50557: [clang][mips] Set __mips_fpr correctly for -mfpxx

2018-08-10 Thread Stefan Maksimovic via Phabricator via cfe-commits
smaksimovic created this revision.
smaksimovic added a reviewer: atanasyan.
Herald added subscribers: arichardson, sdardis.

Set __mips_fpr to 0 if o32 ABI is used with either -mfpxx or none of -mfp32, 
-mfpxx, -mfp64 being specified.

Introduce additional checks:

- -mfpxx is only to be used in conjunction with the o32 ABI.
- report an error when incompatible options are provided.

Formerly no errors were raised when combining n32/n64 ABIs with -mfp32 and 
-mfpxx.

There are other cases when __mips_fpr should be set to 0 that are not covered, 
ex. using o32 on a mips64 cpu which is valid but not supported in the backend 
as of yet.


https://reviews.llvm.org/D50557

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  lib/Basic/Targets/Mips.cpp
  lib/Basic/Targets/Mips.h

Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -58,15 +58,16 @@
 
 protected:
   bool HasFP64;
+  bool HasFPXX;
   std::string ABI;
 
 public:
   MipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsAbs2008(false), IsSingleFloat(false),
 IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat),
 DspRev(NoDSP), HasMSA(false), DisableMadd4(false),
-UseIndirectJumpHazard(false), HasFP64(false) {
+UseIndirectJumpHazard(false), HasFP64(false), HasFPXX(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI(getTriple().isMIPS32() ? "o32" : "n64");
@@ -181,6 +182,8 @@
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
+  unsigned getISARev(const std::string& CPU) const;
+
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
@@ -328,6 +331,8 @@
 HasFP64 = true;
   else if (Feature == "-fp64")
 HasFP64 = false;
+  else if (Feature == "+fpxx")
+HasFPXX = true;
   else if (Feature == "+nan2008")
 IsNan2008 = true;
   else if (Feature == "-nan2008")
Index: lib/Basic/Targets/Mips.cpp
===
--- lib/Basic/Targets/Mips.cpp
+++ lib/Basic/Targets/Mips.cpp
@@ -59,6 +59,16 @@
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
+unsigned MipsTargetInfo::getISARev(const std::string& CPU) const {
+  return llvm::StringSwitch(getCPU())
+ .Cases("mips32", "mips64", 1)
+ .Cases("mips32r2", "mips64r2", 2)
+ .Cases("mips32r3", "mips64r3", 3)
+ .Cases("mips32r5", "mips64r5", 5)
+ .Cases("mips32r6", "mips64r6", 6)
+ .Default(0);
+}
+
 void MipsTargetInfo::getTargetDefines(const LangOptions &Opts,
   MacroBuilder &Builder) const {
   if (BigEndian) {
@@ -84,13 +94,8 @@
 Builder.defineMacro("_MIPS_ISA", "_MIPS_ISA_MIPS64");
   }
 
-  const std::string ISARev = llvm::StringSwitch(getCPU())
- .Cases("mips32", "mips64", "1")
- .Cases("mips32r2", "mips64r2", "2")
- .Cases("mips32r3", "mips64r3", "3")
- .Cases("mips32r5", "mips64r5", "5")
- .Cases("mips32r6", "mips64r6", "6")
- .Default("");
+  const std::string ISARev = std::to_string(getISARev(getCPU()));
+
   if (!ISARev.empty())
 Builder.defineMacro("__mips_isa_rev", ISARev);
 
@@ -129,7 +134,8 @@
   if (IsSingleFloat)
 Builder.defineMacro("__mips_single_float", Twine(1));
 
-  Builder.defineMacro("__mips_fpr", HasFP64 ? Twine(64) : Twine(32));
+  Builder.defineMacro("__mips_fpr",
+  Twine(HasFPXX ? 0 : (HasFP64 ? 64 : 32)));
   Builder.defineMacro("_MIPS_FPSET",
   Twine(32 / (HasFP64 || IsSingleFloat ? 1 : 2)));
 
@@ -235,5 +241,29 @@
 return false;
   }
 
+  // -fpxx is valid only for the o32 ABI
+  if (HasFPXX && (ABI == "n32" || ABI == "n64")) {
+Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32";
+return false;
+  }
+
+  // -mfp32 and n32/n64 ABIs are incompatible
+  if (!HasFP64 && !HasFPXX && !IsSingleFloat &&
+  (ABI == "n32" || ABI == "n64")) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU;
+return false;
+  }
+  // Mips revision 6 and -mfp32 are incompatible
+  if (!HasFP64 && !HasFPXX && (CPU == "mips32r6" || CPU == "mips64r6")) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32" << CPU;
+return false;
+  }
+  // Option -mfp64 permitted on Mips32 iff revision 2 or higher is present
+  if (HasFP64 && (CPU == "mips1" || CPU == "mips2" ||
+  getISARev(CPU) < 2) && ABI == "o32") {
+Diags.Report(diag::err_mips_fp64_req) << "-mfp64";
+return false;
+  }
+
   return true;
 }
Index

r339423 - Fix a wrong type bug in ParsedAttr::TypeTagForDatatypeData

2018-08-10 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Aug 10 04:20:20 2018
New Revision: 339423

URL: http://llvm.org/viewvc/llvm-project?rev=339423&view=rev
Log:
Fix a wrong type bug in ParsedAttr::TypeTagForDatatypeData

This patch fixes a wrong type bug inside ParsedAttr::TypeTagForDatatypeData.
The details to the best of my knowledge are as follow. The incredible thing
is that everything works out just fine by chance due to a sequence of lucky
coincidences in the layout of various types.

The struct ParsedAttr::TypeTagForDatatypeData contains among other things
a ParsedType *MatchingCType, where ParsedType is just OpaquePtr.

However the member MatchingCType is initialized in the constructor for
type_tag_for_datatype attribute as follows:

new (&ExtraData.MatchingCType) ParsedType(matchingCType);

This results in the ParsedType being constructed in the location of the
ParsedType * Later ParsedAttr::getMatchingCType do return
*getTypeTagForDatatypeDataSlot().MatchingCType; which instead of
dereferencing the ParsedType * will dereference the QualType inside
the ParsedType. Now this QualType in this case contains no qualifiers
and therefore is a valid Type *. Therefore getMatchingCType returns a
Type or at least the stuff that is in the first sizeof(void*) bytes of it,
But it turns out that Type inherits from ExtQualsCommonBase and that the
first member of ExtQualsCommonBase is a const Type *const BaseType. This
Type * in this case points to the original Type pointed to by the
QualType and so everything works fine even though all the types were wrong.

This bug was only found because I changed the layout of Type,
which obviously broke all of this long chain of improbable events.

Reviewed By: erichkeane

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


Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339423&r1=339422&r2=339423&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Fri Aug 10 04:20:20 2018
@@ -78,7 +78,7 @@ struct AvailabilityData {
 };
 
 struct TypeTagForDatatypeData {
-  ParsedType *MatchingCType;
+  ParsedType MatchingCType;
   unsigned LayoutCompatible : 1;
   unsigned MustBeNull : 1;
 };
@@ -502,7 +502,7 @@ public:
   const ParsedType &getMatchingCType() const {
 assert(getKind() == AT_TypeTagForDatatype &&
"Not a type_tag_for_datatype attribute");
-return *getTypeTagForDatatypeDataSlot().MatchingCType;
+return getTypeTagForDatatypeDataSlot().MatchingCType;
   }
 
   bool getLayoutCompatible() const {


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


[PATCH] D50532: Fix a wrong type bug in ParsedAttr::TypeTagForDatatypeData

2018-08-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339423: Fix a wrong type bug in 
ParsedAttr::TypeTagForDatatypeData (authored by brunoricci, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50532?vs=159988&id=160086#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50532

Files:
  include/clang/Sema/ParsedAttr.h


Index: include/clang/Sema/ParsedAttr.h
===
--- include/clang/Sema/ParsedAttr.h
+++ include/clang/Sema/ParsedAttr.h
@@ -78,7 +78,7 @@
 };
 
 struct TypeTagForDatatypeData {
-  ParsedType *MatchingCType;
+  ParsedType MatchingCType;
   unsigned LayoutCompatible : 1;
   unsigned MustBeNull : 1;
 };
@@ -502,7 +502,7 @@
   const ParsedType &getMatchingCType() const {
 assert(getKind() == AT_TypeTagForDatatype &&
"Not a type_tag_for_datatype attribute");
-return *getTypeTagForDatatypeDataSlot().MatchingCType;
+return getTypeTagForDatatypeDataSlot().MatchingCType;
   }
 
   bool getLayoutCompatible() const {


Index: include/clang/Sema/ParsedAttr.h
===
--- include/clang/Sema/ParsedAttr.h
+++ include/clang/Sema/ParsedAttr.h
@@ -78,7 +78,7 @@
 };
 
 struct TypeTagForDatatypeData {
-  ParsedType *MatchingCType;
+  ParsedType MatchingCType;
   unsigned LayoutCompatible : 1;
   unsigned MustBeNull : 1;
 };
@@ -502,7 +502,7 @@
   const ParsedType &getMatchingCType() const {
 assert(getKind() == AT_TypeTagForDatatype &&
"Not a type_tag_for_datatype attribute");
-return *getTypeTagForDatatypeDataSlot().MatchingCType;
+return getTypeTagForDatatypeDataSlot().MatchingCType;
   }
 
   bool getLayoutCompatible() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

@cdavis5x I presume the fact that this one turned out tricky is blocking 
submitting the SEH unwinding patch.

Would it be worth to rework that patch to just use the basic types just like 
libunwind does today, e.g. having `_Unwind_GetRegionStart` return plain 
`uintptr_t` instead of `_Unwind_Ptr`, which also would be consistent with the 
existing entry points in Unwind-EHABI.cpp, Unwind-sjlj.c and UnwindLevel1.c, in 
order to be able to submit it before this one gets sorted out?


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


r339424 - clang-cl: accept -fcrash-diagnostics-dir=

2018-08-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug 10 04:40:50 2018
New Revision: 339424

URL: http://llvm.org/viewvc/llvm-project?rev=339424&view=rev
Log:
clang-cl: accept -fcrash-diagnostics-dir=

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=339424&r1=339423&r2=339424&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 10 04:40:50 2018
@@ -802,7 +802,7 @@ def fconstexpr_backtrace_limit_EQ : Join
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
-def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused]>;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused, CoreOption]>;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 def fcxx_exceptions: Flag<["-"], "fcxx-exceptions">, Group,
   HelpText<"Enable C++ exceptions">, Flags<[CC1Option]>;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=339424&r1=339423&r2=339424&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Aug 10 04:40:50 2018
@@ -577,6 +577,7 @@
 // RUN: %clang_cl \
 // RUN: --driver-mode=cl \
 // RUN: -fblocks \
+// RUN: -fcrash-diagnostics-dir=/foo \
 // RUN: -fno-blocks \
 // RUN: -fbuiltin \
 // RUN: -fno-builtin \


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


[PATCH] D50500: [clangd] Allow consuming limited number of items

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

https://reviews.llvm.org/D50500

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


Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -240,6 +240,27 @@
 "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))");
 }
 
+TEST(DexIndexIterators, Limit) {
+  const PostingList L0 = {4, 7, 8, 20, 42, 100};
+  const PostingList L1 = {1, 3, 5, 8, 9};
+  const PostingList L2 = {1, 5, 7, 9};
+  const PostingList L3 = {0, 5};
+  const PostingList L4 = {0, 1, 5};
+  const PostingList L5;
+
+  auto DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 0), ElementsAre());
+}
+
 testing::Matcher>
 trigramsAre(std::initializer_list Trigrams) {
   std::vector Tokens;
Index: clang-tools-extra/clangd/index/dex/Iterator.h
===
--- clang-tools-extra/clangd/index/dex/Iterator.h
+++ clang-tools-extra/clangd/index/dex/Iterator.h
@@ -101,9 +101,10 @@
   virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0;
 };
 
-/// Exhausts given iterator and returns all processed DocIDs. The result
-/// contains sorted DocumentIDs.
-std::vector consume(Iterator &It);
+/// Advances the iterator until it is either exhausted or the number of
+/// requested items is reached. The result contains sorted DocumentIDs.
+std::vector consume(Iterator &It,
+   size_t Limit = std::numeric_limits::max());
 
 /// Returns a document iterator over given PostingList.
 std::unique_ptr create(PostingListRef Documents);
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
@@ -218,9 +218,10 @@
 
 } // end namespace
 
-std::vector consume(Iterator &It) {
+std::vector consume(Iterator &It, size_t Limit) {
   std::vector Result;
-  for (; !It.reachedEnd(); It.advance())
+  for (size_t Retrieved = 0; !It.reachedEnd() && Retrieved < Limit;
+   It.advance(), ++Retrieved)
 Result.push_back(It.peek());
   return Result;
 }


Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -240,6 +240,27 @@
 "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))");
 }
 
+TEST(DexIndexIterators, Limit) {
+  const PostingList L0 = {4, 7, 8, 20, 42, 100};
+  const PostingList L1 = {1, 3, 5, 8, 9};
+  const PostingList L2 = {1, 5, 7, 9};
+  const PostingList L3 = {0, 5};
+  const PostingList L4 = {0, 1, 5};
+  const PostingList L5;
+
+  auto DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 0), ElementsAre());
+}
+
 testing::Matcher>
 trigramsAre(std::initializer_list Trigrams) {
   std::vector Tokens;
Index: clang-tools-extra/clangd/index/dex/Iterator.h
===
--- clang-tools-extra/clangd/index/dex/Iterator.h
+++ clang-tools-extra/clangd/index/dex/Iterator.h
@@ -101,9 +101,10 @@
   virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0;
 };
 
-/// Exhausts given iterator and returns all processed DocIDs. The result
-/// contains sorted DocumentIDs.
-std::vector consume(Iterator &It);
+/// Advances the iterator until it is either exhausted or the number of
+/// requested items is reached. The result contains sorted DocumentIDs.
+std::vector consume(Iterator &It,
+   size_t Limit = std::numeric_limits::max());
 
 /// Returns a document iterator over given PostingList.
 std::unique_ptr create(PostingListRef Documents);
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
@@ -218,9 +218,10 @@
 
 } // end namespace

[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-10 Thread Andi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339427: [clang-tidy]  run-clang-tidy.py - add 
synchronisation to the output (authored by Abpostelnicu, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49851?vs=159511&id=160090#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49851

Files:
  clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -153,18 +153,23 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, failed_files):
+def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
-sys.stdout.write(' '.join(invocation) + '\n')
-return_code = subprocess.call(invocation)
-if return_code != 0:
+
+proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+output, err = proc.communicate()
+if proc.returncode != 0:
   failed_files.append(name)
+with lock:
+  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
+  if err > 0:
+sys.stderr.write(err + '\n')
 queue.task_done()
 
 
@@ -263,9 +268,10 @@
 task_queue = queue.Queue(max_task)
 # List of files with a non-zero return code.
 failed_files = []
+lock = threading.Lock()
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue, 
failed_files))
+   args=(args, tmpdir, build_path, task_queue, lock, 
failed_files))
   t.daemon = True
   t.start()
 


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -153,18 +153,23 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, failed_files):
+def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
-sys.stdout.write(' '.join(invocation) + '\n')
-return_code = subprocess.call(invocation)
-if return_code != 0:
+
+proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+output, err = proc.communicate()
+if proc.returncode != 0:
   failed_files.append(name)
+with lock:
+  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
+  if err > 0:
+sys.stderr.write(err + '\n')
 queue.task_done()
 
 
@@ -263,9 +268,10 @@
 task_queue = queue.Queue(max_task)
 # List of files with a non-zero return code.
 failed_files = []
+lock = threading.Lock()
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue, failed_files))
+   args=(args, tmpdir, build_path, task_queue, lock, failed_files))
   t.daemon = True
   t.start()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r339426 - [clangd] Allow consuming limited number of items

2018-08-10 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Fri Aug 10 04:50:44 2018
New Revision: 339426

URL: http://llvm.org/viewvc/llvm-project?rev=339426&view=rev
Log:
[clangd] Allow consuming limited number of items

This patch modifies `consume` function to allow retrieval of limited
number of symbols. This is the "cheap" implementation of top-level
limiting iterator. In the future we would like to have a complete limit
iterator implementation to insert it into the query subtrees, but in the
meantime this version would be enough for a fully-functional
proof-of-concept Dex implementation.

Reviewers: ioeric, ilya-biryukov

Reviewed by: ioeric

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
clang-tools-extra/trunk/clangd/index/dex/Iterator.h
clang-tools-extra/trunk/unittests/clangd/DexIndexTests.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=339426&r1=339425&r2=339426&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp Fri Aug 10 04:50:44 
2018
@@ -218,9 +218,10 @@ private:
 
 } // end namespace
 
-std::vector consume(Iterator &It) {
+std::vector consume(Iterator &It, size_t Limit) {
   std::vector Result;
-  for (; !It.reachedEnd(); It.advance())
+  for (size_t Retrieved = 0; !It.reachedEnd() && Retrieved < Limit;
+   It.advance(), ++Retrieved)
 Result.push_back(It.peek());
   return Result;
 }

Modified: clang-tools-extra/trunk/clangd/index/dex/Iterator.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Iterator.h?rev=339426&r1=339425&r2=339426&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.h (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.h Fri Aug 10 04:50:44 2018
@@ -101,9 +101,10 @@ private:
   virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0;
 };
 
-/// Exhausts given iterator and returns all processed DocIDs. The result
-/// contains sorted DocumentIDs.
-std::vector consume(Iterator &It);
+/// Advances the iterator until it is either exhausted or the number of
+/// requested items is reached. The result contains sorted DocumentIDs.
+std::vector consume(Iterator &It,
+   size_t Limit = std::numeric_limits::max());
 
 /// Returns a document iterator over given PostingList.
 std::unique_ptr create(PostingListRef Documents);

Modified: clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp?rev=339426&r1=339425&r2=339426&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp Fri Aug 10 
04:50:44 2018
@@ -240,6 +240,27 @@ TEST(DexIndexIterators, StringRepresenta
 "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))");
 }
 
+TEST(DexIndexIterators, Limit) {
+  const PostingList L0 = {4, 7, 8, 20, 42, 100};
+  const PostingList L1 = {1, 3, 5, 8, 9};
+  const PostingList L2 = {1, 5, 7, 9};
+  const PostingList L3 = {0, 5};
+  const PostingList L4 = {0, 1, 5};
+  const PostingList L5;
+
+  auto DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 0), ElementsAre());
+}
+
 testing::Matcher>
 trigramsAre(std::initializer_list Trigrams) {
   std::vector Tokens;


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


[PATCH] D50500: [clangd] Allow consuming limited number of items

2018-08-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339426: [clangd] Allow consuming limited number of items 
(authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50500?vs=160088&id=160089#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50500

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


Index: clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
@@ -240,6 +240,27 @@
 "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))");
 }
 
+TEST(DexIndexIterators, Limit) {
+  const PostingList L0 = {4, 7, 8, 20, 42, 100};
+  const PostingList L1 = {1, 3, 5, 8, 9};
+  const PostingList L2 = {1, 5, 7, 9};
+  const PostingList L3 = {0, 5};
+  const PostingList L4 = {0, 1, 5};
+  const PostingList L5;
+
+  auto DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 0), ElementsAre());
+}
+
 testing::Matcher>
 trigramsAre(std::initializer_list Trigrams) {
   std::vector Tokens;
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
@@ -218,9 +218,10 @@
 
 } // end namespace
 
-std::vector consume(Iterator &It) {
+std::vector consume(Iterator &It, size_t Limit) {
   std::vector Result;
-  for (; !It.reachedEnd(); It.advance())
+  for (size_t Retrieved = 0; !It.reachedEnd() && Retrieved < Limit;
+   It.advance(), ++Retrieved)
 Result.push_back(It.peek());
   return Result;
 }
Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.h
===
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.h
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.h
@@ -101,9 +101,10 @@
   virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0;
 };
 
-/// Exhausts given iterator and returns all processed DocIDs. The result
-/// contains sorted DocumentIDs.
-std::vector consume(Iterator &It);
+/// Advances the iterator until it is either exhausted or the number of
+/// requested items is reached. The result contains sorted DocumentIDs.
+std::vector consume(Iterator &It,
+   size_t Limit = std::numeric_limits::max());
 
 /// Returns a document iterator over given PostingList.
 std::unique_ptr create(PostingListRef Documents);


Index: clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp
@@ -240,6 +240,27 @@
 "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))");
 }
 
+TEST(DexIndexIterators, Limit) {
+  const PostingList L0 = {4, 7, 8, 20, 42, 100};
+  const PostingList L1 = {1, 3, 5, 8, 9};
+  const PostingList L2 = {1, 5, 7, 9};
+  const PostingList L3 = {0, 5};
+  const PostingList L4 = {0, 1, 5};
+  const PostingList L5;
+
+  auto DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator), ElementsAre(4, 7, 8, 20, 42, 100));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8));
+
+  DocIterator = create(L0);
+  EXPECT_THAT(consume(*DocIterator, 0), ElementsAre());
+}
+
 testing::Matcher>
 trigramsAre(std::initializer_list Trigrams) {
   std::vector Tokens;
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
@@ -218,9 +218,10 @@
 
 } // end namespace
 
-std::vector consume(Iterator &It) {
+std::vector consume(Iterator &It, size_t Limit) {
   std::vector Result;
-  for (; !It.reachedEnd(); It.advance())
+  for (size_t Retrieved = 0; !It.reachedEnd() && Retrieved < Limit;
+   It.advance(), ++Retrieved)
 Result.push_back(It.peek());
   return Result;
 }
Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.h
===
--- clang-tools-extra/trunk

[clang-tools-extra] r339427 - [clang-tidy] run-clang-tidy.py - add synchronisation to the output

2018-08-10 Thread Andi-Bogdan Postelnicu via cfe-commits
Author: abpostelnicu
Date: Fri Aug 10 04:50:47 2018
New Revision: 339427

URL: http://llvm.org/viewvc/llvm-project?rev=339427&view=rev
Log:
[clang-tidy]  run-clang-tidy.py - add synchronisation to the output
Differential Revision: https://reviews.llvm.org/D49851

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=339427&r1=339426&r2=339427&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Fri Aug 10 
04:50:47 2018
@@ -153,7 +153,7 @@ def apply_fixes(args, tmpdir):
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, failed_files):
+def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
@@ -161,10 +161,15 @@ def run_tidy(args, tmpdir, build_path, q
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
-sys.stdout.write(' '.join(invocation) + '\n')
-return_code = subprocess.call(invocation)
-if return_code != 0:
+
+proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+output, err = proc.communicate()
+if proc.returncode != 0:
   failed_files.append(name)
+with lock:
+  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
+  if err > 0:
+sys.stderr.write(err + '\n')
 queue.task_done()
 
 
@@ -263,9 +268,10 @@ def main():
 task_queue = queue.Queue(max_task)
 # List of files with a non-zero return code.
 failed_files = []
+lock = threading.Lock()
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue, 
failed_files))
+   args=(args, tmpdir, build_path, task_queue, lock, 
failed_files))
   t.daemon = True
   t.start()
 


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


[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response

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

Only a few NITs from my side.
Excited for this fix to get in, have been seeing duplicate in other cases too 
:-)




Comment at: clangd/SourceCode.h:69
 
+llvm::Optional getRealPath(const FileEntry *F,
+const SourceManager &SourceMgr);

This function looks like a good default choice for normalizing paths before 
putting them into LSP structs, ClangdServer responses, etc.
I suggest we add a small comment here with a guideline for everyone to attempt 
using it whenever possible. WDYT?



Comment at: unittests/clangd/TestFS.h:43
 public:
-  /// When \p UseRelPaths is true, uses relative paths in compile commands.
-  /// When \p UseRelPaths is false, uses absoulte paths.
-  MockCompilationDatabase(bool UseRelPaths = false);
+  /// If \p Directory is not null, use that as the Directory field of the
+  /// CompileCommand.

s/not null/not empty



Comment at: unittests/clangd/TestFS.h:46
+  ///
+  /// If \p RelPathPrefix is not null, use that as a prefix in front of the
+  /// source file name, instead of using an absolute path.

s/not null/not empty


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48687



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


[PATCH] D50415: [clangd] extend the publishDiagnostics response to send back fixits to the client directly as well (if requested)

2018-08-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 with a small NIT.




Comment at: clangd/ClangdLSPServer.cpp:507
+}
+LSPDiag["clangd.fixes"] = std::move(ClangdFixes);
+  }

NIT: maybe avoid `.` and use something like `clangd_fixes`? having dots in the 
object keys might be awkward if someone tries to use those from javascript. 
(not that we have these use-cases now, but still)


https://reviews.llvm.org/D50415



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-10 Thread David Chisnall via Phabricator via cfe-commits
theraven updated this revision to Diff 160091.
theraven added a comment.

Squashed into a single commit.


Repository:
  rC Clang

https://reviews.llvm.org/D50144

Files:
  include/clang/Driver/Options.td
  lib/AST/MicrosoftMangle.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGObjCRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGenObjC/gnu-init.m
  test/CodeGenObjC/gnustep2-proto.m
  test/CodeGenObjCXX/arc-marker-funclet.mm
  test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
  test/CodeGenObjCXX/msabi-objc-extensions.mm
  test/CodeGenObjCXX/msabi-objc-types.mm

Index: test/CodeGenObjCXX/msabi-objc-types.mm
===
--- test/CodeGenObjCXX/msabi-objc-types.mm
+++ test/CodeGenObjCXX/msabi-objc-types.mm
@@ -3,166 +3,166 @@
 @class I;
 
 id kid;
-// CHECK: @"?kid@@3PAUobjc_object@@A" =  dso_local global
+// CHECK: @"?kid@@3PAU.objc_object@@A" =  dso_local global
 
 Class klass;
-// CHECK: @"?klass@@3PAUobjc_class@@A" = dso_local global
+// CHECK: @"?klass@@3PAU.objc_class@@A" = dso_local global
 
 I *kI;
-// CHECK: @"?kI@@3PAUI@@A" = dso_local global
+// CHECK: @"?kI@@3PAU.objc_cls_I@@A" = dso_local global
 
 void f(I *) {}
-// CHECK-LABEL: "?f@@YAXPAUI@@@Z"
+// CHECK-LABEL: "?f@@YAXPAU.objc_cls_I@@@Z"
 
 void f(const I *) {}
-// CHECK-LABEL: "?f@@YAXPBUI@@@Z"
+// CHECK-LABEL: "?f@@YAXPBU.objc_cls_I@@@Z"
 
 void f(I &) {}
-// CHECK-LABEL: "?f@@YAXAAUI@@@Z"
+// CHECK-LABEL: "?f@@YAXAAU.objc_cls_I@@@Z"
 
 void f(const I &) {}
-// CHECK-LABEL: "?f@@YAXABUI@@@Z"
+// CHECK-LABEL: "?f@@YAXABU.objc_cls_I@@@Z"
 
 void f(const I &&) {}
-// CHECK-LABEL: "?f@@YAX$$QBUI@@@Z"
+// CHECK-LABEL: "?f@@YAX$$QBU.objc_cls_I@@@Z"
 
 void g(id) {}
-// CHECK-LABEL: "?g@@YAXPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXPAU.objc_object@@@Z"
 
 void g(id &) {}
-// CHECK-LABEL: "?g@@YAXAAPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXAAPAU.objc_object@@@Z"
 
 void g(const id &) {}
-// CHECK-LABEL: "?g@@YAXABQAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXABQAU.objc_object@@@Z"
 
 void g(id &&) {}
-// CHECK-LABEL: "?g@@YAX$$QAPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAX$$QAPAU.objc_object@@@Z"
 
 void h(Class) {}
-// CHECK-LABEL: "?h@@YAXPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXPAU.objc_class@@@Z"
 
 void h(Class &) {}
-// CHECK-LABEL: "?h@@YAXAAPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXAAPAU.objc_class@@@Z"
 
 void h(const Class &) {}
-// CHECK-LABEL: "?h@@YAXABQAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXABQAU.objc_class@@@Z"
 
 void h(Class &&) {}
-// CHECK-LABEL: "?h@@YAX$$QAPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAX$$QAPAU.objc_class@@@Z"
 
 I *i() { return nullptr; }
-// CHECK-LABEL: "?i@@YAPAUI@@XZ"
+// CHECK-LABEL: "?i@@YAPAU.objc_cls_I@@XZ"
 
 const I *j() { return nullptr; }
-// CHECK-LABEL: "?j@@YAPBUI@@XZ"
+// CHECK-LABEL: "?j@@YAPBU.objc_cls_I@@XZ"
 
 I &k() { return *kI; }
-// CHECK-LABEL: "?k@@YAAAUI@@XZ"
+// CHECK-LABEL: "?k@@YAAAU.objc_cls_I@@XZ"
 
 const I &l() { return *kI; }
-// CHECK-LABEL: "?l@@YAABUI@@XZ"
+// CHECK-LABEL: "?l@@YAABU.objc_cls_I@@XZ"
 
 void m(const id) {}
-// CHECK-LABEL: "?m@@YAXQAUobjc_object@@@Z"
+// CHECK-LABEL: "?m@@YAXQAU.objc_object@@@Z"
 
 void m(const I *) {}
-// CHECK-LABEL: "?m@@YAXPBUI@@@Z"
+// CHECK-LABEL: "?m@@YAXPBU.objc_cls_I@@@Z"
 
 void n(SEL) {}
-// CHECK-LABEL: "?n@@YAXPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXPAU.objc_selector@@@Z"
 
 void n(SEL *) {}
-// CHECK-LABEL: "?n@@YAXPAPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXPAPAU.objc_selector@@@Z"
 
 void n(const SEL *) {}
-// CHECK-LABEL: "?n@@YAXPBQAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXPBQAU.objc_selector@@@Z"
 
 void n(SEL &) {}
-// CHECK-LABEL: "?n@@YAXAAPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXAAPAU.objc_selector@@@Z"
 
 void n(const SEL &) {}
-// CHECK-LABEL: "?n@@YAXABQAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXABQAU.objc_selector@@@Z"
 
 void n(SEL &&) {}
-// CHECK-LABEL: "?n@@YAX$$QAPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAX$$QAPAU.objc_selector@@@Z"
 
 struct __declspec(dllexport) s {
   struct s &operator=(const struct s &) = delete;
 
   void m(I *) {}
-  // CHECK-LABEL: "?m@s@@QAAXPAUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXPAU.objc_cls_I@@@Z"
 
   void m(const I *) {}
-  // CHECK-LABEL: "?m@s@@QAAXPBUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXPBU.objc_cls_I@@@Z"
 
   void m(I &) {}
-  // CHECK-LABEL: "?m@s@@QAAXAAUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXAAU.objc_cls_I@@@Z"
 
   void m(const I &) {}
-  // CHECK-LABEL: "?m@s@@QAAXABUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXABU.objc_cls_I@@@Z"
 
   void m(I &&) {}
-  // CHECK-LABEL: "?m@s@@QAAX$$QAUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAX$$QAU.objc_cls_I@@@Z"
 
   void m(const I &&) {}
-  // CHECK-LABEL: "?m@s@@QAAX$$QBUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAX$$QBU.objc_cls_I@@@Z"
 
   void m(id) {}
-  // CHECK-LABEL: "?m@s@@QAAXPAUobjc_object@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXPAU.objc_object@@@Z"
 
  

[PATCH] D49240: [libc++] Introduce _LIBCPP_HIDE_FROM_ABI to replace _LIBCPP_INLINE_VISIBILITY

2018-08-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

When we updated out clang bundle in chromium (which includes libc++ headers), 
our ios simulator bots regressed debug info size by ~50% due to this commit 
(https://bugs.chromium.org/p/chromium/issues/detail?id=872926#c13). Is that 
expected?


Repository:
  rCXX libc++

https://reviews.llvm.org/D49240



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


[PATCH] D50555: [clangd] Introduce scoring mechanism for SignatureInformations.

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



Comment at: clangd/CodeComplete.cpp:715
  unsigned NumCandidates) override {
+TopN Top(
+std::numeric_limits::max());

Maybe use `vector`, followed by `std::sort` at the end?

Or is there any functionality that we can reuse from the priority queue?



Comment at: clangd/Quality.h:170
+  bool ContainsActiveParameter = false;
+  CodeCompleteConsumer::OverloadCandidate::CandidateKind Kind;
+

Maybe set some default value to avoid UB if someone forgets to set it?



Comment at: clangd/Quality.h:172
+
+  float evaluate() const;
+};

Maybe write a direct comparison here instead of `evaluate`?
Having floating scores makes sense for completion, where lot's of different 
signals from multiple sources are taken into account and clients have to 
rescore on the client side.
Not so much for SignatureHelp, where we have all required information to 
compare the signatures is on clangd side and clients won't need to rescore.

A comparison operator should be easier to reason about, though.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50555



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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

Address issues we discussed with Eric.


https://reviews.llvm.org/D50517

Files:
  clang-tools-extra/clangd/index/dex/Iterator.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/index/dex/Trigram.h
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -250,45 +250,59 @@
 }
 
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
-  EXPECT_THAT(generateIdentifierTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateIdentifierTrigrams("X86"),
+  trigramsAre({"x86", "x$$", "x8$", "$$$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateIdentifierTrigrams("nl"),
+  trigramsAre({"nl$", "n$$", "$$$"}));
+
+  EXPECT_THAT(generateIdentifierTrigrams("n"), trigramsAre({"n$$", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("clangd"),
-  trigramsAre({"cla", "lan", "ang", "ngd"}));
+  trigramsAre({"c$$", "cl$", "cla", "lan", "ang", "ngd", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("abc_def"),
-  trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def"}));
+  trigramsAre({"a$$", "abc", "abd", "ade", "bcd", "bde", "cde",
+   "def", "ab$", "ad$", "de$", "$$$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("a_b_c_d_e_"),
-  trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"}));
+  EXPECT_THAT(generateIdentifierTrigrams("a_b_c_d_e_"),
+  trigramsAre({"a$$", "a_$", "abc", "abd", "acd", "ace", "bcd",
+   "bce", "bde", "cde", "ab$", "ac$", "bc$", "bd$",
+   "cd$", "ce$", "de$", "$$$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("unique_ptr"),
-  trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", "iqp",
-   "ipt", "que", "qup", "qpt", "uep", "ept", "ptr"}));
+  EXPECT_THAT(generateIdentifierTrigrams("unique_ptr"),
+  trigramsAre({"u$$", "uni", "unp", "upt", "niq", "nip", "npt",
+   "iqu", "iqp", "ipt", "que", "qup", "qpt", "uep",
+   "ept", "ptr", "un$", "up$", "pt$", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("TUDecl"),
-  trigramsAre({"tud", "tde", "ude", "dec", "ecl"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("IsOK"),
-  trigramsAre({"iso", "iok", "sok"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("abc_defGhij__klm"),
-  trigramsAre({
-  "abc", "abd", "abg", "ade", "adg", "adk", "agh", "agk", "bcd",
-  "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde", "cdg", "cdk",
-  "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl", "efg",
-  "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
-  "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm",
-  }));
+  trigramsAre({"t$$", "tud", "tde", "ude", "dec", "ecl", "tu$",
+   "td$", "de$", "$$$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("IsOK"),
+  trigramsAre({"i$$", "iso", "iok", "sok", "is$", "io$", "ok$", "$$$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("abc_defGhij__klm"),
+  trigramsAre({"a$$", "abc", "abd", "abg", "ade", "adg", "adk", "agh",
+   "agk", "bcd", "bcg", "bde", "bdg", "bdk", "bgh", "bgk",
+   "cde", "cdg", "cdk", "cgh", "cgk", "def", "deg", "dek",
+   "dgh", "dgk", "dkl", "efg", "efk", "egh", "egk", "ekl",
+   "fgh", "fgk", "fkl", "ghi", "ghk", "gkl", "hij", "hik",
+   "hkl", "ijk", "ikl", "jkl", "klm", "ab$", "ad$", "ag$",
+   "de$", "dg$", "dk$", "gh$", "gk$", "kl$", "$$$"}));
 }
 
 TEST(DexIndexTrigrams, QueryTrigrams) {
-  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateQueryTrigrams("c"), trigramsAre({"c$$"}));
+  EXPECT_THAT(generateQueryTrigrams("cl"), trigramsAre({"cl$"}));
+  EXPECT_THAT(generateQueryTrigrams("cla"), trigramsAre({"cla"}));
 
-  EXPECT_THAT(generateQueryTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateQueryTrigrams("__b"), trigramsAre({"__$"}));
+  EXPECT_THAT(generateQueryTrigrams("_"), trigramsAre({"_$$"}));
+
+  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
 
   EXPECT_THAT(generateQueryTrigrams("clangd"),
   trigramsAre({"cla", "lan", "ang", "ngd"}));
Index: clang-tools-extra/clangd/index/dex/Trigram.h
===
--- clang-tools-extra/clangd/index/dex/Tr

[PATCH] D50449: [clangd] Support textEdit in addition to insertText.

2018-08-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. Thanks for the change!
Could we add an option to clangd to switch it on? (VSCode does not work, but 
our hacked-up ycm integration seems to work, right?)




Comment at: clangd/CodeComplete.cpp:1310
+  // other.
+  for (const auto &FixIt : FixIts) {
+if (IsRangeConsecutive(FixIt.range, LSP.textEdit->range)) {

kadircet wrote:
> ilya-biryukov wrote:
> > Maybe keep the `reserve` call? (we could reserve one extra element, but 
> > that's fine)
> Actually we could have much more than one extra element, not for the current 
> situation but may be in the future when we have more fixit completions.
We can't have more than one edit adjacent to the completion identifier, right? 
Otherwise they'll conflict.
It is possible to have multiple edits which are consectutive and the last of 
them is adjacent to the completion identifier, though. But I don't think we 
handle those cases here anyway.

But I'm not too worried about leaving out the reserve call either. At the very 
worst we could waste some memory on a single completion item, but we shouldn't 
keep too many around at the same time anyway, so feel free to ignore this one.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50449



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


r339428 - Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-10 Thread David Chisnall via cfe-commits
Author: theraven
Date: Fri Aug 10 05:53:13 2018
New Revision: 339428

URL: http://llvm.org/viewvc/llvm-project?rev=339428&view=rev
Log:
Add Windows support for the GNUstep Objective-C ABI V2.

Summary:
Introduces funclet-based unwinding for Objective-C and fixes an issue
where global blocks can't have their isa pointers initialised on
Windows.

After discussion with Dustin, this changes the name mangling of
Objective-C types to prevent a C++ catch statement of type struct X*
from catching an Objective-C object of type X*.

Reviewers: rjmccall, DHowett-MSFT

Reviewed By: rjmccall, DHowett-MSFT

Subscribers: mgrang, mstorsjo, smeenai, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/CodeGenObjC/gnu-init.m
cfe/trunk/test/CodeGenObjC/gnustep2-proto.m
cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
cfe/trunk/test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
cfe/trunk/test/CodeGenObjCXX/msabi-objc-extensions.mm
cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=339428&r1=339427&r2=339428&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 10 05:53:13 2018
@@ -1488,7 +1488,7 @@ def fobjc_weak : Flag<["-"], "fobjc-weak
   HelpText<"Enable ARC-style weak references in Objective-C">;
 
 // Objective-C ABI options.
-def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group, 
Flags<[CC1Option]>,
+def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Specify the target Objective-C runtime kind and version">;
 def fobjc_abi_version_EQ : Joined<["-"], "fobjc-abi-version=">, Group;
 def fobjc_nonfragile_abi_version_EQ : Joined<["-"], 
"fobjc-nonfragile-abi-version=">, Group;

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=339428&r1=339427&r2=339428&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri Aug 10 05:53:13 2018
@@ -445,7 +445,7 @@ void MicrosoftCXXNameMangler::mangle(con
 mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
   else if (const VarDecl *VD = dyn_cast(D))
 mangleVariableEncoding(VD);
-  else
+  else if (!isa(D))
 llvm_unreachable("Tried to mangle unexpected NamedDecl!");
 }
 
@@ -1884,13 +1884,13 @@ void MicrosoftCXXNameMangler::mangleType
 llvm_unreachable("placeholder types shouldn't get to name mangling");
 
   case BuiltinType::ObjCId:
-mangleArtificalTagType(TTK_Struct, "objc_object");
+mangleArtificalTagType(TTK_Struct, ".objc_object");
 break;
   case BuiltinType::ObjCClass:
-mangleArtificalTagType(TTK_Struct, "objc_class");
+mangleArtificalTagType(TTK_Struct, ".objc_class");
 break;
   case BuiltinType::ObjCSel:
-mangleArtificalTagType(TTK_Struct, "objc_selector");
+mangleArtificalTagType(TTK_Struct, ".objc_selector");
 break;
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
@@ -2570,9 +2570,10 @@ void MicrosoftCXXNameMangler::mangleType
 
 void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T, 
Qualifiers,
  SourceRange) {
-  // ObjC interfaces have structs underlying them.
+  // ObjC interfaces are mangled as if they were structs with a name that is
+  // not a valid C/C++ identifier
   mangleTagTypeKind(TTK_Struct);
-  mangleName(T->getDecl());
+  mangle(T->getDecl(), ".objc_cls_");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T, Qualifiers,
@@ -2590,11 +2591,11 @@ void MicrosoftCXXNameMangler::mangleType
 
   Out << "?$";
   if (T->isObjCId())
-mangleSourceName("objc_object");
+mangleSourceName(".objc_object");
   else if (T->isObjCClass())
-mangleSourceName("objc_class");
+mangleSourceName(".objc_class");
   else
-mangleSourceName(T->getInterface()->getName());
+mangleSourceName((".objc_cls_" + T->getInterface()->getName()).str());
 
   for (const auto &Q : T->quals())
 mangleObjCProtocol(Q);

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=339428&r1=339427&r2=339428&view=diff
==
--

r339429 - Fix a deprecated warning in the last commit.

2018-08-10 Thread David Chisnall via cfe-commits
Author: theraven
Date: Fri Aug 10 05:53:18 2018
New Revision: 339429

URL: http://llvm.org/viewvc/llvm-project?rev=339429&view=rev
Log:
Fix a deprecated warning in the last commit.

Done as a separate commit to make it easier to cherry pick the changes
to the release branch.

Modified:
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=339429&r1=339428&r2=339429&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Fri Aug 10 05:53:18 2018
@@ -205,7 +205,7 @@ void CGObjCRuntime::EmitTryCatchStmt(Cod
 // Emit the original filter expression, convert to i32, and return.
 HelperCGF.EmitStmt(FinallyBlock);
 
-HelperCGF.FinishFunction(FinallyBlock->getLocEnd());
+HelperCGF.FinishFunction(FinallyBlock->getEndLoc());
 
 llvm::Function *FinallyFunc = HelperCGF.CurFn;
 


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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-10 Thread David Chisnall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339428: Add Windows support for the GNUstep Objective-C ABI 
V2. (authored by theraven, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50144?vs=160091&id=160095#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50144

Files:
  include/clang/Driver/Options.td
  lib/AST/MicrosoftMangle.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGObjCRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGenObjC/gnu-init.m
  test/CodeGenObjC/gnustep2-proto.m
  test/CodeGenObjCXX/arc-marker-funclet.mm
  test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
  test/CodeGenObjCXX/msabi-objc-extensions.mm
  test/CodeGenObjCXX/msabi-objc-types.mm

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1488,7 +1488,7 @@
   HelpText<"Enable ARC-style weak references in Objective-C">;
 
 // Objective-C ABI options.
-def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group, Flags<[CC1Option]>,
+def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group, Flags<[CC1Option, CoreOption]>,
   HelpText<"Specify the target Objective-C runtime kind and version">;
 def fobjc_abi_version_EQ : Joined<["-"], "fobjc-abi-version=">, Group;
 def fobjc_nonfragile_abi_version_EQ : Joined<["-"], "fobjc-nonfragile-abi-version=">, Group;
Index: test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
===
--- test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
+++ test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
@@ -9,7 +9,7 @@
 
 // Verify that we destruct things from left to right in the MS C++ ABI: a, b, c, d.
 //
-// CHECK-LABEL: define dso_local void @"?test_arc_order@@YAXUA@@PAUobjc_object@@01@Z"
+// CHECK-LABEL: define dso_local void @"?test_arc_order@@YAXUA@@PAU.objc_object@@01@Z"
 // CHECK:   (<{ %struct.A, i8*, %struct.A, i8* }>* inalloca)
 void test_arc_order(A a, id __attribute__((ns_consumed)) b , A c, id __attribute__((ns_consumed)) d) {
   // CHECK: call x86_thiscallcc void @"??1A@@QAE@XZ"(%struct.A* %{{.*}})
Index: test/CodeGenObjCXX/msabi-objc-types.mm
===
--- test/CodeGenObjCXX/msabi-objc-types.mm
+++ test/CodeGenObjCXX/msabi-objc-types.mm
@@ -3,166 +3,166 @@
 @class I;
 
 id kid;
-// CHECK: @"?kid@@3PAUobjc_object@@A" =  dso_local global
+// CHECK: @"?kid@@3PAU.objc_object@@A" =  dso_local global
 
 Class klass;
-// CHECK: @"?klass@@3PAUobjc_class@@A" = dso_local global
+// CHECK: @"?klass@@3PAU.objc_class@@A" = dso_local global
 
 I *kI;
-// CHECK: @"?kI@@3PAUI@@A" = dso_local global
+// CHECK: @"?kI@@3PAU.objc_cls_I@@A" = dso_local global
 
 void f(I *) {}
-// CHECK-LABEL: "?f@@YAXPAUI@@@Z"
+// CHECK-LABEL: "?f@@YAXPAU.objc_cls_I@@@Z"
 
 void f(const I *) {}
-// CHECK-LABEL: "?f@@YAXPBUI@@@Z"
+// CHECK-LABEL: "?f@@YAXPBU.objc_cls_I@@@Z"
 
 void f(I &) {}
-// CHECK-LABEL: "?f@@YAXAAUI@@@Z"
+// CHECK-LABEL: "?f@@YAXAAU.objc_cls_I@@@Z"
 
 void f(const I &) {}
-// CHECK-LABEL: "?f@@YAXABUI@@@Z"
+// CHECK-LABEL: "?f@@YAXABU.objc_cls_I@@@Z"
 
 void f(const I &&) {}
-// CHECK-LABEL: "?f@@YAX$$QBUI@@@Z"
+// CHECK-LABEL: "?f@@YAX$$QBU.objc_cls_I@@@Z"
 
 void g(id) {}
-// CHECK-LABEL: "?g@@YAXPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXPAU.objc_object@@@Z"
 
 void g(id &) {}
-// CHECK-LABEL: "?g@@YAXAAPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXAAPAU.objc_object@@@Z"
 
 void g(const id &) {}
-// CHECK-LABEL: "?g@@YAXABQAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXABQAU.objc_object@@@Z"
 
 void g(id &&) {}
-// CHECK-LABEL: "?g@@YAX$$QAPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAX$$QAPAU.objc_object@@@Z"
 
 void h(Class) {}
-// CHECK-LABEL: "?h@@YAXPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXPAU.objc_class@@@Z"
 
 void h(Class &) {}
-// CHECK-LABEL: "?h@@YAXAAPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXAAPAU.objc_class@@@Z"
 
 void h(const Class &) {}
-// CHECK-LABEL: "?h@@YAXABQAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXABQAU.objc_class@@@Z"
 
 void h(Class &&) {}
-// CHECK-LABEL: "?h@@YAX$$QAPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAX$$QAPAU.objc_class@@@Z"
 
 I *i() { return nullptr; }
-// CHECK-LABEL: "?i@@YAPAUI@@XZ"
+// CHECK-LABEL: "?i@@YAPAU.objc_cls_I@@XZ"
 
 const I *j() { return nullptr; }
-// CHECK-LABEL: "?j@@YAPBUI@@XZ"
+// CHECK-LABEL: "?j@@YAPBU.objc_cls_I@@XZ"
 
 I &k() { return *kI; }
-// CHECK-LABEL: "?k@@YAAAUI@@XZ"
+// CHECK-LABEL: "?k@@YAAAU.objc_cls_I@@XZ"
 
 const I &l() { return *kI; }
-// CHECK-LABEL: "?l@@YAABUI@@XZ"
+// CHECK-LABEL: "?l@@YAABU.objc_cls_I@@XZ"
 
 void m(const id) {}
-// CHECK-LABEL: "?m@@YAXQAUobjc_object@@@Z"
+// CHECK-LABEL: "?m@@YAXQAU.objc_object@@@Z"
 
 void m(const I *) {}
-// CHECK-LABEL: "?m@@YAXPBUI@@@Z"

[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:38
+   "depends upon internal implementation details, which violates the "
+   "abseil compatibilty guidelines. These can be found at "
+   "https://abseil.io/about/compatibility";);

s/. These can be found at/; see/



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:38
+   "depends upon internal implementation details, which violates the "
+   "abseil compatibilty guidelines. These can be found at "
+   "https://abseil.io/about/compatibility";);

alexfh wrote:
> s/. These can be found at/; see/
s/abseil/Abseil/


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50542



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


[PATCH] D49800: [clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro

2018-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a couple of nits. Do you need someone to commit the patch for you?




Comment at: clang-tidy/modernize/RedundantVoidArgCheck.cpp:241
+SourceLocation End, Begin;
+auto SM = Result.SourceManager;
+auto TypeLoc = Lambda->getLambdaClass()->getLambdaTypeInfo()->getTypeLoc();

s/auto /SourceManager */



Comment at: clang-tidy/modernize/RedundantVoidArgCheck.cpp:242
+auto SM = Result.SourceManager;
+auto TypeLoc = Lambda->getLambdaClass()->getLambdaTypeInfo()->getTypeLoc();
+End = SM->getSpellingLoc(TypeLoc.getLocEnd());

Use the actual type name here as well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49800



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


[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers

2018-08-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In https://reviews.llvm.org/D46652#1174220, @mikerice wrote:

> In https://reviews.llvm.org/D46652#1164010, @thakis wrote:
>
> > Also, were you planning on also adding support for the (filename-less 
> > version of) hdrstop pragma? After this change, that should probably be 
> > fairly straightforward.
>
>
> Thanks for taking a look.  I'll be going through our PCH tests at some point 
> soon and will likely add support for this and any other interesting issues 
> that remain.


Cool :-) I gave hrdstop a try (wip at https://reviews.llvm.org/D49496) but kind 
of got stuck and haven't had time to become unstuck. If you get to it first, 
maybe the wip patch is useful (or not).

It looks like your change did break using /P together with /Yu: 
https://bugs.llvm.org/show_bug.cgi?id=38508


Repository:
  rC Clang

https://reviews.llvm.org/D46652



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like keys

2018-08-10 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

I'm only a beginner, but here are some things that caught my eye. I really like 
the idea! :)




Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:28
+
+// PointerSortingVisitor class.
+class PointerSortingVisitor : public StmtVisitor {

This comment holds little value.



Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:46
+};
+}
+

` // end of anonymous namespace`



Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:88
+
+  if (!II->getName().equals("sort"))
+return;

whisperity wrote:
> Brrr... `equals`. StringRef has a `==` and `!=` operator which accepts string 
> literals on the other side, which would result in a more concise code.
> 
> Also, this heuristic can be applied without extra changes (apart from those 
> mentioned by NoQ and might be mentioned later by others) to other sorting 
> functions, such as `std::stable_sort` and `std::stable_partition`. Perhaps it 
> would be worthy to enable checking those functions too.
Maybe `II->isStr("sort")`?



Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:93
+  const RecordDecl *RD =
+IterTy->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
+

Is there a reason for not directly acquiring the record declaration?



Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:119
+};
+}
+

` // end of anonymous namespace`



Comment at: test/Analysis/ptr-sort.cpp:1
+// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.nondeterminism.PointerSorting %s -analyzer-output=text 
-verify
+

Always run the core checkers too.
`-analyzer-checker=core,alpha.nondeterminism.PointerSorting`


Repository:
  rC Clang

https://reviews.llvm.org/D50488



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


[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-10 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 160096.
deannagarcia marked 7 inline comments as done.

https://reviews.llvm.org/D50389

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationDivisionCheck.cpp
  clang-tidy/abseil/DurationDivisionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-division.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-division.cpp

Index: test/clang-tidy/abseil-duration-division.cpp
===
--- test/clang-tidy/abseil-duration-division.cpp
+++ test/clang-tidy/abseil-duration-division.cpp
@@ -0,0 +1,75 @@
+// RUN: %check_clang_tidy %s abseil-duration-division %t
+
+namespace absl {
+
+class Duration {};
+
+int operator/(Duration lhs, Duration rhs);
+
+double FDivDuration(Duration num, Duration den);
+
+}  // namespace absl
+
+void TakesInt(int);
+void TakesDouble(double);
+template 
+void TakesGeneric(T);
+
+absl::Duration d;
+
+#define MACRO_EQ(x, y) (x == y)
+#define MACRO_DIVEQ(x,y,z) (x/y == z)
+#define CHECK(x) (x)
+
+
+void Positives() {
+  const double num_double = d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:30: warning: operator/ on absl::Duration objects performs integer division; did you mean to use FDivDuration()? [abseil-duration-division]
+  // CHECK-FIXES: const double num_double = absl::FDivDuration(d, d);
+  const float num_float = d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: const float num_float = absl::FDivDuration(d, d);
+  const auto SomeVal = 1.0 + d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: const auto SomeVal = 1.0 + absl::FDivDuration(d, d);
+  if (MACRO_EQ(d/d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: if (MACRO_EQ(absl::FDivDuration(d, d), 0.0)) {}
+  if (CHECK(MACRO_EQ(d/d, 0.0))) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: if (CHECK(MACRO_EQ(absl::FDivDuration(d, d), 0.0))) {}
+
+  // This one generates a message, but no fix.
+  if (MACRO_DIVEQ(d, d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: if (MACRO_DIVEQ(d, d, 0.0)) {}
+ 
+  TakesDouble(d/d);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: TakesDouble(absl::FDivDuration(d, d));
+}
+
+template 
+double DoubleDivision(T t1, T t2) {return t1/t2;}
+
+void AnotherPositive() {
+  DoubleDivision(d, d);
+  // CHECK-MESSAGES: [[@LINE-4]]:45: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: double DoubleDivision(T t1, T t2) {return
+  // absl::FDivDuration(t1, t2);}
+}
+
+void Negatives() {
+  const int num_int = d/d;
+  const long num_long = d/d;
+  const short num_short = d/d;
+  const char num_char = d/d;
+  const auto num_auto = d/d;
+  const auto SomeVal = 1 + d/d;
+
+  TakesInt(d/d);
+  TakesGeneric(d/d);
+  // Explicit cast should disable the warning.
+  const double num_cast1 = static_cast(d/d);
+  const double num_cast2 = (double)(d/d);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-duration-division
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-duration-division.rst
===
--- docs/clang-tidy/checks/abseil-duration-division.rst
+++ docs/clang-tidy/checks/abseil-duration-division.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - abseil-duration-division
+  
+abseil-duration-division
+
+
+``absl::Duration`` arithmetic works like it does with integers. That means that
+division of two ``absl::Duration`` objects returns an ``int64`` with any fractional
+component truncated toward 0. See `this link `_ for more information on arithmetic with ``absl::Duration``.
+
+For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ int64 sec1 = d / absl::Seconds(1); // Truncates toward 0.
+ int64 sec2 = absl::ToInt64Seconds(d);  // Equivalent to division.
+ assert(sec1 == 3 && sec2 == 3);
+
+ double dsec = d / absl::Seconds(1);  // WRONG: Still truncates toward 0.
+ assert(dsec == 3.0);
+
+If you want floating-point division, you should use either the
+``absl::FDivDuration()`` function, or one of the unit conversion functions such
+as ``absl::ToDoubleSeconds()``. For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ double dsec1 = absl::FDivDuration(d, absl::Seconds

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.



> The downside of this approach is that LLVM doesn't recognize these function 
> calls and doesn't perform optimizations to fold libcalls. For example `pow(a, 
> 2)` is transformed into a multiplication but `__nv_pow(a, 2)` is not.

Doesn't CUDA have the same problem?


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D50555: [clangd] Introduce scoring mechanism for SignatureInformations.

2018-08-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 160097.
kadircet marked 3 inline comments as done.
kadircet added a comment.
Herald added a subscriber: mgrang.

- Resolve discussions.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50555

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

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1438,6 +1438,28 @@
   }
 }
 
+TEST(SignatureHelpTest, OverloadsOrdering) {
+  const auto Results = signatures(R"cpp(
+void foo(int x);
+void foo(int x, float y);
+void foo(float x, int y);
+void foo(float x, float y);
+void foo(int x, int y = 0);
+int main() { foo(^); }
+  )cpp");
+  EXPECT_THAT(
+  Results.signatures,
+  ElementsAre(
+  Sig("foo(int x) -> void", {"int x"}),
+  Sig("foo(int x, int y = 0) -> void", {"int x", "int y = 0"}),
+  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
+  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
+  Sig("foo(float x, float y) -> void", {"float x", "float y"})));
+  // We always prefer the first signature.
+  EXPECT_EQ(0, Results.activeSignature);
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/Quality.h
===
--- clangd/Quality.h
+++ clangd/Quality.h
@@ -163,6 +163,16 @@
 /// LSP. (The highest score compares smallest so it sorts at the top).
 std::string sortText(float Score, llvm::StringRef Tiebreak = "");
 
+struct SignatureQualitySignals {
+  uint32_t NumberOfParameters = 0;
+  uint32_t NumberOfOptionalParameters = 0;
+  bool ContainsActiveParameter = false;
+  CodeCompleteConsumer::OverloadCandidate::CandidateKind Kind =
+  CodeCompleteConsumer::OverloadCandidate::CandidateKind::CK_Function;
+};
+llvm::raw_ostream &operator<<(llvm::raw_ostream &,
+  const SignatureQualitySignals &);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/Quality.cpp
===
--- clangd/Quality.cpp
+++ clangd/Quality.cpp
@@ -401,5 +401,17 @@
   return S;
 }
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
+  const SignatureQualitySignals &S) {
+  OS << formatv("=== Signature Quality:\n");
+  OS << formatv("\tNumber of parameters: {0}\n", S.NumberOfParameters);
+  OS << formatv("\tNumber of optional parameters: {0}\n",
+S.NumberOfOptionalParameters);
+  OS << formatv("\tContains active parameter: {0}\n",
+S.ContainsActiveParameter);
+  OS << formatv("\tKind: {0}\n", S.Kind);
+  return OS;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -128,16 +128,16 @@
 /// Get the optional chunk as a string. This function is possibly recursive.
 ///
 /// The parameter info for each parameter is appended to the Parameters.
-std::string
-getOptionalParameters(const CodeCompletionString &CCS,
-  std::vector &Parameters) {
+std::string getOptionalParameters(const CodeCompletionString &CCS,
+  std::vector &Parameters,
+  SignatureQualitySignals &Signal) {
   std::string Result;
   for (const auto &Chunk : CCS) {
 switch (Chunk.Kind) {
 case CodeCompletionString::CK_Optional:
   assert(Chunk.Optional &&
  "Expected the optional code completion string to be non-null.");
-  Result += getOptionalParameters(*Chunk.Optional, Parameters);
+  Result += getOptionalParameters(*Chunk.Optional, Parameters, Signal);
   break;
 case CodeCompletionString::CK_VerticalSpace:
   break;
@@ -153,6 +153,8 @@
   ParameterInformation Info;
   Info.label = Chunk.Text;
   Parameters.push_back(std::move(Info));
+  Signal.ContainsActiveParameter = true;
+  Signal.NumberOfOptionalParameters++;
   break;
 }
 default:
@@ -679,6 +681,41 @@
   llvm::unique_function ResultsCallback;
 };
 
+using ScoredSignature =
+std::pair;
+struct ScoredSignatureGreater {
+  bool operator()(const ScoredSignature &L, const ScoredSignature &R) {
+// Ordering follows:
+// - Less number of parameters is better.
+// - Function is better than FunctionType which is better than Function
+// Template.
+// - High score is better.
+// - Shorter signature is better.
+// - Alphebatically smaller is better.
+if (L.first.NumberOfParameters != R.first.NumberOfParameters)
+  return L.first.NumberOfParameters < R.first.NumberOfParameters;
+if (L.first.NumberOfOpti

[PATCH] D50543: [libcxx] Mark charconv tests as failing for previous libcxx versions.

2018-08-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

Ship it!


https://reviews.llvm.org/D50543



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


[libcxx] r339431 - [libc++] Enable aligned allocation based on feature test macro, irrespective of standard

2018-08-10 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Fri Aug 10 06:24:56 2018
New Revision: 339431

URL: http://llvm.org/viewvc/llvm-project?rev=339431&view=rev
Log:
[libc++] Enable aligned allocation based on feature test macro, irrespective of 
standard

Summary:
The current code enables aligned allocation functions when compiling in C++17
and later. This is a problem because aligned allocation functions might not
be supported on the target platform, which leads to an error at link time.

Since r338934, Clang knows not to define __cpp_aligned_new when it's not
available on the target platform -- this commit takes advantage of that to
only use aligned allocation functions when they are available.

Reviewers: vsapsai, EricWF

Subscribers: christof, dexonsmith, cfe-commits, EricWF, mclow.lists

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

Added:
libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/new

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=339431&r1=339430&r2=339431&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Aug 10 06:24:56 2018
@@ -988,6 +988,11 @@ template  struct __static_asse
 #  endif
 #endif // defined(__APPLE__)
 
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
+!defined(_LIBCPP_BUILDING_LIBRARY) && \
+(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
+#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
 
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #define _LIBCPP_HAS_DEFAULTRUNELOCALE

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=339431&r1=339430&r2=339431&view=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Fri Aug 10 06:24:56 2018
@@ -108,13 +108,6 @@ void  operator delete[](void* ptr, void*
 # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
-(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \
-(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606)))
-# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#endif
-
-
 #if !__has_builtin(__builtin_operator_new) || \
__has_builtin(__builtin_operator_new) < 201802L || \
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \

Added: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp?rev=339431&view=auto
==
--- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp Fri Aug 
10 06:24:56 2018
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+#include 
+
+
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#   error "libc++ should have aligned allocation in C++17 and up when 
targeting a platform that supports it"
+#endif
+
+int main() { }


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


[PATCH] D50344: [libc++] Enable aligned allocation based on feature test macro, irrespective of standard

2018-08-10 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ldionne marked an inline comment as done.
Closed by commit rL339431: [libc++] Enable aligned allocation based on feature 
test macro, irrespective of… (authored by ldionne, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50344?vs=159903&id=160100#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50344

Files:
  libcxx/trunk/include/__config
  libcxx/trunk/include/new
  libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -988,6 +988,11 @@
 #  endif
 #endif // defined(__APPLE__)
 
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
+!defined(_LIBCPP_BUILDING_LIBRARY) && \
+(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
+#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
 
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
Index: libcxx/trunk/include/new
===
--- libcxx/trunk/include/new
+++ libcxx/trunk/include/new
@@ -108,13 +108,6 @@
 # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
-(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \
-(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606)))
-# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#endif
-
-
 #if !__has_builtin(__builtin_operator_new) || \
__has_builtin(__builtin_operator_new) < 201802L || \
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
Index: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
===
--- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
+++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+#include 
+
+
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#   error "libc++ should have aligned allocation in C++17 and up when 
targeting a platform that supports it"
+#endif
+
+int main() { }


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -988,6 +988,11 @@
 #  endif
 #endif // defined(__APPLE__)
 
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
+!defined(_LIBCPP_BUILDING_LIBRARY) && \
+(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
+#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
 
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
Index: libcxx/trunk/include/new
===
--- libcxx/trunk/include/new
+++ libcxx/trunk/include/new
@@ -108,13 +108,6 @@
 # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
-(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \
-(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606)))
-# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#endif
-
-
 #if !__has_builtin(__builtin_operator_new) || \
__has_builtin(__builtin_operator_new) < 201802L || \
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
Index: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
===
--- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
+++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_

[PATCH] D50559: [gnu-objc] Make selector order deterministic.

2018-08-10 Thread David Chisnall via Phabricator via cfe-commits
theraven created this revision.
theraven added a reviewer: rjmccall.
Herald added subscribers: cfe-commits, mgrang.

This probably fixes PR35277, though there may be other sources of
nondeterminism (this was the only case of iterating over a DenseMap).

It's difficult to provide a test case for this, because it shows up only
on systems with ASLR enabled.


Repository:
  rC Clang

https://reviews.llvm.org/D50559

Files:
  lib/CodeGen/CGObjCGNU.cpp


Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -3541,12 +3541,16 @@
 ConstantInitBuilder builder(CGM);
 auto selectors = builder.beginArray(selStructTy);
 auto &table = SelectorTable; // MSVC workaround
-for (auto &entry : table) {
+std::vector allSelectors;
+for (auto &entry : table)
+  allSelectors.push_back(entry.first);
+llvm::sort(allSelectors.begin(), allSelectors.end());
 
-  std::string selNameStr = entry.first.getAsString();
+for (auto &untypedSel : allSelectors) {
+  std::string selNameStr = untypedSel.getAsString();
   llvm::Constant *selName = ExportUniqueString(selNameStr, 
".objc_sel_name");
 
-  for (TypedSelector &sel : entry.second) {
+  for (TypedSelector &sel : table[untypedSel]) {
 llvm::Constant *selectorTypeEncoding = NULLPtr;
 if (!sel.first.empty())
   selectorTypeEncoding =


Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -3541,12 +3541,16 @@
 ConstantInitBuilder builder(CGM);
 auto selectors = builder.beginArray(selStructTy);
 auto &table = SelectorTable; // MSVC workaround
-for (auto &entry : table) {
+std::vector allSelectors;
+for (auto &entry : table)
+  allSelectors.push_back(entry.first);
+llvm::sort(allSelectors.begin(), allSelectors.end());
 
-  std::string selNameStr = entry.first.getAsString();
+for (auto &untypedSel : allSelectors) {
+  std::string selNameStr = untypedSel.getAsString();
   llvm::Constant *selName = ExportUniqueString(selNameStr, ".objc_sel_name");
 
-  for (TypedSelector &sel : entry.second) {
+  for (TypedSelector &sel : table[untypedSel]) {
 llvm::Constant *selectorTypeEncoding = NULLPtr;
 if (!sel.first.empty())
   selectorTypeEncoding =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49240: [libc++] Introduce _LIBCPP_HIDE_FROM_ABI to replace _LIBCPP_INLINE_VISIBILITY

2018-08-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D49240#1195125, @thakis wrote:

> When we updated out clang bundle in chromium (which includes libc++ headers), 
> our ios simulator bots regressed debug info size by ~50% due to this commit 
> (https://bugs.chromium.org/p/chromium/issues/detail?id=872926#c13). Is that 
> expected?


No, this is quite surprising. What happened with the size of the Release 
builds? We should investigate, perhaps this change exposed something in Clang's 
debug info generation.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49240



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


[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.



>   I don't want to use a fast `pow(a, 2)`, I don't want to call a library 
> function for that at all.

I do believe you won't end up calling a function. If you're compiling with 
optimizations on this will be inlined.


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[clang-tools-extra] r339433 - [clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro

2018-08-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Aug 10 06:59:33 2018
New Revision: 339433

URL: http://llvm.org/viewvc/llvm-project?rev=339433&view=rev
Log:
[clang-tidy: modernize] modernize-redundant-void-arg crashes when a function 
body is in a macro

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

Patch by IdrissRio.

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=339433&r1=339432&r2=339433&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Fri 
Aug 10 06:59:33 2018
@@ -149,6 +149,8 @@ void RedundantVoidArgCheck::removeVoidAr
   ProtoToken.getRawIdentifier() == "void") {
 State = SawVoid;
 VoidToken = ProtoToken;
+  } else if (ProtoToken.is(tok::TokenKind::l_paren)) {
+State = SawLeftParen;
   } else {
 State = NothingYet;
   }
@@ -235,10 +237,11 @@ void RedundantVoidArgCheck::processLambd
 const MatchFinder::MatchResult &Result, const LambdaExpr *Lambda) {
   if (Lambda->getLambdaClass()->getLambdaCallOperator()->getNumParams() == 0 &&
   Lambda->hasExplicitParameters()) {
-SourceLocation Begin =
-Lambda->getIntroducerRange().getEnd().getLocWithOffset(1);
-SourceLocation End = Lambda->getBody()->getBeginLoc().getLocWithOffset(-1);
-removeVoidArgumentTokens(Result, SourceRange(Begin, End),
+SourceManager *SM = Result.SourceManager;
+TypeLoc TL = Lambda->getLambdaClass()->getLambdaTypeInfo()->getTypeLoc();
+removeVoidArgumentTokens(Result,
+ {SM->getSpellingLoc(TL.getBeginLoc()),
+  SM->getSpellingLoc(TL.getEndLoc())},
  "lambda expression");
   }
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=339433&r1=339432&r2=339433&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
Fri Aug 10 06:59:33 2018
@@ -445,3 +445,46 @@ struct DefinitionWithNoBody {
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} in function definition
   // CHECK-FIXES: DefinitionWithNoBody() = delete;
 };
+
+
+
+#define BODY {}
+#define LAMBDA1 [](void){}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA1 [](){}
+
+#define LAMBDA2 [](void)BODY
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA2 []()BODY
+
+#define LAMBDA3(captures, args, body) captures args body
+#define WRAP(...) __VA_ARGS__
+
+#define LAMBDA4 (void)LAMBDA3([],(void),BODY)
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA4 (void)LAMBDA3([],(),BODY)
+
+#define LAMBDA5 []() -> void (*)(void) {return BODY;}
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA5 []() -> void (*)() {return BODY;}
+void lambda_expression_with_macro_test(){
+  (void)LAMBDA1;
+  (void)LAMBDA2;
+  (void)LAMBDA3([], (void), BODY);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: (void)LAMBDA3([], (), BODY);
+
+  LAMBDA4;
+  LAMBDA5;
+  WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP((void)), WRAP(BODY);
+  // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP(()), 
WRAP(BODY);
+
+  (void)WRAP([](void) {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: (void)WRAP([]() {});
+
+  [](void) BODY;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: []() BODY;
+}


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

[PATCH] D49800: [clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro

2018-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339433: [clang-tidy: modernize] modernize-redundant-void-arg 
crashes when a function… (authored by alexfh, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49800?vs=160039&id=160103#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49800

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -445,3 +445,46 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} in function definition
   // CHECK-FIXES: DefinitionWithNoBody() = delete;
 };
+
+
+
+#define BODY {}
+#define LAMBDA1 [](void){}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA1 [](){}
+
+#define LAMBDA2 [](void)BODY
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA2 []()BODY
+
+#define LAMBDA3(captures, args, body) captures args body
+#define WRAP(...) __VA_ARGS__
+
+#define LAMBDA4 (void)LAMBDA3([],(void),BODY)
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA4 (void)LAMBDA3([],(),BODY)
+
+#define LAMBDA5 []() -> void (*)(void) {return BODY;}
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+// CHECK-FIXES: LAMBDA5 []() -> void (*)() {return BODY;}
+void lambda_expression_with_macro_test(){
+  (void)LAMBDA1;
+  (void)LAMBDA2;
+  (void)LAMBDA3([], (void), BODY);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: (void)LAMBDA3([], (), BODY);
+
+  LAMBDA4;
+  LAMBDA5;
+  WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP((void)), WRAP(BODY);
+  // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP(()), 
WRAP(BODY);
+
+  (void)WRAP([](void) {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: (void)WRAP([]() {});
+
+  [](void) BODY;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
+  // CHECK-FIXES: []() BODY;
+}
Index: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -149,6 +149,8 @@
   ProtoToken.getRawIdentifier() == "void") {
 State = SawVoid;
 VoidToken = ProtoToken;
+  } else if (ProtoToken.is(tok::TokenKind::l_paren)) {
+State = SawLeftParen;
   } else {
 State = NothingYet;
   }
@@ -235,10 +237,11 @@
 const MatchFinder::MatchResult &Result, const LambdaExpr *Lambda) {
   if (Lambda->getLambdaClass()->getLambdaCallOperator()->getNumParams() == 0 &&
   Lambda->hasExplicitParameters()) {
-SourceLocation Begin =
-Lambda->getIntroducerRange().getEnd().getLocWithOffset(1);
-SourceLocation End = Lambda->getBody()->getBeginLoc().getLocWithOffset(-1);
-removeVoidArgumentTokens(Result, SourceRange(Begin, End),
+SourceManager *SM = Result.SourceManager;
+TypeLoc TL = Lambda->getLambdaClass()->getLambdaTypeInfo()->getTypeLoc();
+removeVoidArgumentTokens(Result,
+ {SM->getSpellingLoc(TL.getBeginLoc()),
+  SM->getSpellingLoc(TL.getEndLoc())},
  "lambda expression");
   }
 }


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -445,3 +445,46 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} in function definition
   // CHECK-FIXES: DefinitionWithNoBody() = delete;
 };
+
+
+
+#define BODY {}
+#define LAMBDA1 [](void){}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]

[PATCH] D49800: [clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro

2018-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I've fixed the comments and committed the patch myself. Hope that's fine by you.


Repository:
  rL LLVM

https://reviews.llvm.org/D49800



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like keys

2018-08-10 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

The basics of the heuristics look okay as comparing pointers from 
non-continuous block of memory is undefined, it would be worthy to check if no 
compiler warning (perhaps by specifying `-W -Wall -Wextra -Weverything` and 
various others of these enable-all flags!) is emitted if `std::sort` is 
instantiated for such a use case.

There is a chance for a serious false positive with the current approach! One 
thing which you should add as a **FIXME**, and implement in a follow-up patch. 
Using `std::sort`, `std::unique` and then `erase` is common technique for 
deduplicating a container (which in some cases might even be quicker than 
using, let's say `std::set` ). In 
case my container contains arbitrary memory addresses (e.g. multiple things 
give me different stuff but might give the same thing multiple times) which I 
don't want to do things with more than once, I might use 
`sort`-`unique`-`erase` and the `sort` call will emit a report.


Repository:
  rC Clang

https://reviews.llvm.org/D50488



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


[PATCH] D50555: [clangd] Introduce scoring mechanism for SignatureInformations.

2018-08-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 with a few NITs




Comment at: clangd/CodeComplete.cpp:687
+struct ScoredSignatureGreater {
+  bool operator()(const ScoredSignature &L, const ScoredSignature &R) {
+// Ordering follows:

NIT: Maybe make it a function with a descriptive name, e.g. 
`hasBetterSignature`?
We could call it in a lambda, should make the code even clearer.



Comment at: clangd/CodeComplete.cpp:755
+  ScoredSignatureGreater());
+for (const auto &SS : ScoredSignatures) {
+  SigHelp.signatures.push_back(SS.second);

NIT: remove braces around the single-statement loop body


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50555



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


[PATCH] D50443: [clang] Store code completion token range in preprocessor.

2018-08-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, but let's land together with a dependent revision to hove some code that 
actually tests it.




Comment at: include/clang/Lex/Preprocessor.h:313
 
+  /// Range for the code completion taken.
+  SourceRange CodeCompletionTokenRange;

NIT: s/taken/token


Repository:
  rC Clang

https://reviews.llvm.org/D50443



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


[PATCH] D50443: [clang] Store code completion token range in preprocessor.

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

NIT: maybe also note the number of the clangd revision in this change's 
description


Repository:
  rC Clang

https://reviews.llvm.org/D50443



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


[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/DurationDivisionCheck.cpp:29
+  hasSourceExpression(ignoringParenCasts(cxxOperatorCallExpr(
+  hasOverloadedOperatorName("/"), argumentCountIs(2),
+  hasArgument(0, expr(IsDuration)),

The `argumentCountIs` should be redundant, not? Operator/ has always two 
operands and must be overloaded as an binary operator.



Comment at: clang-tidy/abseil/DurationDivisionCheck.cpp:31
+  hasArgument(0, expr(IsDuration)),
+  hasArgument(1, expr(IsDuration)), expr().bind("OpCall",
+  hasImplicitDestinationType(qualType(unless(isInteger(,

I dont understand the `expr().bind`, you can directly bind to the 
cxxOperatorCallExpr. That should be equivalent.



Comment at: clang-tidy/abseil/DurationDivisionCheck.h:19
+
+// Find potential incorrect uses of integer division of absl::Duration objects.
+class DurationDivisionCheck : public ClangTidyCheck {

The common `For the user-facing documentation see: ` is missing here.
All clang-tidy checks do have this (as it is autogenerated by the add-check 
tool) so i think it would be better to stay consistent with it.


https://reviews.llvm.org/D50389



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


[PATCH] D50337: [clangd] DexIndex implementation prototype

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

Address most comments.


https://reviews.llvm.org/D50337

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/dex/DexIndex.cpp
  clang-tools-extra/clangd/index/dex/DexIndex.h
  clang-tools-extra/clangd/index/dex/Token.h
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp
  clang-tools-extra/unittests/clangd/IndexTests.cpp
  clang-tools-extra/unittests/clangd/TestIndexOperations.cpp
  clang-tools-extra/unittests/clangd/TestIndexOperations.h

Index: clang-tools-extra/unittests/clangd/TestIndexOperations.h
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TestIndexOperations.h
@@ -0,0 +1,57 @@
+//===-- IndexHelpers.h --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_INDEXTESTCOMMON_H
+#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_INDEXTESTCOMMON_H
+
+#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 {
+
+Symbol symbol(llvm::StringRef QName);
+
+struct SlabAndPointers {
+  SymbolSlab Slab;
+  std::vector Pointers;
+};
+
+// Create a slab of symbols with the given qualified names as both IDs and
+// names. The life time of the slab is managed by the returned shared pointer.
+// If \p WeakSymbols is provided, it will be pointed to the managed object in
+// the returned shared pointer.
+std::shared_ptr>
+generateSymbols(std::vector QualifiedNames,
+std::weak_ptr *WeakSymbols = nullptr);
+
+// Create a slab of symbols with IDs and names [Begin, End], otherwise identical
+// to the `generateSymbols` above.
+std::shared_ptr>
+generateNumSymbols(int Begin, int End,
+   std::weak_ptr *WeakSymbols = nullptr);
+
+std::string getQualifiedName(const Symbol &Sym);
+
+std::vector match(const SymbolIndex &I,
+   const FuzzyFindRequest &Req,
+   bool *Incomplete = nullptr);
+
+// Returns qualified names of symbols with any of IDs in the index.
+std::vector lookup(const SymbolIndex &I,
+llvm::ArrayRef IDs);
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/unittests/clangd/TestIndexOperations.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TestIndexOperations.cpp
@@ -0,0 +1,89 @@
+//===-- IndexHelpers.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestIndexOperations.h"
+
+namespace clang {
+namespace clangd {
+
+Symbol symbol(llvm::StringRef QName) {
+  Symbol Sym;
+  Sym.ID = SymbolID(QName.str());
+  size_t Pos = QName.rfind("::");
+  if (Pos == llvm::StringRef::npos) {
+Sym.Name = QName;
+Sym.Scope = "";
+  } else {
+Sym.Name = QName.substr(Pos + 2);
+Sym.Scope = QName.substr(0, Pos + 2);
+  }
+  return Sym;
+}
+
+// Create a slab of symbols with the given qualified names as both IDs and
+// names. The life time of the slab is managed by the returned shared pointer.
+// If \p WeakSymbols is provided, it will be pointed to the managed object in
+// the returned shared pointer.
+std::shared_ptr>
+generateSymbols(std::vector QualifiedNames,
+std::weak_ptr *WeakSymbols) {
+  SymbolSlab::Builder Slab;
+  for (llvm::StringRef QName : QualifiedNames)
+Slab.insert(symbol(QName));
+
+  auto Storage = std::make_shared();
+  Storage->Slab = std::move(Slab).build();
+  for (const auto &Sym : Storage->Slab)
+Storage->Pointers.push_back(&Sym);
+  if (WeakSymbols)
+*WeakSymbols = Storage;
+  auto *Pointers = &Storage->Pointers;
+  return {std::move(Storage), Pointers};
+}
+
+// Create a slab of symbols with IDs and names [Begin, End], otherwise identical
+// to the `generateSymbols` above.
+std::shared_ptr>
+generateNumSymbols(int Begin, int End,
+   std::weak_ptr *WeakSymbols) {
+  std::vector Names;
+  for (int i = Begin; i <= End; i++)
+Names.push_back(std::to_string(i));
+  return generateSymbols(Names, WeakSymbols);
+}
+
+std::string getQualifiedName(const Symbol &Sym) {
+  return (Sym.Scope + Sym.Name)

[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:33
+
+void insertChars(DenseSet &UniqueTrigrams, std::string Chars) {
+  const auto Trigram = Token(Token::Kind::Trigram, Chars);

This is probably neater as a lambda in `generateIdentifierTrigrams `, e.g.

```
auto add = [&](std::string Chars) {
  trigrams.insert(Token(Token::Kind::Trigram, Chars));
}
...
add("abc"); 
```



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:95
+
+  // Generate trigrams only if the first character is the segment start.
+  // Example: "StringStartsWith" would yield "st$", "ss$" but not "tr$".

Do you mean *bigrams* here?



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:96
+  // Generate trigrams only if the first character is the segment start.
+  // Example: "StringStartsWith" would yield "st$", "ss$" but not "tr$".
+  if (Roles[I] == Head) {

Should we also check `Roles[J] == Head `?

As bigram posting lists would be significantly larger than those of trigrams, I 
would suggest being even more restrictive. For example, for "AppleBananaCat", 
the most common short queries would be "ap" and "ab" (for `AB`).



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:119
 
-// FIXME(kbobyrev): Similarly, to generateIdentifierTrigrams, this ignores 
short
-// inputs (total segment length <3 characters).
+// FIXME(kbobyrev): Correctly handle cases like "u_". In this case, we would
+// like to match "u" only. This might also work better with word bounds for

Couldn't we generate a bigram "u_$" in this case? I think we can assume prefix 
matching in this case, if we generate bigram "u_" for identiifers like "u_*".

> In this case, we would like to match "u" only.
Why? If user types "_", I would expect it to be a meaning filter. 



Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:141
+  // sufficient, generate a single incomplete trigram for query.
+  if (ValidSymbolsCount < 3) {
+std::string Symbols = {{END_MARKER, END_MARKER, END_MARKER}};

For queries like `__` or `_x`,  I think we can generate tokens "__$" or `_x$`. 



Comment at: clang-tools-extra/clangd/index/dex/Trigram.h:49
+/// result. Incomplete trigrams contain END_MARKER ('$') at the end. The result
+/// also contains bigrams which are either two subsequent Head symbols or Head
+/// and subsequent Tail. This means that for short queries Dex index would do

nit: the term "symbol" here is confusing. Do you mean "character"?



Comment at: clang-tools-extra/clangd/index/dex/Trigram.h:59
+/// * Bigram with the first two symbols (if availible), same logic applies.
+///
 /// Note: the returned list of trigrams does not have duplicates, if any 
trigram

I think the comment can be simplified a bit:
```
This also generates incomplete trigrams for short query scenarios:
  * Empty trigram: "$$$"
  * Unigram: the first character of the identifier.
  * Bigrams: a 2-char prefix of the identifier and a bigram of the first two 
HEAD characters (if it exists).
```


https://reviews.llvm.org/D50517



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


[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2018-08-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 160106.
lebedev.ri added a comment.

Rebase (ugh, bitrot), port `test/clang-tidy/hicpp-exception-baseclass.cpp`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36892

Files:
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/hicpp-exception-baseclass.cpp

Index: test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- test/clang-tidy/hicpp-exception-baseclass.cpp
+++ test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -20,28 +20,28 @@
 void problematic() {
   try {
 throw int(42);
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   } catch (int e) {
   }
   throw int(42);
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
 
   try {
 throw 12;
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   } catch (...) {
 throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object.
   }
 
   try {
 throw non_derived_exception();
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 9:1: note: type defined here
   } catch (non_derived_exception &e) {
   }
   throw non_derived_exception();
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK-MESSAGES: 9:1: note: type defined here
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+  // CHECK-NOTES: 9:1: note: type defined here
 
 // FIXME: More complicated kinds of inheritance should be checked later, but there is
 // currently no way use ASTMatchers for this kind of task.
@@ -100,15 +100,15 @@
 // Templated function that throws exception based on template type
 template 
 void ThrowException() { throw T(); }
-// CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
-// CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
-// CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 123:1: note: type defined here
-// CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-// CHECK-MESSAGES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-NOTES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 120:1: note: type defined here
+// CHECK-NOTES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 120:1: note: type defined here
+// CHECK-NOTES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 123:1: note: type defined here
+// CHECK-NOTES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 9:1: note: type defined here
 #define THROW_EXCEPTION(CLASS) ThrowException()
 #define THROW_BAD_EXCEPTION throw int(42);
 #define THROW_GOOD_EXCEPTION throw std::exception();
@@ -134,25 +134,28 @@
   THROW_EXCEPTION(deep_hierarchy);// Ok
 
   THROW_BAD_EXCEPTION;
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-  // CHECK-MESSAGES: [[@LINE-25]]:35: note: expanded from macro 'THROW_BAD_EXCEPTION'
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived f

[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2018-08-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 160107.
lebedev.ri added a comment.

Add docs note.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36892

Files:
  docs/clang-tidy/index.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/hicpp-exception-baseclass.cpp

Index: test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- test/clang-tidy/hicpp-exception-baseclass.cpp
+++ test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -20,28 +20,28 @@
 void problematic() {
   try {
 throw int(42);
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   } catch (int e) {
   }
   throw int(42);
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
 
   try {
 throw 12;
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   } catch (...) {
 throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object.
   }
 
   try {
 throw non_derived_exception();
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 9:1: note: type defined here
   } catch (non_derived_exception &e) {
   }
   throw non_derived_exception();
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK-MESSAGES: 9:1: note: type defined here
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+  // CHECK-NOTES: 9:1: note: type defined here
 
 // FIXME: More complicated kinds of inheritance should be checked later, but there is
 // currently no way use ASTMatchers for this kind of task.
@@ -100,15 +100,15 @@
 // Templated function that throws exception based on template type
 template 
 void ThrowException() { throw T(); }
-// CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
-// CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
-// CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 123:1: note: type defined here
-// CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-// CHECK-MESSAGES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-NOTES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 120:1: note: type defined here
+// CHECK-NOTES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 120:1: note: type defined here
+// CHECK-NOTES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 123:1: note: type defined here
+// CHECK-NOTES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+// CHECK-NOTES: 9:1: note: type defined here
 #define THROW_EXCEPTION(CLASS) ThrowException()
 #define THROW_BAD_EXCEPTION throw int(42);
 #define THROW_GOOD_EXCEPTION throw std::exception();
@@ -134,25 +134,28 @@
   THROW_EXCEPTION(deep_hierarchy);// Ok
 
   THROW_BAD_EXCEPTION;
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-  // CHECK-MESSAGES: [[@LINE-25]]:35: note: expanded from macro 'THROW_BAD_EXCEPTION'
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+  // CHECK-

[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

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

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36892



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


[clang-tools-extra] r339437 - [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2018-08-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Aug 10 08:05:46 2018
New Revision: 339437

URL: http://llvm.org/viewvc/llvm-project?rev=339437&view=rev
Log:
[clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

Summary:
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with 
`warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to 
be checked.
This was useful for me when developing D36836.

Reviewers: alexfh, klimek, aaron.ballman, hokein

Reviewed By: alexfh, aaron.ballman

Subscribers: JonasToth, JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=339437&r1=339436&r2=339437&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Fri Aug 10 08:05:46 2018
@@ -650,7 +650,8 @@ clang-tidy tests.
 
 An additional check enabled by ``check_clang_tidy.py`` ensures that
 if `CHECK-MESSAGES:` is used in a file then every warning or error
-must have an associated CHECK in that file.
+must have an associated CHECK in that file. Or, you can use ``CHECK-NOTES:``
+instead, if you want to **also** ensure that all the notes are checked.
 
 To use the ``check_clang_tidy.py`` script, put a .cpp file with the
 appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=339437&r1=339436&r2=339437&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Fri Aug 10 
08:05:46 2018
@@ -78,6 +78,7 @@ def main():
   file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
   check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
   check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+  check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
@@ -91,9 +92,11 @@ def main():
 
   has_check_fixes = check_fixes_prefix in input_text
   has_check_messages = check_messages_prefix in input_text
+  has_check_notes = check_notes_prefix in input_text
 
-  if not has_check_fixes and not has_check_messages:
-sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, 
check_messages_prefix) )
+  if not has_check_fixes and not has_check_messages and not has_check_notes:
+sys.exit('%s, %s or %s not found in the input' % (check_fixes_prefix,
+ check_messages_prefix, check_notes_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -154,6 +157,19 @@ def main():
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
   print('FileCheck failed:\n' + e.output.decode())
+  raise
+
+  if has_check_notes:
+notes_file = temp_file_name + '.notes'
+write_file(notes_file, clang_tidy_output)
+try:
+  subprocess.check_output(
+  ['FileCheck', '-input-file=' + notes_file, input_file_name,
+   '-check-prefix=' + check_notes_prefix,
+   '-implicit-check-not={{note|warning|error}}:'],
+  stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+  print('FileCheck failed:\n' + e.output.decode())
   raise
 
 if __name__ == '__main__':

Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp?rev=339437&r1=339436&r2=339437&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp Fri 
Aug 10 08:05:46 2018
@@ -20,28 +20,28 @@ class really_creative : public non_deriv
 void problematic() {
   try {
 throw int(42);
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose 
type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning

[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-10 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 160109.
deannagarcia marked 3 inline comments as done.

https://reviews.llvm.org/D50389

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationDivisionCheck.cpp
  clang-tidy/abseil/DurationDivisionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-division.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-division.cpp

Index: test/clang-tidy/abseil-duration-division.cpp
===
--- test/clang-tidy/abseil-duration-division.cpp
+++ test/clang-tidy/abseil-duration-division.cpp
@@ -0,0 +1,75 @@
+// RUN: %check_clang_tidy %s abseil-duration-division %t
+
+namespace absl {
+
+class Duration {};
+
+int operator/(Duration lhs, Duration rhs);
+
+double FDivDuration(Duration num, Duration den);
+
+}  // namespace absl
+
+void TakesInt(int);
+void TakesDouble(double);
+template 
+void TakesGeneric(T);
+
+absl::Duration d;
+
+#define MACRO_EQ(x, y) (x == y)
+#define MACRO_DIVEQ(x,y,z) (x/y == z)
+#define CHECK(x) (x)
+
+
+void Positives() {
+  const double num_double = d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:30: warning: operator/ on absl::Duration objects performs integer division; did you mean to use FDivDuration()? [abseil-duration-division]
+  // CHECK-FIXES: const double num_double = absl::FDivDuration(d, d);
+  const float num_float = d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: const float num_float = absl::FDivDuration(d, d);
+  const auto SomeVal = 1.0 + d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: const auto SomeVal = 1.0 + absl::FDivDuration(d, d);
+  if (MACRO_EQ(d/d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: if (MACRO_EQ(absl::FDivDuration(d, d), 0.0)) {}
+  if (CHECK(MACRO_EQ(d/d, 0.0))) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: if (CHECK(MACRO_EQ(absl::FDivDuration(d, d), 0.0))) {}
+
+  // This one generates a message, but no fix.
+  if (MACRO_DIVEQ(d, d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: if (MACRO_DIVEQ(d, d, 0.0)) {}
+ 
+  TakesDouble(d/d);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: TakesDouble(absl::FDivDuration(d, d));
+}
+
+template 
+double DoubleDivision(T t1, T t2) {return t1/t2;}
+
+void AnotherPositive() {
+  DoubleDivision(d, d);
+  // CHECK-MESSAGES: [[@LINE-4]]:45: warning: operator/ on absl::Duration objects
+  // CHECK-FIXES: double DoubleDivision(T t1, T t2) {return
+  // absl::FDivDuration(t1, t2);}
+}
+
+void Negatives() {
+  const int num_int = d/d;
+  const long num_long = d/d;
+  const short num_short = d/d;
+  const char num_char = d/d;
+  const auto num_auto = d/d;
+  const auto SomeVal = 1 + d/d;
+
+  TakesInt(d/d);
+  TakesGeneric(d/d);
+  // Explicit cast should disable the warning.
+  const double num_cast1 = static_cast(d/d);
+  const double num_cast2 = (double)(d/d);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-duration-division
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-duration-division.rst
===
--- docs/clang-tidy/checks/abseil-duration-division.rst
+++ docs/clang-tidy/checks/abseil-duration-division.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - abseil-duration-division
+  
+abseil-duration-division
+
+
+``absl::Duration`` arithmetic works like it does with integers. That means that
+division of two ``absl::Duration`` objects returns an ``int64`` with any fractional
+component truncated toward 0. See `this link `_ for more information on arithmetic with ``absl::Duration``.
+
+For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ int64 sec1 = d / absl::Seconds(1); // Truncates toward 0.
+ int64 sec2 = absl::ToInt64Seconds(d);  // Equivalent to division.
+ assert(sec1 == 3 && sec2 == 3);
+
+ double dsec = d / absl::Seconds(1);  // WRONG: Still truncates toward 0.
+ assert(dsec == 3.0);
+
+If you want floating-point division, you should use either the
+``absl::FDivDuration()`` function, or one of the unit conversion functions such
+as ``absl::ToDoubleSeconds()``. For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ double dsec1 = absl::FDivDuration(d, absl::Seconds

[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2018-08-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339437: [clang-tidy] check_clang_tidy.py: support 
CHECK-NOTES prefix (authored by lebedevri, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D36892?vs=160107&id=160108#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36892

Files:
  clang-tools-extra/trunk/docs/clang-tidy/index.rst
  clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp

Index: clang-tools-extra/trunk/docs/clang-tidy/index.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst
@@ -650,7 +650,8 @@
 
 An additional check enabled by ``check_clang_tidy.py`` ensures that
 if `CHECK-MESSAGES:` is used in a file then every warning or error
-must have an associated CHECK in that file.
+must have an associated CHECK in that file. Or, you can use ``CHECK-NOTES:``
+instead, if you want to **also** ensure that all the notes are checked.
 
 To use the ``check_clang_tidy.py`` script, put a .cpp file with the
 appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use
Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
@@ -78,6 +78,7 @@
   file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
   check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
   check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+  check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
@@ -91,9 +92,11 @@
 
   has_check_fixes = check_fixes_prefix in input_text
   has_check_messages = check_messages_prefix in input_text
+  has_check_notes = check_notes_prefix in input_text
 
-  if not has_check_fixes and not has_check_messages:
-sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) )
+  if not has_check_fixes and not has_check_messages and not has_check_notes:
+sys.exit('%s, %s or %s not found in the input' % (check_fixes_prefix,
+ check_messages_prefix, check_notes_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -156,5 +159,18 @@
   print('FileCheck failed:\n' + e.output.decode())
   raise
 
+  if has_check_notes:
+notes_file = temp_file_name + '.notes'
+write_file(notes_file, clang_tidy_output)
+try:
+  subprocess.check_output(
+  ['FileCheck', '-input-file=' + notes_file, input_file_name,
+   '-check-prefix=' + check_notes_prefix,
+   '-implicit-check-not={{note|warning|error}}:'],
+  stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+  print('FileCheck failed:\n' + e.output.decode())
+  raise
+
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -20,28 +20,28 @@
 void problematic() {
   try {
 throw int(42);
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   } catch (int e) {
   }
   throw int(42);
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
 
   try {
 throw 12;
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   } catch (...) {
 throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object.
   }
 
   try {
 throw non_derived_exception();
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
+// CHECK-

r339438 - [CodeGen] Merge equivalent block copy/helper functions.

2018-08-10 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Aug 10 08:09:24 2018
New Revision: 339438

URL: http://llvm.org/viewvc/llvm-project?rev=339438&view=rev
Log:
[CodeGen] Merge equivalent block copy/helper functions.

Clang generates copy and dispose helper functions for each block literal
on the stack. Often these functions are equivalent for different blocks.
This commit makes changes to merge equivalent copy and dispose helper
functions and reduce code size.

To enable merging equivalent copy/dispose functions, the captured object
infomation is encoded into the helper function name. This allows IRGen
to check whether an equivalent helper function has already been emitted
and reuse the function instead of generating a new helper function
whenever a block is defined. In addition, the helper functions are
marked as linkonce_odr to enable merging helper functions that have the
same name across translation units and marked as unnamed_addr to enable
the linker's deduplication pass to merge functions that have different
names but the same content.

rdar://problem/42640608

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

Added:
cfe/trunk/test/PCH/block-helpers.cpp
cfe/trunk/test/PCH/block-helpers.h
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBlocks.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGen/blocks-1.c
cfe/trunk/test/CodeGen/blocks.c
cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp
cfe/trunk/test/CodeGenCXX/blocks.cpp
cfe/trunk/test/CodeGenCXX/cxx-block-objects.cpp
cfe/trunk/test/CodeGenObjC/arc-blocks.m
cfe/trunk/test/CodeGenObjC/debug-info-block-helper.m
cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
cfe/trunk/test/CodeGenObjC/mrc-weak.m
cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m
cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm
cfe/trunk/test/CodeGenObjCXX/mrc-weak.mm

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=339438&r1=339437&r2=339438&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Aug 10 08:09:24 2018
@@ -22,6 +22,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -150,6 +151,22 @@ struct TypeInfo {
 /// Holds long-lived AST nodes (such as types and decls) that can be
 /// referred to throughout the semantic analysis of a file.
 class ASTContext : public RefCountedBase {
+public:
+  /// Copy initialization expr of a __block variable and a boolean flag that
+  /// indicates whether the expression can throw.
+  struct BlockVarCopyInit {
+BlockVarCopyInit() = default;
+BlockVarCopyInit(Expr *CopyExpr, bool CanThrow)
+: ExprAndFlag(CopyExpr, CanThrow) {}
+void setExprAndFlag(Expr *CopyExpr, bool CanThrow) {
+  ExprAndFlag.setPointerAndInt(CopyExpr, CanThrow);
+}
+Expr *getCopyExpr() const { return ExprAndFlag.getPointer(); }
+bool canThrow() const { return ExprAndFlag.getInt(); }
+llvm::PointerIntPair ExprAndFlag;
+  };
+
+private:
   friend class NestedNameSpecifier;
 
   mutable SmallVector Types;
@@ -244,8 +261,8 @@ class ASTContext : public RefCountedBase
   /// interface.
   llvm::DenseMap 
ObjCMethodRedecls;
 
-  /// Mapping from __block VarDecls to their copy initialization expr.
-  llvm::DenseMap BlockVarCopyInits;
+  /// Mapping from __block VarDecls to BlockVarCopyInit.
+  llvm::DenseMap BlockVarCopyInits;
 
   /// Mapping from class scope functions specialization to their
   /// template patterns.
@@ -2664,12 +2681,13 @@ public:
   /// otherwise returns null.
   const ObjCInterfaceDecl *getObjContainingInterface(const NamedDecl *ND) 
const;
 
-  /// Set the copy inialization expression of a block var decl.
-  void setBlockVarCopyInits(VarDecl*VD, Expr* Init);
+  /// Set the copy inialization expression of a block var decl. \p CanThrow
+  /// indicates whether the copy expression can throw or not.
+  void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
 
   /// Get the copy initialization expression of the VarDecl \p VD, or
   /// nullptr if none exists.
-  Expr *getBlockVarCopyInits(const VarDecl* VD);
+  BlockVarCopyInit getBlockVarC

[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-10 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339438: [CodeGen] Merge equivalent block copy/helper 
functions. (authored by ahatanak, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50152?vs=160053&id=160110#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm
  test/PCH/block-helpers.cpp
  test/PCH/block-helpers.h

Index: test/PCH/block-helpers.h
===
--- test/PCH/block-helpers.h
+++ test/PCH/block-helpers.h
@@ -0,0 +1,12 @@
+struct S0 {
+  S0();
+  S0(const S0 &) noexcept(false);
+  int a;
+};
+
+struct S {
+  void m() {
+__block S0 x, y;
+^{ (void)x; (void)y; };
+  }
+};
Index: test/PCH/block-helpers.cpp
===
--- test/PCH/block-helpers.cpp
+++ test/PCH/block-helpers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s
+
+// The second call to block_object_assign should be an invoke.
+
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e8_32rc40rc(
+// CHECK: call void @_Block_object_assign(
+// CHECK: invoke void @_Block_object_assign(
+// CHECK: call void @_Block_object_dispose(
+
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e8_32r40r(
+void test() {
+  S s;
+  s.m();
+}
Index: test/CodeGen/sanitize-thread-no-checking-at-run-time.m
===
--- test/CodeGen/sanitize-thread-no-checking-at-run-time.m
+++ test/CodeGen/sanitize-thread-no-checking-at-run-time.m
@@ -35,7 +35,7 @@
 void test2(id x) {
   extern void test2_helper(id (^)(void));
   test2_helper(^{ return x; });
-// TSAN: define internal void @__destroy_helper_block_(i8*) [[ATTR:#[0-9]+]]
+// TSAN: define linkonce_odr hidden void @__destroy_helper_block_8_32o(i8*) unnamed_addr [[ATTR:#[0-9]+]]
 }
 
 // TSAN: attributes [[ATTR]] = { noinline nounwind {{.*}} "sanitize_thread_no_checking_at_run_time" {{.*}} }
Index: test/CodeGen/blocks.c
===
--- test/CodeGen/blocks.c
+++ test/CodeGen/blocks.c
@@ -1,4 +1,9 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - -fblocks | FileCheck %s
+
+// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i32, i32 }
+
+// CHECK: @[[BLOCK_DESCRIPTOR_TMP21:.*]] = internal constant { i32, i32, void (i8*, i8*)*, void (i8*)*, i8*, i8* } { i32 0, i32 24, void (i8*, i8*)* @__copy_helper_block_4_20r, void (i8*)* @__destroy_helper_block_4_20r, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* null }, align 4
+
 void (^f)(void) = ^{};
 
 // rdar://6768379
@@ -27,6 +32,32 @@
   ^ { i = 1; }();
 };
 
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_4_20r(i8*, i8*) unnamed_addr
+// CHECK: %[[_ADDR:.*]] = alloca i8*, align 4
+// CHECK-NEXT: %[[_ADDR1:.*]] = alloca i8*, align 4
+// CHECK-NEXT: store i8* %0, i8** %[[_ADDR]], align 4
+// CHECK-NEXT: store i8* %1, i8** %[[_ADDR1]], align 4
+// CHECK-NEXT: %[[V2:.*]] = load i8*, i8** %[[_ADDR1]], align 4
+// CHECK-NEXT: %[[BLOCK_SOURCE:.*]] = bitcast i8* %[[V2]] to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>*
+// CHECK-NEXT: %[[V3:.*]] = load i8*, i8** %[[_ADDR]], align 4
+// CHECK-NEXT: %[[BLOCK_DEST:.*]] = bitcast i8* %[[V3]] to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>*
+// CHECK-NEXT: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK_SOURCE]], i32 0, i32 5
+// CHECK-NEXT: %[[V5:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK_DEST]], i32 0, i32 5
+// CHECK-NEXT: %[[BLOCKCOPY_SRC:.*]] = load i8*, i8** %[[V4]], align 4
+// CHECK-NEXT: %[[V

[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Hugo Gonzalez via Phabricator via cfe-commits
hugoeg updated this revision to Diff 160112.
hugoeg marked 10 inline comments as done.
hugoeg added a comment.

Applied corrections from first round comments


https://reviews.llvm.org/D50542

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/NoInternalDepsCheck.cpp
  clang-tidy/abseil/NoInternalDepsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-no-internal-deps.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-no-internal-deps.cpp

Index: test/clang-tidy/abseil-no-internal-deps.cpp
===
--- test/clang-tidy/abseil-no-internal-deps.cpp
+++ test/clang-tidy/abseil-no-internal-deps.cpp
@@ -0,0 +1,62 @@
+// RUN: %check_clang_tidy %s abseil-no-internal-deps %t
+
+
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+} // namepsace std
+
+namespace absl {
+std::string StringsFunction (std::string s1){
+  return s1;
+}
+class SomeContainer{};
+
+namespace strings_internal{
+  
+  void InternalFunction(){}
+
+  template 
+  P InternalTemplateFunction (P a) {}
+} // namespace strings_internal
+
+namespace container_internal{
+  struct InternalStruct{};
+
+} // namespace container_internal
+} // namespace absl
+
+void foo(){
+  absl::strings_internal::InternalFunction();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+
+  absl::strings_internal::InternalTemplateFunction ("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+}
+
+class foo2{
+  friend struct absl::container_internal::InternalStruct;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+};
+
+namespace absl{
+  void foo3(){
+strings_internal::InternalFunction();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+  }
+} // namespace absl
+
+
+
+// should not trigger warnings
+void foo4(){
+  std::string str = absl::StringsFunction("a");
+  absl::SomeContainer b;
+}
+
+namespace absl {
+  SomeContainer b;
+  std::string str = absl::StringsFunction("a");
+} // namespace absl
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
abseil-string-find-startswith
+   abseil-no-internal-deps
android-cloexec-accept
android-cloexec-accept4
android-cloexec-creat
Index: docs/clang-tidy/checks/abseil-no-internal-deps.rst
===
--- docs/clang-tidy/checks/abseil-no-internal-deps.rst
+++ docs/clang-tidy/checks/abseil-no-internal-deps.rst
@@ -0,0 +1,16 @@
+subl.. title:: clang-tidy - abseil-no-internal-deps
+
+abseil-no-internal-deps
+===
+
+Warns users if they attempt to depend on internal details. If something is in a namespace or filename/path that includes the word “internal”, users are not allowed to depend upon it beaucse it’s an implementation detail. They cannot friend it, include it, you mention it or refer to it in any way. Doing so violtaes Abseil's compatibility guidelines and may result in breakage.
+
+The folowing cases will result in warnings:
+
+.. code-block:: c++
+
+absl::strings_internal::foo();
+class foo{
+  friend struct absl::container_internal::faa;
+};
+absl::memory_internal::MakeUniqueResult();
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -52,7 +52,10 @@
 Improvements to clang-rename
 
 
-The improvements are...
+- New :doc:`abseil-no-internal-deps
+  ` check.
+  
+  Warns Abseil users if they attempt to depend on internal details.
 
 Improvements to clang-tidy
 --
Index: clang-tidy/abseil/NoInternalDepsCheck.h
===
--- clang-tidy/abseil/NoInternalDepsCheck.h
+++ clang-tidy/abseil/NoInternalDepsCheck.h
@@ -0,0 +1,37 @@
+//===--- NoInternalDepsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NOINTERNALDEPSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_C

[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Hugo Gonzalez via Phabricator via cfe-commits
hugoeg added inline comments.



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:24
+
+  Finder->addMatcher(
+  nestedNameSpecifierLoc(loc(specifiesNamespace(namespaceDecl(

JonasToth wrote:
> Actually that one is generally useful. Accessing the `foo::internal` from 
> outside of `foo` is always a problem. Maybe this matcher can become 
> configurable or just match on any `internal` access from outside the 
> enclosing namespace.
That's a good idea. While we agree, right now our efforts are focused on 
releasing abseil specific functions. Perhaps we can refactor this check at a 
later time. 


https://reviews.llvm.org/D50542



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


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2018-08-10 Thread Justin Hibbits via Phabricator via cfe-commits
jhibbits added a comment.

Hi Vit,

Thanks for the feedback.  I can add the -mspe=yes/no, that shouldn't be hard.  
I didn't include it because it's been deprecated by GCC already as well.  I can 
add the -mcpu=8548 option as well.  I use -mcpu=8540 on FreeBSD for the 
powerpcspe target anyway (GCC based).

Regarding the stack overwriting, that's very peculiar, because I explicitly 
mark the immediate as needing to be an 8-bit multiple-of-8 value, so the 
codegen logic should take that into account.  I'm surprised it's not.  I've 
reproduced it as well myself, so I can take a closer look.


Repository:
  rC Clang

https://reviews.llvm.org/D49754



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


[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response

2018-08-10 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 8 inline comments as done.
simark added inline comments.



Comment at: clangd/SourceCode.h:69
 
+llvm::Optional getRealPath(const FileEntry *F,
+const SourceManager &SourceMgr);

ilya-biryukov wrote:
> This function looks like a good default choice for normalizing paths before 
> putting them into LSP structs, ClangdServer responses, etc.
> I suggest we add a small comment here with a guideline for everyone to 
> attempt using it whenever possible. WDYT?
What about this:

```
/// Get the real/canonical path of \p F.  This means:
///
///   - Absolute path
///   - Symlinks resolved
///   - No "." or ".." component
///   - No duplicate or trailing directory separator
///
/// This function should be used when sending paths to clients, so that paths
/// are normalized as much as possible.
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48687



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


[PATCH] D50389: [clang-tidy] new check for Abseil

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

LGTM with only the formatting question.

But don't commit before any of the reviewers accepts (@alexfh @aaron.ballman 
usually have the last word)




Comment at: clang-tidy/abseil/DurationDivisionCheck.cpp:50
+ *result.SourceManager, result.Context->getLangOpts()),
+ ")");
+}

This line looks odd, does it come from clang-format?


https://reviews.llvm.org/D50389



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


[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-10 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia added inline comments.



Comment at: clang-tidy/abseil/DurationDivisionCheck.cpp:50
+ *result.SourceManager, result.Context->getLangOpts()),
+ ")");
+}

JonasToth wrote:
> This line looks odd, does it come from clang-format?
I have run clang-format on this file and it's still formatted like this.


https://reviews.llvm.org/D50389



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


[PATCH] D50563: Fixed frontend clang tests in windows read-only container

2018-08-10 Thread Justice Adams via Phabricator via cfe-commits
justice_adams created this revision.
justice_adams added a project: clang.

When mounting LLVM source into a windows container in read-only mode, certain 
tests fail. Ideally, we want all these tests to pass so that developers can 
mount the same source folder into multiple (windows) containers simultaneously, 
allowing them to build/test the same source code using various different 
configurations simultaneously.

**Fix**: I've found that when attempting to open a file for writing on windows, 
if you don't have the correct permissions (trying to open a file for writing in 
a read-only folder), you get Access is denied 
.
 In llvm, we map this error message to a linux based error, see: 
https://github.com/llvm-mirror/llvm/blob/master/lib/Support/ErrorHandling.cpp

This is why we see "Permission denied" in our output as opposed to the expected 
"No such file or directory", thus causing the tests to fail.

I've changed the test locally to instead point to the root drive so that they 
can successfully bypass the Access is denied error when o is mounted in as a 
read-only directory. This way, the test operate exactly the same, but we can 
get around the windows-complications of what error to expect in a read-only 
directory.


https://reviews.llvm.org/D50563

Files:
  test/Frontend/output-failures.c
  test/Frontend/stats-file.c
  test/lit.cfg.py


Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -49,6 +49,7 @@
 
 config.substitutions.append(('%PATH%', config.environment['PATH']))
 
+config.substitutions.append(('%ROOT%', os.path.abspath(os.sep)))
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories
Index: test/Frontend/stats-file.c
===
--- test/Frontend/stats-file.c
+++ test/Frontend/stats-file.c
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%S/doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%ROOT%/doesnotexist/bla %s 
2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s
 // OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
Index: test/Frontend/output-failures.c
===
--- test/Frontend/output-failures.c
+++ test/Frontend/output-failures.c
@@ -1,4 +1,3 @@
-// RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t
-// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
+// RUN: not %clang_cc1 -emit-llvm -o %ROOT%/doesnotexist/somename %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
 
-// OUTPUTFAIL: error: unable to open output file 
'{{.*}}{{[/\\]}}test{{[/\\]}}Frontend{{[/\\]}}doesnotexist{{[/\\]}}somename': 
'{{[nN]}}o such file or directory'
+// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
\ No newline at end of file


Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -49,6 +49,7 @@
 
 config.substitutions.append(('%PATH%', config.environment['PATH']))
 
+config.substitutions.append(('%ROOT%', os.path.abspath(os.sep)))
 
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories
Index: test/Frontend/stats-file.c
===
--- test/Frontend/stats-file.c
+++ test/Frontend/stats-file.c
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%S/doesnotexist/bla %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%ROOT%/doesnotexist/bla %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s
 // OUTPUTFAIL: warning: unable to open statistics output file '{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
Index: test/Frontend/output-failures.c
===
--- test/Frontend/output-failures.c
+++ test/Frontend/output-failures.c
@@ -1,4 +1,3 @@
-// RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t
-// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
+// RUN: not %clang_cc1 -emit-llvm -o %ROOT%/doesnotexist/somename %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s
 
-// OUTPUTFAIL: error: unable to open output file '{{.*}}{{[/\\]}}test{{[/\\]}}Frontend{{[/\\]}}doesnotexist{{[/\\]}}somename': '{{[nN]}}o such file or directory'
+// OUTPUTFAIL: error: unable to open

[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-10 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x created this revision.
cdavis5x added reviewers: mstorsjo, rnk, compnerd, smeenai.
Herald added subscribers: cfe-commits, chrib, christof, kristof.beyls, mgorny.
Herald added a reviewer: javed.absar.

I've tested this implementation on x86-64 to ensure that it works. All
`libc++abi` tests pass, as do all `libc++` exception-related tests. ARM
still remains to be implemented (@compnerd?).

Special thanks to KJK::Hyperion for his excellent series of articles on
how EH works on x86-64 Windows. (Seriously, check it out. It's awesome.)

I'm actually not sure if this should go in as is. I particularly don't
like that I duplicated the UnwindCursor class for this special case.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564

Files:
  include/__libunwind_config.h
  src/AddressSpace.hpp
  src/CMakeLists.txt
  src/Unwind-seh.cpp
  src/UnwindCursor.hpp
  src/UnwindLevel1-gcc-ext.c
  src/UnwindLevel1.c
  src/config.h
  src/libunwind_ext.h

Index: src/libunwind_ext.h
===
--- src/libunwind_ext.h
+++ src/libunwind_ext.h
@@ -17,6 +17,11 @@
 #include 
 #include 
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+  #include 
+  #include 
+#endif
+
 #define UNW_STEP_SUCCESS 1
 #define UNW_STEP_END 0
 
@@ -33,6 +38,43 @@
 extern void _unw_add_dynamic_fde(unw_word_t fde);
 extern void _unw_remove_dynamic_fde(unw_word_t fde);
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+  #if defined(__x86_64__) && !defined(__MINGW64__)
+typedef struct _DISPATCHER_CONTEXT {
+  ULONG64 ControlPc;
+  ULONG64 ImageBase;
+  PRUNTIME_FUNCTION FunctionEntry;
+  ULONG64 EstablisherFrame;
+  ULONG64 TargetIp;
+  PCONTEXT ContextRecord;
+  PEXCEPTION_ROUTINE LanguageHandler;
+  PVOID HandlerData;
+  PUNWIND_HISTORY_TABLE HistoryTable;
+  ULONG ScopeIndex;
+  ULONG Fill0;
+} DISPATCHER_CONTEXT;
+  #elif defined(__arm__)
+typedef struct _DISPATCHER_CONTEXT {
+  ULONG ControlPc;
+  ULONG ImageBase;
+  PRUNTIME_FUNCTION FunctionEntry;
+  ULONG EstablisherFrame;
+  ULONG TargetIp;
+  PCONTEXT ContextRecord;
+  PEXCEPTION_ROUTINE LanguageHandler;
+  PVOID HandlerData;
+  PUNWIND_HISTORY_TABLE HistoryTable;
+  ULONG ScopeIndex;
+  ULONG ControlPcIsUnwound;
+  PKNONVOLATILE_CONTEXT_POINTERS NonVolatileRegisters;
+  ULONG VirtualVfpHead;
+} DISPATCHER_CONTEXT;
+  #endif
+extern int _unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx);
+extern DISPATCHER_CONTEXT *_unw_seh_get_disp_ctx(unw_cursor_t *cursor);
+extern void _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp);
+#endif
+
 #if defined(_LIBUNWIND_ARM_EHABI)
 extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);
 extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context,
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -38,7 +38,11 @@
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
 #elif defined(_WIN32)
-  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #ifdef __SEH__
+#define _LIBUNWIND_SUPPORT_SEH_UNWIND 1
+  #else
+#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #endif
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -32,6 +32,8 @@
 
 #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
+#if !_LIBUNWIND_SUPPORT_SEH_UNWIND
+
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
   unw_init_local(cursor, uc);
@@ -449,6 +451,7 @@
   return result;
 }
 
+#endif // !_LIBUNWIND_SUPPORT_SEH_UNWIND
 
 /// Called by personality handler during phase 2 if a foreign exception
 // is caught.
Index: src/UnwindLevel1-gcc-ext.c
===
--- src/UnwindLevel1-gcc-ext.c
+++ src/UnwindLevel1-gcc-ext.c
@@ -25,6 +25,10 @@
 
 #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#define private_1 private_[0]
+#endif
+
 ///  Called by __cxa_rethrow().
 _LIBUNWIND_EXPORT _Unwind_Reason_Code
 _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -18,18 +18,40 @@
 #include 
 #include 
 
+#ifdef _WIN32
+  #include 
+#endif
 #ifdef __APPLE__
   #include 
 #endif
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#  ifdef _LIBUNWIND_TARGET_X86_64
+struct UNWIND_INFO {
+  BYTE Version : 3;
+  BYTE Flags : 5;
+  BYTE SizeOfProlog;
+  BYTE CountOfCodes;
+  BYTE FrameRegister : 4;
+  BYTE FrameOffset : 4;
+  WORD UnwindCodes[2];
+};
+#  endif
+
+extern "C" _Unwind_Reason_Code __libunwind_seh_personality(
+int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception

[PATCH] D50507: [CodeGen][ARM] Coerce FP16 vectors to integer vectors when needed

2018-08-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 160121.
miyuki edited the summary of this revision.
miyuki added a comment.

Fix handling of homogeneous aggregates of FP16 vectors


https://reviews.llvm.org/D50507

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arm-vfp16-arguments.c
  test/CodeGen/arm_neon_intrinsics.c

Index: test/CodeGen/arm_neon_intrinsics.c
===
--- test/CodeGen/arm_neon_intrinsics.c
+++ test/CodeGen/arm_neon_intrinsics.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7s-apple-darwin -target-abi apcs-gnu\
-// RUN:  -target-cpu swift -fallow-half-arguments-and-returns -ffreestanding \
+// RUN:  -target-cpu swift -fallow-half-arguments-and-returns \
+// RUN:  -target-feature +fullfp16 -ffreestanding \
 // RUN:  -disable-O0-optnone -emit-llvm -o - %s \
 // RUN:  | opt -S -mem2reg | FileCheck %s
 
@@ -3896,9 +3897,8 @@
 
 // CHECK-LABEL: @test_vld1q_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[VLD1:%.*]] = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* [[TMP0]], i32 2)
-// CHECK:   [[TMP1:%.*]] = bitcast <8 x i16> [[VLD1]] to <8 x half>
-// CHECK:   ret <8 x half> [[TMP1]]
+// CHECK:   [[VLD1:%.*]] = call <8 x half> @llvm.arm.neon.vld1.v8f16.p0i8(i8* [[TMP0]], i32 2)
+// CHECK:   ret <8 x half> [[VLD1]]
 float16x8_t test_vld1q_f16(float16_t const * a) {
   return vld1q_f16(a);
 }
@@ -3990,9 +3990,8 @@
 
 // CHECK-LABEL: @test_vld1_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[VLD1:%.*]] = call <4 x i16> @llvm.arm.neon.vld1.v4i16.p0i8(i8* [[TMP0]], i32 2)
-// CHECK:   [[TMP1:%.*]] = bitcast <4 x i16> [[VLD1]] to <4 x half>
-// CHECK:   ret <4 x half> [[TMP1]]
+// CHECK:   [[VLD1:%.*]] = call <4 x half> @llvm.arm.neon.vld1.v4f16.p0i8(i8* [[TMP0]], i32 2)
+// CHECK:   ret <4 x half> [[VLD1]]
 float16x4_t test_vld1_f16(float16_t const * a) {
   return vld1_f16(a);
 }
@@ -4106,12 +4105,11 @@
 
 // CHECK-LABEL: @test_vld1q_dup_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to i16*
-// CHECK:   [[TMP2:%.*]] = load i16, i16* [[TMP1]], align 2
-// CHECK:   [[TMP3:%.*]] = insertelement <8 x i16> undef, i16 [[TMP2]], i32 0
-// CHECK:   [[LANE:%.*]] = shufflevector <8 x i16> [[TMP3]], <8 x i16> [[TMP3]], <8 x i32> zeroinitializer
-// CHECK:   [[TMP4:%.*]] = bitcast <8 x i16> [[LANE]] to <8 x half>
-// CHECK:   ret <8 x half> [[TMP4]]
+// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to half*
+// CHECK:   [[TMP2:%.*]] = load half, half* [[TMP1]], align 2
+// CHECK:   [[TMP3:%.*]] = insertelement <8 x half> undef, half [[TMP2]], i32 0
+// CHECK:   [[LANE:%.*]] = shufflevector <8 x half> [[TMP3]], <8 x half> [[TMP3]], <8 x i32> zeroinitializer
+// CHECK:   ret <8 x half> [[LANE]]
 float16x8_t test_vld1q_dup_f16(float16_t const * a) {
   return vld1q_dup_f16(a);
 }
@@ -4233,12 +4231,11 @@
 
 // CHECK-LABEL: @test_vld1_dup_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
-// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to i16*
-// CHECK:   [[TMP2:%.*]] = load i16, i16* [[TMP1]], align 2
-// CHECK:   [[TMP3:%.*]] = insertelement <4 x i16> undef, i16 [[TMP2]], i32 0
-// CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP3]], <4 x i16> [[TMP3]], <4 x i32> zeroinitializer
-// CHECK:   [[TMP4:%.*]] = bitcast <4 x i16> [[LANE]] to <4 x half>
-// CHECK:   ret <4 x half> [[TMP4]]
+// CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to half*
+// CHECK:   [[TMP2:%.*]] = load half, half* [[TMP1]], align 2
+// CHECK:   [[TMP3:%.*]] = insertelement <4 x half> undef, half [[TMP2]], i32 0
+// CHECK:   [[LANE:%.*]] = shufflevector <4 x half> [[TMP3]], <4 x half> [[TMP3]], <4 x i32> zeroinitializer
+// CHECK:   ret <4 x half> [[LANE]]
 float16x4_t test_vld1_dup_f16(float16_t const * a) {
   return vld1_dup_f16(a);
 }
@@ -4365,12 +4362,11 @@
 // CHECK-LABEL: @test_vld1q_lane_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast <8 x half> %b to <16 x i8>
-// CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <8 x i16>
-// CHECK:   [[TMP3:%.*]] = bitcast i8* [[TMP0]] to i16*
-// CHECK:   [[TMP4:%.*]] = load i16, i16* [[TMP3]], align 2
-// CHECK:   [[VLD1_LANE:%.*]] = insertelement <8 x i16> [[TMP2]], i16 [[TMP4]], i32 7
-// CHECK:   [[TMP5:%.*]] = bitcast <8 x i16> [[VLD1_LANE]] to <8 x half>
-// CHECK:   ret <8 x half> [[TMP5]]
+// CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <8 x half>
+// CHECK:   [[TMP3:%.*]] = bitcast i8* [[TMP0]] to half*
+// CHECK:   [[TMP4:%.*]] = load half, half* [[TMP3]], align 2
+// CHECK:   [[VLD1_LANE:%.*]] = insertelement <8 x half> [[TMP2]], half [[TMP4]], i32 7
+// CHECK:   ret <8 x half> [[VLD1_LANE]]
 float16x8_t test_vld1q_lane_f16(float16_t const * a, float16x8_t b) {
   return vld1q_lane_f16(a, b, 7);
 }
@@ -4498,12 +4494,11 @@
 // CHECK-LABEL: @test_vld1_lane_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast <4 x half>

[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-10 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

In https://reviews.llvm.org/D50413#1195101, @mstorsjo wrote:

> @cdavis5x I presume the fact that this one turned out tricky is blocking 
> submitting the SEH unwinding patch.
>
> Would it be worth to rework that patch to just use the basic types just like 
> libunwind does today, e.g. having `_Unwind_GetRegionStart` return plain 
> `uintptr_t` instead of `_Unwind_Ptr`, which also would be consistent with the 
> existing entry points in Unwind-EHABI.cpp, Unwind-sjlj.c and UnwindLevel1.c, 
> in order to be able to submit it before this one gets sorted out?


Sounds reasonable.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/DurationDivisionCheck.cpp:50
+ *result.SourceManager, result.Context->getLangOpts()),
+ ")");
+}

deannagarcia wrote:
> JonasToth wrote:
> > This line looks odd, does it come from clang-format?
> I have run clang-format on this file and it's still formatted like this.
Leave as is :)


https://reviews.llvm.org/D50389



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


[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:24
+
+  Finder->addMatcher(
+  nestedNameSpecifierLoc(loc(specifiesNamespace(namespaceDecl(

hugoeg wrote:
> JonasToth wrote:
> > Actually that one is generally useful. Accessing the `foo::internal` from 
> > outside of `foo` is always a problem. Maybe this matcher can become 
> > configurable or just match on any `internal` access from outside the 
> > enclosing namespace.
> That's a good idea. While we agree, right now our efforts are focused on 
> releasing abseil specific functions. Perhaps we can refactor this check at a 
> later time. 
Ok. Could you please add a `TODO` or `FIXME` that it is not forgotten?


https://reviews.llvm.org/D50542



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


[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Hugo Gonzalez via Phabricator via cfe-commits
hugoeg updated this revision to Diff 160124.

https://reviews.llvm.org/D50542

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/NoInternalDepsCheck.cpp
  clang-tidy/abseil/NoInternalDepsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-no-internal-deps.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-no-internal-deps.cpp

Index: test/clang-tidy/abseil-no-internal-deps.cpp
===
--- test/clang-tidy/abseil-no-internal-deps.cpp
+++ test/clang-tidy/abseil-no-internal-deps.cpp
@@ -0,0 +1,62 @@
+// RUN: %check_clang_tidy %s abseil-no-internal-deps %t
+
+
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+} // namepsace std
+
+namespace absl {
+std::string StringsFunction (std::string s1){
+  return s1;
+}
+class SomeContainer{};
+
+namespace strings_internal{
+  
+  void InternalFunction(){}
+
+  template 
+  P InternalTemplateFunction (P a) {}
+} // namespace strings_internal
+
+namespace container_internal{
+  struct InternalStruct{};
+
+} // namespace container_internal
+} // namespace absl
+
+void foo(){
+  absl::strings_internal::InternalFunction();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+
+  absl::strings_internal::InternalTemplateFunction ("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+}
+
+class foo2{
+  friend struct absl::container_internal::InternalStruct;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+};
+
+namespace absl{
+  void foo3(){
+strings_internal::InternalFunction();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: depends upon internal implementation details, which violates the Abseil compatibilty guidelines. See https://abseil.io/about/compatibility
+  }
+} // namespace absl
+
+
+
+// should not trigger warnings
+void foo4(){
+  std::string str = absl::StringsFunction("a");
+  absl::SomeContainer b;
+}
+
+namespace absl {
+  SomeContainer b;
+  std::string str = absl::StringsFunction("a");
+} // namespace absl
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
abseil-string-find-startswith
+   abseil-no-internal-deps
android-cloexec-accept
android-cloexec-accept4
android-cloexec-creat
Index: docs/clang-tidy/checks/abseil-no-internal-deps.rst
===
--- docs/clang-tidy/checks/abseil-no-internal-deps.rst
+++ docs/clang-tidy/checks/abseil-no-internal-deps.rst
@@ -0,0 +1,16 @@
+subl.. title:: clang-tidy - abseil-no-internal-deps
+
+abseil-no-internal-deps
+===
+
+Warns users if they attempt to depend on internal details. If something is in a namespace or filename/path that includes the word “internal”, users are not allowed to depend upon it beaucse it’s an implementation detail. They cannot friend it, include it, you mention it or refer to it in any way. Doing so violtaes Abseil's compatibility guidelines and may result in breakage.
+
+The folowing cases will result in warnings:
+
+.. code-block:: c++
+
+absl::strings_internal::foo();
+class foo{
+  friend struct absl::container_internal::faa;
+};
+absl::memory_internal::MakeUniqueResult();
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -52,7 +52,10 @@
 Improvements to clang-rename
 
 
-The improvements are...
+- New :doc:`abseil-no-internal-deps
+  ` check.
+  
+  Warns Abseil users if they attempt to depend on internal details.
 
 Improvements to clang-tidy
 --
Index: clang-tidy/abseil/NoInternalDepsCheck.h
===
--- clang-tidy/abseil/NoInternalDepsCheck.h
+++ clang-tidy/abseil/NoInternalDepsCheck.h
@@ -0,0 +1,37 @@
+//===--- NoInternalDepsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NOINTERNALDEPSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NOINTERNALDEPSCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namesp

[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

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

Thank you for your first contribution to LLVM btw :)




Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:24
+
+  TODO(hugoeg): refactor matcher to be configurable or just match on any 
internal access from outside the enclosing namespace.
+  

Missing //



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:35
+void NoInternalDepsCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *intr_dep =
+  Result.Nodes.getNodeAs("internal_dep");

Please follow the LLVM naming convention (s/initr_dep/InternalDependency/ or 
similar)

https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
for reference


https://reviews.llvm.org/D50542



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


Re: r339428 - Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-10 Thread Tom Weaver via cfe-commits
Hi David,

revision 339428 seems to have caused failing tests on a couple of windows
build bots, any chance you can take a look please?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/18985


Failing Tests (1):
Clang :: CodeGenObjC/gnu-init.m

  Expected Passes: 30627
  Expected Failures  : 65
  Unsupported Tests  : 12223
  Unexpected Failures: 1


Thanks

Tom Weaver

On 10 August 2018 at 13:53, David Chisnall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: theraven
> Date: Fri Aug 10 05:53:13 2018
> New Revision: 339428
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339428&view=rev
> Log:
> Add Windows support for the GNUstep Objective-C ABI V2.
>
> Summary:
> Introduces funclet-based unwinding for Objective-C and fixes an issue
> where global blocks can't have their isa pointers initialised on
> Windows.
>
> After discussion with Dustin, this changes the name mangling of
> Objective-C types to prevent a C++ catch statement of type struct X*
> from catching an Objective-C object of type X*.
>
> Reviewers: rjmccall, DHowett-MSFT
>
> Reviewed By: rjmccall, DHowett-MSFT
>
> Subscribers: mgrang, mstorsjo, smeenai, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D50144
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/CodeGen/CGException.cpp
> cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
> cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
> cfe/trunk/lib/CodeGen/CGObjCRuntime.h
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/CodeGenObjC/gnu-init.m
> cfe/trunk/test/CodeGenObjC/gnustep2-proto.m
> cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
> cfe/trunk/test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
> cfe/trunk/test/CodeGenObjCXX/msabi-objc-extensions.mm
> cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=339428&r1=339427&r2=339428&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 10 05:53:13 2018
> @@ -1488,7 +1488,7 @@ def fobjc_weak : Flag<["-"], "fobjc-weak
>HelpText<"Enable ARC-style weak references in Objective-C">;
>
>  // Objective-C ABI options.
> -def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group,
> Flags<[CC1Option]>,
> +def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group,
> Flags<[CC1Option, CoreOption]>,
>HelpText<"Specify the target Objective-C runtime kind and version">;
>  def fobjc_abi_version_EQ : Joined<["-"], "fobjc-abi-version=">,
> Group;
>  def fobjc_nonfragile_abi_version_EQ : Joined<["-"],
> "fobjc-nonfragile-abi-version=">, Group;
>
> Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> MicrosoftMangle.cpp?rev=339428&r1=339427&r2=339428&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
> +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri Aug 10 05:53:13 2018
> @@ -445,7 +445,7 @@ void MicrosoftCXXNameMangler::mangle(con
>  mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));
>else if (const VarDecl *VD = dyn_cast(D))
>  mangleVariableEncoding(VD);
> -  else
> +  else if (!isa(D))
>  llvm_unreachable("Tried to mangle unexpected NamedDecl!");
>  }
>
> @@ -1884,13 +1884,13 @@ void MicrosoftCXXNameMangler::mangleType
>  llvm_unreachable("placeholder types shouldn't get to name mangling");
>
>case BuiltinType::ObjCId:
> -mangleArtificalTagType(TTK_Struct, "objc_object");
> +mangleArtificalTagType(TTK_Struct, ".objc_object");
>  break;
>case BuiltinType::ObjCClass:
> -mangleArtificalTagType(TTK_Struct, "objc_class");
> +mangleArtificalTagType(TTK_Struct, ".objc_class");
>  break;
>case BuiltinType::ObjCSel:
> -mangleArtificalTagType(TTK_Struct, "objc_selector");
> +mangleArtificalTagType(TTK_Struct, ".objc_selector");
>  break;
>
>  #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
> @@ -2570,9 +2570,10 @@ void MicrosoftCXXNameMangler::mangleType
>
>  void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T,
> Qualifiers,
>   SourceRange) {
> -  // ObjC interfaces have structs underlying them.
> +  // ObjC interfaces are mangled as if they were structs with a name that
> is
> +  // not a valid C/C++ identifier
>mangleTagTypeKind(TTK_Struct);
> -  mangleName(T->getDecl());
> +  mangle(T->getDecl(), ".objc_cls_");
>  }
>
>  void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T,
> Qualifiers,
> @@

[libcxx] r339451 - [libcxx] Mark charconv tests as failing for previous libcxx versions.

2018-08-10 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Aug 10 10:03:47 2018
New Revision: 339451

URL: http://llvm.org/viewvc/llvm-project?rev=339451&view=rev
Log:
[libcxx] Mark charconv tests as failing for previous libcxx versions.

 was added in r338479. Previous libcxx versions don't have
this functionality and corresponding tests should be failing.

Reviewers: mclow.lists, ldionne, EricWF

Reviewed By: ldionne

Subscribers: christof, dexonsmith, lichray, EricWF, cfe-commits

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

Modified:

libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp?rev=339451&r1=339450&r2=339451&view=diff
==
--- 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp 
Fri Aug 10 10:03:47 2018
@@ -8,6 +8,15 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // from_chars_result from_chars(const char* first, const char* last,

Modified: 
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp?rev=339451&r1=339450&r2=339451&view=diff
==
--- 
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp 
Fri Aug 10 10:03:47 2018
@@ -8,6 +8,15 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // to_chars_result to_chars(char* first, char* last, Integral value,


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


[PATCH] D50543: [libcxx] Mark charconv tests as failing for previous libcxx versions.

2018-08-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339451: [libcxx] Mark charconv tests as failing for previous 
libcxx versions. (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50543?vs=160041&id=160132#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50543

Files:
  libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp


Index: 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
===
--- 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
+++ 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
@@ -8,6 +8,15 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // from_chars_result from_chars(const char* first, const char* last,
Index: 
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
===
--- libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
+++ libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
@@ -8,6 +8,15 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // to_chars_result to_chars(char* first, char* last, Integral value,


Index: libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
===
--- libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
+++ libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
@@ -8,6 +8,15 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // from_chars_result from_chars(const char* first, const char* last,
Index: libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
===
--- libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
+++ libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
@@ -8,6 +8,15 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // to_chars_result to_chars(char* first, char* last, Integral value,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339452 - Make changes to the check strings so that the test I modified in r339438

2018-08-10 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Aug 10 10:07:27 2018
New Revision: 339452

URL: http://llvm.org/viewvc/llvm-project?rev=339452&view=rev
Log:
Make changes to the check strings so that the test I modified in r339438
passes on 32-bit targets.

Modified:
cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp

Modified: cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp?rev=339452&r1=339451&r2=339452&view=diff
==
--- cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/block-byref-cxx-objc.cpp Fri Aug 10 10:07:27 2018
@@ -26,12 +26,12 @@ int testA() {
 // CHECK-LABEL: define internal void @__Block_byref_object_dispose_
 // CHECK: call {{.*}} @_ZN1AD1Ev
 
-// CHECK-LABEL: define linkonce_odr hidden void 
@__copy_helper_block_e8_32rc40rc(
+// CHECK-LABEL: define linkonce_odr hidden void 
@__copy_helper_block_e{{4|8}}_{{20|32}}rc{{24|40}}rc(
 // CHECK: call void @_Block_object_assign(
 // CHECK: invoke void @_Block_object_assign(
 // CHECK: call void @_Block_object_dispose({{.*}}) #[[NOUNWIND_ATTR:[0-9]+]]
 
-// CHECK-LABEL: define linkonce_odr hidden void 
@__destroy_helper_block_e8_32rd40rd(
+// CHECK-LABEL: define linkonce_odr hidden void 
@__destroy_helper_block_e{{4|8}}_{{20|32}}rd{{24|40}}rd(
 // CHECK: invoke void @_Block_object_dispose(
 // CHECK: call void @_Block_object_dispose(
 // CHECK: invoke void @_Block_object_dispose(
@@ -48,7 +48,7 @@ int testB() {
 // CHECK: call {{.*}} @_ZN1BD1Ev
 
 // CHECK-NOT: define{{.*}}@__copy_helper_block
-// CHECK: define linkonce_odr hidden void @__destroy_helper_block_e8_32r40r(
+// CHECK: define linkonce_odr hidden void 
@__destroy_helper_block_e{{4|8}}_{{20|32}}r{{24|40}}r(
 
 // CHECK: attributes #[[NOUNWIND_ATTR]] = {{{.*}}nounwind{{.*}}}
 


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


[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index

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

Address issues we have discussed with Eric.


https://reviews.llvm.org/D50517

Files:
  clang-tools-extra/clangd/index/dex/Iterator.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/index/dex/Trigram.h
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -250,45 +250,57 @@
 }
 
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
-  EXPECT_THAT(generateIdentifierTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateIdentifierTrigrams("X86"),
+  trigramsAre({"x86", "x$$", "x8$", "$$$"}));
 
-  EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateIdentifierTrigrams("nl"),
+  trigramsAre({"nl$", "n$$", "$$$"}));
+
+  EXPECT_THAT(generateIdentifierTrigrams("n"), trigramsAre({"n$$", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("clangd"),
-  trigramsAre({"cla", "lan", "ang", "ngd"}));
+  trigramsAre({"c$$", "cl$", "cla", "lan", "ang", "ngd", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("abc_def"),
-  trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def"}));
+  trigramsAre({"a$$", "abc", "abd", "ade", "bcd", "bde", "cde",
+   "def", "ab$", "ad$", "$$$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("a_b_c_d_e_"),
-  trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"}));
+  EXPECT_THAT(generateIdentifierTrigrams("a_b_c_d_e_"),
+  trigramsAre({"a$$", "a_$", "a_b", "abc", "abd", "acd", "ace",
+   "bcd", "bce", "bde", "cde", "ab$", "$$$"}));
 
-  EXPECT_THAT(
-  generateIdentifierTrigrams("unique_ptr"),
-  trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", "iqp",
-   "ipt", "que", "qup", "qpt", "uep", "ept", "ptr"}));
+  EXPECT_THAT(generateIdentifierTrigrams("unique_ptr"),
+  trigramsAre({"u$$", "uni", "unp", "upt", "niq", "nip", "npt",
+   "iqu", "iqp", "ipt", "que", "qup", "qpt", "uep",
+   "ept", "ptr", "un$", "up$", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("TUDecl"),
-  trigramsAre({"tud", "tde", "ude", "dec", "ecl"}));
+  trigramsAre({"t$$", "tud", "tde", "ude", "dec", "ecl", "tu$",
+   "td$", "$$$"}));
 
   EXPECT_THAT(generateIdentifierTrigrams("IsOK"),
-  trigramsAre({"iso", "iok", "sok"}));
-
-  EXPECT_THAT(generateIdentifierTrigrams("abc_defGhij__klm"),
-  trigramsAre({
-  "abc", "abd", "abg", "ade", "adg", "adk", "agh", "agk", "bcd",
-  "bcg", "bde", "bdg", "bdk", "bgh", "bgk", "cde", "cdg", "cdk",
-  "cgh", "cgk", "def", "deg", "dek", "dgh", "dgk", "dkl", "efg",
-  "efk", "egh", "egk", "ekl", "fgh", "fgk", "fkl", "ghi", "ghk",
-  "gkl", "hij", "hik", "hkl", "ijk", "ikl", "jkl", "klm",
-  }));
+  trigramsAre({"i$$", "iso", "iok", "sok", "is$", "io$", "$$$"}));
+
+  EXPECT_THAT(
+  generateIdentifierTrigrams("abc_defGhij__klm"),
+  trigramsAre({"a$$", "abc", "abd", "abg", "ade", "adg", "adk", "agh",
+   "agk", "bcd", "bcg", "bde", "bdg", "bdk", "bgh", "bgk",
+   "cde", "cdg", "cdk", "cgh", "cgk", "def", "deg", "dek",
+   "dgh", "dgk", "dkl", "efg", "efk", "egh", "egk", "ekl",
+   "fgh", "fgk", "fkl", "ghi", "ghk", "gkl", "hij", "hik",
+   "hkl", "ijk", "ikl", "jkl", "klm", "ab$", "ad$", "$$$"}));
 }
 
 TEST(DexIndexTrigrams, QueryTrigrams) {
-  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
+  EXPECT_THAT(generateQueryTrigrams("c"), trigramsAre({"c$$"}));
+  EXPECT_THAT(generateQueryTrigrams("cl"), trigramsAre({"cl$"}));
+  EXPECT_THAT(generateQueryTrigrams("cla"), trigramsAre({"cla"}));
 
-  EXPECT_THAT(generateQueryTrigrams("nl"), trigramsAre({}));
+  EXPECT_THAT(generateQueryTrigrams("_"), trigramsAre({"_$$"}));
+  EXPECT_THAT(generateQueryTrigrams("__"), trigramsAre({"__$"}));
+  EXPECT_THAT(generateQueryTrigrams("___"), trigramsAre({"___"}));
+
+  EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
 
   EXPECT_THAT(generateQueryTrigrams("clangd"),
   trigramsAre({"cla", "lan", "ang", "ngd"}));
Index: clang-tools-extra/clangd/index/dex/Trigram.h
===
--- clang-tools-extra/clangd/index/dex/Trigram.h
+++ clang-tools-extra/clangd/index/dex/Trigram.h
@@ -36,14 +36,26 @@
 /// First, given Identifier (unqualified symbol name) is segmen

[PATCH] D50543: [libcxx] Mark charconv tests as failing for previous libcxx versions.

2018-08-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review.


Repository:
  rL LLVM

https://reviews.llvm.org/D50543



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


[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-10 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:58
+  
+  Warns Abseil users if they attempt to depend on internal details.
 

I think will be good idea to omit user, and just refer to code which depend on 
internal details. Please synchronize with documentations.



Comment at: test/clang-tidy/abseil-no-internal-deps.cpp:15
+}
+class SomeContainer{};
+

Please separate with empty line.



Comment at: test/clang-tidy/abseil-no-internal-deps.cpp:51
+
+
+

Please remove two empty lines


https://reviews.llvm.org/D50542



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


  1   2   >