[clang-tools-extra] r322821 - [clangd] Use fuzzy match to select top N index results.

2018-01-18 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jan 18 00:35:04 2018
New Revision: 322821

URL: http://llvm.org/viewvc/llvm-project?rev=322821&view=rev
Log:
[clangd] Use fuzzy match to select top N index results.

Summary:
This makes performance slower but more predictable (it always processes
every symbol). We need to find ways to make this fast, possibly by precomputing
short queries or capping the number of scored results. But our current approach
is too naive.

It also no longer returns results in a "good" order. In fact it's pathological:
the top N results are ranked from worst to best. Indexes aren't responsible for
ranking and MergedIndex can't do a good job, so I'm pleased that this will make
any hidden assumptions we have more noticeable :-)

Reviewers: hokein

Subscribers: klimek, ilya-biryukov, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=322821&r1=322820&r2=322821&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Thu Jan 18 00:35:04 2018
@@ -8,7 +8,9 @@
 //===---===//
 
 #include "MemIndex.h"
+#include "../FuzzyMatch.h"
 #include "../Logger.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -32,7 +34,9 @@ bool MemIndex::fuzzyFind(
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  unsigned Matched = 0;
+  std::priority_queue> Top;
+  FuzzyMatcher Filter(Req.Query);
+  bool More = false;
   {
 std::lock_guard Lock(Mutex);
 for (const auto Pair : Index) {
@@ -42,15 +46,18 @@ bool MemIndex::fuzzyFind(
   if (!Req.Scopes.empty() && !llvm::is_contained(Req.Scopes, Sym->Scope))
 continue;
 
-  // FIXME(ioeric): use fuzzy matcher.
-  if (StringRef(Sym->Name).find_lower(Req.Query) != StringRef::npos) {
-if (++Matched > Req.MaxCandidateCount)
-  return false;
-Callback(*Sym);
+  if (auto Score = Filter.match(Sym->Name)) {
+Top.emplace(-*Score, Sym);
+if (Top.size() > Req.MaxCandidateCount) {
+  More = true;
+  Top.pop();
+}
   }
 }
+for (; !Top.empty(); Top.pop())
+  Callback(*Top.top().second);
   }
-  return true;
+  return More;
 }
 
 std::unique_ptr MemIndex::build(SymbolSlab Slab) {

Modified: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp?rev=322821&r1=322820&r2=322821&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Thu Jan 18 00:35:04 
2018
@@ -149,12 +149,22 @@ TEST(MemIndexTest, MemIndexLimitedNumMat
   EXPECT_EQ(Matches.size(), Req.MaxCandidateCount);
 }
 
+TEST(MemIndexTest, FuzzyMatch) {
+  MemIndex I;
+  I.build(
+  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}));
+  FuzzyFindRequest Req;
+  Req.Query = "lol";
+  Req.MaxCandidateCount = 2;
+  EXPECT_THAT(match(I, Req),
+  UnorderedElementsAre("LaughingOutLoud", "LittleOldLady"));
+}
+
 TEST(MemIndexTest, MatchQualifiedNamesWithoutSpecificScope) {
   MemIndex I;
   I.build(generateSymbols({"a::xyz", "b::yz", "yz"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz", "b::yz", "yz"));
 }
 
@@ -164,7 +174,6 @@ TEST(MemIndexTest, MatchQualifiedNamesWi
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {""};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("yz"));
 }
 
@@ -174,7 +183,6 @@ TEST(MemIndexTest, MatchQualifiedNamesWi
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz", "a::yy"));
 }
 
@@ -184,7 +192,6 @@ TEST(MemIndexTest, MatchQualifiedNamesWi
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a", "b"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz", "a::yy", "b::yz"));
 }
 
@@ -194,7 +201,6 @@ TEST(MemIndexTest, NoMatchNestedScopes)
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz"));
 }
 
@@ -204,7 +210,6 @@ TEST(MemIndexTest, IgnoreCases) {
   FuzzyFindRequest Req;
   Req.Query = "AB";
   Req.Scopes = {"ns"};
-  auto Matches = match(I, Req);
   EXPECT_

[PATCH] D42060: [clangd] Use fuzzy match to select top N index results.

2018-01-18 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rL322821: [clangd] Use fuzzy match to select top N index 
results. (authored by sammccall, committed by ).
Herald added a reviewer: jkorous-apple.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42060?vs=129833&id=130363#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42060

Files:
  clang-tools-extra/trunk/clangd/index/MemIndex.cpp
  clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp
@@ -8,7 +8,9 @@
 //===---===//
 
 #include "MemIndex.h"
+#include "../FuzzyMatch.h"
 #include "../Logger.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -32,7 +34,9 @@
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  unsigned Matched = 0;
+  std::priority_queue> Top;
+  FuzzyMatcher Filter(Req.Query);
+  bool More = false;
   {
 std::lock_guard Lock(Mutex);
 for (const auto Pair : Index) {
@@ -42,15 +46,18 @@
   if (!Req.Scopes.empty() && !llvm::is_contained(Req.Scopes, Sym->Scope))
 continue;
 
-  // FIXME(ioeric): use fuzzy matcher.
-  if (StringRef(Sym->Name).find_lower(Req.Query) != StringRef::npos) {
-if (++Matched > Req.MaxCandidateCount)
-  return false;
-Callback(*Sym);
+  if (auto Score = Filter.match(Sym->Name)) {
+Top.emplace(-*Score, Sym);
+if (Top.size() > Req.MaxCandidateCount) {
+  More = true;
+  Top.pop();
+}
   }
 }
+for (; !Top.empty(); Top.pop())
+  Callback(*Top.top().second);
   }
-  return true;
+  return More;
 }
 
 std::unique_ptr MemIndex::build(SymbolSlab Slab) {
Index: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
@@ -149,12 +149,22 @@
   EXPECT_EQ(Matches.size(), Req.MaxCandidateCount);
 }
 
+TEST(MemIndexTest, FuzzyMatch) {
+  MemIndex I;
+  I.build(
+  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}));
+  FuzzyFindRequest Req;
+  Req.Query = "lol";
+  Req.MaxCandidateCount = 2;
+  EXPECT_THAT(match(I, Req),
+  UnorderedElementsAre("LaughingOutLoud", "LittleOldLady"));
+}
+
 TEST(MemIndexTest, MatchQualifiedNamesWithoutSpecificScope) {
   MemIndex I;
   I.build(generateSymbols({"a::xyz", "b::yz", "yz"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz", "b::yz", "yz"));
 }
 
@@ -164,7 +174,6 @@
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {""};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("yz"));
 }
 
@@ -174,7 +183,6 @@
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz", "a::yy"));
 }
 
@@ -184,7 +192,6 @@
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a", "b"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz", "a::yy", "b::yz"));
 }
 
@@ -194,7 +201,6 @@
   FuzzyFindRequest Req;
   Req.Query = "y";
   Req.Scopes = {"a"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz"));
 }
 
@@ -204,7 +210,6 @@
   FuzzyFindRequest Req;
   Req.Query = "AB";
   Req.Scopes = {"ns"};
-  auto Matches = match(I, Req);
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42232: [cmake] Also pass CMAKE_ASM_COMPILER_ID to next stage when bootstrapping

2018-01-18 Thread Don Hinton via Phabricator via cfe-commits
hintonda created this revision.
hintonda added reviewers: compnerd, beanz.
Herald added a subscriber: mgorny.

If CMAKE_ASM_COMPILER is set, cmake assumes
CMAKE_ASM_COMPILER_ID was also set, and doesn't try to set it.

Without CMAKE_ASM_COMPILER_ID, cmake can't set
CMAKE_ASM_COMPILER_OPTIONS_TARGET either, which means
CMAKE_ASM_COMPILER_TARGET is ignored, causing cross compiling to fail,
i.e., `--target=${CMAKE_ASM_COMPILER_TARGET}` isn't passed.


Repository:
  rC Clang

https://reviews.llvm.org/D42232

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -624,7 +624,8 @@
   set(COMPILER_OPTIONS
 -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${CXX_COMPILER}
 -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
--DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER})
+-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
+-DCMAKE_ASM_COMPILER_ID=Clang)
 
   if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
 add_dependencies(clang-bootstrap-deps llvm-profdata)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -624,7 +624,8 @@
   set(COMPILER_OPTIONS
 -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${CXX_COMPILER}
 -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
--DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER})
+-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
+-DCMAKE_ASM_COMPILER_ID=Clang)
 
   if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
 add_dependencies(clang-bootstrap-deps llvm-profdata)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41852: [clang-tidy] Don't generate fix for argument constructed from std::initializer_list.

2018-01-18 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL322822: [clang-tidy] Don't generate fix for argument 
constructed from std… (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41852

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -25,6 +25,11 @@
   int a, b;
 };
 
+template
+struct MyVector {
+  MyVector(std::initializer_list);
+};
+
 struct Empty {};
 
 struct E {
@@ -45,6 +50,7 @@
 
 struct H {
   H(std::vector);
+  H(MyVector, int);
 };
 
 struct I {
@@ -331,6 +337,13 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
   // CHECK-FIXES: PH1.reset(new H({1, 2, 3}));
 
+  std::unique_ptr PH2 = std::unique_ptr(new H({1, 2, 3}, 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr PH2 = std::unique_ptr(new H({1, 2, 3}, 
1));
+  PH2.reset(new H({1, 2, 3}, 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PH2.reset(new H({1, 2, 3}, 1));
+
   std::unique_ptr PI1 = std::unique_ptr(new I(G({1, 2, 3})));
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PI1 = std::make_unique(G({1, 2, 3}));
Index: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
===
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
@@ -27,5 +27,6 @@
 class vector {
  public:
   vector(initializer_list<_E> init);
+  ~vector();
 };
 } // namespace std
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -281,12 +281,25 @@
 if (isa(Arg)) {
   return false;
 }
+// Check whether we construct a class from a std::initializer_list.
+// If so, we won't generate the fixes.
+auto IsStdInitListInitConstructExpr = [](const Expr* E) {
+  assert(E);
+  if (const auto *ImplicitCE = dyn_cast(E)) {
+if (ImplicitCE->isStdInitListInitialization())
+  return true;
+  }
+  return false;
+};
 // Check the implicit conversion from the std::initializer_list type to
 // a class type.
-if (const auto *ImplicitCE = dyn_cast(Arg)) {
-  if (ImplicitCE->isStdInitListInitialization()) {
+if (IsStdInitListInitConstructExpr(Arg))
+  return false;
+// The Arg can be a CXXBindTemporaryExpr, checking its underlying
+// construct expr.
+if (const auto * CTE = dyn_cast(Arg)) {
+  if (IsStdInitListInitConstructExpr(CTE->getSubExpr()))
 return false;
-  }
 }
   }
 }


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -25,6 +25,11 @@
   int a, b;
 };
 
+template
+struct MyVector {
+  MyVector(std::initializer_list);
+};
+
 struct Empty {};
 
 struct E {
@@ -45,6 +50,7 @@
 
 struct H {
   H(std::vector);
+  H(MyVector, int);
 };
 
 struct I {
@@ -331,6 +337,13 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
   // CHECK-FIXES: PH1.reset(new H({1, 2, 3}));
 
+  std::unique_ptr PH2 = std::unique_ptr(new H({1, 2, 3}, 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr PH2 = std::unique_ptr(new H({1, 2, 3}, 1));
+  PH2.reset(new H({1, 2, 3}, 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PH2.reset(new H({1, 2, 3}, 1));
+
   std::unique_ptr PI1 = std::unique_ptr(new I(G({1, 2, 3})));
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PI1 = std::make_unique(G({1, 2, 3}));
Index: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_

[clang-tools-extra] r322822 - [clang-tidy] Don't generate fix for argument constructed from std::initializer_list.

2018-01-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jan 18 00:58:18 2018
New Revision: 322822

URL: http://llvm.org/viewvc/llvm-project?rev=322822&view=rev
Log:
[clang-tidy] Don't generate fix for argument constructed from 
std::initializer_list.

Summary:
A follow-up fix of rL311652.

The previous `vector` in our test is different with `std::vector`, so
The check still generates fixes for std::vector (`auto p =
std::unique_ptr(new Foo({1,2,3}))`) in real world, the patch makes the
vector behavior in test align with std::vector (both AST nodes are the same 
now).

Reviewers: ilya-biryukov, alexfh

Reviewed By: ilya-biryukov

Subscribers: klimek, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=322822&r1=322821&r2=322822&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Thu Jan 
18 00:58:18 2018
@@ -281,12 +281,25 @@ bool MakeSmartPtrCheck::replaceNew(Diagn
 if (isa(Arg)) {
   return false;
 }
+// Check whether we construct a class from a std::initializer_list.
+// If so, we won't generate the fixes.
+auto IsStdInitListInitConstructExpr = [](const Expr* E) {
+  assert(E);
+  if (const auto *ImplicitCE = dyn_cast(E)) {
+if (ImplicitCE->isStdInitListInitialization())
+  return true;
+  }
+  return false;
+};
 // Check the implicit conversion from the std::initializer_list type to
 // a class type.
-if (const auto *ImplicitCE = dyn_cast(Arg)) {
-  if (ImplicitCE->isStdInitListInitialization()) {
+if (IsStdInitListInitConstructExpr(Arg))
+  return false;
+// The Arg can be a CXXBindTemporaryExpr, checking its underlying
+// construct expr.
+if (const auto * CTE = dyn_cast(Arg)) {
+  if (IsStdInitListInitConstructExpr(CTE->getSubExpr()))
 return false;
-  }
 }
   }
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h?rev=322822&r1=322821&r2=322822&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h
 Thu Jan 18 00:58:18 2018
@@ -27,5 +27,6 @@ template 
 class vector {
  public:
   vector(initializer_list<_E> init);
+  ~vector();
 };
 } // namespace std

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=322822&r1=322821&r2=322822&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Thu Jan 
18 00:58:18 2018
@@ -25,6 +25,11 @@ struct DPair {
   int a, b;
 };
 
+template
+struct MyVector {
+  MyVector(std::initializer_list);
+};
+
 struct Empty {};
 
 struct E {
@@ -45,6 +50,7 @@ struct G {
 
 struct H {
   H(std::vector);
+  H(MyVector, int);
 };
 
 struct I {
@@ -331,6 +337,13 @@ void initialization(int T, Base b) {
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
   // CHECK-FIXES: PH1.reset(new H({1, 2, 3}));
 
+  std::unique_ptr PH2 = std::unique_ptr(new H({1, 2, 3}, 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr PH2 = std::unique_ptr(new H({1, 2, 3}, 
1));
+  PH2.reset(new H({1, 2, 3}, 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PH2.reset(new H({1, 2, 3}, 1));
+
   std::unique_ptr PI1 = std::unique_ptr(new I(G({1, 2, 3})));
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PI1 = std::make_unique(G({1, 2, 3}));


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


[PATCH] D41829: [cmake] Add cache file to bootstrap 2-stage linux cross compile on Darwin.

2018-01-18 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 130367.
hintonda added a comment.

Refactor to eliminate need for second stage and toolchain files.


Repository:
  rC Clang

https://reviews.llvm.org/D41829

Files:
  cmake/caches/Linux.cmake

Index: cmake/caches/Linux.cmake
===
--- /dev/null
+++ cmake/caches/Linux.cmake
@@ -0,0 +1,130 @@
+# This file is primarily for cross compiling clang+llvm, et al, for
+# Linux on Darwin, and can be invoked like this:
+#
+#  cmake -GNinja -DBOOTSTRAP_CMAKE_SYSROOT= [OPTIONS] \
+#-C /cmake/caches/Linux.cmake ../llvm
+#
+# Known issues:
+#
+#  1) This toolchain assumes a flat, mono-repo layout.
+#
+#  2) Several sub-projects, including libcxx, libcxxabi, and
+# libunwind, use find_path() to find the source path for headers
+# in the source directories of other sub-projects on the host
+# system, but fail because they don't specify
+# NO_CMAKE_FIND_ROOT_PATH.  The following patches are reqired to
+# build these projects:
+#
+# Patch: libcxx   https://reviews.llvm.org/D41622
+#libcxxabihttps://reviews.llvm.org/D41623
+#libunwindhttps://reviews.llvm.org/D41621
+#
+# Workaround: None
+#
+#  3) Stage2 configuration fails for several sub-projects which don't
+# explicitly handle rpath correctly, including compiler-rt,
+# libcxx, libcxxabi, and libunwind.  LLVM handles this in the
+# llvm_setup_rpath() function in AddLLVM.cmake.
+#
+# Patch: TBD
+#
+# Workaround: pass -DBOOTSTRAP_CMAKE_BUILD_WITH_INSTALL_RPATH=ON
+#
+#  4) To link elf binaries on Darwin, it's necessary to pass
+# CLANG_DEFAULT_LINKER=lld when building the compiler used in
+# stage2.  Unfortunately, ld64.lld does not yet handle several
+# arguments sent by clang, causing Native tool configuration to
+# fail.  In order to prevent this, it is necessary to pass
+# CLANG_TABLEGEN, LLVM_TABLEGEN, and LLVM_CONFIG_EXE.
+#
+# Patch: https://reviews.llvm.org/D41806
+#
+# Workaround: None
+#
+#  5) If CMAKE_ASM_COMPILER is set, cmake assumes
+# CMAKE_ASM_COMPILER_ID was also set, and doesn't try to set it.
+# Without CMAKE_ASM_COMPILER_ID, cmake can't set
+# CMAKE_ASM_COMPILER_OPTIONS_TARGET either, which means
+# CMAKE_ASM_COMPILER_TARGET is ignored, causing cross compiling to
+# fail, i.e., `--target=${CMAKE_ASM_COMPILER_TARGET}` isn't
+# passed.
+#
+# Patch: https://reviews.llvm.org/D42232
+#
+# Workaround: pass -DBOOTSTRAP_CMAKE_ASM_COMPILER_ID=Clang
+
+if(NOT DEFINED BOOTSTRAP_CMAKE_SYSROOT)
+  message(FATAL_ERROR "Missing required argument -DBOOTSTRAP_CMAKE_SYSROOT=.")
+endif()
+
+# FIXME: Default to Linux, but should this be required?
+if(NOT DEFINED BOOTSTRAP_CMAKE_SYSTEM_NAME)
+	set(BOOTSTRAP_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
+endif()
+
+# FIXME:  Should this default be based on BOOTSTRAP_CMAKE_SYSTEM_NAME?
+if(NOT DEFINED BOOTSTRAP_LLVM_DEFAULT_BOOTSTRAP_TRIPLE)
+  set(BOOTSTRAP_LLVM_DEFAULT_BOOTSTRAP_TRIPLE "x86_64-unknown-linux-gnu")
+endif()
+
+if(NOT DEFINED BOOTSTRAP_GCC_INSTALL_PREFIX)
+  # Force clang to look for gcc at runtime -- otherwise it will
+  # default to 4.2.1.
+  set(BOOTSTRAP_GCC_INSTALL_PREFIX "/usr" CACHE STRING "")
+endif()
+
+# Allow user to pass a custom stage2 cache file.
+if(DEFINED STAGE2_CACHE_FILE)
+	list(APPEND EXTRA_ARGS -C${STAGE2_CACHE_FILE})
+endif()
+
+list(APPEND EXTRA_ARGS
+	-DCMAKE_C_COMPILER_TARGET=${BOOTSTRAP_LLVM_DEFAULT_BOOTSTRAP_TRIPLE}
+	-DCMAKE_CXX_COMPILER_TARGET=${BOOTSTRAP_LLVM_DEFAULT_BOOTSTRAP_TRIPLE}
+	-DCMAKE_ASM_COMPILER_TARGET=${BOOTSTRAP_LLVM_DEFAULT_BOOTSTRAP_TRIPLE}
+
+	# Adjust the default behaviour of the FIND_XXX() commands to only
+	# search for headers and libraries in the
+	# CMAKE_SYSROOT/CMAKE_FIND_ROOT_PATH, and always search for programs
+	# in the host system.  These all default to BOTH.
+	-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+	-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
+	-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
+	)
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_RUNTIMES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(CLANG_BUILD_TOOLS OFF CACHE BOOL "")
+set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
+set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
+
+# FIXME: Is there a better way to specify this? i.e., target is elf,
+# but host isn't.
+if(CMAKE_HOST_APPLE)
+  # Make sure at least clang and lld are included.
+  set(LLVM_ENABLE_PROJECTS ${LLVM_ENABLE_PROJECTS} clang lld CACHE STRING "")
+
+  # Passing -fuse-ld=lld is hard for cmake to handle correctly, so
+  # make lld the default linker.
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+
+	list(APPEND EXTRA_ARGS
+		-DLLVM_

[clang-tools-extra] r322824 - [clangd] CodeCompleteTests cleanup: naming, ordering, helpers. NFC

2018-01-18 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jan 18 01:27:56 2018
New Revision: 322824

URL: http://llvm.org/viewvc/llvm-project?rev=322824&view=rev
Log:
[clangd] CodeCompleteTests cleanup: naming, ordering, helpers. NFC

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=322824&r1=322823&r2=322824&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan 18 
01:27:56 2018
@@ -97,8 +97,25 @@ Matcher memIndex(std::vector Symbols) {
+  SymbolSlab::Builder Slab;
+  for (const auto &Sym : Symbols)
+Slab.insert(Sym);
+  return MemIndex::build(std::move(Slab).build());
+}
+
+// Builds a server and runs code completion.
+// If IndexSymbols is non-empty, an index will be built and passed to opts.
 CompletionList completions(StringRef Text,
+   std::vector IndexSymbols = {},
clangd::CodeCompleteOptions Opts = {}) {
+  std::unique_ptr OverrideIndex;
+  if (!IndexSymbols.empty()) {
+assert(!Opts.Index && "both Index and IndexSymbols given!");
+OverrideIndex = memIndex(std::move(IndexSymbols));
+Opts.Index = OverrideIndex.get();
+  }
+
   MockFSProvider FS;
   MockCompilationDatabase CDB;
   IgnoreDiagnostics DiagConsumer;
@@ -116,6 +133,27 @@ CompletionList completions(StringRef Tex
   return CompletionList;
 }
 
+// Helpers to produce fake index symbols for memIndex() or completions().
+Symbol sym(StringRef QName, index::SymbolKind Kind) {
+  Symbol Sym;
+  Sym.ID = SymbolID(QName);
+  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);
+  }
+  Sym.CompletionPlainInsertText = Sym.Name;
+  Sym.CompletionLabel = Sym.Name;
+  Sym.SymInfo.Kind = Kind;
+  return Sym;
+}
+Symbol func(StringRef Name) { return sym(Name, index::SymbolKind::Function); }
+Symbol cls(StringRef Name) { return sym(Name, index::SymbolKind::Class); }
+Symbol var(StringRef Name) { return sym(Name, index::SymbolKind::Variable); }
+
 TEST(CompletionTest, Limit) {
   clangd::CodeCompleteOptions Opts;
   Opts.Limit = 2;
@@ -127,7 +165,7 @@ struct ClassWithMembers {
 }
 int main() { ClassWithMembers().^ }
   )cpp",
- Opts);
+ /*IndexSymbols=*/{}, Opts);
 
   EXPECT_TRUE(Results.isIncomplete);
   EXPECT_THAT(Results.items, ElementsAre(Named("AAA"), Named("BBB")));
@@ -188,7 +226,7 @@ void TestAfterDotCompletion(clangd::Code
 ClassWithMembers().^
   }
   )cpp",
-  Opts);
+  /*IndexSymbols=*/{}, Opts);
 
   // Class members. The only items that must be present in after-dot
   // completion.
@@ -233,7 +271,7 @@ void TestGlobalScopeCompletion(clangd::C
 ^
   }
   )cpp",
-  Opts);
+  /*IndexSymbols=*/{}, Opts);
 
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.items,
@@ -355,7 +393,7 @@ TEST(CompletionTest, Snippets) {
 f.^
   }
   )cpp",
-  Opts);
+  /*IndexSymbols=*/{}, Opts);
   EXPECT_THAT(Results.items,
   HasSubsequence(Snippet("a"),
  Snippet("f(${1:int i}, ${2:const float f})")));
@@ -375,9 +413,6 @@ TEST(CompletionTest, Kinds) {
   EXPECT_THAT(Results.items, Has("Struct", CompletionItemKind::Class));
   EXPECT_THAT(Results.items, Has("MACRO", CompletionItemKind::Text));
 
-  clangd::CodeCompleteOptions Opts;
-  Opts.EnableSnippets = true; // Needed for code patterns.
-
   Results = completions("nam^");
   EXPECT_THAT(Results.items, Has("namespace", CompletionItemKind::Snippet));
 }
@@ -406,184 +441,67 @@ TEST(CompletionTest, FuzzyRanking) {
   EXPECT_THAT(Items, ElementsAre(Named("BigBang"), Named("Babble")));
 }
 
-SignatureHelp signatures(StringRef Text) {
-  MockFSProvider FS;
-  MockCompilationDatabase CDB;
-  IgnoreDiagnostics DiagConsumer;
-  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true);
-  auto File = getVirtualTestFilePath("foo.cpp");
-  Annotations Test(Text);
-  Server.addDocument(Context::empty(), File, Test.code());
-  auto R = Server.signatureHelp(Context::empty(), File, Test.point());
-  assert(R);
-  return R.get().Value;
-}
-
-MATCHER_P(ParamsAre, P, "") {
-  if (P.size() != arg.parameters.size())
-return false;
-  for (unsigned I = 0; I < P.size(); ++I)
-if (P[I] != arg.parameters[I].label)
-  return false;
-  return true;
-}
-
-Matcher Sig(std::string Label,
-  std::vector Params) {
-  return AllOf(Labeled(Labe

[PATCH] D42185: [ASTMatcher] Add isScoped matcher for enumDecl.

2018-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 130370.
hokein added a comment.

- add the matcher to dynamic registry.
- add documentation.
- remove duplicated ";".


Repository:
  rC Clang

https://reviews.llvm.org/D42185

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2107,5 +2107,10 @@
   cxxRecordDecl(hasDefinition(;
 }
 
+TEST(IsScopedEnum, MatchesScopedEnum) {
+  EXPECT_TRUE(matches("enum class X {};", enumDecl(isScoped(;
+  EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -361,6 +361,7 @@
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5880,6 +5880,17 @@
   return Node.hasDefinition();
 }
 
+/// \brief Matches C++11 scoped enum declaration.
+///
+/// Example matches Y (matcher = enumDecl(isScoped()))
+/// \code
+/// enum X {};
+/// enum class Y {};
+/// \endcode
+AST_MATCHER(EnumDecl, isScoped) {
+  return Node.isScoped();
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2644,6 +2644,15 @@
 
 
 
+MatcherEnumDecl>isScoped
+Matches C++11 scoped enum 
declaration.
+
+Example matches Y (matcher = enumDecl(isScoped()))
+enum X {};
+enum class Y {};
+
+
+
 MatcherFieldDecl>hasBitWidthunsigned Width
 Matches non-static data 
members that are bit-fields of the specified
 bit width.


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2107,5 +2107,10 @@
   cxxRecordDecl(hasDefinition(;
 }
 
+TEST(IsScopedEnum, MatchesScopedEnum) {
+  EXPECT_TRUE(matches("enum class X {};", enumDecl(isScoped(;
+  EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -361,6 +361,7 @@
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5880,6 +5880,17 @@
   return Node.hasDefinition();
 }
 
+/// \brief Matches C++11 scoped enum declaration.
+///
+/// Example matches Y (matcher = enumDecl(isScoped()))
+/// \code
+/// enum X {};
+/// enum class Y {};
+/// \endcode
+AST_MATCHER(EnumDecl, isScoped) {
+  return Node.isScoped();
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2644,6 +2644,15 @@
 
 
 
+MatcherEnumDecl>isScoped
+Matches C++11 scoped enum declaration.
+
+Example matches Y (matcher = enumDecl(isScoped()))
+enum X {};
+enum class Y {};
+
+
+
 MatcherFieldDecl>hasBitWidthunsigned Width
 Matches non-static data members that are bit-fields of the specified
 bit width.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322826 - [ASTMatcher] Add isScoped matcher for enumDecl.

2018-01-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jan 18 01:47:57 2018
New Revision: 322826

URL: http://llvm.org/viewvc/llvm-project?rev=322826&view=rev
Log:
[ASTMatcher] Add isScoped matcher for enumDecl.

Summary:

Reviewers: bkramer, aaron.ballman

Subscribers: aaron.ballman, cfe-commits, klimek

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=322826&r1=322825&r2=322826&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Jan 18 01:47:57 2018
@@ -2644,6 +2644,15 @@ designatorCountIs(2)
 
 
 
+MatcherEnumDecl>isScoped
+Matches C++11 scoped enum 
declaration.
+
+Example matches Y (matcher = enumDecl(isScoped()))
+enum X {};
+enum class Y {};
+
+
+
 MatcherFieldDecl>hasBitWidthunsigned Width
 Matches non-static data 
members that are bit-fields of the specified
 bit width.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=322826&r1=322825&r2=322826&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Jan 18 01:47:57 2018
@@ -5880,6 +5880,17 @@ AST_MATCHER(CXXRecordDecl, hasDefinition
   return Node.hasDefinition();
 }
 
+/// \brief Matches C++11 scoped enum declaration.
+///
+/// Example matches Y (matcher = enumDecl(isScoped()))
+/// \code
+/// enum X {};
+/// enum class Y {};
+/// \endcode
+AST_MATCHER(EnumDecl, isScoped) {
+  return Node.isScoped();
+}
+
 } // namespace ast_matchers
 } // namespace clang
 

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=322826&r1=322825&r2=322826&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Thu Jan 18 01:47:57 2018
@@ -361,6 +361,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=322826&r1=322825&r2=322826&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Thu Jan 18 
01:47:57 2018
@@ -2107,5 +2107,10 @@ TEST(HasDefinition, MatchesUnionDefiniti
   cxxRecordDecl(hasDefinition(;
 }
 
+TEST(IsScopedEnum, MatchesScopedEnum) {
+  EXPECT_TRUE(matches("enum class X {};", enumDecl(isScoped(;
+  EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
+}
+
 } // namespace ast_matchers
 } // namespace clang


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


Re: r322769 - [RISCV] Propagate -mabi and -march values to GNU assembler.

2018-01-18 Thread Alex Bradbury via cfe-commits
On 18 January 2018 at 00:38, Rafael Avila de Espindola via cfe-commits
 wrote:
> With this I am getting a test failure on linux:
>
>  TEST 'Clang :: Driver/riscv-gnutools.c' FAILED 
> 
> Script:
> --
> /home/admin/llvm/build/bin/clang -target riscv32-linux-unknown-elf 
> -fno-integrated-as  
> --gcc-toolchain=/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk
>   
> --sysroot=/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot
>  /home/admin/llvm/llvm-project/clang/test/Driver/riscv-gnutools.c -###  2>&1 
> | /home/admin/llvm/build/bin/FileCheck -check-prefix=MABI-ILP32 
> /home/admin/llvm/llvm-project/clang/test/Driver/riscv-gnutools.c
> /home/admin/llvm/build/bin/clang -target riscv32-linux-unknown-elf 
> -fno-integrated-as  -march=rv32g 
> --gcc-toolchain=/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk
>   
> --sysroot=/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot
>  /home/admin/llvm/llvm-project/clang/test/Driver/riscv-gnutools.c -###  2>&1 
> | /home/admin/llvm/build/bin/FileCheck -check-prefix=MABI-ILP32-MARCH-G 
> /home/admin/llvm/llvm-project/clang/test/Driver/riscv-gnutools.c
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /home/admin/llvm/llvm-project/clang/test/Driver/riscv-gnutools.c:12:16: 
> error: expected string not found in input
> // MABI-ILP32: 
> "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as"
>  "-mabi" "ilp32"
>^
> :1:1: note: scanning from here
> clang version 7.0.0
> ^
> :7:42: note: possible intended match here
>  
> "/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld"
>  
> "--sysroot=/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot"
>  "--hash-style=both" "--eh-frame-hdr" "-m" "elf32lriscv" "-dynamic-linker" 
> "/lib/ld-linux-riscv32-ilp32.so.1" "-o" "a.out" "crt1.o" "crti.o" 
> "/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32/crtbegin.o"
>  
> "-L/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32"
>  
> "-L/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot/lib/../lib32"
>  
> "-L/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32"
>  
> "-L/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
>  
> "-L/home/admin/llvm/llvm-project/clang/test/Driver/Inputs/multilib_riscv_linux_sdk/sysroot/lib"
>  "/tmp/lit_tmp_9u9TOy/riscv-gnutools-ebce8c.o" "-lgcc" "--as-needed" 
> "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" 
> "--no-as-needed" "crtend.o" "crtn.o"
>  ^

Thanks for pasting the failure Rafael. I'm surprised that neither
/bin/as or Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as
show up here at all. It does seem that the dummy `as` was added
without the svn:executable property. Ana: I believe you need to do
`svn propset svn:executable on $file` in order to have the executable
bit preserved. That seems a likely culprit, but as I say I would have
expected to see /usr/bin/as in the above.

Best,

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


[PATCH] D42074: [clangd] Collect enum constants in SymbolCollector

2018-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 130372.
hokein marked 2 inline comments as done.
hokein added a comment.
Herald added a reviewer: jkorous-apple.

Ignore enum constants in scoped enum.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42074

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -161,6 +161,36 @@
QName("foo::baz")}));
 }
 
+TEST_F(SymbolCollectorTest, IncludeEnums) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+enum {
+  Red
+};
+enum Color {
+  Green
+};
+enum class Color2 {
+  Yellow // ignore
+};
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
+QName("Green"), QName("Color2")));
+}
+
+TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+struct {
+  int a;
+} Foo;
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Foo")));
+}
+
 TEST_F(SymbolCollectorTest, IgnoreSymbolsInMainFile) {
   CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -71,6 +71,10 @@
   using namespace clang::ast_matchers;
   if (ND->isImplicit())
 return true;
+  // Skip nameless declarations.
+  if (ND->getDeclName().isEmpty())
+return true;
+
   // FIXME: figure out a way to handle internal linkage symbols (e.g. static
   // variables, function) defined in the .cc files. Also we skip the symbols
   // in anonymous namespace as the qualifier names of these symbols are like
@@ -82,12 +86,18 @@
   if (ND->isInAnonymousNamespace())
 return true;
 
-  // We only want symbols in namespaces or translation unit scopes (e.g. no
-  // class members).
-  if (match(decl(allOf(
-Opts.IndexMainFiles ? decl()
-: decl(unless(isExpansionInMainFile())),
-hasDeclContext(anyOf(namespaceDecl(), 
translationUnitDecl(),
+  // We only want:
+  //   * symbols in namespaces or translation unit scopes (e.g. no class
+  // members)
+  //   * enum constants in unscoped enum decl (e.g. "red" in "enum {red};")
+  auto InTopLevelScope =
+  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl()));
+  if (match(decl(allOf(Opts.IndexMainFiles
+   ? decl()
+   : decl(unless(isExpansionInMainFile())),
+   anyOf(InTopLevelScope,
+ hasDeclContext(enumDecl(InTopLevelScope,
+ unless(isScoped())),
 *ND, *ASTCtx)
   .empty())
 return true;


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -161,6 +161,36 @@
QName("foo::baz")}));
 }
 
+TEST_F(SymbolCollectorTest, IncludeEnums) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+enum {
+  Red
+};
+enum Color {
+  Green
+};
+enum class Color2 {
+  Yellow // ignore
+};
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
+QName("Green"), QName("Color2")));
+}
+
+TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+struct {
+  int a;
+} Foo;
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Foo")));
+}
+
 TEST_F(SymbolCollectorTest, IgnoreSymbolsInMainFile) {
   CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -71,6 +71,10 @@
   using namespace clang::ast_matchers;
   if (ND->isImplicit())
 return true;
+  // Skip nameless declarations.
+  if (ND->getDeclName().isEmpty())
+return true;
+
   // FIXME: figure out a way to handle internal linkage symbols (e.g. static
   // variables, function) defined in the .cc files. Also we skip the symbols
   // in anonymous namespace as the qualifier names of these symbols

[PATCH] D42074: [clangd] Collect enum constants in SymbolCollector

2018-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:75
+  // Skip nameless declarations.
+  if (ND->getDeclName().isEmpty())
+return true;

ilya-biryukov wrote:
> What are those declarations exactly?
This would  ignore anonymous declarations, e.g. anonymous class/enum. See the 
unittest.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:174
+enum class Color2 {
+  Yellow
+};

ilya-biryukov wrote:
> I'd say we should drop `enum` constants inside stongly-typed enums (i.e. 
> `enum class`).
> They can't be found inside namespace by code completion, therefore being 
> similar to static method in that regard. (And we don't include static methods 
> now, right?)
yeah, that makes sense. 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42074



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


[PATCH] D42185: [ASTMatcher] Add isScoped matcher for enumDecl.

2018-01-18 Thread Haojian Wu via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rC322826: [ASTMatcher] Add isScoped matcher for enumDecl. 
(authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42185?vs=130370&id=130371#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42185

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2107,5 +2107,10 @@
   cxxRecordDecl(hasDefinition(;
 }
 
+TEST(IsScopedEnum, MatchesScopedEnum) {
+  EXPECT_TRUE(matches("enum class X {};", enumDecl(isScoped(;
+  EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2644,6 +2644,15 @@
 
 
 
+MatcherEnumDecl>isScoped
+Matches C++11 scoped enum 
declaration.
+
+Example matches Y (matcher = enumDecl(isScoped()))
+enum X {};
+enum class Y {};
+
+
+
 MatcherFieldDecl>hasBitWidthunsigned Width
 Matches non-static data 
members that are bit-fields of the specified
 bit width.
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5880,6 +5880,17 @@
   return Node.hasDefinition();
 }
 
+/// \brief Matches C++11 scoped enum declaration.
+///
+/// Example matches Y (matcher = enumDecl(isScoped()))
+/// \code
+/// enum X {};
+/// enum class Y {};
+/// \endcode
+AST_MATCHER(EnumDecl, isScoped) {
+  return Node.isScoped();
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -361,6 +361,7 @@
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2107,5 +2107,10 @@
   cxxRecordDecl(hasDefinition(;
 }
 
+TEST(IsScopedEnum, MatchesScopedEnum) {
+  EXPECT_TRUE(matches("enum class X {};", enumDecl(isScoped(;
+  EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2644,6 +2644,15 @@
 
 
 
+MatcherEnumDecl>isScoped
+Matches C++11 scoped enum declaration.
+
+Example matches Y (matcher = enumDecl(isScoped()))
+enum X {};
+enum class Y {};
+
+
+
 MatcherFieldDecl>hasBitWidthunsigned Width
 Matches non-static data members that are bit-fields of the specified
 bit width.
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5880,6 +5880,17 @@
   return Node.hasDefinition();
 }
 
+/// \brief Matches C++11 scoped enum declaration.
+///
+/// Example matches Y (matcher = enumDecl(isScoped()))
+/// \code
+/// enum X {};
+/// enum class Y {};
+/// \endcode
+AST_MATCHER(EnumDecl, isScoped) {
+  return Node.isScoped();
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -361,6 +361,7 @@
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);
_

[PATCH] D42074: [clangd] Collect enum constants in SymbolCollector

2018-01-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:164
 
+TEST_F(SymbolCollectorTest, IncludeEnums) {
+  CollectorOpts.IndexMainFiles = false;

Could you add a test case like the following and check whether `ns::X` is in 
the result?

```
namespace ns {
  enum {
 X
  };
}
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42074



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


[clang-tools-extra] r322827 - [clangd] Output log messages to stderr when not configured (e.g. in tests). NFC

2018-01-18 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jan 18 02:24:01 2018
New Revision: 322827

URL: http://llvm.org/viewvc/llvm-project?rev=322827&view=rev
Log:
[clangd] Output log messages to stderr when not configured (e.g. in tests). NFC

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

Modified: clang-tools-extra/trunk/clangd/Logger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Logger.cpp?rev=322827&r1=322826&r2=322827&view=diff
==
--- clang-tools-extra/trunk/clangd/Logger.cpp (original)
+++ clang-tools-extra/trunk/clangd/Logger.cpp Thu Jan 18 02:24:01 2018
@@ -8,6 +8,8 @@
 
//===--===//
 
 #include "Logger.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -24,9 +26,13 @@ LoggingSession::LoggingSession(clangd::L
 LoggingSession::~LoggingSession() { L = nullptr; }
 
 void log(const Context &Ctx, const llvm::Twine &Message) {
-  if (!L)
-return;
-  L->log(Ctx, Message);
+  if (L)
+L->log(Ctx, Message);
+  else {
+static std::mutex Mu;
+std::lock_guard Guard(Mu);
+llvm::errs() << Message << "\n";
+  }
 }
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/Logger.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Logger.h?rev=322827&r1=322826&r2=322827&view=diff
==
--- clang-tools-extra/trunk/clangd/Logger.h (original)
+++ clang-tools-extra/trunk/clangd/Logger.h Thu Jan 18 02:24:01 2018
@@ -16,8 +16,9 @@
 namespace clang {
 namespace clangd {
 
-/// Main logging function. Logs messages to a global logger, which can be set 
up
-/// by LoggingSesssion.
+/// Main logging function.
+/// Logs messages to a global logger, which can be set up by LoggingSesssion.
+/// If no logger is registered, writes to llvm::errs().
 void log(const Context &Ctx, const llvm::Twine &Message);
 
 /// Interface to allow custom logging in clangd.


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


[PATCH] D41947: Provide default virtual filesystem argument to ClangTool constructor

2018-01-18 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun updated this revision to Diff 130382.
vladimir.plyashkun added a comment.

Implemented test-case to check that `BaseFS` is actually used in `ClangTool`


Repository:
  rC Clang

https://reviews.llvm.org/D41947

Files:
  include/clang/Tooling/Tooling.h
  lib/Tooling/Tooling.cpp
  unittests/Tooling/ToolingTest.cpp


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -402,6 +402,24 @@
   EXPECT_FALSE(Found);
 }
 
+TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
+  FixedCompilationDatabase Compilations("/", std::vector());
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile(
+  "a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
+
+  ClangTool Tool(Compilations, std::vector(1, "a.cpp"),
+ std::make_shared(), 
OverlayFileSystem);
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+  EXPECT_EQ(0, Tool.run(Action.get()));
+}
+
 // Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
 TEST(ClangToolTest, StripDependencyFileAdjuster) {
   FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -328,10 +328,11 @@
 
 ClangTool::ClangTool(const CompilationDatabase &Compilations,
  ArrayRef SourcePaths,
- std::shared_ptr PCHContainerOps)
+ std::shared_ptr PCHContainerOps,
+ IntrusiveRefCntPtr BaseFS)
 : Compilations(Compilations), SourcePaths(SourcePaths),
   PCHContainerOps(std::move(PCHContainerOps)),
-  OverlayFileSystem(new vfs::OverlayFileSystem(vfs::getRealFileSystem())),
+  OverlayFileSystem(new vfs::OverlayFileSystem(BaseFS)),
   InMemoryFileSystem(new vfs::InMemoryFileSystem),
   Files(new FileManager(FileSystemOptions(), OverlayFileSystem)),
   DiagConsumer(nullptr) {
Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -296,10 +296,13 @@
   ///not found in Compilations, it is skipped.
   /// \param PCHContainerOps The PCHContainerOperations for loading and 
creating
   /// clang modules.
+  /// \param BaseFS Base virtual filesystem used for OverlayFileSystem creation
   ClangTool(const CompilationDatabase &Compilations,
 ArrayRef SourcePaths,
 std::shared_ptr PCHContainerOps =
-std::make_shared());
+std::make_shared(),
+IntrusiveRefCntPtr BaseFS = 
+vfs::getRealFileSystem());
 
   ~ClangTool();
 


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -402,6 +402,24 @@
   EXPECT_FALSE(Found);
 }
 
+TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
+  FixedCompilationDatabase Compilations("/", std::vector());
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile(
+  "a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
+
+  ClangTool Tool(Compilations, std::vector(1, "a.cpp"),
+ std::make_shared(), OverlayFileSystem);
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+  EXPECT_EQ(0, Tool.run(Action.get()));
+}
+
 // Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
 TEST(ClangToolTest, StripDependencyFileAdjuster) {
   FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -328,10 +328,11 @@
 
 ClangTool::ClangTool(const CompilationDatabase &Compilations,
  ArrayRef SourcePaths,
- std::shared_ptr PCHContainerOps)
+ std::shared_ptr PCHContainerOps,
+ IntrusiveRefCntPtr BaseFS)
 : Compilations(Compilations), SourcePaths(SourcePaths),
   PCHContainerOps(std::move(PCHContainerOps)),
-  OverlayFileSystem(new vfs::OverlayFileSystem(vfs::getRealFileSystem())),
+  OverlayFileSystem(new vfs::OverlayFileSystem(BaseFS)),
   InMemoryFileSystem(new vfs::InMemoryFileSystem),
   Files

[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-01-18 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 130384.
yvvan added a comment.

Rebased. Applies for current master.

Also ping again...


https://reviews.llvm.org/D41537

Files:
  include/clang-c/Index.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/CodeCompleteOptions.h
  lib/Frontend/ASTUnit.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndexCodeCompletion.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -173,6 +173,7 @@
 clang_getCompletionNumAnnotations
 clang_getCompletionParent
 clang_getCompletionPriority
+clang_getCompletionRequiresDotToArrowCorrection
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -238,6 +238,16 @@
   return cxstring::createRef(CCStr->getBriefComment());
 }
 
+unsigned
+clang_getCompletionRequiresDotToArrowCorrection(CXCompletionString completion_string) {
+  CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+
+  if (!CCStr)
+return false;
+
+  return CCStr->requiresDotToArrowCorrection();
+}
+
 namespace {
 
 /// \brief The CXCodeCompleteResults structure we allocate internally;
@@ -644,13 +654,13 @@
   unsigned options) {
   bool IncludeBriefComments = options & CXCodeComplete_IncludeBriefComments;
   bool SkipPreamble = options & CXCodeComplete_SkipPreamble;
+  bool TryArrowInsteadOfDot = options & CXCodeComplete_TryArrowInsteadOfDot;
 
 #ifdef UDP_CODE_COMPLETION_LOGGER
 #ifdef UDP_CODE_COMPLETION_LOGGER_PORT
   const llvm::TimeRecord &StartTime =  llvm::TimeRecord::getCurrentTime();
 #endif
 #endif
-
   bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != nullptr;
 
   if (cxtu::isNotUsableTU(TU)) {
@@ -691,6 +701,7 @@
   CodeCompleteOptions Opts;
   Opts.IncludeBriefComments = IncludeBriefComments;
   Opts.LoadExternal = !SkipPreamble;
+  Opts.TryArrowInsteadOfDot = TryArrowInsteadOfDot;
   CaptureCompletionResults Capture(Opts, *Results, &TU);
 
   // Perform completion.
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -2322,7 +2322,13 @@
 fprintf(file, "(brief comment: %s)", BriefCommentCString);
   }
   clang_disposeString(BriefComment);
-  
+
+  unsigned RequiresDotToArrowCorrection =
+  clang_getCompletionRequiresDotToArrowCorrection(
+  completion_result->CompletionString);
+  if (RequiresDotToArrowCorrection) {
+fprintf(file, " (requires correction: \".\" to \"->\")");
+  }
   fprintf(file, "\n");
 }
 
@@ -2421,6 +2427,8 @@
 completionOptions |= CXCodeComplete_IncludeBriefComments;
   if (getenv("CINDEXTEST_COMPLETION_SKIP_PREAMBLE"))
 completionOptions |= CXCodeComplete_SkipPreamble;
+  if (getenv("CINDEXTEST_COMPLETION_TRY_ARROW_INSTEAD_OF_DOT"))
+completionOptions |= CXCodeComplete_TryArrowInsteadOfDot;
   
   if (timing_only)
 input += strlen("-code-completion-timing=");
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -2749,7 +2749,8 @@
CodeCompletionAllocator &Allocator,
CodeCompletionTUInfo &CCTUInfo,
bool IncludeBriefComments) {
-  CodeCompletionBuilder Result(Allocator, CCTUInfo, Priority, Availability);
+  CodeCompletionBuilder Result(Allocator, CCTUInfo, Priority, Availability,
+   RequiresDotToArrowCorrection);
   
   PrintingPolicy Policy = getCompletionPrintingPolicy(Ctx, PP);
   if (Kind == RK_Pattern) {
@@ -3974,62 +3975,41 @@
   }
 }
 
-void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
-   SourceLocation OpLoc, bool IsArrow,
-   bool IsBaseExprStatement) {
-  if (!Base || !CodeCompleter)
-return;
-  
-  ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
-  if (ConvertedBase.isInvalid())
-return;
-  Base = ConvertedBase.get();
-  
-  QualType BaseType = Base->getType();
-
-  if (IsArrow) {
-if (const PointerType *Ptr = BaseType->getAs())
-  BaseType = Ptr->getPointeeType();
-else if (BaseType->isObjCObjectPointerType())
-  /*Do nothing*/ ;
-else
-  return;
-  }
-  
+static ResultBuilder
+GetCodeCompleteMemberReferenceResults(Sema &SemaRef, Scope *S,
+  QualType Ba

[PATCH] D41535: Add -vfsoverlay option for Clang-Tidy

2018-01-18 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun updated this revision to Diff 130385.
vladimir.plyashkun added a comment.

Moved logic to `ClangTidyMain`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41535

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -17,6 +17,7 @@
 
 #include "../ClangTidy.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/TargetSelect.h"
 
@@ -209,6 +210,12 @@
cl::init(false),
cl::cat(ClangTidyCategory));
 
+static cl::opt VfsOverlay("vfsoverlay", cl::desc(R"(
+Overlay the virtual filesystem described by file over the real file system.
+)"),
+   cl::value_desc("filename"),
+   cl::cat(ClangTidyCategory));
+
 namespace clang {
 namespace tidy {
 
@@ -330,6 +337,24 @@
 OverrideOptions);
 }
 
+void pushVfsOverlayFromFile(const std::string &OverlayFile,
+vfs::OverlayFileSystem &OverlayFS) {
+  llvm::ErrorOr> Buffer =
+  OverlayFS.getBufferForFile(OverlayFile);
+  if (!Buffer) {
+llvm::errs() << diag::err_missing_vfs_overlay_file << OverlayFile;
+return;
+  }
+
+  IntrusiveRefCntPtr FS = vfs::getVFSFromYAML(
+  std::move(Buffer.get()), /*DiagHandler*/ nullptr, OverlayFile);
+  if (!FS.get()) {
+llvm::errs() << diag::err_invalid_vfs_overlay << OverlayFile;
+return;
+  }
+  OverlayFS.pushOverlay(FS);
+}
+
 static int clangTidyMain(int argc, const char **argv) {
   CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
 cl::ZeroOrMore);
@@ -402,15 +427,21 @@
 return 0;
   }
 
+  llvm::IntrusiveRefCntPtr BaseFS(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  if (!VfsOverlay.empty()) {
+pushVfsOverlayFromFile(VfsOverlay, *BaseFS);
+  }
+
   ProfileData Profile;
 
   llvm::InitializeAllTargetInfos();
   llvm::InitializeAllTargetMCs();
   llvm::InitializeAllAsmParsers();
 
   ClangTidyContext Context(std::move(OwningOptionsProvider));
   runClangTidy(Context, OptionsParser.getCompilations(), PathList,
-   EnableCheckProfile ? &Profile : nullptr);
+   BaseFS, EnableCheckProfile ? &Profile : nullptr);
   ArrayRef Errors = Context.getErrors();
   bool FoundErrors =
   std::find_if(Errors.begin(), Errors.end(), [](const ClangTidyError &E) {
@@ -422,7 +453,7 @@
   unsigned WErrorCount = 0;
 
   // -fix-errors implies -fix.
-  handleErrors(Context, (FixErrors || Fix) && !DisableFixes, WErrorCount);
+  handleErrors(Context, (FixErrors || Fix) && !DisableFixes, WErrorCount, BaseFS);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -227,6 +227,7 @@
 void runClangTidy(clang::tidy::ClangTidyContext &Context,
   const tooling::CompilationDatabase &Compilations,
   ArrayRef InputFiles,
+  llvm::IntrusiveRefCntPtr BaseFS,
   ProfileData *Profile = nullptr);
 
 // FIXME: This interface will need to be significantly extended to be useful.
@@ -236,7 +237,8 @@
 /// Errors containing fixes are automatically applied and reformatted. If no
 /// clang-format configuration file is found, the given \P FormatStyle is used.
 void handleErrors(ClangTidyContext &Context, bool Fix,
-  unsigned &WarningsAsErrorsCount);
+  unsigned &WarningsAsErrorsCount,
+  llvm::IntrusiveRefCntPtr BaseFS);
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -89,8 +89,10 @@
 
 class ErrorReporter {
 public:
-  ErrorReporter(ClangTidyContext &Context, bool ApplyFixes)
-  : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()),
+  ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
+llvm::IntrusiveRefCntPtr BaseFS)
+  : Files(FileSystemOptions(), BaseFS), 
+DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
@@ -474,8 +476,11 @@
 
 void runClangTidy(clang::tidy::ClangTidyContext &Context,
   const CompilationDatabase &Compilations,
-  ArrayRef InputFiles, ProfileData *Profile) {
-  ClangTool Tool

[PATCH] D42074: [clangd] Collect enum constants in SymbolCollector

2018-01-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 130395.
hokein marked an inline comment as done.
hokein added a comment.

Add one more test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42074

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -161,6 +161,43 @@
QName("foo::baz")}));
 }
 
+TEST_F(SymbolCollectorTest, IncludeEnums) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+enum {
+  Red
+};
+enum Color {
+  Green
+};
+enum class Color2 {
+  Yellow // ignore
+};
+namespace ns {
+enum {
+  Black
+};
+}
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
+QName("Green"), QName("Color2"),
+QName("ns"),
+QName("ns::Black")));
+}
+
+TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+struct {
+  int a;
+} Foo;
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Foo")));
+}
+
 TEST_F(SymbolCollectorTest, IgnoreSymbolsInMainFile) {
   CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -71,6 +71,10 @@
   using namespace clang::ast_matchers;
   if (ND->isImplicit())
 return true;
+  // Skip nameless declarations.
+  if (ND->getDeclName().isEmpty())
+return true;
+
   // FIXME: figure out a way to handle internal linkage symbols (e.g. static
   // variables, function) defined in the .cc files. Also we skip the symbols
   // in anonymous namespace as the qualifier names of these symbols are like
@@ -82,12 +86,18 @@
   if (ND->isInAnonymousNamespace())
 return true;
 
-  // We only want symbols in namespaces or translation unit scopes (e.g. no
-  // class members).
-  if (match(decl(allOf(
-Opts.IndexMainFiles ? decl()
-: decl(unless(isExpansionInMainFile())),
-hasDeclContext(anyOf(namespaceDecl(), 
translationUnitDecl(),
+  // We only want:
+  //   * symbols in namespaces or translation unit scopes (e.g. no class
+  // members)
+  //   * enum constants in unscoped enum decl (e.g. "red" in "enum {red};")
+  auto InTopLevelScope =
+  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl()));
+  if (match(decl(allOf(Opts.IndexMainFiles
+   ? decl()
+   : decl(unless(isExpansionInMainFile())),
+   anyOf(InTopLevelScope,
+ hasDeclContext(enumDecl(InTopLevelScope,
+ unless(isScoped())),
 *ND, *ASTCtx)
   .empty())
 return true;


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -161,6 +161,43 @@
QName("foo::baz")}));
 }
 
+TEST_F(SymbolCollectorTest, IncludeEnums) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+enum {
+  Red
+};
+enum Color {
+  Green
+};
+enum class Color2 {
+  Yellow // ignore
+};
+namespace ns {
+enum {
+  Black
+};
+}
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
+QName("Green"), QName("Color2"),
+QName("ns"),
+QName("ns::Black")));
+}
+
+TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
+  CollectorOpts.IndexMainFiles = false;
+  const std::string Header = R"(
+struct {
+  int a;
+} Foo;
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Foo")));
+}
+
 TEST_F(SymbolCollectorTest, IgnoreSymbolsInMainFile) {
   CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -71,6 +71,10 @@
   using namespace clang::ast_matchers;
   if (ND->isImplicit())
 return true;
+  // S

r322845 - Fix MSVC "uninitialized variable" warning.

2018-01-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jan 18 05:28:54 2018
New Revision: 322845

URL: http://llvm.org/viewvc/llvm-project?rev=322845&view=rev
Log:
Fix MSVC "uninitialized variable" warning.

Modified:
cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=322845&r1=322844&r2=322845&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan 18 05:28:54 2018
@@ -739,7 +739,10 @@ static CXString CursorToText(CXCursor Cu
   }
   }
   assert(0 && "unknown display type"); /* no llvm_unreachable in C. */
-  return /*garbage*/ text;
+  // Set to NULL to prevent uninitialized variable warnings.
+  text.data = NULL;
+  text.private_flags = 0;
+  return text;
 }
 
 static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) {


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


[PATCH] D42181: [clangd] Merge index-provided completions with those from Sema.

2018-01-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.
Herald added a reviewer: jkorous-apple.

Overall looks good! Some ideas about code structure inlined.




Comment at: clangd/CodeComplete.cpp:327
+// The CompletionRecorder captures Sema code-complete output, including 
context.
+// It filters out ignored results (and therefore does fuzzy-matching of names).
+// It doesn't do scoring or conversion to CompletionItem yet, as we want to

Does the recorder still do fuzzy-matching?



Comment at: clangd/CodeComplete.cpp:339
+  std::vector Results;
+  CodeCompletionContext CCContext;
+  Sema *Sema = nullptr; // The Sema that created the results.

It seems that `CCContext` can change  during `ProcessCodeCompleteResults`. It's 
unclear what the implication is for `codeCompletionString` at the end. 



Comment at: clangd/CodeComplete.cpp:434
+  // Returns true if we had more than N candidates, and dropped some.
+  bool more() const { return More; }
 

Maybe `dropped()`? 



Comment at: clangd/CodeComplete.cpp:679
+//   - TopN determines the results with the best score.
 CompletionList codeComplete(const Context &Ctx, PathRef FileName,
 const tooling::CompileCommand &Command,

The overall behavior looks good. And the comments really help understand the 
code! As chatted offline, we might want to break down this function, and a 
class that book-keeps all the states might be helpful. 



Comment at: clangd/CodeComplete.cpp:734
+// Now we have the needed context to query the index.
+// FIXME: we shouldn't query the index if the scope is e.g. class members.
+// FIXME: in addition to querying for extra/overlapping symbols, we should

I think we already only query namespace scopes now?



Comment at: clangd/CodeComplete.cpp:747
+  // FIXME(ioeric): add scopes based on using directives and enclosing ns.
+  if (auto SS = Recorder->CCContext.getCXXScopeSpecifier())
+Req.Scopes = {getSpecifiedScope(*Recorder->Sema, **SS).forIndex()};

As discussed offline, we want to defer unqualified completion support (IIRC?) 
until we have enough information about visible scopes (i.e. after D42073).



Comment at: clangd/CodeComplete.cpp:782
+  // For Sema results, we build the CCS here, where we have the arenas.
+  auto *CCS =
+  Candidate.first.SemaResult

It would be a bit more natural if the decision of building CCS is hidden in the 
candidate. Maybe pass in a callback for creating CCS from a sema result and let 
candidate decide whether to create CCS or not? This would also get rid of the 
constraint for `build`.



Comment at: clangd/CodeComplete.cpp:789
+  auto &R = Output.items.back();
+  R.scoreInfo = Candidate.second;
+  R.sortText = sortText(R.scoreInfo->finalScore, R.label);

Would it make sense to move the score construction into `build`, by passing in 
necessary information in `Candidate.second`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42181



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


[PATCH] D42168: [OpenMP] Correct generation of offloading entries

2018-01-18 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 130399.
Hahnfeld retitled this revision from "[OpenMP] Generate unique name for 
offloading entries" to "[OpenMP] Correct generation of offloading entries".
Hahnfeld edited the summary of this revision.
Hahnfeld added a comment.

Use `llvm::Twine`, add `PackedAttr`, and adjust regression tests to check the 
name of the generated constants.


https://reviews.llvm.org/D42168

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_codegen_registration.cpp

Index: test/OpenMP/target_codegen_registration.cpp
===
--- test/OpenMP/target_codegen_registration.cpp
+++ test/OpenMP/target_codegen_registration.cpp
@@ -123,54 +123,54 @@
 // CHECK-NTARGET-NOT: private unnamed_addr constant [1 x i
 
 // CHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
-// CHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME1]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
-// CHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME2]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
-// CHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME3]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
-// CHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME4]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
-// CHECK-DAG: [[ENTRY5:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME5]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
-// CHECK-DAG: [[ENTRY6:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME6]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
-// CHECK-DAG: [[ENTRY7:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME7]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR8:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME8:.+]]\00"
-// CHECK-DAG: [[ENTRY8:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} 

[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-01-18 Thread Balogh , ƁdƔm via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 130403.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D41938

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c

Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- /dev/null
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -0,0 +1,927 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-relational-comparison-simplification=true -verify %s
+
+void clang_analyzer_dump(int x);
+void clang_analyzer_eval(int x);
+
+void exit(int);
+
+#define UINT_MAX (~0U)
+#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
+
+int g();
+int f() {
+  int x = g();
+  // Assert that no overflows occur in this test file.
+  // Assuming that concrete integers are also within that range.
+  if (x > ((int)INT_MAX / 4))
+exit(1);
+  if (x < -(((int)INT_MAX) / 4))
+exit(1);
+  return x;
+}
+
+void compare_different_symbol_equal() {
+  int x = f(), y = f();
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 0}}
+}
+
+void compare_different_symbol_plus_left_int_equal() {
+  int x = f()+1, y = f();
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}}
+}
+
+void compare_different_symbol_minus_left_int_equal() {
+  int x = f()-1, y = f();
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}}
+}
+
+void compare_different_symbol_plus_right_int_equal() {
+  int x = f(), y = f()+2;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 2}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 2}}
+}
+
+void compare_different_symbol_minus_right_int_equal() {
+  int x = f(), y = f()-2;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 2}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 2}}
+}
+
+void compare_different_symbol_plus_left_plus_right_int_equal() {
+  int x = f()+2, y = f()+1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}}
+}
+
+void compare_different_symbol_plus_left_minus_right_int_equal() {
+  int x = f()+2, y = f()-1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 3}}
+}
+
+void compare_different_symbol_minus_left_plus_right_int_equal() {
+  int x = f()-2, y = f()+1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 3}}
+}
+
+void compare_different_symbol_minus_left_minus_right_int_equal() {
+  int x = f()-2, y = f()-1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}}
+}
+
+void compare_same_symbol_equal() {
+  int x = f(), y = x;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{1 S32b}}
+}
+
+void compare_same_symbol_plus_left_int_equal() {
+  int x = f(), y = x;
+  ++x;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{0 S32b}}
+}
+
+void compare_same_symbol_minus_left_int_equal() {
+  int x = f(), y = x;
+  --x;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{0 S32b}}
+}
+
+void compare_same_symbol_plus_right_int_equal() {
+  int 

[PATCH] D42029: [Solaris] Make RHEL devtoolsets handling Linux-specific

2018-01-18 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Thanks for the quick review.  Could you commit the base patch (which had been 
approved some time ago) and this one?


Repository:
  rC Clang

https://reviews.llvm.org/D42029



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


[PATCH] D42241: [CodeComplete] Fix completion in the middle of idents in macro calls

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: bkramer, arphaman.

This patch removes IdentifierInfo from completion token after remembering
the identifier in the preprocessor.

Prior to this patch, completion token had the IdentifierInfo set to null when
completing at the start of identifier and to the II for completion prefix
when in the middle of identifier.

This patch unifies how code completion token is handled when it is insterted
before the identifier and in the middle of the identifier.

The actual IdentifierInfo can still be obtained from the Preprocessor.


Repository:
  rC Clang

https://reviews.llvm.org/D42241

Files:
  lib/Lex/Preprocessor.cpp
  test/CodeCompletion/inside-macros.cpp


Index: test/CodeCompletion/inside-macros.cpp
===
--- /dev/null
+++ test/CodeCompletion/inside-macros.cpp
@@ -0,0 +1,13 @@
+#define ID(X) X
+
+void test(bool input_var) {
+  ID(input_var) = true;
+  // Check that input_var shows up when completing at the start, in the middle
+  // and at the end of the identifier.
+  //
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | 
FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | 
FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | 
FileCheck %s
+
+  // CHECK: input_var
+}
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -773,8 +773,13 @@
 }
   } while (!ReturnedToken);
 
-  if (Result.is(tok::code_completion))
+  if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) {
+// Remember the identifier before code completion token.
 setCodeCompletionIdentifierInfo(Result.getIdentifierInfo());
+// Set IdenfitierInfo to null to avoid confusing code that handles both
+// identifiers and completion tokens.
+Result.setIdentifierInfo(nullptr);
+  }
 
   LastTokenWasAt = Result.is(tok::at);
 }


Index: test/CodeCompletion/inside-macros.cpp
===
--- /dev/null
+++ test/CodeCompletion/inside-macros.cpp
@@ -0,0 +1,13 @@
+#define ID(X) X
+
+void test(bool input_var) {
+  ID(input_var) = true;
+  // Check that input_var shows up when completing at the start, in the middle
+  // and at the end of the identifier.
+  //
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | FileCheck %s
+
+  // CHECK: input_var
+}
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -773,8 +773,13 @@
 }
   } while (!ReturnedToken);
 
-  if (Result.is(tok::code_completion))
+  if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) {
+// Remember the identifier before code completion token.
 setCodeCompletionIdentifierInfo(Result.getIdentifierInfo());
+// Set IdenfitierInfo to null to avoid confusing code that handles both
+// identifiers and completion tokens.
+Result.setIdentifierInfo(nullptr);
+  }
 
   LastTokenWasAt = Result.is(tok::at);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42168: [OpenMP] Correct generation of offloading entries

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

LG


https://reviews.llvm.org/D42168



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


[PATCH] D42242: Make libc++abi work with gcc's ARM unwind library

2018-01-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.
Herald added subscribers: kristof.beyls, aemerson.

See https://bugs.llvm.org/show_bug.cgi?id=35945, which reports that libc++ 
doesn't build for the Raspberry PI.

The problem is that the exception class is defined as a `char[8]` in that 
library, rather than `uint64_t`, as in other libraries.
Same size, same values, different type.

Solution: Pull the code to check the exception class into a routine, and memcpy 
the field into a `uint64_t` and call the routine everywhere we were previously 
checking directly.


https://reviews.llvm.org/D42242

Files:
  src/cxa_default_handlers.cpp
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_handlers.cpp
  src/cxa_personality.cpp

Index: src/cxa_personality.cpp
===
--- src/cxa_personality.cpp
+++ src/cxa_personality.cpp
@@ -1073,8 +1073,7 @@
 if (unwind_exception == 0 || context == 0)
 return _URC_FATAL_PHASE1_ERROR;
 
-bool native_exception = (unwind_exception->exception_class & get_vendor_and_language) ==
-(kOurExceptionClass & get_vendor_and_language);
+bool native_exception = __isOurExceptionClass(unwind_exception);
 
 #if !defined(LIBCXXABI_USE_LLVM_UNWINDER)
 // Copy the address of _Unwind_Control_Block to r12 so that
@@ -1178,9 +1177,7 @@
 if (unwind_exception == 0)
 call_terminate(false, unwind_exception);
 __cxa_begin_catch(unwind_exception);
-bool native_old_exception =
-(unwind_exception->exception_class & get_vendor_and_language) ==
-(kOurExceptionClass& get_vendor_and_language);
+bool native_old_exception = __isOurExceptionClass(unwind_exception);
 std::unexpected_handler u_handler;
 std::terminate_handler t_handler;
 __cxa_exception* old_exception_header = 0;
@@ -1242,9 +1239,7 @@
 if (new_exception_header == 0)
 // This shouldn't be able to happen!
 std::__terminate(t_handler);
-bool native_new_exception =
-(new_exception_header->unwindHeader.exception_class & get_vendor_and_language) ==
-(kOurExceptionClass & get_vendor_and_language);
+bool native_new_exception = __isOurExceptionClass(&new_exception_header->unwindHeader);
 void* adjustedPtr;
 if (native_new_exception && (new_exception_header != old_exception_header))
 {
Index: src/cxa_handlers.cpp
===
--- src/cxa_handlers.cpp
+++ src/cxa_handlers.cpp
@@ -89,10 +89,7 @@
 {
 _Unwind_Exception* unwind_exception =
 reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
-bool native_exception =
-(unwind_exception->exception_class & get_vendor_and_language) ==
-   (kOurExceptionClass & get_vendor_and_language);
-if (native_exception)
+if (__isOurExceptionClass(unwind_exception))
 __terminate(exception_header->terminateHandler);
 }
 }
Index: src/cxa_exception.hpp
===
--- src/cxa_exception.hpp
+++ src/cxa_exception.hpp
@@ -24,6 +24,8 @@
 static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1
 static const uint64_t get_vendor_and_language = 0xFF00; // mask for CLNGC++
 
+bool __isOurExceptionClass(const _Unwind_Exception*);
+
 struct _LIBCXXABI_HIDDEN __cxa_exception {
 #if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI)
 // This is a new field to support C++ 0x exception_ptr.
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -87,9 +87,15 @@
 }
 
 //  Is it one of ours?
-static bool isOurExceptionClass(const _Unwind_Exception* unwind_exception) {
-return (unwind_exception->exception_class & get_vendor_and_language) == 
-   (kOurExceptionClass& get_vendor_and_language);
+bool __isOurExceptionClass(const _Unwind_Exception* unwind_exception) {
+//	On x86 and some ARM unwinders, unwind_exception->exception_class is
+//		a uint64_t. On other ARM unwinders, it is a char[8]
+//	See: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
+//	So we just copy it into a uint64_t to be sure.
+	uint64_t exClass;
+	::memcpy(&exClass, &unwind_exception->exception_class, sizeof(exClass));
+return (exClass& get_vendor_and_language) == 
+   (kOurExceptionClass & get_vendor_and_language);
 }
 
 static bool isDependentException(_Unwind_Exception* unwind_exception) {
@@ -299,7 +305,7 @@
 __cxa_exception* exception_header =
 cxa_exception_from_exception_unwind_exception(unwind_exception);
 
-  

r322853 - [Frontend] Allow to use PrecompiledPreamble without calling CanReuse

2018-01-18 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jan 18 07:16:53 2018
New Revision: 322853

URL: http://llvm.org/viewvc/llvm-project?rev=322853&view=rev
Log:
[Frontend] Allow to use PrecompiledPreamble without calling CanReuse

Summary:
The new method 'OverridePreamble' allows to override the preamble of
any source file without checking if preamble bounds or dependencies
were changed.

This is used for completion in clangd.

Reviewers: bkramer, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp

Modified: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h?rev=322853&r1=322852&r2=322853&view=diff
==
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h (original)
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h Thu Jan 18 07:16:53 
2018
@@ -104,14 +104,22 @@ public:
   /// Changes options inside \p CI to use PCH from this preamble. Also remaps
   /// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble
   /// is accessible.
-  /// For in-memory preambles, PrecompiledPreamble instance continues to own
-  /// the MemoryBuffer with the Preamble after this method returns. The caller
-  /// is reponsible for making sure the PrecompiledPreamble instance outlives
-  /// the compiler run and the AST that will be using the PCH.
+  /// Requires that CanReuse() is true.
+  /// For in-memory preambles, PrecompiledPreamble instance continues to own 
the
+  /// MemoryBuffer with the Preamble after this method returns. The caller is
+  /// reponsible for making sure the PrecompiledPreamble instance outlives the
+  /// compiler run and the AST that will be using the PCH.
   void AddImplicitPreamble(CompilerInvocation &CI,
IntrusiveRefCntPtr &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;
 
+  /// Configure \p CI to use this preamble.
+  /// Like AddImplicitPreamble, but doesn't assume CanReuse() is true.
+  /// If this preamble does not match the file, it may parse differently.
+  void OverridePreamble(CompilerInvocation &CI,
+IntrusiveRefCntPtr &VFS,
+llvm::MemoryBuffer *MainFileBuffer) const;
+
 private:
   PrecompiledPreamble(PCHStorage Storage, std::vector PreambleBytes,
   bool PreambleEndsAtStartOfLine,
@@ -222,6 +230,12 @@ private:
 }
   };
 
+  /// Helper function to set up PCH for the preamble into \p CI and \p VFS to
+  /// with the specified \p Bounds.
+  void configurePreamble(PreambleBounds Bounds, CompilerInvocation &CI,
+ IntrusiveRefCntPtr &VFS,
+ llvm::MemoryBuffer *MainFileBuffer) const;
+
   /// Sets up the PreprocessorOptions and changes VFS, so that PCH stored in \p
   /// Storage is accessible to clang. This method is an implementation detail 
of
   /// AddImplicitPreamble.

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=322853&r1=322852&r2=322853&view=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Thu Jan 18 07:16:53 2018
@@ -485,20 +485,15 @@ bool PrecompiledPreamble::CanReuse(const
 void PrecompiledPreamble::AddImplicitPreamble(
 CompilerInvocation &CI, IntrusiveRefCntPtr &VFS,
 llvm::MemoryBuffer *MainFileBuffer) const {
-  assert(VFS && "VFS must not be null");
-
-  auto &PreprocessorOpts = CI.getPreprocessorOpts();
-
-  // Remap main file to point to MainFileBuffer.
-  auto MainFilePath = CI.getFrontendOpts().Inputs[0].getFile();
-  PreprocessorOpts.addRemappedFile(MainFilePath, MainFileBuffer);
-
-  // Configure ImpicitPCHInclude.
-  PreprocessorOpts.PrecompiledPreambleBytes.first = PreambleBytes.size();
-  PreprocessorOpts.PrecompiledPreambleBytes.second = PreambleEndsAtStartOfLine;
-  PreprocessorOpts.DisablePCHValidation = true;
+  PreambleBounds Bounds(PreambleBytes.size(), PreambleEndsAtStartOfLine);
+  configurePreamble(Bounds, CI, VFS, MainFileBuffer);
+}
 
-  setupPreambleStorage(Storage, PreprocessorOpts, VFS);
+void PrecompiledPreamble::OverridePreamble(
+CompilerInvocation &CI, IntrusiveRefCntPtr &VFS,
+llvm::MemoryBuffer *MainFileBuffer) const {
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), MainFileBuffer, 0);
+  configurePreamble(Bounds, CI, VFS, MainFileBuffer);
 }
 
 PrecompiledPreamble::PrecompiledPreamble(
@@ -681,6 +676,27 @@ PrecompiledPreamble::PreambleFileHash::c
   return Result;
 }
 
+void PrecompiledPreamble::configurePreamble(
+PreambleBounds Boun

[clang-tools-extra] r322854 - [clangd] Always use preamble (even stale) for code completion

2018-01-18 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jan 18 07:17:00 2018
New Revision: 322854

URL: http://llvm.org/viewvc/llvm-project?rev=322854&view=rev
Log:
[clangd] Always use preamble (even stale) for code completion

Summary:
This improves performance of code completion, because we avoid stating
the files from the preamble and never attempt to parse the files
without using the preamble if it's provided.

However, the change comes at a cost of sometimes providing incorrect
results when doing code completion after making actually considerable
changes to the files used in the preamble or the preamble itself.
Eventually the preamble will get rebuilt and code completion will
be providing the correct results.

Reviewers: bkramer, sammccall, jkorous-apple

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

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

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=322854&r1=322853&r2=322854&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jan 18 07:17:00 2018
@@ -517,14 +517,18 @@ bool invokeCodeComplete(const Context &C
   std::unique_ptr ContentsBuffer =
   llvm::MemoryBuffer::getMemBufferCopy(Contents, FileName);
 
-  // Attempt to reuse the PCH from precompiled preamble, if it was built.
+  // We reuse the preamble whether it's valid or not. This is a
+  // correctness/performance tradeoff: building without a preamble is slow, and
+  // completion is latency-sensitive.
   if (Preamble) {
 auto Bounds =
 ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
-if (!Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds, VFS.get()))
-  Preamble = nullptr;
+// FIXME(ibiryukov): Remove this call to CanReuse() after we'll fix
+// clients relying on getting stats for preamble files during code
+// completion.
+// Note that results of CanReuse() are ignored, see the comment above.
+Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds, VFS.get());
   }
-
   auto Clang = prepareCompilerInstance(
   std::move(CI), Preamble, std::move(ContentsBuffer), std::move(PCHs),
   std::move(VFS), DummyDiagsConsumer);

Modified: clang-tools-extra/trunk/clangd/Compiler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Compiler.cpp?rev=322854&r1=322853&r2=322854&view=diff
==
--- clang-tools-extra/trunk/clangd/Compiler.cpp (original)
+++ clang-tools-extra/trunk/clangd/Compiler.cpp Thu Jan 18 07:17:00 2018
@@ -14,13 +14,6 @@
 namespace clang {
 namespace clangd {
 
-/// Creates a CompilerInstance from \p CI, with main buffer overriden to \p
-/// Buffer and arguments to read the PCH from \p Preamble, if \p Preamble is 
not
-/// null. Note that vfs::FileSystem inside returned instance may differ from \p
-/// VFS if additional file remapping were set in command-line arguments.
-/// On some errors, returns null. When non-null value is returned, it's 
expected
-/// to be consumed by the FrontendAction as it will have a pointer to the \p
-/// Buffer that will only be deleted if BeginSourceFile is called.
 std::unique_ptr
 prepareCompilerInstance(std::unique_ptr CI,
 const PrecompiledPreamble *Preamble,
@@ -36,7 +29,7 @@ prepareCompilerInstance(std::unique_ptr<
   // NOTE: we use Buffer.get() when adding remapped files, so we have to make
   // sure it will be released if no error is emitted.
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, VFS, Buffer.get());
+Preamble->OverridePreamble(*CI, VFS, Buffer.get());
   } else {
 CI->getPreprocessorOpts().addRemappedFile(
 CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get());

Modified: clang-tools-extra/trunk/clangd/Compiler.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Compiler.h?rev=322854&r1=322853&r2=322854&view=diff
==
--- clang-tools-extra/trunk/clangd/Compiler.h (original)
+++ clang-tools-extra/trunk/clangd/Compiler.h Thu Jan 18 07:17:00 2018
@@ -28,13 +28,16 @@ public:
 const clang::Diagnostic &Info) override {}
 };
 
-/// Creates a CompilerInstance with the main file contens overridden.
-/// The preamble will be reused unless it is null.
-/// Note that the vfs::FileSystem inside returned instance may differ if
-/// additional file remappings occur in command-line arguments.
-/// On some errors, returns null. When non-null value is returned, it's 
expected
-/// to be consumed by the FrontendAction as

[PATCH] D41991: [clangd] Always use preamble (even stale) for code completion

2018-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322854: [clangd] Always use preamble (even stale) for code 
completion (authored by ibiryukov, committed by ).
Herald added subscribers: llvm-commits, ioeric.

Repository:
  rL LLVM

https://reviews.llvm.org/D41991

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


Index: clang-tools-extra/trunk/clangd/Compiler.cpp
===
--- clang-tools-extra/trunk/clangd/Compiler.cpp
+++ clang-tools-extra/trunk/clangd/Compiler.cpp
@@ -14,13 +14,6 @@
 namespace clang {
 namespace clangd {
 
-/// Creates a CompilerInstance from \p CI, with main buffer overriden to \p
-/// Buffer and arguments to read the PCH from \p Preamble, if \p Preamble is 
not
-/// null. Note that vfs::FileSystem inside returned instance may differ from \p
-/// VFS if additional file remapping were set in command-line arguments.
-/// On some errors, returns null. When non-null value is returned, it's 
expected
-/// to be consumed by the FrontendAction as it will have a pointer to the \p
-/// Buffer that will only be deleted if BeginSourceFile is called.
 std::unique_ptr
 prepareCompilerInstance(std::unique_ptr CI,
 const PrecompiledPreamble *Preamble,
@@ -36,7 +29,7 @@
   // NOTE: we use Buffer.get() when adding remapped files, so we have to make
   // sure it will be released if no error is emitted.
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, VFS, Buffer.get());
+Preamble->OverridePreamble(*CI, VFS, Buffer.get());
   } else {
 CI->getPreprocessorOpts().addRemappedFile(
 CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get());
Index: clang-tools-extra/trunk/clangd/Compiler.h
===
--- clang-tools-extra/trunk/clangd/Compiler.h
+++ clang-tools-extra/trunk/clangd/Compiler.h
@@ -28,13 +28,16 @@
 const clang::Diagnostic &Info) override {}
 };
 
-/// Creates a CompilerInstance with the main file contens overridden.
-/// The preamble will be reused unless it is null.
-/// Note that the vfs::FileSystem inside returned instance may differ if
-/// additional file remappings occur in command-line arguments.
-/// On some errors, returns null. When non-null value is returned, it's 
expected
-/// to be consumed by the FrontendAction as it will have a pointer to the
-/// MainFile buffer that will only be deleted if BeginSourceFile is called.
+/// Creates a compiler instance, configured so that:
+///   - Contents of the parsed file are remapped to \p MainFile.
+///   - Preamble is overriden to use PCH passed to this function. It means the
+/// changes to the preamble headers or files included in the preamble are
+/// not visible to this compiler instance.
+///   - vfs::FileSystem is used for all underlying file accesses. The actual
+/// vfs used by the compiler may be an overlay over the passed vfs.
+/// Returns null on errors. When non-null value is returned, it is expected to
+/// be consumed by FrontendAction::BeginSourceFile to properly destroy \p
+/// MainFile.
 std::unique_ptr prepareCompilerInstance(
 std::unique_ptr, const PrecompiledPreamble *,
 std::unique_ptr MainFile,
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -517,14 +517,18 @@
   std::unique_ptr ContentsBuffer =
   llvm::MemoryBuffer::getMemBufferCopy(Contents, FileName);
 
-  // Attempt to reuse the PCH from precompiled preamble, if it was built.
+  // We reuse the preamble whether it's valid or not. This is a
+  // correctness/performance tradeoff: building without a preamble is slow, and
+  // completion is latency-sensitive.
   if (Preamble) {
 auto Bounds =
 ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
-if (!Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds, VFS.get()))
-  Preamble = nullptr;
+// FIXME(ibiryukov): Remove this call to CanReuse() after we'll fix
+// clients relying on getting stats for preamble files during code
+// completion.
+// Note that results of CanReuse() are ignored, see the comment above.
+Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds, VFS.get());
   }
-
   auto Clang = prepareCompilerInstance(
   std::move(CI), Preamble, std::move(ContentsBuffer), std::move(PCHs),
   std::move(VFS), DummyDiagsConsumer);


Index: clang-tools-extra/trunk/clangd/Compiler.cpp
===
--- clang-tools-extra/trunk/clangd/Compiler.cpp
+++ clang-tools-extra/trunk/clangd/Compiler.cpp
@@ -14,13 +14,6 @@
 namespace clang {
 namespace clangd {
 
-/// Creates a CompilerI

[PATCH] D41990: [Frontend] Allow to use PrecompiledPreamble without calling CanReuse

2018-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322853: [Frontend] Allow to use PrecompiledPreamble without 
calling CanReuse (authored by ibiryukov, committed by ).
Herald added a subscriber: ioeric.

Changed prior to commit:
  https://reviews.llvm.org/D41990?vs=129817&id=130408#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41990

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/PrecompiledPreamble.cpp

Index: include/clang/Frontend/PrecompiledPreamble.h
===
--- include/clang/Frontend/PrecompiledPreamble.h
+++ include/clang/Frontend/PrecompiledPreamble.h
@@ -104,14 +104,22 @@
   /// Changes options inside \p CI to use PCH from this preamble. Also remaps
   /// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble
   /// is accessible.
-  /// For in-memory preambles, PrecompiledPreamble instance continues to own
-  /// the MemoryBuffer with the Preamble after this method returns. The caller
-  /// is reponsible for making sure the PrecompiledPreamble instance outlives
-  /// the compiler run and the AST that will be using the PCH.
+  /// Requires that CanReuse() is true.
+  /// For in-memory preambles, PrecompiledPreamble instance continues to own the
+  /// MemoryBuffer with the Preamble after this method returns. The caller is
+  /// reponsible for making sure the PrecompiledPreamble instance outlives the
+  /// compiler run and the AST that will be using the PCH.
   void AddImplicitPreamble(CompilerInvocation &CI,
IntrusiveRefCntPtr &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;
 
+  /// Configure \p CI to use this preamble.
+  /// Like AddImplicitPreamble, but doesn't assume CanReuse() is true.
+  /// If this preamble does not match the file, it may parse differently.
+  void OverridePreamble(CompilerInvocation &CI,
+IntrusiveRefCntPtr &VFS,
+llvm::MemoryBuffer *MainFileBuffer) const;
+
 private:
   PrecompiledPreamble(PCHStorage Storage, std::vector PreambleBytes,
   bool PreambleEndsAtStartOfLine,
@@ -222,6 +230,12 @@
 }
   };
 
+  /// Helper function to set up PCH for the preamble into \p CI and \p VFS to
+  /// with the specified \p Bounds.
+  void configurePreamble(PreambleBounds Bounds, CompilerInvocation &CI,
+ IntrusiveRefCntPtr &VFS,
+ llvm::MemoryBuffer *MainFileBuffer) const;
+
   /// Sets up the PreprocessorOptions and changes VFS, so that PCH stored in \p
   /// Storage is accessible to clang. This method is an implementation detail of
   /// AddImplicitPreamble.
Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -485,20 +485,15 @@
 void PrecompiledPreamble::AddImplicitPreamble(
 CompilerInvocation &CI, IntrusiveRefCntPtr &VFS,
 llvm::MemoryBuffer *MainFileBuffer) const {
-  assert(VFS && "VFS must not be null");
-
-  auto &PreprocessorOpts = CI.getPreprocessorOpts();
-
-  // Remap main file to point to MainFileBuffer.
-  auto MainFilePath = CI.getFrontendOpts().Inputs[0].getFile();
-  PreprocessorOpts.addRemappedFile(MainFilePath, MainFileBuffer);
-
-  // Configure ImpicitPCHInclude.
-  PreprocessorOpts.PrecompiledPreambleBytes.first = PreambleBytes.size();
-  PreprocessorOpts.PrecompiledPreambleBytes.second = PreambleEndsAtStartOfLine;
-  PreprocessorOpts.DisablePCHValidation = true;
+  PreambleBounds Bounds(PreambleBytes.size(), PreambleEndsAtStartOfLine);
+  configurePreamble(Bounds, CI, VFS, MainFileBuffer);
+}
 
-  setupPreambleStorage(Storage, PreprocessorOpts, VFS);
+void PrecompiledPreamble::OverridePreamble(
+CompilerInvocation &CI, IntrusiveRefCntPtr &VFS,
+llvm::MemoryBuffer *MainFileBuffer) const {
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), MainFileBuffer, 0);
+  configurePreamble(Bounds, CI, VFS, MainFileBuffer);
 }
 
 PrecompiledPreamble::PrecompiledPreamble(
@@ -681,6 +676,27 @@
   return Result;
 }
 
+void PrecompiledPreamble::configurePreamble(
+PreambleBounds Bounds, CompilerInvocation &CI,
+IntrusiveRefCntPtr &VFS,
+llvm::MemoryBuffer *MainFileBuffer) const {
+  assert(VFS);
+
+  auto &PreprocessorOpts = CI.getPreprocessorOpts();
+
+  // Remap main file to point to MainFileBuffer.
+  auto MainFilePath = CI.getFrontendOpts().Inputs[0].getFile();
+  PreprocessorOpts.addRemappedFile(MainFilePath, MainFileBuffer);
+
+  // Configure ImpicitPCHInclude.
+  PreprocessorOpts.PrecompiledPreambleBytes.first = Bounds.Size;
+  PreprocessorOpts.PrecompiledPreambleBytes.second =
+  Bounds.PreambleEndsAtStartOfLine;
+  PreprocessorOpts.DisablePCHValidation = true;
+
+  setupPreambleStorage(Storage, PreprocessorOpts, VFS);
+}
+
 void PrecompiledPreamble::setupPreambleS

[PATCH] D41947: Provide default virtual filesystem argument to ClangTool constructor

2018-01-18 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.

Looks good. Do you have commit access or do you need someone to land this patch 
for you?


Repository:
  rC Clang

https://reviews.llvm.org/D41947



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


[PATCH] D42036: [clang-format] Keep comments aligned to macros

2018-01-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1710
 
+enum CommentAlignment { CA_None, CA_Code, CA_Preprocessor };
+

Please comment these.



Comment at: lib/Format/TokenAnnotator.cpp:1756
+  if (Alignment == CA_Preprocessor)
+(*I)->LevelOffset = 1;
 } else {

This feels a bit awkward: we're adding code that implicitly assumes the exact 
style the preprocessor directives and comments around them are handled. Maybe 
if this could become part of the level itself, it would feel less awkward.



Comment at: lib/Format/TokenAnnotator.h:41
   AnnotatedLine(const UnwrappedLine &Line)
-  : First(Line.Tokens.front().Tok), Level(Line.Level),
+  : First(Line.Tokens.front().Tok), Level(Line.Level), LevelOffset(0),
 MatchingOpeningBlockLineIndex(Line.MatchingOpeningBlockLineIndex),

Is there a way to not introduce `LevelOffset`, but have it part of `Level`?



Comment at: unittests/Format/FormatTest.cpp:2619
+   "#endif\n"
+   "#endif";
+EXPECT_EQ(Expected, format(ToFormat, Style));

I would like to see test including multiline `//`-comment sections before, 
inside and after preprocessor directives as well as `/**/`-style comments.


Repository:
  rC Clang

https://reviews.llvm.org/D42036



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


[clang-tools-extra] r322856 - [clangd] Remove unused IncludeGlobals completion option, always pass true to sema

2018-01-18 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jan 18 07:31:30 2018
New Revision: 322856

URL: http://llvm.org/viewvc/llvm-project?rev=322856&view=rev
Log:
[clangd] Remove unused IncludeGlobals completion option, always pass true to 
sema

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

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=322856&r1=322855&r2=322856&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jan 18 07:31:30 2018
@@ -643,7 +643,7 @@ clang::CodeCompleteOptions CodeCompleteO
   clang::CodeCompleteOptions Result;
   Result.IncludeCodePatterns = EnableSnippets && IncludeCodePatterns;
   Result.IncludeMacros = IncludeMacros;
-  Result.IncludeGlobals = IncludeGlobals;
+  Result.IncludeGlobals = true;
   Result.IncludeBriefComments = IncludeBriefComments;
 
   // When an is used, Sema is responsible for completing the main file,

Modified: clang-tools-extra/trunk/clangd/CodeComplete.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=322856&r1=322855&r2=322856&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.h (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.h Thu Jan 18 07:31:30 2018
@@ -45,9 +45,6 @@ struct CodeCompleteOptions {
   /// Add macros to code completion results.
   bool IncludeMacros = true;
 
-  /// Add globals to code completion results.
-  bool IncludeGlobals = true;
-
   /// Add brief comments to completion items, if available.
   /// FIXME(ibiryukov): it looks like turning this option on significantly 
slows
   /// down completion, investigate if it can be made faster.

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=322856&r1=322855&r2=322856&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan 18 
07:31:30 2018
@@ -277,10 +277,10 @@ void TestGlobalScopeCompletion(clangd::C
   EXPECT_THAT(Results.items,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
   // Global items.
-  EXPECT_IFF(Opts.IncludeGlobals, Results.items,
- AllOf(Has("global_var"),
-   Has(Opts.EnableSnippets ? "global_func()" : "global_func"),
-   Has("GlobalClass")));
+  EXPECT_THAT(Results.items,
+  AllOf(Has("global_var"),
+Has(Opts.EnableSnippets ? "global_func()" : "global_func"),
+Has("GlobalClass")));
   // A macro.
   EXPECT_IFF(Opts.IncludeMacros, Results.items, Has("MACRO"));
   // Local items. Must be present always.
@@ -300,7 +300,6 @@ TEST(CompletionTest, CompletionOptions)
   // We used to test every combination of options, but that got too slow (2^N).
   auto Flags = {
 &clangd::CodeCompleteOptions::IncludeMacros,
-&clangd::CodeCompleteOptions::IncludeGlobals,
 &clangd::CodeCompleteOptions::IncludeBriefComments,
 &clangd::CodeCompleteOptions::EnableSnippets,
 &clangd::CodeCompleteOptions::IncludeCodePatterns,


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


r322858 - [OpenMP] Correct generation of offloading entries

2018-01-18 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Jan 18 07:38:03 2018
New Revision: 322858

URL: http://llvm.org/viewvc/llvm-project?rev=322858&view=rev
Log:
[OpenMP] Correct generation of offloading entries

Firstly, each offloading entry must have a unique name or the
linker will complain if there are multiple files with target
regions. Secondly, the compiler must not introduce padding so
mark the struct with a PackedAttr.

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_codegen_registration.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=322858&r1=322857&r2=322858&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan 18 07:38:03 2018
@@ -3573,11 +3573,9 @@ void CGOpenMPRuntime::createOffloadEntry
   EntryInit.addInt(CGM.SizeTy, Size);
   EntryInit.addInt(CGM.Int32Ty, Flags);
   EntryInit.addInt(CGM.Int32Ty, 0);
-  llvm::GlobalVariable *Entry =
-EntryInit.finishAndCreateGlobal(".omp_offloading.entry",
-Align,
-/*constant*/ true,
-llvm::GlobalValue::ExternalLinkage);
+  llvm::GlobalVariable *Entry = EntryInit.finishAndCreateGlobal(
+  Twine(".omp_offloading.entry.") + Name, Align,
+  /*constant*/ true, llvm::GlobalValue::ExternalLinkage);
 
   // The entry has to be created in the section the linker expects it to be.
   Entry->setSection(".omp_offloading.entries");
@@ -3760,6 +3758,7 @@ QualType CGOpenMPRuntime::getTgtOffloadE
 addFieldToRecordDecl(
 C, RD, C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true));
 RD->completeDefinition();
+RD->addAttr(PackedAttr::CreateImplicit(C));
 TgtOffloadEntryQTy = C.getRecordType(RD);
   }
   return TgtOffloadEntryQTy;

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=322858&r1=322857&r2=322858&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Thu Jan 18 07:38:03 
2018
@@ -123,54 +123,54 @@
 // CHECK-NTARGET-NOT: private unnamed_addr constant [1 x i
 
 // CHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] 
c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
-// CHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* 
getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 
0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME1]] = constant [[ENTTY]] { i8* 
@{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* 
[[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section 
".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] 
c"[[NAME2:.+]]\00"
-// CHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* 
getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 
0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME2]] = constant [[ENTTY]] { i8* 
@{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* 
[[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section 
".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] 
c"[[NAME3:.+]]\00"
-// CHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* 
getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 
0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME3]] = constant [[ENTTY]] { i8* 
@{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* 
[[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section 
".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] 
c"[[NAME4:.+]]\00"
-// CHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* 
getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 
0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME4]] = constant [[ENTTY]] { i8* 
@{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* 
[[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section 
".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] 
c"[[NAME5:.+]]\00"
-// CHECK

[PATCH] D41947: Provide default virtual filesystem argument to ClangTool constructor

2018-01-18 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

In https://reviews.llvm.org/D41947#980298, @ilya-biryukov wrote:

> Looks good. Do you have commit access or do you need someone to land this 
> patch for you?


No, i don't have commit access.


Repository:
  rC Clang

https://reviews.llvm.org/D41947



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


[PATCH] D42168: [OpenMP] Correct generation of offloading entries

2018-01-18 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322858: [OpenMP] Correct generation of offloading entries 
(authored by Hahnfeld, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42168

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_codegen_registration.cpp

Index: test/OpenMP/target_codegen_registration.cpp
===
--- test/OpenMP/target_codegen_registration.cpp
+++ test/OpenMP/target_codegen_registration.cpp
@@ -123,54 +123,54 @@
 // CHECK-NTARGET-NOT: private unnamed_addr constant [1 x i
 
 // CHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
-// CHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME1]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
-// CHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME2]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
-// CHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME3]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
-// CHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME4]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
-// CHECK-DAG: [[ENTRY5:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME5]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
-// CHECK-DAG: [[ENTRY6:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME6]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
-// CHECK-DAG: [[ENTRY7:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME7]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR8:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME8:.+]]\00"
-// CHECK-DAG: [[ENTRY8:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR8]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: @.omp_offloading.entry.[[NAME8]] = constant [[

[PATCH] D41852: [clang-tidy] Don't generate fix for argument constructed from std::initializer_list.

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/clang-tidy/Inputs/modernize-smart-ptr/initializer_list.h:30
   vector(initializer_list<_E> init);
+  ~vector();
 };

hokein wrote:
> ilya-biryukov wrote:
> > Why do we need to add this destructor in this patch?
> Yeah, we do need it to reproduce the issue in real world. The AST is 
> different with/without the destructor.
Because without destructor `CXXBindTemporaryExpr` does not show up?


Repository:
  rL LLVM

https://reviews.llvm.org/D41852



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


[PATCH] D41535: Add -vfsoverlay option for Clang-Tidy

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:345
+  if (!Buffer) {
+llvm::errs() << diag::err_missing_vfs_overlay_file << OverlayFile;
+return;

This code will print only the enum's integral value, we want to print an actual 
error message.
I don't think there's an easy way to reuse clang's diagnostics here, we should 
spell out the error message explicitly.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:430
 
+  llvm::IntrusiveRefCntPtr BaseFS(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));

We should only create an overlay is `-vfsoverlay` was passed and use 
`getRealFileSystem` without wrappers in the common case.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:433
+  if (!VfsOverlay.empty()) {
+pushVfsOverlayFromFile(VfsOverlay, *BaseFS);
+  }

Could we stop clang-tidy with an error if we couldn't create an overlay? That 
seems like a better option than silently running without an overlay when it was 
actually specified.



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41535



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


[PATCH] D42029: [Solaris] Make RHEL devtoolsets handling Linux-specific

2018-01-18 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added a comment.

I'm trying!
I had no access to Solaris box, and I finally got one yesterday, though it is 
rather old one and slow.
I plan to resolve it all till the end of this week.


Repository:
  rC Clang

https://reviews.llvm.org/D42029



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


[PATCH] D42029: [Solaris] Make RHEL devtoolsets handling Linux-specific

2018-01-18 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Excellent, thanks a lot.


Repository:
  rC Clang

https://reviews.llvm.org/D42029



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


[PATCH] D42074: [clangd] Collect enum constants in SymbolCollector

2018-01-18 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. (See the comment about changing the comment, though)




Comment at: clangd/index/SymbolCollector.cpp:75
+  // Skip nameless declarations.
+  if (ND->getDeclName().isEmpty())
+return true;

hokein wrote:
> ilya-biryukov wrote:
> > What are those declarations exactly?
> This would  ignore anonymous declarations, e.g. anonymous class/enum. See the 
> unittest.
Thanks for clarifying. Maybe we could change the comment to say "anonymous" 
instead of "nameless"? This is what bit got me confused.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42074



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


[PATCH] D42073: [clangd] Query all visible scopes based on all visible using-namespace declarationsand containing namespace for global qualified code completion.

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/CodeComplete.cpp:270
+  /// namespace scopes which are visible to the qualified-id completion token.
+  std::vector Scopes;
+};

sammccall wrote:
> Just to check, if the user types:
> "vec" --> None
> "::vec" --> {""}
> "std::vec" --> {"std"}
> "using namespace std; vec" --> None
> "using namespace std; ::vec" --> {"", "std"}
> 
> is this right?
I think the idea was to have (I only highlight the differences):
"vec" --> {""}
"using namespace std; vec" --> {"", "std"}

@hokein , or am I getting it wrong?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42073



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


[PATCH] D41947: Provide default virtual filesystem argument to ClangTool constructor

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D41947#980305, @vladimir.plyashkun wrote:

> In https://reviews.llvm.org/D41947#980298, @ilya-biryukov wrote:
>
> > Looks good. Do you have commit access or do you need someone to land this 
> > patch for you?
>
>
> No, i don't have commit access.


I can land this for you together with the other patch that you're working on.
BTW, have you seen that you could set a child revision in phabricator? That 
would link these two changes together, making it clear that those changes are 
closely related.


Repository:
  rC Clang

https://reviews.llvm.org/D41947



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


[PATCH] D40925: Add option -fkeep-static-consts

2018-01-18 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

That makes sense. Is it not possible to implement the required functionality 
using a flag vs an attribute? In an earlier comment you mentioned adding the 
global to @llvm.used to prevent GlobalDCE from removing it. Can you not do that 
when using a flag?


https://reviews.llvm.org/D40925



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


[PATCH] D42181: [clangd] Merge index-provided completions with those from Sema.

2018-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 130417.
sammccall marked 7 inline comments as done.
sammccall added a comment.

Addressed review comments, except for "refactor into class" which is still todo.
Added explicit check of code completion context kind.
Added tests (mostly updating existing ones).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42181

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

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -17,7 +17,6 @@
 #include "SourceCode.h"
 #include "TestFS.h"
 #include "index/MemIndex.h"
-#include "index/Merge.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -82,7 +81,7 @@
   return arg.insertTextFormat == clangd::InsertTextFormat::Snippet &&
  arg.insertText == Text;
 }
-MATCHER(FilterContainsName, "") {
+MATCHER(NameContainsFilter, "") {
   if (arg.filterText.empty())
 return true;
   return llvm::StringRef(arg.insertText).contains(arg.filterText);
@@ -129,30 +128,53 @@
   .get()
   .second.Value;
   // Sanity-check that filterText is valid.
-  EXPECT_THAT(CompletionList.items, Each(FilterContainsName()));
+  EXPECT_THAT(CompletionList.items, Each(NameContainsFilter()));
   return CompletionList;
 }
 
+std::string replace(StringRef Haystack, StringRef Needle, StringRef Repl) {
+  std::string Result;
+  raw_string_ostream OS(Result);
+  std::pair Split;
+  for (Split = Haystack.split(Needle); !Split.second.empty();
+   Split = Split.first.split(Needle))
+OS << Split.first << Repl;
+  Result += Split.first;
+  OS.flush();
+  return Result;
+}
+
 // Helpers to produce fake index symbols for memIndex() or completions().
-Symbol sym(StringRef QName, index::SymbolKind Kind) {
+// USRFormat is a regex replacement string for the unqualified part of the USR.
+Symbol sym(StringRef QName, index::SymbolKind Kind, StringRef USRFormat) {
   Symbol Sym;
-  Sym.ID = SymbolID(QName);
+  std::string USR = "c:"; // We synthesize a few simple cases of USRs by hand!
   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);
+USR += "@N@" + replace(Sym.Scope, "::", "@N@"); // ns:: -> @N@ns
   }
+  USR += Regex("^.*$").sub(USRFormat, Sym.Name); // e.g. func -> @F@func#
+  Sym.ID = SymbolID(USR);
   Sym.CompletionPlainInsertText = Sym.Name;
+  Sym.CompletionSnippetInsertText = Sym.Name;
   Sym.CompletionLabel = Sym.Name;
   Sym.SymInfo.Kind = Kind;
   return Sym;
 }
-Symbol func(StringRef Name) { return sym(Name, index::SymbolKind::Function); }
-Symbol cls(StringRef Name) { return sym(Name, index::SymbolKind::Class); }
-Symbol var(StringRef Name) { return sym(Name, index::SymbolKind::Variable); }
+Symbol func(StringRef Name) { // Assumes the function has no args.
+  return sym(Name, index::SymbolKind::Function, "@F@\\0#"); // no args
+}
+Symbol cls(StringRef Name) {
+  return sym(Name, index::SymbolKind::Class, "@S@\\0@S@\\0");
+}
+Symbol var(StringRef Name) {
+  return sym(Name, index::SymbolKind::Variable, "@\\0");
+}
 
 TEST(CompletionTest, Limit) {
   clangd::CodeCompleteOptions Opts;
@@ -226,7 +248,7 @@
 ClassWithMembers().^
   }
   )cpp",
-  /*IndexSymbols=*/{}, Opts);
+  {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
   // Class members. The only items that must be present in after-dot
   // completion.
@@ -236,9 +258,11 @@
   EXPECT_IFF(Opts.IncludeIneligibleResults, Results.items,
  Has("private_field"));
   // Global items.
-  EXPECT_THAT(Results.items, Not(AnyOf(Has("global_var"), Has("global_func"),
-   Has("global_func()"), Has("GlobalClass"),
-   Has("MACRO"), Has("LocalClass";
+  EXPECT_THAT(
+  Results.items,
+  Not(AnyOf(Has("global_var"), Has("index_var"), Has("global_func"),
+Has("global_func()"), Has("index_func"), Has("GlobalClass"),
+Has("IndexClass"), Has("MACRO"), Has("LocalClass";
   // There should be no code patterns (aka snippets) in after-dot
   // completion. At least there aren't any we're aware of.
   EXPECT_THAT(Results.items, Not(Contains(Kind(CompletionItemKind::Snippet;
@@ -271,16 +295,17 @@
 ^
   }
   )cpp",
-  /*IndexSymbols=*/{}, Opts);
+  {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.items,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
   // Global items.
-  EXPECT_IFF(Opts.IncludeGlobals, Results.items,
- AllOf(Has("global_var"),
-   Has(Opts.EnableSnippets ? "global_func()" : "glo

[libcxx] r322863 - A simple program for testing OSS-Fuzz test cases locally.

2018-01-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jan 18 08:52:19 2018
New Revision: 322863

URL: http://llvm.org/viewvc/llvm-project?rev=322863&view=rev
Log:
A simple program for testing OSS-Fuzz test cases locally.

Added:
libcxx/trunk/fuzzing/fuzz_test.cpp

Added: libcxx/trunk/fuzzing/fuzz_test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/fuzzing/fuzz_test.cpp?rev=322863&view=auto
==
--- libcxx/trunk/fuzzing/fuzz_test.cpp (added)
+++ libcxx/trunk/fuzzing/fuzz_test.cpp Thu Jan 18 08:52:19 2018
@@ -0,0 +1,111 @@
+// -*- C++ -*-
+//===- fuzz_test.cpp 
--===//
+//
+// 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.
+//
+//===--===//
+
+//  A simple program for running regressions on the fuzzing routines.
+//  This code is not part of any shipping product.
+//
+//  To build:
+//  clang++ -std=c++11 fuzz_test.cpp fuzzing.cpp
+//
+//  To use:
+//  fuzz_test -r partial_sort [-v] files...
+//
+//  Each file should contain a test case.
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "fuzzing.h"
+
+typedef int (*FuzzProc) (const uint8_t *data, size_t size);
+
+const std::map procs = {
+{"sort",fuzzing::sort},
+{"stable_sort", fuzzing::stable_sort},
+{"partition",   fuzzing::partition},
+{"partition_copy",  fuzzing::partition_copy},
+{"stable_partition",fuzzing::stable_partition},
+{"unique",  fuzzing::unique},
+{"unique_copy", fuzzing::unique_copy},
+{"nth_element", fuzzing::nth_element},
+{"partial_sort",fuzzing::partial_sort},
+{"partial_sort_copy",   fuzzing::partial_sort_copy},
+{"make_heap",   fuzzing::make_heap},
+{"push_heap",   fuzzing::push_heap},
+{"pop_heap",fuzzing::pop_heap},
+{"regex_ECMAScript",fuzzing::regex_ECMAScript},
+{"regex_POSIX", fuzzing::regex_POSIX},
+{"regex_extended",  fuzzing::regex_extended},
+{"regex_awk",   fuzzing::regex_awk},
+{"regex_grep",  fuzzing::regex_grep},
+{"regex_egrep", fuzzing::regex_egrep},
+{"search",  fuzzing::search}
+};
+
+
+
+bool verbose = false;
+
+void test_one(const char *filename, FuzzProc fp)
+{
+std::vector v;
+std::ifstream f (filename, std::ios::binary);
+if (!f.is_open())
+std::cerr << "## Can't open '" << filename << "'" << std::endl;
+else {
+typedef std::istream_iterator Iter;
+std::copy(Iter(f), Iter(), std::back_inserter(v));
+if (verbose)
+std::cout << "File '" << filename << "' contains " << v.size() << 
" entries" << std::endl;
+const auto start_time = std::chrono::steady_clock::now();
+int ret = fp (v.data(), v.size());
+const auto finish_time = std::chrono::steady_clock::now();
+if (ret != 0)
+std::cerr << "## Failure code: " << ret << std::endl;
+if (verbose)
+std::cout << "Execution time: "
+<< 
std::chrono::duration_cast(finish_time - 
start_time).count()
+<< " milliseconds" << std::endl;
+}
+}
+
+void usage (const char *name)
+{
+std::cout << "Usage: " << name << " -r proc [-v] files..." << std::endl;
+std::cout << "Supported routines:" << std::endl;
+for (const auto &p : procs)
+std::cout << "" << p.first << std::endl;
+std::cout << std::endl;
+}
+
+// Poor man's command-line options
+const std::string dashR("-r");
+const std::string dashV("-v");
+
+int main(int argc, char *argv[])
+{
+if (argc < 4 || dashR != argv[1] || procs.find(argv[2]) == procs.end())
+usage(argv[0]);
+else {
+FuzzProc fp = procs.find(argv[2])->second;
+int firstFile = 3;
+if (dashV == argv[firstFile])
+{
+verbose = true;
+++firstFile;
+}
+for (int i = firstFile; i < argc; ++i)
+test_one(argv[i], fp);
+}
+}


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


[libcxx] r322864 - Use high_resolution_clock instead of steady_clock. Also now builds with gcc 7.2 (for comparison purposes)

2018-01-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jan 18 09:01:34 2018
New Revision: 322864

URL: http://llvm.org/viewvc/llvm-project?rev=322864&view=rev
Log:
Use high_resolution_clock instead of steady_clock. Also now builds with gcc 7.2 
(for comparison purposes)

Modified:
libcxx/trunk/fuzzing/fuzz_test.cpp

Modified: libcxx/trunk/fuzzing/fuzz_test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/fuzzing/fuzz_test.cpp?rev=322864&r1=322863&r2=322864&view=diff
==
--- libcxx/trunk/fuzzing/fuzz_test.cpp (original)
+++ libcxx/trunk/fuzzing/fuzz_test.cpp Thu Jan 18 09:01:34 2018
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -68,9 +69,9 @@ void test_one(const char *filename, Fuzz
 std::copy(Iter(f), Iter(), std::back_inserter(v));
 if (verbose)
 std::cout << "File '" << filename << "' contains " << v.size() << 
" entries" << std::endl;
-const auto start_time = std::chrono::steady_clock::now();
+const auto start_time = std::chrono::high_resolution_clock::now();
 int ret = fp (v.data(), v.size());
-const auto finish_time = std::chrono::steady_clock::now();
+const auto finish_time = std::chrono::high_resolution_clock::now();
 if (ret != 0)
 std::cerr << "## Failure code: " << ret << std::endl;
 if (verbose)


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


[PATCH] D42173: [clangd] Simplify code handling compile commands

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.cpp:35
 
+tooling::CompileCommand getCompileCommand(GlobalCompilationDatabase &CDB,
+  PathRef File, PathRef ResourceDir) {

sammccall wrote:
> This seems like something of an odd fit: the clangdserver both produces and 
> consumes the compile commands, but ClangdUnit is responsible for storing it?
> 
> Are we sure it wouldn't be clearer to keep the "get compile command" action 
> in clangd unit (and propagate the "should rescan" flag), and just encapsulate 
> the resource-dir/fallback logic a bit better?
I've put the command into `ClangdUnit` to not change the code consuming compile 
commands (this is where you currently get compile commands from).

The final goal is to remove compile command from `ClangdUnit` and store it 
beside the contents of the file (somewhere inside ClangdServer or its component 
that manages the resources), ClangdUnit will only manage the built 
ASTs/Preambles.
This is what `ParseInputs` is for, it captures all things necessary to build 
AST/Preamble. When we'll start dropping ASTs for non-accessed files, we could 
be storing ParseInputs instead to be able to recreate the ASTs when necessary.



Comment at: clangd/ClangdServer.cpp:336
+  assert(Resources->getLatestCommand() &&
+ "CppFile is in inconsistent state, missing CompileCommand");
+  tooling::CompileCommand CompileCommand = *Resources->getLatestCommand();

sammccall wrote:
> what's inconsistent about this state? (and above)
There's an invariant that if a file is tracked, its compile command in CppFile 
should be set.
E.g., `!!(Untis.getFile(File))  == 
!!(Untis.getFile(File))->getLatestCompileCommand`.

We should probably spell it out explicitly in the assertion message. E.g. 
`"getFile() must only return files with populated commands"`
WDYT?



Comment at: clangd/ClangdServer.h:335
+  Tagged> TaggedFS,
+  bool UpdateCompileCommand);
 

sammccall wrote:
> The name `UpdateCompileCommand` is confusing in the case that this file 
> hasn't been seen: it's not obvious whether you have to pass true, or whether 
> it doesn't matter.
> 
> Consider `AllowCachedFlags`, and inverting the sense?
> At least for me, it's more obvious that this flag is ignored if the cache is 
> empty.
> (or AllowCachedCompileCommand, which is a bit long for my taste, or 
> AllowCachedCommand, which is a bit vague)
I like `CachedFlags`, but it also seems a bit vague in the same sense that  
`CachedCommand` is vague.
I've opted for `AllowCachedCompileFlags`, it's long but shouldn't cause any 
confusion.



Comment at: clangd/ClangdUnit.h:67
+
+  /// Compilation arguments.
+  tooling::CompileCommand CompileCommand;

sammccall wrote:
> these comments just echo the type/name, remove?
Sorry, I thought I removed them prior to doing the commit.
Thanks for spotting that.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42173



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


[PATCH] D42173: [clangd] Simplify code handling compile commands

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 130428.
ilya-biryukov marked 7 inline comments as done.
ilya-biryukov added a comment.
Herald added a subscriber: ioeric.

Addressing review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42173

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h

Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -32,42 +32,19 @@
 
   std::shared_ptr
   getOrCreateFile(PathRef File, PathRef ResourceDir,
-  GlobalCompilationDatabase &CDB, bool StorePreamblesInMemory,
+  bool StorePreamblesInMemory,
   std::shared_ptr PCHs) {
 std::lock_guard Lock(Mutex);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
-  auto Command = getCompileCommand(CDB, File, ResourceDir);
-
   It = OpenedFiles
-   .try_emplace(File, CppFile::Create(File, std::move(Command),
-  StorePreamblesInMemory,
+   .try_emplace(File, CppFile::Create(File, StorePreamblesInMemory,
   std::move(PCHs), ASTCallback))
.first;
 }
 return It->second;
   }
 
-  struct RecreateResult {
-/// A CppFile, stored in this CppFileCollection for the corresponding
-/// filepath after calling recreateFileIfCompileCommandChanged.
-std::shared_ptr FileInCollection;
-/// If a new CppFile had to be created to account for changed
-/// CompileCommand, a previous CppFile instance will be returned in this
-/// field.
-std::shared_ptr RemovedFile;
-  };
-
-  /// Similar to getOrCreateFile, but will replace a current CppFile for \p File
-  /// with a new one if CompileCommand, provided by \p CDB has changed.
-  /// If a currently stored CppFile had to be replaced, the previous instance
-  /// will be returned in RecreateResult.RemovedFile.
-  RecreateResult recreateFileIfCompileCommandChanged(
-  PathRef File, PathRef ResourceDir, GlobalCompilationDatabase &CDB,
-  bool StorePreamblesInMemory,
-  std::shared_ptr PCHs);
-
   std::shared_ptr getFile(PathRef File) {
 std::lock_guard Lock(Mutex);
 
@@ -82,12 +59,6 @@
   std::shared_ptr removeIfPresent(PathRef File);
 
 private:
-  tooling::CompileCommand getCompileCommand(GlobalCompilationDatabase &CDB,
-PathRef File, PathRef ResourceDir);
-
-  bool compileCommandsAreEqual(tooling::CompileCommand const &LHS,
-   tooling::CompileCommand const &RHS);
-
   std::mutex Mutex;
   llvm::StringMap> OpenedFiles;
   ASTParsedCallback ASTCallback;
Index: clangd/ClangdUnitStore.cpp
===
--- clangd/ClangdUnitStore.cpp
+++ clangd/ClangdUnitStore.cpp
@@ -25,53 +25,3 @@
   OpenedFiles.erase(It);
   return Result;
 }
-
-CppFileCollection::RecreateResult
-CppFileCollection::recreateFileIfCompileCommandChanged(
-PathRef File, PathRef ResourceDir, GlobalCompilationDatabase &CDB,
-bool StorePreamblesInMemory, std::shared_ptr PCHs) {
-  auto NewCommand = getCompileCommand(CDB, File, ResourceDir);
-
-  std::lock_guard Lock(Mutex);
-
-  RecreateResult Result;
-
-  auto It = OpenedFiles.find(File);
-  if (It == OpenedFiles.end()) {
-It = OpenedFiles
- .try_emplace(File, CppFile::Create(File, std::move(NewCommand),
-StorePreamblesInMemory,
-std::move(PCHs), ASTCallback))
- .first;
-  } else if (!compileCommandsAreEqual(It->second->getCompileCommand(),
-  NewCommand)) {
-Result.RemovedFile = std::move(It->second);
-It->second =
-CppFile::Create(File, std::move(NewCommand), StorePreamblesInMemory,
-std::move(PCHs), ASTCallback);
-  }
-  Result.FileInCollection = It->second;
-  return Result;
-}
-
-tooling::CompileCommand
-CppFileCollection::getCompileCommand(GlobalCompilationDatabase &CDB,
- PathRef File, PathRef ResourceDir) {
-  llvm::Optional C = CDB.getCompileCommand(File);
-  if (!C) // FIXME: Suppress diagnostics? Let the user know?
-C = CDB.getFallbackCommand(File);
-
-  // Inject the resource dir.
-  // FIXME: Don't overwrite it if it's already there.
-  C->CommandLine.push_back("-resource-dir=" + ResourceDir.str());
-  return std::move(*C);
-}
-
-bool CppFileCollection::compileCommandsAreEqual(
-tooling::CompileCommand const &LHS, tooling::CompileCommand const &RHS) {
-  // tooling::CompileCommand.Output is ignored, it's not relevant for clangd.
-  return LHS.Directory == RHS.Directory &&
- LHS.CommandLine.size() == RHS.

[PATCH] D41594: Support `ivfsoverlay` option in Tooling

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

With https://reviews.llvm.org/D41947 in place, do we still need this change? Or 
can it be "abandoned" now?


Repository:
  rC Clang

https://reviews.llvm.org/D41594



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


[PATCH] D41947: Provide default virtual filesystem argument to ClangTool constructor

2018-01-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Tooling/Tooling.h:299
   /// clang modules.
+  /// \param BaseFS Base virtual filesystem used for OverlayFileSystem creation
   ClangTool(const CompilationDatabase &Compilations,

NIT: LLVM coding style requires full stop at the end of comments.
Could we also rephrase it to not mention the `OverlayFileSystem`, the important 
bit seems to be that we use it for all fs operations. Something like:
```
/// \param BaseFS VFS used for all underlying file accesses when running the 
tool.
```



Repository:
  rC Clang

https://reviews.llvm.org/D41947



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


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2018-01-18 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 130427.
juliehockett added a comment.

Rebasing from trunk


https://reviews.llvm.org/D40580

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-multiple-inheritance.cpp

Index: test/clang-tidy/fuchsia-multiple-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -0,0 +1,131 @@
+// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
+
+class Base_A {
+public:
+  virtual int foo() { return 0; }
+};
+
+class Base_B {
+public:
+  virtual int bar() { return 0; }
+};
+
+class Base_A_child : public Base_A {
+public:
+  virtual int baz() { return 0; }
+};
+
+class Interface_A {
+public:
+  virtual int foo() = 0;
+};
+
+class Interface_B {
+public:
+  virtual int bar() = 0;
+};
+
+class Interface_C {
+public:
+  virtual int blat() = 0;
+};
+
+class Interface_A_with_member {
+public:
+  virtual int foo() = 0;
+  int val = 0;
+};
+
+class Interface_with_A_Parent : public Base_A {
+public:
+  virtual int baz() = 0;
+};
+
+// Inherits from multiple concrete classes.
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
+class Bad_Child1 : public Base_A, Base_B {};
+
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+class Bad_Child2 : public Base_A, Interface_A_with_member {
+  virtual int foo() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+  virtual int baz() override { return 0; }
+};
+
+// Easy cases of single inheritance
+class Simple_Child1 : public Base_A {};
+class Simple_Child2 : public Interface_A {
+  virtual int foo() override { return 0; }
+};
+
+// Valid uses of multiple inheritance
+class Good_Child1 : public Interface_A, Interface_B {
+  virtual int foo() override { return 0; }
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child2 : public Base_A, Interface_B {
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
+  virtual int bar() override { return 0; }
+  virtual int blat() override { return 0; }
+};
+
+struct B1 { int x; };
+struct B2 { int x;};
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: struct D : B1, B2 {};
+struct D1 : B1, B2 {};
+
+struct Base1 { virtual void foo() = 0; };
+struct V1 : virtual Base1 {};
+struct V2 : virtual Base1 {};
+struct D2 : V1, V2 {};
+
+struct Base2 { virtual void foo(); };
+struct V3 : virtual Base2 {};
+struct V4 : virtual Base2 {};
+struct D3 : V3, V4 {};
+
+struct Base3 {};
+struct V5 : virtual Base3 { virtual void f(); };
+struct V6 : virtual Base3 { virtual void g(); };
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: struct D4 : V5, V6 {};
+struct D4 : V5, V6 {};
+
+struct Base4 {};
+struct V7 : virtual Base4 { virtual void f() = 0; };
+struct V8 : virtual Base4 { virtual void g() = 0; };
+struct D5 : V7, V8 {};
+
+struct Base5 { virtual void f() = 0; };
+struct V9 : virtual Base5 { virtual void f(); };
+struct V10 : virtual Base5 { virtual void g() = 0; };
+struct D6 : V9, V10 {};
+
+struct Base6 { virtual void f(); };
+struct Base7 { virtual void g(); };
+struct V15 : virtual Base6 { virtual void f() = 0; };
+struct V16 : virtual Base7 { virtual void g() = 0; };
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: struct D9 : V15, V16 {};
+struct D9 : V15, V16 {};
+
+struct Static_Base { static void foo(); };
+struct V11 : virtual Static_Base {};
+struct V12 : virtual Static_Base {};
+struct D7 : V11, V12 {};
+
+struct Static_Base_2 {};
+struct V13 : virtual Static_Base_2 { static void f(); };
+struct V14 : virtual Static_Base_2 { static void g(); };
+struct D8 : V13, V14 {};
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@
cppcoreguidelines-slicing
cppcoreguidelines-special-member-

[PATCH] D41727: [libcxx] Disable tautological-type-limit-compare warning

2018-01-18 Thread Brian Cain via Phabricator via cfe-commits
bcain updated this revision to Diff 130431.
bcain added a comment.
Herald added a subscriber: cfe-commits.

Changed per review


Repository:
  rCXX libc++

https://reviews.llvm.org/D41727

Files:
  libcxx/utils/libcxx/test/config.py


Index: libcxx/utils/libcxx/test/config.py
===
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -903,6 +903,7 @@
 if self.cxx.hasWarningFlag('-Wuser-defined-warnings'):
 self.cxx.warning_flags += ['-Wuser-defined-warnings']
 self.config.available_features.add('diagnose-if-support')
+
self.cxx.addWarningFlagIfSupported('-Wno-tautological-type-limit-compare')
 self.cxx.addWarningFlagIfSupported('-Wshadow')
 self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
 self.cxx.addWarningFlagIfSupported('-Wno-attributes')


Index: libcxx/utils/libcxx/test/config.py
===
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -903,6 +903,7 @@
 if self.cxx.hasWarningFlag('-Wuser-defined-warnings'):
 self.cxx.warning_flags += ['-Wuser-defined-warnings']
 self.config.available_features.add('diagnose-if-support')
+self.cxx.addWarningFlagIfSupported('-Wno-tautological-type-limit-compare')
 self.cxx.addWarningFlagIfSupported('-Wshadow')
 self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
 self.cxx.addWarningFlagIfSupported('-Wno-attributes')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42248: [LangOpts] Add a LangOpt to represent "#pragma region" support.

2018-01-18 Thread Matt Davis via Phabricator via cfe-commits
mattd created this revision.
mattd added reviewers: rnk, rsmith.

Both MS and PS4 targets are capable of recognizing the
existence of:  #pragma region, #pragma endregion.

This patch adds a LangOpt and sets the value based on target 
information or MS compatibility. In the case of PS4 or MS we
should avoid emitting "unknown pragma" warnings for regions.
This change prevents that situation.


https://reviews.llvm.org/D42248

Files:
  include/clang/Basic/LangOptions.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/Pragma.cpp
  test/Frontend/region-pragmas.c


Index: test/Frontend/region-pragmas.c
===
--- test/Frontend/region-pragmas.c
+++ test/Frontend/region-pragmas.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 -Wall -verify %s
+// RUN: %clang_cc1 -fms-compatibility -Wall -verify %s
+// RUN: %clang_cc1 -Wall -Wno-unknown-pragmas -verify %s
+// expected-no-diagnostics
+
+#pragma region foo
+#pragma endregion foo
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -1781,6 +1781,10 @@
   if (LangOpts.MicrosoftExt) {
 AddPragmaHandler(new PragmaWarningHandler());
 AddPragmaHandler(new PragmaIncludeAliasHandler());
+  }
+
+  // Region support.
+  if (LangOpts.MicrosoftPragmaRegion) {
 AddPragmaHandler(new PragmaRegionHandler("region"));
 AddPragmaHandler(new PragmaRegionHandler("endregion"));
   }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2160,6 +2160,7 @@
 
   Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
   Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
+  Opts.MicrosoftPragmaRegion = Opts.MicrosoftExt || T.isPS4();
   Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
   Opts.MSCompatibilityVersion = 0;
   if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -85,6 +85,7 @@
 LANGOPT(C17   , 1, 0, "C17")
 LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility 
mode")
 LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
+BENIGN_LANGOPT(MicrosoftPragmaRegion, 1, 0, "region pragma support")
 LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
 LANGOPT(Borland   , 1, 0, "Borland extensions")
 LANGOPT(CPlusPlus , 1, 0, "C++")


Index: test/Frontend/region-pragmas.c
===
--- test/Frontend/region-pragmas.c
+++ test/Frontend/region-pragmas.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 -Wall -verify %s
+// RUN: %clang_cc1 -fms-compatibility -Wall -verify %s
+// RUN: %clang_cc1 -Wall -Wno-unknown-pragmas -verify %s
+// expected-no-diagnostics
+
+#pragma region foo
+#pragma endregion foo
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -1781,6 +1781,10 @@
   if (LangOpts.MicrosoftExt) {
 AddPragmaHandler(new PragmaWarningHandler());
 AddPragmaHandler(new PragmaIncludeAliasHandler());
+  }
+
+  // Region support.
+  if (LangOpts.MicrosoftPragmaRegion) {
 AddPragmaHandler(new PragmaRegionHandler("region"));
 AddPragmaHandler(new PragmaRegionHandler("endregion"));
   }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2160,6 +2160,7 @@
 
   Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
   Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
+  Opts.MicrosoftPragmaRegion = Opts.MicrosoftExt || T.isPS4();
   Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
   Opts.MSCompatibilityVersion = 0;
   if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -85,6 +85,7 @@
 LANGOPT(C17   , 1, 0, "C17")
 LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility mode")
 LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
+BENIGN_LANGOPT(MicrosoftPragmaRegion, 1, 0, "region pragma support")
 LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
 LANGOPT(Borland   , 1, 0, "Borland extensions")
 LANGOPT(CPlusPlus , 1, 0, "C++")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.

[PATCH] D42249: [CodeGenCXX] annotate a GEP to a derived class with 'inbounds' (PR35909)

2018-01-18 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
spatel added reviewers: efriedma, hfinkel, rjmccall, rsmith.
Herald added a subscriber: mcrosier.

I'm not sure if the code comment is adequate or even correct, but hopefully the 
change itself is valid.

Eli cited this section of the standard in PR35909 ( 
https://bugs.llvm.org/show_bug.cgi?id=35909 ):
[expr.static.cast] p11: "If the prvalue of type ā€œpointer to cv1 Bā€ points to a 
B that is actually a subobject of an object of type D, the resulting pointer 
points to the enclosing object of type D. Otherwise, the behavior is undefined."

In the motivating case in the bug report, LLVM can't eliminate a nullptr check 
because a GEP is not marked with 'inbounds':

  class A {
  int a;
  };
  class B {
  int b;
  public:
  A *getAsA();
  };
  class X : public A, public B {
  int x;
  };
  
  A *B::getAsA() {
  if (b == 42) {
  auto temp = static_cast(this);
  //__builtin_assume(temp != nullptr);
  return temp;
  }
  return nullptr;
  }
  
  void helper(A *);
  
  void test(B *b) {
  auto temp = b->getAsA();
  if (temp)
  return helper(temp);
  }


https://reviews.llvm.org/D42249

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/catch-undef-behavior.cpp


Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -371,7 +371,7 @@
 void downcast_pointer(B *b) {
   (void) static_cast(b);
   // Alignment check from EmitTypeCheck(TCK_DowncastPointer, ...)
-  // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr i8, i8* {{.*}}, i64 -16
+  // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr inbounds i8, i8* {{.*}}, i64 
-16
   // CHECK-NEXT: [[C:%.+]] = bitcast i8* [[SUB]] to %class.C*
   // null check goes here
   // CHECK: [[FROM_PHI:%.+]] = phi %class.C* [ [[C]], {{.*}} ], {{.*}}
@@ -388,7 +388,7 @@
 void downcast_reference(B &b) {
   (void) static_cast(b);
   // Alignment check from EmitTypeCheck(TCK_DowncastReference, ...)
-  // CHECK:  [[SUB:%[.a-z0-9]*]] = getelementptr i8, i8* {{.*}}, i64 -16
+  // CHECK:  [[SUB:%[.a-z0-9]*]] = getelementptr inbounds i8, i8* {{.*}}, 
i64 -16
   // CHECK-NEXT: [[C:%.+]] = bitcast i8* [[SUB]] to %class.C*
   // Objectsize check goes here
   // CHECK:  [[C_INT:%.+]] = ptrtoint %class.C* [[C]] to i64
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -406,8 +406,10 @@
 
   // Apply the offset.
   llvm::Value *Value = Builder.CreateBitCast(BaseAddr.getPointer(), Int8PtrTy);
-  Value = Builder.CreateGEP(Value, Builder.CreateNeg(NonVirtualOffset),
-"sub.ptr");
+
+  // The GEP is to a derived object, so this GEP must be 'inbounds'.
+  Value = Builder.CreateInBoundsGEP(Value, Builder.CreateNeg(NonVirtualOffset),
+"sub.ptr");
 
   // Just cast.
   Value = Builder.CreateBitCast(Value, DerivedPtrTy);


Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -371,7 +371,7 @@
 void downcast_pointer(B *b) {
   (void) static_cast(b);
   // Alignment check from EmitTypeCheck(TCK_DowncastPointer, ...)
-  // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr i8, i8* {{.*}}, i64 -16
+  // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr inbounds i8, i8* {{.*}}, i64 -16
   // CHECK-NEXT: [[C:%.+]] = bitcast i8* [[SUB]] to %class.C*
   // null check goes here
   // CHECK: [[FROM_PHI:%.+]] = phi %class.C* [ [[C]], {{.*}} ], {{.*}}
@@ -388,7 +388,7 @@
 void downcast_reference(B &b) {
   (void) static_cast(b);
   // Alignment check from EmitTypeCheck(TCK_DowncastReference, ...)
-  // CHECK:  [[SUB:%[.a-z0-9]*]] = getelementptr i8, i8* {{.*}}, i64 -16
+  // CHECK:  [[SUB:%[.a-z0-9]*]] = getelementptr inbounds i8, i8* {{.*}}, i64 -16
   // CHECK-NEXT: [[C:%.+]] = bitcast i8* [[SUB]] to %class.C*
   // Objectsize check goes here
   // CHECK:  [[C_INT:%.+]] = ptrtoint %class.C* [[C]] to i64
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -406,8 +406,10 @@
 
   // Apply the offset.
   llvm::Value *Value = Builder.CreateBitCast(BaseAddr.getPointer(), Int8PtrTy);
-  Value = Builder.CreateGEP(Value, Builder.CreateNeg(NonVirtualOffset),
-"sub.ptr");
+
+  // The GEP is to a derived object, so this GEP must be 'inbounds'.
+  Value = Builder.CreateInBoundsGEP(Value, Builder.CreateNeg(NonVirtualOffset),
+"sub.ptr");
 
   // Just cast.
   Value = Builder.CreateBitCast(Value, DerivedPtrTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.

[PATCH] D42181: [clangd] Merge index-provided completions with those from Sema.

2018-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 130440.
sammccall added a comment.

Converted the big codeComplete function to a CodeCompleteFlow class


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42181

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

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -17,7 +17,6 @@
 #include "SourceCode.h"
 #include "TestFS.h"
 #include "index/MemIndex.h"
-#include "index/Merge.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -82,7 +81,7 @@
   return arg.insertTextFormat == clangd::InsertTextFormat::Snippet &&
  arg.insertText == Text;
 }
-MATCHER(FilterContainsName, "") {
+MATCHER(NameContainsFilter, "") {
   if (arg.filterText.empty())
 return true;
   return llvm::StringRef(arg.insertText).contains(arg.filterText);
@@ -129,30 +128,53 @@
   .get()
   .second.Value;
   // Sanity-check that filterText is valid.
-  EXPECT_THAT(CompletionList.items, Each(FilterContainsName()));
+  EXPECT_THAT(CompletionList.items, Each(NameContainsFilter()));
   return CompletionList;
 }
 
+std::string replace(StringRef Haystack, StringRef Needle, StringRef Repl) {
+  std::string Result;
+  raw_string_ostream OS(Result);
+  std::pair Split;
+  for (Split = Haystack.split(Needle); !Split.second.empty();
+   Split = Split.first.split(Needle))
+OS << Split.first << Repl;
+  Result += Split.first;
+  OS.flush();
+  return Result;
+}
+
 // Helpers to produce fake index symbols for memIndex() or completions().
-Symbol sym(StringRef QName, index::SymbolKind Kind) {
+// USRFormat is a regex replacement string for the unqualified part of the USR.
+Symbol sym(StringRef QName, index::SymbolKind Kind, StringRef USRFormat) {
   Symbol Sym;
-  Sym.ID = SymbolID(QName);
+  std::string USR = "c:"; // We synthesize a few simple cases of USRs by hand!
   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);
+USR += "@N@" + replace(Sym.Scope, "::", "@N@"); // ns:: -> @N@ns
   }
+  USR += Regex("^.*$").sub(USRFormat, Sym.Name); // e.g. func -> @F@func#
+  Sym.ID = SymbolID(USR);
   Sym.CompletionPlainInsertText = Sym.Name;
+  Sym.CompletionSnippetInsertText = Sym.Name;
   Sym.CompletionLabel = Sym.Name;
   Sym.SymInfo.Kind = Kind;
   return Sym;
 }
-Symbol func(StringRef Name) { return sym(Name, index::SymbolKind::Function); }
-Symbol cls(StringRef Name) { return sym(Name, index::SymbolKind::Class); }
-Symbol var(StringRef Name) { return sym(Name, index::SymbolKind::Variable); }
+Symbol func(StringRef Name) { // Assumes the function has no args.
+  return sym(Name, index::SymbolKind::Function, "@F@\\0#"); // no args
+}
+Symbol cls(StringRef Name) {
+  return sym(Name, index::SymbolKind::Class, "@S@\\0@S@\\0");
+}
+Symbol var(StringRef Name) {
+  return sym(Name, index::SymbolKind::Variable, "@\\0");
+}
 
 TEST(CompletionTest, Limit) {
   clangd::CodeCompleteOptions Opts;
@@ -226,7 +248,7 @@
 ClassWithMembers().^
   }
   )cpp",
-  /*IndexSymbols=*/{}, Opts);
+  {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
   // Class members. The only items that must be present in after-dot
   // completion.
@@ -236,9 +258,11 @@
   EXPECT_IFF(Opts.IncludeIneligibleResults, Results.items,
  Has("private_field"));
   // Global items.
-  EXPECT_THAT(Results.items, Not(AnyOf(Has("global_var"), Has("global_func"),
-   Has("global_func()"), Has("GlobalClass"),
-   Has("MACRO"), Has("LocalClass";
+  EXPECT_THAT(
+  Results.items,
+  Not(AnyOf(Has("global_var"), Has("index_var"), Has("global_func"),
+Has("global_func()"), Has("index_func"), Has("GlobalClass"),
+Has("IndexClass"), Has("MACRO"), Has("LocalClass";
   // There should be no code patterns (aka snippets) in after-dot
   // completion. At least there aren't any we're aware of.
   EXPECT_THAT(Results.items, Not(Contains(Kind(CompletionItemKind::Snippet;
@@ -271,16 +295,17 @@
 ^
   }
   )cpp",
-  /*IndexSymbols=*/{}, Opts);
+  {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.items,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
   // Global items.
   EXPECT_THAT(Results.items,
-  AllOf(Has("global_var"),
+  AllOf(Has("global_var"), Has("index_var"),
 Has(Opts.EnableSnippets ? "global_func()" : "global_func"),
-Has("GlobalClass")));
+Has("index_func" /

[PATCH] D42073: [clangd] Query all visible scopes based on all visible using-namespace declarationsand containing namespace for global qualified code completion.

2018-01-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:270
+  /// namespace scopes which are visible to the qualified-id completion token.
+  std::vector Scopes;
+};

ilya-biryukov wrote:
> sammccall wrote:
> > Just to check, if the user types:
> > "vec" --> None
> > "::vec" --> {""}
> > "std::vec" --> {"std"}
> > "using namespace std; vec" --> None
> > "using namespace std; ::vec" --> {"", "std"}
> > 
> > is this right?
> I think the idea was to have (I only highlight the differences):
> "vec" --> {""}
> "using namespace std; vec" --> {"", "std"}
> 
> @hokein , or am I getting it wrong?
You're probably right, just want to be sure we're talking about the same thing.

There's two layers here: the context detected from sema, and what we're going 
to send the index. The layering is more relevant now that more of this moves 
out of clangd.

for "vec", we should be sending {""} to the index for now, and later move 
towards doing global completion.
But if possible the detection code should report None, and the query-index code 
should translate it - there's no reason the detection code needs to be wrong 
just because clangd can't do qualifier insertion/smart ranking/etc.

That said, per our discussion this morning, the detected state shouldn't really 
be Optional>, but rather struct { vector 
AccessibleScope, optional UnresolvedQualifier } or something like 
that...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42073



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


[libcxxabi] r322870 - [cmake] [libcxxabi] Don't print warning when tests are disabled.

2018-01-18 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Thu Jan 18 10:29:36 2018
New Revision: 322870

URL: http://llvm.org/viewvc/llvm-project?rev=322870&view=rev
Log:
[cmake] [libcxxabi] Don't print warning when tests are disabled.

Summary:
Don't print, possibly erroneous, warning if
LIBCXXABI_INCLUDE_TESTS is false.

This patch fixes a problem introduced in r291367.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=322870&r1=322869&r2=322870&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Thu Jan 18 10:29:36 2018
@@ -440,18 +440,21 @@ endif()
 # soname, etc...
 add_subdirectory(src)
 
-if (NOT LIBCXXABI_INCLUDE_TESTS OR (LIBCXXABI_STANDALONE_BUILD AND NOT 
LIBCXXABI_ENABLE_SHARED))
-  # We can't reasonably test the system C++ library with a static libc++abi.
-  # We either need to be able to replace libc++abi at run time (with a shared
-  # libc++abi), or we need to be able to replace the C++ runtime (with a non-
-  # standalone build).
-  message(WARNING "The libc++abi tests aren't valid when libc++abi is built "
-  "standalone (i.e. outside of llvm/projects/libcxxabi ) and "
-  "is built without a shared library.  Either build a shared "
-  "library, build libc++abi at the same time as you build "
-  "libc++, or do without testing.  No check target will be "
-  "available!")
-else()
-  add_subdirectory(test)
-  add_subdirectory(fuzz)
+if (LIBCXXABI_INCLUDE_TESTS)
+  if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED)
+# We can't reasonably test the system C++ library with a static
+# libc++abi.  We either need to be able to replace libc++abi at
+# run time (with a shared libc++abi), or we need to be able to
+# replace the C++ runtime (with a non- standalone build).
+message(WARNING "The libc++abi tests aren't valid when libc++abi "
+"is built standalone (i.e. outside of "
+"llvm/projects/libcxxabi ) and is built without "
+"a shared library.  Either build a shared "
+"library, build libc++abi at the same time as "
+"you build libc++, or do without testing.  No "
+"check target will be available!")
+  else()
+add_subdirectory(test)
+add_subdirectory(fuzz)
+  endif()
 endif()


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


[PATCH] D42229: [cmake] [libcxxabi] Don't print warning when tests are disabled.

2018-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322870: [cmake] [libcxxabi] Don't print warning when 
tests are disabled. (authored by dhinton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42229

Files:
  libcxxabi/trunk/CMakeLists.txt


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -440,18 +440,21 @@
 # soname, etc...
 add_subdirectory(src)
 
-if (NOT LIBCXXABI_INCLUDE_TESTS OR (LIBCXXABI_STANDALONE_BUILD AND NOT 
LIBCXXABI_ENABLE_SHARED))
-  # We can't reasonably test the system C++ library with a static libc++abi.
-  # We either need to be able to replace libc++abi at run time (with a shared
-  # libc++abi), or we need to be able to replace the C++ runtime (with a non-
-  # standalone build).
-  message(WARNING "The libc++abi tests aren't valid when libc++abi is built "
-  "standalone (i.e. outside of llvm/projects/libcxxabi ) and "
-  "is built without a shared library.  Either build a shared "
-  "library, build libc++abi at the same time as you build "
-  "libc++, or do without testing.  No check target will be "
-  "available!")
-else()
-  add_subdirectory(test)
-  add_subdirectory(fuzz)
+if (LIBCXXABI_INCLUDE_TESTS)
+  if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED)
+# We can't reasonably test the system C++ library with a static
+# libc++abi.  We either need to be able to replace libc++abi at
+# run time (with a shared libc++abi), or we need to be able to
+# replace the C++ runtime (with a non- standalone build).
+message(WARNING "The libc++abi tests aren't valid when libc++abi "
+"is built standalone (i.e. outside of "
+"llvm/projects/libcxxabi ) and is built without "
+"a shared library.  Either build a shared "
+"library, build libc++abi at the same time as "
+"you build libc++, or do without testing.  No "
+"check target will be available!")
+  else()
+add_subdirectory(test)
+add_subdirectory(fuzz)
+  endif()
 endif()


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -440,18 +440,21 @@
 # soname, etc...
 add_subdirectory(src)
 
-if (NOT LIBCXXABI_INCLUDE_TESTS OR (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED))
-  # We can't reasonably test the system C++ library with a static libc++abi.
-  # We either need to be able to replace libc++abi at run time (with a shared
-  # libc++abi), or we need to be able to replace the C++ runtime (with a non-
-  # standalone build).
-  message(WARNING "The libc++abi tests aren't valid when libc++abi is built "
-  "standalone (i.e. outside of llvm/projects/libcxxabi ) and "
-  "is built without a shared library.  Either build a shared "
-  "library, build libc++abi at the same time as you build "
-  "libc++, or do without testing.  No check target will be "
-  "available!")
-else()
-  add_subdirectory(test)
-  add_subdirectory(fuzz)
+if (LIBCXXABI_INCLUDE_TESTS)
+  if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED)
+# We can't reasonably test the system C++ library with a static
+# libc++abi.  We either need to be able to replace libc++abi at
+# run time (with a shared libc++abi), or we need to be able to
+# replace the C++ runtime (with a non- standalone build).
+message(WARNING "The libc++abi tests aren't valid when libc++abi "
+"is built standalone (i.e. outside of "
+"llvm/projects/libcxxabi ) and is built without "
+"a shared library.  Either build a shared "
+"library, build libc++abi at the same time as "
+"you build libc++, or do without testing.  No "
+"check target will be available!")
+  else()
+add_subdirectory(test)
+add_subdirectory(fuzz)
+  endif()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42187: [clang-format] Adds a canonical delimiter to raw string formatting

2018-01-18 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg




Comment at: lib/Format/ContinuationIndenter.cpp:1336
+  unsigned OldSuffixSize = 2 + OldDelimiter.size();
+  std::string RawText =
+  Current.TokenText.substr(OldPrefixSize).drop_back(OldSuffixSize);

Can this be a StringRef? Can RawText outlive the Current token?


Repository:
  rC Clang

https://reviews.llvm.org/D42187



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


[libcxx] r322872 - Add memory tracking

2018-01-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jan 18 10:37:11 2018
New Revision: 322872

URL: http://llvm.org/viewvc/llvm-project?rev=322872&view=rev
Log:
Add memory tracking


Modified:
libcxx/trunk/fuzzing/fuzz_test.cpp

Modified: libcxx/trunk/fuzzing/fuzz_test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/fuzzing/fuzz_test.cpp?rev=322872&r1=322871&r2=322872&view=diff
==
--- libcxx/trunk/fuzzing/fuzz_test.cpp (original)
+++ libcxx/trunk/fuzzing/fuzz_test.cpp Thu Jan 18 10:37:11 2018
@@ -19,6 +19,8 @@
 //
 //  Each file should contain a test case.
 
+//  TODO: should add some memory tracking, too.
+
 
 #include 
 #include 
@@ -29,6 +31,78 @@
 
 #include "fuzzing.h"
 
+//   Count memory allocations 
+
+struct MemoryCounters {
+size_t totalAllocationCount;
+size_t netAllocationCount;
+size_t totalBytesAllocated;
+};
+
+MemoryCounters gMemoryCounters;
+
+void ZeroMemoryCounters() {
+gMemoryCounters.totalAllocationCount = 0;
+gMemoryCounters.netAllocationCount = 0;
+gMemoryCounters.totalBytesAllocated = 0;
+}
+
+void* operator new(std::size_t size)
+{
+if (size == 0) size = 1;
+void *p = ::malloc(size);
+if (p == NULL)
+throw std::bad_alloc();
+gMemoryCounters.totalAllocationCount += 1;
+gMemoryCounters.netAllocationCount  += 1;
+gMemoryCounters.totalBytesAllocated += size;
+return p;
+}
+
+void* operator new(std::size_t size, const std::nothrow_t&) noexcept
+{
+try { return operator new(size); }
+catch (const std::bad_alloc &) {}
+return nullptr;
+}
+
+void* operator new[](std::size_t size)
+{
+return ::operator new(size);
+}
+
+void* operator new[](std::size_t size, const std::nothrow_t&) noexcept
+{
+try { return operator new(size); }
+catch (const std::bad_alloc &) {}
+return nullptr;
+}
+
+void  operator delete(void* ptr) noexcept
+{
+if (ptr)
+::free(ptr);
+gMemoryCounters.netAllocationCount -= 1;
+}
+
+void  operator delete(void* ptr, const std::nothrow_t&) noexcept
+{
+::operator delete(ptr);
+}
+
+void  operator delete[](void* ptr) noexcept
+{
+::operator delete(ptr);
+}
+
+void  operator delete[](void* ptr, const std::nothrow_t&) noexcept
+{
+::operator delete(ptr);
+}
+
+//   End count memory allocations 
+
+
 typedef int (*FuzzProc) (const uint8_t *data, size_t size);
 
 const std::map procs = {
@@ -64,21 +138,30 @@ void test_one(const char *filename, Fuzz
 std::ifstream f (filename, std::ios::binary);
 if (!f.is_open())
 std::cerr << "## Can't open '" << filename << "'" << std::endl;
-else {
+else
+{
 typedef std::istream_iterator Iter;
 std::copy(Iter(f), Iter(), std::back_inserter(v));
 if (verbose)
 std::cout << "File '" << filename << "' contains " << v.size() << 
" entries" << std::endl;
+ZeroMemoryCounters();
 const auto start_time = std::chrono::high_resolution_clock::now();
 int ret = fp (v.data(), v.size());
 const auto finish_time = std::chrono::high_resolution_clock::now();
+MemoryCounters mc = gMemoryCounters;
 if (ret != 0)
 std::cerr << "## Failure code: " << ret << std::endl;
 if (verbose)
+{
 std::cout << "Execution time: "
 << 
std::chrono::duration_cast(finish_time - 
start_time).count()
 << " milliseconds" << std::endl;
+std::cout << "Memory: " 
+  << mc.totalBytesAllocated  << " bytes allocated ("
+  << mc.totalAllocationCount << " allocations); "
+  << mc.netAllocationCount   << " allocations remain" << 
std::endl;
 }
+}
 }
 
 void usage (const char *name)


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


r322873 - [ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style

2018-01-18 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Thu Jan 18 10:37:16 2018
New Revision: 322873

URL: http://llvm.org/viewvc/llvm-project?rev=322873&view=rev
Log:
[ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style

Summary:
The Google style guide is neutral on whether there should be a
space before the protocol list in an Objective-C @interface or
@implementation.

The majority of Objective-C code in both Apple's public
header files and Google's open-source uses a space before
the protocol list, so this changes the google style to
default ObjCSpaceBeforeProtocolList to true.

Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=322873&r1=322872&r2=322873&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Jan 18 10:37:16 2018
@@ -694,7 +694,7 @@ FormatStyle getGoogleStyle(FormatStyle::
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
-  GoogleStyle.ObjCSpaceBeforeProtocolList = false;
+  GoogleStyle.ObjCSpaceBeforeProtocolList = true;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
   GoogleStyle.RawStringFormats = {{
   FormatStyle::LK_TextProto,

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=322873&r1=322872&r2=322873&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Thu Jan 18 10:37:16 2018
@@ -271,7 +271,7 @@ TEST_F(FormatTestObjC, FormatObjCInterfa
"@end");
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
-  verifyFormat("@interface Foo : NSObject {\n"
+  verifyFormat("@interface Foo : NSObject  {\n"
" @public\n"
"  int field1;\n"
" @protected\n"
@@ -283,15 +283,15 @@ TEST_F(FormatTestObjC, FormatObjCInterfa
"}\n"
"+ (id)init;\n"
"@end");
-  verifyFormat("@interface Foo : Bar\n"
+  verifyFormat("@interface Foo : Bar \n"
"+ (id)init;\n"
"@end");
-  verifyFormat("@interface Foo (HackStuff)\n"
+  verifyFormat("@interface Foo (HackStuff) \n"
"+ (id)init;\n"
"@end");
   Style.BinPackParameters = false;
   Style.ColumnLimit = 80;
-  verifyFormat("@interface a ()<\n"
+  verifyFormat("@interface a () <\n"
"a,\n"
",\n"
"aa,\n"
@@ -414,7 +414,7 @@ TEST_F(FormatTestObjC, FormatObjCProtoco
"@end");
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
-  verifyFormat("@protocol MyProtocol\n"
+  verifyFormat("@protocol MyProtocol \n"
"- (NSUInteger)numberOfThings;\n"
"@end");
 }


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


[PATCH] D41074: [ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style

2018-01-18 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322873: [ClangFormat] ObjCSpaceBeforeProtocolList should be 
true in the google style (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41074?vs=126806&id=130448#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41074

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestObjC.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -694,7 +694,7 @@
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
-  GoogleStyle.ObjCSpaceBeforeProtocolList = false;
+  GoogleStyle.ObjCSpaceBeforeProtocolList = true;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
   GoogleStyle.RawStringFormats = {{
   FormatStyle::LK_TextProto,
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -271,7 +271,7 @@
"@end");
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
-  verifyFormat("@interface Foo : NSObject {\n"
+  verifyFormat("@interface Foo : NSObject  {\n"
" @public\n"
"  int field1;\n"
" @protected\n"
@@ -283,15 +283,15 @@
"}\n"
"+ (id)init;\n"
"@end");
-  verifyFormat("@interface Foo : Bar\n"
+  verifyFormat("@interface Foo : Bar \n"
"+ (id)init;\n"
"@end");
-  verifyFormat("@interface Foo (HackStuff)\n"
+  verifyFormat("@interface Foo (HackStuff) \n"
"+ (id)init;\n"
"@end");
   Style.BinPackParameters = false;
   Style.ColumnLimit = 80;
-  verifyFormat("@interface a ()<\n"
+  verifyFormat("@interface a () <\n"
"a,\n"
",\n"
"aa,\n"
@@ -414,7 +414,7 @@
"@end");
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
-  verifyFormat("@protocol MyProtocol\n"
+  verifyFormat("@protocol MyProtocol \n"
"- (NSUInteger)numberOfThings;\n"
"@end");
 }


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -694,7 +694,7 @@
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
-  GoogleStyle.ObjCSpaceBeforeProtocolList = false;
+  GoogleStyle.ObjCSpaceBeforeProtocolList = true;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
   GoogleStyle.RawStringFormats = {{
   FormatStyle::LK_TextProto,
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -271,7 +271,7 @@
"@end");
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
-  verifyFormat("@interface Foo : NSObject {\n"
+  verifyFormat("@interface Foo : NSObject  {\n"
" @public\n"
"  int field1;\n"
" @protected\n"
@@ -283,15 +283,15 @@
"}\n"
"+ (id)init;\n"
"@end");
-  verifyFormat("@interface Foo : Bar\n"
+  verifyFormat("@interface Foo : Bar \n"
"+ (id)init;\n"
"@end");
-  verifyFormat("@interface Foo (HackStuff)\n"
+  verifyFormat("@interface Foo (HackStuff) \n"
"+ (id)init;\n"
"@end");
   Style.BinPackParameters = false;
   Style.ColumnLimit = 80;
-  verifyFormat("@interface a ()<\n"
+  verifyFormat("@interface a () <\n"
"a,\n"
",\n"
"aa,\n"
@@ -414,7 +414,7 @@
"@end");
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
-  verifyFormat("@protocol MyProtocol\n"
+  verifyFormat("@protocol MyProtocol \n"
"- (NSUInteger)numberOfThings;\n"
"@end");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42248: [LangOpts] Add a LangOpt to represent "#pragma region" support.

2018-01-18 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

Why not always support the pragma regardless of the compiler mode? Our 
"support" for it just ignores it anyway...


https://reviews.llvm.org/D42248



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


[PATCH] D42248: [LangOpts] Add a LangOpt to represent "#pragma region" support.

2018-01-18 Thread Matt Davis via Phabricator via cfe-commits
mattd added a comment.

In https://reviews.llvm.org/D42248#980541, @majnemer wrote:

> Why not always support the pragma regardless of the compiler mode? Our 
> "support" for it just ignores it anyway...


Thanks for the reply @majnemer.

I am not opposed to that idea.  My change just operates similar to the existing 
behavior.  The only reservation I had against not always accepting the pragma 
is that it might mislead devs who are not using PS4/VS based environments.


https://reviews.llvm.org/D42248



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


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130458.
MaskRay added a comment.

More


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   A c;
 ///
-///   template f() {};
+///   template void f() {};
 ///   void func() { f(); };
 /// \endcode
 /// classTemplateSpecializationDecl(hasTemplateArgument(
@@ -880,12 +880,12 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<&B::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
 /// \c B::next
 AST_MATCHER_P(TemplateArgument, refersToDeclaration,
@@ -899,8 +899,8 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<&B::next> a;
 /// \endcode
 /// templateSpecializationType(hasAnyTemplateArgument(
@@ -917,7 +917,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -932,7 +932,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -953,7 +953,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -1523,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   A c;
 ///
-///   template f() {};
+///   template void f() {};
 ///   void func() { f(); };
 /// \endcode
 /// classTemplateSpecializationDecl(hasTemplateArgument(
@@ -880,12 +880,12 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<&B::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
 /// \c B::next
 AST_MATCHER_P(TemplateArgument, refersToDeclaration,
@@ -899,8 +899,8 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<&B::next> a;
 /// \endcode
 /// templateSpecializationType(hasAnyTemplateArgument(
@@ -917,7 +917,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -932,7 +932,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -953,7 +953,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -1523,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42253: [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

2018-01-18 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: Wizard, hokein, klimek.
Herald added a subscriber: cfe-commits.

We were missing some pretty common acronyms in the camelCase
property name check objc-property-declaration.

This expands the list and sorts it lexicographically, so we can
avoid duplicates.

Test Plan: make -j12 check-clang-tools


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42253

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  test/clang-tidy/objc-property-declaration.m

Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -1,13 +1,17 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t
+@class NSData;
 @class NSString;
+@class UIViewController;
 
 @interface Foo
 @property(assign, nonatomic) int NotCamelCase;
 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
 @property(strong, nonatomic) NSString *bundleID;
+@property(strong, nonatomic) NSData *RGBABytes;
+@property(strong, nonatomic) UIViewController *notificationsVC;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -24,25 +24,63 @@
 namespace {
 /// The acronyms are from
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
+///
+/// Keep this list sorted.
 constexpr char DefaultSpecialAcronyms[] =
+"ACL;"
+"API;"
+"ARGB;"
 "ASCII;"
-"PDF;"
-"XML;"
+"BGRA;"
+"CMYK;"
+"DNS;"
+"FPS;"
+"FTP;"
+"GIF;"
+"GPS;"
+"HD;"
+"HDR;"
 "HTML;"
-"URL;"
-"RTF;"
 "HTTP;"
-"TIFF;"
+"HTTPS;"
+"HUD;"
+"ID;"
 "JPG;"
-"PNG;"
-"GIF;"
+"JS;"
+"LAN;"
 "LZW;"
-"ROM;"
-"RGB;"
-"CMYK;"
+"MDNS;"
 "MIDI;"
-"FTP;"
-"ID";
+"OS;"
+"PDF;"
+"PIN;"
+"PNG;"
+"POI;"
+"PSTN;"
+"PTR;"
+"QA;"
+"QOS;"
+"RGB;"
+"RGBA;"
+"RGBX;"
+"ROM;"
+"RPC;"
+"RTF;"
+"RTL;"
+"SDK;"
+"SSO;"
+"TCP;"
+"TIFF;"
+"TTS;"
+"UI;"
+"URI;"
+"URL;"
+"VC;"
+"VOIP;"
+"VPN;"
+"VR;"
+"WAN;"
+"XML";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Don't forget that you also need to regenerate the HTML docs:

  $ cd docs/tools # yes, cd
  $ ./dump_ast_matchers.py


Repository:
  rC Clang

https://reviews.llvm.org/D42213



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


[PATCH] D42043: c-index: CXString: fix MSAN read-past-end bug

2018-01-18 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande added a comment.

Thanks very much for looking at this @vsk !  I actually found an ASAN bug in my 
new code, mixing and matching `malloc/free` and `operator`s `new/delete`.




Comment at: tools/c-index-test/c-index-test.c:3268
 
-  filename = clang_getFileName(file);
-  index_data->main_filename = clang_getCString(filename);
-  clang_disposeString(filename);
+  index_data->main_filename = clang_getFileName(file);
 

vsk wrote:
> This looks like a separate bug fix. Is it possible to separate the 
> main_filename changes from this patch?
Will do!



Comment at: tools/libclang/CXString.cpp:59
 CXString createEmpty() {
   CXString Str;
+  Str.Contents = (const void *) "";

vsk wrote:
> Why shouldn't this be defined as createRef("")?
Hmm, good question.  `createRef` below actually calls back to `createEmpty` and 
`createNull` in the nonnull-but-empty and null cases.

I think I'll do this the other way around, and let `createRef` have the 
responsibility of dealing with these fields and nulls and whatnot.



Comment at: tools/libclang/CXString.cpp:213
+  if (string.IsNullTerminated) {
+CString = (const char *) string.Contents;
+  } else {

vsk wrote:
> Basic question: If a non-owning CXString is null-terminated, what provides 
> the guarantee that the string is in fact valid when getCString() is called? 
> Is the user of the C API responsible for ensuring the lifetime of the string 
> is valid?
I believe the API itself is the one building `CXString` instances, and the user 
of the C API doesn't really create them, only use them.  So the API has to 
ensure the string stays "good" while there may be references to it.

(Which feels a little fragile.  But I think that's the tradeoff being made.  
You'll get either "fast" strings, or data guaranteed to be sane.  I'd opt for 
safer data but I don't know who's using this C API and am afraid to introduce a 
serious perf regression.  So it'll stay this way and I'll try my best to solve 
*-SAN issues with these constraints :) )


Repository:
  rC Clang

https://reviews.llvm.org/D42043



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


[PATCH] D42249: [CodeGenCXX] annotate a GEP to a derived class with 'inbounds' (PR35909)

2018-01-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGClass.cpp:410
+
+  // The GEP is to a derived object, so this GEP must be 'inbounds'.
+  Value = Builder.CreateInBoundsGEP(Value, Builder.CreateNeg(NonVirtualOffset),

Not sure this comment really adds anything, unless you want to cite the 
standard.



Comment at: test/CodeGenCXX/catch-undef-behavior.cpp:391
   // Alignment check from EmitTypeCheck(TCK_DowncastReference, ...)
-  // CHECK:  [[SUB:%[.a-z0-9]*]] = getelementptr i8, i8* {{.*}}, i64 -16
+  // CHECK:  [[SUB:%[.a-z0-9]*]] = getelementptr inbounds i8, i8* {{.*}}, 
i64 -16
   // CHECK-NEXT: [[C:%.+]] = bitcast i8* [[SUB]] to %class.C*

We probably want a test which checks the output when ubsan isn't enabled.


https://reviews.llvm.org/D42249



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-01-18 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun updated this revision to Diff 130461.
khuttun added a comment.

- Detect unused return values also inside other kinds of statements than 
compound statements
- Ignore void functions in the checker
- Check std::remove, std::remove_if and std::unique by default


https://reviews.llvm.org/D41655

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tidy/bugprone/UnusedReturnValueCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-unused-return-value.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-unused-return-value-custom.cpp
  test/clang-tidy/bugprone-unused-return-value.cpp

Index: test/clang-tidy/bugprone-unused-return-value.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-unused-return-value.cpp
@@ -0,0 +1,311 @@
+// RUN: %check_clang_tidy %s bugprone-unused-return-value %t
+
+namespace std {
+
+using size_t = decltype(sizeof(int));
+
+using max_align_t = long double;
+
+struct future {};
+
+enum class launch {
+  async,
+  deferred
+};
+
+template 
+future async(Function &&, Args &&...);
+
+template 
+future async(launch, Function &&, Args &&...);
+
+template 
+bool empty(const T &);
+
+template 
+ForwardIt remove(ForwardIt, ForwardIt, const T &);
+
+template 
+ForwardIt remove_if(ForwardIt, ForwardIt, UnaryPredicate);
+
+template 
+ForwardIt unique(ForwardIt, ForwardIt);
+
+// the check should be able to match std lib calls even if the functions are
+// declared inside inline namespaces
+inline namespace v1 {
+
+template 
+T *launder(T *);
+
+} // namespace v1
+
+template 
+struct allocator {
+  using value_type = T;
+  T *allocate(std::size_t);
+  T *allocate(std::size_t, const void *);
+};
+
+template 
+struct allocator_traits {
+  using value_type = typename Alloc::value_type;
+  using pointer = value_type *;
+  using size_type = size_t;
+  using const_void_pointer = const void *;
+  static pointer allocate(Alloc &, size_type);
+  static pointer allocate(Alloc &, size_type, const_void_pointer);
+};
+
+template 
+struct scoped_allocator_adaptor : public OuterAlloc {
+  using pointer = typename allocator_traits::pointer;
+  using size_type = typename allocator_traits::size_type;
+  using const_void_pointer = typename allocator_traits::const_void_pointer;
+  pointer allocate(size_type);
+  pointer allocate(size_type, const_void_pointer);
+};
+
+template 
+struct default_delete {};
+
+template >
+struct unique_ptr {
+  using pointer = T *;
+  pointer release() noexcept;
+};
+
+template >
+struct vector {
+  bool empty() const noexcept;
+};
+
+namespace filesystem {
+
+struct path {
+  bool empty() const noexcept;
+};
+
+} // namespace filesystem
+
+namespace pmr {
+
+struct memory_resource {
+  void *allocate(size_t, size_t = alignof(max_align_t));
+};
+
+template 
+struct polymorphic_allocator {
+  T *allocate(size_t);
+};
+
+} // namespace pmr
+
+} // namespace std
+
+struct Foo {
+  void f();
+};
+
+int increment(int i) {
+  return i + 1;
+}
+
+void useFuture(const std::future &fut);
+
+struct FooAlloc {
+  using value_type = Foo;
+};
+
+void warning() {
+  std::async(increment, 42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::async(std::launch::async, increment, 42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  Foo F;
+  std::launder(&F);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::unique_ptr UP;
+  UP.release();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::unique_ptr> UP2;
+  UP2.release();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::allocator FA;
+  FA.allocate(1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  FA.allocate(1, nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::allocator_traits>::allocate(FA, 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  std::allocator_traits>::allocate(FA, 1, nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::scoped_allocator_adaptor SAA;
+  SAA.allocate(1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  SAA.allocate(1, nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning:

r322880 - Convert comment to C-style to prevent warning

2018-01-18 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Jan 18 11:31:33 2018
New Revision: 322880

URL: http://llvm.org/viewvc/llvm-project?rev=322880&view=rev
Log:
Convert comment to C-style to prevent warning

Modified:
cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=322880&r1=322879&r2=322880&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan 18 11:31:33 2018
@@ -739,7 +739,7 @@ static CXString CursorToText(CXCursor Cu
   }
   }
   assert(0 && "unknown display type"); /* no llvm_unreachable in C. */
-  // Set to NULL to prevent uninitialized variable warnings.
+  /* Set to NULL to prevent uninitialized variable warnings. */
   text.data = NULL;
   text.private_flags = 0;
   return text;


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


[PATCH] D42043: c-index: CXString: fix MSAN read-past-end bug

2018-01-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for working on this :).




Comment at: tools/libclang/CXString.cpp:213
+  if (string.IsNullTerminated) {
+CString = (const char *) string.Contents;
+  } else {

elsteveogrande wrote:
> vsk wrote:
> > Basic question: If a non-owning CXString is null-terminated, what provides 
> > the guarantee that the string is in fact valid when getCString() is called? 
> > Is the user of the C API responsible for ensuring the lifetime of the 
> > string is valid?
> I believe the API itself is the one building `CXString` instances, and the 
> user of the C API doesn't really create them, only use them.  So the API has 
> to ensure the string stays "good" while there may be references to it.
> 
> (Which feels a little fragile.  But I think that's the tradeoff being made.  
> You'll get either "fast" strings, or data guaranteed to be sane.  I'd opt for 
> safer data but I don't know who's using this C API and am afraid to introduce 
> a serious perf regression.  So it'll stay this way and I'll try my best to 
> solve *-SAN issues with these constraints :) )
Sgtm, it doesn't look like this is altering the API contract.


Repository:
  rC Clang

https://reviews.llvm.org/D42043



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


[PATCH] D42253: [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

2018-01-18 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

Can you update the doc btw since the acronyms are not only for prefix anymore?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42253



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-01-18 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun added a comment.

The checker reports 7 warnings on LLVM + Clang code bases, all on 
std::unique_ptr::release:

lib/Bitcode/Reader/BitReader.cpp:114:3

- release() called on moved-from unique_ptr
- no harm, just unnecessary

lib/ExecutionEngine/ExecutionEngine.cpp:149:7

- release() called before erasing unique_ptr from a container
- false positive?

lib/Target/AMDGPU/GCNIterativeScheduler.cpp:196:5

- release() called before assigning new pointer to unique_ptr
- false positive?

lib/AsmParser/LLParser.cpp:855:3

- get() + release() could be replaced with release()

tools/clang/lib/Lex/ModuleMap.cpp:791:3

- false positive?

tools/clang/tools/extra/clangd/Compiler.cpp:61:3

- get() + release() could potentially be replaced with release()?

unittests/Support/Casting.cpp:144:3

- release() called to avoid calling delete on a pointer to global object
- false positive?


https://reviews.llvm.org/D41655



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


[PATCH] D42259: c-index-test: small fix to CXString handling and disposal

2018-01-18 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande created this revision.
elsteveogrande added reviewers: vsk, benlangmuir, akyrtzi.
Herald added a subscriber: cfe-commits.

(Separating some unrelated changes out of https://reviews.llvm.org/D42043)


Repository:
  rC Clang

https://reviews.llvm.org/D42259

Files:
  tools/c-index-test/c-index-test.c

Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1128,6 +1128,13 @@
   }
 }
 
+static CXString createCXString(const char *CS) {
+  CXString Str;
+  Str.data = (const void *) CS;
+  Str.private_flags = 0;
+  return Str;
+}
+
 /**/
 /* Callbacks. */
 /**/
@@ -3090,7 +3097,7 @@
   int first_check_printed;
   int fail_for_error;
   int abort;
-  const char *main_filename;
+  CXString main_filename;
   ImportedASTFilesData *importedASTs;
   IndexDataStringList *strings;
   CXTranslationUnit TU;
@@ -3129,6 +3136,7 @@
   const char *cname;
   CXIdxClientFile file;
   unsigned line, column;
+  const char *main_filename;
   int isMainFile;
   
   index_data = (IndexData *)client_data;
@@ -3143,7 +3151,8 @@
   }
   filename = clang_getFileName((CXFile)file);
   cname = clang_getCString(filename);
-  if (strcmp(cname, index_data->main_filename) == 0)
+  main_filename = clang_getCString(index_data->main_filename);
+  if (strcmp(cname, main_filename) == 0)
 isMainFile = 1;
   else
 isMainFile = 0;
@@ -3345,14 +3354,11 @@
 static CXIdxClientFile index_enteredMainFile(CXClientData client_data,
CXFile file, void *reserved) {
   IndexData *index_data;
-  CXString filename;
 
   index_data = (IndexData *)client_data;
   printCheck(index_data);
 
-  filename = clang_getFileName(file);
-  index_data->main_filename = clang_getCString(filename);
-  clang_disposeString(filename);
+  index_data->main_filename = clang_getFileName(file);
 
   printf("[enteredMainFile]: ");
   printCXIndexFile((CXIdxClientFile)file);
@@ -3591,7 +3597,7 @@
   index_data.first_check_printed = 0;
   index_data.fail_for_error = 0;
   index_data.abort = 0;
-  index_data.main_filename = "";
+  index_data.main_filename = createCXString("");
   index_data.importedASTs = importedASTs;
   index_data.strings = NULL;
   index_data.TU = NULL;
@@ -3607,6 +3613,7 @@
   if (index_data.fail_for_error)
 result = -1;
 
+  clang_disposeString(index_data.main_filename);
   free_client_data(&index_data);
   return result;
 }
@@ -3628,7 +3635,7 @@
   index_data.first_check_printed = 0;
   index_data.fail_for_error = 0;
   index_data.abort = 0;
-  index_data.main_filename = "";
+  index_data.main_filename = createCXString("");
   index_data.importedASTs = importedASTs;
   index_data.strings = NULL;
   index_data.TU = TU;
@@ -3641,6 +3648,7 @@
 result = -1;
 
   clang_disposeTranslationUnit(TU);
+  clang_disposeString(index_data.main_filename);
   free_client_data(&index_data);
   return result;
 }
@@ -4133,9 +4141,7 @@
   if (!isUSR(I[2]))
 return not_usr("", I[2]);
   else {
-CXString x;
-x.data = (void*) I[2];
-x.private_flags = 0;
+CXString x = createCXString(I[2]);
 print_usr(clang_constructUSR_ObjCIvar(I[1], x));
   }
 
@@ -4160,9 +4166,7 @@
   if (!isUSR(I[3]))
 return not_usr("", I[3]);
   else {
-CXString x;
-x.data = (void*) I[3];
-x.private_flags = 0;
+CXString x = createCXString(I[3]);
 print_usr(clang_constructUSR_ObjCMethod(I[1], atoi(I[2]), x));
   }
   I += 4;
@@ -4190,9 +4194,7 @@
   if (!isUSR(I[2]))
 return not_usr("", I[2]);
   else {
-CXString x;
-x.data = (void*) I[2];
-x.private_flags = 0;
+CXString x = createCXString(I[2]);
 print_usr(clang_constructUSR_ObjCProperty(I[1], x));
   }
   I += 3;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42259: c-index-test: small fix to CXString handling and disposal

2018-01-18 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322883: c-index-test: small fix to CXString handling and 
disposal (authored by steveo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42259?vs=130475&id=130476#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42259

Files:
  tools/c-index-test/c-index-test.c

Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1128,6 +1128,13 @@
   }
 }
 
+static CXString createCXString(const char *CS) {
+  CXString Str;
+  Str.data = (const void *) CS;
+  Str.private_flags = 0;
+  return Str;
+}
+
 /**/
 /* Callbacks. */
 /**/
@@ -3090,7 +3097,7 @@
   int first_check_printed;
   int fail_for_error;
   int abort;
-  const char *main_filename;
+  CXString main_filename;
   ImportedASTFilesData *importedASTs;
   IndexDataStringList *strings;
   CXTranslationUnit TU;
@@ -3129,6 +3136,7 @@
   const char *cname;
   CXIdxClientFile file;
   unsigned line, column;
+  const char *main_filename;
   int isMainFile;
   
   index_data = (IndexData *)client_data;
@@ -3143,7 +3151,8 @@
   }
   filename = clang_getFileName((CXFile)file);
   cname = clang_getCString(filename);
-  if (strcmp(cname, index_data->main_filename) == 0)
+  main_filename = clang_getCString(index_data->main_filename);
+  if (strcmp(cname, main_filename) == 0)
 isMainFile = 1;
   else
 isMainFile = 0;
@@ -3345,14 +3354,11 @@
 static CXIdxClientFile index_enteredMainFile(CXClientData client_data,
CXFile file, void *reserved) {
   IndexData *index_data;
-  CXString filename;
 
   index_data = (IndexData *)client_data;
   printCheck(index_data);
 
-  filename = clang_getFileName(file);
-  index_data->main_filename = clang_getCString(filename);
-  clang_disposeString(filename);
+  index_data->main_filename = clang_getFileName(file);
 
   printf("[enteredMainFile]: ");
   printCXIndexFile((CXIdxClientFile)file);
@@ -3591,7 +3597,7 @@
   index_data.first_check_printed = 0;
   index_data.fail_for_error = 0;
   index_data.abort = 0;
-  index_data.main_filename = "";
+  index_data.main_filename = createCXString("");
   index_data.importedASTs = importedASTs;
   index_data.strings = NULL;
   index_data.TU = NULL;
@@ -3607,6 +3613,7 @@
   if (index_data.fail_for_error)
 result = -1;
 
+  clang_disposeString(index_data.main_filename);
   free_client_data(&index_data);
   return result;
 }
@@ -3628,7 +3635,7 @@
   index_data.first_check_printed = 0;
   index_data.fail_for_error = 0;
   index_data.abort = 0;
-  index_data.main_filename = "";
+  index_data.main_filename = createCXString("");
   index_data.importedASTs = importedASTs;
   index_data.strings = NULL;
   index_data.TU = TU;
@@ -3641,6 +3648,7 @@
 result = -1;
 
   clang_disposeTranslationUnit(TU);
+  clang_disposeString(index_data.main_filename);
   free_client_data(&index_data);
   return result;
 }
@@ -4133,9 +4141,7 @@
   if (!isUSR(I[2]))
 return not_usr("", I[2]);
   else {
-CXString x;
-x.data = (void*) I[2];
-x.private_flags = 0;
+CXString x = createCXString(I[2]);
 print_usr(clang_constructUSR_ObjCIvar(I[1], x));
   }
 
@@ -4160,9 +4166,7 @@
   if (!isUSR(I[3]))
 return not_usr("", I[3]);
   else {
-CXString x;
-x.data = (void*) I[3];
-x.private_flags = 0;
+CXString x = createCXString(I[3]);
 print_usr(clang_constructUSR_ObjCMethod(I[1], atoi(I[2]), x));
   }
   I += 4;
@@ -4190,9 +4194,7 @@
   if (!isUSR(I[2]))
 return not_usr("", I[2]);
   else {
-CXString x;
-x.data = (void*) I[2];
-x.private_flags = 0;
+CXString x = createCXString(I[2]);
 print_usr(clang_constructUSR_ObjCProperty(I[1], x));
   }
   I += 3;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42043: c-index: CXString: fix MSAN read-past-end bug

2018-01-18 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande marked 2 inline comments as done.
elsteveogrande added inline comments.



Comment at: tools/c-index-test/c-index-test.c:3268
 
-  filename = clang_getFileName(file);
-  index_data->main_filename = clang_getCString(filename);
-  clang_disposeString(filename);
+  index_data->main_filename = clang_getFileName(file);
 

elsteveogrande wrote:
> vsk wrote:
> > This looks like a separate bug fix. Is it possible to separate the 
> > main_filename changes from this patch?
> Will do!
Done: https://reviews.llvm.org/D42259


Repository:
  rC Clang

https://reviews.llvm.org/D42043



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


[PATCH] D42253: [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

2018-01-18 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 130478.
benhamilton added a comment.

- Added comment about prefixes and suffixes.
- Updated list of acronyms.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42253

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  docs/clang-tidy/checks/objc-property-declaration.rst
  test/clang-tidy/objc-property-declaration.m

Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -1,13 +1,17 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t
+@class NSData;
 @class NSString;
+@class UIViewController;
 
 @interface Foo
 @property(assign, nonatomic) int NotCamelCase;
 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
 @property(strong, nonatomic) NSString *bundleID;
+@property(strong, nonatomic) NSData *RGBABytes;
+@property(strong, nonatomic) UIViewController *notificationsVC;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: docs/clang-tidy/checks/objc-property-declaration.rst
===
--- docs/clang-tidy/checks/objc-property-declaration.rst
+++ docs/clang-tidy/checks/objc-property-declaration.rst
@@ -23,8 +23,8 @@
 only provide warning messages since the property name could be complicated.
 Users will need to come up with a proper name by their own.
 
-This check also accepts special acronyms as prefix. Such prefix will suppress
-the check of Lower Camel Case according to the guide:
+This check also accepts special acronyms as prefixes or suffixes. Such prefixes or suffixes
+will suppress the Lower Camel Case check according to the guide:
 https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB
 
 For a full list of well-known acronyms:
@@ -37,7 +37,7 @@
 
 .. option:: Acronyms
 
-   Semicolon-separated list of acronyms that can be used as prefix
-   of property names.
+   Semicolon-separated list of acronyms that can be used as a prefix
+   or a suffix of property names.
 
-   Defaults to `ASCII;PDF;XML;HTML;URL;RTF;HTTP;TIFF;JPG;PNG;GIF;LZW;ROM;RGB;CMYK;MIDI;FTP`.
+   If unset, defaults to "ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML".
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -24,25 +24,63 @@
 namespace {
 /// The acronyms are from
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
+///
+/// Keep this list sorted.
 constexpr char DefaultSpecialAcronyms[] =
+"ACL;"
+"API;"
+"ARGB;"
 "ASCII;"
-"PDF;"
-"XML;"
+"BGRA;"
+"CMYK;"
+"DNS;"
+"FPS;"
+"FTP;"
+"GIF;"
+"GPS;"
+"HD;"
+"HDR;"
 "HTML;"
-"URL;"
-"RTF;"
 "HTTP;"
-"TIFF;"
+"HTTPS;"
+"HUD;"
+"ID;"
 "JPG;"
-"PNG;"
-"GIF;"
+"JS;"
+"LAN;"
 "LZW;"
-"ROM;"
-"RGB;"
-"CMYK;"
+"MDNS;"
 "MIDI;"
-"FTP;"
-"ID";
+"OS;"
+"PDF;"
+"PIN;"
+"PNG;"
+"POI;"
+"PSTN;"
+"PTR;"
+"QA;"
+"QOS;"
+"RGB;"
+"RGBA;"
+"RGBX;"
+"ROM;"
+"RPC;"
+"RTF;"
+"RTL;"
+"SDK;"
+"SSO;"
+"TCP;"
+"TIFF;"
+"TTS;"
+"UI;"
+"URI;"
+"URL;"
+"VC;"
+"VOIP;"
+"VPN;"
+"VR;"
+"WAN;"
+"XML";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42261: [clang-tidy objc-property-declaration] New option AdditionalAcronyms

2018-01-18 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: Wizard, hokein, klimek.
Herald added a subscriber: cfe-commits.

The existing option objc-property-declaration.Acronyms
replaces the built-in set of acronyms.

While this behavior is OK for clients that don't want the default
behavior, many clients may just want to add their own custom acronyms
to the default list.

This revision introduces a new option,
objc-property-declaration.AdditionalAcronyms, which appends custom
acronyms to the default list (instead of replacing the default list).

I also updated the documentation.

Test Plan: make -j12 check-clang-tools


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42261

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tidy/objc/PropertyDeclarationCheck.h
  docs/clang-tidy/checks/objc-property-declaration.rst
  test/clang-tidy/objc-property-declaration-additional.m
  test/clang-tidy/objc-property-declaration-custom.m


Index: test/clang-tidy/objc-property-declaration-custom.m
===
--- test/clang-tidy/objc-property-declaration-custom.m
+++ test/clang-tidy/objc-property-declaration-custom.m
@@ -11,4 +11,6 @@
 @property(assign, nonatomic) int ABCCustomPrefix;
 @property(strong, nonatomic) NSString *ABC_custom_prefix;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' 
should use lowerCamelCase style, according to the Apple Coding Guidelines 
[objc-property-declaration]
+@property(assign, nonatomic) int GIFIgnoreStandardAcronym;
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 
'GIFIgnoreStandardAcronym' should use lowerCamelCase style, according to the 
Apple Coding Guidelines [objc-property-declaration]
 @end
Index: test/clang-tidy/objc-property-declaration-additional.m
===
--- test/clang-tidy/objc-property-declaration-additional.m
+++ test/clang-tidy/objc-property-declaration-additional.m
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t \
 // RUN: -config='{CheckOptions: \
-// RUN:  [{key: objc-property-declaration.Acronyms, value: "ABC;TGIF"}]}' \
+// RUN:  [{key: objc-property-declaration.AdditionalAcronyms, value: 
"ABC;TGIF"}]}' \
 // RUN: --
 @class NSString;
 
@@ -11,4 +11,5 @@
 @property(assign, nonatomic) int ABCCustomPrefix;
 @property(strong, nonatomic) NSString *ABC_custom_prefix;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' 
should use lowerCamelCase style, according to the Apple Coding Guidelines 
[objc-property-declaration]
+@property(assign, nonatomic) int GIFShouldIncludeStandardAcronym;
 @end
Index: docs/clang-tidy/checks/objc-property-declaration.rst
===
--- docs/clang-tidy/checks/objc-property-declaration.rst
+++ docs/clang-tidy/checks/objc-property-declaration.rst
@@ -41,3 +41,12 @@
or a suffix of property names.
 
If unset, defaults to 
"ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML".
+
+   If set, replaces the default list. (If you want to append to the default 
list, set AdditionalAcronyms instead.)
+
+.. option:: AdditionalAcronyms
+
+   Semicolon-separated list of additional acronyms that can be used as a prefix
+   or a suffix of property names.
+
+   Appends to the list in Acronyms.
Index: clang-tidy/objc/PropertyDeclarationCheck.h
===
--- clang-tidy/objc/PropertyDeclarationCheck.h
+++ clang-tidy/objc/PropertyDeclarationCheck.h
@@ -35,6 +35,7 @@
 
 private:
 const std::vector SpecialAcronyms;
+const std::vector AdditionalAcronyms;
 };
 
 } // namespace objc
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -124,14 +124,22 @@
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   SpecialAcronyms(utils::options::parseStringList(
-  Options.get("Acronyms", DefaultSpecialAcronyms))) {}
+  Options.get("Acronyms", DefaultSpecialAcronyms))),
+  AdditionalAcronyms(utils::options::parseStringList(
+  Options.get("AdditionalAcronyms", ""))) {}
 
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  std::vector Acronyms;
+  Acronyms.reserve(SpecialAcronyms.size() + AdditionalAcronyms.size());
+  Acronyms.insert(Acronyms.end(), SpecialAcronyms.begin(),
+  SpecialAcronyms.end());
+  Acronyms.insert(Acronyms.end(), AdditionalAcronyms.begin(),
+  AdditionalAcronyms.end());
   Finder->addMatcher(
   

[clang-tools-extra] r322886 - [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

2018-01-18 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Thu Jan 18 12:51:24 2018
New Revision: 322886

URL: http://llvm.org/viewvc/llvm-project?rev=322886&view=rev
Log:
[clang-tidy objc-property-declaration] Expand list of ObjC acronyms

Summary:
We were missing some pretty common acronyms in the camelCase
property name check objc-property-declaration.

This expands the list and sorts it lexicographically, so we can
avoid duplicates.

Test Plan: make -j12 check-clang-tools

Reviewers: Wizard, hokein, klimek

Reviewed By: Wizard

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=322886&r1=322885&r2=322886&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Thu 
Jan 18 12:51:24 2018
@@ -24,25 +24,63 @@ namespace objc {
 namespace {
 /// The acronyms are from
 /// 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
+///
+/// Keep this list sorted.
 constexpr char DefaultSpecialAcronyms[] =
+"ACL;"
+"API;"
+"ARGB;"
 "ASCII;"
-"PDF;"
-"XML;"
+"BGRA;"
+"CMYK;"
+"DNS;"
+"FPS;"
+"FTP;"
+"GIF;"
+"GPS;"
+"HD;"
+"HDR;"
 "HTML;"
-"URL;"
-"RTF;"
 "HTTP;"
-"TIFF;"
+"HTTPS;"
+"HUD;"
+"ID;"
 "JPG;"
-"PNG;"
-"GIF;"
+"JS;"
+"LAN;"
 "LZW;"
-"ROM;"
-"RGB;"
-"CMYK;"
+"MDNS;"
 "MIDI;"
-"FTP;"
-"ID";
+"OS;"
+"PDF;"
+"PIN;"
+"PNG;"
+"POI;"
+"PSTN;"
+"PTR;"
+"QA;"
+"QOS;"
+"RGB;"
+"RGBA;"
+"RGBX;"
+"ROM;"
+"RPC;"
+"RTF;"
+"RTL;"
+"SDK;"
+"SSO;"
+"TCP;"
+"TIFF;"
+"TTS;"
+"UI;"
+"URI;"
+"URL;"
+"VC;"
+"VOIP;"
+"VPN;"
+"VR;"
+"WAN;"
+"XML";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst?rev=322886&r1=322885&r2=322886&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst 
Thu Jan 18 12:51:24 2018
@@ -23,8 +23,8 @@ The check will only fix 'CamelCase' to '
 only provide warning messages since the property name could be complicated.
 Users will need to come up with a proper name by their own.
 
-This check also accepts special acronyms as prefix. Such prefix will suppress
-the check of Lower Camel Case according to the guide:
+This check also accepts special acronyms as prefixes or suffixes. Such 
prefixes or suffixes
+will suppress the Lower Camel Case check according to the guide:
 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB
 
 For a full list of well-known acronyms:
@@ -37,7 +37,7 @@ Options
 
 .. option:: Acronyms
 
-   Semicolon-separated list of acronyms that can be used as prefix
-   of property names.
+   Semicolon-separated list of acronyms that can be used as a prefix
+   or a suffix of property names.
 
-   Defaults to 
`ASCII;PDF;XML;HTML;URL;RTF;HTTP;TIFF;JPG;PNG;GIF;LZW;ROM;RGB;CMYK;MIDI;FTP`.
+   If unset, defaults to 
"ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML".

Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=322886&r1=322885&r2=322886&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Thu Jan 
18 12:51:24 2018
@@ -1,5 +1,7 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t
+@class NSData;
 @class NSString;
+@class UIViewContro

[PATCH] D42253: [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

2018-01-18 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322886: [clang-tidy objc-property-declaration] Expand list 
of ObjC acronyms (authored by benhamilton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42253

Files:
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
  clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m

Index: clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
@@ -23,8 +23,8 @@
 only provide warning messages since the property name could be complicated.
 Users will need to come up with a proper name by their own.
 
-This check also accepts special acronyms as prefix. Such prefix will suppress
-the check of Lower Camel Case according to the guide:
+This check also accepts special acronyms as prefixes or suffixes. Such prefixes or suffixes
+will suppress the Lower Camel Case check according to the guide:
 https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB
 
 For a full list of well-known acronyms:
@@ -37,7 +37,7 @@
 
 .. option:: Acronyms
 
-   Semicolon-separated list of acronyms that can be used as prefix
-   of property names.
+   Semicolon-separated list of acronyms that can be used as a prefix
+   or a suffix of property names.
 
-   Defaults to `ASCII;PDF;XML;HTML;URL;RTF;HTTP;TIFF;JPG;PNG;GIF;LZW;ROM;RGB;CMYK;MIDI;FTP`.
+   If unset, defaults to "ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML".
Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
===
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
@@ -1,13 +1,17 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t
+@class NSData;
 @class NSString;
+@class UIViewController;
 
 @interface Foo
 @property(assign, nonatomic) int NotCamelCase;
 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
 @property(strong, nonatomic) NSString *bundleID;
+@property(strong, nonatomic) NSData *RGBABytes;
+@property(strong, nonatomic) UIViewController *notificationsVC;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -24,25 +24,63 @@
 namespace {
 /// The acronyms are from
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
+///
+/// Keep this list sorted.
 constexpr char DefaultSpecialAcronyms[] =
+"ACL;"
+"API;"
+"ARGB;"
 "ASCII;"
-"PDF;"
-"XML;"
+"BGRA;"
+"CMYK;"
+"DNS;"
+"FPS;"
+"FTP;"
+"GIF;"
+"GPS;"
+"HD;"
+"HDR;"
 "HTML;"
-"URL;"
-"RTF;"
 "HTTP;"
-"TIFF;"
+"HTTPS;"
+"HUD;"
+"ID;"
 "JPG;"
-"PNG;"
-"GIF;"
+"JS;"
+"LAN;"
 "LZW;"
-"ROM;"
-"RGB;"
-"CMYK;"
+"MDNS;"
 "MIDI;"
-"FTP;"
-"ID";
+"OS;"
+"PDF;"
+"PIN;"
+"PNG;"
+"POI;"
+"PSTN;"
+"PTR;"
+"QA;"
+"QOS;"
+"RGB;"
+"RGBA;"
+"RGBX;"
+"ROM;"
+"RPC;"
+"RTF;"
+"RTL;"
+"SDK;"
+"SSO;"
+"TCP;"
+"TIFF;"
+"TTS;"
+"UI;"
+"URI;"
+"URL;"
+"VC;"
+"VOIP;"
+"VPN;"
+"VR;"
+"WAN;"
+"XML";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42253: [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

2018-01-18 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE322886: [clang-tidy objc-property-declaration] Expand list 
of ObjC acronyms (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42253?vs=130478&id=130480#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42253

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  docs/clang-tidy/checks/objc-property-declaration.rst
  test/clang-tidy/objc-property-declaration.m

Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -1,13 +1,17 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t
+@class NSData;
 @class NSString;
+@class UIViewController;
 
 @interface Foo
 @property(assign, nonatomic) int NotCamelCase;
 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
 @property(strong, nonatomic) NSString *bundleID;
+@property(strong, nonatomic) NSData *RGBABytes;
+@property(strong, nonatomic) UIViewController *notificationsVC;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -24,25 +24,63 @@
 namespace {
 /// The acronyms are from
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
+///
+/// Keep this list sorted.
 constexpr char DefaultSpecialAcronyms[] =
+"ACL;"
+"API;"
+"ARGB;"
 "ASCII;"
-"PDF;"
-"XML;"
+"BGRA;"
+"CMYK;"
+"DNS;"
+"FPS;"
+"FTP;"
+"GIF;"
+"GPS;"
+"HD;"
+"HDR;"
 "HTML;"
-"URL;"
-"RTF;"
 "HTTP;"
-"TIFF;"
+"HTTPS;"
+"HUD;"
+"ID;"
 "JPG;"
-"PNG;"
-"GIF;"
+"JS;"
+"LAN;"
 "LZW;"
-"ROM;"
-"RGB;"
-"CMYK;"
+"MDNS;"
 "MIDI;"
-"FTP;"
-"ID";
+"OS;"
+"PDF;"
+"PIN;"
+"PNG;"
+"POI;"
+"PSTN;"
+"PTR;"
+"QA;"
+"QOS;"
+"RGB;"
+"RGBA;"
+"RGBX;"
+"ROM;"
+"RPC;"
+"RTF;"
+"RTL;"
+"SDK;"
+"SSO;"
+"TCP;"
+"TIFF;"
+"TTS;"
+"UI;"
+"URI;"
+"URL;"
+"VC;"
+"VOIP;"
+"VPN;"
+"VR;"
+"WAN;"
+"XML";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
Index: docs/clang-tidy/checks/objc-property-declaration.rst
===
--- docs/clang-tidy/checks/objc-property-declaration.rst
+++ docs/clang-tidy/checks/objc-property-declaration.rst
@@ -23,8 +23,8 @@
 only provide warning messages since the property name could be complicated.
 Users will need to come up with a proper name by their own.
 
-This check also accepts special acronyms as prefix. Such prefix will suppress
-the check of Lower Camel Case according to the guide:
+This check also accepts special acronyms as prefixes or suffixes. Such prefixes or suffixes
+will suppress the Lower Camel Case check according to the guide:
 https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB
 
 For a full list of well-known acronyms:
@@ -37,7 +37,7 @@
 
 .. option:: Acronyms
 
-   Semicolon-separated list of acronyms that can be used as prefix
-   of property names.
+   Semicolon-separated list of acronyms that can be used as a prefix
+   or a suffix of property names.
 
-   Defaults to `ASCII;PDF;XML;HTML;URL;RTF;HTTP;TIFF;JPG;PNG;GIF;LZW;ROM;RGB;CMYK;MIDI;FTP`.
+   If unset, defaults to "ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML".
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41746: Make std::get_temporary_buffer respect overaligned types when possible

2018-01-18 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly marked an inline comment as done.
ckennelly added a comment.

I don't have commit access, so can this be committed to trunk?


Repository:
  rCXX libc++

https://reviews.llvm.org/D41746



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


[libclc] r322888 - half_sqrt: Cleanup implementation

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:38 2018
New Revision: 322888

URL: http://llvm.org/viewvc/llvm-project?rev=322888&view=rev
Log:
half_sqrt: Cleanup implementation

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Removed:
libclc/trunk/generic/lib/math/half_sqrt.inc
Modified:
libclc/trunk/generic/include/clc/math/half_sqrt.h
libclc/trunk/generic/lib/math/half_sqrt.cl

Modified: libclc/trunk/generic/include/clc/math/half_sqrt.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_sqrt.h?rev=322888&r1=322887&r2=322888&view=diff
==
--- libclc/trunk/generic/include/clc/math/half_sqrt.h (original)
+++ libclc/trunk/generic/include/clc/math/half_sqrt.h Thu Jan 18 13:11:38 2018
@@ -20,8 +20,6 @@
  * THE SOFTWARE.
  */
 
-#undef half_sqrt
-
 #define __CLC_BODY 
 #define __CLC_FUNCTION half_sqrt
 #define __FLOAT_ONLY

Modified: libclc/trunk/generic/lib/math/half_sqrt.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_sqrt.cl?rev=322888&r1=322887&r2=322888&view=diff
==
--- libclc/trunk/generic/lib/math/half_sqrt.cl (original)
+++ libclc/trunk/generic/lib/math/half_sqrt.cl Thu Jan 18 13:11:38 2018
@@ -1,28 +1,6 @@
-/*
- * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
 #include 
 
-#define __CLC_BODY 
+#define __CLC_FUNC sqrt
+#define __CLC_BODY 
 #define __FLOAT_ONLY
 #include 
-#undef __FLOAT_ONLY

Removed: libclc/trunk/generic/lib/math/half_sqrt.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_sqrt.inc?rev=322887&view=auto
==
--- libclc/trunk/generic/lib/math/half_sqrt.inc (original)
+++ libclc/trunk/generic/lib/math/half_sqrt.inc (removed)
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE half_sqrt(__CLC_GENTYPE val) {
-  return sqrt(val);
-}


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


[libclc] r322887 - half_rsqrt: Cleanup implementation

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:35 2018
New Revision: 322887

URL: http://llvm.org/viewvc/llvm-project?rev=322887&view=rev
Log:
half_rsqrt: Cleanup implementation

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/half_unary.inc
Removed:
libclc/trunk/generic/lib/math/half_rsqrt.inc
Modified:
libclc/trunk/generic/include/clc/math/half_rsqrt.h
libclc/trunk/generic/lib/math/half_rsqrt.cl

Modified: libclc/trunk/generic/include/clc/math/half_rsqrt.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_rsqrt.h?rev=322887&r1=322886&r2=322887&view=diff
==
--- libclc/trunk/generic/include/clc/math/half_rsqrt.h (original)
+++ libclc/trunk/generic/include/clc/math/half_rsqrt.h Thu Jan 18 13:11:35 2018
@@ -20,8 +20,6 @@
  * THE SOFTWARE.
  */
 
-#undef half_rsqrt
-
 #define __CLC_BODY 
 #define __CLC_FUNCTION half_rsqrt
 #define __FLOAT_ONLY

Modified: libclc/trunk/generic/lib/math/half_rsqrt.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_rsqrt.cl?rev=322887&r1=322886&r2=322887&view=diff
==
--- libclc/trunk/generic/lib/math/half_rsqrt.cl (original)
+++ libclc/trunk/generic/lib/math/half_rsqrt.cl Thu Jan 18 13:11:35 2018
@@ -1,28 +1,6 @@
-/*
- * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
 #include 
 
-#define __CLC_BODY 
+#define __CLC_FUNC rsqrt
+#define __CLC_BODY 
 #define __FLOAT_ONLY
 #include 
-#undef __FLOAT_ONLY

Removed: libclc/trunk/generic/lib/math/half_rsqrt.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_rsqrt.inc?rev=322886&view=auto
==
--- libclc/trunk/generic/lib/math/half_rsqrt.inc (original)
+++ libclc/trunk/generic/lib/math/half_rsqrt.inc (removed)
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE half_rsqrt(__CLC_GENTYPE val) {
-  return rsqrt(val);
-}

Added: libclc/trunk/generic/lib/math/half_unary.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_unary.inc?rev=322887&view=auto
==
--- libclc/trunk/generic/lib/math/half_unary.inc (added)
+++ libclc/trunk/generic/lib/math/half_unary.inc Thu Jan 18 13:11:35 2018
@@ -0,0 +1,9 @@
+#include 
+
+#define __CLC_HALF_FUNC(x) __CLC_CONCAT(half_, x)
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_HALF_FUNC(__CLC_FUNC)(__CLC_GENTYPE 
val) {
+  return __CLC_FUNC(val);
+}
+
+#undef

[libclc] r322889 - half_cos: Implement using cos

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:40 2018
New Revision: 322889

URL: http://llvm.org/viewvc/llvm-project?rev=322889&view=rev
Log:
half_cos: Implement using cos

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_cos.h
libclc/trunk/generic/lib/math/half_cos.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322889&r1=322888&r2=322889&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:40 2018
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_cos.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_cos.h?rev=322889&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_cos.h (added)
+++ libclc/trunk/generic/include/clc/math/half_cos.h Thu Jan 18 13:11:40 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_cos
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322889&r1=322888&r2=322889&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:40 2018
@@ -104,6 +104,7 @@ math/fmin.cl
 math/fmod.cl
 math/fract.cl
 math/frexp.cl
+math/half_cos.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_cos.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_cos.cl?rev=322889&view=auto
==
--- libclc/trunk/generic/lib/math/half_cos.cl (added)
+++ libclc/trunk/generic/lib/math/half_cos.cl Thu Jan 18 13:11:40 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC cos
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322891 - half_exp2: Implement using exp2

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:45 2018
New Revision: 322891

URL: http://llvm.org/viewvc/llvm-project?rev=322891&view=rev
Log:
half_exp2: Implement using exp2

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_exp2.h
libclc/trunk/generic/lib/math/half_exp2.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322891&r1=322890&r2=322891&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:45 2018
@@ -72,6 +72,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_exp2.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_exp2.h?rev=322891&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_exp2.h (added)
+++ libclc/trunk/generic/include/clc/math/half_exp2.h Thu Jan 18 13:11:45 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_exp2
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322891&r1=322890&r2=322891&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:45 2018
@@ -106,6 +106,7 @@ math/fract.cl
 math/frexp.cl
 math/half_cos.cl
 math/half_exp.cl
+math/half_exp2.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_exp2.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_exp2.cl?rev=322891&view=auto
==
--- libclc/trunk/generic/lib/math/half_exp2.cl (added)
+++ libclc/trunk/generic/lib/math/half_exp2.cl Thu Jan 18 13:11:45 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC exp2
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322892 - half_exp10: Implement using exp10

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:48 2018
New Revision: 322892

URL: http://llvm.org/viewvc/llvm-project?rev=322892&view=rev
Log:
half_exp10: Implement using exp10

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_exp10.h
libclc/trunk/generic/lib/math/half_exp10.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322892&r1=322891&r2=322892&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:48 2018
@@ -72,6 +72,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_exp10.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_exp10.h?rev=322892&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_exp10.h (added)
+++ libclc/trunk/generic/include/clc/math/half_exp10.h Thu Jan 18 13:11:48 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_exp10
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322892&r1=322891&r2=322892&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:48 2018
@@ -106,6 +106,7 @@ math/fract.cl
 math/frexp.cl
 math/half_cos.cl
 math/half_exp.cl
+math/half_exp10.cl
 math/half_exp2.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl

Added: libclc/trunk/generic/lib/math/half_exp10.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_exp10.cl?rev=322892&view=auto
==
--- libclc/trunk/generic/lib/math/half_exp10.cl (added)
+++ libclc/trunk/generic/lib/math/half_exp10.cl Thu Jan 18 13:11:48 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC exp10
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322890 - half_exp: Implement using exp

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:43 2018
New Revision: 322890

URL: http://llvm.org/viewvc/llvm-project?rev=322890&view=rev
Log:
half_exp: Implement using exp

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_exp.h
libclc/trunk/generic/lib/math/half_exp.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322890&r1=322889&r2=322890&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:43 2018
@@ -71,6 +71,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_exp.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_exp.h?rev=322890&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_exp.h (added)
+++ libclc/trunk/generic/include/clc/math/half_exp.h Thu Jan 18 13:11:43 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_exp
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322890&r1=322889&r2=322890&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:43 2018
@@ -105,6 +105,7 @@ math/fmod.cl
 math/fract.cl
 math/frexp.cl
 math/half_cos.cl
+math/half_exp.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_exp.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_exp.cl?rev=322890&view=auto
==
--- libclc/trunk/generic/lib/math/half_exp.cl (added)
+++ libclc/trunk/generic/lib/math/half_exp.cl Thu Jan 18 13:11:43 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC exp
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322895 - half_log2: Implement using log2

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:56 2018
New Revision: 322895

URL: http://llvm.org/viewvc/llvm-project?rev=322895&view=rev
Log:
half_log2: Implement using log2

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_log2.h
libclc/trunk/generic/lib/math/half_log2.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322895&r1=322894&r2=322895&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:56 2018
@@ -76,6 +76,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_log2.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_log2.h?rev=322895&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_log2.h (added)
+++ libclc/trunk/generic/include/clc/math/half_log2.h Thu Jan 18 13:11:56 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_log2
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322895&r1=322894&r2=322895&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:56 2018
@@ -110,6 +110,7 @@ math/half_exp10.cl
 math/half_exp2.cl
 math/half_log.cl
 math/half_log10.cl
+math/half_log2.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_log2.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_log2.cl?rev=322895&view=auto
==
--- libclc/trunk/generic/lib/math/half_log2.cl (added)
+++ libclc/trunk/generic/lib/math/half_log2.cl Thu Jan 18 13:11:56 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC log2
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322896 - half_recip: Implement using 1/x

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:58 2018
New Revision: 322896

URL: http://llvm.org/viewvc/llvm-project?rev=322896&view=rev
Log:
half_recip: Implement using 1/x

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_recip.h
libclc/trunk/generic/lib/math/half_recip.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322896&r1=322895&r2=322896&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:58 2018
@@ -77,6 +77,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_recip.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_recip.h?rev=322896&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_recip.h (added)
+++ libclc/trunk/generic/include/clc/math/half_recip.h Thu Jan 18 13:11:58 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_recip
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322896&r1=322895&r2=322896&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:58 2018
@@ -111,6 +111,7 @@ math/half_exp2.cl
 math/half_log.cl
 math/half_log10.cl
 math/half_log2.cl
+math/half_recip.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_recip.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_recip.cl?rev=322896&view=auto
==
--- libclc/trunk/generic/lib/math/half_recip.cl (added)
+++ libclc/trunk/generic/lib/math/half_recip.cl Thu Jan 18 13:11:58 2018
@@ -0,0 +1,10 @@
+#include 
+
+#define recip(x) (1.0f/x)
+
+#define __CLC_FUNC recip
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 
+
+#undef recip


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


[libclc] r322894 - half_log10: Implement using log10

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:53 2018
New Revision: 322894

URL: http://llvm.org/viewvc/llvm-project?rev=322894&view=rev
Log:
half_log10: Implement using log10

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_log10.h
libclc/trunk/generic/lib/math/half_log10.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322894&r1=322893&r2=322894&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:53 2018
@@ -75,6 +75,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_log10.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_log10.h?rev=322894&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_log10.h (added)
+++ libclc/trunk/generic/include/clc/math/half_log10.h Thu Jan 18 13:11:53 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_log10
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322894&r1=322893&r2=322894&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:53 2018
@@ -109,6 +109,7 @@ math/half_exp.cl
 math/half_exp10.cl
 math/half_exp2.cl
 math/half_log.cl
+math/half_log10.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_log10.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_log10.cl?rev=322894&view=auto
==
--- libclc/trunk/generic/lib/math/half_log10.cl (added)
+++ libclc/trunk/generic/lib/math/half_log10.cl Thu Jan 18 13:11:53 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC log10
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322893 - half_log: Implement using log

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:11:50 2018
New Revision: 322893

URL: http://llvm.org/viewvc/llvm-project?rev=322893&view=rev
Log:
half_log: Implement using log

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_log.h
libclc/trunk/generic/lib/math/half_log.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322893&r1=322892&r2=322893&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:11:50 2018
@@ -74,6 +74,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_log.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_log.h?rev=322893&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_log.h (added)
+++ libclc/trunk/generic/include/clc/math/half_log.h Thu Jan 18 13:11:50 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_log
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322893&r1=322892&r2=322893&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:11:50 2018
@@ -108,6 +108,7 @@ math/half_cos.cl
 math/half_exp.cl
 math/half_exp10.cl
 math/half_exp2.cl
+math/half_log.cl
 math/half_rsqrt.cl
 math/half_sqrt.cl
 math/hypot.cl

Added: libclc/trunk/generic/lib/math/half_log.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_log.cl?rev=322893&view=auto
==
--- libclc/trunk/generic/lib/math/half_log.cl (added)
+++ libclc/trunk/generic/lib/math/half_log.cl Thu Jan 18 13:11:50 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC log
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322898 - half_tan: Implement using tan

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:12:04 2018
New Revision: 322898

URL: http://llvm.org/viewvc/llvm-project?rev=322898&view=rev
Log:
half_tan: Implement using tan

v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_tan.h
libclc/trunk/generic/lib/math/half_tan.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322898&r1=322897&r2=322898&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:12:04 2018
@@ -81,6 +81,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_tan.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_tan.h?rev=322898&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_tan.h (added)
+++ libclc/trunk/generic/include/clc/math/half_tan.h Thu Jan 18 13:12:04 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_tan
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322898&r1=322897&r2=322898&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:12:04 2018
@@ -115,6 +115,7 @@ math/half_recip.cl
 math/half_rsqrt.cl
 math/half_sin.cl
 math/half_sqrt.cl
+math/half_tan.cl
 math/hypot.cl
 math/ilogb.cl
 math/clc_ldexp.cl

Added: libclc/trunk/generic/lib/math/half_tan.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_tan.cl?rev=322898&view=auto
==
--- libclc/trunk/generic/lib/math/half_tan.cl (added)
+++ libclc/trunk/generic/lib/math/half_tan.cl Thu Jan 18 13:12:04 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC tan
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[libclc] r322899 - half_divide: Implement using x/y

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:12:06 2018
New Revision: 322899

URL: http://llvm.org/viewvc/llvm-project?rev=322899&view=rev
Log:
half_divide: Implement using x/y

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_divide.h
libclc/trunk/generic/lib/math/half_binary.inc
libclc/trunk/generic/lib/math/half_divide.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322899&r1=322898&r2=322899&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:12:06 2018
@@ -71,6 +71,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_divide.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_divide.h?rev=322899&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_divide.h (added)
+++ libclc/trunk/generic/include/clc/math/half_divide.h Thu Jan 18 13:12:06 2018
@@ -0,0 +1,7 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_divide
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322899&r1=322898&r2=322899&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:12:06 2018
@@ -105,6 +105,7 @@ math/fmod.cl
 math/fract.cl
 math/frexp.cl
 math/half_cos.cl
+math/half_divide.cl
 math/half_exp.cl
 math/half_exp10.cl
 math/half_exp2.cl

Added: libclc/trunk/generic/lib/math/half_binary.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_binary.inc?rev=322899&view=auto
==
--- libclc/trunk/generic/lib/math/half_binary.inc (added)
+++ libclc/trunk/generic/lib/math/half_binary.inc Thu Jan 18 13:12:06 2018
@@ -0,0 +1,9 @@
+#include 
+
+#define __CLC_HALF_FUNC(x) __CLC_CONCAT(half_, x)
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_HALF_FUNC(__CLC_FUNC)(__CLC_GENTYPE 
x, __CLC_GENTYPE y) {
+  return __CLC_FUNC(x, y);
+}
+
+#undef __CLC_HALF_FUNC

Added: libclc/trunk/generic/lib/math/half_divide.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_divide.cl?rev=322899&view=auto
==
--- libclc/trunk/generic/lib/math/half_divide.cl (added)
+++ libclc/trunk/generic/lib/math/half_divide.cl Thu Jan 18 13:12:06 2018
@@ -0,0 +1,9 @@
+#include 
+
+#define divide(x,y) (x/y)
+
+#define __CLC_FUNC divide
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 
+#undef divide


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


[libclc] r322897 - half_sin: Implement using sin

2018-01-18 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jan 18 13:12:01 2018
New Revision: 322897

URL: http://llvm.org/viewvc/llvm-project?rev=322897&view=rev
Log:
half_sin: Implement using sin

Passes CTS on carrizo
v2: Use full precision implementation

Reviewer: Jeroen Ketema 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/half_sin.h
libclc/trunk/generic/lib/math/half_sin.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=322897&r1=322896&r2=322897&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Jan 18 13:12:01 2018
@@ -79,6 +79,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/half_sin.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/half_sin.h?rev=322897&view=auto
==
--- libclc/trunk/generic/include/clc/math/half_sin.h (added)
+++ libclc/trunk/generic/include/clc/math/half_sin.h Thu Jan 18 13:12:01 2018
@@ -0,0 +1,9 @@
+#define __CLC_BODY 
+#define __CLC_FUNCTION half_sin
+#define __FLOAT_ONLY
+
+#include 
+
+#undef __FLOAT_ONLY
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=322897&r1=322896&r2=322897&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jan 18 13:12:01 2018
@@ -113,6 +113,7 @@ math/half_log10.cl
 math/half_log2.cl
 math/half_recip.cl
 math/half_rsqrt.cl
+math/half_sin.cl
 math/half_sqrt.cl
 math/hypot.cl
 math/ilogb.cl

Added: libclc/trunk/generic/lib/math/half_sin.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/half_sin.cl?rev=322897&view=auto
==
--- libclc/trunk/generic/lib/math/half_sin.cl (added)
+++ libclc/trunk/generic/lib/math/half_sin.cl Thu Jan 18 13:12:01 2018
@@ -0,0 +1,6 @@
+#include 
+
+#define __CLC_FUNC sin
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 


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


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-01-18 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:597
+  // than or equal to the quarter of the maximum value of that type.
+  bool shouldAggressivelySimplifyRelationalComparison();
+

High level comment: can you list all [[ https://en.wikipedia.org/wiki/Rewriting 
| rewriting ]] rules you are applying in a formula explicitly in a comment?
From the phabricator discussion I see that you are applying
```
A + n >= B + m -> A - B >= n + m // A, B symbolic, n and m are integers
```

but from the code it seems that you are applying more canonicalization rules?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:317
+// with simpler symbols on every recursive call.
+static bool isOverflowClampedBy4(SymbolRef Sym, ProgramStateRef State) {
+  SValBuilder &SVB = State->getStateManager().getSValBuilder();

Can we have a better function name here? I can't think of one straight away, 
but "clamped" is not very self-descriptive. `isWithinConstantOverflowBounds`?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:326
+
+  llvm::APSInt Max = AT.getMaxValue() >> 2; // Divide by 4.
+  SVal IsCappedFromAbove =

Would just division produce the same result? Also probably it's better to make 
"4" a constant, at least with `#define`



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:330
+  nonloc::ConcreteInt(Max), SVB.getConditionType());
+  if (auto DV = IsCappedFromAbove.getAs()) {
+if (State->assume(*DV, false))

6 lines of branching is probably better expressed as

```
if (!isa(IsCappedFromAbove) || 
State->assume(*dyn_cast(IsCappedFromAbove), false))
   return false
```



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:337
+
+  llvm::APSInt Min = -Max;
+  SVal IsCappedFromBelow =

326-335 duplicates 338-346.
Perhaps we could have

```
static bool isCappedFrom(bool Above, llvm::APSInt bound, ...)
```

?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:352
+// Same for the concrete integers: see if I is within [min/4, max/4].
+static bool isOverflowClampedBy4(llvm::APSInt I) {
+  APSIntType AT(I);

Again, could we do better with a function name?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:357
+
+  llvm::APSInt Max = AT.getMaxValue() >> 2;
+  if (I > Max)

I think you want

```
return (I <= Max) && (I >= -Max)
```

instead of 358-365



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:376
+  // Fail to decompose: "reduce" the problem to the "$x + 0" case.
+  return std::make_tuple(Sym, BO_Add, BV.getValue(0, Sym->getType()));
+}

Is it beneficial to do this though? At the point where `decomposeSymbol` is 
called we are still checking whether the rearrangement could be performed, so 
maybe just returning a false flag would be better?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:403
+  if (LOp == BO_Sub)
+LInt = -LInt;
+  else

I think this is a separate rewrite, which is better performed in a separate 
function.
If you move it to `decomposeSymbol` or to a separate function, you would get a 
lot of simplifications:

1. This function would be performing only a single rewrite.
2. You would no longer need to take `Lop` and `Rop` as parameters
3. At that point, two separate cases would be clearly seen: `Op` is a 
comparison operator, or `Op` is an additive operator.
I would separate those two rewrites in separate functions, distinguishing 
between them at the callsite.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:429
+  if (BinaryOperator::isComparisonOp(Op)) {
+// Prefer comparing to a non-negative number.
+// FIXME: Maybe it'd be better to have consistency in

It seems that having a concrete positive RHS is a part of your rewrite rule. In 
that case, that should be documented in a high-level overview of the rewrite 
rules.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:432
+// "$x - $y" vs. "$y - $x" because those are solver's keys.
+if (LInt > RInt) {
+  ResultSym = SymMgr.getSymSymExpr(RSym, BO_Sub, LSym, SymTy);

I think this could be shortened and made more explicit by constructing the LHS 
and RHS first, and then reversing both and the comparison operator if RHS is 
negative.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:472
+  if (BinaryOperator::isComparisonOp(Op) &&
+  Opts.shouldAggressivelySimplifyRelationalComparison()) {
+if (ResultTy != SVB.getConditionType())

I am confused why the option `shouldAggressivelySimplifyRelationalComparison` 
is checked here. Do we rewrite cases where `Op` is addi

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130486.
MaskRay added a comment.

More


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   A c;
 ///
-///   template f() {};
+///   template void f() {};
 ///   void func() { f(); };
 /// \endcode
 /// classTemplateSpecializationDecl(hasTemplateArgument(
@@ -880,12 +880,12 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<&B::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
 /// \c B::next
 AST_MATCHER_P(TemplateArgument, refersToDeclaration,
@@ -899,8 +899,8 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<&B::next> a;
 /// \endcode
 /// templateSpecializationType(hasAnyTemplateArgument(
@@ -917,7 +917,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -932,7 +932,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -953,7 +953,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -1523,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -1789,7 +1789,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// switchStmt()
-///   matches 'switch(a)'.
+///   matches 'switch(a) {'.
 extern const internal::VariadicDynCastAllOfMatcher switchStmt;
 
 /// \brief Matches case and default statements inside switch statements.
@@ -1799,7 +1799,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// switchCase()
-///   matches 'case 42: break;' and 'default: break;'.
+///   matches 'case 42:' and 'default:'.
 extern const internal::VariadicDynCastAllOfMatcher switchCase;
 
 /// \brief Matches case statements inside switch statements.
@@ -1809,7 +1809,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// caseStmt()
-///   matches 'case 42: break;'.
+///   matches 'case 42:'.
 extern const internal::VariadicDynCastAllOfMatcher caseStmt;
 
 /// \brief Matches default statements inside switch statements.
@@ -1819,13 +1819,13 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// defaultStmt()
-///   matches 'default: break;'.
+///   matches 'default:'.
 extern const internal::VariadicDynCastAllOfMatcher
 defaultStmt;
 
 /// \brief Matches compound statements.
 ///
-/// Example matches '{}' and '{{}}'in 'for (;;) {{}}'
+/// Example matches '{}' and '{{}}' in 'for (;;) {{}}'
 /// \code
 ///   for (;;) {{}}
 /// \endcode
@@ -1838,7 +1838,7 @@
 ///   try {} catch(int i) {}
 /// \endcode
 /// cxxCatchStmt()
-///   matches 'catch(int i)'
+///   matches 'catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher
 cxxCatchStmt;
 
@@ -1848,7 +1848,7 @@
 ///   try {} catch(int i) {}
 /// \endcode
 /// cxxTryStmt()
-///   matches 'try {}'
+///   matches 'try {} catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher cxxTryStmt;
 
 /// \brief Matches throw expressions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >