[PATCH] D52610: [Esan] Port cache frag to FreeBSD

2018-10-08 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

ping.


Repository:
  rC Clang

https://reviews.llvm.org/D52610



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


[PATCH] D52957: [analyzer] Teach CallEvent about C++17 aligned new.

2018-10-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!

I agree that it would make sense to either not have arguments that are not 
represented in the AST  or create expressions for those implicit arguments.


Repository:
  rC Clang

https://reviews.llvm.org/D52957



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


[PATCH] D52937: [clangd] Add clangd.serverInfo command to inspect server state.

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

How will this command be triggered? What's the advantage comparing to `vlog`ing?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52937



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


[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:501
+  auto FieldAccessM = 
memberExpr(hasDeclaration(equalsNode(FD))).bind("access");
+  // TODO: Should we only regard asserts as guards, or maybe something else 
too?
+  auto GuardM = 
callExpr(callee(functionDecl(hasName("assert".bind("guard");

I would consider any access that is guarded by if, ternary operator, switch as 
a guard.

For example I would consider field guarded in the following method:
```
int *method() {
  return cond ? field : nullptr;
}
```

But unguarded in this:
```
int *method() {
  return field ? field2 : nullptr;
}
```

Also, knowing that a variable is guarded or not might be a useful heuristic for 
other checks too. So if you do plan to cover all those cases. I would recommend 
to implement it outside of this check so other checks might also leverage this 
functionality.


https://reviews.llvm.org/D51866



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


[PATCH] D52976: [clangd] Update the out-of-date yaml-symbol-file flag in clangd.

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

The flag is stale due to the recent changes of clangd indexer, this
patch rename it to "index-file".


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52976

Files:
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -158,11 +158,10 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will 
"
-"use the static index for global code completion.\n"
+"Index file to build the static index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +287,12 @@
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new 
SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -158,11 +158,10 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will "
-"use the static index for global code completion.\n"
+"Index file to build the static index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +287,12 @@
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:519
+
+if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+  return true;

I am not sure if this is a reliable way to check if the access is before the 
guard.

Consider:
```
switch(x): {
   case 2: guard; access; break;
   case 1: access break;
}
```

Here, we have no particular ordering between the access in case 1 and the guard 
in case 2 at runtime. But relying on the source locations we might come to the 
false conclusion that there is. Loops, gotos can cause similar problems.
I do understand that this might not be too easy to solve without traversing the 
cfg and we might not want to do that but I think we should at least add a 
test/todo. 


https://reviews.llvm.org/D51866



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


[PATCH] D52445: [Index] Use locations to uniquify function-scope BindingDecl USR

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

The change looks reasonable to me, so lg. I'd wait a bit to see whether other 
reviewers have comments.




Comment at: lib/Index/USRGeneration.cpp:339
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (D->getParentFunctionOrMethod() && GenLoc(D, /*IncludeOffset=*/true))
+return;

use `isLocal(D)` instead.


Repository:
  rC Clang

https://reviews.llvm.org/D52445



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


[PATCH] D52976: [clangd] Update the out-of-date yaml-symbol-file flag in clangd.

2018-10-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Hmm, I wonder if we should remove "experimental" text and the hidden bit. Or 
wait to see if we want to move to automatic index entirely?
May want to mention "must have been created by a compatible clangd-indexer".


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52976



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


[PATCH] D52598: [OpenCL] Fixed address space cast in C style cast of C++ parsing

2018-10-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 168633.
Anastasia added a comment.

- Changed to pass `QualType` by value.
- Improved description of new method.
- Added a comment about the OpenCL rules.


https://reviews.llvm.org/D52598

Files:
  lib/Sema/SemaCast.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -9,46 +9,47 @@
   __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}}
 
   int *ip;
-// FIXME: Temporarily disable part of the test that doesn't work for C++ yet.
-#if !__OPENCL_CPP_VERSION__
-#if __OPENCL_C_VERSION__ < 200
+#if ((!__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ < 200))
   ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}}
   ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}}
   ip = &ci; // expected-error {{assigning '__constant int *' to 'int *' changes address space of pointer}}
 #else
   ip = gip;
   ip = &li;
-  ip = &ci; // expected-error {{assigning '__constant int *' to '__generic int *' changes address space of pointer}}
+  ip = &ci;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{assigning '__constant int *' to '__generic int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{assigning to '__generic int *' from incompatible type '__constant int *'}}
+#endif
 #endif
 }
 
-void explicit_cast(global int* g, local int* l, constant int* c, private int* p, const constant int *cc)
-{
-  g = (global int*) l;// expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
-  g = (global int*) c;// expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
-  g = (global int*) cc;   // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
-  g = (global int*) p;// expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
+void explicit_cast(__global int *g, __local int *l, __constant int *c, __private int *p, const __constant int *cc) {
+  g = (__global int *)l;  // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
+  g = (__global int *)c;  // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
+  g = (__global int *)cc; // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
+  g = (__global int *)p;  // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
 
-  l = (local int*) g; // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
-  l = (local int*) c; // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
-  l = (local int*) cc;// expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
-  l = (local int*) p; // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)g;  // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)c;  // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)cc; // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
+  l = (__local int *)p;  // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
 
-  c = (constant int*) g;  // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}}
-  c = (constant int*) l;  // expected-error {{casting '__local int *' to type '__constant int *' changes address space of pointer}}
-  c = (constant int*) p;  // expected-error {{casting 'int *' to type '__constant int *' changes address space of pointer}}
+  c = (__constant int *)g; // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}}
+  c = (__constant int *)l; // expected-error {{casting '__local int *' to type '__constant int *' changes address space of pointer}}
+  c = (__constant int *)p; // expected-error {{casting 'int *' to type '__constant int *' changes address space of pointer}}
 
-  p = (private int*) g;   // expected-error {{casting '__global int *' to type 'int *' changes address space of pointer}}
-  p = (private int*) l;   // expected-error {{casting '__local int *' to type 'int *' changes address space of pointer}}
-  p = (private int

[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added reviewers: ioeric, sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.

Currently we don't cleanup dynamic index if a file is closed in clangd,
which may result in large memory consumption in clangd (if we open many files
and closes them).

This patch is the first step.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52979

Files:
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  unittests/clangd/FileIndexTests.cpp


Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -21,6 +21,7 @@
 #include "gtest/gtest.h"
 
 using testing::_;
+using testing::IsEmpty;
 using testing::AllOf;
 using testing::ElementsAre;
 using testing::Pair;
@@ -164,6 +165,17 @@
   EXPECT_THAT(match(M, Req), UnorderedElementsAre("ns::f", "ns::X"));
 }
 
+TEST(FileIndexTest, RemoveFile) {
+  FileIndex M;
+  update(M, "f1", "class Foo {};");
+
+  FuzzyFindRequest Req;
+  EXPECT_THAT(match(M, Req), UnorderedElementsAre("Foo"));
+
+  M.removeFile("f1.cpp");
+  EXPECT_THAT(match(M, Req), IsEmpty());
+}
+
 TEST(FileIndexTest, NoLocal) {
   FileIndex M;
   update(M, "f1", "namespace ns { void f() { int local = 0; } class X {}; }");
Index: clangd/index/FileIndex.h
===
--- clangd/index/FileIndex.h
+++ clangd/index/FileIndex.h
@@ -59,7 +59,6 @@
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
-/// FIXME: Expose an interface to remove files that are closed.
 class FileIndex : public MergedIndex {
 public:
   /// If URISchemes is empty, the default schemes in SymbolCollector will be
@@ -75,6 +74,9 @@
   /// `indexMainDecls`.
   void updateMain(PathRef Path, ParsedAST &AST);
 
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+
 private:
   std::vector URISchemes;
 
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -174,5 +174,12 @@
   MainFileIndex.reset(MainFileSymbols.buildMemIndex());
 }
 
+void FileIndex::removeFile(PathRef Path) {
+  PreambleSymbols.update(Path, nullptr, nullptr);
+  PreambleIndex.reset(PreambleSymbols.buildMemIndex());
+  MainFileSymbols.update(Path, nullptr, nullptr);
+  MainFileIndex.reset(MainFileSymbols.buildMemIndex());
+}
+
 } // namespace clangd
 } // namespace clang


Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -21,6 +21,7 @@
 #include "gtest/gtest.h"
 
 using testing::_;
+using testing::IsEmpty;
 using testing::AllOf;
 using testing::ElementsAre;
 using testing::Pair;
@@ -164,6 +165,17 @@
   EXPECT_THAT(match(M, Req), UnorderedElementsAre("ns::f", "ns::X"));
 }
 
+TEST(FileIndexTest, RemoveFile) {
+  FileIndex M;
+  update(M, "f1", "class Foo {};");
+
+  FuzzyFindRequest Req;
+  EXPECT_THAT(match(M, Req), UnorderedElementsAre("Foo"));
+
+  M.removeFile("f1.cpp");
+  EXPECT_THAT(match(M, Req), IsEmpty());
+}
+
 TEST(FileIndexTest, NoLocal) {
   FileIndex M;
   update(M, "f1", "namespace ns { void f() { int local = 0; } class X {}; }");
Index: clangd/index/FileIndex.h
===
--- clangd/index/FileIndex.h
+++ clangd/index/FileIndex.h
@@ -59,7 +59,6 @@
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
-/// FIXME: Expose an interface to remove files that are closed.
 class FileIndex : public MergedIndex {
 public:
   /// If URISchemes is empty, the default schemes in SymbolCollector will be
@@ -75,6 +74,9 @@
   /// `indexMainDecls`.
   void updateMain(PathRef Path, ParsedAST &AST);
 
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+
 private:
   std::vector URISchemes;
 
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -174,5 +174,12 @@
   MainFileIndex.reset(MainFileSymbols.buildMemIndex());
 }
 
+void FileIndex::removeFile(PathRef Path) {
+  PreambleSymbols.update(Path, nullptr, nullptr);
+  PreambleIndex.reset(PreambleSymbols.buildMemIndex());
+  MainFileSymbols.update(Path, nullptr, nullptr);
+  MainFileIndex.reset(MainFileSymbols.buildMemIndex());
+}
+
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 168638.
hokein added a comment.

clang-format.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52979

Files:
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  unittests/clangd/FileIndexTests.cpp


Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -23,6 +23,7 @@
 using testing::_;
 using testing::AllOf;
 using testing::ElementsAre;
+using testing::IsEmpty;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -164,6 +165,17 @@
   EXPECT_THAT(match(M, Req), UnorderedElementsAre("ns::f", "ns::X"));
 }
 
+TEST(FileIndexTest, RemoveFile) {
+  FileIndex M;
+  update(M, "f1", "class Foo {};");
+
+  FuzzyFindRequest Req;
+  EXPECT_THAT(match(M, Req), UnorderedElementsAre("Foo"));
+
+  M.removeFile("f1.cpp");
+  EXPECT_THAT(match(M, Req), IsEmpty());
+}
+
 TEST(FileIndexTest, NoLocal) {
   FileIndex M;
   update(M, "f1", "namespace ns { void f() { int local = 0; } class X {}; }");
Index: clangd/index/FileIndex.h
===
--- clangd/index/FileIndex.h
+++ clangd/index/FileIndex.h
@@ -59,7 +59,6 @@
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
-/// FIXME: Expose an interface to remove files that are closed.
 class FileIndex : public MergedIndex {
 public:
   /// If URISchemes is empty, the default schemes in SymbolCollector will be
@@ -75,6 +74,9 @@
   /// `indexMainDecls`.
   void updateMain(PathRef Path, ParsedAST &AST);
 
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+
 private:
   std::vector URISchemes;
 
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -174,5 +174,12 @@
   MainFileIndex.reset(MainFileSymbols.buildMemIndex());
 }
 
+void FileIndex::removeFile(PathRef Path) {
+  PreambleSymbols.update(Path, nullptr, nullptr);
+  PreambleIndex.reset(PreambleSymbols.buildMemIndex());
+  MainFileSymbols.update(Path, nullptr, nullptr);
+  MainFileIndex.reset(MainFileSymbols.buildMemIndex());
+}
+
 } // namespace clangd
 } // namespace clang


Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -23,6 +23,7 @@
 using testing::_;
 using testing::AllOf;
 using testing::ElementsAre;
+using testing::IsEmpty;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -164,6 +165,17 @@
   EXPECT_THAT(match(M, Req), UnorderedElementsAre("ns::f", "ns::X"));
 }
 
+TEST(FileIndexTest, RemoveFile) {
+  FileIndex M;
+  update(M, "f1", "class Foo {};");
+
+  FuzzyFindRequest Req;
+  EXPECT_THAT(match(M, Req), UnorderedElementsAre("Foo"));
+
+  M.removeFile("f1.cpp");
+  EXPECT_THAT(match(M, Req), IsEmpty());
+}
+
 TEST(FileIndexTest, NoLocal) {
   FileIndex M;
   update(M, "f1", "namespace ns { void f() { int local = 0; } class X {}; }");
Index: clangd/index/FileIndex.h
===
--- clangd/index/FileIndex.h
+++ clangd/index/FileIndex.h
@@ -59,7 +59,6 @@
 };
 
 /// This manages symbols from files and an in-memory index on all symbols.
-/// FIXME: Expose an interface to remove files that are closed.
 class FileIndex : public MergedIndex {
 public:
   /// If URISchemes is empty, the default schemes in SymbolCollector will be
@@ -75,6 +74,9 @@
   /// `indexMainDecls`.
   void updateMain(PathRef Path, ParsedAST &AST);
 
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+
 private:
   std::vector URISchemes;
 
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -174,5 +174,12 @@
   MainFileIndex.reset(MainFileSymbols.buildMemIndex());
 }
 
+void FileIndex::removeFile(PathRef Path) {
+  PreambleSymbols.update(Path, nullptr, nullptr);
+  PreambleIndex.reset(PreambleSymbols.buildMemIndex());
+  MainFileSymbols.update(Path, nullptr, nullptr);
+  MainFileIndex.reset(MainFileSymbols.buildMemIndex());
+}
+
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52976: [clangd] Update the out-of-date yaml-symbol-file flag in clangd.

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D52976#1257614, @sammccall wrote:

> Hmm, I wonder if we should remove "experimental" text and the hidden bit. Or 
> wait to see if we want to move to automatic index entirely?


Our plan seems unclear at the moment, so I would suggest not doing it now until 
we sort them out.

> May want to mention "must have been created by a compatible clangd-indexer".

Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52976



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


[PATCH] D52976: [clangd] Update the out-of-date yaml-symbol-file flag in clangd.

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 168639.
hokein added a comment.

address comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52976

Files:
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -158,11 +158,11 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will 
"
-"use the static index for global code completion.\n"
+"Index file to build the static index. The file must have been created 
"
+"by a compatible clangd-index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +288,12 @@
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new 
SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -158,11 +158,11 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will "
-"use the static index for global code completion.\n"
+"Index file to build the static index. The file must have been created "
+"by a compatible clangd-index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +288,12 @@
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r343963 - [clangd] Update the out-of-date yaml-symbol-file flag in clangd.

2018-10-08 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Oct  8 03:44:54 2018
New Revision: 343963

URL: http://llvm.org/viewvc/llvm-project?rev=343963&view=rev
Log:
[clangd] Update the out-of-date yaml-symbol-file flag in clangd.

Summary:
The flag is stale due to the recent changes of clangd indexer, this
patch renames the flag to "index-file".

Reviewers: sammccall

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

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

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

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=343963&r1=343962&r2=343963&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Mon Oct  8 03:44:54 2018
@@ -158,11 +158,11 @@ static llvm::cl::opt HeaderInserti
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will 
"
-"use the static index for global code completion.\n"
+"Index file to build the static index. The file must have been created 
"
+"by a compatible clangd-index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +288,12 @@ int main(int argc, char *argv[]) {
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new 
SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)


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


[PATCH] D52976: [clangd] Update the out-of-date yaml-symbol-file flag in clangd.

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343963: [clangd] Update the out-of-date yaml-symbol-file 
flag in clangd. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52976

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


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -158,11 +158,11 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will 
"
-"use the static index for global code completion.\n"
+"Index file to build the static index. The file must have been created 
"
+"by a compatible clangd-index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +288,12 @@
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new 
SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -158,11 +158,11 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
-static llvm::cl::opt YamlSymbolFile(
-"yaml-symbol-file",
+static llvm::cl::opt IndexFile(
+"index-file",
 llvm::cl::desc(
-"YAML-format global symbol file to build the static index. Clangd will "
-"use the static index for global code completion.\n"
+"Index file to build the static index. The file must have been created "
+"by a compatible clangd-index.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
@@ -288,12 +288,12 @@
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
-  if (EnableIndex && !YamlSymbolFile.empty()) {
+  if (EnableIndex && !IndexFile.empty()) {
 // Load the index asynchronously. Meanwhile SwapIndex returns no results.
 SwapIndex *Placeholder;
 StaticIdx.reset(Placeholder = new SwapIndex(llvm::make_unique()));
 AsyncIndexLoad = runAsync([Placeholder, &Opts] {
-  if (auto Idx = loadIndex(YamlSymbolFile, Opts.URISchemes, UseDex))
+  if (auto Idx = loadIndex(IndexFile, Opts.URISchemes, UseDex))
 Placeholder->reset(std::move(Idx));
 });
 if (RunSynchronously)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-10-08 Thread Filipe Cabecinhas via cfe-commits
Sorry about that. I’m away today but I don’t think you’ve answered my
questions about “why not support standalone UBSan in tests”. Sorry if I
missed the answers if you did. Will review the latest tomorrow.

Thank you,
 Filipe

On Mon, 8 Oct 2018 at 07:48, Roman Lebedev via Phabricator <
revi...@reviews.llvm.org> wrote:

> lebedev.ri added a comment.
>
> Ping! It seemed we were so close here :)
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D50901
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-10-08 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a subscriber: aizatsky.
filcab added a comment.

Sorry about that. I’m away today but I don’t think you’ve answered my
questions about “why not support standalone UBSan in tests”. Sorry if I
missed the answers if you did. Will review the latest tomorrow.

Thank you,
Filipe


Repository:
  rC Clang

https://reviews.llvm.org/D50901



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


[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

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

In https://reviews.llvm.org/D50901#1257651, @filcab wrote:

> Sorry about that. I’m away today but I don’t think you’ve answered my
>  questions about “why not support standalone UBSan in tests”. Sorry if I
>  missed the answers if you did.


I did answer that question twice now :)

https://reviews.llvm.org/D50902#inline-463926

>> Can't we simply not test on the SUMMARY line (test on the error line) and 
>> allow standalone too? I don't see what we gain by restricting the test.
> 
> That summary line is the very essence of what we are checking in this test.
>  We can only do that in non-standalone builds, because standalone builds only 
> print generic undefined-behavior error name, while ubsan is coupled with some 
> other sanitizer, an actual error name is printed.
>  We have discussed this with you in 
> https://reviews.llvm.org/D48959#inline-429528



> Will review the latest tomorrow.
> 
> Thank you,
> 
>   Filipe




Repository:
  rC Clang

https://reviews.llvm.org/D50901



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


[PATCH] D52598: [OpenCL] Fixed address space cast in C style cast of C++ parsing

2018-10-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2288
+  SrcType->isPointerType()) {
+const PointerType *DestPtr = DestType->getAs();
+if (!DestPtr->isAddressSpaceOverlapping(*SrcType->getAs())) {

rjmccall wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > rjmccall wrote:
> > > > Please test the result of `getAs` instead of separately testing 
> > > > `isPointerType`.
> > > > 
> > > > Why is this check OpenCL-specific?  Address spaces are a general 
> > > > language feature.
> > > I think mainly because I am factoring out from the existing OpenCL check. 
> > > But it probably makes sense that the semantics of this is not different 
> > > in other languages. I will update it! Thanks!
> > After playing with this for a bit longer I discovered that I have to keep 
> > the OpenCL check unfortunately.
> > 
> > I found this old commit (`d4c5f84`/`r129583`) that says:
> >   C-style casts can add/remove/change address spaces through the 
> > reinterpret_cast mechanism.
> > That's not the same as in OpenCL because it seems for C++ you can cast any 
> > AS to any other AS. Therefore, no checks are needed at all. I am not sure 
> > if we can come up with a common function for the moment.
> > 
> > The following  tests are checking this:
> >CodeGenCXX/address-space-cast.cpp
> >SemaCXX/address-space-conversion.cpp
> > 
> > Do you think it would make sense to rename this method with 
> > OpenCL-something or keep in case may be CUDA or some other languages might 
> > need similar functionality...
> > 
> I think you can leave it alone for now, but please add a comment explaining 
> the reasoning as best you see it, and feel free to express uncertainty about 
> the right rule.
> 
> Don't take `QualType` by `const &`, by the way.  It's a cheap-to-copy value 
> type and should always be passed by value.
My general understand of the address spaces in C and C++ that they are intended 
to be more general than in OpenCL (i.e. they don't reflect any particular 
memory system). Perhaps, it makes sense that we have more restrictions in 
OpenCL or other similar languages.


https://reviews.llvm.org/D52598



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


[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.

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



Comment at: clangd/index/FileIndex.h:78
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+

should we use this somewhere? E.g. when file is closed in ClangdServer?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52979



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


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

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

The change looks good in principle. I think it would make sense to migrate one 
test already, to use the new capability and check if everything works as 
expected. The current tests still run fine?




Comment at: test/clang-tidy/check_clang_tidy.py:112
+sys.exit('%s, %s or %s not found in the input' %
+ (check_fixes_prefixes, check_messages_prefixes, check_notes_prefixes))
 

i think the whitespace in this line should be aligned with with the line above


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52971



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


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

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

Looks good with a comment.




Comment at: test/clang-tidy/check_clang_tidy.py:52
   parser.add_argument('temp_file_name')
+  parser.add_argument('-check-suffix', default=[], type=csv, 
help="comma-separated list of FileCheck suffixes")
 

Maybe `-check-suffixes` to make it more obvious that multiple values are 
supported?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52971



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


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

2018-10-08 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In https://reviews.llvm.org/D52971#1257702, @JonasToth wrote:

> The change looks good in principle. I think it would make sense to migrate 
> one test already, to use the new capability and check if everything works as 
> expected. The current tests still run fine?


Yes, all the existing tests pass successfully.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52971



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


[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.

2018-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/FileIndex.h:78
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+

ioeric wrote:
> should we use this somewhere? E.g. when file is closed in ClangdServer?
Yes, the usage of this method is not included in this patch. 

We probably use this function in `TUScheduler::remove`, the code path will be 
like

`TUScheduler::remove => ParsingCallback::onASTRemove => FileIndex::removeFile`.

We need to add a similar interface to `ParsingCallback`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52979



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


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

2018-10-08 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In https://reviews.llvm.org/D52971#1257705, @alexfh wrote:

> Looks good with a comment.


It can break the compatibility. May be it worth to add an alias 
"-check-suffixes" for this option?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52971



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


[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-08 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 168646.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D52727

Files:
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/ForRangeCopyCheck.h
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tidy/utils/Matchers.h
  docs/clang-tidy/checks/performance-for-range-copy.rst
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  test/clang-tidy/performance-for-range-copy-allowed-types.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
  test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp

Index: test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp
@@ -0,0 +1,66 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -config="{CheckOptions: [{key: performance-unnecessary-value-param.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" --
+
+struct SmartPointer {
+  ~SmartPointer();
+};
+
+struct smart_pointer {
+  ~smart_pointer();
+};
+
+struct SmartPtr {
+  ~SmartPtr();
+};
+
+struct smart_ptr {
+  ~smart_ptr();
+};
+
+struct SmartReference {
+  ~SmartReference();
+};
+
+struct smart_reference {
+  ~smart_reference();
+};
+
+struct SmartRef {
+  ~SmartRef();
+};
+
+struct smart_ref {
+  ~smart_ref();
+};
+
+struct OtherType {
+  ~OtherType();
+};
+
+void negativeSmartPointer(SmartPointer P) {
+}
+
+void negative_smart_pointer(smart_pointer p) {
+}
+
+void negativeSmartPtr(SmartPtr P) {
+}
+
+void negative_smart_ptr(smart_ptr p) {
+}
+
+void negativeSmartReference(SmartReference R) {
+}
+
+void negative_smart_reference(smart_reference r) {
+}
+
+void negativeSmartRef(SmartRef R) {
+}
+
+void negative_smart_ref(smart_ref r) {
+}
+
+void positiveOtherType(OtherType O) {
+  // CHECK-MESSAGES: [[@LINE-1]]:34: warning: the parameter 'O' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveOtherType(const OtherType& O) {
+}
Index: test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t -- -config="{CheckOptions: [{key: performance-unnecessary-copy-initialization.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" --
+
+struct SmartPointer {
+  ~SmartPointer();
+};
+
+struct smart_pointer {
+  ~smart_pointer();
+};
+
+struct SmartPtr {
+  ~SmartPtr();
+};
+
+struct smart_ptr {
+  ~smart_ptr();
+};
+
+struct SmartReference {
+  ~SmartReference();
+};
+
+struct smart_reference {
+  ~smart_reference();
+};
+
+struct SmartRef {
+  ~SmartRef();
+};
+
+struct smart_ref {
+  ~smart_ref();
+};
+
+struct OtherType {
+  ~OtherType();
+};
+
+const SmartPointer &getSmartPointer();
+const smart_pointer &get_smart_pointer();
+const SmartPtr &getSmartPtr();
+const smart_ptr &get_smart_ptr();
+const SmartReference &getSmartReference();
+const smart_reference &get_smart_reference();
+const SmartRef &getSmartRef();
+const smart_ref &get_smart_ref();
+const OtherType &getOtherType();
+
+void negativeSmartPointer() {
+  const auto P = getSmartPointer();
+}
+
+void negative_smart_pointer() {
+  const auto p = get_smart_pointer();
+}
+
+void negativeSmartPtr() {
+  const auto P = getSmartPtr();
+}
+
+void negative_smart_ptr() {
+  const auto p = get_smart_ptr();
+}
+
+void negativeSmartReference() {
+  const auto R = getSmartReference();
+}
+
+void negative_smart_reference() {
+  const auto r = get_smart_reference();
+}
+
+void negativeSmartRef() {
+  const auto R = getSmartRef();
+}
+
+void negative_smart_ref() {
+  const auto r = get_smart_ref();
+}
+
+void positiveOtherType() {
+  const auto O = getOtherType();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'O' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& O = getOtherType();
+}
Index: test/clang-tidy/performance-for-range-copy-allowed-types.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-for-range-copy-allowed-types.cpp
@@ -0,0 +1,112 @@
+// RUN: %check_clang_tidy %s performance-for-range-copy %t -- -config="{CheckOptions: [{key: performance-fo

[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

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

That's it!
Hopefully last portion of nits.




Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:65-66
has(varDecl(hasLocalStorage(),
-   hasType(matchers::isExpensiveToCopy()),
+   hasType(hasCanonicalType(
+   allOf(matchers::isExpensiveToCopy(),
+ unless(hasDeclaration(namedDecl(

Does it matter whether we are calling `matchers::isExpensiveToCopy()` on the 
type, or on the canonical type?



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:83-86
+  unless(anyOf(referenceType(),
+   hasDeclaration(namedDecl(
+   matchers::matchesAnyListedName(AllowedTypes),
+  matchers::isExpensiveToCopy(,

This is inconsistent with the rest of the matchers here.
I think you want to check `isExpensiveToCopy()` first, because that should be 
less expensive than regex.



Comment at: clang-tidy/utils/Matchers.h:51
 
+AST_MATCHER_P(NamedDecl, matchesAnyListedName, std::vector,
+  NameList) {

Please double-check that this does not result in a copy, and `std::vector` is 
passed as a reference.



Comment at: clang-tidy/utils/Matchers.h:53
+  NameList) {
+  for (const std::string &Name: NameList) {
+if (llvm::Regex(Name).match(Node.getName()))

```
for (const std::string &Name : NameList) {
```



Comment at: clang-tidy/utils/Matchers.h:53
+  NameList) {
+  for (const std::string &Name: NameList) {
+if (llvm::Regex(Name).match(Node.getName()))

lebedev.ri wrote:
> ```
> for (const std::string &Name : NameList) {
> ```
Do we want to be explicit about early-return here?


https://reviews.llvm.org/D52727



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


[PATCH] D52983: [analyzer] Support Reinitializes attribute in MisusedMovedObject check

2018-10-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: NoQ, szepet, george.karpenkov.
xazax.hun added a project: clang.
Herald added subscribers: Szelethus, mikhail.ramalho, a.sidorin, dkrupp, 
rnkovacs, baloghadamsoftware, whisperity.

Support the same attribute that the tidy version of this check already supports.
Also do some minor cleanups.


Repository:
  rC Clang

https://reviews.llvm.org/D52983

Files:
  lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
  test/Analysis/MisusedMovedObject.cpp


Index: test/Analysis/MisusedMovedObject.cpp
===
--- test/Analysis/MisusedMovedObject.cpp
+++ test/Analysis/MisusedMovedObject.cpp
@@ -638,7 +638,10 @@
   }
 }
 
-class C : public A {};
+struct C : public A {
+  [[clang::reinitializes]] void reinit();
+};
+
 void subRegionMoveTest() {
   {
 A a;
@@ -672,6 +675,13 @@
   C c2 = c; // no-warning
 }
 
+void resetSuperClass2() {
+  C c;
+  C c1 = std::move(c);
+  c.reinit();
+  C c2 = c; // no-warning
+}
+
 void reportSuperClass() {
   C c;
   C c1 = std::move(c); // expected-note {{'c' became 'moved-from' here}}
Index: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
@@ -314,17 +314,18 @@
   return true;
   }
   // Function call `empty` can be skipped.
-  if (MethodDec && MethodDec->getDeclName().isIdentifier() &&
+  return (MethodDec && MethodDec->getDeclName().isIdentifier() &&
   (MethodDec->getName().lower() == "empty" ||
-   MethodDec->getName().lower() == "isempty"))
-return true;
-
-  return false;
+   MethodDec->getName().lower() == "isempty"));
 }
 
 bool MisusedMovedObjectChecker::isStateResetMethod(
 const CXXMethodDecl *MethodDec) const {
-  if (MethodDec && MethodDec->getDeclName().isIdentifier()) {
+  if (!MethodDec)
+  return false;
+  if (MethodDec->hasAttr())
+  return true;
+  if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
 if (MethodName == "reset" || MethodName == "clear" ||
 MethodName == "destroy")
@@ -429,8 +430,7 @@
 
   // We want to investigate the whole object, not only sub-object of a parent
   // class in which the encountered method defined.
-  while (const CXXBaseObjectRegion *BR =
- dyn_cast(ThisRegion))
+  while (const auto *BR = dyn_cast(ThisRegion))
 ThisRegion = BR->getSuperRegion();
 
   if (isMoveSafeMethod(MethodDecl))
@@ -487,13 +487,9 @@
 ThisRegion = IC->getCXXThisVal().getAsRegion();
   }
 
-  for (ArrayRef::iterator I = ExplicitRegions.begin(),
- E = ExplicitRegions.end();
-   I != E; ++I) {
-const auto *Region = *I;
-if (ThisRegion != Region) {
+  for (const auto *Region : ExplicitRegions) {
+if (ThisRegion != Region)
   State = removeFromState(State, Region);
-}
   }
 
   return State;


Index: test/Analysis/MisusedMovedObject.cpp
===
--- test/Analysis/MisusedMovedObject.cpp
+++ test/Analysis/MisusedMovedObject.cpp
@@ -638,7 +638,10 @@
   }
 }
 
-class C : public A {};
+struct C : public A {
+  [[clang::reinitializes]] void reinit();
+};
+
 void subRegionMoveTest() {
   {
 A a;
@@ -672,6 +675,13 @@
   C c2 = c; // no-warning
 }
 
+void resetSuperClass2() {
+  C c;
+  C c1 = std::move(c);
+  c.reinit();
+  C c2 = c; // no-warning
+}
+
 void reportSuperClass() {
   C c;
   C c1 = std::move(c); // expected-note {{'c' became 'moved-from' here}}
Index: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
@@ -314,17 +314,18 @@
   return true;
   }
   // Function call `empty` can be skipped.
-  if (MethodDec && MethodDec->getDeclName().isIdentifier() &&
+  return (MethodDec && MethodDec->getDeclName().isIdentifier() &&
   (MethodDec->getName().lower() == "empty" ||
-   MethodDec->getName().lower() == "isempty"))
-return true;
-
-  return false;
+   MethodDec->getName().lower() == "isempty"));
 }
 
 bool MisusedMovedObjectChecker::isStateResetMethod(
 const CXXMethodDecl *MethodDec) const {
-  if (MethodDec && MethodDec->getDeclName().isIdentifier()) {
+  if (!MethodDec)
+  return false;
+  if (MethodDec->hasAttr())
+  return true;
+  if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
 if (MethodName == "reset" || MethodName == "clear" ||
 MethodName == "destroy")
@@ -429,8 +430,7 @@
 
   // We want to investigate the whole object, not only sub-object of a parent
   // class in which the encountered metho

[PATCH] D52984: [analyzer] Checker reviewer's checklist

2018-10-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: NoQ, george.karpenkov, Szelethus, rnkovacs, szepet, 
dcoughlin, a.sidorin, MTC.
xazax.hun added a project: clang.
Herald added subscribers: mikhail.ramalho, dkrupp, baloghadamsoftware, 
whisperity.

This is a first proposal to have a checklist for reviewing checkers.
Feel free to propose additional points or moving it around in the HTML document 
(or putting it somewhere else?)
I think this would come handy to catch some of the most common errors, 
omissions when reviewing checks.
For example, we tend to not update the list of checks at the homepage.

+ Added Devin for potential word smithing.


Repository:
  rC Clang

https://reviews.llvm.org/D52984

Files:
  www/analyzer/checker_dev_manual.html


Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -705,6 +705,17 @@
 The list of Implicit Checkers
 
 
+Checker Reviewer Checklist
+
+Is there unintended branching in the exploded graph?
+Are there unintended sinks?
+Produced reports are easy to understand? Do we need bug visitors? Is there 
a way to suppress false positives?
+Have the checker been run on large projects?
+Did we update the list of available checks on the homepage?
+Are GDM structures properly cleaned up?
+Escaping into unkown functions is properly handled (if applicable)?
+
+
 
 
 


Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -705,6 +705,17 @@
 The list of Implicit Checkers
 
 
+Checker Reviewer Checklist
+
+Is there unintended branching in the exploded graph?
+Are there unintended sinks?
+Produced reports are easy to understand? Do we need bug visitors? Is there a way to suppress false positives?
+Have the checker been run on large projects?
+Did we update the list of available checks on the homepage?
+Are GDM structures properly cleaned up?
+Escaping into unkown functions is properly handled (if applicable)?
+
+
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52984: [analyzer] Checker reviewer's checklist

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

I love the idea. I got a couple more:

Is `-analyzer-checker=core` included in all `RUN:` lines?
Is the description in `Checkers.td` clear to a regular user?
Is `Checkers.td` and the CMakeLists file alphabetically sorted?


Repository:
  rC Clang

https://reviews.llvm.org/D52984



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


[PATCH] D52892: [Clang-tidy] readability check to convert numerical constants to std::numeric_limits

2018-10-08 Thread Idriss Riouak via Phabricator via cfe-commits
IdrissRio updated this revision to Diff 168662.
IdrissRio marked 22 inline comments as done.
IdrissRio edited the summary of this revision.
IdrissRio added a comment.

Update with the suggestion proposed by @Eugene.Zelenko and @JonasToth


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52892

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/NumericalCostantsToMaxIntCheck.cpp
  clang-tidy/readability/NumericalCostantsToMaxIntCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-numerical-costants-to-max-int.rst
  test/clang-tidy/readability-numerical-costants-to-max-int.cpp

Index: test/clang-tidy/readability-numerical-costants-to-max-int.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-numerical-costants-to-max-int.cpp
@@ -0,0 +1,120 @@
+// RUN: %check_clang_tidy %s readability-numerical-costants-to-max-int %t
+unsigned const int Uval1 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: #include 
+// CHECK-FIXES: unsigned const int Uval1 = std::numeric_limits::max();
+
+unsigned const long Uval2 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const long Uval2 = std::numeric_limits::max();
+
+unsigned const long int Uval3 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const long int Uval3 = std::numeric_limits::max();
+
+unsigned const long long int Uval4 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const long long int Uval4 = std::numeric_limits::max();
+
+unsigned const short int Uval5 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const short int Uval5 = std::numeric_limits::max();
+
+unsigned const Uval6 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const Uval6 = std::numeric_limits::max();
+
+unsigned const char Uval7 = -1;
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use 'std::numeric_limits::max()' instead of '-1' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const char Uval7 = std::numeric_limits::max();
+
+//if not constants do nothing
+unsigned int Uval8 = -1;
+unsigned long Uval9 = -1;
+unsigned long int Uval10 = -1;
+unsigned long long int Uval11 = -1;
+unsigned short int Uval12 = -1;
+unsigned Uval13 = -1;
+unsigned char Uval14 = -1;
+
+unsigned const long Uval15 = ~0;
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use 'std::numeric_limits::max()' instead of '~0' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const long Uval15 = std::numeric_limits::max();
+
+unsigned const long int Uval16 = ~0;
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use 'std::numeric_limits::max()' instead of '~0' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const long int Uval16 = std::numeric_limits::max();
+
+unsigned const long long int Uval17 = ~0;
+// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: use 'std::numeric_limits::max()' instead of '~0' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const long long int Uval17 = std::numeric_limits::max();
+
+unsigned const short int Uval18 = ~0;
+// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: use 'std::numeric_limits::max()' instead of '~0' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const short int Uval18 = std::numeric_limits::max();
+
+unsigned const Uval19 = ~0;
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'std::numeric_limits::max()' instead of '~0' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const Uval19 = std::numeric_limits::max();
+
+unsigned const char Uval20 = ~0;
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use 'std::numeric_limits::max()' instead of '~0' for unsigned constant int [readability-numerical-costants-to-max-int]
+// CHECK-FIXES: unsigned const char Uval20 = std::numeric_limits::max();
+
+//if not constants do nothing
+unsigned int Uval21 = ~0;
+unsigned long Uva22 = ~0;
+unsig

[PATCH] D52984: [analyzer] Checker reviewer's checklist

2018-10-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 168664.
xazax.hun added a comment.

- Added the ideas from Kristof.


https://reviews.llvm.org/D52984

Files:
  www/analyzer/checker_dev_manual.html


Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -705,6 +705,20 @@
 The list of Implicit Checkers
 
 
+Checker Reviewer Checklist
+
+Is there unintended branching in the exploded graph?
+Are there unintended sinks?
+Produced reports are easy to understand? Do we need bug visitors? Is there 
a way to suppress false positives?
+Have the checker been run on large projects?
+Did we update the list of available checks on the homepage?
+Are GDM structures properly cleaned up?
+Escaping into unkown functions is properly handled (if applicable)?
+Is -analyzer-checker=core included in all RUN: lines?
+Is the description in Checkers.td clear to the users?
+Are Checkers.td and the CMakeLists entry alphabetically ordered?
+
+
 
 
 


Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -705,6 +705,20 @@
 The list of Implicit Checkers
 
 
+Checker Reviewer Checklist
+
+Is there unintended branching in the exploded graph?
+Are there unintended sinks?
+Produced reports are easy to understand? Do we need bug visitors? Is there a way to suppress false positives?
+Have the checker been run on large projects?
+Did we update the list of available checks on the homepage?
+Are GDM structures properly cleaned up?
+Escaping into unkown functions is properly handled (if applicable)?
+Is -analyzer-checker=core included in all RUN: lines?
+Is the description in Checkers.td clear to the users?
+Are Checkers.td and the CMakeLists entry alphabetically ordered?
+
+
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52986: [analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__

2018-10-08 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: george.karpenkov, xazax.hun, NoQ, rnkovacs, 
baloghadamsoftware.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, 
whisperity.

Thanks to @donat.nagy for spotting this!


Repository:
  rC Clang

https://reviews.llvm.org/D52986

Files:
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
  test/Analysis/plist-macros-with-expansion.cpp

Index: test/Analysis/plist-macros-with-expansion.cpp
===
--- test/Analysis/plist-macros-with-expansion.cpp
+++ test/Analysis/plist-macros-with-expansion.cpp
@@ -261,9 +261,8 @@
   *ptr = 5; // expected-warning{{Dereference of null pointer}}
 }
 
-// TODO: Should correctly display the rest of the parameters.
 // CHECK: nameVARIADIC_SET_TO_NULL
-// CHECK: expansionptr = nullptr ; variadicFunc ( 1 ) 
+// CHECK: expansionptr = nullptr ; variadicFunc ( 1 , 5 , "haha!" ) 
 
 //===--===//
 // Tests for # and ##.
Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
===
--- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
+++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
@@ -3,7 +3,7 @@
 
 
  clang_version
-clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 650e3f54f6a63798143c7181035a285f03dccb7f) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82)
+clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 531e9e44e37061619212a542a5d1076525fdbea9) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82)
  diagnostics
  
   
@@ -3590,7 +3590,7 @@
   file0
  
  nameVARIADIC_SET_TO_NULL
- expansionptr = nullptr ; variadicFunc ( 1 ) 
+ expansionptr = nullptr ; variadicFunc ( 1 , 5 , "haha!" ) 
 
 
  kindevent
@@ -3722,25 +3722,25 @@
 start
  
   
-   line277
+   line276
col3
file0
   
   
-   line277
+   line276
col5
file0
   
  
 end
  
   
-   line278
+   line277
col3
file0
   
   
-   line278
+   line277
col30
file0
   
@@ -3752,7 +3752,7 @@
  kindmacro_expansion
  location
  
-  line278
+  line277
   col3
   file0
  
@@ -3763,20 +3763,20 @@
  kindevent
  location
  
-  line278
+  line277
   col3
   file0
  
  ranges
  

 
- line278
+ line277
  col3
  file0
 
 
- line278
+ line277
  col45
  file0
 
@@ -3796,25 +3796,25 @@
 start
  
   
-   line279
+   line278
col3
file0
   
   
-   line279
+   line278
col3
file0
   
  
 end
  
   
-   line279
+   line278
col8
file0
   
   
-   line279
+   line278
col8
file0
   
@@ -3826,20 +3826,20 @@
  kindevent
  location
  
-  line279
+  line278
   col8
   file0
  
  ranges
  

 
- line279
+ line278
  col4
  file0
 
 
- line279
+ line278
  col6
  file0
 
@@ -3863,18 +3863,18 @@
   issue_hash_function_offset3
   location
   
-   line279
+   line278
col8
file0
   
   ExecutedLines
   
0

+275
 276
 277
 278
-279

   
   
@@ -3889,25 +3889,25 @@
 start
  
   
-   line291
+   line290
col3
file0
   
   
-   line291
+   line290
col5
file0
   
  
 end
  
   
-   line292
+   line291
col3
file0
   
   
-   line292
+   line291
col11
file0
   
@@ -3919,7 +3919,7 @@
  kindmacro_expansion
  location
  
-  line292
+  line291
   col3
   file0
  
@@ -3930,20 +3930,20 @@
  kindevent
  location
  
-  line292
+  line291
   col3
   file0
  
  ranges
  

 
- line292
+ line291
  col3
  file0
 
 
- line292
+ line291
  col23
  file0
 
@@

[PATCH] D46975: Implement deduction guides for `std::deque`

2018-10-08 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Committed as r332785


https://reviews.llvm.org/D46975



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


[PATCH] D52984: [analyzer] Checker reviewer's checklist

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

LGTM! I can think of a couple more, like

- making sure that `clang-format` was run on the new files,
- not forgetting header guards,
- making sure that variables and functions only intended for use within an 
`assert` call are handled in a way that release build bots won't break on them 
(`(void)Var`),
- every virtual overridden method is marked as `override` (bots love breaking 
on that),

but these are general rules, not specific to the analyzer, even if they are 
easily forgotten and aren't emphasized enough elsewhere.


https://reviews.llvm.org/D52984



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


[PATCH] D52892: [Clang-tidy] readability check to convert numerical constants to std::numeric_limits

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



Comment at: clang-tidy/readability/NumericalCostantsToMaxIntCheck.h:25
+///
+class NumericalCostantsToMaxIntCheck : public ClangTidyCheck {
+public:

I feel like the name is overly vague.
This *only* handles the cases of `-1` and `~0`.
It does not handle cases like `255` -> `std::numeric_limits::max()`.
(It might be nice to do that, but it is more complex i suspect.)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52892



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


[PATCH] D52988: [analyzer][PlistMacroExpansion] Part 5.: Support for # and ##

2018-10-08 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: xazax.hun, NoQ, george.karpenkov, rnkovacs, 
baloghadamsoftware.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, 
whisperity.

>From what I can see, this should be the last patch needed to replicate macro 
>argument expansions.

Thanks again to @donat.nagy for spotting this!


Repository:
  rC Clang

https://reviews.llvm.org/D52988

Files:
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
  test/Analysis/plist-macros-with-expansion.cpp

Index: test/Analysis/plist-macros-with-expansion.cpp
===
--- test/Analysis/plist-macros-with-expansion.cpp
+++ test/Analysis/plist-macros-with-expansion.cpp
@@ -278,9 +278,17 @@
   *ptr = 5; // expected-warning{{Dereference of null pointer}}
 }
 
-// TODO: Should expand correctly.
 // CHECK: nameDECLARE_FUNC_AND_SET_TO_NULL
-// CHECK: expansionvoid generated_ ## whatever ( ) ; ptr = nullptr ; 
+// CHECK: expansionvoid generated_whatever ( ) ; ptr = nullptr ; 
+
+void macroArgContainsHashHashInStringTest() {
+  int *a;
+  TO_NULL_AND_PRINT(a, "Will this ## cause a crash?");
+  *a = 5; // expected-warning{{Dereference of null pointer}}
+}
+
+// CHECK: nameTO_NULL_AND_PRINT
+// CHECK: expansiona = 0 ; print ( "Will this ## cause a crash?" ) 
 
 #define PRINT_STR(str, ptr) \
   print(#str);  \
@@ -292,6 +300,14 @@
   *ptr = 5; // expected-warning{{Dereference of null pointer}}
 }
 
-// TODO: Should expand correctly.
 // CHECK: namePRINT_STR
-// CHECK: expansionprint ( # Hello ) ; ptr = nullptr 
+// CHECK: expansionprint ( "Hello" ) ; ptr = nullptr 
+
+void macroArgContainsHashInStringTest() {
+  int *a;
+  TO_NULL_AND_PRINT(a, "Will this # cause a crash?");
+  *a = 5; // expected-warning{{Dereference of null pointer}}
+}
+
+// CHECK: nameTO_NULL_AND_PRINT
+// CHECK: expansiona = 0 ; print ( "Will this # cause a crash?" ) 
Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
===
--- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
+++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
@@ -3,7 +3,7 @@
 
 
  clang_version
-clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 531e9e44e37061619212a542a5d1076525fdbea9) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82)
+clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 263b6f72a3ff1483b445ba5bd8c1cdefcad4f6f6) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82)
  diagnostics
  
   
@@ -3757,7 +3757,7 @@
   file0
  
  nameDECLARE_FUNC_AND_SET_TO_NULL
- expansionvoid generated_ ## whatever ( ) ; ptr = nullptr ; 
+ expansionvoid generated_whatever ( ) ; ptr = nullptr ; 
 
 
  kindevent
@@ -3889,25 +3889,192 @@
 start
  
   
-   line290
+   line285
col3
file0
   
   
-   line290
+   line285
col5
file0
   
  
 end
  
   
-   line291
+   line286
col3
file0
   
   
-   line291
+   line286
+   col19
+   file0
+  
+ 
+   
+  
+
+
+ kindmacro_expansion
+ location
+ 
+  line286
+  col3
+  file0
+ 
+ nameTO_NULL_AND_PRINT
+ expansiona = 0 ; print ( "Will this ## cause a crash?" ) 
+
+
+ kindevent
+ location
+ 
+  line286
+  col3
+  file0
+ 
+ ranges
+ 
+   
+
+ line286
+ col3
+ file0
+
+
+ line286
+ col53
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ Null pointer value stored to 'a'
+ message
+ Null pointer value stored to 'a'
+
+
+ kindcontrol
+ edges
+  
+   
+start
+ 
+  
+   line287
+   col3
+   file0
+  
+  
+   line287
+   col3
+   file0
+  
+ 
+end
+ 
+  
+   line287
+   col6
+   file0
+  
+  
+   line287
+   col6
+   file0
+  
+ 
+   
+  
+
+
+ kindevent
+ location
+ 
+  line287
+  col6
+  file0
+ 
+ ranges
+ 
+   
+
+ line287
+ col4
+ file0
+
+
+ line287
+ col4
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ Dereference of null pointer (loaded from variable 'a')
+ message
+ Dereference of null p

[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

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



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:519
+
+if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+  return true;

xazax.hun wrote:
> I am not sure if this is a reliable way to check if the access is before the 
> guard.
> 
> Consider:
> ```
> switch(x): {
>case 2: guard; access; break;
>case 1: access break;
> }
> ```
> 
> Here, we have no particular ordering between the access in case 1 and the 
> guard in case 2 at runtime. But relying on the source locations we might come 
> to the false conclusion that there is. Loops, gotos can cause similar 
> problems.
> I do understand that this might not be too easy to solve without traversing 
> the cfg and we might not want to do that but I think we should at least add a 
> test/todo. 
> I am not sure if this is a reliable way to check if the access is before the 
> guard.
I'm 100% sure it isn't. Using the CFG instead of matchers sounds like a great 
and difficult to implement (at least to me, as I never touched them) idea. It 
should get rid of the false negatives, at least in part.
> [...]  I think we should at least add a test/todo.
There are some :)


https://reviews.llvm.org/D51866



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


[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added a reviewer: hokein.
Herald added a subscriber: xazax.hun.

Extra parentheses around a new expression result in incorrect code
after applying fixes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52989

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  test/clang-tidy/modernize-make-shared.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -110,6 +110,19 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
   // CHECK-FIXES: auto P3 = std::make_unique();
 
+  std::unique_ptr P4 = std::unique_ptr((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P4 = std::make_unique();
+  P4.reset((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: P4 = std::make_unique();
+  std::unique_ptr P5 = std::unique_ptrnew int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P5 = std::make_unique();
+  P5.reset(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: P5 = std::make_unique();
+
   {
 // No std.
 using namespace std;
Index: test/clang-tidy/modernize-make-shared.cpp
===
--- test/clang-tidy/modernize-make-shared.cpp
+++ test/clang-tidy/modernize-make-shared.cpp
@@ -70,6 +70,18 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_shared instead
   // CHECK-FIXES: auto P3 = std::make_shared();
 
+  std::shared_ptr P4 = std::shared_ptr((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: std::shared_ptr P4 = std::make_shared();
+
+  P4.resetnew int();
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: P4 = std::make_shared();
+
+  P4 = std::shared_ptr(((new int)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: P4 = std::make_shared();
+
   {
 // No std.
 using namespace std;
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -44,25 +44,23 @@
   virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
 
   static const char PointerType[];
-  static const char ConstructorCall[];
-  static const char ResetCall[];
-  static const char NewExpression[];
 
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
 
-  void checkConstruct(SourceManager &SM, const CXXConstructExpr *Construct,
-  const QualType *Type, const CXXNewExpr *New);
-  void checkReset(SourceManager &SM, const CXXMemberCallExpr *Member,
-  const CXXNewExpr *New);
+  void checkConstruct(SourceManager &SM, ASTContext *Ctx,
+  const CXXConstructExpr *Construct, const QualType *Type,
+  const CXXNewExpr *New);
+  void checkReset(SourceManager &SM, ASTContext *Ctx,
+  const CXXMemberCallExpr *Member, const CXXNewExpr *New);
 
   /// Returns true when the fixes for replacing CXXNewExpr are generated.
   bool replaceNew(DiagnosticBuilder &Diag, const CXXNewExpr *New,
-  SourceManager &SM);
+  SourceManager &SM, ASTContext *Ctx);
   void insertHeader(DiagnosticBuilder &Diag, FileID FD);
 };
 
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -21,6 +21,9 @@
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,17 +33,14 @@
   NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
 
 } // namespace
 

[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added a reviewer: rnk.

Turns out that ubsan actually already was supported for msvc mode as well; it 
just didn't require any code in lib/Driver/ToolChains/MSVC.cpp,


Repository:
  rC Clang

https://reviews.llvm.org/D52990

Files:
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/MinGW.cpp
  test/Driver/fsanitize.c
  test/Driver/mingw-sanitizers.c


Index: test/Driver/mingw-sanitizers.c
===
--- test/Driver/mingw-sanitizers.c
+++ test/Driver/mingw-sanitizers.c
@@ -9,3 +9,9 @@
 // ASAN-X86_64: "{{[^"]*}}libclang_rt.asan_dynamic_runtime_thunk-x86_64.a"
 // ASAN-X86_64: "--require-defined" "__asan_seh_interceptor"
 // ASAN-X86_64: "--whole-archive" 
"{{.*}}libclang_rt.asan_dynamic_runtime_thunk-x86_64.a" "--no-whole-archive"
+
+// RUN: %clang -target x86_64-windows-gnu %s -### -fsanitize=undefined 2>&1 | 
FileCheck --check-prefix=UBSAN-X86_64 %s
+// The ubsan library itself gets linked in with embedded linker directives
+// in the object files, but the static library needs -lpsapi unless
+// the sanitizer was built targeting >= win7.
+// UBSAN-X86_64: "-lpsapi"
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -17,9 +17,11 @@
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN32
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64
+// RUN: %clang -target x86_64-w64-mingw32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64-MINGW
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // CHECK-UNDEFINED-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib"
 // CHECK-UNDEFINED-WIN64: 
"--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
+// CHECK-UNDEFINED-WIN64-MINGW: 
"--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a"
 // CHECK-UNDEFINED-WIN-CXX: 
"--dependent-lib={{[^"]*}}ubsan_standalone_cxx{{[^"]*}}.lib"
 // CHECK-UNDEFINED-WIN-SAME: 
"-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -260,6 +260,12 @@
 CmdArgs.push_back("-lshell32");
 CmdArgs.push_back("-luser32");
 CmdArgs.push_back("-lkernel32");
+if (Sanitize.needsUbsanRt()) {
+  // The ubsan library itself gets linked in with embedded linker
+  // directives in the object files, but the static library needs
+  // -lpsapi unless the sanitizer was built targeting >= win7.
+  CmdArgs.push_back("-lpsapi");
+}
   }
 
   if (Args.hasArg(options::OPT_static))
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2337,7 +2337,7 @@
   bool Quote = (Lib.find(" ") != StringRef::npos);
   std::string ArgStr = Quote ? "\"" : "";
   ArgStr += Lib;
-  if (!Lib.endswith_lower(".lib"))
+  if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))
 ArgStr += ".lib";
   ArgStr += Quote ? "\"" : "";
   return ArgStr;


Index: test/Driver/mingw-sanitizers.c
===
--- test/Driver/mingw-sanitizers.c
+++ test/Driver/mingw-sanitizers.c
@@ -9,3 +9,9 @@
 // ASAN-X86_64: "{{[^"]*}}libclang_rt.asan_dynamic_runtime_thunk-x86_64.a"
 // ASAN-X86_64: "--require-defined" "__asan_seh_interceptor"
 // ASAN-X86_64: "--whole-archive" "{{.*}}libclang_rt.asan_dynamic_runtime_thunk-x86_64.a" "--no-whole-archive"
+
+// RUN: %clang -target x86_64-windows-gnu %s -### -fsanitize=undefined 2>&1 | FileCheck --check-prefix=UBSAN-X86_64 %s
+// The ubsan library itself gets linked in with embedded linker directives
+// in the object files, but the static library needs -lpsapi unless
+// the sanitizer was built targeting >= win7.
+// UBSAN-X86_64: "-lpsapi"
Index: test/Driver/fsanitize.c
===
--- test/Driver

[PATCH] D52991: [clangd] Avoid cache main file status in preamble.

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

Main file can certainly change when reusing preamble.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52991

Files:
  clangd/ClangdUnit.cpp
  clangd/FS.cpp
  clangd/FS.h
  unittests/clangd/FSTests.cpp

Index: unittests/clangd/FSTests.cpp
===
--- unittests/clangd/FSTests.cpp
+++ unittests/clangd/FSTests.cpp
@@ -20,16 +20,20 @@
   llvm::StringMap Files;
   Files["x"] = "";
   Files["y"] = "";
+  Files["main"] = "";
   auto FS = buildTestFS(Files);
   FS->setCurrentWorkingDirectory(testRoot());
 
-  PreambleFileStatusCache StatCache;
+  PreambleFileStatusCache StatCache(testPath("main"));
   auto ProduceFS = StatCache.getProducingFS(FS);
   EXPECT_TRUE(ProduceFS->openFileForRead("x"));
   EXPECT_TRUE(ProduceFS->status("y"));
+  EXPECT_TRUE(ProduceFS->status("main"));
 
   EXPECT_TRUE(StatCache.lookup(testPath("x")).hasValue());
   EXPECT_TRUE(StatCache.lookup(testPath("y")).hasValue());
+  // Main file is not cached.
+  EXPECT_FALSE(StatCache.lookup(testPath("main")).hasValue());
 
   vfs::Status S("fake", llvm::sys::fs::UniqueID(0, 0),
 std::chrono::system_clock::now(), 0, 0, 1024,
Index: clangd/FS.h
===
--- clangd/FS.h
+++ clangd/FS.h
@@ -17,10 +17,10 @@
 namespace clangd {
 
 /// Records status information for files open()ed or stat()ed during preamble
-/// build, so we can avoid stat()s on the underlying FS when reusing the
-/// preamble. For example, code completion can re-stat files when getting FileID
-/// for source locations stored in preamble (e.g. checking whether a location is
-/// in the main file).
+/// build (except for the main file), so we can avoid stat()s on the underlying
+/// FS when reusing the preamble. For example, code completion can re-stat files
+/// when getting FileID for source locations stored in preamble (e.g. checking
+/// whether a location is in the main file).
 ///
 /// The cache is keyed by absolute path of file name in cached status, as this
 /// is what preamble stores.
@@ -35,7 +35,12 @@
 /// Note that the cache is only valid when reusing preamble.
 class PreambleFileStatusCache {
 public:
+  /// \p MainFilePath is the absolute path of the main source file this preamble
+  /// corresponds to. The stat for the main file will not be cached.
+  PreambleFileStatusCache(llvm::StringRef MainFilePath);
+
   void update(const vfs::FileSystem &FS, vfs::Status S);
+
   /// \p Path is a path stored in preamble.
   llvm::Optional lookup(llvm::StringRef Path) const;
 
@@ -56,6 +61,7 @@
   getConsumingFS(IntrusiveRefCntPtr FS) const;
 
 private:
+  std::string MainFilePath;
   llvm::StringMap StatCache;
 };
 
Index: clangd/FS.cpp
===
--- clangd/FS.cpp
+++ clangd/FS.cpp
@@ -10,14 +10,23 @@
 #include "FS.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "llvm/ADT/None.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace clangd {
 
+PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath)
+: MainFilePath(MainFilePath) {
+  assert(llvm::sys::path::is_absolute(MainFilePath));
+}
+
 void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) {
   SmallString<32> PathStore(S.getName());
   if (FS.makeAbsolute(PathStore))
 return;
+  // Do not cache status for the main file.
+  if (PathStore == MainFilePath)
+return;
   // Stores the latest status in cache as it can change in a preamble build.
   StatCache.insert({PathStore, std::move(S)});
 }
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -29,6 +29,7 @@
 #include "clang/Serialization/ASTWriter.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/raw_ostream.h"
@@ -336,7 +337,9 @@
 // dirs.
   }
 
-  auto StatCache = llvm::make_unique();
+  llvm::SmallString<32> AbsFileName(FileName);
+  Inputs.FS->makeAbsolute(AbsFileName);
+  auto StatCache = llvm::make_unique(AbsFileName);
   auto BuiltPreamble = PrecompiledPreamble::Build(
   CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine,
   StatCache->getProducingFS(Inputs.FS), PCHs, StoreInMemory,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52892: [Clang-tidy] readability check to convert numerical constants to std::numeric_limits

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



Comment at: docs/ReleaseNotes.rst:118
+
+  Checks for numerical unsigned constants that are equal to '-1' or '~0'
+  and substitutes them with 'std::numeric_limits::max()'.

Wrong kind of quotes were used. Should be `. std::numeric_limits::max() 
Should be enclosed in ``.



Comment at: 
docs/clang-tidy/checks/readability-numerical-costants-to-max-int.rst:7
+
+Checks for numerical unsigned constants that are equal to '-1' or '~0'
+and substitutes them with 'std::numeric_limits::max()'.

Please re-synchronize.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52892



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


[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-08 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Checking for asserts makes sense, but as a rough estimate will suppress roughly 
zero false positives I have seen.
In general, LLVM codebase is exceptional in its use of asserts, and most 
projects, unfortunately, don't really know how to use them.




Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:519
+
+if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+  return true;

Szelethus wrote:
> xazax.hun wrote:
> > I am not sure if this is a reliable way to check if the access is before 
> > the guard.
> > 
> > Consider:
> > ```
> > switch(x): {
> >case 2: guard; access; break;
> >case 1: access break;
> > }
> > ```
> > 
> > Here, we have no particular ordering between the access in case 1 and the 
> > guard in case 2 at runtime. But relying on the source locations we might 
> > come to the false conclusion that there is. Loops, gotos can cause similar 
> > problems.
> > I do understand that this might not be too easy to solve without traversing 
> > the cfg and we might not want to do that but I think we should at least add 
> > a test/todo. 
> > I am not sure if this is a reliable way to check if the access is before 
> > the guard.
> I'm 100% sure it isn't. Using the CFG instead of matchers sounds like a great 
> and difficult to implement (at least to me, as I never touched them) idea. It 
> should get rid of the false negatives, at least in part.
> > [...]  I think we should at least add a test/todo.
> There are some :)
> Using the CFG instead of matchers sounds like a great and difficult to 
> implement

That would also require building a dataflow framework, which we do not have 
(yet)


https://reviews.llvm.org/D51866



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


[clang-tools-extra] r343982 - [clang-move] Dump whether a declaration is templated.

2018-10-08 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Oct  8 10:22:50 2018
New Revision: 343982

URL: http://llvm.org/viewvc/llvm-project?rev=343982&view=rev
Log:
[clang-move] Dump whether a declaration is templated.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=343982&r1=343981&r2=343982&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Mon Oct  8 10:22:50 2018
@@ -899,21 +899,21 @@ void ClangMoveTool::onEndOfTranslationUn
 assert(Reporter);
 for (const auto *Decl : UnremovedDeclsInOldHeader) {
   auto Kind = Decl->getKind();
+  bool Templated = Decl->isTemplated();
   const std::string QualifiedName = Decl->getQualifiedNameAsString();
   if (Kind == Decl::Kind::Var)
-Reporter->reportDeclaration(QualifiedName, "Variable");
+Reporter->reportDeclaration(QualifiedName, "Variable", Templated);
   else if (Kind == Decl::Kind::Function ||
Kind == Decl::Kind::FunctionTemplate)
-Reporter->reportDeclaration(QualifiedName, "Function");
+Reporter->reportDeclaration(QualifiedName, "Function", Templated);
   else if (Kind == Decl::Kind::ClassTemplate ||
Kind == Decl::Kind::CXXRecord)
-Reporter->reportDeclaration(QualifiedName, "Class");
+Reporter->reportDeclaration(QualifiedName, "Class", Templated);
   else if (Kind == Decl::Kind::Enum)
-Reporter->reportDeclaration(QualifiedName, "Enum");
-  else if (Kind == Decl::Kind::Typedef ||
-   Kind == Decl::Kind::TypeAlias ||
+Reporter->reportDeclaration(QualifiedName, "Enum", Templated);
+  else if (Kind == Decl::Kind::Typedef || Kind == Decl::Kind::TypeAlias ||
Kind == Decl::Kind::TypeAliasTemplate)
-Reporter->reportDeclaration(QualifiedName, "TypeAlias");
+Reporter->reportDeclaration(QualifiedName, "TypeAlias", Templated);
 }
 return;
   }

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=343982&r1=343981&r2=343982&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Mon Oct  8 10:22:50 2018
@@ -17,6 +17,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 #include 
@@ -31,23 +32,30 @@ public:
   DeclarationReporter() = default;
   ~DeclarationReporter() = default;
 
-  void reportDeclaration(llvm::StringRef DeclarationName,
- llvm::StringRef Type) {
-DeclarationList.emplace_back(DeclarationName, Type);
+  void reportDeclaration(llvm::StringRef DeclarationName, llvm::StringRef Type,
+ bool Templated) {
+DeclarationList.emplace_back(DeclarationName, Type, Templated);
   };
 
-  // A  pair.
-  // The DeclarationName is a fully qualified name for the declaration, like
-  // A::B::Foo. The DeclarationKind is a string represents the kind of the
-  // declaration, currently only "Function" and "Class" are supported.
-  typedef std::pair DeclarationPair;
+  struct Declaration {
+Declaration(llvm::StringRef QName, llvm::StringRef Kind, bool Templated)
+: QualifiedName(QName), Kind(Kind), Templated(Templated) {}
+
+friend bool operator==(const Declaration &LHS, const Declaration &RHS) {
+  return std::tie(LHS.QualifiedName, LHS.Kind, LHS.Templated) ==
+ std::tie(RHS.QualifiedName, RHS.Kind, RHS.Templated);
+}
+std::string QualifiedName; // E.g. A::B::Foo.
+std::string Kind;  // E.g. Function, Class
+bool Templated = false;// Whether the declaration is templated.
+  };
 
-  const std::vector getDeclarationList() const {
+  const std::vector getDeclarationList() const {
 return DeclarationList;
   }
 
 private:
-  std::vector DeclarationList;
+  std::vector DeclarationList;
 };
 
 // Specify declarations being moved. It contains all information of the moved

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=343982&r1=343981&r2=343982&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/

[PATCH] D52956: Support `-fno-visibility-inlines-hidden`

2018-10-08 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande accepted this revision.
elsteveogrande added a comment.
This revision is now accepted and ready to land.

lgtm!


Repository:
  rC Clang

https://reviews.llvm.org/D52956



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


[PATCH] D52993: [analyzer][www] Add more useful links

2018-10-08 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, dcoughlin.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, rnkovacs, 
szepet, whisperity.

This bothered me for a while, but finding literature about static analysis is 
very difficult. Do you know any other links that would be great to add?


Repository:
  rC Clang

https://reviews.llvm.org/D52993

Files:
  www/analyzer/checker_dev_manual.html


Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -702,6 +702,19 @@
 
 Useful Links
 
+http://lcs.ios.ac.cn/~xuzb/canalyze/memmodel.pdf";>Xu, Zhongxing &
+Kremenek, Ted & Zhang, Jian. (2010). A Memory Model for Static Analysis of C
+Programs.
+https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/README.txt";>
+The Clang Static Analyzer README
+https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/RegionStore.txt";>
+Documentation for how the Store works
+https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/IPA.txt";>
+Documentation about inlining
+
+https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf";>
+Artem Degrachev: Clang Static Analyzer: A Checker Developer's Guide
+ (reading the previous items first might be a good idea)
 The list of Implicit Checkers
 
 


Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -702,6 +702,19 @@
 
 Useful Links
 
+http://lcs.ios.ac.cn/~xuzb/canalyze/memmodel.pdf";>Xu, Zhongxing &
+Kremenek, Ted & Zhang, Jian. (2010). A Memory Model for Static Analysis of C
+Programs.
+https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/README.txt";>
+The Clang Static Analyzer README
+https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/RegionStore.txt";>
+Documentation for how the Store works
+https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/IPA.txt";>
+Documentation about inlining
+
+https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf";>
+Artem Degrachev: Clang Static Analyzer: A Checker Developer's Guide
+ (reading the previous items first might be a good idea)
 The list of Implicit Checkers
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46441: [clang][CodeGenCXX] Noalias attr for 'this' parameter

2018-10-08 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

LGTM.




Comment at: lib/CodeGen/CGCall.cpp:2049
+// from the constructor’s this pointer, the value of the object or
+// subobject thus obtained is unspecified.
+unsigned ThisIRArg, NumIRArgs;

rjmccall wrote:
> You probably ought to add here that we're treating this as undefined behavior 
> and have recommended the standard be changed.
Thanks, looks good.


https://reviews.llvm.org/D46441



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


[PATCH] D52598: [OpenCL] Fixed address space cast in C style cast of C++ parsing

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

LGTM.




Comment at: lib/Sema/SemaCast.cpp:2288
+  SrcType->isPointerType()) {
+const PointerType *DestPtr = DestType->getAs();
+if (!DestPtr->isAddressSpaceOverlapping(*SrcType->getAs())) {

Anastasia wrote:
> rjmccall wrote:
> > Anastasia wrote:
> > > Anastasia wrote:
> > > > rjmccall wrote:
> > > > > Please test the result of `getAs` instead of separately testing 
> > > > > `isPointerType`.
> > > > > 
> > > > > Why is this check OpenCL-specific?  Address spaces are a general 
> > > > > language feature.
> > > > I think mainly because I am factoring out from the existing OpenCL 
> > > > check. But it probably makes sense that the semantics of this is not 
> > > > different in other languages. I will update it! Thanks!
> > > After playing with this for a bit longer I discovered that I have to keep 
> > > the OpenCL check unfortunately.
> > > 
> > > I found this old commit (`d4c5f84`/`r129583`) that says:
> > >   C-style casts can add/remove/change address spaces through the 
> > > reinterpret_cast mechanism.
> > > That's not the same as in OpenCL because it seems for C++ you can cast 
> > > any AS to any other AS. Therefore, no checks are needed at all. I am not 
> > > sure if we can come up with a common function for the moment.
> > > 
> > > The following  tests are checking this:
> > >CodeGenCXX/address-space-cast.cpp
> > >SemaCXX/address-space-conversion.cpp
> > > 
> > > Do you think it would make sense to rename this method with 
> > > OpenCL-something or keep in case may be CUDA or some other languages 
> > > might need similar functionality...
> > > 
> > I think you can leave it alone for now, but please add a comment explaining 
> > the reasoning as best you see it, and feel free to express uncertainty 
> > about the right rule.
> > 
> > Don't take `QualType` by `const &`, by the way.  It's a cheap-to-copy value 
> > type and should always be passed by value.
> My general understand of the address spaces in C and C++ that they are 
> intended to be more general than in OpenCL (i.e. they don't reflect any 
> particular memory system). Perhaps, it makes sense that we have more 
> restrictions in OpenCL or other similar languages.
No, their primary use is to reflect underlying memory systems, like near vs. 
far pointers on 32-on-64 targets or specialized address spaces like 
`gs`-segment addressing on x86-64, and it doesn't make sense to allow arbitrary 
conversions any more than it does for OpenCL.  The Embedded C spec has rules 
about overlapping address spaces, and while it doesn't say that casts between 
non-overlapping address spaces are ill-formed, it probably ought to.  
Regardless, if we've permitted arbitrary casts in the past, we'll need to 
investigate the source compatibility issues before imposing restrictions.

There have also been proposals for "superficial" address spaces that are 
eliminated during lowering which might have their own restrictions.


https://reviews.llvm.org/D52598



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


[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-10-08 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x updated this revision to Diff 168687.
cdavis5x added a comment.

- Detect libgcc.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51657

Files:
  cmake/config-ix.cmake
  src/CMakeLists.txt


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -53,7 +53,12 @@
 # Generate library list.
 set(libraries)
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
-append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+if (LIBUNWIND_USE_COMPILER_RT)
+  list(APPEND libraries "${LIBUNWIND_BUILTINS_LIBRARY}")
+else()
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  append_if(libraries LIBUNWIND_HAS_GCC_LIB gcc)
+endif()
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
 if (LIBUNWIND_ENABLE_THREADS)
   append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -7,6 +7,7 @@
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
+  check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
 endif()
 
 # libunwind is built with -nodefaultlibs, so we want all our checks to also
@@ -25,8 +26,13 @@
   if (LIBUNWIND_USE_COMPILER_RT)
 find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY)
 list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
-  elseif (LIBUNWIND_HAS_GCC_S_LIB)
-list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  else ()
+if (LIBUNWIND_HAS_GCC_S_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+endif ()
+if (LIBUNWIND_HAS_GCC_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
+endif ()
   endif ()
   if (MINGW)
 # Mingw64 requires quite a few "C" runtime libraries in order for basic


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -53,7 +53,12 @@
 # Generate library list.
 set(libraries)
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
-append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+if (LIBUNWIND_USE_COMPILER_RT)
+  list(APPEND libraries "${LIBUNWIND_BUILTINS_LIBRARY}")
+else()
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  append_if(libraries LIBUNWIND_HAS_GCC_LIB gcc)
+endif()
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
 if (LIBUNWIND_ENABLE_THREADS)
   append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -7,6 +7,7 @@
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
+  check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
 endif()
 
 # libunwind is built with -nodefaultlibs, so we want all our checks to also
@@ -25,8 +26,13 @@
   if (LIBUNWIND_USE_COMPILER_RT)
 find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY)
 list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
-  elseif (LIBUNWIND_HAS_GCC_S_LIB)
-list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  else ()
+if (LIBUNWIND_HAS_GCC_S_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+endif ()
+if (LIBUNWIND_HAS_GCC_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
+endif ()
   endif ()
   if (MINGW)
 # Mingw64 requires quite a few "C" runtime libraries in order for basic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46441: [clang][CodeGenCXX] Noalias attr for 'this' parameter

2018-10-08 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev added a comment.

@rsmith do you have any comments or suggestions?


https://reviews.llvm.org/D46441



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-08 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Can I convince someone to be interested enough in this to approve it?

I have a talk coming up and I'd like to be able to say that you don't have to 
switch between `dump` mode and `diag` mode all the time.

I also want to enable other relevant outputting features in `clang-query` that 
I have in the pipeline.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[libunwind] r343990 - [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-10-08 Thread Charles Davis via cfe-commits
Author: cdavis
Date: Mon Oct  8 11:35:00 2018
New Revision: 343990

URL: http://llvm.org/viewvc/llvm-project?rev=343990&view=rev
Log:
[CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

Summary:
If `-nodefaultlibs` is given, we weren't actually linking to it. This
was true irrespective of passing `-rtlib=compiler-rt` (see previous
patch). Now we explicitly link it to handle that case.

I wonder if we should be linking these libraries only if we're using
`-nodefaultlibs`...

Reviewers: beanz

Subscribers: dberris, mgorny, christof, chrib, cfe-commits

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

Modified:
libunwind/trunk/cmake/config-ix.cmake
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=343990&r1=343989&r2=343990&view=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Mon Oct  8 11:35:00 2018
@@ -7,6 +7,7 @@ check_library_exists(c fopen "" LIBUNWIN
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
+  check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
 endif()
 
 # libunwind is built with -nodefaultlibs, so we want all our checks to also
@@ -25,8 +26,13 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
   if (LIBUNWIND_USE_COMPILER_RT)
 find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY)
 list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
-  elseif (LIBUNWIND_HAS_GCC_S_LIB)
-list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  else ()
+if (LIBUNWIND_HAS_GCC_S_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+endif ()
+if (LIBUNWIND_HAS_GCC_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
+endif ()
   endif ()
   if (MINGW)
 # Mingw64 requires quite a few "C" runtime libraries in order for basic

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=343990&r1=343989&r2=343990&view=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Mon Oct  8 11:35:00 2018
@@ -53,7 +53,12 @@ set(LIBUNWIND_SOURCES
 # Generate library list.
 set(libraries)
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
-append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+if (LIBUNWIND_USE_COMPILER_RT)
+  list(APPEND libraries "${LIBUNWIND_BUILTINS_LIBRARY}")
+else()
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  append_if(libraries LIBUNWIND_HAS_GCC_LIB gcc)
+endif()
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
 if (LIBUNWIND_ENABLE_THREADS)
   append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)


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


[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-10-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343990: [CMake] Link to compiler-rt if 
LIBUNWIND_USE_COMPILER_RT is ON. (authored by cdavis, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51657

Files:
  libunwind/trunk/cmake/config-ix.cmake
  libunwind/trunk/src/CMakeLists.txt


Index: libunwind/trunk/src/CMakeLists.txt
===
--- libunwind/trunk/src/CMakeLists.txt
+++ libunwind/trunk/src/CMakeLists.txt
@@ -53,7 +53,12 @@
 # Generate library list.
 set(libraries)
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
-append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+if (LIBUNWIND_USE_COMPILER_RT)
+  list(APPEND libraries "${LIBUNWIND_BUILTINS_LIBRARY}")
+else()
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  append_if(libraries LIBUNWIND_HAS_GCC_LIB gcc)
+endif()
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
 if (LIBUNWIND_ENABLE_THREADS)
   append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
Index: libunwind/trunk/cmake/config-ix.cmake
===
--- libunwind/trunk/cmake/config-ix.cmake
+++ libunwind/trunk/cmake/config-ix.cmake
@@ -7,6 +7,7 @@
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
+  check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
 endif()
 
 # libunwind is built with -nodefaultlibs, so we want all our checks to also
@@ -25,8 +26,13 @@
   if (LIBUNWIND_USE_COMPILER_RT)
 find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY)
 list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
-  elseif (LIBUNWIND_HAS_GCC_S_LIB)
-list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  else ()
+if (LIBUNWIND_HAS_GCC_S_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+endif ()
+if (LIBUNWIND_HAS_GCC_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
+endif ()
   endif ()
   if (MINGW)
 # Mingw64 requires quite a few "C" runtime libraries in order for basic


Index: libunwind/trunk/src/CMakeLists.txt
===
--- libunwind/trunk/src/CMakeLists.txt
+++ libunwind/trunk/src/CMakeLists.txt
@@ -53,7 +53,12 @@
 # Generate library list.
 set(libraries)
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
-append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+if (LIBUNWIND_USE_COMPILER_RT)
+  list(APPEND libraries "${LIBUNWIND_BUILTINS_LIBRARY}")
+else()
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  append_if(libraries LIBUNWIND_HAS_GCC_LIB gcc)
+endif()
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
 if (LIBUNWIND_ENABLE_THREADS)
   append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
Index: libunwind/trunk/cmake/config-ix.cmake
===
--- libunwind/trunk/cmake/config-ix.cmake
+++ libunwind/trunk/cmake/config-ix.cmake
@@ -7,6 +7,7 @@
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)
+  check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)
 endif()
 
 # libunwind is built with -nodefaultlibs, so we want all our checks to also
@@ -25,8 +26,13 @@
   if (LIBUNWIND_USE_COMPILER_RT)
 find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY)
 list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
-  elseif (LIBUNWIND_HAS_GCC_S_LIB)
-list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  else ()
+if (LIBUNWIND_HAS_GCC_S_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+endif ()
+if (LIBUNWIND_HAS_GCC_LIB)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
+endif ()
   endif ()
   if (MINGW)
 # Mingw64 requires quite a few "C" runtime libraries in order for basic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

2018-10-08 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 168690.
zinovy.nis added a comment.

- Fixed diagnostics;
- Interchangeable alias introduced: `-check-suffixes` for `-check-suffix`.


https://reviews.llvm.org/D52971

Files:
  test/clang-tidy/check_clang_tidy.cpp
  test/clang-tidy/check_clang_tidy.py

Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -18,7 +18,7 @@
 Usage:
   check_clang_tidy.py [-resource-dir=] \
 [-assume-filename=] \
-[-check-suffix=] \
+[-check-suffix=] \
\
 -- [optional clang-tidy arguments]
 
@@ -38,15 +38,20 @@
 f.write(text)
 f.truncate()
 
+def csv(string):
+  return string.split(',')
+
 def main():
   parser = argparse.ArgumentParser()
   parser.add_argument('-expect-clang-tidy-error', action='store_true')
   parser.add_argument('-resource-dir')
   parser.add_argument('-assume-filename')
-  parser.add_argument('-check-suffix', default='')
   parser.add_argument('input_file_name')
   parser.add_argument('check_name')
   parser.add_argument('temp_file_name')
+  parser.add_argument('-check-suffix', '-check-suffixes',
+  default=[], type=csv,
+  help="comma-separated list of FileCheck suffixes")
 
   args, extra_args = parser.parse_known_args()
 
@@ -72,14 +77,6 @@
   clang_tidy_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
-  if args.check_suffix and not re.match('^[A-Z0-9\-]+$', args.check_suffix):
-sys.exit('Only A..Z, 0..9 and "-" are allowed in check suffix, but "%s" was given' % (args.check_suffix))
-
-  file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
-  check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
-  check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
-  check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
-
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
   clang_tidy_extra_args.append('-nostdinc++')
@@ -90,16 +87,48 @@
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
 
-  has_check_fixes = check_fixes_prefix in input_text
-  has_check_messages = check_messages_prefix in input_text
-  has_check_notes = check_notes_prefix in input_text
-
-  if not has_check_fixes and not has_check_messages and not has_check_notes:
-sys.exit('%s, %s or %s not found in the input' % (check_fixes_prefix,
- check_messages_prefix, check_notes_prefix) )
-
-  if has_check_notes and has_check_messages:
-sys.exit('Please use either CHECK-NOTES or CHECK-MESSAGES but not both')
+  check_fixes_prefixes = []
+  check_messages_prefixes = []
+  check_notes_prefixes = []
+
+  has_check_fixes = False
+  has_check_messages = False
+  has_check_notes = False
+
+  if any(args.check_suffix):
+for check in args.check_suffix:
+  if not re.match('^[A-Z0-9\-]+$', check):
+sys.exit('Only A..Z, 0..9 and "-" are ' +
+  'allowed in check suffixes list, but "%s" was given' % (check))
+
+  file_check_suffix = '-' + check
+  check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
+  check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+  check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
+
+  has_check_fix = check_fixes_prefix in input_text 
+  has_check_message = check_messages_prefix in input_text
+  has_check_note = check_notes_prefix in input_text 
+
+  if has_check_note and has_check_message:
+sys.exit('Please use either %s or %s but not both' %
+  (check_notes_prefix, check_messages_prefix))
+
+  if not has_check_fix and not has_check_message and not has_check_note:
+sys.exit('%s, %s or %s not found in the input' %
+  (check_fixes_prefix, check_messages_prefix, check_notes_prefix))
+
+  has_check_fixes = has_check_fixes or has_check_fix
+  has_check_messages = has_check_messages or has_check_message
+  has_check_notes = has_check_notes or has_check_note
+
+  check_fixes_prefixes.append(check_fixes_prefix)
+  check_messages_prefixes.append(check_messages_prefix)
+  check_notes_prefixes.append(check_notes_prefix)
+  else:
+check_fixes_prefixes = ['CHECK-FIXES']
+check_messages_prefixes = ['CHECK-MESSAGES']
+check_notes_prefixes = ['CHECK-NOTES']
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -143,7 +172,8 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + temp_file_name, input_file_name,
-   '-check-prefix=' + check_fixes_prefix, '-strict-whitespace'],
+   '-check-prefixes=' + ','.join(check_fixes_prefixes),
+   '-strict-whitespace'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as 

[PATCH] D52854: Use is.constant intrinsic for __builtin_constant_p

2018-10-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I don't think that was the approach @rsmith was suggesting; you don't need to 
wrap every possible kind of expression.  Rather, at the point where the 
expression is required to be constant, add a single expression which wraps the 
entire expression tree to indicate that.  So for "constexpr int c = 10+2;", the 
expression tree for the initializer is something like 
ConstExpr(BinaryOperator(IntegerLiteral, IntegerLiteral)).


Repository:
  rC Clang

https://reviews.llvm.org/D52854



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


[PATCH] D52891: [AMDGPU] Add -fvisibility-amdgpu-non-kernel-functions

2018-10-08 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

I will update the patch to modify the HIP toolchain and to add tests for global 
variables.

As far as the semantics are concerned, are we OK with this being AMDGPU only? I 
do not see a means of determining what is a "kernel" in a language-agnostic way 
other than checking for our AMDGPU-specific calling convention. If there is a 
more general mechanism, this could be implemented in 
`LinkageComputer::getLVForNamespaceScopeDecl` instead. As it stands, it sounds 
like being AMDGPU specific, but omitting `amdgpu` from the option name is 
preferred?

What about:

  -fvisibility-non-offload-functions=
  
  Set the default symbol visibility for non-offload function declarations 
(AMDGPU only)

I cannot think of a way to avoid `non` or something similar ending up in the 
name.


https://reviews.llvm.org/D52891



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


[PATCH] D52854: Use is.constant intrinsic for __builtin_constant_p

2018-10-08 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

No, I understood that. But the issue is that you then need to specify this new 
expression class in over 23 different files: various macros, switch statements, 
etc.


Repository:
  rC Clang

https://reviews.llvm.org/D52854



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


[PATCH] D52854: Use is.constant intrinsic for __builtin_constant_p

2018-10-08 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Here's a WIP patch to show what I'm talking about.F7375980: example.diff 



Repository:
  rC Clang

https://reviews.llvm.org/D52854



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


[PATCH] D52920: Introduce code_model macros

2018-10-08 Thread Ali Tamur via Phabricator via cfe-commits
tamur updated this revision to Diff 168700.

Repository:
  rC Clang

https://reviews.llvm.org/D52920

Files:
  include/clang/Basic/TargetOptions.h
  lib/Basic/Targets/X86.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -47,21 +47,21 @@
 // CXX11:#define __cplusplus 201103L
 // CXX11:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX98 %s
-// 
+//
 // CXX98:#define __GNUG__ {{.*}}
 // CXX98:#define __GXX_RTTI 1
 // CXX98:#define __GXX_WEAK__ 1
 // CXX98:#define __cplusplus 199711L
 // CXX98:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -fdeprecated-macro -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix DEPRECATED %s
 //
 // DEPRECATED:#define __DEPRECATED 1
 //
-// 
+//
 // RUN: %clang_cc1 -std=c99 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C99 %s
 //
 // C99:#define __STDC_VERSION__ 199901L
@@ -71,7 +71,7 @@
 // C99-NOT: __GXX_WEAK__
 // C99-NOT: __cplusplus
 //
-// 
+//
 // RUN: %clang_cc1 -std=c11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
 // RUN: %clang_cc1 -std=c1x -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
 // RUN: %clang_cc1 -std=iso9899:2011 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
@@ -86,7 +86,7 @@
 // C11-NOT: __GXX_WEAK__
 // C11-NOT: __cplusplus
 //
-// 
+//
 // RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix COMMON %s
 //
 // COMMON:#define __CONSTANT_CFSTRINGS__ 1
@@ -113,7 +113,7 @@
 // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -triple=x86_64-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -triple=armv7a-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
-// 
+//
 // C-DEFAULT:#define __STDC_VERSION__ 201112L
 //
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
@@ -158,12 +158,12 @@
 // GXX98:#define __cplusplus 199711L
 // GXX98:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -std=iso9899:199409 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C94 %s
 //
 // C94:#define __STDC_VERSION__ 199409L
 //
-// 
+//
 // RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT %s
 //
 // MSEXT-NOT:#define __STDC__
@@ -185,7 +185,7 @@
 // MSEXT-CXX-NOWCHAR-NOT:#define _WCHAR_T_DEFINED 1
 // MSEXT-CXX-NOWCHAR:#define __BOOL_DEFINED 1
 //
-// 
+//
 // RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJC %s
 //
 // OBJC:#define OBJC_NEW_PROPERTIES 1
@@ -197,7 +197,7 @@
 //
 // OBJCGC:#define __OBJC_GC__ 1
 //
-// 
+//
 // RUN: %clang_cc1 -x objective-c -fobjc-exceptions -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NONFRAGILE %s
 //
 // NONFRAGILE:#define OBJC_ZEROCOST_EXCEPTIONS 1
@@ -246,9 +246,9 @@
 //
 // PASCAL:#define __PASCAL_STRINGS__ 1
 //
-// 
+//
 // RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix SCHAR %s
-// 
+//
 // SCHAR:#define __STDC__ 1
 // SCHAR-NOT:#define __UNSIGNED_CHAR__
 // SCHAR:#define __clang__ 1
@@ -7978,6 +7978,7 @@
 // X86_64:#define __WINT_WIDTH__ 32
 // X86_64:#define __amd64 1
 // X86_64:#define __amd64__ 1
+// X86_64:#define __code_model_small_ 1
 // X86_64:#define __x86_64 1
 // X86_64:#define __x86_64__ 1
 //
@@ -7987,7 +7988,10 @@
 // X86_64H:#define __x86_64__ 1
 // X86_64H:#define __x86_64h 1
 // X86_64H:#define __x86_64h__ 1
-
+//
+// RUN: %clang -xc - -E -dM -mcmodel=medium --target=i386-unknown-linux < /dev/null | FileCheck -match-full-lines -check-prefix X86_MEDIUM %s
+// X86_MEDIUM:#define __code_model_medium_ 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -match-full-lines -check-prefix X32 %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -match-full-lines -check-prefix X32 -check-prefix X32-CXX %s
 //
@@ -9830,16 +9834,16 @@
 // AVR:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
 // AVR:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1
 // AVR:#define __GXX_ABI_VERSION 1002
-// AVR:#define __INT16_C_SUFFIX__ 
+// AVR:#define __INT16_C_SUFFIX__
 // AVR:#define __INT16_MAX__ 32767
 // AVR:#define __INT16_TYPE__ short
 // AVR:#define __INT32_C_SUFFIX__ L
 // AVR:#define __INT32_MAX__ 2147483647L
 // AVR:#define __INT32_TYPE__ long int
 // AVR:#define __INT64_C_SUFFIX__ LL
 // AVR:#define __INT64_MAX__ 9223372036854775807LL
 // AVR:#define __INT64_TYPE__ long long int
-/

[PATCH] D52920: Introduce code_model macros

2018-10-08 Thread Ali Tamur via Phabricator via cfe-commits
tamur added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:865
+  if (CodeModel == "default")
+// When the user has not explicitly specified anything,
+// the default code model to use is small.

MaskRay wrote:
> I'm not sure if the comment is useful here... or you can comment that this 
> piece of code should be consistent with X86TargetMachine.cpp#L208
I removed the comment, Done. What I had wanted was to explain why we have a 
__code_model_small_ macro, not e.g. __code_model_default_ macro, but maybe it 
will be obvious to future readers.


Repository:
  rC Clang

https://reviews.llvm.org/D52920



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


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

2018-10-08 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In https://reviews.llvm.org/D52971#1257702, @JonasToth wrote:

> I think it would make sense to migrate one test already, to use the new 
> capability


This change was inspired by Roman Lebedev (lebedev.ri), so we expect him to 
provide us with such a test soon ;-)


https://reviews.llvm.org/D52971



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


[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes

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

In https://reviews.llvm.org/D52971#1258086, @zinovy.nis wrote:

> In https://reviews.llvm.org/D52971#1257702, @JonasToth wrote:
>
> > I think it would make sense to migrate one test already, to use the new 
> > capability
>
>
> This change was inspired by @lebedev.ri, so we expect him to provide us with 
> such a test soon ;-)


This will hopefully deduplicate some check lines in 
https://reviews.llvm.org/D52771 
`test/clang-tidy/misc-non-private-member-variables-in-classes.cpp`


https://reviews.llvm.org/D52971



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


[PATCH] D52445: [Index] Use locations to uniquify function-scope BindingDecl USR

2018-10-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 168704.
MaskRay added a comment.

Use isLocal


Repository:
  rC Clang

https://reviews.llvm.org/D52445

Files:
  lib/Index/USRGeneration.cpp
  test/Index/Core/index-source.cpp


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -1,4 +1,5 @@
 // RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target 
x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s 
-std=c++1z -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=LOCAL %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def 
| rel: 0
 class Cls { public:
@@ -493,6 +494,7 @@
 // CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont 
| rel: 1
 // CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
 // CHECK-NOT: localBinding
+// LOCAL: [[@LINE-4]]:9 | variable(local)/C++ | localBinding1 | 
c:index-source.cpp@25382@N@cpp17structuredBinding@F@localStructuredBindingAndRef#@localBinding1
 }
 
 }
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (isLocal(D) && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -1,4 +1,5 @@
 // RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=LOCAL %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def | rel: 0
 class Cls { public:
@@ -493,6 +494,7 @@
 // CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont | rel: 1
 // CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
 // CHECK-NOT: localBinding
+// LOCAL: [[@LINE-4]]:9 | variable(local)/C++ | localBinding1 | c:index-source.cpp@25382@N@cpp17structuredBinding@F@localStructuredBindingAndRef#@localBinding1
 }
 
 }
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (isLocal(D) && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);
___
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-10-08 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D42242#1257428, @mgorny wrote:

> @mclow.lists , ping. Any chance to get a proper version upstream? I'd rather 
> not pull patches from Fedora when we can have something official.


I gave up on this patch several months ago, because no one would say how much 
work it was.
I fixed one place, and was told "here are several others".
I fixed those, and was told "I get some new errors:" (which were completely 
unrelated to the previous problems.


https://reviews.llvm.org/D42242



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


[PATCH] D52937: [clangd] Add clangd.serverInfo command to inspect server state.

2018-10-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Rather than use a `workspace/executeCommand` command, you may consider making 
it a custom request message whose method name starts with `$/`

https://microsoft.github.io/language-server-protocol/specification

> Notification and requests whose methods start with ‘$/’ are messages which 
> are protocol implementation dependent and might not be implementable in all 
> clients or servers. For example if the server implementation uses a single 
> threaded synchronous programming language then there is little a server can 
> do to react to a ‘$/cancelRequest’. If a server or client receives 
> notifications or requests starting with ‘$/’ it is free to ignore them if 
> they are unknown.

The return type of `workspace/executeCommand` is `any | null` per spec, but its 
interpretation may not be that flexible in some clients. It is pretty simple to 
use lsp-mode eglot vscode-languageclient to send custom request messages, 
though.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52937



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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: rnk, kbobyrev, omtcyfz, lebedev.ri, erichkeane.
Herald added a subscriber: mgorny.

Define _HAS_EXCEPTIONS=0, when compiling benchmark files, to disable exceptions 
in Microsoft STL.

Windows builds were failing due to C4530 warnings (C++ exception handler used, 
but unwind semantics are not enabled) thrown by MSVC standard library.


https://reviews.llvm.org/D52998

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -1089,7 +1089,8 @@
   set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in 
benchmark" FORCE)
   # Since LLVM requires C++11 it is safe to assume that std::regex is 
available.
   set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE)
-
+  # Disable exceptions in Microsoft STL to prevent warnings about exception 
handlers in STL.
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_HAS_EXCEPTIONS=0")
   add_subdirectory(utils/benchmark)
   add_subdirectory(benchmarks)
 endif()


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -1089,7 +1089,8 @@
   set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE)
   # Since LLVM requires C++11 it is safe to assume that std::regex is available.
   set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE)
-
+  # Disable exceptions in Microsoft STL to prevent warnings about exception handlers in STL.
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_HAS_EXCEPTIONS=0")
   add_subdirectory(utils/benchmark)
   add_subdirectory(benchmarks)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52854: Use is.constant intrinsic for __builtin_constant_p

2018-10-08 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 168708.
void added a comment.

I updated the patch that implements putting the "can delay evaluation" bit into 
the CallExprBitfields. PTAL.


Repository:
  rC Clang

https://reviews.llvm.org/D52854

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseInit.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/builtin-functions.cpp
  test/Sema/builtins.c

Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -122,6 +122,14 @@
  __builtin_constant_p(1, 2); // expected-error {{too many arguments}}
 }
 
+// __builtin_constant_p cannot resolve non-constants such as a file scoped array.
+int expr;
+char y[__builtin_constant_p(expr) ? -1 : 1]; // no warning, the builtin is false.
+
+// no warning, the builtin is false.
+struct foo { int a; };
+struct foo x = (struct foo) { __builtin_constant_p(42) ? 37 : 927 };
+
 const int test17_n = 0;
 const char test17_c[] = {1, 2, 3, 0};
 const char test17_d[] = {1, 2, 3, 4};
@@ -168,14 +176,17 @@
   // a builtin.
   ASSERT(OPT("abc"));
   ASSERT(!OPT("abcd"));
+
   // In these cases, the strlen is non-constant, but the __builtin_constant_p
-  // is 0: the array size is not an ICE but is foldable.
-  ASSERT(!OPT(test17_c));// expected-warning {{folded}}
+  // is 0: the array size is not an ICE.
+  ASSERT(!OPT(test17_c));// no warning expected
+  ASSERT(!OPT((char*)test17_c)); // no warning expected
+  ASSERT(!OPT(test17_d));// no warning expected
+  ASSERT(!OPT((char*)test17_d)); // no warning expected
+
+  // These are foldable.
   ASSERT(!OPT(&test17_c[0]));// expected-warning {{folded}}
-  ASSERT(!OPT((char*)test17_c)); // expected-warning {{folded}}
-  ASSERT(!OPT(test17_d));// expected-warning {{folded}}
   ASSERT(!OPT(&test17_d[0]));// expected-warning {{folded}}
-  ASSERT(!OPT((char*)test17_d)); // expected-warning {{folded}}
 
 #undef OPT
 #undef T
@@ -287,3 +298,22 @@
   memcpy(buf, src, 11); // expected-warning{{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
   my_memcpy(buf, src, 11); // expected-warning{{'__builtin___memcpy_chk' will always overflow; destination buffer has size 10, but size argument is 11}}
 }
+
+size_t test24(int a) {
+  char x[__builtin_constant_p(a) ? -1 : 1]; // no warning expected
+  return strlen(x);
+}
+
+__attribute__((always_inline))
+size_t test25(int a) {
+  char x[__builtin_constant_p(a) ? 1 : -1]; // no warning expected
+  return strlen(x);
+}
+
+size_t test26() {
+  return test25(2);
+}
+
+void f(int n) {
+  enum E { a = __builtin_constant_p(n) }; // ok, a == 0, not an error because a's value is non-constant
+}
Index: test/Analysis/builtin-functions.cpp
===
--- test/Analysis/builtin-functions.cpp
+++ test/Analysis/builtin-functions.cpp
@@ -70,7 +70,7 @@
   const int j = 2;
   constexpr int k = 3;
   clang_analyzer_eval(__builtin_constant_p(42) == 1); // expected-warning {{TRUE}}
-  clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{TRUE}}
+  clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{UNKNOWN}}
   clang_analyzer_eval(__builtin_constant_p(j) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(k) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(i + 42) == 0); // expected-warning {{TRUE}}
@@ -77,7 +77,7 @@
   clang_analyzer_eval(__builtin_constant_p(j + 42) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(k + 42) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(" ") == 1); // expected-warning {{TRUE}}
-  clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{TRUE}}
+  clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{UNKNOWN}}
   clang_analyzer_eval(__builtin_constant_p(k - 3) == 0); // expected-warning {{FALSE}}
   clang_analyzer_eval(__builtin_constant_p(k - 3) == 1); // expected-warning {{TRUE}}
 }
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -590,6 +590,7 @@
 void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
   VisitExpr(E);
   Record.push_back(E->getNumArgs());
+  Record.push_back(E->getCanDelayEvaluation());
   Record.AddSourceLocation(E->getRParenLoc());
   Record.AddStmt(E->getCallee());
   for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Index: lib/Serialization/ASTReaderStmt.cpp

[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

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

Are those warnings about C++ exceptions, or some windows-specific exception 
stuff?
It seems the C++ exceptions are used in tests e.g.
https://github.com/google/benchmark/search?q=throw&unscoped_q=throw
https://github.com/google/benchmark/search?q=catch&unscoped_q=catch


https://reviews.llvm.org/D52998



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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

I do not think defining _HAS_EXCEPTIONS=0 affects C++ exceptions in the 
application. I thought it only affected the STL. I will verify this and update 
you.


https://reviews.llvm.org/D52998



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


Re: [PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-08 Thread Zachary Turner via cfe-commits
`_HAS_EXCEPTIONS=0` is an undocumented STL specific thing that the library
implementation uses to mean "don't write code that does `throw X;`, do
something else instead".

On Mon, Oct 8, 2018 at 2:27 PM Elizabeth Andrews via Phabricator <
revi...@reviews.llvm.org> wrote:

> eandrews added a comment.
>
> I do not think defining _HAS_EXCEPTIONS=0 affects C++ exceptions in the
> application. I thought it only affected the STL. I will verify this and
> update you.
>
>
> https://reviews.llvm.org/D52998
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-08 Thread Zachary Turner via Phabricator via cfe-commits
zturner added subscribers: eandrews, zturner.
zturner added a comment.

`_HAS_EXCEPTIONS=0` is an undocumented STL specific thing that the library
implementation uses to mean "don't write code that does `throw X;`, do
something else instead".


https://reviews.llvm.org/D52998



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


[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-08 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:266
+  // directives in the object files, but the static library needs
+  // -lpsapi unless the sanitizer was built targeting >= win7.
+  CmdArgs.push_back("-lpsapi");

Isn't Windows 7 our minimum supported Windows version anyway? I can't find the 
documentation pointing to that, but I thought that was the policy. In 
particular, we require VS 2015 or above, which doesn't support anything older 
than Server 2008 anyway (including Vista and XP), and I doubt we'd have anyone 
using Server 2008.


Repository:
  rC Clang

https://reviews.llvm.org/D52990



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


[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:266
+  // directives in the object files, but the static library needs
+  // -lpsapi unless the sanitizer was built targeting >= win7.
+  CmdArgs.push_back("-lpsapi");

smeenai wrote:
> Isn't Windows 7 our minimum supported Windows version anyway? I can't find 
> the documentation pointing to that, but I thought that was the policy. In 
> particular, we require VS 2015 or above, which doesn't support anything older 
> than Server 2008 anyway (including Vista and XP), and I doubt we'd have 
> anyone using Server 2008.
For llvm itself, yes, but this is for the runtimes. Or does the policy cover 
that as well?

Mingw upstream still(!) default to supporting xp onwards, while I'm configuring 
my own setups to default to vista. I guess making that 7 wouldn't be too much 
of an issue though.

FWIW, I included a corresponding change for ASAN here: 
https://reviews.llvm.org/rCRT343074, in adding a `append_list_if(MINGW psapi 
ASAN_DYNAMIC_LIBS)` in compiler-rt/trunk/lib/asan/CMakeLists.txt.


Repository:
  rC Clang

https://reviews.llvm.org/D52990



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


[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:266
+  // directives in the object files, but the static library needs
+  // -lpsapi unless the sanitizer was built targeting >= win7.
+  CmdArgs.push_back("-lpsapi");

mstorsjo wrote:
> smeenai wrote:
> > Isn't Windows 7 our minimum supported Windows version anyway? I can't find 
> > the documentation pointing to that, but I thought that was the policy. In 
> > particular, we require VS 2015 or above, which doesn't support anything 
> > older than Server 2008 anyway (including Vista and XP), and I doubt we'd 
> > have anyone using Server 2008.
> For llvm itself, yes, but this is for the runtimes. Or does the policy cover 
> that as well?
> 
> Mingw upstream still(!) default to supporting xp onwards, while I'm 
> configuring my own setups to default to vista. I guess making that 7 wouldn't 
> be too much of an issue though.
> 
> FWIW, I included a corresponding change for ASAN here: 
> https://reviews.llvm.org/rCRT343074, in adding a `append_list_if(MINGW psapi 
> ASAN_DYNAMIC_LIBS)` in compiler-rt/trunk/lib/asan/CMakeLists.txt.
I think most of our policies have to do with LLVM's own build requirements. 
Clang has supported targeting older OSs for a while, and we shouldn't 
intentionally break it, at least. We probably don't want to support running the 
sanitizers on old Windows OSs, since they tend to want to use modern OS APIs. 
For example, I used the slim reader writer lock APIs in ASan to fix a race.

In any case, do you think it would be nicer to put this directive in the ubsan 
object files that use psapi? It seems lame for clang to have to know about what 
libraries the sanitizers use.


Repository:
  rC Clang

https://reviews.llvm.org/D52990



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


[PATCH] D52854: Use is.constant intrinsic for __builtin_constant_p

2018-10-08 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 168712.

Repository:
  rC Clang

https://reviews.llvm.org/D52854

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseInit.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/builtin-functions.cpp
  test/Sema/builtins.c

Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -122,6 +122,14 @@
  __builtin_constant_p(1, 2); // expected-error {{too many arguments}}
 }
 
+// __builtin_constant_p cannot resolve non-constants such as a file scoped array.
+int expr;
+char y[__builtin_constant_p(expr) ? -1 : 1]; // no warning, the builtin is false.
+
+// no warning, the builtin is false.
+struct foo { int a; };
+struct foo x = (struct foo) { __builtin_constant_p(42) ? 37 : 927 };
+
 const int test17_n = 0;
 const char test17_c[] = {1, 2, 3, 0};
 const char test17_d[] = {1, 2, 3, 4};
@@ -168,14 +176,17 @@
   // a builtin.
   ASSERT(OPT("abc"));
   ASSERT(!OPT("abcd"));
+
   // In these cases, the strlen is non-constant, but the __builtin_constant_p
-  // is 0: the array size is not an ICE but is foldable.
-  ASSERT(!OPT(test17_c));// expected-warning {{folded}}
+  // is 0: the array size is not an ICE.
+  ASSERT(!OPT(test17_c));// no warning expected
+  ASSERT(!OPT((char*)test17_c)); // no warning expected
+  ASSERT(!OPT(test17_d));// no warning expected
+  ASSERT(!OPT((char*)test17_d)); // no warning expected
+
+  // These are foldable.
   ASSERT(!OPT(&test17_c[0]));// expected-warning {{folded}}
-  ASSERT(!OPT((char*)test17_c)); // expected-warning {{folded}}
-  ASSERT(!OPT(test17_d));// expected-warning {{folded}}
   ASSERT(!OPT(&test17_d[0]));// expected-warning {{folded}}
-  ASSERT(!OPT((char*)test17_d)); // expected-warning {{folded}}
 
 #undef OPT
 #undef T
@@ -287,3 +298,22 @@
   memcpy(buf, src, 11); // expected-warning{{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
   my_memcpy(buf, src, 11); // expected-warning{{'__builtin___memcpy_chk' will always overflow; destination buffer has size 10, but size argument is 11}}
 }
+
+size_t test24(int a) {
+  char x[__builtin_constant_p(a) ? -1 : 1]; // no warning expected
+  return strlen(x);
+}
+
+__attribute__((always_inline))
+size_t test25(int a) {
+  char x[__builtin_constant_p(a) ? 1 : -1]; // no warning expected
+  return strlen(x);
+}
+
+size_t test26() {
+  return test25(2);
+}
+
+void f(int n) {
+  enum E { a = __builtin_constant_p(n) }; // ok, a == 0, not an error because a's value is non-constant
+}
Index: test/Analysis/builtin-functions.cpp
===
--- test/Analysis/builtin-functions.cpp
+++ test/Analysis/builtin-functions.cpp
@@ -70,14 +70,14 @@
   const int j = 2;
   constexpr int k = 3;
   clang_analyzer_eval(__builtin_constant_p(42) == 1); // expected-warning {{TRUE}}
-  clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{TRUE}}
+  clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{UNKNOWN}}
   clang_analyzer_eval(__builtin_constant_p(j) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(k) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(i + 42) == 0); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(j + 42) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(k + 42) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(" ") == 1); // expected-warning {{TRUE}}
-  clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{TRUE}}
+  clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{UNKNOWN}}
   clang_analyzer_eval(__builtin_constant_p(k - 3) == 0); // expected-warning {{FALSE}}
   clang_analyzer_eval(__builtin_constant_p(k - 3) == 1); // expected-warning {{TRUE}}
 }
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -590,6 +590,7 @@
 void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
   VisitExpr(E);
   Record.push_back(E->getNumArgs());
+  Record.push_back(E->getCanDelayEvaluation());
   Record.AddSourceLocation(E->getRParenLoc());
   Record.AddStmt(E->getCallee());
   for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -679,6 +679,7 @@
 void ASTStmtReader::VisitCall

[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

Thanks for the information Zachary.

@lebedev.ri  I do not know how benchmark library developers need/want to handle 
exceptions in MSVC STL.  If these need to be enabled when 
BENCHMARK_ENABLE_EXCEPTIONS is true,  I think we can just modify 
_HAS_EXCEPTIONS in utils/benchmark/CMakeLists.txt.


https://reviews.llvm.org/D52998



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


[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-08 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:266
+  // directives in the object files, but the static library needs
+  // -lpsapi unless the sanitizer was built targeting >= win7.
+  CmdArgs.push_back("-lpsapi");

rnk wrote:
> mstorsjo wrote:
> > smeenai wrote:
> > > Isn't Windows 7 our minimum supported Windows version anyway? I can't 
> > > find the documentation pointing to that, but I thought that was the 
> > > policy. In particular, we require VS 2015 or above, which doesn't support 
> > > anything older than Server 2008 anyway (including Vista and XP), and I 
> > > doubt we'd have anyone using Server 2008.
> > For llvm itself, yes, but this is for the runtimes. Or does the policy 
> > cover that as well?
> > 
> > Mingw upstream still(!) default to supporting xp onwards, while I'm 
> > configuring my own setups to default to vista. I guess making that 7 
> > wouldn't be too much of an issue though.
> > 
> > FWIW, I included a corresponding change for ASAN here: 
> > https://reviews.llvm.org/rCRT343074, in adding a `append_list_if(MINGW 
> > psapi ASAN_DYNAMIC_LIBS)` in compiler-rt/trunk/lib/asan/CMakeLists.txt.
> I think most of our policies have to do with LLVM's own build requirements. 
> Clang has supported targeting older OSs for a while, and we shouldn't 
> intentionally break it, at least. We probably don't want to support running 
> the sanitizers on old Windows OSs, since they tend to want to use modern OS 
> APIs. For example, I used the slim reader writer lock APIs in ASan to fix a 
> race.
> 
> In any case, do you think it would be nicer to put this directive in the 
> ubsan object files that use psapi? It seems lame for clang to have to know 
> about what libraries the sanitizers use.
Ah, I wasn't thinking of the LLVM/runtimes distinction. SRWLocks would require 
Vista and above though, and at that point just going for 7 and above would make 
sense.

This is a bit orthogonal to the patch though, so sorry for side-tracking 
things. +1 for Reid's suggestion of embedding the psapi directive in object 
files.


Repository:
  rC Clang

https://reviews.llvm.org/D52990



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


Re: [libcxx] r342073 - Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955

2018-10-08 Thread Marshall Clow via cfe-commits
On Thu, Oct 4, 2018 at 8:41 AM Richard Smith  wrote:

> Perhaps libc++ could provide a __version file that contains the headers,
> and use #include <__version> internally? We'd still need a  header
> that just includes <__version> for conformance, but that should be after
> user headers on the include path so shouldn't break things.
>

We can do this - but I'm not sure we would be doing anyone any favors in
the long run by doing so.

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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-08 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

It's not enough to just set `_HAS_EXCEPTIONS=1`, it has to match whatever the 
value of `/EH` is passed to the compiler.  So if we need to be able to throw 
catch exceptions, then you should pass `/EHsc` and not touch `_HAS_EXCEPTIONS` 
(technically you could set it to 1 but that's the default).  And if we don't 
need to be able to throw or catch exceptions, then we pass `/EHs-c-` (which is 
what we do today) and also set `_HAS_EXCEPTIONS=0`.  But the two should agree 
with each other.


https://reviews.llvm.org/D52998



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


[PATCH] D53001: [DRIVER] check for exit code from SIGPIPE

2018-10-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: jfb.
Herald added a subscriber: cfe-commits.

https://reviews.llvm.org/D53000 adds a special exit code for SIGPIPE (writing 
to a closed
reader), and rather than print a fatal warning, skips printing the
error.

Fixes PR25349, rdar://problem/14285346, b/77310947.


Repository:
  rC Clang

https://reviews.llvm.org/D53001

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1401,6 +1401,11 @@
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == 71)
+  continue;
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1401,6 +1401,11 @@
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == 71)
+  continue;
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:266
+  // directives in the object files, but the static library needs
+  // -lpsapi unless the sanitizer was built targeting >= win7.
+  CmdArgs.push_back("-lpsapi");

smeenai wrote:
> rnk wrote:
> > mstorsjo wrote:
> > > smeenai wrote:
> > > > Isn't Windows 7 our minimum supported Windows version anyway? I can't 
> > > > find the documentation pointing to that, but I thought that was the 
> > > > policy. In particular, we require VS 2015 or above, which doesn't 
> > > > support anything older than Server 2008 anyway (including Vista and 
> > > > XP), and I doubt we'd have anyone using Server 2008.
> > > For llvm itself, yes, but this is for the runtimes. Or does the policy 
> > > cover that as well?
> > > 
> > > Mingw upstream still(!) default to supporting xp onwards, while I'm 
> > > configuring my own setups to default to vista. I guess making that 7 
> > > wouldn't be too much of an issue though.
> > > 
> > > FWIW, I included a corresponding change for ASAN here: 
> > > https://reviews.llvm.org/rCRT343074, in adding a `append_list_if(MINGW 
> > > psapi ASAN_DYNAMIC_LIBS)` in compiler-rt/trunk/lib/asan/CMakeLists.txt.
> > I think most of our policies have to do with LLVM's own build requirements. 
> > Clang has supported targeting older OSs for a while, and we shouldn't 
> > intentionally break it, at least. We probably don't want to support running 
> > the sanitizers on old Windows OSs, since they tend to want to use modern OS 
> > APIs. For example, I used the slim reader writer lock APIs in ASan to fix a 
> > race.
> > 
> > In any case, do you think it would be nicer to put this directive in the 
> > ubsan object files that use psapi? It seems lame for clang to have to know 
> > about what libraries the sanitizers use.
> Ah, I wasn't thinking of the LLVM/runtimes distinction. SRWLocks would 
> require Vista and above though, and at that point just going for 7 and above 
> would make sense.
> 
> This is a bit orthogonal to the patch though, so sorry for side-tracking 
> things. +1 for Reid's suggestion of embedding the psapi directive in object 
> files.
> We probably don't want to support running the sanitizers on old Windows OSs, 
> since they tend to want to use modern OS APIs. For example, I used the slim 
> reader writer lock APIs in ASan to fix a race.

Yes, I've tried to keep things simple by requiring Vista in a number of other 
places as well, especially for SRWLocks and other threading related things. 
Since Vista is pretty much extinct, requiring 7 wouldn't be that big of a 
change though. I have no intention of trying to support sanitizers on anything 
older than that.

> In any case, do you think it would be nicer to put this directive in the 
> ubsan object files that use psapi? It seems lame for clang to have to know 
> about what libraries the sanitizers use.

It would definitely be nicer - I'll have a shot at doing that.


Repository:
  rC Clang

https://reviews.llvm.org/D52990



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


r344000 - Introduce code_model macros

2018-10-08 Thread Ali Tamur via cfe-commits
Author: tamur
Date: Mon Oct  8 15:25:20 2018
New Revision: 344000

URL: http://llvm.org/viewvc/llvm-project?rev=344000&view=rev
Log:
Introduce code_model macros

Summary:
gcc defines macros such as __code_model_small_ based on the user passed command 
line flag -mcmodel. clang accepts a flag with the same name and similar 
effects, but does not generate any macro that the user can use. This cl narrows 
the gap between gcc and clang behaviour.

However, achieving full compatibility with gcc is not trivial: The set of valid 
values for mcmodel in gcc and clang are not equal. Also, gcc defines different 
macros for different architectures. In this cl, we only tackle an easy part of 
the problem and define the macro only for x64 architecture. When the user does 
not specify a mcmodel, the macro for small code model is produced, as is the 
case with gcc.

Reviewers: compnerd, MaskRay

Reviewed By: MaskRay

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/TargetOptions.h
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=344000&r1=343999&r2=344000&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Mon Oct  8 15:25:20 2018
@@ -67,6 +67,12 @@ public:
   /// \brief If enabled, use 32-bit pointers for accessing const/local/shared
   /// address space.
   bool NVPTXUseShortPointers = false;
+
+  // The code model to be used as specified by the user. Corresponds to
+  // CodeModel::Model enum defined in include/llvm/Support/CodeGen.h, plus
+  // "default" for the case when the user has not explicitly specified a
+  // code model.
+  std::string CodeModel;
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=344000&r1=343999&r2=344000&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Mon Oct  8 15:25:20 2018
@@ -860,6 +860,11 @@ bool X86TargetInfo::handleTargetFeatures
 /// definitions for this particular subtarget.
 void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
+  std::string CodeModel = getTargetOpts().CodeModel;
+  if (CodeModel == "default")
+CodeModel = "small";
+  Builder.defineMacro("__code_model_" + CodeModel + "_");
+
   // Target identification.
   if (getTriple().getArch() == llvm::Triple::x86_64) {
 Builder.defineMacro("__amd64__");

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=344000&r1=343999&r2=344000&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Oct  8 15:25:20 2018
@@ -669,7 +669,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.RegisterGlobalDtorsWithAtExit =
   Args.hasArg(OPT_fregister_global_dtors_with_atexit);
   Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
-  Opts.CodeModel = getCodeModel(Args, Diags);
+  Opts.CodeModel = TargetOpts.CodeModel;
   Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
   Opts.DisableFPElim =
   (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
@@ -2975,6 +2975,7 @@ static void ParsePreprocessorOutputArgs(
 
 static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
 DiagnosticsEngine &Diags) {
+  Opts.CodeModel = getCodeModel(Args, Diags);
   Opts.ABI = Args.getLastArgValue(OPT_target_abi);
   if (Arg *A = Args.getLastArg(OPT_meabi)) {
 StringRef Value = A->getValue();

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=344000&r1=343999&r2=344000&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Oct  8 15:25:20 2018
@@ -47,21 +47,21 @@
 // CXX11:#define __cplusplus 201103L
 // CXX11:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck 
-match-full-lines -check-prefix CXX98 %s
-// 
+//
 // CXX98:#define __GNUG__ {{.*}}
 // CXX98:#define __GXX_RTTI 1
 // CXX98:#define __GXX_WEAK__ 1
 // CXX98:#define __cplusplus 199711L
 // CXX98:#define __private_extern__ extern
 //
-// 
+//
 // RU

Re: [clang-tools-extra] r* - [clangd]*

2018-10-08 Thread Artem Dergachev via cfe-commits

Hi all,

Just wanted to attract attention to the clangd test failure at 
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/12782/


Buildbots were down recently, so I guess this one was very easy to miss.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52920: Introduce code_model macros

2018-10-08 Thread Ali Tamur via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344000: Introduce code_model macros (authored by tamur, 
committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52920

Files:
  cfe/trunk/include/clang/Basic/TargetOptions.h
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/include/clang/Basic/TargetOptions.h
===
--- cfe/trunk/include/clang/Basic/TargetOptions.h
+++ cfe/trunk/include/clang/Basic/TargetOptions.h
@@ -67,6 +67,12 @@
   /// \brief If enabled, use 32-bit pointers for accessing const/local/shared
   /// address space.
   bool NVPTXUseShortPointers = false;
+
+  // The code model to be used as specified by the user. Corresponds to
+  // CodeModel::Model enum defined in include/llvm/Support/CodeGen.h, plus
+  // "default" for the case when the user has not explicitly specified a
+  // code model.
+  std::string CodeModel;
 };
 
 }  // end namespace clang
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -47,21 +47,21 @@
 // CXX11:#define __cplusplus 201103L
 // CXX11:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX98 %s
-// 
+//
 // CXX98:#define __GNUG__ {{.*}}
 // CXX98:#define __GXX_RTTI 1
 // CXX98:#define __GXX_WEAK__ 1
 // CXX98:#define __cplusplus 199711L
 // CXX98:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -fdeprecated-macro -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix DEPRECATED %s
 //
 // DEPRECATED:#define __DEPRECATED 1
 //
-// 
+//
 // RUN: %clang_cc1 -std=c99 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C99 %s
 //
 // C99:#define __STDC_VERSION__ 199901L
@@ -71,7 +71,7 @@
 // C99-NOT: __GXX_WEAK__
 // C99-NOT: __cplusplus
 //
-// 
+//
 // RUN: %clang_cc1 -std=c11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
 // RUN: %clang_cc1 -std=c1x -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
 // RUN: %clang_cc1 -std=iso9899:2011 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
@@ -86,7 +86,7 @@
 // C11-NOT: __GXX_WEAK__
 // C11-NOT: __cplusplus
 //
-// 
+//
 // RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix COMMON %s
 //
 // COMMON:#define __CONSTANT_CFSTRINGS__ 1
@@ -113,7 +113,7 @@
 // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -triple=x86_64-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -triple=armv7a-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
-// 
+//
 // C-DEFAULT:#define __STDC_VERSION__ 201112L
 //
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
@@ -158,12 +158,12 @@
 // GXX98:#define __cplusplus 199711L
 // GXX98:#define __private_extern__ extern
 //
-// 
+//
 // RUN: %clang_cc1 -std=iso9899:199409 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C94 %s
 //
 // C94:#define __STDC_VERSION__ 199409L
 //
-// 
+//
 // RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT %s
 //
 // MSEXT-NOT:#define __STDC__
@@ -185,7 +185,7 @@
 // MSEXT-CXX-NOWCHAR-NOT:#define _WCHAR_T_DEFINED 1
 // MSEXT-CXX-NOWCHAR:#define __BOOL_DEFINED 1
 //
-// 
+//
 // RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJC %s
 //
 // OBJC:#define OBJC_NEW_PROPERTIES 1
@@ -197,7 +197,7 @@
 //
 // OBJCGC:#define __OBJC_GC__ 1
 //
-// 
+//
 // RUN: %clang_cc1 -x objective-c -fobjc-exceptions -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NONFRAGILE %s
 //
 // NONFRAGILE:#define OBJC_ZEROCOST_EXCEPTIONS 1
@@ -246,9 +246,9 @@
 //
 // PASCAL:#define __PASCAL_STRINGS__ 1
 //
-// 
+//
 // RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix SCHAR %s
-// 
+//
 // SCHAR:#define __STDC__ 1
 // SCHAR-NOT:#define __UNSIGNED_CHAR__
 // SCHAR:#define __clang__ 1
@@ -7978,6 +7978,7 @@
 // X86_64:#define __WINT_WIDTH__ 32
 // X86_64:#define __amd64 1
 // X86_64:#define __amd64__ 1
+// X86_64:#define __code_model_small_ 1
 // X86_64:#define __x86_64 1
 // X86_64:#define __x86_64__ 1
 //
@@ -7987,7 +7988,10 @@
 // X86_64H:#define __x86_64__ 1
 // X86_64H:#define __x86_64h 1
 // X86_64H:#define __x86_64h__ 1
-
+//
+// RUN: %clang -xc - -E -dM -mcmodel=medium --target=i386-unknown-linux < /dev/null | FileCheck -match-full-lines -check-prefix X86_MEDIUM %s
+// X86

[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

What's the return code of the driver when the pipe is broken that way?




Comment at: lib/Driver/Driver.cpp:1406
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == 71)
+  continue;

Ditto on magical number in a header.



Comment at: lib/Driver/Driver.cpp:1406
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == 71)
+  continue;

jfb wrote:
> Ditto on magical number in a header.
I think you want to create a new diagnostic here for "broken pipe" before the 
`continue`.


Repository:
  rC Clang

https://reviews.llvm.org/D53001



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


[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lib/Driver/Driver.cpp:1406
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == 71)
+  continue;

jfb wrote:
> jfb wrote:
> > Ditto on magical number in a header.
> I think you want to create a new diagnostic here for "broken pipe" before the 
> `continue`.
Won't the diagnostic always be printed then? I thought we were trying to 
silence all related warnings?


Repository:
  rC Clang

https://reviews.llvm.org/D53001



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


[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: lib/Driver/Driver.cpp:1406
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == 71)
+  continue;

nickdesaulniers wrote:
> jfb wrote:
> > jfb wrote:
> > > Ditto on magical number in a header.
> > I think you want to create a new diagnostic here for "broken pipe" before 
> > the `continue`.
> Won't the diagnostic always be printed then? I thought we were trying to 
> silence all related warnings?
It is an error that I think we want to report, but we don't want to ask for a 
bug report. So I think we want to avoid printing the long bug report error 
message, but we want to say "Broken pipe" which seems to be the standard Unix 
thing to do.

Not my area of expertise though, maybe someone has a different opinion?


Repository:
  rC Clang

https://reviews.llvm.org/D53001



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


[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Just to be sure: what's the exit code from the driver? If we don't diagnose I'm 
fine with it... but the exit code still needs to reflect the failure!


Repository:
  rC Clang

https://reviews.llvm.org/D53001



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


[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 168728.
nickdesaulniers added a comment.

- prefer EX_IOERR from sysexits.h


Repository:
  rC Clang

https://reviews.llvm.org/D53001

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -77,6 +77,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
@@ -1401,6 +1402,11 @@
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == EX_IOERR)
+  continue;
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -77,6 +77,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
@@ -1401,6 +1402,11 @@
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (Res == EX_IOERR)
+  continue;
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 168733.
nickdesaulniers added a comment.

- return error code 74 (EX_IOERR) if observed


Repository:
  rC Clang

https://reviews.llvm.org/D53001

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -77,6 +77,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
@@ -1387,20 +1388,28 @@
 
   // Otherwise, remove result files and print extra information about abnormal
   // failures.
+  int Res = 0;
   for (const auto &CmdPair : FailingCommands) {
-int Res = CmdPair.first;
+int CommandRes = CmdPair.first;
 const Command *FailingCommand = CmdPair.second;
 
 // Remove result files if we're not saving temps.
 if (!isSaveTempsEnabled()) {
   const JobAction *JA = cast(&FailingCommand->getSource());
   C.CleanupFileMap(C.getResultFiles(), JA, true);
 
   // Failure result files are valid unless we crashed.
-  if (Res < 0)
+  if (CommandRes < 0)
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (CommandRes == EX_IOERR) {
+  Res = CommandRes;
+  continue;
+}
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
@@ -1410,17 +1419,17 @@
 // diagnostics, so always print the diagnostic there.
 const Tool &FailingTool = FailingCommand->getCreator();
 
-if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) {
+if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) 
{
   // FIXME: See FIXME above regarding result code interpretation.
-  if (Res < 0)
+  if (CommandRes < 0)
 Diag(clang::diag::err_drv_command_signalled)
 << FailingTool.getShortName();
   else
-Diag(clang::diag::err_drv_command_failed) << FailingTool.getShortName()
-  << Res;
+Diag(clang::diag::err_drv_command_failed)
+<< FailingTool.getShortName() << CommandRes;
 }
   }
-  return 0;
+  return Res;
 }
 
 void Driver::PrintHelp(bool ShowHidden) const {


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -77,6 +77,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
 #include 
 #if LLVM_ON_UNIX
 #include  // getpid
@@ -1387,20 +1388,28 @@
 
   // Otherwise, remove result files and print extra information about abnormal
   // failures.
+  int Res = 0;
   for (const auto &CmdPair : FailingCommands) {
-int Res = CmdPair.first;
+int CommandRes = CmdPair.first;
 const Command *FailingCommand = CmdPair.second;
 
 // Remove result files if we're not saving temps.
 if (!isSaveTempsEnabled()) {
   const JobAction *JA = cast(&FailingCommand->getSource());
   C.CleanupFileMap(C.getResultFiles(), JA, true);
 
   // Failure result files are valid unless we crashed.
-  if (Res < 0)
+  if (CommandRes < 0)
 C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
 }
 
+// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
+// for SIGPIPE. Do not print diagnostics for this case.
+if (CommandRes == EX_IOERR) {
+  Res = CommandRes;
+  continue;
+}
+
 // Print extra information about abnormal failures, if possible.
 //
 // This is ad-hoc, but we don't want to be excessively noisy. If the result
@@ -1410,17 +1419,17 @@
 // diagnostics, so always print the diagnostic there.
 const Tool &FailingTool = FailingCommand->getCreator();
 
-if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) {
+if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) {
   // FIXME: See FIXME above regarding result code interpretation.
-  if (Res < 0)
+  if (CommandRes < 0)
 Diag(clang::diag::err_drv_command_signalled)
 << FailingTool.getShortName();
   else
-Diag(clang::diag::err_drv_command_failed) << FailingTool.getShortName()
-  << Res;
+Diag(clang::diag::err_drv_command_failed)
+<< FailingTool.getShortName() << CommandRes;
 }
   }
-  return 0;
+  return Res;
 }
 
 void Driver::PrintHelp(bool ShowHidden) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53001: [Driver] check for exit code from SIGPIPE

2018-10-08 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added a comment.
This revision is now accepted and ready to land.

Digging through `tools/driver/driver.cpp` this seems to be the right thing. 
Maybe leave it open for a bit so others can chime in (if say they have other 
drivers or whatever?). Thanks for fixing!


Repository:
  rC Clang

https://reviews.llvm.org/D53001



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


[PATCH] D53007: [WebAssembly][NFC] Rename test functions for builtins

2018-10-08 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: cfe-commits, kristina, jfb, sunfish, 
jgravelle-google, sbc100.

Repository:
  rC Clang

https://reviews.llvm.org/D53007

Files:
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -17,285 +17,285 @@
 typedef float f32x4 __attribute((vector_size(16)));
 typedef double f64x2 __attribute((vector_size(16)));
 
-__SIZE_TYPE__ f0(void) {
+__SIZE_TYPE__ memory_size(void) {
   return __builtin_wasm_memory_size(0);
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0)
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f1(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ memory_grow(__SIZE_TYPE__ delta) {
   return __builtin_wasm_memory_grow(0, delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f2(void) {
+__SIZE_TYPE__ mem_size(void) {
   return __builtin_wasm_mem_size(0);
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.mem.size.i32(i32 0)
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.mem.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f3(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ mem_grow(__SIZE_TYPE__ delta) {
   return __builtin_wasm_mem_grow(0, delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.mem.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f4(void) {
+__SIZE_TYPE__ current_memory(void) {
   return __builtin_wasm_current_memory();
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32()
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64()
 }
 
-__SIZE_TYPE__ f5(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ grow_memory(__SIZE_TYPE__ delta) {
   return __builtin_wasm_grow_memory(delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.grow.memory.i32(i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.grow.memory.i64(i64 %{{.*}})
 }
 
-void f6(unsigned int tag, void *obj) {
+void throw(unsigned int tag, void *obj) {
   return __builtin_wasm_throw(tag, obj);
   // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
   // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 }
 
-void f7(void) {
+void rethrow(void) {
   return __builtin_wasm_rethrow();
   // WEBASSEMBLY32: call void @llvm.wasm.rethrow()
   // WEBASSEMBLY64: call void @llvm.wasm.rethrow()
 }
 
-int f8(int *addr, int expected, long long timeout) {
+int atomic_wait_i32(int *addr, int expected, long long timeout) {
   return __builtin_wasm_atomic_wait_i32(addr, expected, timeout);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}})
 }
 
-int f9(long long *addr, long long expected, long long timeout) {
+int atomic_wait_i64(long long *addr, long long expected, long long timeout) {
   return __builtin_wasm_atomic_wait_i64(addr, expected, timeout);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
 }
 
-unsigned int f10(int *addr, int count) {
+unsigned int atomic_notify(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }
 
-int f11(i8x16 v) {
+int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f12(i8x16 v) {
+int extract_lane_u_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_u_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: zext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f13(i16x8 v) {
+int extract_lane_s_i16x8(i16x8 v) {
   return __builtin_wasm_extract_lane_s_i16x8(v, 7);
   // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f14(i16x8 v) {
+int extract_lane_u_i16x8(i16x8 v) {
   return __builtin_wasm_extract_lane_u_i16x8(v, 7);
   // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
   // WEBASSEMBLY-NEXT: zext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f15(i32x4 v) {
+int extract_lane_i32x4(i32x4 v) {
   return __builtin_wasm_extract_lane_i32x4(v, 3);
   // WEBASSEMBLY: extractelement <4 x i32> %v, i32 3
   // WEBASSEMBLY-NEXT: ret
 }
 
-long long f16(i64x2 v) {
+long long extract_lane_i64x2(i64x2 v) {
   return __builtin_wasm_extract_lane_i64x2(v, 1);
   // WEBASSEMBLY: extractelement <2 x i64> %v, i32 1
   //

[PATCH] D53007: [WebAssembly][NFC] Rename test functions for builtins

2018-10-08 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added a comment.
This revision is now accepted and ready to land.

A lot better this way! Thanks.


Repository:
  rC Clang

https://reviews.llvm.org/D53007



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


[PATCH] D53009: [WebAssembly] Saturating float-to-int builtins

2018-10-08 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: cfe-commits, kristina, sunfish, jgravelle-google, 
sbc100.

Depends on https://reviews.llvm.org/D52959 and https://reviews.llvm.org/D53004.


Repository:
  rC Clang

https://reviews.llvm.org/D53009

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -83,6 +83,54 @@
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }
 
+int trunc_saturate_s_i32_f32(float f) {
+  return __builtin_wasm_trunc_saturate_s_i32_f32(f);
+  // WEBASSEMBLY: call i32 @llvm.wasm.trunc.saturate.signed.i32.f32(float %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+int trunc_saturate_u_i32_f32(float f) {
+  return __builtin_wasm_trunc_saturate_u_i32_f32(f);
+  // WEBASSEMBLY: call i32 @llvm.wasm.trunc.saturate.unsigned.i32.f32(float %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+int trunc_saturate_s_i32_f64(double f) {
+  return __builtin_wasm_trunc_saturate_s_i32_f64(f);
+  // WEBASSEMBLY: call i32 @llvm.wasm.trunc.saturate.signed.i32.f64(double %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+int trunc_saturate_u_i32_f64(double f) {
+  return __builtin_wasm_trunc_saturate_u_i32_f64(f);
+  // WEBASSEMBLY: call i32 @llvm.wasm.trunc.saturate.unsigned.i32.f64(double %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+long long trunc_saturate_s_i64_f32(float f) {
+  return __builtin_wasm_trunc_saturate_s_i64_f32(f);
+  // WEBASSEMBLY: call i64 @llvm.wasm.trunc.saturate.signed.i64.f32(float %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+long long trunc_saturate_u_i64_f32(float f) {
+  return __builtin_wasm_trunc_saturate_u_i64_f32(f);
+  // WEBASSEMBLY: call i64 @llvm.wasm.trunc.saturate.unsigned.i64.f32(float %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+long long trunc_saturate_s_i64_f64(double f) {
+  return __builtin_wasm_trunc_saturate_s_i64_f64(f);
+  // WEBASSEMBLY: call i64 @llvm.wasm.trunc.saturate.signed.i64.f64(double %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+long long trunc_saturate_u_i64_f64(double f) {
+  return __builtin_wasm_trunc_saturate_u_i64_f64(f);
+  // WEBASSEMBLY: call i64 @llvm.wasm.trunc.saturate.unsigned.i64.f64(double %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
@@ -300,3 +348,27 @@
   // WEBASSEMBLY: call <2 x double> @llvm.sqrt.v2f64(<2 x double> %x)
   // WEBASSEMBLY: ret
 }
+
+i32x4 trunc_saturate_s_v4i32_v4f32(f32x4 f) {
+  return __builtin_wasm_trunc_saturate_s_v4i32_v4f32(f);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.trunc.saturate.signed.v4i32.v4f32(<4 x float> %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+i32x4 trunc_saturate_u_v4i32_v4f32(f32x4 f) {
+  return __builtin_wasm_trunc_saturate_u_v4i32_v4f32(f);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.trunc.saturate.unsigned.v4i32.v4f32(<4 x float> %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+i64x2 trunc_saturate_s_v2i64_v2f64(f64x2 f) {
+  return __builtin_wasm_trunc_saturate_s_v2i64_v2f64(f);
+  // WEBASSEMBLY: call <2 x i64> @llvm.wasm.trunc.saturate.signed.v2i64.v2f64(<2 x double> %f)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+i64x2 trunc_saturate_u_v2i64_v2f64(f64x2 f) {
+  return __builtin_wasm_trunc_saturate_u_v2i64_v2f64(f);
+  // WEBASSEMBLY: call <2 x i64> @llvm.wasm.trunc.saturate.unsigned.v2i64.v2f64(<2 x double> %f)
+  // WEBASSEMBLY-NEXT: ret
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -12456,6 +12456,30 @@
 Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_atomic_notify);
 return Builder.CreateCall(Callee, {Addr, Count});
   }
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32_f32:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32_f64:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f32:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f64:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_v4i32_v4f32:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_v2i64_v2f64: {
+Value *Src = EmitScalarExpr(E->getArg(0));
+llvm::Type *ResT = ConvertType(E->getType());
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_signed,
+ {ResT, Src->getType()});
+return Builder.CreateCall(Callee, {Src});
+  }
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32_f32:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32_f64:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f32:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f64:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_v4i32_v4f32:
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_v2i64_v2f64: {
+Value *Src = 

r344009 - [WebAssembly][NFC] Rename test functions for builtins

2018-10-08 Thread Thomas Lively via cfe-commits
Author: tlively
Date: Mon Oct  8 17:42:13 2018
New Revision: 344009

URL: http://llvm.org/viewvc/llvm-project?rev=344009&view=rev
Log:
[WebAssembly][NFC] Rename test functions for builtins

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, jfb, kristina, cfe-commits

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

Modified:
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=344009&r1=344008&r2=344009&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Mon Oct  8 17:42:13 2018
@@ -17,285 +17,285 @@ typedef unsigned long long u64x2 __attri
 typedef float f32x4 __attribute((vector_size(16)));
 typedef double f64x2 __attribute((vector_size(16)));
 
-__SIZE_TYPE__ f0(void) {
+__SIZE_TYPE__ memory_size(void) {
   return __builtin_wasm_memory_size(0);
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0)
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f1(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ memory_grow(__SIZE_TYPE__ delta) {
   return __builtin_wasm_memory_grow(0, delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f2(void) {
+__SIZE_TYPE__ mem_size(void) {
   return __builtin_wasm_mem_size(0);
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.mem.size.i32(i32 0)
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.mem.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f3(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ mem_grow(__SIZE_TYPE__ delta) {
   return __builtin_wasm_mem_grow(0, delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.mem.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f4(void) {
+__SIZE_TYPE__ current_memory(void) {
   return __builtin_wasm_current_memory();
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32()
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64()
 }
 
-__SIZE_TYPE__ f5(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ grow_memory(__SIZE_TYPE__ delta) {
   return __builtin_wasm_grow_memory(delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.grow.memory.i32(i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.grow.memory.i64(i64 %{{.*}})
 }
 
-void f6(unsigned int tag, void *obj) {
+void throw(unsigned int tag, void *obj) {
   return __builtin_wasm_throw(tag, obj);
   // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
   // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 }
 
-void f7(void) {
+void rethrow(void) {
   return __builtin_wasm_rethrow();
   // WEBASSEMBLY32: call void @llvm.wasm.rethrow()
   // WEBASSEMBLY64: call void @llvm.wasm.rethrow()
 }
 
-int f8(int *addr, int expected, long long timeout) {
+int atomic_wait_i32(int *addr, int expected, long long timeout) {
   return __builtin_wasm_atomic_wait_i32(addr, expected, timeout);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
 }
 
-int f9(long long *addr, long long expected, long long timeout) {
+int atomic_wait_i64(long long *addr, long long expected, long long timeout) {
   return __builtin_wasm_atomic_wait_i64(addr, expected, timeout);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
 }
 
-unsigned int f10(int *addr, int count) {
+unsigned int atomic_notify(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 
%{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 
%{{.*}})
 }
 
-int f11(i8x16 v) {
+int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f12(i8x16 v) {
+int extract_lane_u_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_u_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: zext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f13(i16x8 v) {
+int extract_lane_s_i16x8(i16x8 v) {
   return __builtin_wasm_extract_lane_s_i16x8(v, 7);
   // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f14(i16x8 v) {
+int extract_lane_u_i16x8(i16x8 v) {
   return __builtin_wasm_extract_lane_u_i16x8(v, 7);
   // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
   // WEBASSEMBLY-NEXT: zext
   // WEBA

[PATCH] D53007: [WebAssembly][NFC] Rename test functions for builtins

2018-10-08 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344009: [WebAssembly][NFC] Rename test functions for 
builtins (authored by tlively, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D53007

Files:
  cfe/trunk/test/CodeGen/builtins-wasm.c

Index: cfe/trunk/test/CodeGen/builtins-wasm.c
===
--- cfe/trunk/test/CodeGen/builtins-wasm.c
+++ cfe/trunk/test/CodeGen/builtins-wasm.c
@@ -17,285 +17,285 @@
 typedef float f32x4 __attribute((vector_size(16)));
 typedef double f64x2 __attribute((vector_size(16)));
 
-__SIZE_TYPE__ f0(void) {
+__SIZE_TYPE__ memory_size(void) {
   return __builtin_wasm_memory_size(0);
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0)
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f1(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ memory_grow(__SIZE_TYPE__ delta) {
   return __builtin_wasm_memory_grow(0, delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f2(void) {
+__SIZE_TYPE__ mem_size(void) {
   return __builtin_wasm_mem_size(0);
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.mem.size.i32(i32 0)
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.mem.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f3(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ mem_grow(__SIZE_TYPE__ delta) {
   return __builtin_wasm_mem_grow(0, delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.mem.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f4(void) {
+__SIZE_TYPE__ current_memory(void) {
   return __builtin_wasm_current_memory();
   // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32()
   // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64()
 }
 
-__SIZE_TYPE__ f5(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ grow_memory(__SIZE_TYPE__ delta) {
   return __builtin_wasm_grow_memory(delta);
   // WEBASSEMBLY32: call i32 @llvm.wasm.grow.memory.i32(i32 %{{.*}})
   // WEBASSEMBLY64: call i64 @llvm.wasm.grow.memory.i64(i64 %{{.*}})
 }
 
-void f6(unsigned int tag, void *obj) {
+void throw(unsigned int tag, void *obj) {
   return __builtin_wasm_throw(tag, obj);
   // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
   // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}})
 }
 
-void f7(void) {
+void rethrow(void) {
   return __builtin_wasm_rethrow();
   // WEBASSEMBLY32: call void @llvm.wasm.rethrow()
   // WEBASSEMBLY64: call void @llvm.wasm.rethrow()
 }
 
-int f8(int *addr, int expected, long long timeout) {
+int atomic_wait_i32(int *addr, int expected, long long timeout) {
   return __builtin_wasm_atomic_wait_i32(addr, expected, timeout);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}})
 }
 
-int f9(long long *addr, long long expected, long long timeout) {
+int atomic_wait_i64(long long *addr, long long expected, long long timeout) {
   return __builtin_wasm_atomic_wait_i64(addr, expected, timeout);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
 }
 
-unsigned int f10(int *addr, int count) {
+unsigned int atomic_notify(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
   // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
   // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }
 
-int f11(i8x16 v) {
+int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f12(i8x16 v) {
+int extract_lane_u_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_u_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: zext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f13(i16x8 v) {
+int extract_lane_s_i16x8(i16x8 v) {
   return __builtin_wasm_extract_lane_s_i16x8(v, 7);
   // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f14(i16x8 v) {
+int extract_lane_u_i16x8(i16x8 v) {
   return __builtin_wasm_extract_lane_u_i16x8(v, 7);
   // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
   // WEBASSEMBLY-NEXT: zext
   // WEBASSEMBLY-NEXT: ret
 }
 
-int f15(i32x4 v) {
+int extract_lane_i32x4(i32x4 v) {
   return __builtin_wasm_extract_lane_i32x4(v, 3);
   // WEBASSEMBLY: extractelement <4 x i32> %v, i32 3
   // WEBASSEMBLY-NEXT: ret
 }
 
-long long f16(i64x2 v) {
+long long extract_lane_i64x2(i64x2 v) {

Buildbot numbers for the week of 9/23/2018 - 9/29/2018

2018-10-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 9/23/2018 - 9/29/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  |  was_red
---+--
 clang-cmake-armv8-lld | 114:32:52
 clang-cmake-aarch64-lld   | 113:42:27
 aosp-O3-polly-before-vectorizer-unprofitable  | 72:42:39
 clang-bpf-build   | 56:52:45
 clang-ppc64le-linux-lnt   | 53:39:32
 clang-ppc64be-linux-multistage| 51:21:21
 sanitizer-x86_64-linux-fast   | 47:40:55
 sanitizer-x86_64-linux-bootstrap-ubsan| 47:04:02
 clang-x64-ninja-win7  | 41:05:40
 clang-ppc64be-linux   | 34:00:48
 clang-ppc64be-linux-lnt   | 33:52:46
 clang-s390x-linux-multistage  | 33:41:09
 clang-s390x-linux-lnt | 33:25:57
 clang-s390x-linux | 32:54:53
 clang-ppc64le-linux   | 32:07:35
 sanitizer-x86_64-linux| 24:50:57
 clang-with-lto-ubuntu | 24:15:23
 sanitizer-ppc64be-linux   | 24:01:15
 clang-with-thin-lto-ubuntu| 22:15:24
 clang-ppc64le-linux-multistage| 22:14:37
 libcxx-libcxxabi-x86_64-linux-debian  | 21:52:52
 clang-lld-x86_64-2stage   | 17:12:52
 clang-x86_64-linux-selfhost-modules   | 16:33:16
 sanitizer-ppc64le-linux   | 15:43:31
 sanitizer-x86_64-linux-bootstrap  | 11:37:55
 clang-cmake-thumbv7-full-sh   | 11:26:24
 lld-x86_64-darwin13   | 10:33:39
 llvm-clang-x86_64-expensive-checks-win| 07:38:38
 clang-cmake-aarch64-quick | 07:25:20
 clang-cmake-aarch64-global-isel   | 07:18:19
 clang-x86_64-debian-fast  | 07:14:32
 sanitizer-x86_64-linux-autoconf   | 06:54:17
 clang-cmake-armv7-full| 06:29:26
 clang-cmake-armv7-quick   | 05:28:53
 clang-cmake-armv8-global-isel | 05:23:26
 clang-cmake-armv8-full| 04:44:19
 lldb-amd64-ninja-netbsd8  | 04:20:08
 clang-cmake-armv8-quick   | 04:19:45
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 04:04:41
 clang-cmake-armv7-global-isel | 03:49:54
 sanitizer-x86_64-linux-fuzzer | 03:33:26
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 03:32:24
 libcxx-libcxxabi-libunwind-armv7-linux| 03:27:32
 lldb-x86_64-ubuntu-14.04-buildserver  | 03:20:13
 sanitizer-x86_64-linux-android| 03:16:02
 lldb-amd64-ninja-freebsd11| 03:12:29
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 03:12:26
 libcxx-libcxxabi-libunwind-armv8-linux| 03:12:23
 libcxx-libcxxabi-libunwind-aarch64-linux  | 03:07:47
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 03:07:37
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 03:05:48
 clang-hexagon-elf | 03:04:21
 clang-cmake-armv7-lnt | 02:59:24
 clang-cuda-build  | 02:55:10
 sanitizer-x86_64-linux-bootstrap-msan | 02:35:26
 clang-cmake-x86_64-avx2-linux-perf| 02:34:28
 clang-cmake-armv8-lnt | 02:25:24
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 01:57:15
 clang-cmake-x86_64-avx2-linux | 01:47:11
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 01:39:33
 clang-x86_64-linux-abi-test   | 01:21:37
 llvm-hexagon-elf  | 00:59:46
 clang-cmake-x86_64-sde-avx512-linux   | 00:55:41
 clang-aarch64-linux-build-cache   | 00:46:45
 sanitizer-win

Buildbot numbers for the last week of 9/30/2018 - 10/06/2018

2018-10-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 9/30/2018 - 10/06/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 clang-x64-ninja-win7 | 87:29:01
 clang-x64-windows-msvc   | 61:58:15
 llvm-clang-x86_64-expensive-checks-win   | 39:22:44
 clang-bpf-build  | 38:48:08
 openmp-clang-x86_64-linux-debian | 31:10:25
 openmp-clang-ppc64le-linux-rhel  | 29:19:36
 clang-cmake-aarch64-lld  | 27:11:24
 lldb-amd64-ninja-netbsd8 | 26:32:06
 openmp-gcc-x86_64-linux-debian   | 25:00:10
 sanitizer-x86_64-linux-android   | 21:31:08
 clang-cmake-armv7-selfhost   | 19:16:20
 clang-cmake-armv8-lld| 18:08:33
 clang-cmake-aarch64-full | 17:32:47
 clang-with-lto-ubuntu| 16:33:11
 clang-with-thin-lto-ubuntu   | 15:05:19
 clang-x86_64-linux-selfhost-modules  | 13:40:46
 clang-ppc64le-linux-multistage   | 12:41:27
 clang-cmake-armv7-selfhost-neon  | 12:33:25
 clang-lld-x86_64-2stage  | 12:11:02
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 11:14:48
 clang-cmake-armv8-full   | 10:25:37
 clang-cmake-armv8-quick  | 10:25:04
 clang-cmake-thumbv7-full-sh  | 10:24:18
 clang-cmake-armv8-global-isel| 10:19:52
 clang-cmake-armv7-full   | 10:08:39
 clang-s390x-linux-multistage | 10:02:36
 clang-cmake-armv7-global-isel| 10:00:47
 clang-cmake-thumbv8-full-sh  | 09:59:31
 clang-cmake-aarch64-global-isel  | 09:53:17
 clang-cmake-armv7-quick  | 09:52:44
 clang-cmake-aarch64-quick| 09:51:25
 clang-ppc64le-linux-lnt  | 09:50:13
 clang-x86_64-debian-fast | 09:41:52
 clang-cmake-armv8-selfhost-neon  | 08:14:32
 clang-cmake-x86_64-avx2-linux-perf   | 07:06:02
 clang-ppc64be-linux-multistage   | 06:29:09
 clang-cmake-x86_64-avx2-linux| 06:13:00
 libcxx-libcxxabi-libunwind-aarch64-linux | 06:07:21
 clang-ppc64le-linux  | 04:41:57
 clang-x86_64-linux-abi-test  | 04:24:56
 sanitizer-x86_64-linux-bootstrap-ubsan   | 04:15:17
 clang-hexagon-elf| 04:13:09
 sanitizer-x86_64-linux-bootstrap-msan| 04:12:35
 sanitizer-x86_64-linux-fast  | 04:09:31
 clang-s390x-linux| 04:07:30
 sanitizer-x86_64-linux-bootstrap | 04:07:16
 clang-s390x-linux-lnt| 04:03:41
 clang-cmake-armv8-lnt| 03:55:26
 clang-ppc64be-linux  | 03:51:15
 clang-ppc64be-linux-lnt  | 03:50:05
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 03:49:58
 clang-cuda-build | 03:44:12
 clang-cmake-x86_64-sde-avx512-linux  | 03:42:38
 clang-cmake-armv7-lnt| 03:32:59
 sanitizer-ppc64le-linux  | 02:49:57
 sanitizer-x86_64-linux   | 02:28:48
 sanitizer-windows| 02:13:09
 sanitizer-x86_64-linux-autoconf  | 02:09:25
 lld-x86_64-darwin13  | 02:02:16
 lld-x86_64-freebsd   | 02:01:39
 sanitizer-ppc64be-linux  | 01:28:24
 libcxx-libcxxabi-libunwind-x86_64-linux-debian   | 01:23:23
 lldb-x86_64-ubuntu-14.04-buildserver | 01:19:04
 sanitizer-x86_64-linux-fuzzer| 00:55:58
 polly-arm-linux  | 00:52:31
 clang-aarch64-linux-build-cache  | 00:47:48
 polly-amd64-linux| 00:45:12
 llvm-hexagon-elf | 00:45:06
 clang-armv7-linux-build-cache| 00:41:35
 lldb-amd64-ninja-freebsd11  

r344010 - [Index] Use locations to uniquify function-scope BindingDecl USR

2018-10-08 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Mon Oct  8 18:02:56 2018
New Revision: 344010

URL: http://llvm.org/viewvc/llvm-project?rev=344010&view=rev
Log:
[Index] Use locations to uniquify function-scope BindingDecl USR

Summary:
This makes BindingDecl's of the same name have different USRs, so that 
references can be correctly attributed.

int a[1] = {};
{ auto [x] = a; x; }
{ auto [x] = a; x; }

Reviewers: akyrtzi, arphaman, rsmith, hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=344010&r1=344009&r2=344010&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  8 18:02:56 2018
@@ -97,6 +97,7 @@ public:
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@ void USRGenerator::VisitVarDecl(const Va
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (isLocal(D) && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=344010&r1=344009&r2=344010&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Mon Oct  8 18:02:56 2018
@@ -1,4 +1,5 @@
 // RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target 
x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s 
-std=c++1z -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=LOCAL %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def 
| rel: 0
 class Cls { public:
@@ -493,6 +494,7 @@ void localStructuredBindingAndRef() {
 // CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont 
| rel: 1
 // CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
 // CHECK-NOT: localBinding
+// LOCAL: [[@LINE-4]]:9 | variable(local)/C++ | localBinding1 | 
c:index-source.cpp@25382@N@cpp17structuredBinding@F@localStructuredBindingAndRef#@localBinding1
 }
 
 }


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


[PATCH] D52445: [Index] Use locations to uniquify function-scope BindingDecl USR

2018-10-08 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344010: [Index] Use locations to uniquify function-scope 
BindingDecl USR (authored by MaskRay, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52445?vs=168704&id=168740#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52445

Files:
  lib/Index/USRGeneration.cpp
  test/Index/Core/index-source.cpp


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -1,4 +1,5 @@
 // RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target 
x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s 
-std=c++1z -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=LOCAL %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def 
| rel: 0
 class Cls { public:
@@ -493,6 +494,7 @@
 // CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont 
| rel: 1
 // CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
 // CHECK-NOT: localBinding
+// LOCAL: [[@LINE-4]]:9 | variable(local)/C++ | localBinding1 | 
c:index-source.cpp@25382@N@cpp17structuredBinding@F@localStructuredBindingAndRef#@localBinding1
 }
 
 }
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (isLocal(D) && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -1,4 +1,5 @@
 // RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=LOCAL %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def | rel: 0
 class Cls { public:
@@ -493,6 +494,7 @@
 // CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont | rel: 1
 // CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
 // CHECK-NOT: localBinding
+// LOCAL: [[@LINE-4]]:9 | variable(local)/C++ | localBinding1 | c:index-source.cpp@25382@N@cpp17structuredBinding@F@localStructuredBindingAndRef#@localBinding1
 }
 
 }
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (isLocal(D) && GenLoc(D, /*IncludeOffset=*/true))
+return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
 const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >