[PATCH] D36252: [diagtool] Add ability to get name from id

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D36252



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


[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D27827#829661, @thakis wrote:

> We just noticed that if you call __builtin_available() for the first time 
> after activating your app's sandbox, the function will fail:
>
> SandboxViolation: crdmg(15489) deny file-read-data 
> /System/Library/CoreServices/SystemVersion.plist
>  Violation:   deny file-read-data 
> /System/Library/CoreServices/SystemVersion.plist 
>  Process: crdmg [15489]
>  Path:/Volumes/Build/src/./out/release/crdmg
>
> Thread 0 (id: 421251):
>  0   libsystem_kernel.dylib   0x7fffe94a1a86 __open_nocancel + 10
>  1   crdmg0x00010444be98 
> parseSystemVersionPList + 360
>  20xec83485354415541


Hmm, never saw this before. Please post your exact configuration - 
clang/compiler-rt versions, OS version, toolchain & SDK. Is it possible to get 
a reproducer?


Repository:
  rL LLVM

https://reviews.llvm.org/D27827



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


[PATCH] D36177: [clang-diff] Add commandline arguments.

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Tooling/clang-diff-args.sh:1
+RUN: echo a > %t.cpp
+

I think a '.test' extension rather than '.sh' is better



Comment at: test/Tooling/clang-diff-args.sh:3
+
+RUN: echo "CHECK: unknown type name 'X'" > %t1
+

You can just have a CHECK in this file and run `FileCheck %s`


https://reviews.llvm.org/D36177



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D36261

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -273,16 +273,17 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
-/*RunSynchronously=*/false);
+SchedulingParams::RunOnDefaultNumberOfThreads());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
 
 auto SourceFilename = getVirtualTestFilePath(SourceFileRelPath);
 
 FS.ExpectedFile = SourceFilename;
 
-// Have to sync reparses because RunSynchronously is false.
+// Have to sync reparses because requests are processed on the calling
+// thread.
 auto AddDocFuture = Server.addDocument(SourceFilename, SourceContents);
 
 auto Result = dumpASTWithoutMemoryLocs(Server, SourceFilename);
@@ -335,7 +336,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  SchedulingParams::RunOnDefaultNumberOfThreads());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -380,7 +381,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  SchedulingParams::RunOnDefaultNumberOfThreads());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -426,15 +427,15 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  SchedulingParams::RunOnCallingThread());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
   FS.Files[FooCpp] = SourceContents;
   FS.ExpectedFile = FooCpp;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
@@ -457,7 +458,7 @@
  {"-xc++", "-target", "x86_64-linux-unknown",
   "-m64", "--gcc-toolchain=/randomusr"});
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  SchedulingParams::RunOnCallingThread());
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -486,8 +487,8 @@
 )cpp";
   FS.Files[FooCpp] = SourceContents;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
@@ -517,7 +518,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  SchedulingParams::RunOnDefaultNumberOfThreads());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -16,14 +16,30 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace clang::clangd;
 
-static llvm::cl::opt
-RunSynchronously("run-synchronously",
- llvm::cl::desc("Parse on main thread"),
- llvm::cl::init(false), llvm::cl::Hidden);
+static unsigned getDefaultThreadsCount() {
+  unsigned HardwareConcurrency = std::thread::hardware_concurrency();
+  // C++ standard says that hardware_concurrency()
+  // may return 0, fallback to 1 worker thread in
+  // that case.
+  if (HardwareConcurrency == 0)
+return 1;
+  return HardwareConcurrency;
+}
+
+static llvm::cl::opt
+ThreadsCount("j",
+ llvm::cl::desc("Number of parallel workers used by clangd."),
+ llvm::cl::init(getDefaultThreadsCount()));
+
+static llvm::cl::opt RunSynchronously(
+"run-synchronously",
+llvm::cl::desc("Parse on main thread. If set, -j is ignored."),
+llvm::cl::init(false), llvm::cl::Hidden)

[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Tooling/clang-diff-json.cpp:1
+// RUN: clang-diff -ast-dump %s -- | python -m json.tool | FileCheck %s
+

I think you have to use `%python` instead of `python`, like LLVM tests do.


https://reviews.llvm.org/D36178



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


[PATCH] D36181: [clang-diff] Make printing of matches optional

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Tooling/clang-diff-args.sh:10
+
+RUN: echo "// CHECK-NOT: {{.}}" > %t-no-output
+RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 
\

You can use `MYCHECK-NOT` in this file and run `FileCheck 
--check-prefix=MYCHECK %s`


https://reviews.llvm.org/D36181



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clangd/ClangdServer.h:107
+public:
+  /// Indicates that requests must be executed immidieately on the calling
+  /// thread.

Typo: immediately


https://reviews.llvm.org/D36261



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


[PATCH] D36226: Added a RealFileSystem implementation that does not rely on global CWD.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov planned changes to this revision.
ilya-biryukov added a comment.

After a chat with @klimek, working on an implementation that would use 
`openAt()`.


https://reviews.llvm.org/D36226



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clangd/ClangdServer.h:105
+/// A helper class to pass concurrency parameters to ClangdScheduler.
+class SchedulingParams {
+public:

I think calling it "Options" is more idiomatic.



Comment at: clangd/ClangdServer.h:110
+  static SchedulingParams RunOnCallingThread();
+  /// Indicates then requests should be executed on separate worker threads. In
+  /// total \p ThreadsCount working threads will be created.

Typo: Indicates *that*.



Comment at: clangd/ClangdServer.h:121-122
+public:
+  /// Returns the number of threads to use when shouldRunsynchronously() is
+  /// false. Must not be called if shouldRunsynchronously() is true.
+  unsigned getThreadsCount();

Why not: 1 -> run synchronously, > 1, run in parallel?


https://reviews.llvm.org/D36261



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


[PATCH] D35894: [clangd] Code hover for Clangd

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D35894#829190, @malaperle wrote:

> @Nebiroth I think it's OK to put this on hold until we make the "semantic" 
> hover and figure out how to have both. From our perspective, this is going 
> beyond parity of what we had before but it's seems like the right thing to do.


BTW, just noticed that VS Code shows the range reported by `findDefinitions` 
when you hover over a symbol and holding Ctrl.
Would calling `findDefinitions` help you to do the same thing? That would allow 
to get closer to feature parity with CDT without implementing semantic hover in 
clangd.


https://reviews.llvm.org/D35894



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Sorry for the delay, and thanks for refining it.

In general, I'm fine with the current design, a few comments below.




Comment at: clang-tidy/android/CloexecCheck.cpp:62
+const int ArgPos) {
+  const auto MatchedCall = Result.Nodes.getNodeAs("func");
+  const auto FD = Result.Nodes.getNodeAs("funcDecl");

Use `const auto*`, obviously indicates this is a pointer, the same to other 
places. 



Comment at: clang-tidy/android/CloexecCheck.cpp:94
+  StringRef SR = cast(Arg->IgnoreParenCasts())->getString();
+  return ("\"" + SR + Twine(Mode) + "\"").str();
+}

I think there will be a use-after-free issue here.

The method returns a StringRef (which doesn't own the "std::string"), the 
temporary `std::string` will be destructed after the method finished.



Comment at: clang-tidy/android/CloexecCheck.h:18
+
+/// The base class for all close-on-exec checks.
+class CloexecCheck : public ClangTidyCheck {

This base class will  be used in a bunch of cloase-on-exec checks.
It deserves a better and more detailed documentation (e.g. the intended usage).



Comment at: clang-tidy/android/CloexecCheck.h:26
+  template 
+  void doRegisterMatchers(ast_matchers::MatchFinder *Finder, Types... Params) {
+auto FuncDecl = std::bind(ast_matchers::functionDecl,

I think we can drop the `do` for most methods, how about 

`doRegisterMatchers` => `registerMatchers`
`doMacroFlagInsertion` => `insertMacroFlag`
`doFuncReplacement` => `replaceFunc`
`doStringFlagInsertion` => `insertStringFlag`?



Comment at: clang-tidy/android/CloexecCheck.h:30
+Finder->addMatcher(ast_matchers::callExpr(
+   ast_matchers::callee(FuncDecl().bind("funcDecl")))
+   .bind("func"),

Instead of using the magic string `funDecl` anywhere, I would define a static 
const member for it. The same to `func`.



Comment at: clang-tidy/android/CloexecCheck.h:35
+
+  // This issue has three types.
+  // Type1 is to insert the necessary macro flag in the flag argument.

It is unclear to me what the "issue" means here? I assume there are three types 
of fixes?



Comment at: clang-tidy/android/CloexecCheck.h:36
+  // This issue has three types.
+  // Type1 is to insert the necessary macro flag in the flag argument.
+  void

Deserve a document on the behavior of the method, would be better to give an 
example. The same below.

Is `Flag` required to be a macro flag? looks like it could be any string.



Comment at: clang-tidy/android/CloexecCheck.h:53
+  // Helper function to get the spelling of a particular argument.
+  StringRef getArgSpelling(const ast_matchers::MatchFinder::MatchResult 
&Result,
+   int n);

Maybe getSpellingArg which sounds more natural?



Comment at: clang-tidy/android/CloexecCheck.h:54
+  StringRef getArgSpelling(const ast_matchers::MatchFinder::MatchResult 
&Result,
+   int n);
+

s/n/N



Comment at: clang-tidy/android/CloexecCheck.h:75
+  inline ast_matchers::internal::Matcher
+  hasSockAddrPointerTypeParameter(int n) {
+return ast_matchers::hasParameter(

should we put this method and below in the base class? They seem to be 
check-specific, I think? 


https://reviews.llvm.org/D35372



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


[PATCH] D35932: [clang-tidy] Add integer division check

2017-08-03 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 109497.
rnkovacs edited the summary of this revision.
rnkovacs added a comment.

Uploaded a more thought-out version of the check with more cases covered and 
hopefully clearer docs. It produces no hits on LLVM&Clang.


https://reviews.llvm.org/D35932

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/IntegerDivisionCheck.cpp
  clang-tidy/bugprone/IntegerDivisionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-integer-division.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-integer-division.cpp

Index: test/clang-tidy/bugprone-integer-division.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-integer-division.cpp
@@ -0,0 +1,150 @@
+// RUN: %check_clang_tidy %s bugprone-integer-division %t
+
+void floatArg(float x) {}
+void doubleArg(double x) {}
+void longDoubleArg(long double x) {}
+
+float floatReturn(unsigned x, int y, bool z) {
+  return (x * y) / z;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: integer division; possible precision loss [bugprone-integer-division]
+}
+
+double doubleReturn(int x, char y) {
+  return x / y - 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: integer division; possible precision loss [bugprone-integer-division]
+}
+
+long double longDoubleReturn(char x, unsigned y) {
+  return (1 + x / y) + 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: integer division; possible precision loss [bugprone-integer-division]
+}
+
+struct X {
+  int n;
+  void m() {
+floatArg(n / 3);
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: integer division; possible precision loss [bugprone-integer-division]
+  }
+};
+
+struct Y {
+  void f(){
+auto l = [] { floatArg(2 / 3); };
+// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: integer division; possible precision loss [bugprone-integer-division]
+  }
+};
+
+template 
+void arbitraryArg(T x) {
+  longDoubleArg(x);
+}
+
+void floatEnvironment() {
+  char a = 2;
+  int b = -5;
+  unsigned c = 9784;
+  enum third { x, y, z=2 };
+  third d = z;
+  char e[] = {'a', 'b', 'c'};
+  char f = *(e + 1 / a);
+  bool g = 1;
+
+  // Implicit cast to float: function argument.
+  floatArg(a / g - 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: integer division; possible precision loss [bugprone-integer-division]
+  doubleArg(2 + b / f);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: integer division; possible precision loss [bugprone-integer-division]
+  longDoubleArg(c + (e[0] / d));
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: integer division; possible precision loss [bugprone-integer-division]
+
+  // Implicit cast to float: function return value.
+  long double q;
+  q = floatReturn(c, b, g);
+  q = doubleReturn(d, a);
+  q = longDoubleReturn(f, c);
+
+  // Explicit casts.
+  q = (float)(a / b + 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: integer division; possible precision loss [bugprone-integer-division]
+  q = double((1 - c) / d);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: integer division; possible precision loss [bugprone-integer-division]
+  q = static_cast(2 + e[1] / g);
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: integer division; possible precision loss [bugprone-integer-division]
+
+#define THIRD float(1 / 3);
+  THIRD
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: integer division; possible precision loss [bugprone-integer-division]
+
+  arbitraryArg(a / b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: integer division; possible precision loss [bugprone-integer-division]
+}
+
+int intArg(int x) { return x; }
+char charArg(char x) { return x; }
+bool boolArg(bool x) { return x; }
+
+int intReturn(int x, int y) {
+  return (x - 5) / y + 1;
+}
+
+char charReturn(int x, unsigned y) {
+  return 1 - x / (y * 4);
+}
+
+bool boolReturn(int x, char y) {
+  return (x / y + 1) * 5;
+}
+
+void integerCastInFloatEnvironment() {
+  unsigned k = 87;
+  int l = -7;
+  char m = 'q';
+  bool n = 0;
+
+  // We can assume that the following cases are intended.
+  // Function calls expecting integers:
+  floatArg(0.3 + intArg(6 * k / m));
+  doubleArg(charArg(n / l) * 9);
+  longDoubleArg(3 - boolArg(m / (k - 2)));
+
+  // Function calls returning integers:
+  double o;
+  o = intReturn(-2, 99);
+  o = charReturn(1, 7);
+  o = boolReturn(42, 'c');
+
+  // Explicit casts:
+  floatArg(0.3 + int(6 * k / m));
+  doubleArg((int)(n / l) * 9);
+  longDoubleArg(3 - static_cast(m / (k - 2)));
+
+  // Operators expecting integral types:
+  o = 1 << (2 / m);
+  o = 1 << intArg(4 + k / 64);
+  o = ~(k / 8 + 3);
+  o = (32 - k / 8) ^ 1;
+  o = ((k / 8 + 1) * 32) | 1;
+  o = (1 & (k / 8)) - 2;
+  o = ((k - 8) / 32) % m;
+
+  // Relational, logical, and conditional operators:
+  o = k / m <= 0;
+  o = (k * l - 5) / m != n;
+  o = !(l / m * 8 - 1);
+  o = n / m || l == -7;
+  o = n / m ? 1 : 0;
+  o = n / m ?: 1;
+
+  // Precision loss can still be

[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added inline comments.



Comment at: test/Tooling/clang-diff-json.cpp:1
+// RUN: clang-diff -ast-dump %s -- | python -m json.tool | FileCheck %s
+

arphaman wrote:
> I think you have to use `%python` instead of `python`, like LLVM tests do.
ok
So I have to use python 2.7? (for the test in https://reviews.llvm.org/D36182)


https://reviews.llvm.org/D36178



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


[PATCH] D36177: [clang-diff] Add commandline arguments.

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109502.
johannes added a comment.

fix tests


https://reviews.llvm.org/D36177

Files:
  test/Tooling/clang-diff-args.test
  test/Tooling/clang-diff-basic.cpp
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -28,12 +28,6 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
-static cl::opt NoCompilationDatabase(
-"no-compilation-database",
-cl::desc(
-"Do not attempt to load build settings from a compilation database"),
-cl::init(false), cl::cat(ClangDiffCategory));
-
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -43,43 +37,83 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static std::unique_ptr getAST(const StringRef Filename) {
+static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
+cl::init(-1), cl::cat(ClangDiffCategory));
+
+static cl::opt BuildPath("p", cl::desc("Build path"), cl::init(""),
+  cl::Optional, cl::cat(ClangDiffCategory));
+
+static cl::list ArgsAfter(
+"extra-arg",
+cl::desc("Additional argument to append to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static cl::list ArgsBefore(
+"extra-arg-before",
+cl::desc("Additional argument to prepend to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static void addExtraArgs(std::unique_ptr &Compilations) {
+  if (!Compilations)
+return;
+  auto AdjustingCompilations =
+  llvm::make_unique(
+  std::move(Compilations));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsBefore, ArgumentInsertPosition::BEGIN));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsAfter, ArgumentInsertPosition::END));
+  Compilations = std::move(AdjustingCompilations);
+}
+
+static std::unique_ptr
+getAST(const std::unique_ptr &CommonCompilations,
+   const StringRef Filename) {
   std::string ErrorMessage;
   std::unique_ptr Compilations;
-  if (!NoCompilationDatabase)
-Compilations =
-CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
-  if (!Compilations) {
-if (!NoCompilationDatabase)
+  if (!CommonCompilations) {
+Compilations = CompilationDatabase::autoDetectFromSource(
+BuildPath.empty() ? Filename : BuildPath, ErrorMessage);
+if (!Compilations) {
   llvm::errs()
   << "Error while trying to load a compilation database, running "
  "without flags.\n"
   << ErrorMessage;
-Compilations = llvm::make_unique(
-".", std::vector());
+  Compilations =
+  llvm::make_unique(
+  ".", std::vector());
+}
   }
+  addExtraArgs(Compilations);
   std::array Files = {{Filename}};
-  ClangTool Tool(*Compilations, Files);
+  ClangTool Tool(Compilations ? *Compilations : *CommonCompilations, Files);
   std::vector> ASTs;
   Tool.buildASTs(ASTs);
   if (ASTs.size() != Files.size())
 return nullptr;
   return std::move(ASTs[0]);
 }
 
 int main(int argc, const char **argv) {
+  std::string ErrorMessage;
+  std::unique_ptr CommonCompilations =
+  FixedCompilationDatabase::loadFromCommandLine(argc, argv, ErrorMessage);
+  if (!CommonCompilations && !ErrorMessage.empty())
+llvm::errs() << ErrorMessage;
   cl::HideUnrelatedOptions(ClangDiffCategory);
   if (!cl::ParseCommandLineOptions(argc, argv)) {
 cl::PrintOptionValues();
 return 1;
   }
 
+  addExtraArgs(CommonCompilations);
+
   if (ASTDump) {
 if (!DestinationPath.empty()) {
   llvm::errs() << "Error: Please specify exactly one filename.\n";
   return 1;
 }
-std::unique_ptr AST = getAST(SourcePath);
+std::unique_ptr AST = getAST(CommonCompilations, SourcePath);
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
@@ -92,12 +126,14 @@
 return 1;
   }
 
-  std::unique_ptr Src = getAST(SourcePath);
-  std::unique_ptr Dst = getAST(DestinationPath);
+  std::unique_ptr Src = getAST(CommonCompilations, SourcePath);
+  std::unique_ptr Dst = getAST(CommonCompilations, DestinationPath);
   if (!Src || !Dst)
 return 1;
 
   diff::ComparisonOptions Options;
+  if (MaxSize != -1)
+Options.MaxSize = MaxSize;
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff DiffTool(SrcTree, DstTree, Options);
Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic

[PATCH] D36181: [clang-diff] Make printing of matches optional

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109503.
johannes added a comment.

fix tests


https://reviews.llvm.org/D36181

Files:
  test/Tooling/clang-diff-args.test
  test/Tooling/clang-diff-basic.cpp
  tools/clang-diff/ClangDiff.cpp


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -33,6 +33,10 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt
+PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
+ cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -267,7 +271,7 @@
 
   for (diff::NodeId Dst : DstTree) {
 diff::NodeId Src = Diff.getMapped(DstTree, Dst);
-if (Src.isValid()) {
+if (PrintMatches && Src.isValid()) {
   llvm::outs() << "Match ";
   printNode(llvm::outs(), SrcTree, Src);
   llvm::outs() << " to ";
Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic.cpp
+++ test/Tooling/clang-diff-basic.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %T/src.cpp
 // RUN: %clang_cc1 -E %s > %T/dst.cpp -DDEST
-// RUN: clang-diff %T/src.cpp %T/dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %T/src.cpp %T/dst.cpp -- | FileCheck %s
 
 #ifndef DEST
 namespace src {
Index: test/Tooling/clang-diff-args.test
===
--- test/Tooling/clang-diff-args.test
+++ test/Tooling/clang-diff-args.test
@@ -6,3 +6,7 @@
 RUN: clang-diff -ast-dump -extra-arg=-Da=X%t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s
+
+NOMATCH-CHECK-NOT: {{.}}
+RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 
\
+RUN: | FileCheck -check-prefix=NOMATCH-CHECK -allow-empty %s


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -33,6 +33,10 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt
+PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
+ cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -267,7 +271,7 @@
 
   for (diff::NodeId Dst : DstTree) {
 diff::NodeId Src = Diff.getMapped(DstTree, Dst);
-if (Src.isValid()) {
+if (PrintMatches && Src.isValid()) {
   llvm::outs() << "Match ";
   printNode(llvm::outs(), SrcTree, Src);
   llvm::outs() << " to ";
Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic.cpp
+++ test/Tooling/clang-diff-basic.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %T/src.cpp
 // RUN: %clang_cc1 -E %s > %T/dst.cpp -DDEST
-// RUN: clang-diff %T/src.cpp %T/dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %T/src.cpp %T/dst.cpp -- | FileCheck %s
 
 #ifndef DEST
 namespace src {
Index: test/Tooling/clang-diff-args.test
===
--- test/Tooling/clang-diff-args.test
+++ test/Tooling/clang-diff-args.test
@@ -6,3 +6,7 @@
 RUN: clang-diff -ast-dump -extra-arg=-Da=X%t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s
+
+NOMATCH-CHECK-NOT: {{.}}
+RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 \
+RUN: | FileCheck -check-prefix=NOMATCH-CHECK -allow-empty %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36183: [clang-diff] Simplify mapping

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109504.
johannes added a comment.

merge parent changes


https://reviews.llvm.org/D36183

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/Inputs/clang-diff-basic-src.cpp
  test/Tooling/clang-diff-basic.cpp

Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic.cpp
+++ test/Tooling/clang-diff-basic.cpp
@@ -38,8 +38,15 @@
   return "foo";
 return 0;
   }
-  // CHECK: Delete AccessSpecDecl: public
   X(){};
-  // CHECK: Delete CXXMethodDecl
 };
 }
+
+namespace {
+// match with parents of different type
+// CHECK: Match FunctionDecl: f1{{.*}} to FunctionDecl: f1
+void f1() {{ (void) __func__;;; }}
+}
+
+// CHECK: Delete AccessSpecDecl: public
+// CHECK: Delete CXXMethodDecl
Index: test/Tooling/Inputs/clang-diff-basic-src.cpp
===
--- test/Tooling/Inputs/clang-diff-basic-src.cpp
+++ test/Tooling/Inputs/clang-diff-basic-src.cpp
@@ -26,3 +26,5 @@
   int id(int i) { return i; }
 };
 }
+
+void f1() {{ (void) __func__;;; }}
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -34,48 +34,23 @@
   Mapping() = default;
   Mapping(Mapping &&Other) = default;
   Mapping &operator=(Mapping &&Other) = default;
-  Mapping(int Size1, int Size2) {
-// Maximum possible size after patching one tree.
-int Size = Size1 + Size2;
-SrcToDst = llvm::make_unique[]>(Size);
-DstToSrc = llvm::make_unique[]>(Size);
+
+  Mapping(size_t Size) {
+SrcToDst = llvm::make_unique(Size);
+DstToSrc = llvm::make_unique(Size);
   }
 
   void link(NodeId Src, NodeId Dst) {
-SrcToDst[Src].push_back(Dst);
-DstToSrc[Dst].push_back(Src);
-  }
-
-  NodeId getDst(NodeId Src) const {
-if (hasSrc(Src))
-  return SrcToDst[Src][0];
-return NodeId();
-  }
-  NodeId getSrc(NodeId Dst) const {
-if (hasDst(Dst))
-  return DstToSrc[Dst][0];
-return NodeId();
-  }
-  const SmallVector &getAllDsts(NodeId Src) const {
-return SrcToDst[Src];
-  }
-  const SmallVector &getAllSrcs(NodeId Dst) const {
-return DstToSrc[Dst];
-  }
-  bool hasSrc(NodeId Src) const { return !SrcToDst[Src].empty(); }
-  bool hasDst(NodeId Dst) const { return !DstToSrc[Dst].empty(); }
-  bool hasSrcDst(NodeId Src, NodeId Dst) const {
-for (NodeId DstId : SrcToDst[Src])
-  if (DstId == Dst)
-return true;
-for (NodeId SrcId : DstToSrc[Dst])
-  if (SrcId == Src)
-return true;
-return false;
+SrcToDst[Src] = Dst, DstToSrc[Dst] = Src;
   }
 
+  NodeId getDst(NodeId Src) const { return SrcToDst[Src]; }
+  NodeId getSrc(NodeId Dst) const { return DstToSrc[Dst]; }
+  bool hasSrc(NodeId Src) const { return getDst(Src).isValid(); }
+  bool hasDst(NodeId Dst) const { return getSrc(Dst).isValid(); }
+
 private:
-  std::unique_ptr[]> SrcToDst, DstToSrc;
+  std::unique_ptr SrcToDst, DstToSrc;
 };
 } // end anonymous namespace
 
@@ -104,8 +79,6 @@
   // Returns true if the two subtrees are identical.
   bool identical(NodeId Id1, NodeId Id2) const;
 
-  bool canBeAddedToMapping(const Mapping &M, NodeId Id1, NodeId Id2) const;
-
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
@@ -711,23 +684,6 @@
   return true;
 }
 
-bool ASTDiff::Impl::canBeAddedToMapping(const Mapping &M, NodeId Id1,
-NodeId Id2) const {
-  assert(isMatchingPossible(Id1, Id2) &&
- "Matching must be possible in the first place.");
-  if (M.hasSrcDst(Id1, Id2))
-return false;
-  if (Options.EnableMatchingWithUnmatchableParents)
-return true;
-  const Node &N1 = T1.getNode(Id1);
-  const Node &N2 = T2.getNode(Id2);
-  NodeId P1 = N1.Parent;
-  NodeId P2 = N2.Parent;
-  // Only allow matching if parents can be matched.
-  return (P1.isInvalid() && P2.isInvalid()) ||
- (P1.isValid() && P2.isValid() && isMatchingPossible(P1, P2));
-}
-
 bool ASTDiff::Impl::isMatchingPossible(NodeId Id1, NodeId Id2) const {
   return Options.isMatchingAllowed(T1.getNode(Id1), T2.getNode(Id2));
 }
@@ -750,7 +706,7 @@
   for (const auto Tuple : R) {
 NodeId Src = Tuple.first;
 NodeId Dst = Tuple.second;
-if (canBeAddedToMapping(M, Src, Dst))
+if (!M.hasSrc(Src) && !M.hasDst(Dst))
   M.link(Src, Dst);
   }
 }
@@ -803,7 +759,7 @@
 if (Matched || !MatchedChildren)
   continue;
 NodeId Id2 = findCandidate(M, Id1);
-if (Id2.isValid() && canBeAddedToMapping(M, Id1, Id2)) {
+if (Id2.isValid()) {
   M.link(Id1, Id2);
   addOptimalMapping(M, Id1, Id2);
 }
@@ -814,7 +770,7 @@
   PriorityList L1(T1);
   PriorityList L2(T2);
 
-  Mapping M(T1.getSize(), T2.getSize());
+  Mapping M(T1.getSize() + T2.getSize());
 
   L1.push(T1.g

[PATCH] D36185: [clang-diff] Fix similarity computation

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109505.
johannes added a comment.

merge parent changes


https://reviews.llvm.org/D36185

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-bottomup.cpp
  test/Tooling/clang-diff-opt.cpp
  test/Tooling/clang-diff-topdown.cpp
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -50,6 +50,11 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
+static cl::opt StopAfter("stop-after",
+  cl::desc(""),
+  cl::Optional, cl::init(""),
+  cl::cat(ClangDiffCategory));
+
 static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
 cl::init(-1), cl::cat(ClangDiffCategory));
 
@@ -424,6 +429,14 @@
   diff::ComparisonOptions Options;
   if (MaxSize != -1)
 Options.MaxSize = MaxSize;
+  if (!StopAfter.empty()) {
+if (StopAfter == "topdown")
+  Options.StopAfterTopDown = true;
+else if (StopAfter != "bottomup") {
+  llvm::errs() << "Error: Invalid argument for -stop-after";
+  return 1;
+}
+  }
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
Index: test/Tooling/clang-diff-topdown.cpp
===
--- /dev/null
+++ test/Tooling/clang-diff-topdown.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -E %s > %t.src.cpp
+// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
+// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- | FileCheck %s
+//
+// Test the top-down matching of identical subtrees only.
+
+#ifndef DEST
+
+void f1()
+{
+  // Match some subtree of height greater than 2.
+  // CHECK: Match CompoundStmt(3) to CompoundStmt(3)
+  // CHECK: Match CompoundStmt(4) to CompoundStmt(4)
+  // CHECK: Match NullStmt(5) to NullStmt(5)
+  {{;}}
+
+  // Don't match subtrees that are smaller.
+  // CHECK-NOT: Match CompoundStmt(6)
+  // CHECK-NOT: Match NullStmt(7)
+  {;}
+
+  // Greedy approach - use the first matching subtree when there are multiple
+  // identical subtrees.
+  // CHECK: Match CompoundStmt(8) to CompoundStmt(8)
+  // CHECK: Match CompoundStmt(9) to CompoundStmt(9)
+  // CHECK: Match NullStmt(10) to NullStmt(10)
+  {{;;}}
+}
+
+#else
+
+void f1() {
+
+  {{;}}
+
+  {;}
+
+  {{;;}}
+  // CHECK-NOT: Match {{.*}} to CompoundStmt(11)
+  // CHECK-NOT: Match {{.*}} to CompoundStmt(12)
+  // CHECK-NOT: Match {{.*}} to NullStmt(13)
+  {{;;}}
+
+  // CHECK-NOT: Match {{.*}} to NullStmt(14)
+  ;
+}
+
+#endif
Index: test/Tooling/clang-diff-opt.cpp
===
--- /dev/null
+++ test/Tooling/clang-diff-opt.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -E %s > %t.src.cpp
+// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
+// RUN: clang-diff -dump-matches -s=10 %t.src.cpp %t.dst.cpp -- | FileCheck %s
+//
+// Test the behaviour of the matching according to the optimal tree edit
+// distance, implemented with Zhang and Shasha's algorithm.
+// Just for testing we use a tiny value of 10 for maxsize. Subtrees bigger than
+// this size will not be processed by the optimal algorithm.
+
+#ifndef DEST
+
+void f1() { {;} {{;}} }
+
+void f2() { {;} {{;}} }
+
+void f3() { {;} {{;;}} }
+
+#else
+
+void f1() {
+// Jaccard similarity = 3 / (5 + 4 - 3) = 3 / 6 >= 0.5
+// The optimal matching algorithm should move the ; into the outer block
+// CHECK: Match CompoundStmt(2) to CompoundStmt(2)
+// CHECK-NOT: Match CompoundStmt(3)
+// CHECK-NEXT: Match NullStmt(4) to NullStmt(3)
+  ; {{;}}
+}
+ 
+void f2() {
+  // Jaccard similarity = 7 / (10 + 10 - 7) >= 0.5
+  // As none of the subtrees is bigger than 10 nodes, the optimal algorithm
+  // will be run.
+  // CHECK: Match NullStmt(11) to NullStmt(9)
+  ;; {{;}}
+}
+
+void f3() {
+  // Jaccard similarity = 8 / (11 + 11 - 8) >= 0.5
+  // As the subtrees are bigger than 10 nodes, the optimal algorithm will not
+  // be run.
+  // CHECK: Delete NullStmt(22)
+  ;; {{;;}}
+}
+#endif
Index: test/Tooling/clang-diff-bottomup.cpp
===
--- /dev/null
+++ test/Tooling/clang-diff-bottomup.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -E %s > %t.src.cpp
+// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
+// RUN: clang-diff -dump-matches -s=0 %t.src.cpp %t.dst.cpp -- | FileCheck %s
+//
+// Test the bottom-up matching, with maxsize set to 0, so that the optimal matching will never be applied.
+
+#ifndef DEST
+
+void f1() { ; {{;}} }
+void f2() { ;; {{;}} }
+
+#else
+
+// Jaccard similarity threshold is 0.5.
+
+void f1() {
+// CompoundStmt: 3 m

[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Tooling/clang-diff-json.cpp:1
+// RUN: clang-diff -ast-dump %s -- | python -m json.tool | FileCheck %s
+

johannes wrote:
> arphaman wrote:
> > I think you have to use `%python` instead of `python`, like LLVM tests do.
> ok
> So I have to use python 2.7? (for the test in https://reviews.llvm.org/D36182)
Yeah, 2.7 support is still a requirement.


https://reviews.llvm.org/D36178



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


[PATCH] D36177: [clang-diff] Add commandline arguments.

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

I think you have to test the -p option too (check the compilation database can 
be loaded and arguments are propagated to the parser), otherwise LGTM!


https://reviews.llvm.org/D36177



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


[PATCH] D36181: [clang-diff] Make printing of matches optional

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D36181



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


[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added inline comments.



Comment at: test/Tooling/clang-diff-json.cpp:1
+// RUN: clang-diff -ast-dump %s -- | python -m json.tool | FileCheck %s
+

johannes wrote:
> arphaman wrote:
> > I think you have to use `%python` instead of `python`, like LLVM tests do.
> ok
> So I have to use python 2.7? (for the test in https://reviews.llvm.org/D36182)
It looks like %python is expanded in the wrong way.
I get the same as when using %Sython, the directory of the test case is 
substituted


https://reviews.llvm.org/D36178



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


[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Tooling/clang-diff-json.cpp:1
+// RUN: clang-diff -ast-dump %s -- | python -m json.tool | FileCheck %s
+

arphaman wrote:
> johannes wrote:
> > johannes wrote:
> > > arphaman wrote:
> > > > I think you have to use `%python` instead of `python`, like LLVM tests 
> > > > do.
> > > ok
> > > So I have to use python 2.7? (for the test in 
> > > https://reviews.llvm.org/D36182)
> > It looks like %python is expanded in the wrong way.
> > I get the same as when using %Sython, the directory of the test case is 
> > substituted
> Yeah, 2.7 support is still a requirement.
It might not be in the lit.cfg for Clang, let me check.


https://reviews.llvm.org/D36178



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


[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@johannes , you have to add %python substitution to lit.cfg, see my attached 
patch that does it.F4172676: python.diff 


https://reviews.llvm.org/D36178



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


[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

2017-08-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: xazax.hun, JDevlieghere.

The check doesn't fully support smart-ptr usages inside macros, which
may cause incorrect fixes, or even crashes, ignore them for now.


https://reviews.llvm.org/D36264

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.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
@@ -336,3 +336,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead
   // CHECK-FIXES: *Q = std::make_unique();
 }
+
+#define DEFINE(...) __VA_ARGS__
+template
+void g2(std::unique_ptr *t) {
+  DEFINE(auto p = std::unique_ptr(new Foo); t->reset(new Foo););
+}
+void macro() {
+  std::unique_ptr *t;
+  g2(t);
+}
+#undef DEFINE
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -111,9 +111,9 @@
   if (New->getNumPlacementArgs() != 0)
 return;
 
-  if (Construct)
+  if (Construct && !Construct->getLocation().isMacroID())
 checkConstruct(SM, Construct, Type, New);
-  else if (Reset)
+  else if (Reset && !Reset->getExprLoc().isMacroID())
 checkReset(SM, Reset, New);
 }
 


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -336,3 +336,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead
   // CHECK-FIXES: *Q = std::make_unique();
 }
+
+#define DEFINE(...) __VA_ARGS__
+template
+void g2(std::unique_ptr *t) {
+  DEFINE(auto p = std::unique_ptr(new Foo); t->reset(new Foo););
+}
+void macro() {
+  std::unique_ptr *t;
+  g2(t);
+}
+#undef DEFINE
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -111,9 +111,9 @@
   if (New->getNumPlacementArgs() != 0)
 return;
 
-  if (Construct)
+  if (Construct && !Construct->getLocation().isMacroID())
 checkConstruct(SM, Construct, Type, New);
-  else if (Reset)
+  else if (Reset && !Reset->getExprLoc().isMacroID())
 checkReset(SM, Reset, New);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36226: Added a RealFileSystem implementation that does not rely on global CWD.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 109524.
ilya-biryukov added a comment.

Added a very rough prototype of vfs::RealFileSystem not using openat.
Not ready for submission yet, wanted to start discussion about Windows 
implementation.


https://reviews.llvm.org/D36226

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -12,6 +12,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gtest/gtest.h"
 #include 
@@ -477,6 +478,75 @@
 }
 #endif
 
+TEST(VirtualFileSystemTest, ThreadFriendlyRealFSWorkingDirTest) {
+  ScopedDir TestDirectory("thread-friendly-vfs-test", /*Unique*/ true);
+
+  SmallString<128> PathA = TestDirectory.Path;
+  llvm::sys::path::append(PathA, "a");
+  SmallString<128> PathAC = PathA;
+  llvm::sys::path::append(PathAC, "c");
+  SmallString<128> PathB = TestDirectory.Path;
+  llvm::sys::path::append(PathB, "b");
+  SmallString<128> PathBD = PathB;
+  llvm::sys::path::append(PathBD, "d");
+
+  ScopedDir A(PathA);
+  ScopedDir AC(PathAC);
+  ScopedDir B(PathB);
+  ScopedDir BD(PathBD);
+
+  IntrusiveRefCntPtr FSA = vfs::createThreadFriendlyRealFS();
+  // setCurrentWorkingDirectory should fininsh without error
+  ASSERT_TRUE(!FSA->setCurrentWorkingDirectory(Twine(A)));
+
+  IntrusiveRefCntPtr FSB = vfs::createThreadFriendlyRealFS();
+  // setCurrentWorkingDirectory should fininsh without error
+  ASSERT_TRUE(!FSB->setCurrentWorkingDirectory(Twine(B)));
+
+  ASSERT_TRUE(FSA->getCurrentWorkingDirectory());
+  EXPECT_EQ(*FSA->getCurrentWorkingDirectory(), StringRef(A));
+
+  ASSERT_TRUE(FSB->getCurrentWorkingDirectory());
+  EXPECT_EQ(*FSB->getCurrentWorkingDirectory(), StringRef(B));
+
+  auto C = FSA->status("c");
+  // a/c should be found in FSA
+  ASSERT_TRUE(!!C);
+  // name of 'c' must be relative
+  EXPECT_EQ(C->getName(), "c");
+  EXPECT_TRUE(C->isDirectory());
+
+  // "a", "b" and "d" should not be found in FSA.
+  EXPECT_FALSE(!!FSA->status("a"));
+  EXPECT_FALSE(!!FSA->status("b"));
+  EXPECT_FALSE(!!FSA->status("d"));
+
+  auto D = FSB->status("d");
+  // b/d should be found in FSB
+  ASSERT_TRUE(!!D);
+  // name of 'd' must be relative
+  EXPECT_EQ(D->getName(), "d");
+  EXPECT_TRUE(D->isDirectory());
+
+  // "a", "b" and "c" should not be found in FSB.
+  EXPECT_FALSE(!!FSB->status("a"));
+  EXPECT_FALSE(!!FSB->status("b"));
+  EXPECT_FALSE(!!FSB->status("c"));
+
+  SmallString<128> RelPathC = StringRef("..");
+  llvm::sys::path::append(RelPathC, "a", "c");
+  auto RelCFromFSA = FSA->status(RelPathC);
+  ASSERT_TRUE(!!RelCFromFSA);
+  EXPECT_EQ(RelCFromFSA->getName(), StringRef(RelPathC));
+
+  auto RelCFromFSB = FSB->status(RelPathC);
+  ASSERT_TRUE(!!RelCFromFSB);
+  EXPECT_EQ(RelCFromFSB->getName(), StringRef(RelPathC));
+
+  EXPECT_TRUE(C->equivalent(*RelCFromFSA));
+  EXPECT_TRUE(C->equivalent(*RelCFromFSB));
+}
+
 template 
 static void checkContents(DirIter I, ArrayRef ExpectedOut) {
   std::error_code EC;
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -189,59 +189,88 @@
 /// \brief The file system according to your operating system.
 class RealFileSystem : public FileSystem {
 public:
+  RealFileSystem();
+  ~RealFileSystem();
+
   ErrorOr status(const Twine &Path) override;
   ErrorOr> openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
 
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+
+private:
+  std::string WorkingDir;
+  int WorkingDirFD;
 };
 } // end anonymous namespace
 
+RealFileSystem::RealFileSystem() {
+  SmallString<128> CWD;
+
+  auto Err = llvm::sys::fs::openDirectoryForAt(".", /*ref*/WorkingDirFD, &CWD);
+  // TODO: handle errors gracefully.
+  assert(!Err && "couldn't open CWD'");
+
+  WorkingDir = CWD.str();
+}
+
+RealFileSystem::~RealFileSystem() {
+  sys::Process::SafelyCloseFileDescriptor(WorkingDirFD);
+}
+
 ErrorOr RealFileSystem::status(const Twine &Path) {
   sys::fs::file_status RealStatus;
-  if (std::error_code EC = sys::fs::status(Path, RealStatus))
+  // TODO: handle errors gracefully.
+  if (std::error_code EC = sys::fs::status_at(WorkingDirFD, Path, RealStatus))
 return EC;
   return Status::copyWithNewName(RealStatus, Path.str());
 }
 
 ErrorOr>
 RealFileSystem::openFileForRead(const Twine &Name) {
   int FD;
   SmallString<256> RealName;
-  if (std::error_code EC = sys::fs::openFileForRead(Name, FD, &RealName))
+  // TO

[PATCH] D36176: [clang-diff] Fix some errors and inconsistencies

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

LGTM. Although I'm not 100% sure it's fully NFC, so if you can't come up with a 
test please justify why.


https://reviews.llvm.org/D36176



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


[PATCH] D36226: Added a RealFileSystem implementation that does not rely on global CWD.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Requires changes in Support library to run correctly: 
https://reviews.llvm.org/D36265


https://reviews.llvm.org/D36226



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


[PATCH] D35787: [clang-tidy] Ignore vector in inefficient-vector-operation.

2017-08-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D35787#819007, @alexfh wrote:

> Should we look at whether the size is statically known?


Do you mean the size of the template type T in `vector`?  STL only provides 
a template specialization for `std::vector`, so I think excluding 
`vector` is probably enough, or am I missing anything here?


https://reviews.llvm.org/D35787



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


[PATCH] D36259: [OpenCL] Remove extra select functions from opencl-c.h

2017-08-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D36259#830122, @bader wrote:

> Out of curiosity: how did you detect this?
>  Can we use the same approach for writing tests?


Some user code generated call to a select function which we do not have in 
library, then Brian found that there are extra select function in opencl-c.h.

I guess that's just good luck. We still do not have a systematic approach to 
test opencl-c.h.


https://reviews.llvm.org/D36259



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.h:121-122
+public:
+  /// Returns the number of threads to use when shouldRunsynchronously() is
+  /// false. Must not be called if shouldRunsynchronously() is true.
+  unsigned getThreadsCount();

klimek wrote:
> Why not: 1 -> run synchronously, > 1, run in parallel?
Currently 1 means: start 1 worker thread to run async operations (that thread 
is separate from the main thread).
This makes sense for clangd, as if you do that, you still get code completion 
that doesn't wait for diagnostics to finish.
On the other hand, it's useful to have `-run-synchronously` for some tests.


https://reviews.llvm.org/D36261



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 109527.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

Addressed review comments.

- Fixed typos.
- Renamed SchedulingParams to SchedulingOptions.


https://reviews.llvm.org/D36261

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -273,16 +273,17 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
-/*RunSynchronously=*/false);
+SchedulingOptions::RunOnDefaultNumberOfThreads());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
 
 auto SourceFilename = getVirtualTestFilePath(SourceFileRelPath);
 
 FS.ExpectedFile = SourceFilename;
 
-// Have to sync reparses because RunSynchronously is false.
+// Have to sync reparses because requests are processed on the calling
+// thread.
 auto AddDocFuture = Server.addDocument(SourceFilename, SourceContents);
 
 auto Result = dumpASTWithoutMemoryLocs(Server, SourceFilename);
@@ -335,7 +336,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  SchedulingOptions::RunOnDefaultNumberOfThreads());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -380,7 +381,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  SchedulingOptions::RunOnDefaultNumberOfThreads());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -426,15 +427,15 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  SchedulingOptions::RunOnCallingThread());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
   FS.Files[FooCpp] = SourceContents;
   FS.ExpectedFile = FooCpp;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
@@ -457,7 +458,7 @@
  {"-xc++", "-target", "x86_64-linux-unknown",
   "-m64", "--gcc-toolchain=/randomusr"});
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  SchedulingOptions::RunOnCallingThread());
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -486,8 +487,8 @@
 )cpp";
   FS.Files[FooCpp] = SourceContents;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
@@ -517,7 +518,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  SchedulingOptions::RunOnDefaultNumberOfThreads());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -16,14 +16,30 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace clang::clangd;
 
-static llvm::cl::opt
-RunSynchronously("run-synchronously",
- llvm::cl::desc("Parse on main thread"),
- llvm::cl::init(false), llvm::cl::Hidden);
+static unsigned getDefaultThreadsCount() {
+  unsigned HardwareConcurrency = std::thread::hardware_concurrency();
+  // C++ standard says that hardware_concurrency()
+  // may return 0, fallback to 1 worker thread in
+  // that case.
+  if (HardwareConcurrency == 0)
+return 1;
+  return HardwareConcurrency;
+}
+
+static llvm::cl::opt
+ThreadsCount("j",
+ llvm::cl::desc("Number of parallel workers used by clangd."),
+ llvm::cl::init(getDefaultThread

[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ping.


https://reviews.llvm.org/D35917



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


[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added inline comments.



Comment at: include/clang/Driver/Options.td:2065
+def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">,
+  Group, HelpText<"Do not Place uninitialized constants in the "
+   "read-only data section instead of the common"

s/Place/place/



Comment at: lib/Driver/ToolChains/Clang.cpp:1523
+  CmdArgs.push_back("-muninit-const-in-rodata");
+  A->claim();
+}

What's happened if the `-muninit-const-in-rodata` is used without 
`-membedded-data`? Will the compiler shows a warning about unused command line 
option?


https://reviews.llvm.org/D35917



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


[PATCH] D36208: [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-03 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 109528.
atanasyan retitled this revision from "[mips] Enable target-specific attributes 
for MIPS64" to "[mips] Enable `long_call/short_call` attributes on MIPS64".
atanasyan edited the summary of this revision.
atanasyan added a comment.

Simplify and reduce the patch. Keep `mips16`, `micromips`, and `interrupt` 
attributes handling unchanged. The only MIPS specific attributes supported on 
MIPS64 targets are `long_call/short_call/far/near`.


Repository:
  rL LLVM

https://reviews.llvm.org/D36208

Files:
  include/clang/Basic/Attr.td
  test/CodeGen/long-call-attr.c
  test/Sema/attr-long-call.c


Index: test/Sema/attr-long-call.c
===
--- test/Sema/attr-long-call.c
+++ test/Sema/attr-long-call.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' 
attribute takes no arguments}}
 __attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' 
attribute takes no arguments}}
Index: test/CodeGen/long-call-attr.c
===
--- test/CodeGen/long-call-attr.c
+++ test/CodeGen/long-call-attr.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
 void __attribute__((short_call)) foo4 (void);
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -265,6 +265,7 @@
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
 def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -1188,13 +1189,13 @@
   let Documentation = [MicroMipsDocs];
 }
 
-def MipsLongCall : InheritableAttr, TargetSpecificAttr {
+def MipsLongCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"long_call">, GCC<"far">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsLongCallStyleDocs];
 }
 
-def MipsShortCall : InheritableAttr, TargetSpecificAttr {
+def MipsShortCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"short_call">, GCC<"near">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsShortCallStyleDocs];


Index: test/Sema/attr-long-call.c
===
--- test/Sema/attr-long-call.c
+++ test/Sema/attr-long-call.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
 __attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' attribute takes no arguments}}
Index: test/CodeGen/long-call-attr.c
===
--- test/CodeGen/long-call-attr.c
+++ test/CodeGen/long-call-attr.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
 void __attribute__((short_call)) foo4 (void);
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -265,6 +265,7 @@
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
 def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -1188,13 +1189,13 @@
   let Documentation = [MicroMipsDocs];
 }
 
-def MipsLongCall : InheritableAttr, TargetSpecificAttr {
+def MipsLongCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"long_call">, GCC<"far">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsLongCallStyleDocs];
 }
 
-def MipsShortCall : InheritableAttr, TargetSpecificAttr {
+def MipsShortCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"short_call">, GCC<"near">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsShortCallStyleDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.

Re: [clang-tools-extra] r308721 - [clangd] Specified --gcc-toolchain explicitly in VFS test.

2017-08-03 Thread NAKAMURA Takumi via cfe-commits
My builder is failing,

[ RUN  ] ClangdVFSTest.SearchLibDir
/home/bb/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/clang-tools-extra/unittests/clangd/ClangdTests.cpp:492:
Failure
Value of: DiagConsumer.hadErrorInLastDiags()
  Actual: true
Expected: false
[  FAILED  ] ClangdVFSTest.SearchLibDir (11 ms)

As a special configuration, it has CLANG_DEFAULT_CXX_STDLIB=libc++
Seems adding "-stdlib=libstdc++" in CDB.ExtraClangFlags will fix.
How do you think?


On Fri, Jul 21, 2017 at 5:21 PM Ilya Biryukov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Fri Jul 21 01:20:47 2017
> New Revision: 308721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308721&view=rev
> Log:
> [clangd] Specified --gcc-toolchain explicitly in VFS test.
>
> In order to avoid platform-specific configuration quirks.
> (Possible fix for https://bugs.llvm.org/show_bug.cgi?id=33842)
>
> Modified:
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>
> Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=308721&r1=308720&r2=308721&view=diff
>
> ==
> --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
> +++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Fri Jul 21
> 01:20:47 2017
> @@ -422,9 +422,9 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>MockFSProvider FS;
>ErrorCheckingDiagConsumer DiagConsumer;
>MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
> -  CDB.ExtraClangFlags.insert(
> -  CDB.ExtraClangFlags.end(),
> -  {"-xc++", "-target", "x86_64-linux-unknown", "-m64"});
> +  CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
> + {"-xc++", "-target", "x86_64-linux-unknown",
> +  "-m64", "--gcc-toolchain=/randomusr"});
>ClangdServer Server(CDB, DiagConsumer, FS,
>/*RunSynchronously=*/true);
>
> @@ -432,7 +432,7 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>SmallString<8> Version("4.9.3");
>
>// A lib dir for gcc installation
> -  SmallString<64> LibDir("/usr/lib/gcc/x86_64-linux-gnu");
> +  SmallString<64> LibDir("/randomusr/lib/gcc/x86_64-linux-gnu");
>llvm::sys::path::append(LibDir, Version);
>
>// Put crtbegin.o into LibDir/64 to trick clang into thinking there's a
> gcc
> @@ -441,7 +441,7 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>llvm::sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o");
>FS.Files[DummyLibFile] = "";
>
> -  SmallString<64> IncludeDir("/usr/include/c++");
> +  SmallString<64> IncludeDir("/randomusr/include/c++");
>llvm::sys::path::append(IncludeDir, Version);
>
>SmallString<64> StringPath;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309935 - [mips] Add support -m(no-)embedded-data option

2017-08-03 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Thu Aug  3 06:04:29 2017
New Revision: 309935

URL: http://llvm.org/viewvc/llvm-project?rev=309935&view=rev
Log:
[mips] Add support -m(no-)embedded-data option

Add support for the -membedded-data option which places constant data in
the .rodata section, rather than the .sdata section.

Reviewers: atanasyan, nitesh.jain

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=309935&r1=309934&r2=309935&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug  3 06:04:29 2017
@@ -2051,6 +2051,12 @@ def mextern_sdata : Flag<["-"], "mextern
 def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group,
   HelpText<"Do not assume that externally defined data is in the small data if"
" it meets the -G  threshold (MIPS)">;
+def membedded_data : Flag<["-"], "membedded-data">, Group,
+  HelpText<"Place constants in the .rodata section instead of the .sdata "
+   "section even if they meet the -G  threshold (MIPS)">;
+def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
+  HelpText<"Do not place constants in the .rodata section instead of the "
+   ".sdata if they meet the -G  threshold (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=309935&r1=309934&r2=309935&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Aug  3 06:04:29 2017
@@ -1484,7 +1484,9 @@ void Clang::AddMIPSTargetArgs(const ArgL
 Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata,
   options::OPT_mno_local_sdata);
 Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata,
-  options::OPT_mno_extern_sdata);
+   options::OPT_mno_extern_sdata);
+Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data,
+options::OPT_mno_embedded_data);
 if (LocalSData) {
   CmdArgs.push_back("-mllvm");
   if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) {
@@ -1504,6 +1506,17 @@ void Clang::AddMIPSTargetArgs(const ArgL
   }
   ExternSData->claim();
 }
+
+if (EmbeddedData) {
+  CmdArgs.push_back("-mllvm");
+  if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) {
+CmdArgs.push_back("-membedded-data=1");
+  } else {
+CmdArgs.push_back("-membedded-data=0");
+  }
+  EmbeddedData->claim();
+}
+
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
 D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1);
 

Modified: cfe/trunk/test/Driver/mips-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=309935&r1=309934&r2=309935&view=diff
==
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Thu Aug  3 06:04:29 2017
@@ -65,6 +65,21 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s
 // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata"
 //
+// -mno-abicalls -mgpopt -membedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 
-mno-embedded-data -membedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s
+// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1"
+//
+// -mno-abicalls -mgpopt -mno-embedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 
-membedded-data -mno-embedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s
+// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
+// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \


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


[PATCH] D35914: [mips] Add support -m(no-)embedded-data option

2017-08-03 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309935: [mips] Add support -m(no-)embedded-data option 
(authored by sdardis).

Repository:
  rL LLVM

https://reviews.llvm.org/D35914

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/mips-features.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1484,7 +1484,9 @@
 Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata,
   options::OPT_mno_local_sdata);
 Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata,
-  options::OPT_mno_extern_sdata);
+   options::OPT_mno_extern_sdata);
+Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data,
+options::OPT_mno_embedded_data);
 if (LocalSData) {
   CmdArgs.push_back("-mllvm");
   if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) {
@@ -1504,6 +1506,17 @@
   }
   ExternSData->claim();
 }
+
+if (EmbeddedData) {
+  CmdArgs.push_back("-mllvm");
+  if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) {
+CmdArgs.push_back("-membedded-data=1");
+  } else {
+CmdArgs.push_back("-membedded-data=0");
+  }
+  EmbeddedData->claim();
+}
+
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
 D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1);
 
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2051,6 +2051,12 @@
 def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group,
   HelpText<"Do not assume that externally defined data is in the small data if"
" it meets the -G  threshold (MIPS)">;
+def membedded_data : Flag<["-"], "membedded-data">, Group,
+  HelpText<"Place constants in the .rodata section instead of the .sdata "
+   "section even if they meet the -G  threshold (MIPS)">;
+def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
+  HelpText<"Do not place constants in the .rodata section instead of the "
+   ".sdata if they meet the -G  threshold (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -65,6 +65,21 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s
 // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata"
 //
+// -mno-abicalls -mgpopt -membedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 
-mno-embedded-data -membedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s
+// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1"
+//
+// -mno-abicalls -mgpopt -mno-embedded-data
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 
-membedded-data -mno-embedded-data 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s
+// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
+// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1484,7 +1484,9 @@
 Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata,
   options::OPT_mno_local_sdata);
 Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata,
-  options::OPT_mno_extern_sdata);
+   options::OPT_mno_extern_sdata);
+Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data,
+options::OPT_mno_embedded_data);
 if (LocalSData) {
   CmdArgs.push_back("-mllvm");
   if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) {
@@ -1504,6 +1506,17 @@
   }
   ExternSData->claim();
 }
+
+if (EmbeddedData) {
+  CmdArgs.push_back("-mllvm");
+  if (EmbeddedData->getOption().matches(

[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Great!




Comment at: clangd/ClangdServer.h:131
+
 /// Handles running WorkerRequests of ClangdServer on a separate threads.
 /// Currently runs only one worker thread.

typo: "on separate threads"



Comment at: clangd/ClangdServer.h:176
   std::mutex Mutex;
   /// We run some tasks on a separate threads(parsing, CppFile cleanup).
   /// This thread looks into RequestQueue to find requests to handle and

typo: "on separate threads"



Comment at: clangd/tool/ClangdMain.cpp:24
 
-static llvm::cl::opt
-RunSynchronously("run-synchronously",
- llvm::cl::desc("Parse on main thread"),
- llvm::cl::init(false), llvm::cl::Hidden);
+static unsigned getDefaultThreadsCount() {
+  unsigned HardwareConcurrency = std::thread::hardware_concurrency();

Extract this somewhere when it can be reused both by this and in 
`clangd/ClangdServer.cpp:90`.



Comment at: clangd/tool/ClangdMain.cpp:69
+  SchedulingOptions SchedOpts =
+  !RunSynchronously ? SchedulingOptions::RunOnWorkerThreads(ThreadsCount)
+: SchedulingOptions::RunOnCallingThread();

Consider inverting this condition.


https://reviews.llvm.org/D36261



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 109532.
ilya-biryukov added a comment.

- Removed SchedulingOptions altogether, replaced with AsyncThreadsCount.


https://reviews.llvm.org/D36261

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -272,17 +272,17 @@
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
-ClangdServer Server(CDB, DiagConsumer, FS,
-/*RunSynchronously=*/false);
+ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
 
 auto SourceFilename = getVirtualTestFilePath(SourceFileRelPath);
 
 FS.ExpectedFile = SourceFilename;
 
-// Have to sync reparses because RunSynchronously is false.
+// Have to sync reparses because requests are processed on the calling
+// thread.
 auto AddDocFuture = Server.addDocument(SourceFilename, SourceContents);
 
 auto Result = dumpASTWithoutMemoryLocs(Server, SourceFilename);
@@ -334,8 +334,7 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -379,8 +378,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -425,16 +423,17 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  /*AsyncThreadsCount=*/0);
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
   FS.Files[FooCpp] = SourceContents;
   FS.ExpectedFile = FooCpp;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
@@ -456,8 +455,9 @@
   CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
  {"-xc++", "-target", "x86_64-linux-unknown",
   "-m64", "--gcc-toolchain=/randomusr"});
+  // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  /*AsyncThreadsCount=*/0);
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -486,8 +486,8 @@
 )cpp";
   FS.Files[FooCpp] = SourceContents;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
@@ -516,8 +516,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -16,14 +16,20 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace clang::clangd;
 
-static llvm::cl::opt
-RunSynchronously("run-synchronously",
- llvm::cl::desc("Parse on main thread"),
- llvm::cl::init(false), llvm::cl::Hidden);
+static llvm::cl::opt
+WorkerThreadsCount("j",
+   llvm::cl::desc("Number of async workers used by clangd"),
+   llvm::cl::init(getDefaultAsyncThreadsCount()));
+
+static llvm::cl::opt RunSynchronously(
+"run-synchronously",
+llvm::cl::d

[PATCH] D36176: [clang-diff] Fix some errors and inconsistencies

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

In https://reviews.llvm.org/D36176#830341, @arphaman wrote:

> LGTM. Although I'm not 100% sure it's fully NFC, so if you can't come up with 
> a test please justify why.


There are changes that affect the output.
Firstly the computation of the rightmost descendant; the added assertion fails 
every time with the old version.
Secondly, the change around line 811 prevents root nodes from being mapped if 
they are already mapped. When comparing translation units this happens only if 
the two trees are identical (in this case the output would not change). 
Otherwise, it would require some change in the client to demonstrate how the 
behaviour changed. One needs to compare AST Nodes other than entire translation 
units. At some point there will be something that uses this feature so we cover 
it too (or remove the feature). So I'd keep it like this


https://reviews.llvm.org/D36176



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:69
+  SchedulingOptions SchedOpts =
+  !RunSynchronously ? SchedulingOptions::RunOnWorkerThreads(ThreadsCount)
+: SchedulingOptions::RunOnCallingThread();

krasimir wrote:
> Consider inverting this condition.
Thanks, good point. I also like non-negated conditions more.
That code was removed in the updated version, though.


https://reviews.llvm.org/D36261



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 109534.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Fixed more typos/inconsistences in comments, pointed out by @krasimir.


https://reviews.llvm.org/D36261

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -272,17 +272,17 @@
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
-ClangdServer Server(CDB, DiagConsumer, FS,
-/*RunSynchronously=*/false);
+ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
 
 auto SourceFilename = getVirtualTestFilePath(SourceFileRelPath);
 
 FS.ExpectedFile = SourceFilename;
 
-// Have to sync reparses because RunSynchronously is false.
+// Have to sync reparses because requests are processed on the calling
+// thread.
 auto AddDocFuture = Server.addDocument(SourceFilename, SourceContents);
 
 auto Result = dumpASTWithoutMemoryLocs(Server, SourceFilename);
@@ -334,8 +334,7 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -379,8 +378,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -425,16 +423,17 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  /*AsyncThreadsCount=*/0);
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
   FS.Files[FooCpp] = SourceContents;
   FS.ExpectedFile = FooCpp;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
@@ -456,8 +455,9 @@
   CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
  {"-xc++", "-target", "x86_64-linux-unknown",
   "-m64", "--gcc-toolchain=/randomusr"});
+  // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/true);
+  /*AsyncThreadsCount=*/0);
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -486,8 +486,8 @@
 )cpp";
   FS.Files[FooCpp] = SourceContents;
 
-  // No need to sync reparses, because RunSynchronously is set
-  // to true.
+  // No need to sync reparses, because requests are processed on the calling
+  // thread.
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
@@ -516,8 +516,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -16,14 +16,20 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace clang::clangd;
 
-static llvm::cl::opt
-RunSynchronously("run-synchronously",
- llvm::cl::desc("Parse on main thread"),
- llvm::cl::init(false), llvm::cl::Hidden);
+static llvm::cl::opt
+WorkerThreadsCount("j",
+   llvm::cl::desc("Number of async workers used by clangd"),
+   llvm::cl::init(getDefaultAsyncThreadsCount()));
+
+static llvm::cl::opt RunSynchrono

[PATCH] D36176: [clang-diff] Fix some errors and inconsistencies

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ok, please include this info in the commit message.


https://reviews.llvm.org/D36176



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


Re: [clang-tools-extra] r308721 - [clangd] Specified --gcc-toolchain explicitly in VFS test.

2017-08-03 Thread Ilya Biryukov via cfe-commits
Seems like a proper fix. Do you want me to submit it for you?

On Thu, Aug 3, 2017 at 3:03 PM, NAKAMURA Takumi 
wrote:

> My builder is failing,
>
> [ RUN  ] ClangdVFSTest.SearchLibDir
> /home/bb/bootstrap-clang-libcxx-lld-i686-linux/llvm-
> project/clang-tools-extra/unittests/clangd/ClangdTests.cpp:492: Failure
> Value of: DiagConsumer.hadErrorInLastDiags()
>   Actual: true
> Expected: false
> [  FAILED  ] ClangdVFSTest.SearchLibDir (11 ms)
>
> As a special configuration, it has CLANG_DEFAULT_CXX_STDLIB=libc++
> Seems adding "-stdlib=libstdc++" in CDB.ExtraClangFlags will fix.
> How do you think?
>
>
> On Fri, Jul 21, 2017 at 5:21 PM Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Fri Jul 21 01:20:47 2017
>> New Revision: 308721
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=308721&view=rev
>> Log:
>> [clangd] Specified --gcc-toolchain explicitly in VFS test.
>>
>> In order to avoid platform-specific configuration quirks.
>> (Possible fix for https://bugs.llvm.org/show_bug.cgi?id=33842)
>>
>> Modified:
>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>
>> Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
>> trunk/unittests/clangd/ClangdTests.cpp?rev=308721&r1=
>> 308720&r2=308721&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
>> +++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Fri Jul 21
>> 01:20:47 2017
>> @@ -422,9 +422,9 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>>MockFSProvider FS;
>>ErrorCheckingDiagConsumer DiagConsumer;
>>MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
>> -  CDB.ExtraClangFlags.insert(
>> -  CDB.ExtraClangFlags.end(),
>> -  {"-xc++", "-target", "x86_64-linux-unknown", "-m64"});
>> +  CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
>> + {"-xc++", "-target", "x86_64-linux-unknown",
>> +  "-m64", "--gcc-toolchain=/randomusr"});
>>ClangdServer Server(CDB, DiagConsumer, FS,
>>/*RunSynchronously=*/true);
>>
>> @@ -432,7 +432,7 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>>SmallString<8> Version("4.9.3");
>>
>>// A lib dir for gcc installation
>> -  SmallString<64> LibDir("/usr/lib/gcc/x86_64-linux-gnu");
>> +  SmallString<64> LibDir("/randomusr/lib/gcc/x86_64-linux-gnu");
>>llvm::sys::path::append(LibDir, Version);
>>
>>// Put crtbegin.o into LibDir/64 to trick clang into thinking there's
>> a gcc
>> @@ -441,7 +441,7 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
>>llvm::sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o");
>>FS.Files[DummyLibFile] = "";
>>
>> -  SmallString<64> IncludeDir("/usr/include/c++");
>> +  SmallString<64> IncludeDir("/randomusr/include/c++");
>>llvm::sys::path::append(IncludeDir, Version);
>>
>>SmallString<64> StringPath;
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>


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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done.
yaxunl added inline comments.



Comment at: include/clang/Basic/Builtins.def:717
+ATOMIC_BUILTIN(__opencl_atomic_fetch_max, "v.", "t")
+
 #undef ATOMIC_BUILTIN

t-tye wrote:
> Will the OpenCL 2.0 memory fences also be supported which also have a memory 
> order and memory scope?
I am considering supporting it with a separate patch since this patch is 
already quite large.



Comment at: include/clang/Basic/SyncScope.h:23
+enum class SyncScope {
+  OpenCLWorkItem = 0,
+  OpenCLWorkGroup = 1,

t-tye wrote:
> The OpenCL workitem scope is only used for image fences and does not apply to 
> atomic operations so not sure that it should be in this enumeration which is 
> used only for memory atomics.
You are right. I think we should drop it from this enum for now.



Comment at: lib/CodeGen/CGAtomic.cpp:896
+return V;
+  auto DestAS = getContext().getTargetAddressSpace(LangAS::opencl_generic);
+  auto T = V->getType();

rjmccall wrote:
> You can sink this line and the next.
will do.



Comment at: lib/CodeGen/CGCall.cpp:3911
+  V = Builder.CreateBitOrPointerCast(V,
+  IRFuncTy->getParamType(FirstIRArg));
 

rjmccall wrote:
> No.  Callers should ensure that they've added the right argument type, at 
> least at the level of address spaces.
Will remove.



Comment at: lib/CodeGen/TargetInfo.cpp:7554-7555
+  switch (S) {
+  case SyncScope::OpenCLWorkItem:
+Name = "singlethread";
+break;

t-tye wrote:
> OpenCL only uses workitem for image fences which are not the same as atomic 
> memory fences.
> 
> For image fences I don't think it would map to singlethread which is intended 
> for signal handler support to ensure a signal handler has visibility of the 
> updates done by a thread which is more of an optimization barrier. In 
> contrast an image fence may need to flush caches to make the image and vector 
> access paths coherent in a single thread.
> 
> Since this patch does not support fences probably want to leave workitem 
> scope out. Current AMDGPU targets do not need to do anything for an OpenCL 
> image fence, but other targets may need to generate an intrinsic since there 
> is no LLVMIR instruction for this.
Thanks. I will remove this for now.



Comment at: lib/Headers/opencl-c.h:13145-13150
   memory_scope_work_item,
   memory_scope_work_group,
   memory_scope_device,
   memory_scope_all_svm_devices,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
   memory_scope_sub_group

t-tye wrote:
> Do these have to have the same values as the SycnScope enumeration? Should 
> that be ensured in a similar way to the memory_order enumeration?
It is desirable to have the same value as SyncScope enumeration, otherwise the 
library has to do the translation when calling __opencl_atomic_* builtins.

Will do.



Comment at: lib/Sema/SemaChecking.cpp:3160
+Op == AtomicExpr::AO__opencl_atomic_load)
+? 0
+: 1);

Anastasia wrote:
> Could we merge this and the line after please.
will do



Comment at: lib/Sema/SemaChecking.cpp:3103
+Diag(Scope->getLocStart(),
+ diag::err_atomic_op_has_non_constant_synch_scope)
+<< Scope->getSourceRange();

rjmccall wrote:
> t-tye wrote:
> > IIRC OpenCL allows the scope to be a runtime value. So will doing this will 
> > likely cause failures in conformance?
> Ah, if that's true, you'll need to emit a switch in IRGen, the same way we 
> handle non-constant memory orders.
Will support it in another patch since this one is already quite large.


https://reviews.llvm.org/D28691



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


[clang-tools-extra] r309936 - ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.

2017-08-03 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Aug  3 06:30:43 2017
New Revision: 309936

URL: http://llvm.org/viewvc/llvm-project?rev=309936&view=rev
Log:
ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.

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

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=309936&r1=309935&r2=309936&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Thu Aug  3 
06:30:43 2017
@@ -455,7 +455,8 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(),
  {"-xc++", "-target", "x86_64-linux-unknown",
-  "-m64", "--gcc-toolchain=/randomusr"});
+  "-m64", "--gcc-toolchain=/randomusr",
+  "-stdlib=libstdc++"});
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 


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


[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109537.
johannes added a comment.

use %python in tests


https://reviews.llvm.org/D36178

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-json.cpp
  test/lit.cfg
  test/lit.site.cfg.in
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -94,6 +94,65 @@
   return std::move(ASTs[0]);
 }
 
+static char hexdigit(int N) { return N &= 0xf, N + (N < 10 ? '0' : 'a' - 10); }
+
+static void printJsonString(raw_ostream &OS, const StringRef Str) {
+  for (char C : Str) {
+switch (C) {
+case '"':
+  OS << R"(\")";
+  break;
+case '\\':
+  OS << R"(\\)";
+  break;
+case '\n':
+  OS << R"(\n)";
+  break;
+case '\t':
+  OS << R"(\t)";
+  break;
+default:
+  if ('\x00' <= C && C <= '\x1f') {
+OS << R"(\u00)" << hexdigit(C >> 4) << hexdigit(C);
+  } else {
+OS << C;
+  }
+}
+  }
+}
+
+static void printNodeAttributes(raw_ostream &OS, diff::SyntaxTree &Tree,
+diff::NodeId Id) {
+  const diff::Node &N = Tree.getNode(Id);
+  OS << R"("id":)" << int(Id);
+  OS << R"(,"type":")" << N.getTypeLabel() << '"';
+  auto Offsets = Tree.getSourceRangeOffsets(N);
+  OS << R"(,"begin":)" << Offsets.first;
+  OS << R"(,"end":)" << Offsets.second;
+  std::string Value = Tree.getNodeValue(N.ASTNode);
+  if (!Value.empty()) {
+OS << R"(,"value":")";
+printJsonString(OS, Value);
+OS << '"';
+  }
+}
+
+static void printNodeAsJson(raw_ostream &OS, diff::SyntaxTree &Tree,
+diff::NodeId Id) {
+  const diff::Node &N = Tree.getNode(Id);
+  OS << "{";
+  printNodeAttributes(OS, Tree, Id);
+  OS << R"(,"children":[)";
+  if (N.Children.size() > 0) {
+printNodeAsJson(OS, Tree, N.Children[0]);
+for (size_t I = 1, E = N.Children.size(); I < E; ++I) {
+  OS << ",";
+  printNodeAsJson(OS, Tree, N.Children[I]);
+}
+  }
+  OS << "]}";
+}
+
 int main(int argc, const char **argv) {
   std::string ErrorMessage;
   std::unique_ptr CommonCompilations =
@@ -117,7 +176,11 @@
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
-Tree.printAsJson(llvm::outs());
+llvm::outs() << R"({"filename":")";
+printJsonString(llvm::outs(), SourcePath);
+llvm::outs() << R"(","root":)";
+printNodeAsJson(llvm::outs(), Tree, Tree.getRootId());
+llvm::outs() << "}\n";
 return 0;
   }
 
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -25,6 +25,7 @@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
 config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -276,6 +276,7 @@
 config.substitutions.append( ('%itanium_abi_triple', makeItaniumABITriple(config.target_triple)) )
 config.substitutions.append( ('%ms_abi_triple', makeMSABITriple(config.target_triple)) )
 config.substitutions.append( ('%resource_dir', getClangBuiltinIncludeDir(config.clang)) )
+config.substitutions.append( ('%python', config.python_executable) )
 
 # The host triple might not be set, at least if we're compiling clang from
 # an already installed llvm.
Index: test/Tooling/clang-diff-json.cpp
===
--- /dev/null
+++ test/Tooling/clang-diff-json.cpp
@@ -0,0 +1,27 @@
+// RUN: clang-diff -ast-dump %s -- \
+// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN: | FileCheck %s
+
+// CHECK: "begin": 294,
+// CHECK: "type": "CXXRecordDecl",
+// CHECK: "type": "FieldDecl",
+// CHECK: "end": 314,
+class A {
+  int x;
+};
+
+// CHECK: "children": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "begin":
+// CHECK-NEXT: "children": []
+// CHECK-NEXT: "end":
+// CHECK-NEXT: "id":
+// CHECK-NEXT: "type": "CharacterLiteral"
+// CHECK-NEXT: }
+// CHECK: ]
+// CHECK: "type": "VarDecl",
+char nl = '\n';
+
+// CHECK: "value": "abc \n\t\u\u001f\u0123 \ub370\ubc15"
+char s[] = "abc \n\t\0\x1f\u0123 데박";
+
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -176,9 +176,6 @@
   void printTree(NodeId Root) const;
   void printTree(raw_ostream &OS, NodeId Root) const;
 
-  void printAsJsonImpl(raw_ostream &OS) const;
-  void printNodeA

[PATCH] D36180: [clang-diff] Add option to dump the AST, one node per line

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109538.
johannes added a comment.

merge update


https://reviews.llvm.org/D36180

Files:
  test/Tooling/clang-diff-ast.cpp
  test/Tooling/clang-diff-json.cpp
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -25,9 +25,14 @@
 
 static cl::opt
 ASTDump("ast-dump",
-cl::desc("Print the internal representation of the AST as JSON."),
+cl::desc("Print the internal representation of the AST."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt ASTDumpJson(
+"ast-dump-json",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -166,6 +171,15 @@
   OS << "(" << Id << ")";
 }
 
+static void printTree(raw_ostream &OS, diff::SyntaxTree &Tree) {
+  for (diff::NodeId Id : Tree) {
+for (int I = 0; I < Tree.getNode(Id).Depth; ++I)
+  OS << " ";
+printNode(OS, Tree, Id);
+OS << "\n";
+  }
+}
+
 static void printDstChange(raw_ostream &OS, diff::ASTDiff &Diff,
diff::SyntaxTree &SrcTree, diff::SyntaxTree &DstTree,
diff::NodeId Dst) {
@@ -213,15 +227,19 @@
 
   addExtraArgs(CommonCompilations);
 
-  if (ASTDump) {
+  if (ASTDump || ASTDumpJson) {
 if (!DestinationPath.empty()) {
   llvm::errs() << "Error: Please specify exactly one filename.\n";
   return 1;
 }
 std::unique_ptr AST = getAST(CommonCompilations, SourcePath);
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
+if (ASTDump) {
+  printTree(llvm::outs(), Tree);
+  return 0;
+}
 llvm::outs() << R"({"filename":")";
 printJsonString(llvm::outs(), SourcePath);
 llvm::outs() << R"(","root":)";
Index: test/Tooling/clang-diff-json.cpp
===
--- test/Tooling/clang-diff-json.cpp
+++ test/Tooling/clang-diff-json.cpp
@@ -1,11 +1,11 @@
-// RUN: clang-diff -ast-dump %s -- \
+// RUN: clang-diff -ast-dump-json %s -- \
 // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 294,
+// CHECK: "begin": 299,
 // CHECK: "type": "CXXRecordDecl",
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 314,
+// CHECK: "end": 319,
 class A {
   int x;
 };
Index: test/Tooling/clang-diff-ast.cpp
===
--- /dev/null
+++ test/Tooling/clang-diff-ast.cpp
@@ -0,0 +1,50 @@
+// RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
+
+
+// CHECK: {{^}}TranslationUnitDecl(0)
+// CHECK: {{^}} NamespaceDecl: test;(
+namespace test {
+
+// CHECK: {{^}}  FunctionDecl: f(
+// CHECK: CompoundStmt(
+void f() {
+  // CHECK: VarDecl: i(int)(
+  // CHECK: IntegerLiteral: 1
+  auto i = 1;
+  // CHECK: CallExpr(
+  // CHECK: DeclRefExpr: f(
+  f();
+  // CHECK: BinaryOperator: =(
+  i = i;
+}
+
+} // end namespace test
+
+// CHECK: TypedefDecl: nat;unsigned int;(
+typedef unsigned nat;
+// CHECK: TypeAliasDecl: real;double;(
+using real = double;
+
+class Base {
+};
+
+// CHECK: CXXRecordDecl: X;class X;(
+class X : Base {
+  int m;
+  // CHECK: CXXMethodDecl: foo(const char *(int))(
+  // CHECK: ParmVarDecl: i(int)(
+  const char *foo(int i) {
+if (i == 0)
+  // CHECK: StringLiteral: foo(
+  return "foo";
+return 0;
+  }
+
+  // CHECK: AccessSpecDecl: public(
+public:
+  // CHECK: CXXConstructorDecl: X(void (char, int))(
+  X(char, int) : Base(), m(0) {
+// CHECK: MemberExpr(
+int x = m;
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36182: [clang-diff] Add HTML side-by-side diff output

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109539.
johannes added a comment.

make test work with python 2


https://reviews.llvm.org/D36182

Files:
  test/Tooling/Inputs/clang-diff-basic-src.cpp
  test/Tooling/clang-diff-basic.cpp
  test/Tooling/clang-diff-html.py
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -37,6 +37,10 @@
 PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
  cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt HtmlDiff("html",
+  cl::desc("Output a side-by-side diff in HTML."),
+  cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -105,6 +109,161 @@
 
 static char hexdigit(int N) { return N &= 0xf, N + (N < 10 ? '0' : 'a' - 10); }
 
+static const char HtmlDiffHeader[] = R"(
+
+
+
+
+span.d { color: red; }
+span.u { color: #cc00cc; }
+span.i { color: green; }
+span.m { font-weight: bold; }
+span   { font-weight: normal; color: black; }
+div.code {
+  width: 48%;
+  height: 98%;
+  overflow: scroll;
+  float: left;
+  padding: 0 0 0.5% 0.5%;
+  border: solid 2px LightGrey;
+  border-radius: 5px;
+}
+
+
+
+highlightStack = []
+function clearHighlight() {
+  while (highlightStack.length) {
+let [l, r] = highlightStack.pop()
+document.getElementById(l).style.backgroundColor = 'white'
+document.getElementById(r).style.backgroundColor = 'white'
+  }
+}
+function highlight(event) {
+  id = event.target['id']
+  doHighlight(id)
+}
+function doHighlight(id) {
+  clearHighlight()
+  source = document.getElementById(id)
+  if (!source.attributes['tid'])
+return
+  tid = source.attributes['tid'].value
+  target = document.getElementById(tid)
+  if (!target || source.parentElement && source.parentElement.classList.contains('code'))
+return
+  source.style.backgroundColor = target.style.backgroundColor = 'lightgrey'
+  highlightStack.push([id, tid])
+  source.scrollIntoView()
+  target.scrollIntoView()
+  location.hash = '#' + id
+}
+function scrollToBoth() {
+  doHighlight(location.hash.substr(1))
+}
+window.onload = scrollToBoth
+
+
+
+)";
+
+static void printHtml(raw_ostream &OS, char C) {
+  switch (C) {
+  case '&':
+OS << "&";
+break;
+  case '<':
+OS << "<";
+break;
+  case '>':
+OS << ">";
+break;
+  case '\'':
+OS << "'";
+break;
+  case '"':
+OS << """;
+break;
+  default:
+OS << C;
+  }
+}
+
+static void printHtml(raw_ostream &OS, const StringRef Str) {
+  for (char C : Str)
+printHtml(OS, C);
+}
+
+static std::string getChangeKindAbbr(diff::ChangeKind Kind) {
+  switch (Kind) {
+  case diff::None:
+return "";
+  case diff::Delete:
+return "d";
+  case diff::Update:
+return "u";
+  case diff::Insert:
+return "i";
+  case diff::Move:
+return "m";
+  case diff::UpdateMove:
+return "u m";
+  }
+}
+
+static unsigned printHtmlForNode(raw_ostream &OS, const diff::ASTDiff &Diff,
+ diff::SyntaxTree &Tree, bool IsLeft,
+ diff::NodeId Id, unsigned Offset) {
+  const diff::Node &Node = Tree.getNode(Id);
+  char MyTag, OtherTag;
+  diff::NodeId LeftId, RightId;
+  diff::NodeId TargetId = Diff.getMapped(Tree, Id);
+  if (IsLeft) {
+MyTag = 'L';
+OtherTag = 'R';
+LeftId = Id;
+RightId = TargetId;
+  } else {
+MyTag = 'R';
+OtherTag = 'L';
+LeftId = TargetId;
+RightId = Id;
+  }
+  unsigned Begin, End;
+  std::tie(Begin, End) = Tree.getSourceRangeOffsets(Node);
+  const SourceManager &SrcMgr = Tree.getASTContext().getSourceManager();
+  auto Code = SrcMgr.getBuffer(SrcMgr.getMainFileID())->getBuffer();
+  for (; Offset < Begin; ++Offset)
+printHtml(OS, Code[Offset]);
+  OS << "";
+
+  for (diff::NodeId Child : Node.Children)
+Offset = printHtmlForNode(OS, Diff, Tree, IsLeft, Child, Offset);
+
+  for (; Offset < End; ++Offset)
+printHtml(OS, Code[Offset]);
+  if (Id == Tree.getRootId()) {
+End = Code.size();
+for (; Offset < End; ++Offset)
+  printHtml(OS, Code[Offset]);
+  }
+  OS << "";
+  return Offset;
+}
+
 static void printJsonString(raw_ostream &OS, const StringRef Str) {
   for (char C : Str) {
 switch (C) {
@@ -269,6 +428,19 @@
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
 
+  if (HtmlDiff) {
+llvm::outs() << HtmlDiffHeader << "";
+llvm::outs() << "";
+printHtmlForNode(llvm::outs(), Diff, SrcTree, true, SrcTree.getRootId(), 0);
+llvm::outs() << "";
+llvm::outs() << "";
+printHtmlForNode(llvm::outs(), Diff, DstTree, false, DstTree.getRo

[PATCH] D36176: [clang-diff] Fix some errors and inconsistencies

2017-08-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 109536.
johannes edited the summary of this revision.
johannes added a comment.

update commit message


https://reviews.llvm.org/D36176

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  lib/Tooling/ASTDiff/ASTDiff.cpp

Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -27,6 +27,7 @@
 namespace clang {
 namespace diff {
 
+namespace {
 /// Maps nodes of the left tree to ones on the right, and vice versa.
 class Mapping {
 public:
@@ -76,6 +77,7 @@
 private:
   std::unique_ptr[]> SrcToDst, DstToSrc;
 };
+} // end anonymous namespace
 
 class ASTDiff::Impl {
 public:
@@ -110,10 +112,6 @@
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
-  // Adds all corresponding subtrees of the two nodes to the mapping.
-  // The two nodes must be identical.
-  void addIsomorphicSubTrees(Mapping &M, NodeId Id1, NodeId Id2) const;
-
   // Uses an optimal albeit slow algorithm to compute a mapping between two
   // subtrees, but only if both have fewer nodes than MaxSize.
   void addOptimalMapping(Mapping &M, NodeId Id1, NodeId Id2) const;
@@ -254,7 +252,10 @@
 Parent = PreviousParent;
 --Depth;
 Node &N = Tree.getMutableNode(MyId);
-N.RightMostDescendant = Id;
+N.RightMostDescendant = Id - 1;
+assert(N.RightMostDescendant >= 0 &&
+   N.RightMostDescendant < Tree.getSize() &&
+   "Rightmost descendant must be a valid tree node.");
 if (N.isLeaf())
   Tree.Leaves.push_back(MyId);
 N.Height = 1;
@@ -358,9 +359,7 @@
 }
 
 bool SyntaxTree::Impl::isInSubtree(NodeId Id, NodeId SubtreeRoot) const {
-  NodeId Lower = SubtreeRoot;
-  NodeId Upper = getNode(SubtreeRoot).RightMostDescendant;
-  return Id >= Lower && Id <= Upper;
+  return Id >= SubtreeRoot && Id <= getNode(SubtreeRoot).RightMostDescendant;
 }
 
 std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const {
@@ -625,12 +624,11 @@
   }
 
 private:
-  /// Simple cost model for edit actions.
+  /// We use a simple cost model for edit actions, which seems good enough.
+  /// Simple cost model for edit actions. This seems to make the matching
+  /// algorithm perform reasonably well.
   /// The values range between 0 and 1, or infinity if this edit action should
   /// always be avoided.
-
-  /// These costs could be modified to better model the estimated cost of /
-  /// inserting / deleting the current node.
   static constexpr double DeletionCost = 1;
   static constexpr double InsertionCost = 1;
 
@@ -687,6 +685,7 @@
 };
 } // end anonymous namespace
 
+namespace {
 // Priority queue for nodes, sorted descendingly by their height.
 class PriorityList {
   const SyntaxTree::Impl &Tree;
@@ -723,6 +722,7 @@
   push(Child);
   }
 };
+} // end anonymous namespace
 
 bool ASTDiff::Impl::identical(NodeId Id1, NodeId Id2) const {
   const Node &N1 = T1.getNode(Id1);
@@ -759,16 +759,6 @@
T2.getNode(Id2).ASTNode);
 }
 
-void ASTDiff::Impl::addIsomorphicSubTrees(Mapping &M, NodeId Id1,
-  NodeId Id2) const {
-  assert(identical(Id1, Id2) && "Can only be called on identical subtrees.");
-  M.link(Id1, Id2);
-  const Node &N1 = T1.getNode(Id1);
-  const Node &N2 = T2.getNode(Id2);
-  for (size_t Id = 0, E = N1.Children.size(); Id < E; ++Id)
-addIsomorphicSubTrees(M, N1.Children[Id], N2.Children[Id]);
-}
-
 void ASTDiff::Impl::addOptimalMapping(Mapping &M, NodeId Id1,
   NodeId Id2) const {
   if (std::max(T1.getNumberOfDescendants(Id1),
@@ -805,7 +795,7 @@
 if (M.hasDst(Id2))
   continue;
 double Similarity = getSimilarity(M, Id1, Id2);
-if (Similarity > HighestSimilarity) {
+if (Similarity >= Options.MinSimilarity && Similarity > HighestSimilarity) {
   HighestSimilarity = Similarity;
   Candidate = Id2;
 }
@@ -816,7 +806,8 @@
 void ASTDiff::Impl::matchBottomUp(Mapping &M) const {
   std::vector Postorder = getSubtreePostorder(T1, T1.getRootId());
   for (NodeId Id1 : Postorder) {
-if (Id1 == T1.getRootId()) {
+if (Id1 == T1.getRootId() && !M.hasSrc(T1.getRootId()) &&
+!M.hasDst(T2.getRootId())) {
   if (isMatchingPossible(T1.getRootId(), T2.getRootId())) {
 M.link(T1.getRootId(), T2.getRootId());
 addOptimalMapping(M, T1.getRootId(), T2.getRootId());
@@ -831,11 +822,10 @@
 if (Matched || !MatchedChildren)
   continue;
 NodeId Id2 = findCandidate(M, Id1);
-if (Id2.isInvalid() || !canBeAddedToMapping(M, Id1, Id2) ||
-getSimilarity(M, Id1, Id2) < Options.MinSimilarity)
-  continue;
-M.link(Id1, Id2);
-addOptimalMapping(M, Id1, Id2);
+if (Id2.isValid() && canBeAddedToMapping(M, Id1, Id2)) {
+  M.link(Id1, Id2);
+  addOptim

[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36178



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


[PATCH] D36238: Use "foo-12345.o" instead of "foo.o-12345" as temporary file name.

2017-08-03 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added a comment.

Seems reasonable to me as well..


https://reviews.llvm.org/D36238



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 109542.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.
Herald added subscribers: aheejin, dschuff, jfb.

Revised by Tony's and John's comments.


https://reviews.llvm.org/D28691

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/SyncScope.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Frontend/InitPreprocessor.cpp
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/Preprocessor/init.c
  test/Preprocessor/predefined-macros.c
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,161 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+
+// Basic parsing/Sema tests for __opencl_atomic_*
+
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+
+struct S { char c[3]; };
+
+char i8;
+short i16;
+int i32;
+int8 i64;
+
+atomic_int gn;
+
+void f(atomic_int *i, const atomic_int *ci,
+   atomic_intptr_t *p, atomic_float *d,
+   int *I, const int *CI,
+   intptr_t *P, float *D, struct S *s1, struct S *s2,
+   global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
+   constant atomic_int *i_c) {
+  __opencl_atomic_init(I, 5); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __opencl_atomic_load(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+  __opencl_atomic_store(0,0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
+  __opencl_atomic_store((int *)0, 0, 0, 0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_store(i, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+  __opencl_atomic_store(i_g, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(i_l, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(i_p, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(i_c, 0, memory_order_relaxed, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+
+  int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
+
+  __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic int

r309937 - [clang-format] Fix parsing of <>-style proto options

2017-08-03 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Aug  3 06:43:45 2017
New Revision: 309937

URL: http://llvm.org/viewvc/llvm-project?rev=309937&view=rev
Log:
[clang-format] Fix parsing of <>-style proto options

Summary:
This patch fixes the parsing of proto option fields like `option op = <...>`.
Previously the parser did not enter the right code path inside the angle braces,
causing the contents to be split into several unwrapped lines inside.

I'll just go ahead and commit this since it's a straightforward bugfix.

Reviewers: djasper, klimek

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=309937&r1=309936&r2=309937&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Aug  3 06:43:45 2017
@@ -1450,6 +1450,15 @@ bool UnwrappedLineParser::parseBracedLis
   nextToken();
   parseBracedList();
   break;
+case tok::less:
+  if (Style.Language == FormatStyle::LK_Proto) {
+nextToken();
+parseBracedList(/*ContinueOnSemicolons=*/false,
+/*ClosingBraceKind=*/tok::greater);
+  } else {
+nextToken();
+  }
+  break;
 case tok::semi:
   // JavaScript (or more precisely TypeScript) can have semicolons in 
braced
   // lists (in so-called TypeMemberLists). Thus, the semicolon cannot be

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=309937&r1=309936&r2=309937&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Thu Aug  3 06:43:45 2017
@@ -356,6 +356,11 @@ TEST_F(FormatTestProto, FormatsOptions)
"  }\n"
"  field_g: OK\n"
">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+   "  data1 \n"
+   "  data2 {key2: value2}\n"
+   ">;");
 }
 
 TEST_F(FormatTestProto, FormatsService) {


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


[PATCH] D36217: [clang-format] Fix parsing of <>-style proto options

2017-08-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309937: [clang-format] Fix parsing of <>-style proto options 
(authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D36217

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestProto.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1450,6 +1450,15 @@
   nextToken();
   parseBracedList();
   break;
+case tok::less:
+  if (Style.Language == FormatStyle::LK_Proto) {
+nextToken();
+parseBracedList(/*ContinueOnSemicolons=*/false,
+/*ClosingBraceKind=*/tok::greater);
+  } else {
+nextToken();
+  }
+  break;
 case tok::semi:
   // JavaScript (or more precisely TypeScript) can have semicolons in 
braced
   // lists (in so-called TypeMemberLists). Thus, the semicolon cannot be
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -356,6 +356,11 @@
"  }\n"
"  field_g: OK\n"
">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+   "  data1 \n"
+   "  data2 {key2: value2}\n"
+   ">;");
 }
 
 TEST_F(FormatTestProto, FormatsService) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1450,6 +1450,15 @@
   nextToken();
   parseBracedList();
   break;
+case tok::less:
+  if (Style.Language == FormatStyle::LK_Proto) {
+nextToken();
+parseBracedList(/*ContinueOnSemicolons=*/false,
+/*ClosingBraceKind=*/tok::greater);
+  } else {
+nextToken();
+  }
+  break;
 case tok::semi:
   // JavaScript (or more precisely TypeScript) can have semicolons in braced
   // lists (in so-called TypeMemberLists). Thus, the semicolon cannot be
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -356,6 +356,11 @@
"  }\n"
"  field_g: OK\n"
">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+   "  data1 \n"
+   "  data2 {key2: value2}\n"
+   ">;");
 }
 
 TEST_F(FormatTestProto, FormatsService) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via Phabricator via cfe-commits
sdardis updated this revision to Diff 109545.
sdardis marked an inline comment as done.
sdardis added a comment.

Address review comment.


https://reviews.llvm.org/D35917

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/mips-uninit-const-in-ro.c

Index: test/CodeGen/mips-uninit-const-in-ro.c
===
--- /dev/null
+++ test/CodeGen/mips-uninit-const-in-ro.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple mips-mti--elf -emit-llvm -mrelocation-model static \
+// RUN:-target-feature +noabicalls -mllvm -mgpopt -mllvm \
+// RUN:-membedded-data=1 -muninit-const-in-rodata -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that -muninit-const-in-rodata places constant uninitialized structures
+// in the .rodata section rather than the commeon section.
+
+// CHECK: @a = global [8 x i32] zeroinitializer, section "rodata", align 4
+const int a[8];
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -950,6 +950,8 @@
 
   Opts.Backchain = Args.hasArg(OPT_mbackchain);
 
+  Opts.UInitCstDataInROData = Args.hasArg(OPT_muninit_const_in_rodata);
+
   Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
   Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1515,6 +1515,14 @@
 CmdArgs.push_back("-membedded-data=0");
   }
   EmbeddedData->claim();
+
+  if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata,
+   options::OPT_mno_uninit_const_in_rodata)) {
+if (A->getOption().matches(options::OPT_muninit_const_in_rodata)) {
+  CmdArgs.push_back("-muninit-const-in-rodata");
+  A->claim();
+}
+  }
 }
 
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6656,6 +6656,20 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM,
ForDefinition_t IsForDefinition) const override {
+
+if (const VarDecl *VD = dyn_cast_or_null(D)) {
+  if (CGM.getCodeGenOpts().UInitCstDataInROData &&
+  VD->getType().isConstQualified() && !VD->hasInit()) {
+llvm::GlobalVariable *GVar = dyn_cast_or_null(GV);
+if (GVar && !GVar->hasSection()) {
+  GVar->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  GVar->setSection("rodata");
+}
+  }
+
+  return;
+}
+
 const FunctionDecl *FD = dyn_cast_or_null(D);
 if (!FD) return;
 llvm::Function *Fn = cast(GV);
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -101,6 +101,8 @@
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled.
 CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is enabled.
+CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data
+   ///< & -muinit-const-in-rodata is set
 CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2057,6 +2057,14 @@
 def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
   HelpText<"Do not place constants in the .rodata section instead of the "
".sdata if they meet the -G  threshold (MIPS)">;
+def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">,
+  Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place "
+  "uninitialized constants in the read-only data section instead of"
+  " the common section (MIPS)">;
+def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">,
+  Group, HelpText<"Do not place uninitialized constants in the "
+   "read-only data section instead of the common"
+   " section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : 

[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1523
+  CmdArgs.push_back("-muninit-const-in-rodata");
+  A->claim();
+}

atanasyan wrote:
> What's happened if the `-muninit-const-in-rodata` is used without 
> `-membedded-data`? Will the compiler shows a warning about unused command 
> line option?
Yes, it warns that it's unused.


https://reviews.llvm.org/D35917



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


[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D35917



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


[PATCH] D33672: [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checker

2017-08-03 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 109546.
gamesh411 added a comment.

Applied most of the suggested changes, thanks for all the insights!


https://reviews.llvm.org/D33672

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
  test/Analysis/enum-cast-out-of-range.cpp

Index: test/Analysis/enum-cast-out-of-range.cpp
===
--- /dev/null
+++ test/Analysis/enum-cast-out-of-range.cpp
@@ -0,0 +1,181 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=alpha.cplusplus.EnumCastOutOfRange -verify %s
+
+enum unscoped_unspecified_t {
+  unscoped_unspecified_0 = -4,
+  unscoped_unspecified_1,
+  unscoped_unspecified_2 = 1,
+  unscoped_unspecified_3,
+  unscoped_unspecified_4 = 4
+};
+
+enum unscoped_specified_t : int {
+  unscoped_specified_0 = -4,
+  unscoped_specified_1,
+  unscoped_specified_2 = 1,
+  unscoped_specified_3,
+  unscoped_specified_4 = 4
+};
+
+enum class scoped_unspecified_t {
+  scoped_unspecified_0 = -4,
+  scoped_unspecified_1,
+  scoped_unspecified_2 = 1,
+  scoped_unspecified_3,
+  scoped_unspecified_4 = 4
+};
+
+enum class scoped_specified_t : int {
+  scoped_specified_0 = -4,
+  scoped_specified_1,
+  scoped_specified_2 = 1,
+  scoped_specified_3,
+  scoped_specified_4 = 4
+};
+
+void unscopedUnspecified() {
+  unscoped_unspecified_t InvalidBeforeRangeBegin = static_cast(-5); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_unspecified_t ValidNegativeValue1 = static_cast(-4); // OK.
+  unscoped_unspecified_t ValidNegativeValue2 = static_cast(-3); // OK.
+  unscoped_unspecified_t InvalidInsideRange1 = static_cast(-2); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_unspecified_t InvalidInsideRange2 = static_cast(-1); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_unspecified_t InvalidInsideRange3 = static_cast(0); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_unspecified_t ValidPositiveValue1 = static_cast(1); // OK.
+  unscoped_unspecified_t ValidPositiveValue2 = static_cast(2); // OK.
+  unscoped_unspecified_t InvalidInsideRange4 = static_cast(3); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_unspecified_t ValidPositiveValue3 = static_cast(4); // OK.
+  unscoped_unspecified_t InvalidAfterRangeEnd = static_cast(5); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+}
+
+void unscopedSpecified() {
+  unscoped_specified_t InvalidBeforeRangeBegin = static_cast(-5); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_specified_t ValidNegativeValue1 = static_cast(-4); // OK.
+  unscoped_specified_t ValidNegativeValue2 = static_cast(-3); // OK.
+  unscoped_specified_t InvalidInsideRange1 = static_cast(-2); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_specified_t InvalidInsideRange2 = static_cast(-1); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_specified_t InvalidInsideRange3 = static_cast(0); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_specified_t ValidPositiveValue1 = static_cast(1); // OK.
+  unscoped_specified_t ValidPositiveValue2 = static_cast(2); // OK.
+  unscoped_specified_t InvalidInsideRange4 = static_cast(3); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  unscoped_specified_t ValidPositiveValue3 = static_cast(4); // OK.
+  unscoped_specified_t InvalidAfterRangeEnd = static_cast(5); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+}
+
+void scopedUnspecified() {
+  scoped_unspecified_t InvalidBeforeRangeBegin = static_cast(-5); // expected-warning{{the value provided to the cast expression is not in the valid range of values for the enum}}
+  scoped_unspecified_t ValidNegativeValue1 = static_cast(-4); // OK.
+  scoped_unspecified_t ValidNegativeValue2 = static_cast(-3); // OK.
+  scoped_unspecified_t InvalidInsideRange1 = static_cast(-2); // expected-warning {{the value provided to the cast expression is not in the valid range of values for the enum}}
+  scoped_unspecified_t InvalidInsideRange2 = static_cast(-1); // expected-warning {{the value provided to the cast expression is not in the valid ran

r309940 - [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Thu Aug  3 07:01:17 2017
New Revision: 309940

URL: http://llvm.org/viewvc/llvm-project?rev=309940&view=rev
Log:
[mips] Implement -muninit-const-in-rodata

This option when combined with -mgpopt and -membedded-data places all
uninitialized constant variables in the read-only section.

Reviewers: atanasyan, nitesh.jain

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

Added:
cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=309940&r1=309939&r2=309940&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug  3 07:01:17 2017
@@ -2057,6 +2057,14 @@ def membedded_data : Flag<["-"], "membed
 def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
   HelpText<"Do not place constants in the .rodata section instead of the "
".sdata if they meet the -G  threshold (MIPS)">;
+def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">,
+  Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place "
+  "uninitialized constants in the read-only data section instead of"
+  " the common section (MIPS)">;
+def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">,
+  Group, HelpText<"Do not place uninitialized constants in the "
+   "read-only data section instead of the common"
+   " section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=309940&r1=309939&r2=309940&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Aug  3 07:01:17 2017
@@ -101,6 +101,8 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
+CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data
+   ///< & -muinit-const-in-rodata is set
 CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=309940&r1=309939&r2=309940&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Aug  3 07:01:17 2017
@@ -6656,6 +6656,20 @@ public:
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM,
ForDefinition_t IsForDefinition) const override {
+
+if (const VarDecl *VD = dyn_cast_or_null(D)) {
+  if (CGM.getCodeGenOpts().UInitCstDataInROData &&
+  VD->getType().isConstQualified() && !VD->hasInit()) {
+llvm::GlobalVariable *GVar = 
dyn_cast_or_null(GV);
+if (GVar && !GVar->hasSection()) {
+  GVar->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  GVar->setSection("rodata");
+}
+  }
+
+  return;
+}
+
 const FunctionDecl *FD = dyn_cast_or_null(D);
 if (!FD) return;
 llvm::Function *Fn = cast(GV);

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=309940&r1=309939&r2=309940&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Aug  3 07:01:17 2017
@@ -1515,6 +1515,14 @@ void Clang::AddMIPSTargetArgs(const ArgL
 CmdArgs.push_back("-membedded-data=0");
   }
   EmbeddedData->claim();
+
+  if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata,
+   options::OPT_mno_uninit_const_in_rodata)) {
+if (A->getOption().matc

[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309940: [mips] Implement -muninit-const-in-rodata (authored 
by sdardis).

Repository:
  rL LLVM

https://reviews.llvm.org/D35917

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1515,6 +1515,14 @@
 CmdArgs.push_back("-membedded-data=0");
   }
   EmbeddedData->claim();
+
+  if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata,
+   options::OPT_mno_uninit_const_in_rodata)) {
+if (A->getOption().matches(options::OPT_muninit_const_in_rodata)) {
+  CmdArgs.push_back("-muninit-const-in-rodata");
+  A->claim();
+}
+  }
 }
 
   } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt)
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -950,6 +950,8 @@
 
   Opts.Backchain = Args.hasArg(OPT_mbackchain);
 
+  Opts.UInitCstDataInROData = Args.hasArg(OPT_muninit_const_in_rodata);
+
   Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
   Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
 
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6656,6 +6656,20 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM,
ForDefinition_t IsForDefinition) const override {
+
+if (const VarDecl *VD = dyn_cast_or_null(D)) {
+  if (CGM.getCodeGenOpts().UInitCstDataInROData &&
+  VD->getType().isConstQualified() && !VD->hasInit()) {
+llvm::GlobalVariable *GVar = dyn_cast_or_null(GV);
+if (GVar && !GVar->hasSection()) {
+  GVar->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  GVar->setSection("rodata");
+}
+  }
+
+  return;
+}
+
 const FunctionDecl *FD = dyn_cast_or_null(D);
 if (!FD) return;
 llvm::Function *Fn = cast(GV);
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2057,6 +2057,14 @@
 def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group,
   HelpText<"Do not place constants in the .rodata section instead of the "
".sdata if they meet the -G  threshold (MIPS)">;
+def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">,
+  Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place "
+  "uninitialized constants in the read-only data section instead of"
+  " the common section (MIPS)">;
+def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">,
+  Group, HelpText<"Do not place uninitialized constants in the "
+   "read-only data section instead of the common"
+   " section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -101,6 +101,8 @@
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled.
 CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is enabled.
+CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data
+   ///< & -muinit-const-in-rodata is set
 CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
Index: cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c
===
--- cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c
+++ cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple mips-mti--elf -emit-llvm -mrelocatio

[PATCH] D35917: [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Thanks for the reviews of all of these options.


Repository:
  rL LLVM

https://reviews.llvm.org/D35917



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


[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:2206
+return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl &&
+!(Left.MatchingParen && Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->isOneOf(tok::kw_typeof,

Please use `FormatToken::getPreviousNonComment` here and add a test like 
`typedef typeof/*comment*/(int(int, int))* MyFuncPtr;`


https://reviews.llvm.org/D35847



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


[PATCH] D33672: [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checker

2017-08-03 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 marked 9 inline comments as done.
gamesh411 added a comment.

As for the the loss of precision problem, in the special case of char the size 
of char is known. However does the analysis have the necessary information in 
this stage to know the size of an int for example? I found bit-width specifying 
information in the llvm::Type class which is used in the code generation phase. 
It could be done by checking on a per type basis, but then again, it could 
possibly lead to false positives. Correct me if I am wrong.




Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:88-89
+  new BuiltinBug(this, "Enum cast out of range",
+ "The value provided to the cast expression is not in "
+ "the valid range of values for the enum."));
+C.emitReport(llvm::make_unique(

NoQ wrote:
> I believe that we'd need to explain the range we're seeing for the value in 
> this case. Probably by asking the constraint manager to dump the range of 
> possible values through some new API call (in case of 
> `RangeConstraintManager` it should be straightforward).
> 
> Because otherwise it may be unobvious from the path what values are possible, 
> when the `SVal` is a symbol.
> 
> Or, even better, we could highlight, with the help of a bug reporter visitor, 
> the places where constraints were added to the symbol (then, again, it'd be 
> better with ranges).
> 
> Ideally:
> ```
> enum { Zero=0, One, Two, Three, Four } y;
> 
> void foo(int x) {
>   if (x > 3) {
> // core note: Assuming 'x' is greater than 3
> // checker note: The assigned value is assumed to be within range [4, 
> 2147483647]
> ...
>   }
>   z = x;
>   // intermix of 'x' and 'z' is intentional:
>   // checker notes should track symbol, not variable,
>   // which is what makes them great.
>   if (z < 7) {
> // core note: Assuming 'z' is less than 7
> // checker note: The assigned value is assumed to be within range [4, 6]
> if (x > 4) {
>   // core note: Assuming 'x' is greater than 4
>   // checker note: The assigned value is assumed to be within range [5, 6]
>   y = z; // warning: The value provided to the cast expression is in 
> range [5, 6], which is not in the valid range of values for the enum
> }
>   }
> }
> ```
> (with a special case when the range consists of one element)
As far as I know the current reporting system, and the ConstraintManager API 
does not allow for this degree of finesse when it comes to diagnostics. It is 
however a good idea worth pursuing as part of the enhancement of the 
aforementioned subsystems.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:119-122
+  // Check if any of the enum values possibly match.
+  bool PossibleValueMatch =
+  std::any_of(DeclValues.begin(), DeclValues.end(),
+  ConstraintBasedEQEvaluator(C, *ValueToCastOptional));

NoQ wrote:
> I suspect that enum values often cover a whole segment, and in this case a 
> pair of assumes for the sides of the segment (or, even better, a single 
> `assumeInclusiveRange`) would be much faster.
I have cosidered assumeInclusiveRange, however there can be enums with holes in 
represented values (for example the the enums in the first part of the test 
cases). In such case it would not be practical to call assumeInclusiveRange for 
all subranges.


https://reviews.llvm.org/D33672



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


Re: r309940 - [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Joerg Sonnenberger via cfe-commits
On Thu, Aug 03, 2017 at 02:01:17PM -, Simon Dardis via cfe-commits wrote:
> Author: sdardis
> Date: Thu Aug  3 07:01:17 2017
> New Revision: 309940
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=309940&view=rev
> Log:
> [mips] Implement -muninit-const-in-rodata
> 
> This option when combined with -mgpopt and -membedded-data places all
> uninitialized constant variables in the read-only section.

I don't get it. Why is this preferable to just forbidding the use of
common variables in first placce?

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


[PATCH] D27207: Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

2017-08-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h:2749
+/// \endcode
+/// The matcher type(hasUniqualifeidDesugaredType(recordType())) matches
+/// both B and A.

Typo: hasUniqualifeidDesugaredType (actually, two typos).


Repository:
  rL LLVM

https://reviews.llvm.org/D27207



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


[PATCH] D36143: [clang-format] Fix indent of 'key <...>' and 'key {...}' in text protos

2017-08-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 109551.
krasimir added a comment.

- Rebase with master


https://reviews.llvm.org/D36143

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -245,6 +245,50 @@
">\n"
"field: OK,\n"
"field_c >>");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "tail_id: 2");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "data {key: value}");
+
+  verifyFormat("app {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app: {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data {product {1}}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data >");
+
+  verifyFormat("app <\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  headheadheadheadheadhead_id: 1\n"
+   "  product_data \n"
+   ">");
 }
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -361,6 +361,19 @@
"  data1 \n"
"  data2 {key2: value2}\n"
">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   ">;");
+
+  verifyFormat("option (MyProto.options) = {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  headheadheadheadheadhead_id: 1\n"
+   "  product_data {product {1}}\n"
+   "};");
 }
 
 TEST_F(FormatTestProto, FormatsService) {
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -731,7 +731,10 @@
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (Current.is(tok::identifier) && Current.Next &&
-  Current.Next->is(TT_DictLiteral))
+  (Current.Next->is(TT_DictLiteral) ||
+   ((Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) &&
+Current.Next->isOneOf(TT_TemplateOpener, tok::l_brace
 return State.Stack.back().Indent;
   if (NextNonComment->is(TT_ObjCStringLiteral) &&
   State.StartOfStringLiteral != 0)


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -245,6 +245,50 @@
">\n"
"field: OK,\n"
"field_c >>");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "tail_id: 2");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "data {key: value}");
+
+  verifyFormat("app {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app: {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data {product {1}}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadh

[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D34512#829712, @rsmith wrote:

> Organizationally, this seems fine. Carry on :)


Great news! Thank you!


https://reviews.llvm.org/D34512



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 109552.
xazax.hun marked 3 inline comments as done.
xazax.hun added a comment.

- Addressed review comments.


https://reviews.llvm.org/D34512

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticCrossTUKinds.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/CrossTU/CrossTUDiagnostic.h
  include/clang/CrossTU/CrossTranslationUnit.h
  lib/AST/ASTImporter.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/CrossTU/CMakeLists.txt
  lib/CrossTU/CrossTranslationUnit.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/diagtool/DiagnosticNames.cpp
  unittests/CrossTU/CMakeLists.txt
  unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- /dev/null
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -0,0 +1,98 @@
+//===- unittest/Tooling/CrossTranslationUnitTest.cpp - Tooling unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace cross_tu {
+
+namespace {
+StringRef IndexFileName = "index.txt";
+StringRef ASTFileName = "f.ast";
+StringRef DefinitionFileName = "input.cc";
+
+class CTUASTConsumer : public clang::ASTConsumer {
+public:
+  explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success)
+  : CTU(CI), Success(Success) {}
+
+  void HandleTranslationUnit(ASTContext &Ctx) {
+const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
+const FunctionDecl *FD = nullptr;
+for (const Decl *D : TU->decls()) {
+  FD = dyn_cast(D);
+  if (FD && FD->getName() == "f")
+break;
+}
+assert(FD);
+bool OrigFDHasBody = FD->hasBody();
+
+// Prepare the index file and the AST file.
+std::error_code EC;
+llvm::raw_fd_ostream OS(IndexFileName, EC, llvm::sys::fs::F_Text);
+OS << "c:@F@f#I# " << ASTFileName << "\n";
+OS.flush();
+StringRef SourceText = "int f(int) { return 0; }\n";
+// This file must exist since the saved ASTFile will reference it.
+llvm::raw_fd_ostream OS2(DefinitionFileName, EC, llvm::sys::fs::F_Text);
+OS2 << SourceText;
+OS2.flush();
+std::unique_ptr ASTWithDefinition =
+tooling::buildASTFromCode(SourceText);
+ASTWithDefinition->Save(ASTFileName);
+
+// Load the definition from the AST file.
+const FunctionDecl *NewFD =
+CTU.getCrossTUDefinition(FD, ".", IndexFileName);
+
+*Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+  }
+
+private:
+  CrossTranslationUnit CTU;
+  bool *Success;
+};
+
+class CTUAction : public clang::ASTFrontendAction {
+public:
+  CTUAction(bool *Success) : Success(Success) {}
+
+protected:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
+return llvm::make_unique(CI, Success);
+  }
+
+private:
+  bool *Success;
+};
+
+} // end namespace
+
+TEST(CrossTranslationUnit, CanLoadFunctionDefinition) {
+  bool Success = false;
+  EXPECT_TRUE(tooling::runToolOnCode(new CTUAction(&Success), "int f(int);"));
+  EXPECT_TRUE(Success);
+  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(IndexFileName));
+  EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(ASTFileName));
+  EXPECT_TRUE(llvm::sys::fs::exists(DefinitionFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(DefinitionFileName));
+}
+
+} // end namespace cross_tu
+} // end namespace clang
Index: unittests/CrossTU/CMakeLists.txt
===
--- /dev/null
+++ unittests/CrossTU/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Support
+  )
+
+add_clang_unittest(CrossTUTests
+  CrossTranslationUnitTest.cpp
+  )
+
+target_link_libraries(CrossTUTests
+  clangAST
+  clangBasic
+  clangCrossTU
+  clangFrontend
+  clangTooling
+  )
Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -32,6 +32,7 @@
  SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY)\
   { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
 #include "clang

[PATCH] D36143: [clang-format] Fix indent of 'key <...>' and 'key {...}' in text protos

2017-08-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309941: [clang-format] Fix indent of 'key <...>' and 'key 
{...}' in text protos (authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D36143

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/unittests/Format/FormatTestProto.cpp
  cfe/trunk/unittests/Format/FormatTestTextProto.cpp


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -731,7 +731,10 @@
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (Current.is(tok::identifier) && Current.Next &&
-  Current.Next->is(TT_DictLiteral))
+  (Current.Next->is(TT_DictLiteral) ||
+   ((Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) &&
+Current.Next->isOneOf(TT_TemplateOpener, tok::l_brace
 return State.Stack.back().Indent;
   if (NextNonComment->is(TT_ObjCStringLiteral) &&
   State.StartOfStringLiteral != 0)
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -361,6 +361,19 @@
"  data1 \n"
"  data2 {key2: value2}\n"
">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   ">;");
+
+  verifyFormat("option (MyProto.options) = {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  headheadheadheadheadhead_id: 1\n"
+   "  product_data {product {1}}\n"
+   "};");
 }
 
 TEST_F(FormatTestProto, FormatsService) {
Index: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp
@@ -245,6 +245,50 @@
">\n"
"field: OK,\n"
"field_c >>");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "tail_id: 2");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "data {key: value}");
+
+  verifyFormat("app {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app: {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data {product {1}}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data >");
+
+  verifyFormat("app <\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  headheadheadheadheadhead_id: 1\n"
+   "  product_data \n"
+   ">");
 }
 } // end namespace tooling
 } // end namespace clang


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -731,7 +731,10 @@
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (Current.is(tok::identifier) && Current.Next &&
-  Current.Next->is(TT_DictLiteral))
+  (Current.Next->is(TT_DictLiteral) ||
+   ((Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) &&
+Current.Next->isOneOf(TT_TemplateOpener, tok::l_brace
 return State.Stack.back().Indent;
   if (NextNonComment->is(TT_ObjCStringLiteral) &&
   State.StartOfStringLiteral != 0)
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -361,6 +361,19 @@

r309941 - [clang-format] Fix indent of 'key <...>' and 'key {...}' in text protos

2017-08-03 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Aug  3 07:17:29 2017
New Revision: 309941

URL: http://llvm.org/viewvc/llvm-project?rev=309941&view=rev
Log:
[clang-format] Fix indent of 'key <...>' and 'key {...}' in text protos

Summary:
This patch fixes the indentation of the code pattern `key <...>`and `key {...}` 
in text protos.
Previously, such line would be alinged depending on the column of the previous
colon, which usually indents too much.

I'm gonna go ahead and commit this since it's a straightforward bugfix.

Reviewers: djasper, klimek

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=309941&r1=309940&r2=309941&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Aug  3 07:17:29 2017
@@ -731,7 +731,10 @@ unsigned ContinuationIndenter::getNewLin
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (Current.is(tok::identifier) && Current.Next &&
-  Current.Next->is(TT_DictLiteral))
+  (Current.Next->is(TT_DictLiteral) ||
+   ((Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) &&
+Current.Next->isOneOf(TT_TemplateOpener, tok::l_brace
 return State.Stack.back().Indent;
   if (NextNonComment->is(TT_ObjCStringLiteral) &&
   State.StartOfStringLiteral != 0)

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=309941&r1=309940&r2=309941&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Thu Aug  3 07:17:29 2017
@@ -361,6 +361,19 @@ TEST_F(FormatTestProto, FormatsOptions)
"  data1 \n"
"  data2 {key2: value2}\n"
">;");
+
+  verifyFormat("option (MyProto.options) = <\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   ">;");
+
+  verifyFormat("option (MyProto.options) = {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  headheadheadheadheadhead_id: 1\n"
+   "  product_data {product {1}}\n"
+   "};");
 }
 
 TEST_F(FormatTestProto, FormatsService) {

Modified: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTextProto.cpp?rev=309941&r1=309940&r2=309941&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp Thu Aug  3 07:17:29 2017
@@ -245,6 +245,50 @@ TEST_F(FormatTestTextProto, SupportsAngl
">\n"
"field: OK,\n"
"field_c >>");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "tail_id: 2");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "head_id: 1\n"
+   "data \n"
+   "data {key: value}");
+
+  verifyFormat("app {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app: {\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  head_id: 1\n"
+   "  data \n"
+   "}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data {product {1}}");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data ");
+
+  verifyFormat("app_id: 'com.javax.swing.salsa.latino'\n"
+   "headheadheadheadheadhead_id: 1\n"
+   "product_data >");
+
+  verifyFormat("app <\n"
+   "  app_id: 'com.javax.swing.salsa.latino'\n"
+   "  headheadheadheadheadhead_id: 1\n"
+   "  product_data \n"
+   ">");
 }
 } // end namespace tooling
 } // end namespace clang


___

[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: include/clang/CrossTU/CrossTUDiagnostic.h:16
+namespace clang {
+  namespace diag {
+enum {

LLVM Style uses no indent for namespaces. Reformat with `clang-format`.



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:70
+  llvm::StringMap> FileASTUnitMap;
+  llvm::StringMap FunctionAstUnitMap;
+  llvm::StringMap FunctionFileMap;

Maybe rename to `FunctionASTUnitMap` for consistency with the previous line?


https://reviews.llvm.org/D34512



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 109556.
yaxunl added a comment.

Add assert to make sure pre-defined macros __OPENCL_MEMORY_SCOP_* to be 
consistent with SyncScope enum.


https://reviews.llvm.org/D28691

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/SyncScope.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Frontend/InitPreprocessor.cpp
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/Preprocessor/init.c
  test/Preprocessor/predefined-macros.c
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,161 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+
+// Basic parsing/Sema tests for __opencl_atomic_*
+
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+
+struct S { char c[3]; };
+
+char i8;
+short i16;
+int i32;
+int8 i64;
+
+atomic_int gn;
+
+void f(atomic_int *i, const atomic_int *ci,
+   atomic_intptr_t *p, atomic_float *d,
+   int *I, const int *CI,
+   intptr_t *P, float *D, struct S *s1, struct S *s2,
+   global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
+   constant atomic_int *i_c) {
+  __opencl_atomic_init(I, 5); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __opencl_atomic_load(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+  __opencl_atomic_store(0,0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
+  __opencl_atomic_store((int *)0, 0, 0, 0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_store(i, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+  __opencl_atomic_store(i_g, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(i_l, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(i_p, 0, memory_order_relaxed, memory_scope_work_group);
+  __opencl_atomic_store(i_c, 0, memory_order_relaxed, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+
+  int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
+
+  __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__gene

[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 109559.
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

- Address further review comments.


https://reviews.llvm.org/D34512

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticCrossTUKinds.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/CrossTU/CrossTUDiagnostic.h
  include/clang/CrossTU/CrossTranslationUnit.h
  lib/AST/ASTImporter.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/CrossTU/CMakeLists.txt
  lib/CrossTU/CrossTranslationUnit.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/diagtool/DiagnosticNames.cpp
  unittests/CrossTU/CMakeLists.txt
  unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- /dev/null
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -0,0 +1,98 @@
+//===- unittest/Tooling/CrossTranslationUnitTest.cpp - Tooling unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace cross_tu {
+
+namespace {
+StringRef IndexFileName = "index.txt";
+StringRef ASTFileName = "f.ast";
+StringRef DefinitionFileName = "input.cc";
+
+class CTUASTConsumer : public clang::ASTConsumer {
+public:
+  explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success)
+  : CTU(CI), Success(Success) {}
+
+  void HandleTranslationUnit(ASTContext &Ctx) {
+const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
+const FunctionDecl *FD = nullptr;
+for (const Decl *D : TU->decls()) {
+  FD = dyn_cast(D);
+  if (FD && FD->getName() == "f")
+break;
+}
+assert(FD);
+bool OrigFDHasBody = FD->hasBody();
+
+// Prepare the index file and the AST file.
+std::error_code EC;
+llvm::raw_fd_ostream OS(IndexFileName, EC, llvm::sys::fs::F_Text);
+OS << "c:@F@f#I# " << ASTFileName << "\n";
+OS.flush();
+StringRef SourceText = "int f(int) { return 0; }\n";
+// This file must exist since the saved ASTFile will reference it.
+llvm::raw_fd_ostream OS2(DefinitionFileName, EC, llvm::sys::fs::F_Text);
+OS2 << SourceText;
+OS2.flush();
+std::unique_ptr ASTWithDefinition =
+tooling::buildASTFromCode(SourceText);
+ASTWithDefinition->Save(ASTFileName);
+
+// Load the definition from the AST file.
+const FunctionDecl *NewFD =
+CTU.getCrossTUDefinition(FD, ".", IndexFileName);
+
+*Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+  }
+
+private:
+  CrossTranslationUnit CTU;
+  bool *Success;
+};
+
+class CTUAction : public clang::ASTFrontendAction {
+public:
+  CTUAction(bool *Success) : Success(Success) {}
+
+protected:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
+return llvm::make_unique(CI, Success);
+  }
+
+private:
+  bool *Success;
+};
+
+} // end namespace
+
+TEST(CrossTranslationUnit, CanLoadFunctionDefinition) {
+  bool Success = false;
+  EXPECT_TRUE(tooling::runToolOnCode(new CTUAction(&Success), "int f(int);"));
+  EXPECT_TRUE(Success);
+  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(IndexFileName));
+  EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(ASTFileName));
+  EXPECT_TRUE(llvm::sys::fs::exists(DefinitionFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(DefinitionFileName));
+}
+
+} // end namespace cross_tu
+} // end namespace clang
Index: unittests/CrossTU/CMakeLists.txt
===
--- /dev/null
+++ unittests/CrossTU/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Support
+  )
+
+add_clang_unittest(CrossTUTests
+  CrossTranslationUnitTest.cpp
+  )
+
+target_link_libraries(CrossTUTests
+  clangAST
+  clangBasic
+  clangCrossTU
+  clangFrontend
+  clangTooling
+  )
Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -32,6 +32,7 @@
  SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY)\
   { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
 #include 

r309942 - [mips] Fixup r309940.

2017-08-03 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Thu Aug  3 07:35:06 2017
New Revision: 309942

URL: http://llvm.org/viewvc/llvm-project?rev=309942&view=rev
Log:
[mips] Fixup r309940.

Needed a // REQUIRES: mips-registered-target

Modified:
cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c

Modified: cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c?rev=309942&r1=309941&r2=309942&view=diff
==
--- cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c (original)
+++ cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c Thu Aug  3 07:35:06 2017
@@ -3,6 +3,8 @@
 // RUN:-membedded-data=1 -muninit-const-in-rodata -o - %s | \
 // RUN:   FileCheck %s
 
+// REQUIRES: mips-registered-target
+
 // Test that -muninit-const-in-rodata places constant uninitialized structures
 // in the .rodata section rather than the commeon section.
 


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


[PATCH] D36264: [clang-tidy] Ignore macros in make-unique check.

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

LG with one comment.




Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:114
 
-  if (Construct)
+  if (Construct && !Construct->getLocation().isMacroID())
 checkConstruct(SM, Construct, Type, New);

Seems to be a bit too broad. Maybe just disable the fix in macros? If warnings 
without fixes will be a problem in some codebases, we could then introduce the 
`IgnoreMacros` option as in readability-redundant-declaration, 
modernize-use-using, modernize-use-bool-literals, and 
modernize-use-default-member-init.


https://reviews.llvm.org/D36264



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


[PATCH] D36016: [clang-tidy] Support initializer-list constructor cases in modernize-make-unique.

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

LG with a couple of comments.




Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:253
+//   std::make_smart_ptr({});
+auto NumArgs = NewConstruct->getNumArgs();
+if (NumArgs <= 0) {

s/auto/unsigned/, since the use of `auto` here seems to not be in line with 
http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable.



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:254
+auto NumArgs = NewConstruct->getNumArgs();
+if (NumArgs <= 0) {
+  return;

The `< 0` case doesn't make sense (it will be clear once you change the `auto` 
above to the real type).


https://reviews.llvm.org/D36016



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


[PATCH] D36016: [clang-tidy] Support initializer-list constructor cases in modernize-make-unique.

2017-08-03 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/clang-tidy/modernize-make-unique.cpp:291
+
+  // Initialization with ordinary constructor.
+  std::unique_ptr PG3 = std::unique_ptr(new G{1, 2});

The comment doesn't match the test?


https://reviews.llvm.org/D36016



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


Re: [PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2017-08-03 Thread Nico Weber via cfe-commits
On Thu, Aug 3, 2017 at 4:13 AM, Alex Lorenz via Phabricator via cfe-commits
 wrote:

> arphaman added a comment.
>
> In https://reviews.llvm.org/D27827#829661, @thakis wrote:
>
> > We just noticed that if you call __builtin_available() for the first
> time after activating your app's sandbox, the function will fail:
> >
> > SandboxViolation: crdmg(15489) deny file-read-data
> /System/Library/CoreServices/SystemVersion.plist
> >  Violation:   deny file-read-data /System/Library/CoreServices/S
> ystemVersion.plist
> >  Process: crdmg [15489]
> >  Path:/Volumes/Build/src/./out/release/crdmg
> >
> > Thread 0 (id: 421251):
> >  0   libsystem_kernel.dylib   0x7fffe94a1a86 __open_nocancel
> + 10
> >  1   crdmg0x00010444be98
> parseSystemVersionPList + 360
> >  20xec83485354415541
>
>
> Hmm, never saw this before. Please post your exact configuration -
> clang/compiler-rt versions, OS version, toolchain & SDK. Is it possible to
> get a reproducer?
>

It's in this program, which is pretty stand-alone: https://cs.
chromium.org/chromium/src/chrome/utility/safe_browsing/
mac/crdmg.cc?q=crdmg&sq=package:chromium&l=95 EnableSandbox() is on line
134. clang, compiler-rt are trunk from 2 weeks ago, SDK is 10.12, os
10.12.5. I don't think the particular version numbers matter too much
though. Here's a standalone demo:

thakis-macpro:src thakis$ cat foo.cc
#include 
int main() {
  const char sbox[] = "(version 1) (deny default)";
  char* err;
  ::sandbox_init(sbox, 0, &err);
  if (__builtin_available(macos 10.10, *))
return 32;
  else
return 14;
}
thakis-macpro:src thakis$ third_party/llvm-build/Release+Asserts/bin/clang
-o foo foo.cc -isysroot $(xcrun -show-sdk-path) -mmacosx-version-min=10.9
-w && ./foo
thakis-macpro:src thakis$ echo $?
14
thakis-macpro:src thakis$ sw_vers -productVersion
10.12.5

After running that, look for "sandbox" in console.app to find the "deny
file-read-data".


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


[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2017-08-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like the email reply didn't make it to phab, so here it is again:

It's in this program, which is pretty stand-alone: 
https://cs.chromium.org/chromium/src/chrome/utility/safe_browsing/mac/crdmg.cc?q=crdmg&sq=package:chromium&l=95
 EnableSandbox() is on line 134. clang, compiler-rt are trunk from 2 weeks ago, 
SDK is 10.12, os 10.12.5. I don't think the particular version numbers matter 
too much though. Here's a standalone demo:

thakis-macpro:src thakis$ cat foo.cc
#include 
int main() {

  const char sbox[] = "(version 1) (deny default)";
  char* err;
  ::sandbox_init(sbox, 0, &err);
  if (__builtin_available(macos 10.10, *))
return 32;
  else
return 14;

}
thakis-macpro:src thakis$ third_party/llvm-build/Release+Asserts/bin/clang -o 
foo foo.cc -isysroot $(xcrun -show-sdk-path) -mmacosx-version-min=10.9 -w && 
./foo
thakis-macpro:src thakis$ echo $?
14
thakis-macpro:src thakis$ sw_vers -productVersion
10.12.5

After running that, look for "sandbox" in console.app to find the "deny 
file-read-data".


Repository:
  rL LLVM

https://reviews.llvm.org/D27827



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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-08-03 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik updated this revision to Diff 109564.
szdominik marked 2 inline comments as done.
szdominik added a comment.
Herald added a subscriber: JDevlieghere.

Fixed check-fixes lines in test cases.
Updated matcher definition.


https://reviews.llvm.org/D33722

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/CopyConstructorInitCheck.cpp
  clang-tidy/misc/CopyConstructorInitCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-copy-constructor-init.rst
  test/clang-tidy/misc-copy-constructor-init.cpp

Index: test/clang-tidy/misc-copy-constructor-init.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-copy-constructor-init.cpp
@@ -0,0 +1,95 @@
+// RUN: %check_clang_tidy %s misc-copy-constructor-init %t
+
+class Copyable {
+	public:
+	Copyable() = default;
+	Copyable(const Copyable&) = default;
+};
+class X : public Copyable {
+	X(const X& other) : Copyable(other) {}
+	//Good code: the copy ctor call the ctor of the base class.
+};
+
+class Copyable2 {
+	public:
+	Copyable2() = default;
+	Copyable2(const Copyable2&) = default;
+};
+class X2 : public Copyable2 {
+	X2(const X2& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X2(const X2& other) : Copyable2(other) {};
+};
+
+class X3 : public Copyable, public Copyable2 {
+	X3(const X3& other): Copyable(other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) {};
+};
+
+class X4 : public Copyable {
+	X4(const X4& other): Copyable() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X4(const X4& other): Copyable(other) {};
+};
+
+class Copyable3 : public Copyable {
+	public:
+	Copyable3() = default;
+	Copyable3(const Copyable3&) = default;
+};
+class X5 : public Copyable3 {
+	X5(const X5& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X5(const X5& other) : Copyable3(other) {};
+};
+
+class X6 : public Copyable2, public Copyable3 {
+	X6(const X6& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X6(const X6& other) : Copyable2(other), Copyable3(other) {};
+};
+
+class X7 : public Copyable, public Copyable2 {
+	X7(const X7& other): Copyable() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X7(const X7& other): Copyable2(other), Copyable(other) {};
+};
+
+template 
+class Copyable4 {
+	public:
+	Copyable4() = default;
+	Copyable4(const Copyable4&) = default;
+};
+
+class X8 : public Copyable4 {
+	X8(const X8& other): Copyable4(other) {};
+	//Good code: the copy ctor call the ctor of the base class.
+};
+
+class X9 : public Copyable4 {
+	X9(const X9& other): Copyable4() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X9(const X9& other): Copyable4(other) {};
+};
+
+class X10 : public Copyable4 {
+	X10(const X10& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X10(const X10& other) : Copyable4(other) {};
+};
+
+template 
+class Copyable5 {
+	public:
+	Copyable5() = default;
+	Copyable5(const Copyable5&) = default;
+};
+
+class X11 : public Copyable5 {
+	X11(const X11& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X11(const X11& other) : Copyable5(other) {};
+};
Index: docs/clang-tidy/checks/misc-copy-constructor-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-copy-constructor-init.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - misc-copy-constructor-init
+
+misc-copy-constructor-init
+=
+
+Finds copy constructors where the constructor don't call 
+the constructor of the base class.
+
+.. code-block:: c++
+
+class Copyable {
+public:
+Copyable() = default;
+Copyable(const Copyable&) = default;
+};
+class X2 : public Copyable {
+X

[PATCH] D36051: [clang-tidy] List the checkers with autofix

2017-08-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D36051#825428, @xazax.hun wrote:

> Maybe instead of a separate list, having this information like yes/no column 
> in a table in the original is more user-friendly.


What the better format is would depend on for which purpose do we want to 
expose this information and how it will likely be used. Does anyone have a 
clear idea about this?

Another point is that it would be much better if we come up with a reliable way 
to keep this information up-to-date. I currently see a few ways to find which 
checks are able to issue fix-its:

1. Analyze lit tests: each test contains the name of the check and most of them 
use the check_clang_tidy script and CHECK-FIXES prefix to verify fixes. This 
only works for checks that have lit tests, but the good thing is that we'll 
only list checks that have test for fixes ;)
2. Analyze checks' source code for the presence of FixItHint or utility 
functions that generate it.
3. Require checks to issue a specific call (or be registered with a certain 
flag) to enable fix-its. This way we'll have this information in runtime and 
will be able to expose it in -list-checks.
4. Analyze checks' documentation and require it to contain a certain pattern, 
if the check supports fixes.

But first we need to answer the question on how this information is going to be 
used.


https://reviews.llvm.org/D36051



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-03 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 109566.
Nebiroth marked 7 inline comments as done.
Nebiroth added a comment.

[clangd] LSP extension to switch between source/header file


https://reviews.llvm.org/D36150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h

Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -48,6 +48,8 @@
 JSONOutput &Out) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput &Out) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput &Out) = 0;
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,23 @@
   ProtocolCallbacks &Callbacks;
 };
 
+struct SwitchSourceHeaderHandler : Handler {
+  SwitchSourceHeaderHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks)
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentIdentifier::parse(Params);
+if (!TDPP) {
+  return;
+}
+
+Callbacks.onSwitchSourceHeader(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks &Callbacks;
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
@@ -239,4 +256,7 @@
   llvm::make_unique(Out, Callbacks));
   Dispatcher.registerHandler("textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -182,6 +182,9 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
+  // Helper function to change from one header file to it's corresponding source file and vice versa
+  Path switchSourceHeader(PathRef path);
+
   /// Run formatting for \p Rng inside \p File.
   std::vector formatRange(PathRef File, Range Rng);
   /// Run formatting for the whole \p File.
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -16,13 +16,15 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Path.h"
 #include 
 
 using namespace clang;
 using namespace clang::clangd;
 
 namespace {
 
+
 std::vector formatCode(StringRef Code, StringRef Filename,
  ArrayRef Ranges) {
   // Call clang-format.
@@ -286,3 +288,86 @@
   });
   return make_tagged(std::move(Result), TaggedFS.Tag);
 }
+
+Path ClangdServer::switchSourceHeader(PathRef path) {
+
+  std::string DEFAULT_SOURCE_EXTENSIONS[] = { ".cpp", ".c", ".cc", ".cxx",
+".c++", ".C", ".m", ".mm" };  
+  std::string DEFAULT_HEADER_EXTENSIONS[] = { ".h", ".hh", ".hpp", ".hxx",
+".inc" };  
+
+  const int sourceSize = sizeof(DEFAULT_SOURCE_EXTENSIONS)/sizeof(DEFAULT_SOURCE_EXTENSIONS[0]);
+  const int headerSize = sizeof(DEFAULT_HEADER_EXTENSIONS)/sizeof(DEFAULT_HEADER_EXTENSIONS[0]);
+
+  std::string pathDataRef = std::string(path.data());
+  bool isSourceFile = false, foundExtension = false;
+  SmallString<128> NewPath;
+  int i = 0;
+
+  while (!foundExtension && i < sourceSize)
+  {
+if (llvm::sys::path::extension(pathDataRef) == DEFAULT_SOURCE_EXTENSIONS[i])
+{
+  std::string fileExtension = std::string(DEFAULT_SOURCE_EXTENSIONS[i]);
+  NewPath = pathDataRef;
+  pathDataRef = pathDataRef.substr(0, (pathDataRef.length() - fileExtension.size()));
+  isSourceFile = true;
+  foundExtension = true;
+}
+i++;
+  }
+  i = 0;
+
+  if (!foundExtension)
+  {
+while (!foundExtension && i < headerSize)
+{
+  if (llvm::sys::path::extension(pathDataRef) == DEFAULT_HEADER_EXTENSIONS[i])
+  {
+std::string fileExtension = std::string(DEFAULT_HEADER_EXTENSIONS[i]);
+NewPath = pathDataRef;
+pathDataRef = pathDataRef.substr(0, (pathDataRef.length() - fileExtension.size()));
+isSourceFile = false;
+foundExtension = true;
+  }
+i++;
+}
+  }
+
+  std::string temp = std::string(pathDataRef);
+  SmallString<128> CurrentPath;
+  CurrentPath = temp;
+  bool done = false;
+  std::vector EXTENSIONS_ARRAY;
+  
+  if (!isSourceFile)
+EXTENSIONS_ARRAY.assign(DEFAULT

[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2017-08-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(Our workaround is to call __builtin_available() once before engaging the 
sandbox, which isn't so bad. Just thought I'd let you know about it; this isn't 
a serious bug for us.)


Repository:
  rL LLVM

https://reviews.llvm.org/D27827



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


[PATCH] D35894: [clangd] Code hover for Clangd

2017-08-03 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D35894#830178, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D35894#829190, @malaperle wrote:
>
> > @Nebiroth I think it's OK to put this on hold until we make the "semantic" 
> > hover and figure out how to have both. From our perspective, this is going 
> > beyond parity of what we had before but it's seems like the right thing to 
> > do.
>
>
> BTW, just noticed that VS Code shows the range reported by `findDefinitions` 
> when you hover over a symbol and holding Ctrl.
>  Would calling `findDefinitions` help you to do the same thing? That would 
> allow to get closer to feature parity with CDT without implementing semantic 
> hover in clangd.


That looks very interesting, I had no idea. We'll have to try that. Thanks!


https://reviews.llvm.org/D35894



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


r309948 - Fix some typos in the documentation.

2017-08-03 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Aug  3 08:38:14 2017
New Revision: 309948

URL: http://llvm.org/viewvc/llvm-project?rev=309948&view=rev
Log:
Fix some typos in the documentation.

Patch by: Reka Nikolett Kovacs

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=309948&r1=309947&r2=309948&view=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Thu Aug  3 08:38:14 2017
@@ -49,7 +49,7 @@ when the code is incorrect or dubious.
 (at the minimum) a unique ID, an English translation associated with it, a
 :ref:`SourceLocation ` to "put the caret", and a severity
 (e.g., ``WARNING`` or ``ERROR``).  They can also optionally include a number of
-arguments to the dianostic (which fill in "%0"'s in the string) as well as a
+arguments to the diagnostic (which fill in "%0"'s in the string) as well as a
 number of source ranges that related to the diagnostic.
 
 In this section, we'll be giving examples produced by the Clang command line
@@ -795,7 +795,7 @@ preprocessor and notifies a client of th
 Historically, the parser used to talk to an abstract ``Action`` interface that
 had virtual methods for parse events, for example ``ActOnBinOp()``.  When Clang
 grew C++ support, the parser stopped supporting general ``Action`` clients --
-it now always talks to the :ref:`Sema libray `.  However, the Parser
+it now always talks to the :ref:`Sema library `.  However, the Parser
 still accesses AST objects only through opaque types like ``ExprResult`` and
 ``StmtResult``.  Only :ref:`Sema ` looks at the AST node contents of 
these
 wrappers.
@@ -1324,9 +1324,9 @@ range of iterators over declarations of
 function ``DeclContext::getPrimaryContext`` retrieves the "primary" context for
 a given ``DeclContext`` instance, which is the ``DeclContext`` responsible for
 maintaining the lookup table used for the semantics-centric view.  Given a
-DeclContext, one can obtain the set of declaration contexts that are 
semanticaly
-connected to this declaration context, in source order, including this context
-(which will be the only result, for non-namespace contexts) via
+DeclContext, one can obtain the set of declaration contexts that are
+semantically connected to this declaration context, in source order, including
+this context (which will be the only result, for non-namespace contexts) via
 ``DeclContext::collectAllContexts``. Note that these functions are used
 internally within the lookup and insertion methods of the ``DeclContext``, so
 the vast majority of clients can ignore them.
@@ -1514,7 +1514,7 @@ use an i-c-e where one is required, but
 Things get a little bit more tricky when it comes to compatibility with
 real-world source code.  Specifically, GCC has historically accepted a huge
 superset of expressions as i-c-e's, and a lot of real world code depends on
-this unfortuate accident of history (including, e.g., the glibc system
+this unfortunate accident of history (including, e.g., the glibc system
 headers).  GCC accepts anything its "fold" optimizer is capable of reducing to
 an integer constant, which means that the definition of what it accepts changes
 as its optimizer does.  One example is that GCC accepts things like "``case


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


RE: r309940 - [mips] Implement -muninit-const-in-rodata

2017-08-03 Thread Simon Dardis via cfe-commits
> From: Joerg Sonnenberger [mailto:jo...@bec.de]
> Sent: 03 August 2017 15:12
> To: cfe-commits@lists.llvm.org
> Cc: Simon Dardis
> Subject: Re: r309940 - [mips] Implement -muninit-const-in-rodata
> 
> On Thu, Aug 03, 2017 at 02:01:17PM -, Simon Dardis via cfe-commits
> wrote:
> > Author: sdardis
> > Date: Thu Aug  3 07:01:17 2017
> > New Revision: 309940
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=309940&view=rev
> > Log:
> > [mips] Implement -muninit-const-in-rodata
> >
> > This option when combined with -mgpopt and -membedded-data places all
> > uninitialized constant variables in the read-only section.
> 
> I don't get it. Why is this preferable to just forbidding the use of common
> variables in first placce?
> 
> Joerg

This was added for feature parity with GCC. as -membedded-data changes how
data is laid out in the binary. Using -fno-common places the item in the .bss 
section
which takes up memory at runtime. Both of those options are provided to reduce
the amount of memory required for some embedded programs.

Thanks,
Simon

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


[PATCH] D36249: Mark tests that need intel 80-bit floats as x86-only

2017-08-03 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

In https://reviews.llvm.org/D36249#830121, @weimingz wrote:

> I tried to address it via checking pre-defined macros:
>  https://reviews.llvm.org/D31573
>
> As long as the macros are defined correctly by clang, we don't need to worry 
> about the specific target machine. How do you think about it?


I like the idea of a feature check, rather than a specific architecture 
check--that is clearly the right thing to do.

On the other hand, I would like to mark the test as unsupported and not run in 
that case, rather than running it, saying it passed, but not actually testing 
anything. That better reflects the state of the implementation. Unfortunately, 
I don't think that can be done with macro checks. So my preference would be 
this patch over https://reviews.llvm.org/D31573, but I would also find 
https://reviews.llvm.org/D31573 acceptable if it came to that.

Finally, 80-bit doubles are a bit of a historical artifact these days. Only x86 
and m68k have them (and not even all m68Ks either). So I don't think it matters 
that much.


Repository:
  rL LLVM

https://reviews.llvm.org/D36249



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

LGTM.  I'm fine with the plan to handle potentially non-constant scopes in a 
follow-up patch.




Comment at: include/clang/Basic/SyncScope.h:21
+/// \brief Defines the synch scope values used by the atomic builtins and
+/// expressions
+enum class SyncScope {

If the numeric values here were chosen to align with the arguments to some 
runtime function, that's important to leave as a comment.



Comment at: lib/Headers/opencl-c.h:13145-13150
   memory_scope_work_item,
   memory_scope_work_group,
   memory_scope_device,
   memory_scope_all_svm_devices,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
   memory_scope_sub_group

yaxunl wrote:
> t-tye wrote:
> > Do these have to have the same values as the SycnScope enumeration? Should 
> > that be ensured in a similar way to the memory_order enumeration?
> It is desirable to have the same value as SyncScope enumeration, otherwise 
> the library has to do the translation when calling __opencl_atomic_* builtins.
> 
> Will do.
Since we're defining these builtins ourselves de novo, it's fine to pick 
argument values that align with what the existing runtime functions expect.  
Once the builtins are defined and in-use, of course, we cannot subsequently 
change the builtin values, even if the runtime changes.


https://reviews.llvm.org/D28691



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


[PATCH] D34878: [ARM] Option for reading thread pointer from coprocessor register

2017-08-03 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic updated this revision to Diff 109571.
spetrovic marked 2 inline comments as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D34878

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/ARM.cpp
  lib/Driver/ToolChains/Arch/ARM.h
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -75,6 +75,12 @@
 // ARMV5E: "-cc1"
 // ARMV5E: "-target-cpu" "arm1022e"
 
+// RUN: %clang -target arm-linux -mtp=cp15 -### -S %s -arch armv7 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER %s
+// ARMv7_THREAD_POINTER: "-target-feature" "+read-tp-hard"
+// ARMv7_THREAD_POINTER: "-mtp" "cp15"
+// ARMv7_THREAD_POINTER-NOT: "mtp" "soft"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu \
 // RUN: -### -S %s -mcpu=G5 2>&1 | FileCheck -check-prefix=PPCG5 %s
 // PPCG5: clang
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1345,6 +1345,17 @@
 CmdArgs.push_back("hard");
   }
 
+  arm::ReadTPMode ThreadPointer = arm::getReadTPMode(getToolChain(), Args);
+  if (ThreadPointer == arm::ReadTPMode::Cp15) {
+CmdArgs.push_back("-mtp");
+CmdArgs.push_back("cp15");
+  } else {
+assert(ThreadPointer == arm::ReadTPMode::Soft &&
+   "Invalid mode for reading thread pointer");
+CmdArgs.push_back("-mtp");
+CmdArgs.push_back("soft");
+  }
+
   // Forward the -mglobal-merge option for explicit control over the pass.
   if (Arg *A = Args.getLastArg(options::OPT_mglobal_merge,
options::OPT_mno_global_merge)) {
Index: lib/Driver/ToolChains/Arch/ARM.h
===
--- lib/Driver/ToolChains/Arch/ARM.h
+++ lib/Driver/ToolChains/Arch/ARM.h
@@ -32,14 +32,21 @@
 void appendEBLinkFlags(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const llvm::Triple &Triple);
+enum class ReadTPMode {
+  Invalid,
+  Soft,
+  Cp15,
+};
+
 enum class FloatABI {
   Invalid,
   Soft,
   SoftFP,
   Hard,
 };
 
 FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args);
+ReadTPMode getReadTPMode(const ToolChain &TC, const llvm::opt::ArgList &Args);
 
 bool useAAPCSForMachO(const llvm::Triple &T);
 void getARMArchCPUFromArgs(const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -122,6 +122,31 @@
  T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T);
 }
 
+// Select mode for reading thread pointer (-mtp=soft/cp15).
+arm::ReadTPMode arm::getReadTPMode(const ToolChain &TC, const ArgList &Args) {
+  const Driver &D = TC.getDriver();
+  arm::ReadTPMode ThreadPointer = ReadTPMode::Invalid;
+  if (Arg *A =
+  Args.getLastArg(options::OPT_mtp_mode_EQ)) {
+ThreadPointer = llvm::StringSwitch(A->getValue())
+.Case("cp15", ReadTPMode::Cp15)
+.Case("soft", ReadTPMode::Soft)
+.Default(ReadTPMode::Invalid);
+if (ThreadPointer == ReadTPMode::Invalid) {
+  if (StringRef(A->getValue()).empty())
+D.Diag(diag::err_drv_missing_arg_mtp) << A->getAsString(Args);
+  else
+D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);
+}
+  }
+  
+  // If -mtp option not specified or takes invalid/empty argument 
+  // choose soft mode.
+  if (ThreadPointer == ReadTPMode::Invalid)
+ThreadPointer = ReadTPMode::Soft;
+  return ThreadPointer;
+}
+
 // Select the float ABI as determined by -msoft-float, -mhard-float, and
 // -mfloat-abi=.
 arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
@@ -253,6 +278,7 @@
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
   arm::FloatABI ABI = arm::getARMFloatABI(TC, Args);
+  arm::ReadTPMode ThreadPointer = arm::getReadTPMode(TC, Args);
   const Arg *WaCPU = nullptr, *WaFPU = nullptr;
   const Arg *WaHDiv = nullptr, *WaArch = nullptr;
 
@@ -294,6 +320,10 @@
 }
   }
 
+
+  if (ThreadPointer == arm::ReadTPMode::Cp15)
+Features.push_back("+read-tp-hard");
+
   // Check -march. ClangAs gives preference to -Wa,-march=.
   const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ);
   StringRef ArchName;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1661,6 +1661,8 @@
   HelpText<"Disallow generation of data access to cod

[PATCH] D34878: [ARM] Option for reading thread pointer from coprocessor register

2017-08-03 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic added inline comments.



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:136
+if (ThreadPointer == ReadTPMode::Invalid &&
+!StringRef(A->getValue()).empty()) {
+  D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);

bruno wrote:
> What happens if you pass an empty "-mtp="  to the driver? Will it silently 
> assume soft? Shouldn't it be an error too?
I agree, it should be an error, I fixed that.


Repository:
  rL LLVM

https://reviews.llvm.org/D34878



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


r309955 - [diagtool] Add ability to pass in the id and return the name for a

2017-08-03 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Thu Aug  3 09:13:13 2017
New Revision: 309955

URL: http://llvm.org/viewvc/llvm-project?rev=309955&view=rev
Log:
[diagtool] Add ability to pass in the id and return the name for a
particular diagnostic.

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

Modified:
cfe/trunk/test/Misc/find-diagnostic-id.c
cfe/trunk/tools/diagtool/FindDiagnosticID.cpp

Modified: cfe/trunk/test/Misc/find-diagnostic-id.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/find-diagnostic-id.c?rev=309955&r1=309954&r2=309955&view=diff
==
--- cfe/trunk/test/Misc/find-diagnostic-id.c (original)
+++ cfe/trunk/test/Misc/find-diagnostic-id.c Thu Aug  3 09:13:13 2017
@@ -1,5 +1,7 @@
-// RUN: diagtool find-diagnostic-id warn_unused_variable | FileCheck %s
+// RUN: diagtool find-diagnostic-id warn_unused_variable > %t; FileCheck %s < 
%t
+// RUN: cat %t | xargs diagtool find-diagnostic-id | FileCheck %s 
--check-prefix=INVERSE
 // RUN: not diagtool find-diagnostic-id warn_unused_vars 2>&1 | FileCheck 
--check-prefix=ERROR %s
 
 // CHECK: {{^[0-9]+$}}
+// INVERSE: warn_unused_variable
 // ERROR: error: invalid diagnostic 'warn_unused_vars'

Modified: cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/FindDiagnosticID.cpp?rev=309955&r1=309954&r2=309955&view=diff
==
--- cfe/trunk/tools/diagtool/FindDiagnosticID.cpp (original)
+++ cfe/trunk/tools/diagtool/FindDiagnosticID.cpp Thu Aug  3 09:13:13 2017
@@ -18,6 +18,15 @@ DEF_DIAGTOOL("find-diagnostic-id", "Prin
 using namespace clang;
 using namespace diagtool;
 
+static StringRef getNameFromID(StringRef Name) {
+  int DiagID;
+  if(!Name.getAsInteger(0, DiagID)) {
+const DiagnosticRecord &Diag = getDiagnosticForID(DiagID);
+return Diag.getName();
+  }
+  return StringRef();
+}
+
 static Optional
 findDiagnostic(ArrayRef Diagnostics, StringRef Name) {
   for (const auto &Diag : Diagnostics) {
@@ -38,7 +47,7 @@ int FindDiagnosticID::run(unsigned int a
   llvm::cl::Required, llvm::cl::cat(FindDiagnosticIDOptions));
 
   std::vector Args;
-  Args.push_back("find-diagnostic-id");
+  Args.push_back("diagtool find-diagnostic-id");
   for (const char *A : llvm::makeArrayRef(argv, argc))
 Args.push_back(A);
 
@@ -50,6 +59,13 @@ int FindDiagnosticID::run(unsigned int a
   Optional Diag =
   findDiagnostic(AllDiagnostics, DiagnosticName);
   if (!Diag) {
+// Name to id failed, so try id to name.
+auto Name = getNameFromID(DiagnosticName);
+if (!Name.empty()) {
+  OS << Name << '\n';
+  return 0;
+}
+
 llvm::errs() << "error: invalid diagnostic '" << DiagnosticName << "'\n";
 return 1;
   }


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


[PATCH] D36252: [diagtool] Add ability to get name from id

2017-08-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309955: [diagtool] Add ability to pass in the id and return 
the name for a (authored by dhinton).

Repository:
  rL LLVM

https://reviews.llvm.org/D36252

Files:
  cfe/trunk/test/Misc/find-diagnostic-id.c
  cfe/trunk/tools/diagtool/FindDiagnosticID.cpp


Index: cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
===
--- cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
+++ cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
@@ -18,6 +18,15 @@
 using namespace clang;
 using namespace diagtool;
 
+static StringRef getNameFromID(StringRef Name) {
+  int DiagID;
+  if(!Name.getAsInteger(0, DiagID)) {
+const DiagnosticRecord &Diag = getDiagnosticForID(DiagID);
+return Diag.getName();
+  }
+  return StringRef();
+}
+
 static Optional
 findDiagnostic(ArrayRef Diagnostics, StringRef Name) {
   for (const auto &Diag : Diagnostics) {
@@ -38,7 +47,7 @@
   llvm::cl::Required, llvm::cl::cat(FindDiagnosticIDOptions));
 
   std::vector Args;
-  Args.push_back("find-diagnostic-id");
+  Args.push_back("diagtool find-diagnostic-id");
   for (const char *A : llvm::makeArrayRef(argv, argc))
 Args.push_back(A);
 
@@ -50,6 +59,13 @@
   Optional Diag =
   findDiagnostic(AllDiagnostics, DiagnosticName);
   if (!Diag) {
+// Name to id failed, so try id to name.
+auto Name = getNameFromID(DiagnosticName);
+if (!Name.empty()) {
+  OS << Name << '\n';
+  return 0;
+}
+
 llvm::errs() << "error: invalid diagnostic '" << DiagnosticName << "'\n";
 return 1;
   }
Index: cfe/trunk/test/Misc/find-diagnostic-id.c
===
--- cfe/trunk/test/Misc/find-diagnostic-id.c
+++ cfe/trunk/test/Misc/find-diagnostic-id.c
@@ -1,5 +1,7 @@
-// RUN: diagtool find-diagnostic-id warn_unused_variable | FileCheck %s
+// RUN: diagtool find-diagnostic-id warn_unused_variable > %t; FileCheck %s < 
%t
+// RUN: cat %t | xargs diagtool find-diagnostic-id | FileCheck %s 
--check-prefix=INVERSE
 // RUN: not diagtool find-diagnostic-id warn_unused_vars 2>&1 | FileCheck 
--check-prefix=ERROR %s
 
 // CHECK: {{^[0-9]+$}}
+// INVERSE: warn_unused_variable
 // ERROR: error: invalid diagnostic 'warn_unused_vars'


Index: cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
===
--- cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
+++ cfe/trunk/tools/diagtool/FindDiagnosticID.cpp
@@ -18,6 +18,15 @@
 using namespace clang;
 using namespace diagtool;
 
+static StringRef getNameFromID(StringRef Name) {
+  int DiagID;
+  if(!Name.getAsInteger(0, DiagID)) {
+const DiagnosticRecord &Diag = getDiagnosticForID(DiagID);
+return Diag.getName();
+  }
+  return StringRef();
+}
+
 static Optional
 findDiagnostic(ArrayRef Diagnostics, StringRef Name) {
   for (const auto &Diag : Diagnostics) {
@@ -38,7 +47,7 @@
   llvm::cl::Required, llvm::cl::cat(FindDiagnosticIDOptions));
 
   std::vector Args;
-  Args.push_back("find-diagnostic-id");
+  Args.push_back("diagtool find-diagnostic-id");
   for (const char *A : llvm::makeArrayRef(argv, argc))
 Args.push_back(A);
 
@@ -50,6 +59,13 @@
   Optional Diag =
   findDiagnostic(AllDiagnostics, DiagnosticName);
   if (!Diag) {
+// Name to id failed, so try id to name.
+auto Name = getNameFromID(DiagnosticName);
+if (!Name.empty()) {
+  OS << Name << '\n';
+  return 0;
+}
+
 llvm::errs() << "error: invalid diagnostic '" << DiagnosticName << "'\n";
 return 1;
   }
Index: cfe/trunk/test/Misc/find-diagnostic-id.c
===
--- cfe/trunk/test/Misc/find-diagnostic-id.c
+++ cfe/trunk/test/Misc/find-diagnostic-id.c
@@ -1,5 +1,7 @@
-// RUN: diagtool find-diagnostic-id warn_unused_variable | FileCheck %s
+// RUN: diagtool find-diagnostic-id warn_unused_variable > %t; FileCheck %s < %t
+// RUN: cat %t | xargs diagtool find-diagnostic-id | FileCheck %s --check-prefix=INVERSE
 // RUN: not diagtool find-diagnostic-id warn_unused_vars 2>&1 | FileCheck --check-prefix=ERROR %s
 
 // CHECK: {{^[0-9]+$}}
+// INVERSE: warn_unused_variable
 // ERROR: error: invalid diagnostic 'warn_unused_vars'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308996 - [coroutines] Add serialization/deserialization of coroutines

2017-08-03 Thread Hans Wennborg via cfe-commits
On Wed, Aug 2, 2017 at 3:29 PM, Richard Smith  wrote:
> On 31 July 2017 at 09:11, Hans Wennborg via cfe-commits
>  wrote:
>>
>> Richard, Gor asked for this to be merged to 5.0. What do you think?
>
>
> Sounds good to me.

r309954. Thanks!

>
>> On Tue, Jul 25, 2017 at 11:01 AM, Gor Nishanov via cfe-commits
>>  wrote:
>> > Author: gornishanov
>> > Date: Tue Jul 25 11:01:49 2017
>> > New Revision: 308996
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=308996&view=rev
>> > Log:
>> > [coroutines] Add serialization/deserialization of coroutines
>> >
>> > Reviewers: rsmith
>> >
>> > Reviewed By: rsmith
>> >
>> > Subscribers: EricWF, cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D35383
>> >
>> > Added:
>> > cfe/trunk/test/PCH/coroutines.cpp
>> > Modified:
>> > cfe/trunk/include/clang/AST/StmtCXX.h
>> > cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> > cfe/trunk/lib/AST/StmtCXX.cpp
>> > cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
>> > cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r309958 - Merging r309917:

2017-08-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Aug  3 09:34:10 2017
New Revision: 309958

URL: http://llvm.org/viewvc/llvm-project?rev=309958&view=rev
Log:
Merging r309917:

r309917 | ericwf | 2017-08-02 19:50:43 -0700 (Wed, 02 Aug 2017) | 4 lines

Add system header pragma to BSD locale fallback headers.

This prevent leaking warnings to the user about use of C++11
extensions in C++03.


Modified:
libcxx/branches/release_50/   (props changed)
libcxx/branches/release_50/include/__bsd_locale_defaults.h
libcxx/branches/release_50/include/__bsd_locale_fallbacks.h

Propchange: libcxx/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug  3 09:34:10 2017
@@ -1 +1,2 @@
 /libcxx/branches/apple:136569-137939
+/libcxx/trunk:309917

Modified: libcxx/branches/release_50/include/__bsd_locale_defaults.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/__bsd_locale_defaults.h?rev=309958&r1=309957&r2=309958&view=diff
==
--- libcxx/branches/release_50/include/__bsd_locale_defaults.h (original)
+++ libcxx/branches/release_50/include/__bsd_locale_defaults.h Thu Aug  3 
09:34:10 2017
@@ -15,6 +15,10 @@
 #ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
 #define _LIBCPP_BSD_LOCALE_DEFAULTS_H
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #define __libcpp_mb_cur_max_l(loc)  MB_CUR_MAX_L(loc)
 #define __libcpp_btowc_l(ch, loc)   btowc_l(ch, loc)
 #define __libcpp_wctob_l(wch, loc)  wctob_l(wch, loc)

Modified: libcxx/branches/release_50/include/__bsd_locale_fallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/__bsd_locale_fallbacks.h?rev=309958&r1=309957&r2=309958&view=diff
==
--- libcxx/branches/release_50/include/__bsd_locale_fallbacks.h (original)
+++ libcxx/branches/release_50/include/__bsd_locale_fallbacks.h Thu Aug  3 
09:34:10 2017
@@ -18,6 +18,10 @@
 #include 
 #include 
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 inline _LIBCPP_ALWAYS_INLINE


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


[PATCH] D35678: Omit sumbodule semantics for TS modules

2017-08-03 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D35678



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


[PATCH] D32199: [TySan] A Type Sanitizer (Clang)

2017-08-03 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D32199#828526, @rjmccall wrote:

> Has this proposal run aground?  I'm going back over some old patches that 
> I've been CC'ed on and trying to make sure they're not blocking on my review.


I need to rebase these now that we've "fixed" the union metadata, but I believe 
that orthogonal to the changes here, and otherwise these should be ready to go. 
Could you please review this patch? Thanks in advance.


https://reviews.llvm.org/D32199



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


r309960 - Revert r304836.

2017-08-03 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Aug  3 09:46:17 2017
New Revision: 309960

URL: http://llvm.org/viewvc/llvm-project?rev=309960&view=rev
Log:
Revert r304836.

See discussion in https://reviews.llvm.org/D33900#824172

Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=309960&r1=309959&r2=309960&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Aug  3 09:46:17 2017
@@ -1191,10 +1191,6 @@ bool Driver::HandleImmediateArgs(const C
   if (C.getArgs().hasArg(options::OPT__version)) {
 // Follow gcc behavior and use stdout for --version and stderr for -v.
 PrintVersion(C, llvm::outs());
-
-// Print registered targets.
-llvm::outs() << '\n';
-llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
 return false;
   }
 


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


[PATCH] D33900: Print registered targets in clang's version information

2017-08-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I've reverted this in 309960, as discussed.


https://reviews.llvm.org/D33900



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


Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-03 Thread Shoaib Meenai via cfe-commits
Ping.

On 7/28/17, 7:57 PM, "Shoaib Meenai"  wrote:

Marshall, Eric, Hans,

Any objections to backporting this to 5.0? It fixes a potential visibility
issue for clients of the header.

On 7/28/17, 7:54 PM, "cfe-commits on behalf of Shoaib Meenai via 
cfe-commits"  wrote:

Author: smeenai
Date: Fri Jul 28 19:54:41 2017
New Revision: 309474

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D309474-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=EcGbIxegCOTbSLMJelp_vOaeGiS_iQ1eciM_oeX41-E&s=5q7TS5mhaUsf-1jQBqX62RvjcqAiy2whh8RO7yFhPyA&e=
 
Log:
[libc++] Hoist extern template above first use

This function template is referenced inside class basic_string as a
friend function. The extern template declaration needs to be above that
friend declaration to actually take effect.

This is important because this function was marked as exported in
r307966, so without the extern template taking effect, it can leak into
other DSOs as a visible symbol.

Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_string-3Frev-3D309474-26r1-3D309473-26r2-3D309474-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=EcGbIxegCOTbSLMJelp_vOaeGiS_iQ1eciM_oeX41-E&s=zFJXc9CA6Sgyh25kGeAh4Qo36gpNQX_zo2qRlRFJoL8&e=
 

==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Fri Jul 28 19:54:41 2017
@@ -556,6 +556,8 @@ template
 operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT 
__y);
 
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&))
+
 template 
 class _LIBCPP_TEMPLATE_VIS __basic_string_common
 {
@@ -3999,7 +4001,6 @@ basic_string<_CharT, _Traits, _Allocator
 
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
basic_string)
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
basic_string)
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&))
 
 #if _LIBCPP_STD_VER > 11 
 // Literal suffixes for basic_string [basic.string.literals]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=EcGbIxegCOTbSLMJelp_vOaeGiS_iQ1eciM_oeX41-E&s=95GYNfQT_kBVjYvYRYnF3mje6PEyF4EDl4MCBQKCu88&e=
 




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


  1   2   >