Re: [clang-tools-extra] r308738 - [clangd] Replace ASTUnit with manual AST management.

2017-07-25 Thread Ilya Biryukov via cfe-commits
Hi Douglas,

Looked into that yesterday, there's a mismatch between windows and linux
paths in the output.
I'll come up with a fix today.

On Mon, Jul 24, 2017 at 9:08 PM, Yung, Douglas 
wrote:

> Hi Ilya,
>
> Your change seems to be causing the test 'clangd/definitions.test' to fail
> on the PS4 Windows bot. Can you take a look?
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/11222
>
> FAIL: Clang Tools :: clangd/definitions.test (11935 of 34225)
>  TEST 'Clang Tools :: clangd/definitions.test' FAILED
> 
> Script:
> --
> clangd -run-synchronously < C:\ps4-buildslave2\llvm-clang-
> lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\
> tools\clang\tools\extra\test\clangd\definitions.test | FileCheck
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\tools\extra\test\
> clangd\definitions.test
> --
> Exit Code: 1
>
> Command Output (stdout):
> --
> $ "clangd" "-run-synchronously"
> # command stderr:
> <-- {"jsonrpc":"2.0","id":0,"method":"initialize","params":
> {"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
>
> --> {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
>
>   "textDocumentSync": 1,
>
>   "documentFormattingProvider": true,
>
>   "documentRangeFormattingProvider": true,
>
>   "documentOnTypeFormattingProvider":
> {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
>
>   "codeActionProvider": true,
>
>   "completionProvider": {"resolveProvider": false,
> "triggerCharacters": [".",">"]},
>
>   "definitionProvider": true
>
> }}}
>
> <-- {"jsonrpc":"2.0","method":"textDocument/didOpen","params"
> :{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int
> main() {\nint a;\na;\n}\n"}}}
>
> --> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{
> "uri":"file:///main.cpp","diagnostics":[{"range":{"start": {"line": 2,
> "character": 1}, "end": {"line": 2, "character":
> 1}},"severity":2,"message":"expression result unused"}]}}
>
> <-- {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"
> textDocument":{"uri":"file:///main.cpp"},"position":{"line":
> 2,"character":0}}}
>
> --> {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp",
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,
> "character": 5}}}]}
>
> <-- {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"
> textDocument":{"uri":"file:///main.cpp"},"position":{"line":
> 2,"character":1}}}
>
> --> {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp",
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,
> "character": 5}}}]}
>
> <-- {"jsonrpc":"2.0","method":"textDocument/didChange","
> params":{"textDocument":{"uri":"file:///main.cpp","version":
> 2},"contentChanges":[{"text":"struct Foo {\nint x;\n};\nint main() {\n
> Foo bar = { x : 1 };\n}\n"}]}}
>
> --> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{
> "uri":"file:///main.cpp","diagnostics":[{"range":{"start": {"line": 4,
> "character": 15}, "end": {"line": 4, "character":
> 15}},"severity":2,"message":"use of GNU old-style field designator
> extension"}]}}
>
> <-- {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"
> textDocument":{"uri":"file:///main.cpp"},"position":{"line":
> 4,"character":14}}}
>
> --> {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp",
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,
> "character": 5}}}]}
>
> <-- {"jsonrpc":"2.0","method":"textDocument/didChange","
> params":{"textDocument":{"uri":"file:///main.cpp","version":
> 3},"contentChanges":[{"text":"struct Foo {\nint x;\n};\nint main() {\n
> Foo baz = { .x = 2 };\n}\n"}]}}
>
> --> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{
> "uri":"file:///main.cpp","diagnostics":[]}}
>
> <-- {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"
> textDocument":{"uri":"file:///main.cpp"},"position":{"line":
> 4,"character":15}}}
>
> --> {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp",
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,
> "character": 5}}}]}
>
> <-- {"jsonrpc":"2.0","method":"textDocument/didChange","
> params":{"textDocument":{"uri":"file:///main.cpp","version":
> 4},"contentChanges":[{"text":"int main() {\n   main();\n   return
> 0;\n}"}]}
>
> --> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{
> "uri":"file:///main.cpp","diagnostics":[]}}
>
> <-- {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"
> textDocument":{"uri":"file:///main.cpp"},"position":{"line":
> 1,"character":3}}}
>
> --> {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp",
> "range": {"start": {"line": 0, "character": 0}, "end": {"line": 3,
> "character": 1}}}]}
>
> <-- {"jsonrpc":"2.0","method":"textDoc

[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-07-25 Thread Peter Siket via Phabricator via cfe-commits
MontyKutyi added a comment.

As I can see the `clang/test` contains a lot of different simple tests, but for 
testing this I think it is not enough to run the clang with some arguments on a 
specific input.  So I should create a new executable which uses the postorder 
mode of the RecursiveASTVisitor.  Am I right or is there another preferred way 
for doing this?


https://reviews.llvm.org/D34030



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


[PATCH] D35783: Ignore shadowing for declarations coming from within macros.

2017-07-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

How does this relate to the gcc behavior?
I suspect not everyone would want to have this relaxed `-Wshadow` mode.
Perhaps it could be hidden under some new flag, which is not going to be 
automatically enabled by `-Weverything`.
Like, `-Wshadow-in-macros` which does nothing compared to `-Wshadow`, and then 
`-Wno-shadow-in-macros` which enables this relaxed mode?


https://reviews.llvm.org/D35783



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


[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> I suspect that the usage of the CFGStmtMap* caused the undefined behaviour 
> since its lifetime was depending on its LocationContext.

Yeah, it lives in `AnalysisDeclContextManager`, which lives in 
`AnalysisManager`, which lives throughout a single analysis (top-level 
function) and then dies (when the next top-level function is picked that wasn't 
covered during inlining) to clean up the allocators.

However, you store it in the program state, right? And the new analysis has new 
program states, which don't contain references to the old `CFGStmtMaps`(?)

Also the way you construct `CFGStmtMap` manually sounds slow to me (it's done 
on every path), i guess the whole point of having it in `AnalysisDeclContext` 
was to avoid this.

So i don't think this is it, but i guess you should try speculatively relanding 
anyway, and add the extra run-line that'd show you the backtrace. We made 
changes, so the issue might have been wiped out accidentally (or maybe you're 
actually right!), and if it wasn't, at least we'd have the backtrace for the 
crash.


https://reviews.llvm.org/D34260



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


[PATCH] D35190: __builtin_constant_p should consider the parameter of a constexpr function as constant

2017-07-25 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart added a comment.

ping


https://reviews.llvm.org/D35190



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


[PATCH] D35825: [clangd] Reuse compile commands during reparse

2017-07-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.

Previously we always queried the compilation database and discarded the results
if the file was already opened.


https://reviews.llvm.org/D35825

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


Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start


Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308957 - [analyzer] Further improve suppress-on-sink behavior in incomplete analyses.

2017-07-25 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jul 25 02:25:10 2017
New Revision: 308957

URL: http://llvm.org/viewvc/llvm-project?rev=308957&view=rev
Log:
[analyzer] Further improve suppress-on-sink behavior in incomplete analyses.

If a certain memory leak (or other similar bug) found by the analyzer is known
to be happening only before abnormal termination of the program ("sink", eg.
assertion failure in the code under analysis, or another bug that introduces
undefined behavior), such leak warning is discarded. However, if the analysis
has never reaches completion (due to complexity of the code), it may be
failing to notice the sink.

This commit further extends the partial solution introduced in r290341 to cover
cases when a complicated control flow occurs before encountering a no-return
statement (which anyway inevitably leads to such statement(s)) by traversing
the respective section of the CFG in a depth-first manner. A complete solution
still seems elusive.

rdar://problem/28157554

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=308957&r1=308956&r2=308957&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Jul 25 02:25:10 2017
@@ -3310,6 +3310,45 @@ static const CFGBlock *findBlockForNode(
   return nullptr;
 }
 
+static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
+  const CFG &Cfg = N->getCFG();
+
+  const CFGBlock *StartBlk = findBlockForNode(N);
+  if (!StartBlk)
+return false;
+  if (StartBlk->hasNoReturnElement())
+return true;
+
+  llvm::SmallVector DFSWorkList;
+  llvm::SmallPtrSet Visited;
+
+  DFSWorkList.push_back(StartBlk);
+  while (!DFSWorkList.empty()) {
+const CFGBlock *Blk = DFSWorkList.back();
+DFSWorkList.pop_back();
+Visited.insert(Blk);
+
+for (const auto &Succ : Blk->succs()) {
+  if (const CFGBlock *SuccBlk = Succ.getReachableBlock()) {
+if (SuccBlk == &Cfg.getExit()) {
+  // We seem to be leaving the current CFG.
+  // We're no longer sure what happens next.
+  return false;
+}
+
+if (!SuccBlk->hasNoReturnElement() && !Visited.count(SuccBlk)) {
+  // If the block has reachable child blocks that aren't no-return,
+  // add them to the worklist.
+  DFSWorkList.push_back(SuccBlk);
+}
+  }
+}
+  }
+
+  // Nothing reached the exit. It can only mean one thing: there's no return.
+  return true;
+}
+
 static BugReport *
 FindReportInEquivalenceClass(BugReportEquivClass& EQ,
  SmallVectorImpl &bugReports) {
@@ -3366,9 +3405,8 @@ FindReportInEquivalenceClass(BugReportEq
 // We may be post-dominated in subsequent blocks, or even
 // inter-procedurally. However, it is not clear if more complicated
 // cases are generally worth suppressing.
-if (const CFGBlock *B = findBlockForNode(errorNode))
-  if (B->hasNoReturnElement())
-continue;
+if (isDominatedByNoReturnBlocks(errorNode))
+  continue;
 
 // At this point we know that 'N' is not a sink and it has at least one
 // successor.  Use a DFS worklist to find a non-sink end-of-path node.

Modified: cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c?rev=308957&r1=308956&r2=308957&view=diff
==
--- cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c (original)
+++ cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c Tue Jul 25 02:25:10 
2017
@@ -15,6 +15,8 @@ extern void exit(int) __attribute__ ((__
 
 void clang_analyzer_warnIfReached(void);
 
+int coin();
+
 void test_single_cfg_block_sink() {
   void *p = malloc(1); // no-warning (wherever the leak warning may occur here)
 
@@ -29,3 +31,53 @@ void test_single_cfg_block_sink() {
   // the leak report.
   exit(0);
 }
+
+// A similar test with more complicated control flow before the no-return 
thing,
+// so that the no-return thing wasn't in the same CFG block.
+void test_more_complex_control_flow_before_sink() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  if (coin())
+exit(0);
+  else
+exit(1);
+}
+
+// A loop before the no-return function, to make sure that
+// the dominated-by-sink analysis doesn't hang.
+void test_loop_before_sink(int n) {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReach

[PATCH] D35673: [analyzer] A better CFG-based suppress-on-sink.

2017-07-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308957: [analyzer] Further improve suppress-on-sink behavior 
in incomplete analyses. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D35673?vs=107871&id=108024#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35673

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3310,6 +3310,45 @@
   return nullptr;
 }
 
+static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
+  const CFG &Cfg = N->getCFG();
+
+  const CFGBlock *StartBlk = findBlockForNode(N);
+  if (!StartBlk)
+return false;
+  if (StartBlk->hasNoReturnElement())
+return true;
+
+  llvm::SmallVector DFSWorkList;
+  llvm::SmallPtrSet Visited;
+
+  DFSWorkList.push_back(StartBlk);
+  while (!DFSWorkList.empty()) {
+const CFGBlock *Blk = DFSWorkList.back();
+DFSWorkList.pop_back();
+Visited.insert(Blk);
+
+for (const auto &Succ : Blk->succs()) {
+  if (const CFGBlock *SuccBlk = Succ.getReachableBlock()) {
+if (SuccBlk == &Cfg.getExit()) {
+  // We seem to be leaving the current CFG.
+  // We're no longer sure what happens next.
+  return false;
+}
+
+if (!SuccBlk->hasNoReturnElement() && !Visited.count(SuccBlk)) {
+  // If the block has reachable child blocks that aren't no-return,
+  // add them to the worklist.
+  DFSWorkList.push_back(SuccBlk);
+}
+  }
+}
+  }
+
+  // Nothing reached the exit. It can only mean one thing: there's no return.
+  return true;
+}
+
 static BugReport *
 FindReportInEquivalenceClass(BugReportEquivClass& EQ,
  SmallVectorImpl &bugReports) {
@@ -3366,9 +3405,8 @@
 // We may be post-dominated in subsequent blocks, or even
 // inter-procedurally. However, it is not clear if more complicated
 // cases are generally worth suppressing.
-if (const CFGBlock *B = findBlockForNode(errorNode))
-  if (B->hasNoReturnElement())
-continue;
+if (isDominatedByNoReturnBlocks(errorNode))
+  continue;
 
 // At this point we know that 'N' is not a sink and it has at least one
 // successor.  Use a DFS worklist to find a non-sink end-of-path node.
Index: cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c
===
--- cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c
+++ cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.c
@@ -15,6 +15,8 @@
 
 void clang_analyzer_warnIfReached(void);
 
+int coin();
+
 void test_single_cfg_block_sink() {
   void *p = malloc(1); // no-warning (wherever the leak warning may occur here)
 
@@ -29,3 +31,53 @@
   // the leak report.
   exit(0);
 }
+
+// A similar test with more complicated control flow before the no-return thing,
+// so that the no-return thing wasn't in the same CFG block.
+void test_more_complex_control_flow_before_sink() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  if (coin())
+exit(0);
+  else
+exit(1);
+}
+
+// A loop before the no-return function, to make sure that
+// the dominated-by-sink analysis doesn't hang.
+void test_loop_before_sink(int n) {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  for (int i = 0; i < n; ++i) {
+  }
+  exit(1);
+}
+
+// We're not sure if this is no-return.
+void test_loop_with_sink(int n) {
+  void *p = malloc(1); // expected-warning@+2{{Potential leak of memory}}
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  for (int i = 0; i < n; ++i)
+if (i == 0)
+  exit(1);
+}
+
+// Handle unreachable blocks correctly.
+void test_unreachable_successor_blocks() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  if (1) // no-crash
+exit(1);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r308959 - [clangd] Workaround Windows test failures.

2017-07-25 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jul 25 02:31:51 2017
New Revision: 308959

URL: http://llvm.org/viewvc/llvm-project?rev=308959&view=rev
Log:
[clangd] Workaround Windows test failures.

To properly fix this, Unix-specific paths should not be used when
running tests on Windows.

Modified:
clang-tools-extra/trunk/test/clangd/definitions.test

Modified: clang-tools-extra/trunk/test/clangd/definitions.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/definitions.test?rev=308959&r1=308958&r2=308959&view=diff
==
--- clang-tools-extra/trunk/test/clangd/definitions.test (original)
+++ clang-tools-extra/trunk/test/clangd/definitions.test Tue Jul 25 02:31:51 
2017
@@ -138,8 +138,8 @@ Content-Length: 204
 Content-Length: 148
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":9}}}
-# Go to macro
-# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp", 
"range": {"start": {"line": 0, "character": 8}, "end": {"line": 0, "character": 
18}}}]}
+# Go to macro.
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"uri": 
"file:///{{(C:/)?}}main.cpp", "range": {"start": {"line": 0, "character": 8}, 
"end": {"line": 0, "character": 18}}}]}
 
 Content-Length: 217
 
@@ -149,7 +149,7 @@ Content-Length: 148
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":8}}}
 # Go to macro, re-defined later
-# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"uri": "file:///main.cpp", 
"range": {"start": {"line": 0, "character": 8}, "end": {"line": 0, "character": 
13}}}]}
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"uri": 
"file:///{{(C:/)?}}main.cpp", "range": {"start": {"line": 0, "character": 8}, 
"end": {"line": 0, "character": 13}}}]}
 
 Content-Length: 148
 


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


[PATCH] D35825: [clangd] Reuse compile commands during reparse

2017-07-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.cpp:248
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+

Also have to call it in `codeComplete`.


https://reviews.llvm.org/D35825



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


r308961 - [analyzer] Treat throws as sinks for suppress-on-sink purposes.

2017-07-25 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jul 25 02:44:02 2017
New Revision: 308961

URL: http://llvm.org/viewvc/llvm-project?rev=308961&view=rev
Log:
[analyzer] Treat throws as sinks for suppress-on-sink purposes.

Because since r308957 the suppress-on-sink feature contains its own
mini-analysis, it also needs to become aware that C++ unhandled exceptions
cause sinks. Unfortunately, for now we treat all exceptions as unhandled in
the analyzer, so suppress-on-sink needs to do the same.

rdar://problem/28157554

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

Added:
cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=308961&r1=308960&r2=308961&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Jul 25 02:44:02 2017
@@ -3310,13 +3310,34 @@ static const CFGBlock *findBlockForNode(
   return nullptr;
 }
 
+static bool isNoReturnBlock(const CFGBlock *Blk) {
+  if (Blk->hasNoReturnElement())
+return true;
+
+  // FIXME: Throw-expressions are currently generating sinks during analysis:
+  // they're not supported yet, and also often used for actually terminating
+  // the program. So we should treat them as sinks in this analysis as well,
+  // at least for now, but once we have better support for exceptions,
+  // we'd need to carefully handle the case when the throw is being
+  // immediately caught.
+  if (std::any_of(Blk->begin(), Blk->end(), [](const CFGElement &Elm) {
+if (Optional StmtElm = Elm.getAs())
+  if (isa(StmtElm->getStmt()))
+return true;
+return false;
+  }))
+return true;
+
+  return false;
+}
+
 static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
   const CFG &Cfg = N->getCFG();
 
   const CFGBlock *StartBlk = findBlockForNode(N);
   if (!StartBlk)
 return false;
-  if (StartBlk->hasNoReturnElement())
+  if (isNoReturnBlock(StartBlk))
 return true;
 
   llvm::SmallVector DFSWorkList;
@@ -3336,7 +3357,7 @@ static bool isDominatedByNoReturnBlocks(
   return false;
 }
 
-if (!SuccBlk->hasNoReturnElement() && !Visited.count(SuccBlk)) {
+if (!isNoReturnBlock(SuccBlk) && !Visited.count(SuccBlk)) {
   // If the block has reachable child blocks that aren't no-return,
   // add them to the worklist.
   DFSWorkList.push_back(SuccBlk);

Added: cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp?rev=308961&view=auto
==
--- cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp (added)
+++ cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp Tue Jul 25 02:44:02 
2017
@@ -0,0 +1,34 @@
+// RUN: %clang_analyze_cc1 -x c++ -fcxx-exceptions 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
max-nodes=12 -verify %s
+
+// Here we test how "suppress on sink" feature of certain bugtypes interacts
+// with reaching analysis limits. See comments in max-nodes-suppress-on-sink.c
+// for more discussion.
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+void clang_analyzer_warnIfReached(void);
+
+// Because we don't have a better approach, we currently treat throw as
+// noreturn.
+void test_throw_treated_as_noreturn() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  throw 0;
+}
+
+// FIXME: Handled throws shouldn't be suppressing us!
+void test_handled_throw_treated_as_noreturn() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  try {
+throw 0;
+  } catch (int i) {
+  }
+}


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


[PATCH] D35674: [analyzer] Treat C++ throw as sink during CFG-based suppress-on-sink.

2017-07-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308961: [analyzer] Treat throws as sinks for 
suppress-on-sink purposes. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D35674?vs=107873&id=108029#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35674

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3310,13 +3310,34 @@
   return nullptr;
 }
 
+static bool isNoReturnBlock(const CFGBlock *Blk) {
+  if (Blk->hasNoReturnElement())
+return true;
+
+  // FIXME: Throw-expressions are currently generating sinks during analysis:
+  // they're not supported yet, and also often used for actually terminating
+  // the program. So we should treat them as sinks in this analysis as well,
+  // at least for now, but once we have better support for exceptions,
+  // we'd need to carefully handle the case when the throw is being
+  // immediately caught.
+  if (std::any_of(Blk->begin(), Blk->end(), [](const CFGElement &Elm) {
+if (Optional StmtElm = Elm.getAs())
+  if (isa(StmtElm->getStmt()))
+return true;
+return false;
+  }))
+return true;
+
+  return false;
+}
+
 static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
   const CFG &Cfg = N->getCFG();
 
   const CFGBlock *StartBlk = findBlockForNode(N);
   if (!StartBlk)
 return false;
-  if (StartBlk->hasNoReturnElement())
+  if (isNoReturnBlock(StartBlk))
 return true;
 
   llvm::SmallVector DFSWorkList;
@@ -3336,7 +3357,7 @@
   return false;
 }
 
-if (!SuccBlk->hasNoReturnElement() && !Visited.count(SuccBlk)) {
+if (!isNoReturnBlock(SuccBlk) && !Visited.count(SuccBlk)) {
   // If the block has reachable child blocks that aren't no-return,
   // add them to the worklist.
   DFSWorkList.push_back(SuccBlk);
Index: cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp
===
--- cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp
+++ cfe/trunk/test/Analysis/max-nodes-suppress-on-sink.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_analyze_cc1 -x c++ -fcxx-exceptions 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
max-nodes=12 -verify %s
+
+// Here we test how "suppress on sink" feature of certain bugtypes interacts
+// with reaching analysis limits. See comments in max-nodes-suppress-on-sink.c
+// for more discussion.
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+void clang_analyzer_warnIfReached(void);
+
+// Because we don't have a better approach, we currently treat throw as
+// noreturn.
+void test_throw_treated_as_noreturn() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  throw 0;
+}
+
+// FIXME: Handled throws shouldn't be suppressing us!
+void test_handled_throw_treated_as_noreturn() {
+  void *p = malloc(1); // no-warning
+
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  try {
+throw 0;
+  } catch (int i) {
+  }
+}


Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3310,13 +3310,34 @@
   return nullptr;
 }
 
+static bool isNoReturnBlock(const CFGBlock *Blk) {
+  if (Blk->hasNoReturnElement())
+return true;
+
+  // FIXME: Throw-expressions are currently generating sinks during analysis:
+  // they're not supported yet, and also often used for actually terminating
+  // the program. So we should treat them as sinks in this analysis as well,
+  // at least for now, but once we have better support for exceptions,
+  // we'd need to carefully handle the case when the throw is being
+  // immediately caught.
+  if (std::any_of(Blk->begin(), Blk->end(), [](const CFGElement &Elm) {
+if (Optional StmtElm = Elm.getAs())
+  if (isa(StmtElm->getStmt()))
+return true;
+return false;
+  }))
+return true;
+
+  return false;
+}
+
 static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
   const CFG &Cfg = N->getCFG();
 
   const CFGBlock *StartBlk = findBlockForNode(N);
   if (!StartBlk)
 return false;
-  if (StartBlk->hasNoReturnElement())
+  if (isNoReturnBlock(StartBlk))
 return true;
 
   llvm::SmallVector DFSWorkList;
@@ -3336,7 +3357,7 @@
   return false;
 }
 
-if (!SuccBlk->hasNoReturnElement() && !Visited.count(Su

[PATCH] D35826: [Driver] Error if ARM mode was selected explicitly for M-profile CPUs.

2017-07-25 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

M-class profiles do not support ARM execution mode, so providing
-marm/-mno-thumb does not make sense in combination with -mcpu/-march
options that support the M-profile.

This is a follow-up patch to https://reviews.llvm.org/D35569 and it seemed 
pretty clear that we
should emit an error in the driver in this case.

We probably also should warn/error if the provided -mcpu/-march options
do not match, e.g. -mcpu=cortex-m0 -march=armv8-a is invalid, as
cortex-m0 does not support armv8-a. But that should be a separate patch
I think.


https://reviews.llvm.org/D35826

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChain.cpp
  test/Driver/arm-thumb-only-cores.c


Index: test/Driver/arm-thumb-only-cores.c
===
--- /dev/null
+++ test/Driver/arm-thumb-only-cores.c
@@ -0,0 +1,12 @@
+// RUN: not %clang -target arm-unknown-linux -marm -mcpu=cortex-m0 %s -o 
/dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix M0 %s
+// M0: error: CPU 'cortex-m0' does not support 'ARM' execution mode
+
+// RUN: not %clang -target arm-unknown-linux -marm -march=armv7m %s -o 
/dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix ARMV7M %s
+// RUN: not %clang -target armv7m-unknown-linux -mno-thumb %s -o /dev/null 
2>&1 \
+// RUN:   | FileCheck --check-prefix ARMV7M %s
+// ARMV7M: error: Architecture 'armv7m' does not support 'ARM' execution mode
+//
+// RUN: %clang -S -emit-llvm -target arm-unknown-linux -mcpu=cortex-m0 %s -o 
/dev/null 2>&1
+// M-Profile CPUs default to Thumb mode even if arm triples are provided.
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -517,6 +517,18 @@
 else
   ArchName = "arm";
 
+// Check if ARM ISA was explicitly selected (using -mno-thumb or -marm) for
+// M-Class CPUs/architecture variants, which is not supported.
+bool ARMModeRequested = !Args.hasFlag(options::OPT_mthumb,
+  options::OPT_mno_thumb, 
ThumbDefault);
+if (IsMProfile && ARMModeRequested) {
+  if (!MCPU.empty())
+getDriver().Diag(diag::err_cpu_unsupported_isa) << CPU << "ARM";
+   else
+getDriver().Diag(diag::err_arch_unsupported_isa)
+  << tools::arm::getARMArch(MArch, getTriple()) << "ARM";
+}
+
 // Assembly files should start in ARM mode, unless arch is M-profile.
 // Windows is always thumb.
 if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -106,6 +106,10 @@
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;
+def err_cpu_unsupported_isa
+  : Error<"CPU '%0' does not support '%1' execution mode">;
+def err_arch_unsupported_isa
+  : Error<"Architecture '%0' does not support '%1' execution mode">;
 
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;


Index: test/Driver/arm-thumb-only-cores.c
===
--- /dev/null
+++ test/Driver/arm-thumb-only-cores.c
@@ -0,0 +1,12 @@
+// RUN: not %clang -target arm-unknown-linux -marm -mcpu=cortex-m0 %s -o /dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix M0 %s
+// M0: error: CPU 'cortex-m0' does not support 'ARM' execution mode
+
+// RUN: not %clang -target arm-unknown-linux -marm -march=armv7m %s -o /dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix ARMV7M %s
+// RUN: not %clang -target armv7m-unknown-linux -mno-thumb %s -o /dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix ARMV7M %s
+// ARMV7M: error: Architecture 'armv7m' does not support 'ARM' execution mode
+//
+// RUN: %clang -S -emit-llvm -target arm-unknown-linux -mcpu=cortex-m0 %s -o /dev/null 2>&1
+// M-Profile CPUs default to Thumb mode even if arm triples are provided.
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -517,6 +517,18 @@
 else
   ArchName = "arm";
 
+// Check if ARM ISA was explicitly selected (using -mno-thumb or -marm) for
+// M-Class CPUs/architecture variants, which is not supported.
+bool ARMModeRequested = !Args.hasFlag(options::OPT_mthumb,
+  options::OPT_mno_thumb, ThumbDefault);
+if (IsMProfile && ARMModeRequested) {
+  if (!MCPU.empty())
+getDriver().Diag(diag::err_cpu_unsupported_isa) << CPU << "ARM";
+   else
+getDriver().Diag(diag::err_arch_unsupported_isa)
+  << tools::arm::getARMArch(MArch

[PATCH] D35825: [clangd] Reuse compile commands during reparse

2017-07-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 108033.
krasimir added a comment.

- Address review comment


https://reviews.llvm.org/D35825

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


Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start
@@ -398,6 +400,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {


Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start
@@ -398,6 +400,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35825: [clangd] Reuse compile commands during reparse

2017-07-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D35825



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


[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-25 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment.

In https://reviews.llvm.org/D34260#819721, @NoQ wrote:

> ...  and add the extra run-line that'd show you the backtrace. We made 
> changes, so the issue might have been wiped out accidentally (or maybe you're 
> actually right!), and if it wasn't, at least we'd have the backtrace for the 
> crash.


Hmm I removed the statistics checks so I guess it should print the stacktrace 
in case of a crash anyway. Am I right? (The whole point of the statistics check 
was to count the number of loops unrolled but  
'clang_analyzer_numTimesReached();' is much more powerful.


https://reviews.llvm.org/D34260



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


[PATCH] D35828: Fix incorrect use of current directory to find moved paths in ASTReader.

2017-07-25 Thread Manuel Klimek via Phabricator via cfe-commits
klimek created this revision.

CurrentDir was set as the path of the current module, but that can change as
part of a chain of loaded modules.

When we try to locate a file mentioned in a module that does not exist, we use
a heuristic to look at the relative path between the original location of the
module and the file we look for, and use that relatively to the CurrentDir.

This only works if CurrentDir is the same as the (current) path of the module
file the file was mentioned in; if it is not, we look at the path relatively to
the wrong directory, and can end up reading random unrelated files that happen
to have the same name.

This patch fixes this by using the BaseDirectory of the module file the file
we look for was mentioned in instead of the CurrentDir heuristic.


https://reviews.llvm.org/D35828

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReader.cpp
  test/Modules/path-resolution.modulemap

Index: test/Modules/path-resolution.modulemap
===
--- /dev/null
+++ test/Modules/path-resolution.modulemap
@@ -0,0 +1,70 @@
+// RUN: rm -rf %t
+//
+// First, create two modules a and b, with a dependency b -> a, both within
+// the same directory p1.
+//
+// RUN: mkdir -p %t/p1
+// RUN: cd %t/p1
+//
+// RUN: grep "" %s > %t/p1/a.modulemap
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="a" -o a.pcm a.modulemap
+//
+// RUN: grep "" %s > %t/p1/b.modulemap
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="b" -o b.pcm b.modulemap
+//
+// Next, move the whole tree p1 -> p2.
+//
+// RUN: cd %t
+// RUN: mv %t/p1 %t/p2
+// RUN: cd %t/p2
+//
+// Compile a new module c in the newly generated tree that depends on b; c.pcm
+// has to be within a subdirectory so a.modulemap will be one step up (../) from
+// c.pcm.
+//
+// RUN: mkdir %t/p2/c
+// RUN: grep "" %s > %t/p2/c/c.modulemap
+// RUN: grep "" %s > %t/p2/c/c.h
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="c" -fmodule-file=b.pcm -o c/c.pcm c/c.modulemap
+//
+// Delete a.modulemap from its original location, and instead inject a different
+// (unrelated) a.modulemap in the path p2/p2.
+//
+// RUN: rm %t/p2/a.modulemap
+// RUN: mkdir -p %t/p2/p2
+// RUN: touch %t/p2/p2/a.modulemap
+//
+// Now compile a file c.cpp that uses c.h and the module c; it is important
+// to first load b.pcm and a.pcm before c.pcm on the command line to trigger
+// the right order of module loading. This used to trigger clang to find the
+// p2/p2/a.modulemap via the path c/../p2/a.modulemap, which is not the correct
+// relative path from c.
+//
+// RUN: grep "" %s > %t/p2/c/c.cpp
+// RUN: %clang_cc1 -I. -x c++ -fmodules \
+// RUN: -fmodule-file=b.pcm -fmodule-file=a.pcm -fmodule-file=c/c.pcm  \
+// RUN: -o c/c.o -emit-obj c/c.cpp
+
+module "a" {// 
+}   // 
+
+module "b" {// 
+  use "a"   // 
+}   // 
+
+module "c" {// 
+  header "c/c.h"// 
+  use "a"   // 
+  use "b"   // 
+}   // 
+
+inline void c() {}  // 
+
+#include "c/c.h"// 
+void foo() { c(); } // 
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2060,14 +2060,12 @@
   StringRef Filename = FI.Filename;
 
   const FileEntry *File = FileMgr.getFile(Filename, /*OpenFile=*/false);
-
   // If we didn't find the file, resolve it relative to the
   // original directory from which this AST file was created.
-  if (File == nullptr && !F.OriginalDir.empty() && !CurrentDir.empty() &&
-  F.OriginalDir != CurrentDir) {
-std::string Resolved = resolveFileRelativeToOriginalDir(Filename,
-F.OriginalDir,
-CurrentDir);
+  if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
+  F.OriginalDir != F.BaseDirectory) {
+std::string Resolved = resolveFileRelativeToOriginalDir(
+Filename, F.OriginalDir, F.BaseDirectory);
 if (!Resolved.empty())
   File = FileMgr.getFile(Resolved);
   }
@@ -4065,13 +4063,6 @@
 
   assert(M && "Missing module file");
 
-  // FIXME: This seems rather a hack. Should CurrentDir be part of the
-  // module?
-  if (FileName != "-") {
-CurrentDir = llvm::sys::path::parent_path(FileName);
-if (CurrentDir.empty()) CurrentDi

[PATCH] D34260: [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yeah, right, good point =)


https://reviews.llvm.org/D34260



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


[PATCH] D35828: Fix incorrect use of current directory to find moved paths in ASTReader.

2017-07-25 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D35828



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


r308962 - Fix incorrect use of current directory to find moved paths in ASTReader.

2017-07-25 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Jul 25 03:22:06 2017
New Revision: 308962

URL: http://llvm.org/viewvc/llvm-project?rev=308962&view=rev
Log:
Fix incorrect use of current directory to find moved paths in ASTReader.

CurrentDir was set as the path of the current module, but that can change as
part of a chain of loaded modules.

When we try to locate a file mentioned in a module that does not exist, we use
a heuristic to look at the relative path between the original location of the
module and the file we look for, and use that relatively to the CurrentDir.

This only works if CurrentDir is the same as the (current) path of the module
file the file was mentioned in; if it is not, we look at the path relatively to
the wrong directory, and can end up reading random unrelated files that happen
to have the same name.

This patch fixes this by using the BaseDirectory of the module file the file
we look for was mentioned in instead of the CurrentDir heuristic.

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

Added:
cfe/trunk/test/Modules/path-resolution.modulemap
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=308962&r1=308961&r2=308962&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Jul 25 03:22:06 2017
@@ -867,9 +867,6 @@ private:
   SmallVector ImportedModules;
   //@}
 
-  /// \brief The directory that the PCH we are reading is stored in.
-  std::string CurrentDir;
-
   /// \brief The system include root to be used when loading the
   /// precompiled header.
   std::string isysroot;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=308962&r1=308961&r2=308962&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Jul 25 03:22:06 2017
@@ -2060,14 +2060,12 @@ InputFile ASTReader::getInputFile(Module
   StringRef Filename = FI.Filename;
 
   const FileEntry *File = FileMgr.getFile(Filename, /*OpenFile=*/false);
-
   // If we didn't find the file, resolve it relative to the
   // original directory from which this AST file was created.
-  if (File == nullptr && !F.OriginalDir.empty() && !CurrentDir.empty() &&
-  F.OriginalDir != CurrentDir) {
-std::string Resolved = resolveFileRelativeToOriginalDir(Filename,
-F.OriginalDir,
-CurrentDir);
+  if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
+  F.OriginalDir != F.BaseDirectory) {
+std::string Resolved = resolveFileRelativeToOriginalDir(
+Filename, F.OriginalDir, F.BaseDirectory);
 if (!Resolved.empty())
   File = FileMgr.getFile(Resolved);
   }
@@ -4065,13 +4063,6 @@ ASTReader::ReadASTCore(StringRef FileNam
 
   assert(M && "Missing module file");
 
-  // FIXME: This seems rather a hack. Should CurrentDir be part of the
-  // module?
-  if (FileName != "-") {
-CurrentDir = llvm::sys::path::parent_path(FileName);
-if (CurrentDir.empty()) CurrentDir = ".";
-  }
-
   ModuleFile &F = *M;
   BitstreamCursor &Stream = F.Stream;
   Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer));

Added: cfe/trunk/test/Modules/path-resolution.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/path-resolution.modulemap?rev=308962&view=auto
==
--- cfe/trunk/test/Modules/path-resolution.modulemap (added)
+++ cfe/trunk/test/Modules/path-resolution.modulemap Tue Jul 25 03:22:06 2017
@@ -0,0 +1,70 @@
+// RUN: rm -rf %t
+//
+// First, create two modules a and b, with a dependency b -> a, both within
+// the same directory p1.
+//
+// RUN: mkdir -p %t/p1
+// RUN: cd %t/p1
+//
+// RUN: grep "" %s > %t/p1/a.modulemap
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd 
\
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="a" -o a.pcm a.modulemap
+//
+// RUN: grep "" %s > %t/p1/b.modulemap
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd 
\
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="b" -o b.pcm b.modulemap
+//
+// Next, move the whole tree p1 -> p2.
+//
+// RUN: cd %t
+// RUN: mv %t/p1 %t/p2
+// RUN: cd %t/p2
+//
+// Compile a new module c in the newly generated tree that depends on b; c.pcm
+// has to be within a subdirectory so a.

[PATCH] D35828: Fix incorrect use of current directory to find moved paths in ASTReader.

2017-07-25 Thread Manuel Klimek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308962: Fix incorrect use of current directory to find moved 
paths in ASTReader. (authored by klimek).

Repository:
  rL LLVM

https://reviews.llvm.org/D35828

Files:
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/Modules/path-resolution.modulemap

Index: cfe/trunk/include/clang/Serialization/ASTReader.h
===
--- cfe/trunk/include/clang/Serialization/ASTReader.h
+++ cfe/trunk/include/clang/Serialization/ASTReader.h
@@ -867,9 +867,6 @@
   SmallVector ImportedModules;
   //@}
 
-  /// \brief The directory that the PCH we are reading is stored in.
-  std::string CurrentDir;
-
   /// \brief The system include root to be used when loading the
   /// precompiled header.
   std::string isysroot;
Index: cfe/trunk/test/Modules/path-resolution.modulemap
===
--- cfe/trunk/test/Modules/path-resolution.modulemap
+++ cfe/trunk/test/Modules/path-resolution.modulemap
@@ -0,0 +1,70 @@
+// RUN: rm -rf %t
+//
+// First, create two modules a and b, with a dependency b -> a, both within
+// the same directory p1.
+//
+// RUN: mkdir -p %t/p1
+// RUN: cd %t/p1
+//
+// RUN: grep "" %s > %t/p1/a.modulemap
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="a" -o a.pcm a.modulemap
+//
+// RUN: grep "" %s > %t/p1/b.modulemap
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="b" -o b.pcm b.modulemap
+//
+// Next, move the whole tree p1 -> p2.
+//
+// RUN: cd %t
+// RUN: mv %t/p1 %t/p2
+// RUN: cd %t/p2
+//
+// Compile a new module c in the newly generated tree that depends on b; c.pcm
+// has to be within a subdirectory so a.modulemap will be one step up (../) from
+// c.pcm.
+//
+// RUN: mkdir %t/p2/c
+// RUN: grep "" %s > %t/p2/c/c.modulemap
+// RUN: grep "" %s > %t/p2/c/c.h
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodules-embed-all-files -fmodules-local-submodule-visibility \
+// RUN:   -fmodule-name="c" -fmodule-file=b.pcm -o c/c.pcm c/c.modulemap
+//
+// Delete a.modulemap from its original location, and instead inject a different
+// (unrelated) a.modulemap in the path p2/p2.
+//
+// RUN: rm %t/p2/a.modulemap
+// RUN: mkdir -p %t/p2/p2
+// RUN: touch %t/p2/p2/a.modulemap
+//
+// Now compile a file c.cpp that uses c.h and the module c; it is important
+// to first load b.pcm and a.pcm before c.pcm on the command line to trigger
+// the right order of module loading. This used to trigger clang to find the
+// p2/p2/a.modulemap via the path c/../p2/a.modulemap, which is not the correct
+// relative path from c.
+//
+// RUN: grep "" %s > %t/p2/c/c.cpp
+// RUN: %clang_cc1 -I. -x c++ -fmodules \
+// RUN: -fmodule-file=b.pcm -fmodule-file=a.pcm -fmodule-file=c/c.pcm  \
+// RUN: -o c/c.o -emit-obj c/c.cpp
+
+module "a" {// 
+}   // 
+
+module "b" {// 
+  use "a"   // 
+}   // 
+
+module "c" {// 
+  header "c/c.h"// 
+  use "a"   // 
+  use "b"   // 
+}   // 
+
+inline void c() {}  // 
+
+#include "c/c.h"// 
+void foo() { c(); } // 
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -2060,14 +2060,12 @@
   StringRef Filename = FI.Filename;
 
   const FileEntry *File = FileMgr.getFile(Filename, /*OpenFile=*/false);
-
   // If we didn't find the file, resolve it relative to the
   // original directory from which this AST file was created.
-  if (File == nullptr && !F.OriginalDir.empty() && !CurrentDir.empty() &&
-  F.OriginalDir != CurrentDir) {
-std::string Resolved = resolveFileRelativeToOriginalDir(Filename,
-F.OriginalDir,
-CurrentDir);
+  if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
+  F.OriginalDir != F.BaseDirectory) {
+std::string Resolved = resolveFileRelativeToOriginalDir(
+Filename, F.OriginalDir, F.BaseDirectory);
 if (!Resolved.empty())
   File = FileMgr.getFile(Resolved);
   }
@@ -4065,13 +4063,6 @@
 
   assert(M && "Missing module file");
 
-  // FIXME: This seems rather a hack. Should CurrentDir be part of the
-  // module?
-  if (FileName != "-") {
-CurrentDir = llvm::sys:

r308965 - This patch enables the usage of constant Enum identifiers within Microsoft style inline assembly statements.

2017-07-25 Thread Matan Haroush via cfe-commits
Author: mharoush
Date: Tue Jul 25 03:43:43 2017
New Revision: 308965

URL: http://llvm.org/viewvc/llvm-project?rev=308965&view=rev
Log:
This patch enables the usage of constant Enum identifiers within Microsoft 
style inline assembly statements.

Differential Revision:
https://reviews.llvm.org/D33277
https://reviews.llvm.org/D33278


Added:
cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=308965&r1=308964&r2=308965&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Jul 25 03:43:43 2017
@@ -645,8 +645,8 @@ ExprResult Sema::LookupInlineAsmIdentifi
   // Referring to parameters is not allowed in naked functions.
   if (CheckNakedParmReference(Result.get(), *this))
 return ExprError();
-
-  QualType T = Result.get()->getType();
+  Expr *Res = Result.get();
+  QualType T = Res->getType();
 
   if (T->isDependentType()) {
 return Result;
@@ -658,16 +658,26 @@ ExprResult Sema::LookupInlineAsmIdentifi
   }
 
   // Otherwise, it needs to be a complete type.
-  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
+  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
 return ExprError();
   }
 
   fillInlineAsmTypeInfo(Context, T, Info);
 
   // We can work with the expression as long as it's not an r-value.
-  if (!Result.get()->isRValue())
-Info.IsVarDecl = true;
+  if (!Res->isRValue()) {
+Info.setKindVariable();
+return Result;
+  }
 
+  Expr::EvalResult EvlResult;
+  // Try to evaluate the identifier as enum constant, currently we do not allow
+  // other constant integers to be folded.
+  if (isa(T) &&
+Res->EvaluateAsRValue(EvlResult, getASTContext())) {
+Info.ConstIntValue = EvlResult.Val.getInt();
+Info.setKindConstEnum();
+  }
   return Result;
 }
 
@@ -774,7 +784,7 @@ Sema::LookupInlineAsmVarDeclField(Expr *
   fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
 
   // Fields are "variables" as far as inline assembly is concerned.
-  Info.IsVarDecl = true;
+  Info.setKindVariable();
 
   return Result;
 }

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=308965&r1=308964&r2=308965&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Jul 25 03:43:43 2017
@@ -42,7 +42,7 @@ void t5(void) {
 void t6(void) {
   __asm int 0x2c
 // CHECK: t6
-// CHECK: call void asm sideeffect inteldialect "int $$0x2c", 
"~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$44", 
"~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t7() {
@@ -61,7 +61,7 @@ void t7() {
 mov eax, ebx
   }
 // CHECK: t7
-// CHECK: call void asm sideeffect inteldialect "int $$0x2cU", 
"~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$44", 
"~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "", 
"~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "mov eax, ebx", 
"~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -94,7 +94,7 @@ void t9() {
 // CHECK: t9
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$0x07
+// CHECK-SAME: mov ebx, $$7
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -265,7 +265,7 @@ void t21() {
 // CHECK: t21
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$07H
+// CHECK-SAME: mov ebx, $$7
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -312,13 +312,13 @@ void t24() {
 void t25() {
 // CHECK: t25
   __asm mov eax, 0h
-// CHECK: mov eax, $$0h
+// CHECK: mov eax, $$4294967295
   __asm mov eax, 0fhU
 // CHECK: mov eax, $$15
   __asm mov eax, 0a2h
-// CHECK: mov eax, $$0a2h
+// CHECK: mov eax, $$162
   __asm mov eax, 10100010b
-// CHECK: mov eax, $$10100010b
+// CHECK: mov eax, $$162
   __asm mov eax, 10100010BU
 // CHECK: mov eax, $$162
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()

Added: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp?rev=308965&view=auto
==
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (added)
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp Tue Jul 25 
03:43:43 2017
@@

[PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Matan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308965: This patch enables the usage of constant Enum 
identifiers within Microsoft… (authored by mharoush).

Changed prior to commit:
  https://reviews.llvm.org/D33277?vs=104390&id=108044#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33277

Files:
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm.c
  cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
  cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp

Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -645,8 +645,8 @@
   // Referring to parameters is not allowed in naked functions.
   if (CheckNakedParmReference(Result.get(), *this))
 return ExprError();
-
-  QualType T = Result.get()->getType();
+  Expr *Res = Result.get();
+  QualType T = Res->getType();
 
   if (T->isDependentType()) {
 return Result;
@@ -658,16 +658,26 @@
   }
 
   // Otherwise, it needs to be a complete type.
-  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
+  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
 return ExprError();
   }
 
   fillInlineAsmTypeInfo(Context, T, Info);
 
   // We can work with the expression as long as it's not an r-value.
-  if (!Result.get()->isRValue())
-Info.IsVarDecl = true;
+  if (!Res->isRValue()) {
+Info.setKindVariable();
+return Result;
+  }
 
+  Expr::EvalResult EvlResult;
+  // Try to evaluate the identifier as enum constant, currently we do not allow
+  // other constant integers to be folded.
+  if (isa(T) &&
+Res->EvaluateAsRValue(EvlResult, getASTContext())) {
+Info.ConstIntValue = EvlResult.Val.getInt();
+Info.setKindConstEnum();
+  }
   return Result;
 }
 
@@ -774,7 +784,7 @@
   fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
 
   // Fields are "variables" as far as inline assembly is concerned.
-  Info.IsVarDecl = true;
+  Info.setKindVariable();
 
   return Result;
 }
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -42,7 +42,7 @@
 void t6(void) {
   __asm int 0x2c
 // CHECK: t6
-// CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$44", "~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t7() {
@@ -61,7 +61,7 @@
 mov eax, ebx
   }
 // CHECK: t7
-// CHECK: call void asm sideeffect inteldialect "int $$0x2cU", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$44", "~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "mov eax, ebx", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -94,7 +94,7 @@
 // CHECK: t9
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$0x07
+// CHECK-SAME: mov ebx, $$7
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -265,7 +265,7 @@
 // CHECK: t21
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$07H
+// CHECK-SAME: mov ebx, $$7
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -312,13 +312,13 @@
 void t25() {
 // CHECK: t25
   __asm mov eax, 0h
-// CHECK: mov eax, $$0h
+// CHECK: mov eax, $$4294967295
   __asm mov eax, 0fhU
 // CHECK: mov eax, $$15
   __asm mov eax, 0a2h
-// CHECK: mov eax, $$0a2h
+// CHECK: mov eax, $$162
   __asm mov eax, 10100010b
-// CHECK: mov eax, $$10100010b
+// CHECK: mov eax, $$162
   __asm mov eax, 10100010BU
 // CHECK: mov eax, $$162
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
Index: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
===
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
@@ -0,0 +1,60 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCHECK %s
+namespace x {
+enum { A = 12 };
+struct y_t {
+	enum { A = 17 };
+	int r;
+} y;
+}
+// CHECK-LABEL: x86_enum_only
+void x86_enum_only(){
+  const int a = 0;
+  // CHECK-NOT: mov eax, [$$0]
+  // Other constant type folding is currently unwanted.
+  __asm mov eax, [a]
+  }
+
+// CHECK-LABEL: x86_enum_namespaces
+void x86_enum_namespaces() {
+  enum { A = 1 };
+  // CHECK: call void asm
+  // CHECK-SAME: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK-SAME: mov eax, $$17
+  __asm mov eax, x::y_t::A
+  // CHECK-NEXT: call void asm
+  // CHECK-SAME: mov eax, $$1
+  __asm {mov eax, A}
+}
+
+/

r308967 - [PM] Setup TargetLibraryInfo correctly for the new pass manager.

2017-07-25 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Jul 25 03:46:07 2017
New Revision: 308967

URL: http://llvm.org/viewvc/llvm-project?rev=308967&view=rev
Log:
[PM] Setup TargetLibraryInfo correctly for the new pass manager.

Without this, -fno-builtin and friends doesn't work. Added the obvious
RUN lines to the test for -fno-builtin and they pass now.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/nobuiltin.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=308967&r1=308966&r2=308967&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Jul 25 03:46:07 2017
@@ -871,6 +871,14 @@ void EmitAssemblyHelper::EmitAssemblyWit
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
 
+  // Register the target library analysis directly and give it a customized
+  // preset TLI.
+  Triple TargetTriple(TheModule->getTargetTriple());
+  std::unique_ptr TLII(
+  createTLII(TargetTriple, CodeGenOpts));
+  FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
+  MAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
+
   // Register all the basic analyses with the managers.
   PB.registerModuleAnalyses(MAM);
   PB.registerCGSCCAnalyses(CGAM);

Modified: cfe/trunk/test/CodeGen/nobuiltin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nobuiltin.c?rev=308967&r1=308966&r2=308967&view=diff
==
--- cfe/trunk/test/CodeGen/nobuiltin.c (original)
+++ cfe/trunk/test/CodeGen/nobuiltin.c Tue Jul 25 03:46:07 2017
@@ -4,6 +4,10 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -S -o - %s | 
FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -S -o - %s 
| FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s
 
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 
-fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=STRCPY 
-check-prefix=MEMSET %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 
-fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=NOSTRCPY 
-check-prefix=NOMEMSET %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 
-fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=STRCPY 
-check-prefix=NOMEMSET %s
+
 void PR13497() {
   char content[2];
   // make sure we don't optimize this call to strcpy()


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


r308969 - Fix spelling of FileCheck in test.

2017-07-25 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Jul 25 04:34:55 2017
New Revision: 308969

URL: http://llvm.org/viewvc/llvm-project?rev=308969&view=rev
Log:
Fix spelling of FileCheck in test.

Modified:
cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp

Modified: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp?rev=308969&r1=308968&r2=308969&view=diff
==
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (original)
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp Tue Jul 25 
04:34:55 2017
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCHECK %s
+// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCheck %s
 namespace x {
 enum { A = 12 };
 struct y_t {


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


[clang-tools-extra] r308970 - [clangd] Reuse compile commands during reparse

2017-07-25 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Jul 25 04:37:43 2017
New Revision: 308970

URL: http://llvm.org/viewvc/llvm-project?rev=308970&view=rev
Log:
[clangd] Reuse compile commands during reparse

Summary:
Previously we always queried the compilation database and discarded the results
if the file was already opened.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=308970&r1=308969&r2=308970&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Jul 25 04:37:43 2017
@@ -245,6 +245,8 @@ void ClangdUnit::reparse(StringRef Conte
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start
@@ -398,6 +400,8 @@ ClangdUnit::codeComplete(StringRef Conte
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {

Modified: clang-tools-extra/trunk/clangd/ClangdUnitStore.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnitStore.h?rev=308970&r1=308969&r2=308970&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnitStore.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnitStore.h Tue Jul 25 04:37:43 2017
@@ -79,13 +79,12 @@ private:
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,


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


[PATCH] D35825: [clangd] Reuse compile commands during reparse

2017-07-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308970: [clangd] Reuse compile commands during reparse 
(authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D35825

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnitStore.h


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start
@@ -398,6 +400,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {
Index: clang-tools-extra/trunk/clangd/ClangdUnitStore.h
===
--- clang-tools-extra/trunk/clangd/ClangdUnitStore.h
+++ clang-tools-extra/trunk/clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   {
 // FIXME(ibiryukov): store diagnostics from CommandLine when we start
@@ -398,6 +400,8 @@
   for (const auto &S : Command.CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {
Index: clang-tools-extra/trunk/clangd/ClangdUnitStore.h
===
--- clang-tools-extra/trunk/clangd/ClangdUnitStore.h
+++ clang-tools-extra/trunk/clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
  IntrusiveRefCntPtr VFS, Func Action) {
 std::lock_guard Lock(Mutex);
 
-auto Commands = getCompileCommands(CDB, File);
-assert(!Commands.empty() &&
-   "getCompileCommands should add default command");
-VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
 auto It = OpenedFiles.find(File);
 if (It == OpenedFiles.end()) {
+  auto Commands = getCompileCommands(CDB, File);
+  assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
   It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-07-25 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.

FWIW, I went ahead and implemented this functionality in GCC. It has been 
merged into its c++-modules branch.


https://reviews.llvm.org/D35020



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


[PATCH] D35557: clang-format: merge short case labels with trailing comments

2017-07-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good! Thanks!


https://reviews.llvm.org/D35557



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


[PATCH] D35796: [analyzer] Misused polymorphic object checker

2017-07-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

How does this check differ from the `-Wdelete-non-virtual-dtor` warning class 
that comes out of the frontend?


https://reviews.llvm.org/D35796



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


[PATCH] D35796: [analyzer] Misused polymorphic object checker

2017-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

It seems that this check is more powerful because it works by knowing the 
dynamic type of the object. However, i still suspect that `-Wnon-virtual-dtor` 
(the other one, without `delete-`, that simply asks to make the destructor of 
polymorphic classes virtual) covers most practical cases. The only thing i see 
not covered by `-Wnon-virtual-dtor` but covered by this checker is the 
situation when the destructor is private. Reka, would you confirm our 
understanding?


https://reviews.llvm.org/D35796



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


[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D32210#819577, @ahatanak wrote:

> In https://reviews.llvm.org/D32210#810508, @rjmccall wrote:
>
> > Hmm.  Unfortunately, I'm not sure that's valid.  The retains and releases 
> > of block captures don't protect against anything related to escaping the 
> > block; they protect against the original variables being modified during 
> > the lifetime of the block.  It is true that a block literal passed to a 
> > noescape parameter has a shorter effective lifetime — we know for certain 
> > that it will be unused after the call, and ARC only promises that a value 
> > in an imprecise-lifetime strong variable like a block capture will be valid 
> > until the last load of that value from the variable.  But that duration is 
> > still long enough for someone to modify the original variable in a way that 
> > is properly sequenced after the formation of the block.
> >
> > Now, if you could prove that the variable was not modified for the duration 
> > of the call, that would be sufficient.  And that would be easy to do in the 
> > common case by just proving that the address of the variable never escapes. 
> >  Unfortunately, we don't have that information readily available because 
> > Sema doesn't collect it.
>
>
> OK, so I guess the optimization isn't valid in the following case, for 
> example:
>
>   void foo3(id);
>  
>   id __strong *gp;
>  
>   void foo2(id a) {
> gp = &a;
> nonescapingFunc(^{ foo3(a); }); // this function can modify "a" before 
> the block is executed.
>   }
>


Right.

>> There are some other ways you could optimize blocks that are known not to 
>> escape, though.  One big caveat is that you have to make sure the block 
>> behaves reasonably in response to being copied, becase being noescape 
>> doesn't guarantee that the callee won't try to copy the block.  However:
> 
> I didn't understand the following optimizations. I thought clang doesn't emit 
> copy and destroy helper for global blocks with or without noescape?

They're not really about global blocks, they're about whether we can emit a 
non-escaping block using the isa that we use for global blocks, which causes 
copies to be no-ops (because real global blocks do not have local captures).

John.




Comment at: include/clang/AST/Type.h:3156
 };
 unsigned char Data;
 

ahatanak wrote:
> rjmccall wrote:
> > Oh!  I hadn't noticed that you were adding this to ExtParameterInfo.  
> > You're modifying the function type system; there's a lot of complexity to 
> > do that properly which you haven't done in this patch at all.  That's 
> > especially true because, unlike all these other ExtParameterInfo cases, 
> > there's a natural subtyping rule for escaping parameters: a function type 
> > that takes a non-escaping parameter should be implicitly convertible to be 
> > a function type that takes an escaping parameter.  You will also need to 
> > update a bunch of things, including the type printer, the mangler, the C++ 
> > function conversion rules, the C type compatibility rules, the 
> > redeclaration type matcher, and maybe even template argument deduction.  
> > It's a big thing to do.
> > 
> > You will want Sema tests in C, ObjC, C++, and ObjC++.
> Rather than adding an enum to ExtParameterInfo and modifying the type system, 
> I made changes in IRGen to find out whether a function parameter is annotated 
> with noescape. I'm not sure when it is OK or not OK to change the type system 
> when adding support for an attribute, but this seemed to be the right 
> direction since most of the other attributes are handled this way.
So, I do think it's acceptable to change the type system here; it's just that 
doing so definitely makes the change more complicated.

The guidance here is:
  - If it changes the basic rules for making a call, it really *must* be 
preserved as part of the function type, or else basic things like taking the 
address of the function will never work correctly.  That's why everything 
currently in ExtParameterInfo is there — ns_consumed affects the balancing 
rules for how ARC makes calls, the Swift parameter-ABI treatments are part of 
the CC, etc.
  - Otherwise, it really comes down to how much we care about the feature 
working with indirection.  I feel like blocks are probably the strongest 
motivator here because they're always invoked indirectly: if you want the 
feature to work on a block parameter, it really needs to be part of the 
function type, because we do not want to get into the business of finding 
non-canonical sources of information for function types, e.g. param decls from 
the TypeSourceInfo.

Overall, I would say that it tends to be the case that we eventually find 
attribute-based analyses limiting.  If we start doing serious optimizations 
based on noescape, it is probably something that ought to go in the type system.



Comment at: lib/CodeGen/CGCall.cpp:2096
+if (FI.getE

[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via Phabricator via cfe-commits
kfunk updated this revision to Diff 108061.
kfunk added a comment.

Addressed concerns


https://reviews.llvm.org/D35194

Files:
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  test/clang-apply-replacements/invalid-files.cpp


Index: test/clang-apply-replacements/invalid-files.cpp
===
--- /dev/null
+++ test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/invalid-files
+// RUN: clang-apply-replacements %T/invalid-files
+//
+// Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
+// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
Index: test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===
--- /dev/null
+++ test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+...
Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement &R : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@
 for (const tooling::Replacement &R : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 }


Index: test/clang-apply-replacements/invalid-files.cpp
===
--- /dev/null
+++ test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/invalid-files
+// RUN: clang-apply-replacements %T/invalid-files
+//
+// Check that the yaml files are *not* deleted after running clang-apply-replacements without remove-change-desc-files.
+// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
Index: test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===
--- /dev/null
+++ test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+...
Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement &R : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-

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

2017-07-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33672#819683, @xazax.hun wrote:

> Aaron, could you comment on the applicability of this check to C? Thanks in 
> advance.


C has different rules for their enumerations in that the enumerators are all 
ints, but the enumeration type is either `char`, a signed integer type, or an 
unsigned integer type depending on the values of the enumerators. So this 
problem exists:

  enum E {
one = 1
  };
  
  void f(int i) {
enum E e = (enum E)i;
  }
  
  int main(void) {
f(1024);
  }

If `enum E` is represented by a `char`, then the cast causes a loss of 
precision. However, this isn't undefined behavior in C like it is in C++.




Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:29
+namespace {
+// This evaluator checks 2 SVals for equality. The first SVal is provided via
+// the constructor, the second is the parameter of the overloaded () operator.

s/2/two



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:34
+class ConstraintBasedEQEvaluator {
+private:
+  const DefinedOrUnknownSVal CompareValue;

No need for the access specifier; it defaults to `private`.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:47
+DefinedOrUnknownSVal EnumDeclValue = SVB.makeIntVal(EnumDeclInitValue);
+const auto ElemEqualsValueToCast =
+SVB.evalEQ(PS, EnumDeclValue, CompareValue);

Please do not use `auto` here as the type is not spelled out in the 
initialization. Also, you can drop the `const` qualifier if it's not a pointer 
or reference type.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:74-75
+  EnumValueVector DeclValues;
+  for (const auto *D : ED->decls()) {
+const auto ECD = dyn_cast(D);
+DeclValues.push_back(ECD->getInitVal());

Instead of enumerating over `decls()` and then casting, just enumerate over 
`enumerators()` and  the cast isn't needed. Or, even better:
```
EnumValueVector DeclValues(ED->enumerator_end() - ED->enumerator_begin());
std::transform(ED->enumerator_begin(), ED->enumerator_end(), DeclValues.begin(),
   [](const EnumConstantDecl *D) { return D->getInitVal(); 
});
```



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:84
+void EnumCastOutOfRangeChecker::reportWarning(CheckerContext &C) const {
+  if (auto N = C.generateNonFatalErrorNode(C.getState())) {
+if (!EnumValueCastOutOfRange)

NoQ wrote:
> `C.getState()` is the default value (if you see how 
> `generateNonFatalErrorNode()` calls `addTransition()` which in turns 
> substitutes nullptr with `getState()`), so it can be omitted.
Don't use `auto` here.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:87-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."));

Also, diagnostics should not be full sentences or grammatically correct, so 
drop the capitalization and full stop.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:116
+  // function to handle this.
+  const EnumDecl *ED = T->getAs()->getDecl();
+

You can use `castAs<>()` because you've already determined it's an enumeral 
type.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:121
+  bool PossibleValueMatch =
+  std::any_of(DeclValues.begin(), DeclValues.end(),
+  ConstraintBasedEQEvaluator(C, *ValueToCastOptional));

You can use `llvm::any_of()` and pass in the container.


https://reviews.llvm.org/D33672



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


[PATCH] D35624: Removal of microMIPS64R6

2017-07-25 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a reviewer: cfe-commits.
sdardis added a comment.

Also, this need to be posted to cfe-commits.


Repository:
  rL LLVM

https://reviews.llvm.org/D35624



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


[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 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. Do you need someone to commit the patch for you?


https://reviews.llvm.org/D35194



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


[PATCH] D35624: Removal of microMIPS64R6

2017-07-25 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji marked 2 inline comments as done.
abeserminji added a comment.

Comments resolved


Repository:
  rL LLVM

https://reviews.llvm.org/D35624



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


[PATCH] D35624: Removal of microMIPS64R6

2017-07-25 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 108067.
abeserminji added a comment.

Comments resolved and patch adapted to current revision.


Repository:
  rL LLVM

https://reviews.llvm.org/D35624

Files:
  Basic/Targets/Mips.cpp
  clang/Basic/DiagnosticCommonKinds.td


Index: Basic/Targets/Mips.cpp
===
--- Basic/Targets/Mips.cpp
+++ Basic/Targets/Mips.cpp
@@ -203,6 +203,12 @@
 }
 
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
+  if ((getTriple().getArch() == llvm::Triple::mips64 ||
+   getTriple().getArch() == llvm::Triple::mips64el) &&
+   IsMicromips && (ABI == "n32" || ABI == "n64")) {
+Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
+return false;
+  }
   // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
   //this yet. It's better to fail here than on the backend assertion.
   if (processorSupportsGPR64() && ABI == "o32") {
Index: clang/Basic/DiagnosticCommonKinds.td
===
--- clang/Basic/DiagnosticCommonKinds.td
+++ clang/Basic/DiagnosticCommonKinds.td
@@ -185,6 +185,8 @@
 def err_target_unknown_triple : Error<
   "unknown target triple '%0', please use -triple or -arch">;
 def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
+def err_target_unsupported_cpu_for_micromips : Error<
+  "micromips is not supported for target CPU '%0'">;
 def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
 def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU 
'%1'">;
 def err_target_unsupported_abi_for_triple : Error<


Index: Basic/Targets/Mips.cpp
===
--- Basic/Targets/Mips.cpp
+++ Basic/Targets/Mips.cpp
@@ -203,6 +203,12 @@
 }
 
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
+  if ((getTriple().getArch() == llvm::Triple::mips64 ||
+   getTriple().getArch() == llvm::Triple::mips64el) &&
+   IsMicromips && (ABI == "n32" || ABI == "n64")) {
+Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
+return false;
+  }
   // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
   //this yet. It's better to fail here than on the backend assertion.
   if (processorSupportsGPR64() && ABI == "o32") {
Index: clang/Basic/DiagnosticCommonKinds.td
===
--- clang/Basic/DiagnosticCommonKinds.td
+++ clang/Basic/DiagnosticCommonKinds.td
@@ -185,6 +185,8 @@
 def err_target_unknown_triple : Error<
   "unknown target triple '%0', please use -triple or -arch">;
 def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
+def err_target_unsupported_cpu_for_micromips : Error<
+  "micromips is not supported for target CPU '%0'">;
 def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
 def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU '%1'">;
 def err_target_unsupported_abi_for_triple : Error<
___
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-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 16 inline comments as done.
yaxunl added inline comments.



Comment at: include/clang/Basic/Builtins.def:713
+ATOMIC_BUILTIN(__opencl_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__opencl_atomic_fetch_xor, "v.", "t")
+

Anastasia wrote:
> What about min/max? I believe they will need to have the scope too. 
They are not 2.0 atomic builtin functions. They can be implemented as library 
functions through 2.0 atomic builtin functions.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6956
+  "synchronization scope argument to atomic operation is invalid">;
+def err_atomic_op_has_non_constant_synch_scope : Error<
+  "non-constant synchronization scope argument to atomic operation is not 
supported">;

Anastasia wrote:
> Btw, is this disallowed by the spec? Can't find anything relevant.
Just temporarily not supported by Clang. Will add support later.



Comment at: lib/CodeGen/CGAtomic.cpp:678
 RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
+  bool IsOpenCL = E->isOpenCL();
   QualType AtomicTy = E->getPtr()->getType()->getPointeeType();

Anastasia wrote:
> Seems short enough to introduce an extra variable here. :)
removed the variable



Comment at: lib/CodeGen/CGAtomic.cpp:707
 
-  switch (E->getOp()) {
+  auto Op = E->getOp();
+  switch (Op) {

Anastasia wrote:
> The same here... not sure adding an extra variable is helping here. :)
removed the variable



Comment at: lib/CodeGen/CGAtomic.cpp:889
+return V;
+  auto OrigLangAS = E->getType()
+.getTypePtr()

Anastasia wrote:
> Formatting seems to be a bit odd here...
this is done by clang-format



Comment at: lib/CodeGen/CGAtomic.cpp:1117
+  "Non-constant synchronization scope not supported");
+  auto sco = (llvm::SynchronizationScope)(
+  cast(Scope)->getZExtValue());

Anastasia wrote:
> Anastasia wrote:
> > Variable name doesn't follow the style.
> could we avoid using C style cast?
will fix



Comment at: lib/CodeGen/CGAtomic.cpp:1117
+  "Non-constant synchronization scope not supported");
+  auto sco = (llvm::SynchronizationScope)(
+  cast(Scope)->getZExtValue());

yaxunl wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > Variable name doesn't follow the style.
> > could we avoid using C style cast?
> will fix
will change to static_cast



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

Anastasia wrote:
> formatting seems odd.
this is done by clang-format



Comment at: test/CodeGenOpenCL/atomic-ops-libcall.cl:1
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple spir64 
-emit-llvm | FileCheck -check-prefix=GEN4 %s
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple 
armv5e-none-linux-gnueabi -emit-llvm | FileCheck -check-prefix=GEN0 %s

Anastasia wrote:
> GEN4 -> SPIR
will change



Comment at: test/CodeGenOpenCL/atomic-ops-libcall.cl:2
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple spir64 
-emit-llvm | FileCheck -check-prefix=GEN4 %s
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple 
armv5e-none-linux-gnueabi -emit-llvm | FileCheck -check-prefix=GEN0 %s
+

Anastasia wrote:
> GEN0 -> AMDGPU
Actually this triple is armv5e. This test requires a target not supporting 
atomic instructions. Will change GEN0 -> ARM



Comment at: test/CodeGenOpenCL/atomic-ops-libcall.cl:4
+
+void f(atomic_int *i, int cmp) {
+  int x;

Anastasia wrote:
> Could we use different scopes?
Yes. will add them.



Comment at: test/CodeGenOpenCL/atomic-ops.cl:7
+
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED

Anastasia wrote:
> why do we need this?
This is to test the builtin works in pch. When generating pch, ALREADY_INCLUDED 
is undefined, therefore pch will include all functions. When including pch, 
since ALREADY_INCLUDED is defined through pch, the cl file is empty and 
function definitions from pch is used for codegen.



Comment at: test/CodeGenOpenCL/atomic-ops.cl:15
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} 
singlethread seq_cst
+  int x = __opencl_atomic_load(i, memory_order_seq_cst, 
memory_scope_work_item);
+}

Anastasia wrote:
> I think we could use different scope types all over...
will add them.



Comment at: test/CodeGenOpenCL/atomic-ops.cl:32
+  // CHECK-LABEL: @fi4(
+  // CHECK: [[PAIR:%[.0-9A-Z_a-z]+]] = cmpxchg i32 addrspace(4)* 
[[PTR:%[.0-9A-Z_a-z]+]], i32 [[EXPECTED:%[.0-9A-Z_a-z]+]], i32 
[[DESIRED:%[.0-9A-Z_a-z]+]] singlethread acquire acqu

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

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 108073.
yaxunl marked 16 inline comments as done.
yaxunl edited the summary of this revision.
yaxunl added a reviewer: kzhuravl.
yaxunl added a comment.
Herald added a subscriber: nhaehnle.

Rebased to ToT and revised by Anastasia'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
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,151 @@
+// 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_item);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_item); // 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_item);
+  __opencl_atomic_store(i_l, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_p, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_c, 0, memory_order_relaxed, memory_scope_work_item); // 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_item);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_item); // 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_item);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_item); // 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_item);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_item); // 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_item);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka 

[clang-tools-extra] r308974 - [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Jul 25 07:28:16 2017
New Revision: 308974

URL: http://llvm.org/viewvc/llvm-project?rev=308974&view=rev
Log:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Summary:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Fix crash when running clang-apply-replacements on YML files which
contain an invalid file path. Make sure we never add a nullptr into the
map. The previous code started adding nullptr to the map after the first
warnings via errs() has been emitted.

Backtrace:
```
Starting program:
/home/kfunk/devel/build/llvm/bin/clang-apply-replacements /tmp/tmpIqtp7m
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/x86_64-linux-gnu/libthread_db.so.1".
Described file 
'.moc/../../../../../../src/qt5.8/qtremoteobjects/src/remoteobjects/qremoteobjectregistrysource_p.h'
 doesn't exist. Ignoring...
...

Program received signal SIGSEGV, Segmentation fault.
main (argc=, argv=) at 
/home/kfunk/devel/src/llvm/tools/clang/tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:262
(gdb) p FileAndReplacements.first
$1 = (const clang::FileEntry *) 0x0
(gdb)
```

Added tests.

Before patch:

```
 TEST 'Clang Tools :: 
clang-apply-replacements/invalid-files.cpp' FAILED 
Script:
--
mkdir -p 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
clang-apply-replacements 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
ls -1 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
 | FileCheck 
/home/kfunk/devel/src/llvm/tools/clang/tools/extra/test/clang-apply-replacements/invalid-files.cpp
 --check-prefix=YAML
--
Exit Code: 139

Command Output (stderr):
--
Described file 'idonotexist.h' doesn't exist. Ignoring...
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/invalid-files.cpp.script:
 line 4:  9919 Segmentation fault  clang-apply-replacements 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-   
replacements/Output/Inputs/invalid-files

--
```

After Patch:

```
PASS: Clang Tools :: clang-apply-replacements/invalid-files.cpp (5 of 6)
```

Reviewers: alexfh, yawanng

Reviewed By: alexfh

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

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
Modified:

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=308974&r1=308973&r2=308974&view=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 Tue Jul 25 07:28:16 2017
@@ -288,13 +288,12 @@ bool mergeAndDeduplicate(const TUReplace
 for (const tooling::Replacement &R : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@ bool mergeAndDeduplicate(const TUDiagnos
 for (const tooling::Replacement &R : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(

[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308974: [clang-tidy] clang-apply-replacements: Don't insert 
null entry (authored by kfunk).

Repository:
  rL LLVM

https://reviews.llvm.org/D35194

Files:
  
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp


Index: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement &R : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@
 for (const tooling::Replacement &R : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 }
Index: clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
===
--- clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
+++ clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/invalid-files
+// RUN: clang-apply-replacements %T/invalid-files
+//
+// Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
+// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
Index: 
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===
--- 
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
+++ 
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+...


Index: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement &R : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R

[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via Phabricator via cfe-commits
kfunk added a comment.

Seems to have worked:

  Committing to https://llvm.org/svn/llvm-project/clang-tools-extra/trunk ...
  A   
test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  A   test/clang-apply-replacements/invalid-files.cpp
  M   clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  Committed r308974

I presume this Diff is being auto-closed by Phab?

Anyhow: Thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D35194



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


[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-25 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 108078.
arphaman added a comment.

Simplified the implementation of `LexicallyOrderedRecursiveASTVisitor` and 
removed redundant DenseMap checks.
Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D35012

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/SourceLocation.h
  include/clang/Basic/SourceManager.h
  include/clang/Tooling/Refactoring/ASTSelection.h
  lib/Tooling/Refactoring/ASTSelection.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/ASTSelectionTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -0,0 +1,141 @@
+//===- unittest/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+class DummyMatchVisitor;
+
+class LexicallyOrderedDeclVisitor
+: public LexicallyOrderedRecursiveASTVisitor {
+public:
+  LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher,
+  const SourceManager &SM)
+  : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {}
+
+  bool TraverseDecl(Decl *D) {
+TraversalStack.push_back(D);
+LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
+TraversalStack.pop_back();
+return true;
+  }
+
+  bool VisitNamedDecl(const NamedDecl *D);
+
+private:
+  DummyMatchVisitor &Matcher;
+  llvm::SmallVector TraversalStack;
+};
+
+class DummyMatchVisitor : public ExpectedLocationVisitor {
+public:
+  bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
+const ASTContext &Context = TU->getASTContext();
+const SourceManager &SM = Context.getSourceManager();
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM);
+SubVisitor.TraverseDecl(TU);
+return false;
+  }
+
+  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+};
+
+bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
+  std::string Path;
+  llvm::raw_string_ostream OS(Path);
+  assert(TraversalStack.back() == D);
+  for (const Decl *D : TraversalStack) {
+if (isa(D)) {
+  OS << "/";
+  continue;
+}
+if (const auto *ND = dyn_cast(D))
+  OS << ND->getNameAsString();
+else
+  OS << "???";
+if (isa(D))
+  OS << "/";
+  }
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+@implementation I
+
+int nestedFunction() { }
+
+- (void) method{ }
+
+int anotherNestedFunction(int x) {
+  return x;
+}
+
+int innerVariable = 0;
+
+@end
+
+int outerVariable = 0;
+
+@implementation I(Cat)
+
+void catF() { }
+
+@end
+
+void outerFunction() { }
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.DisallowMatch("/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/method/", 8, 1);
+  Visitor.DisallowMatch("/anotherNestedFunction/", 10, 1);
+  Visitor.ExpectMatch("/I/anotherNestedFunction/", 10, 1);
+  Visitor.DisallowMatch("/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/I/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/outerVariable", 18, 1);
+  Visitor.DisallowMatch("/catF/", 22, 1);
+  Visitor.ExpectMatch("/Cat/catF/", 22, 1);
+  Visitor.ExpectMatch("/outerFunction/", 26, 1);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitMacroDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+
+void outerFunction() { }
+
+#define MACRO_F(x) void nestedFunction##x() { }
+
+@implementation I
+
+MACRO_F(1)
+
+@end
+
+MACRO_F(2)
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.ExpectMatch("/outerFunction/", 5, 1);
+  Visitor.ExpectMatch("/I/nestedFunction1/", 7, 20);
+  Visitor.ExpectMatch("/nestedFunction2/", 7, 20);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -11,11 +11,13 @@
 endif()
 
 add_clang_unittest(ToolingTests
+  ASTSelectionTest.cpp
   CastExprTest.cpp
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
   DiagnosticsYamlTest.cpp
   FixItTest.cpp
+  LexicallyOrderedRecursiveA

[clang-tools-extra] r308975 - [clang-tidy] Fixup clang-apply-replacements/invalid-files test

2017-07-25 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Jul 25 07:39:08 2017
New Revision: 308975

URL: http://llvm.org/viewvc/llvm-project?rev=308975&view=rev
Log:
[clang-tidy] Fixup clang-apply-replacements/invalid-files test

Modified:
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp

Modified: 
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp?rev=308975&r1=308974&r2=308975&view=diff
==
--- clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp Tue 
Jul 25 07:39:08 2017
@@ -1,5 +1,6 @@
 // RUN: mkdir -p %T/invalid-files
+// RUN: cp %S/Inputs/invalid-files/invalid-files.yaml 
%T/invalid-files/invalid-files.yaml
 // RUN: clang-apply-replacements %T/invalid-files
 //
 // Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
-// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
+// RUN: ls %T/invalid-files/invalid-files.yaml


___
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-07-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: include/clang/Basic/Builtins.def:713
+ATOMIC_BUILTIN(__opencl_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__opencl_atomic_fetch_xor, "v.", "t")
+

yaxunl wrote:
> Anastasia wrote:
> > What about min/max? I believe they will need to have the scope too. 
> They are not 2.0 atomic builtin functions. They can be implemented as library 
> functions through 2.0 atomic builtin functions.
Yes, they are.  Please look again at 6.13.11.7.5 in the 2.0 C spec.


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] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: include/clang/Basic/Builtins.def:713
+ATOMIC_BUILTIN(__opencl_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__opencl_atomic_fetch_xor, "v.", "t")
+

b-sumner wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > What about min/max? I believe they will need to have the scope too. 
> > They are not 2.0 atomic builtin functions. They can be implemented as 
> > library functions through 2.0 atomic builtin functions.
> Yes, they are.  Please look again at 6.13.11.7.5 in the 2.0 C spec.
sorry I thought they are just some atomic extensions since C++11 atomic 
builtins do not have those. I will add them.


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] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-25 Thread Peter Smith via Phabricator via cfe-commits
peter.smith updated this revision to Diff 108092.
peter.smith added a comment.
Herald added a subscriber: javed.absar.

I've added a clang test that will check that none of the floating point helper 
functions defined in the Runtime ABI for the ARM Architecture are directly 
called by clang. Given that the calling convention decisions for these helpers 
are made in llvm I think the best place for a test that the correct calling 
convention is in llvm. I'll start working on that and post in a separate 
review. Please let me know if I'm not on the right lines.


https://reviews.llvm.org/D35538

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arm-float-helpers.c
  test/CodeGen/complex-math.c

Index: test/CodeGen/complex-math.c
===
--- test/CodeGen/complex-math.c
+++ test/CodeGen/complex-math.c
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM
+// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 
 float _Complex add_float_rr(float a, float b) {
@@ -476,8 +477,15 @@
 
 // Check that the libcall will obtain proper calling convention on ARM
 _Complex double foo(_Complex double a, _Complex double b) {
+  // These functions are not defined as floating point helper functions in
+  // Run-time ABI for the ARM architecture document so they must not always
+  // use the base AAPCS
+
   // ARM-LABEL: @foo(
-  // ARM: call arm_aapcscc { double, double } @__muldc3
+  // ARM: call void { double, double } @__muldc3
+
+  // ARMHF-LABEL: @foo(
+  // ARMHF: call { double, double } @__muldc3
 
   // ARM7K-LABEL: @foo(
   // ARM7K: call { double, double } @__muldc3
Index: test/CodeGen/arm-float-helpers.c
===
--- /dev/null
+++ test/CodeGen/arm-float-helpers.c
@@ -0,0 +1,195 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s
+
+// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The
+// floating-point helper functions to always use the base AAPCS (soft-float)
+// calling convention.
+//
+// These helper functions such as __aeabi_fadd are not explicitly called by
+// clang, instead they are generated by the ARMISelLowering when they are
+// needed; clang relies on llvm to use the base AAPCS.
+//
+// In this test we check that clang is not directly calling the __aeabi_
+// functions. We rely on llvm to test that the base AAPCS is used for any
+// __aeabi_ function from 4.1.2 that is used.
+//
+// When compiled to an object file with -mfloat-abi=soft each function F
+// below should result in a call to __aeabi_F. If clang is changed to call any
+// of these functions directly the test will need to be altered to check that
+// arm_aapcscc is used.
+//
+// Note that it is only the functions in 4.1.2 that must use the base AAPCS,
+// other runtime functions such as the _Complex helper routines are not covered
+
+float fadd(float a, float b) { return a + b; }
+// CHECK: @fadd
+// CHECK-NOT: __aeabi_fadd
+
+float fdiv(float a, float b) { return a / b; }
+// CHECK: @fdiv
+// CHECK-NOT: __aeabi_fdiv
+
+float fmul(float a, float b) { return a * b; }
+// CHECK: @fmul
+// CHECK-NOT: __aeabi_fmul
+
+float fsub(float a, float b) { return a - 

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

2017-07-25 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic added a comment.

Hi Bruno,

Yes, GCC has similar option (-mtp=soft/hard), but name is not same. I put the 
same option name as in backend (https://reviews.llvm.org/D34408).


https://reviews.llvm.org/D34878



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


r308979 - [OPENMP] Codegen for 'task_reduction' clause.

2017-07-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 25 08:53:26 2017
New Revision: 308979

URL: http://llvm.org/viewvc/llvm-project?rev=308979&view=rev
Log:
[OPENMP] Codegen for 'task_reduction' clause.

Added codegen for taskgroup directive with task_reduction clause.
```

```
The next code is emitted:
```
%struct.kmp_task_red_input_t red_init[n];
void *td;
call void @__kmpc_taskgroup(%ident_t id, i32 gtid)
...
red_init[i].shar = &;
red_init[i].size = sizeof();
red_init[i].init = (void*)initializer_function;
red_init[i].fini = (void*)destructor_function;
red_init[i].comb = (void*)combiner_function;
red_init[i].flags = flags;
...
td = call i8* @__kmpc_task_reduction_init(i32 gtid, i32 n, i8*
(void*)red_init);
call void @__kmpc_end_taskgroup(%ident_t id, i32 gtid)

void initializer_function(i8* priv) {
  *(*)priv = ;
  ret void;
}

void destructor_function(i8* priv) {
  (*)priv->~();
  ret void;
}

void combiner_function(i8* inout, i8* in) {
  *(*)inout = *(*)inout  *(*)in;
  ret void;
}
```

Added:
cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=308979&r1=308978&r2=308979&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Jul 25 08:53:26 2017
@@ -1912,7 +1912,7 @@ class OMPTaskgroupDirective : public OMP
   OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc,
 unsigned NumClauses)
   : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, 
OMPD_taskgroup,
-   StartLoc, EndLoc, NumClauses, 1) {}
+   StartLoc, EndLoc, NumClauses, 2) {}
 
   /// Build an empty directive.
   /// \param NumClauses Number of clauses.
@@ -1920,7 +1920,12 @@ class OMPTaskgroupDirective : public OMP
   explicit OMPTaskgroupDirective(unsigned NumClauses)
   : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, 
OMPD_taskgroup,
SourceLocation(), SourceLocation(), NumClauses,
-   1) {}
+   2) {}
+
+  /// Sets the task_reduction return variable.
+  void setReductionRef(Expr *RR) {
+*std::next(child_begin(), 1) = RR;
+  }
 
 public:
   /// Creates directive.
@@ -1930,10 +1935,12 @@ public:
   /// \param EndLoc Ending Location of the directive.
   /// \param Clauses List of clauses.
   /// \param AssociatedStmt Statement, associated with the directive.
+  /// \param ReductionRef Reference to the task_reduction return variable.
   ///
   static OMPTaskgroupDirective *
   Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
- ArrayRef Clauses, Stmt *AssociatedStmt);
+ ArrayRef Clauses, Stmt *AssociatedStmt,
+ Expr *ReductionRef);
 
   /// Creates an empty directive.
   ///
@@ -1943,6 +1950,15 @@ public:
   static OMPTaskgroupDirective *CreateEmpty(const ASTContext &C,
 unsigned NumClauses, EmptyShell);
 
+
+  /// Returns reference to the task_reduction return variable.
+  const Expr *getReductionRef() const {
+return static_cast(*std::next(child_begin(), 1));
+  }
+  Expr *getReductionRef() {
+return static_cast(*std::next(child_begin(), 1));
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OMPTaskgroupDirectiveClass;
   }

Modified: cfe/trunk/lib/AST/StmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtOpenMP.cpp?rev=308979&r1=308978&r2=308979&view=diff
==
--- cfe/trunk/lib/AST/StmtOpenMP.cpp (original)
+++ cfe/trunk/lib/AST/StmtOpenMP.cpp Tue Jul 25 08:53:26 2017
@@ -524,14 +524,15 @@ OMPTaskwaitDirective *OMPTaskwaitDirecti
 
 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
-ArrayRef Clauses, Stmt *AssociatedStmt) {
+ArrayRef Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
   unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
 sizeof(OMPClause *) * Clauses.size(),
 alignof(Stmt *));
-  void *Mem = C.Allocate(Size + sizeof(Stmt *));
+  void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
   OMPTaskgroupDirective *Dir =
   new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc, Clauses.size());
   Dir->setAssociatedStm

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

2017-07-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D33900#819237, @dim wrote:

> Also note that it is only added to the `--version` output, not the `-v` 
> output (the former is really a "verbose" version of the latter):


Which seems to be the opposite of what gcc does (`gcc -v` is more verbose than 
`gcc --version`.)

  $ gcc --version
  gcc (GCC) 4.9.0 20140318 (experimental)
  Copyright (C) 2014 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



  $ gcc -v
  Using built-in specs.
  COLLECT_GCC=gcc
  
COLLECT_LTO_WRAPPER=/usr/local/google/work/gcc482prefix/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: ../configure --prefix=/work/gcc482prefix 
--enable-languages=c,c++ --enable-checking=release
  Thread model: posix
  gcc version 4.9.0 20140318 (experimental) (GCC)



In https://reviews.llvm.org/D33900#818968, @mehdi_amini wrote:

> I think @thakis is right: this too verbose to be the default --version.
>  We likely shouldn't ship this in clang-5.0 (@hans).


Let me know if you figure out a solution here and I'll merge it.


https://reviews.llvm.org/D33900



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I will commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D35613



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Sorry for the delay! This looks good to me.

We have a really embarrassing FIXMELATER from 2012 (!!!) that disabled the 
plist tests for diagnostics. This means we're not getting testing for the 
diagnostic text itself. Let's not block this patch on fixing that, though.


Repository:
  rL LLVM

https://reviews.llvm.org/D35613



___
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-07-25 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

If there's a precedence for a flag name there, it's nice to be compatible here. 
You don't necessarily need to use the same name as the backend.


https://reviews.llvm.org/D34878



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


[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-07-25 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

In https://reviews.llvm.org/D34030#819699, @MontyKutyi wrote:

> As I can see the `clang/test` contains a lot of different simple tests, but 
> for testing this I think it is not enough to run the clang with some 
> arguments on a specific input.  So I should create a new executable which 
> uses the postorder mode of the RecursiveASTVisitor.  Am I right or is there 
> another preferred way for doing this?


The place you're looking for here is in unittests. For example, see 
unittests/AST/PostOrderASTVisitor.cpp.


https://reviews.llvm.org/D34030



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


[PATCH] D33676: Place implictly declared functions at block scope

2017-07-25 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

Ping.


https://reviews.llvm.org/D33676



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


r308985 - This test case is causing all PPC and SystemZ bots to remain red.

2017-07-25 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Tue Jul 25 10:04:12 2017
New Revision: 308985

URL: http://llvm.org/viewvc/llvm-project?rev=308985&view=rev
Log:
This test case is causing all PPC and SystemZ bots to remain red.

Notifying the author via Diffusion did not yield any answer. Therefore, I'm
adding the missing triple. I have no idea if this is the intended triple, but
it seems to fit the bill and should turn the bots back to green.
If the intended triple is a different one, please feel free to change it but I
need make this change to turn the bots back to green now.

Modified:
cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp

Modified: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp?rev=308985&r1=308984&r2=308985&view=diff
==
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (original)
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp Tue Jul 25 
10:04:12 2017
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fasm-blocks -emit-llvm -o - | 
FileCheck %s
 namespace x {
 enum { A = 12 };
 struct y_t {


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


[PATCH] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread David Majnemer via Phabricator via cfe-commits
majnemer updated this revision to Diff 108105.
majnemer added a comment.

- Address review feedback.


https://reviews.llvm.org/D35824

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  test/CodeGenCXX/std-byte.cpp


Index: test/CodeGenCXX/std-byte.cpp
===
--- /dev/null
+++ test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm 
-O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  // PATH: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  // PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -85,6 +85,12 @@
 return TypeHasMayAlias(TTy->desugar());
   }
 
+  // C++1z [intro.object]p3: If a complete object is created in storage
+  // associated with another object e of type [...] "array of N std::byte", 
that
+  // array provides storage for the created object [...].
+  if (QTy->isStdByteType())
+return true;
+
   return false;
 }
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+  return true;
+  }
+  return false;
+}
+
 bool Type::isPromotableIntegerType() const {
   if (const BuiltinType *BT = getAs())
 switch (BT->getKind()) {
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1752,6 +1752,7 @@
   bool isTemplateTypeParmType() const;  // C++ template type parameter
   bool isNullPtrType() const;   // C++11 std::nullptr_t
   bool isAlignValT() const; // C++17 std::align_val_t
+  bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \


Index: test/CodeGenCXX/std-byte.cpp
===
--- /dev/null
+++ test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  // PATH: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  // PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -85,6 +85,12 @@
 return TypeHasMayAlias(TTy->desugar());
   }
 
+  // C++1z [intro.object]p3: If a complete object is created in storage
+  // associated with another object e of type [...] "array of N std::byte", that
+  // array provides storage for the created object [...].
+  if (QTy->isStdByteType())
+return true;
+
   return false;
 }
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+ 

[PATCH] D35674: [analyzer] Treat C++ throw as sink during CFG-based suppress-on-sink.

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Do we have a radar for this? It sounds familiar.




Comment at: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp:3313
 
+static bool isNoReturnBlock(const CFGBlock *Blk) {
+  if (Blk->hasNoReturnElement())

Maybe a better name for this would be "treatAsSink"? This way people won't use 
it as short-hand for whether the block has a no-return element.


Repository:
  rL LLVM

https://reviews.llvm.org/D35674



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


Re: r308897 - Work around an MSVC2017 update 3 codegen bug.

2017-07-25 Thread Hans Wennborg via cfe-commits
r308988. Thanks!

On Mon, Jul 24, 2017 at 9:55 AM, Nico Weber  wrote:
> We probably want this in 5.0.
>
> On Mon, Jul 24, 2017 at 12:54 PM, Nico Weber via cfe-commits
>  wrote:
>>
>> Author: nico
>> Date: Mon Jul 24 09:54:11 2017
>> New Revision: 308897
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=308897&view=rev
>> Log:
>> Work around an MSVC2017 update 3 codegen bug.
>>
>> C2017 update 3 produces a clang that crashes when compiling clang.
>> Disabling
>> optimizations for StmtProfiler::VisitCXXOperatorCallExpr() makes the crash
>> go
>> away.
>>
>> Patch from Bruce Dawson !
>> https://reviews.llvm.org/D35757
>>
>> Modified:
>> cfe/trunk/lib/AST/StmtProfile.cpp
>>
>> Modified: cfe/trunk/lib/AST/StmtProfile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=308897&r1=308896&r2=308897&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/StmtProfile.cpp (original)
>> +++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Jul 24 09:54:11 2017
>> @@ -1412,6 +1412,15 @@ static Stmt::StmtClass DecodeOperatorCal
>>llvm_unreachable("Invalid overloaded operator expression");
>>  }
>>
>> +#if defined(_MSC_VER)
>> +#if _MSC_VER == 1911
>> +// Work around
>> https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
>> +// MSVC 2017 update 3 miscompiles this function, and a clang built with
>> it
>> +// will crash in stage 2 of a bootstrap build.
>> +#pragma optimize("", off)
>> +#endif
>> +#endif
>> +
>>  void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S)
>> {
>>if (S->isTypeDependent()) {
>>  // Type-dependent operator calls are profiled like their underlying
>> @@ -1444,6 +1453,12 @@ void StmtProfiler::VisitCXXOperatorCallE
>>ID.AddInteger(S->getOperator());
>>  }
>>
>> +#if defined(_MSC_VER)
>> +#if _MSC_VER == 1911
>> +#pragma optimize("", on)
>> +#endif
>> +#endif
>> +
>>  void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
>>VisitCallExpr(S);
>>  }
>>
>>
>> ___
>> 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] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: test/CodeGenCXX/std-byte.cpp:7
+enum byte : unsigned char {};
+}
+

Would it be worth adding an explicit test that `::byte`, `::my::byte`, 
`::my::std::byte` are or are not handled in the same way?


https://reviews.llvm.org/D35824



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


r308990 - [analyzer] Add diagnostic text for generalized refcount annotations.

2017-07-25 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Jul 25 10:17:09 2017
New Revision: 308990

URL: http://llvm.org/viewvc/llvm-project?rev=308990&view=rev
Log:
[analyzer] Add diagnostic text for generalized refcount annotations.

Add a 'Generalized' object kind to the retain-count checker and suitable
generic diagnostic text for retain-count diagnostics involving those objects.

For now the object kind is introduced in summaries by 'annotate' attributes.
Once we have more experience with these annotations we will propose explicit
attributes.

Patch by Malhar Thakkar!

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release-inline.m
cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h?rev=308990&r1=308989&r2=308990&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h Tue Jul 
25 10:17:09 2017
@@ -145,9 +145,11 @@ public:
 /// Indicates that the tracked object is an Objective-C object.
 ObjC,
 /// Indicates that the tracked object could be a CF or Objective-C object.
-AnyObj
+AnyObj,
+/// Indicates that the tracked object is a generalized object.
+Generalized
   };
-  
+
 private:
   Kind K;
   ObjKind O;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=308990&r1=308989&r2=308990&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Jul 25 
10:17:09 2017
@@ -1340,6 +1340,8 @@ RetainSummaryManager::getRetEffectFromAn
 
   if (D->hasAttr())
 return RetEffect::MakeOwned(RetEffect::CF);
+  else if (hasRCAnnotation(D, "rc_ownership_returns_retained"))
+return RetEffect::MakeOwned(RetEffect::Generalized);
 
   if (D->hasAttr())
 return RetEffect::MakeNotOwned(RetEffect::CF);
@@ -1363,9 +1365,11 @@ RetainSummaryManager::updateSummaryFromA
 const ParmVarDecl *pd = *pi;
 if (pd->hasAttr())
   Template->addArg(AF, parm_idx, DecRefMsg);
-else if (pd->hasAttr())
+else if (pd->hasAttr() ||
+ hasRCAnnotation(pd, "rc_ownership_consumed"))
   Template->addArg(AF, parm_idx, DecRef);
-else if (pd->hasAttr()) {
+else if (pd->hasAttr() ||
+ hasRCAnnotation(pd, "rc_ownership_returns_retained")) {
   QualType PointeeTy = pd->getType()->getPointeeType();
   if (!PointeeTy.isNull())
 if (coreFoundation::isCFObjectRef(PointeeTy))
@@ -1999,17 +2003,15 @@ CFRefReportVisitor::VisitNode(const Expl
   }
 
   if (CurrV.getObjKind() == RetEffect::CF) {
-if (Sym->getType().isNull()) {
-  os << " returns a Core Foundation object with a ";
-} else {
-  os << " returns a Core Foundation object of type "
- << Sym->getType().getAsString() << " with a ";
-}
-  }
-  else {
+os << " returns a Core Foundation object of type "
+   << Sym->getType().getAsString() << " with a ";
+  } else if (CurrV.getObjKind() == RetEffect::Generalized) {
+os << " returns an object of type " << Sym->getType().getAsString()
+   << " with a ";
+  } else {
 assert (CurrV.getObjKind() == RetEffect::ObjC);
 QualType T = Sym->getType();
-if (T.isNull() || !isa(T)) {
+if (!isa(T)) {
   os << " returns an Objective-C object with a ";
 } else {
   const ObjCObjectPointerType *PT = cast(T);

Modified: cfe/trunk/test/Analysis/retain-release-inline.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-inline.m?rev=308990&r1=308989&r2=308990&view=diff
==
--- cfe/trunk/test/Analysis/retain-release-inline.m (original)
+++ cfe/trunk/test/Analysis/retain-release-inline.m Tue Jul 25 10:17:09 2017
@@ -299,7 +299,7 @@ void test_neg() {
   bar(s);
 }
 
-__attribute__((cf_returns_retained)) isl_basic_map 
*isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map 
*isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) 
isl_basic_map *bmap);
 void free(void *);
 
 // As 'isl_basic_map_free' is annotated with 
'rc_ownership_trusted_implementation', RetainCountChecker trusts its
@@ -307,7 +307,7 @@

[PATCH] D35383: [coroutines] Add serialization/deserialization of coroutines

2017-07-25 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov updated this revision to Diff 108111.
GorNishanov added a comment.

Thank you for the review. Feedback implemented. Preparing to land


https://reviews.llvm.org/D35383

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/PCH/coroutines.cpp

Index: test/PCH/coroutines.cpp
===
--- /dev/null
+++ test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+suspend_always yield_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template 
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template 
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -286,7 +286,7 @@
   }
 
   // Outputs
-  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {  
+  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
 Record.AddStmt(S->getOutputExpr(I));
 Record.AddString(S->getOutputConstraint(I));
   }
@@ -300,29 +300,48 @@
   Code = serialization::STMT_MSASM;
 }
 
-void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
+  VisitStmt(CoroStmt);
+  Record.push_back(CoroStmt->getParamMoves().size());
+  for (Stmt *S : CoroStmt->children())
+Record.AddStmt(S);
+  Code = serialization::STMT_COROUTINE_BODY;
 }
 
 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  Record.AddSourceLocation(S->getKeywordLoc());
+  Record.AddStmt(S->getOperand());
+  Record.AddStmt(S->getPromiseCall());
+  Record.push_back(S->isImplicit());
+  Code = serialization::STMT_CORETURN;
 }
 
-void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) {
+  VisitExpr(E);
+  Record.AddSourceLocation(E->getKeywordLoc());
+  for (Stmt *S : E->children())
+Record.AddStmt(S);
+  Record.AddStmt(E->getOpaqueValue());
 }
 
-void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
+  VisitCoroutineSuspendExpr(E);
+  Record.push_back(E->isImplicit());
+  Code = serialization::EXPR_COAWAIT;
+}
+
+void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
+  VisitCoroutineSuspendExpr(E);
+  Code = serialization::EXPR_COYIELD;
 }
 
-void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
+  VisitExpr(E);
+  

[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308990: [analyzer] Add diagnostic text for generalized 
refcount annotations. (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D35613?vs=107471&id=108115#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35613

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/test/Analysis/retain-release-inline.m
  cfe/trunk/test/Analysis/retain-release.m

Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
@@ -145,9 +145,11 @@
 /// Indicates that the tracked object is an Objective-C object.
 ObjC,
 /// Indicates that the tracked object could be a CF or Objective-C object.
-AnyObj
+AnyObj,
+/// Indicates that the tracked object is a generalized object.
+Generalized
   };
-  
+
 private:
   Kind K;
   ObjKind O;
Index: cfe/trunk/test/Analysis/retain-release-inline.m
===
--- cfe/trunk/test/Analysis/retain-release-inline.m
+++ cfe/trunk/test/Analysis/retain-release-inline.m
@@ -299,15 +299,15 @@
   bar(s);
 }
 
-__attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
 void free(void *);
 
 // As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
 // implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
 // a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
 // count of 'bmap' along the path in 'isl_basic_map_free' assuming the predicate of the second 'if' branch to be
 // true or assuming both the predicates in the function to be false.
-__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   if (!bmap)
 return NULL;
 
@@ -322,15 +322,15 @@
 // implementation and doesn't analyze its body. If that annotation is removed, a 'use-after-release' warning might
 // be raised by RetainCountChecker as the pointer which is passed as an argument to this function and the pointer
 // which is returned from the function point to the same memory location.
-__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
+__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
   if (!bmap)
 return NULL;
 
   bmap->ref++;
   return bmap;
 }
 
-void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   // After this call, 'bmap' has a +1 reference count.
   bmap = isl_basic_map_cow(bmap);
   // After the call to 'isl_basic_map_copy', 'bmap' has a +1 reference count.
@@ -341,7 +341,7 @@
   isl_basic_map_free(temp);
 }
 
-void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   // After this call, 'bmap' has a +1 reference count.
   bmap = isl_basic_map_cow(bmap); // no-warning
   // After this call, 'bmap' has a +0 reference count.
Index: cfe/trunk/test/Analysis/retain-release.m
===
--- cfe/trunk/test/Analysis/retain-release.m
+++ cfe/trunk/test/Analysis/retain-release.m
@@ -325,6 +325,9 @@
 
 extern
 void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
+typedef struct {
+  int ref;
+} isl_basic_map;
 
 //===--===//
 // Test cases.
@@ -574,6 +577,14 @@
   }
 }
 
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
+
+// T

[PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

This seems reasonable to me.




Comment at: lib/Driver/ToolChain.cpp:660
+  assert(!Args.hasArg(options::OPT_nostdlibxx) &&
+ "should not have called this");
   CXXStdlibType Type = GetCXXStdlibType(Args);

The message here doesn't really add any info. I think asserting without a 
message in this case is fine.


https://reviews.llvm.org/D35780



___
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-07-25 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann created this revision.
euhlmann added a project: clang.

Change 272124* introduced a regression in spaceRequiredBetween for left aligned 
pointers to decltype and typeof expressions. This fix adds logic to fix this. 
The test added is based on a related test in determineStarAmpUsage. Also add 
test cases for the regression.

- http://llvm.org/viewvc/llvm-project?view=revision&revision=272124

LLVM bug tracker: https://bugs.llvm.org/show_bug.cgi?id=30407


https://reviews.llvm.org/D35847

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5351,6 +5351,9 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5397,9 +5400,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2202,7 +2202,10 @@
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
   if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
+return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl &&
+!(Left.MatchingParen && Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->isOneOf(tok::kw_typeof,
+tok::kw_decltype))) ||
(Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5351,6 +5351,9 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5397,9 +5400,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2202,7 +2202,10 @@
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
   if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
+return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl &&
+!(Left.MatchingParen && Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->isOneOf(tok::kw_typeof,
+tok::kw_decltype))) ||
(Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
___
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-07-25 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Seems like SyncScope.h file is missing?


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] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Hi. 
This patch causes the msan bots to complain. Please fix or revert ASAP. 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
Testing: 0 .. 10..
FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)

- TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 

Script:
---

/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/clang
 -cc1 -internal-isystem 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/6.0.0/include
 -nostdsysteminc -triple x86_64-pc-win32 -fasm-blocks -emit-llvm 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
 -o - | 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
--

Exit Code: 2

Command Output (stderr):


4713==WARNING: MemorySanitizer: use-of-uninitialized-value
--

  #0 0x3143ba3 in (anonymous 
namespace)::X86AsmParser::ParseIntelIdentifier(llvm::MCExpr const*&, 
llvm::StringRef&, llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
  #1 0x313f288 in (anonymous 
namespace)::X86AsmParser::ParseIntelExpression((anonymous 
namespace)::X86AsmParser::IntelExprStateMachine&, llvm::SMLoc&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
  #2 0x31389e7 in (anonymous 
namespace)::X86AsmParser::ParseIntelBracExpression(unsigned int, llvm::SMLoc, 
long, bool, unsigned int) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
  #3 0x31307f8 in ParseIntelOperand 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1961:12
  #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand() 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
  #5 0x3118cda in (anonymous 
namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&, 
llvm::StringRef, llvm::SMLoc, 
llvm::SmallVectorImpl > >&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
  #6 0x4bb9a48 in (anonymous namespace)::AsmParser::parseStatement((anonymous 
namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/AsmParser.cpp:2034:42
  #7 0x4ba63a3 in (anonymous namespace)::AsmParser::parseMSInlineAsm(void*, 
std::__1::basic_string, 
std::__1::allocator >&, unsigned int&, unsigned int&, 
llvm::SmallVectorImpl >&, 
llvm::SmallVectorImpl, 
std::__1::allocator > >&, 
llvm::SmallVectorImpl, 
std::__1::allocator > >&, llvm::MCInstrInfo const*, llvm::MCInstPrinter 
const*, llvm::MCAsmParserSemaCallback&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/AsmParser.cpp:5343:25
  #8 0x82f1100 in 
clang::Parser::ParseMicrosoftAsmStatement(clang::SourceLocation) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmtAsm.cpp:619:15
  #9 0x82f6310 in clang::Parser::ParseAsmStatement(bool&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmtAsm.cpp:682:12
  #10 0x82d15d9 in 
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, 
clang::Parser::ParsedAttributesWithRange&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:277:11
  #11 0x82cfff1 in 
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:110:20
  #12 0x82e677b in clang::Parser::ParseCompoundStatementBody(bool) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1001:11
  #13 0x82e

r308996 - [coroutines] Add serialization/deserialization of coroutines

2017-07-25 Thread Gor Nishanov via cfe-commits
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

Modified: cfe/trunk/include/clang/AST/StmtCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=308996&r1=308995&r2=308996&view=diff
==
--- cfe/trunk/include/clang/AST/StmtCXX.h (original)
+++ cfe/trunk/include/clang/AST/StmtCXX.h Tue Jul 25 11:01:49 2017
@@ -317,6 +317,7 @@ class CoroutineBodyStmt final
   unsigned NumParams;
 
   friend class ASTStmtReader;
+  friend class ASTReader;
   friend TrailingObjects;
 
   Stmt **getStoredStmts() { return getTrailingObjects(); }
@@ -347,6 +348,8 @@ private:
 
 public:
   static CoroutineBodyStmt *Create(const ASTContext &C, CtorArgs const &Args);
+  static CoroutineBodyStmt *Create(const ASTContext &C, EmptyShell,
+   unsigned NumParams);
 
   bool hasDependentPromiseType() const {
 return getPromiseDecl()->getType()->isDependentType();
@@ -444,6 +447,8 @@ public:
 SubStmts[SubStmt::PromiseCall] = PromiseCall;
   }
 
+  CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {}
+
   SourceLocation getKeywordLoc() const { return CoreturnLoc; }
 
   /// \brief Retrieve the operand of the 'co_return' statement. Will be nullptr

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=308996&r1=308995&r2=308996&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Tue Jul 25 11:01:49 2017
@@ -1545,9 +1545,14 @@ namespace clang {
 
   // ARC
   EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
-  
+
   STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-  EXPR_LAMBDA // LambdaExpr
+  EXPR_LAMBDA,// LambdaExpr
+  STMT_COROUTINE_BODY,
+  STMT_CORETURN,
+  EXPR_COAWAIT,
+  EXPR_COYIELD,
+  EXPR_DEPENDENT_COAWAIT,
 };
 
 /// \brief The kinds of designators that can occur in a

Modified: cfe/trunk/lib/AST/StmtCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtCXX.cpp?rev=308996&r1=308995&r2=308996&view=diff
==
--- cfe/trunk/lib/AST/StmtCXX.cpp (original)
+++ cfe/trunk/lib/AST/StmtCXX.cpp Tue Jul 25 11:01:49 2017
@@ -96,6 +96,20 @@ CoroutineBodyStmt *CoroutineBodyStmt::Cr
   return new (Mem) CoroutineBodyStmt(Args);
 }
 
+CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext &C, EmptyShell,
+ unsigned NumParams) {
+  std::size_t Size = totalSizeToAlloc(
+  CoroutineBodyStmt::FirstParamMove + NumParams);
+
+  void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt));
+  auto *Result = new (Mem) CoroutineBodyStmt(CtorArgs());
+  Result->NumParams = NumParams;
+  auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove;
+  std::uninitialized_fill(ParamBegin, ParamBegin + NumParams,
+  static_cast(nullptr));
+  return Result;
+}
+
 CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args)
 : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) {
   Stmt **SubStmts = getStoredStmts();

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=308996&r1=308995&r2=308996&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Tue Jul 25 11:01:49 2017
@@ -367,28 +367,45 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsm
 }
 
 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  assert(Record.peekInt() == S->NumParams);
+  Record.skipInts(1);
+  auto *StoredStmts = S->getStoredStmts();
+  for (unsigned i = 0;
+   i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
+StoredStmts[i] = Record.readSubStmt();
 }
 
 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine seriali

r308997 - Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Jul 25 11:02:57 2017
New Revision: 308997

URL: http://llvm.org/viewvc/llvm-project?rev=308997&view=rev
Log:
Introduce -nostdlib++ flag to disable linking the C++ standard library.

Projects that want to statically link their own C++ standard library currently
need to pass -nostdlib or -nodefaultlibs, which also disables linking of the
builtins library, -lm, and so on. Alternatively, they could use `clang` instead
of `clang++`, but that already disables implicit addition of -lm on some
toolchains.

Add a dedicated flag -nostdlib++ that disables just linking of libc++ /
libstdc++. This is analogous to -nostdinc++.

https://reviews.llvm.org/D35780

Added:
cfe/trunk/test/Driver/nostdlibxx.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Ananas.cpp
cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp
cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/DragonFly.cpp
cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/lib/Driver/ToolChains/Minix.cpp
cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=308997&r1=308996&r2=308997&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jul 25 11:02:57 2017
@@ -2144,6 +2144,7 @@ def nostdlibinc : Flag<["-"], "nostdlibi
 def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>,
   HelpText<"Disable standard #include directories for the C++ standard 
library">;
 def nostdlib : Flag<["-"], "nostdlib">;
+def nostdlibxx : Flag<["-"], "nostdlib++">;
 def object : Flag<["-"], "object">;
 def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, 
CC1Option, CC1AsOption]>,
   HelpText<"Write output to ">, MetaVarName<"">;

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=308997&r1=308996&r2=308997&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Jul 25 11:02:57 2017
@@ -432,6 +432,10 @@ public:
   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
 
+  /// Returns if the C++ standard library should be linked in.
+  /// Note that e.g. -lm should still be linked even if this returns false.
+  bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const;
+
   /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
   /// for the given C++ standard library type.
   virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=308997&r1=308996&r2=308997&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Jul 25 11:02:57 2017
@@ -648,8 +648,16 @@ void ToolChain::AddClangCXXStdlibInclude
   DriverArgs.AddAllArgs(CC1Args, options::OPT_stdlib_EQ);
 }
 
+bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const {
+  return getDriver().CCCIsCXX() &&
+ !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+  options::OPT_nostdlibxx);
+}
+
 void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
 ArgStringList &CmdArgs) const {
+  assert(!Args.hasArg(options::OPT_nostdlibxx) &&
+ "should not have called this");
   CXXStdlibType Type = GetCXXStdlibType(Args);
 
   switch (Type) {

Modified: cfe/trunk/lib/Driver/ToolChains/Ananas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Ananas.cpp?rev=308997&r1=308996&r2=308997&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Ananas.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Ananas.cpp T

[PATCH] D35383: [coroutines] Add serialization/deserialization of coroutines

2017-07-25 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
GorNishanov marked an inline comment as done.
Closed by commit rL308996: [coroutines] Add serialization/deserialization of 
coroutines (authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D35383?vs=108111&id=108121#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35383

Files:
  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/trunk/test/PCH/coroutines.cpp

Index: cfe/trunk/include/clang/AST/StmtCXX.h
===
--- cfe/trunk/include/clang/AST/StmtCXX.h
+++ cfe/trunk/include/clang/AST/StmtCXX.h
@@ -317,6 +317,7 @@
   unsigned NumParams;
 
   friend class ASTStmtReader;
+  friend class ASTReader;
   friend TrailingObjects;
 
   Stmt **getStoredStmts() { return getTrailingObjects(); }
@@ -347,6 +348,8 @@
 
 public:
   static CoroutineBodyStmt *Create(const ASTContext &C, CtorArgs const &Args);
+  static CoroutineBodyStmt *Create(const ASTContext &C, EmptyShell,
+   unsigned NumParams);
 
   bool hasDependentPromiseType() const {
 return getPromiseDecl()->getType()->isDependentType();
@@ -444,6 +447,8 @@
 SubStmts[SubStmt::PromiseCall] = PromiseCall;
   }
 
+  CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {}
+
   SourceLocation getKeywordLoc() const { return CoreturnLoc; }
 
   /// \brief Retrieve the operand of the 'co_return' statement. Will be nullptr
Index: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
===
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h
@@ -1545,9 +1545,14 @@
 
   // ARC
   EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
-  
+
   STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-  EXPR_LAMBDA // LambdaExpr
+  EXPR_LAMBDA,// LambdaExpr
+  STMT_COROUTINE_BODY,
+  STMT_CORETURN,
+  EXPR_COAWAIT,
+  EXPR_COYIELD,
+  EXPR_DEPENDENT_COAWAIT,
 };
 
 /// \brief The kinds of designators that can occur in a
Index: cfe/trunk/test/PCH/coroutines.cpp
===
--- cfe/trunk/test/PCH/coroutines.cpp
+++ cfe/trunk/test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+suspend_always yield_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template 
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template 
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
Index: cfe/trunk/lib/AST/StmtCXX.cpp
===
--- cfe/trunk/lib/AST/StmtCXX.cpp
+++ cfe/trunk/lib/AST/StmtCXX.cpp
@@ -96,6 +96,20 @@
   return new (Mem) CoroutineBodyStmt(Args);
 }
 
+CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext &C, EmptyShell,
+ unsigned NumParams) {

[PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r308997, thanks!


https://reviews.llvm.org/D35780



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


Re: [PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Nico Weber via cfe-commits
The test also fails on many other bots on http://lab.llvm.org:8011/console
, a short excerpt:

http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/9702/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/5197/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp

On Tue, Jul 25, 2017 at 1:52 PM, Kostya Serebryany via Phabricator via
cfe-commits  wrote:

> kcc added a comment.
>
> Hi.
> This patch causes the msan bots to complain. Please fix or revert ASAP.
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
> Testing: 0 .. 10..
> FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)
>
> - TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 
>
> Script:
> ---
>
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm_build_msan/./bin/clang -cc1 -internal-isystem
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm_build_msan/lib/clang/6.0.0/include -nostdsysteminc -triple
> x86_64-pc-win32 -fasm-blocks -emit-llvm /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
> -o - | /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm_build_msan/./bin/FileCheck /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/
> CodeGen/ms_this.cpp
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
>
> Exit Code: 2
>
> Command Output (stderr):
> 
>
> 4713==WARNING: MemorySanitizer: use-of-uninitialized-value
> --
>
>   #0 0x3143ba3 in (anonymous namespace)::X86AsmParser::
> ParseIntelIdentifier(llvm::MCExpr const*&, llvm::StringRef&,
> llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
>   #1 0x313f288 in (anonymous namespace)::X86AsmParser::
> ParseIntelExpression((anonymous 
> namespace)::X86AsmParser::IntelExprStateMachine&,
> llvm::SMLoc&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
>   #2 0x31389e7 in (anonymous namespace)::X86AsmParser::
> ParseIntelBracExpression(unsigned int, llvm::SMLoc, long, bool, unsigned
> int) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
>   #3 0x31307f8 in ParseIntelOperand /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/
> AsmParser/X86AsmParser.cpp:1961:12
>   #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand()
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
>   #5 0x3118cda in (anonymous namespace)::X86AsmParser::
> ParseInstruction(llvm::ParseInstructionInfo&, llvm::StringRef,
> llvm::SMLoc, 
> llvm::SmallVectorImpl std::__1::default_delete > >&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
>   #6 0x4bb9a48 in (anonymous namespace)::AsmParser::parseStatement((anonymous
> namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/MC/MCParser/AsmParser.cpp:2034:42
>   #7 0x4ba63a3 in (anonymous namespace)::AsmParser::parseMSInlineAsm(void*,
> std::__1::basic_string,
> std::__1::allocator >&, unsigned int&, unsigned int&,
> llvm::SmallVectorImpl >&,
> llvm::SmallVectorImpl std::__1::char_traits, std::__1::allocator > >&,
> llvm::SmallVectorImpl std::__1::char_traits, std::__1::allocator > >&,
> llvm::MCInstrInfo const*, llvm::MCInstPrinter const*,
> llvm::MCAsmParserSemaCallback&) /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/
> AsmParser.cpp:5343:25
>   #8 0x82f1100 in 
> clang::Parser::ParseMicrosoftAsmStatement(clang::SourceLocation)
> /mnt/b/sa

[PATCH] D35849: [UBSan] Provide default blacklist filename for UBSan

2017-07-25 Thread Han Shen via Phabricator via cfe-commits
shenhan created this revision.

This is to provide a default blacklist filename for UBSan.

While UBSan is turned on, it's better that clang pick up a blacklist file (when 
exists), just as what ASan / MSan does, so we do not end up adding the 
"-fsanitize-blacklist" option to every command line.


https://reviews.llvm.org/D35849

Files:
  lib/Driver/SanitizerArgs.cpp


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,8 @@
 BlacklistFile = "dfsan_abilist.txt";
   else if (Kinds & CFI)
 BlacklistFile = "cfi_blacklist.txt";
+  else if (Kinds & Undefined)
+BlacklistFile = "ubsan_blacklist.txt";
 
   if (BlacklistFile) {
 clang::SmallString<64> Path(D.ResourceDir);


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,8 @@
 BlacklistFile = "dfsan_abilist.txt";
   else if (Kinds & CFI)
 BlacklistFile = "cfi_blacklist.txt";
+  else if (Kinds & Undefined)
+BlacklistFile = "ubsan_blacklist.txt";
 
   if (BlacklistFile) {
 clang::SmallString<64> Path(D.ResourceDir);
___
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-07-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

Can we drop the "opencl" part of the name and use something like 
__scoped_atomic_*?   Also, it may not make sense to support non-constant scope 
here since we can't predict what other scopes may be added by other languages 
in the future.


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] D35849: [UBSan] Provide default blacklist filename for UBSan

2017-07-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a reviewer: vsk.
vsk added a comment.

This won't do the right thing if more than one sanitizer with a default 
blacklist is enabled. It's also problematic that a default blacklist for one 
sanitizer can blacklist code for a different sanitizer. See:

https://reviews.llvm.org/D32043
https://reviews.llvm.org/D32047
https://reviews.llvm.org/D32842

IMO I think https://reviews.llvm.org/D32842 is the right path forward. I don't 
have the time to get back to it this week, but if you'd like to pick it up and 
respond to review feedback from @eugenis, please do (I can certainly help with 
the review).


https://reviews.llvm.org/D35849



___
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-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

In https://reviews.llvm.org/D28691#820375, @kzhuravl wrote:

> Seems like SyncScope.h file is missing?


Right. I will add it.


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] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 108127.
yaxunl added a comment.

Add min/max and missing file.


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/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,156 @@
+// 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_item);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_item); // 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_item);
+  __opencl_atomic_store(i_l, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_p, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_c, 0, memory_order_relaxed, memory_scope_work_item); // 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_item);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_item); // 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_item);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_item); // 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_item);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_item); // 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_item);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetc

[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-25 Thread Lang Hames via Phabricator via cfe-commits
lhames accepted this revision.
lhames added a comment.
This revision is now accepted and ready to land.

Otherwise this looks good to me.




Comment at: examples/clang-interpreter/CMakeLists.txt:73
+set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS ${editedFlags})
+#message("COMPILE_FLAGS: '${addedFlags}' '${editedFlags}'")
+

These debugging messages (this and the one below) should probably be stripped.



Comment at: examples/clang-interpreter/Invoke.h:10
+
+#pragma once
+

I believe you should use include guards in LLVM headers. Pragma once should 
work, but I don't think it's standard (and it doesn't seem to be used anywhere 
else in the codebase).



Comment at: examples/clang-interpreter/Manager.h:10
+
+#pragma once
+

Ditto here.


https://reviews.llvm.org/D35103



___
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-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D28691#820466, @b-sumner wrote:

> Can we drop the "opencl" part of the name and use something like 
> __scoped_atomic_*?   Also, it may not make sense to support non-constant 
> scope here since we can't predict what other scopes may be added by other 
> languages in the future.


we could use the approach of LangAS, i.e. we allow targets to map all language 
specific scopes to target-specific scope names, since IR only cares about scope 
names, which are target specific. And this is what the current implementation 
does.

I have no objection to use the __scoped_atomic_ name. It is more general and 
extensible. John/Anastasia, any comments? Thanks.


https://reviews.llvm.org/D28691



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


Re: [PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Joerg Sonnenberger via cfe-commits
On Sun, Jul 23, 2017 at 07:06:25PM -0400, Nico Weber via cfe-commits wrote:
> If you need this behavior for something, that sounds like something a
> -nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
> stdlib and nothing else.

But the -lm is only there because -lc++ alone (or -lstdc++ for that
matter) wouldn't really work.

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


Re: [PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Nico Weber via cfe-commits
On Tue, Jul 25, 2017 at 2:53 PM, Joerg Sonnenberger  wrote:

> On Sun, Jul 23, 2017 at 07:06:25PM -0400, Nico Weber via cfe-commits wrote:
> > If you need this behavior for something, that sounds like something a
> > -nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
> > stdlib and nothing else.
>
> But the -lm is only there because -lc++ alone (or -lstdc++ for that
> matter) wouldn't really work.
>

Do you have a reference for that? Several toolchains link in -lm in C mode
even.


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


r309004 - Revert "This patch enables the usage of constant Enum identifiers within Microsoft style inline assembly statements." as it is causing msan failures.

2017-07-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Jul 25 12:17:32 2017
New Revision: 309004

URL: http://llvm.org/viewvc/llvm-project?rev=309004&view=rev
Log:
Revert "This patch enables the usage of constant Enum identifiers within 
Microsoft style inline assembly statements." as it is causing msan failures.

This reverts commits r308985 and r308965

Removed:
cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=309004&r1=309003&r2=309004&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Jul 25 12:17:32 2017
@@ -645,8 +645,8 @@ ExprResult Sema::LookupInlineAsmIdentifi
   // Referring to parameters is not allowed in naked functions.
   if (CheckNakedParmReference(Result.get(), *this))
 return ExprError();
-  Expr *Res = Result.get();
-  QualType T = Res->getType();
+
+  QualType T = Result.get()->getType();
 
   if (T->isDependentType()) {
 return Result;
@@ -658,26 +658,16 @@ ExprResult Sema::LookupInlineAsmIdentifi
   }
 
   // Otherwise, it needs to be a complete type.
-  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
+  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
 return ExprError();
   }
 
   fillInlineAsmTypeInfo(Context, T, Info);
 
   // We can work with the expression as long as it's not an r-value.
-  if (!Res->isRValue()) {
-Info.setKindVariable();
-return Result;
-  }
+  if (!Result.get()->isRValue())
+Info.IsVarDecl = true;
 
-  Expr::EvalResult EvlResult;
-  // Try to evaluate the identifier as enum constant, currently we do not allow
-  // other constant integers to be folded.
-  if (isa(T) &&
-Res->EvaluateAsRValue(EvlResult, getASTContext())) {
-Info.ConstIntValue = EvlResult.Val.getInt();
-Info.setKindConstEnum();
-  }
   return Result;
 }
 
@@ -784,7 +774,7 @@ Sema::LookupInlineAsmVarDeclField(Expr *
   fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
 
   // Fields are "variables" as far as inline assembly is concerned.
-  Info.setKindVariable();
+  Info.IsVarDecl = true;
 
   return Result;
 }

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=309004&r1=309003&r2=309004&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Jul 25 12:17:32 2017
@@ -42,7 +42,7 @@ void t5(void) {
 void t6(void) {
   __asm int 0x2c
 // CHECK: t6
-// CHECK: call void asm sideeffect inteldialect "int $$44", 
"~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$0x2c", 
"~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t7() {
@@ -61,7 +61,7 @@ void t7() {
 mov eax, ebx
   }
 // CHECK: t7
-// CHECK: call void asm sideeffect inteldialect "int $$44", 
"~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$0x2cU", 
"~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "", 
"~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "mov eax, ebx", 
"~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -94,7 +94,7 @@ void t9() {
 // CHECK: t9
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$7
+// CHECK-SAME: mov ebx, $$0x07
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -265,7 +265,7 @@ void t21() {
 // CHECK: t21
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$7
+// CHECK-SAME: mov ebx, $$07H
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -312,13 +312,13 @@ void t24() {
 void t25() {
 // CHECK: t25
   __asm mov eax, 0h
-// CHECK: mov eax, $$4294967295
+// CHECK: mov eax, $$0h
   __asm mov eax, 0fhU
 // CHECK: mov eax, $$15
   __asm mov eax, 0a2h
-// CHECK: mov eax, $$162
+// CHECK: mov eax, $$0a2h
   __asm mov eax, 10100010b
-// CHECK: mov eax, $$162
+// CHECK: mov eax, $$10100010b
   __asm mov eax, 10100010BU
 // CHECK: mov eax, $$162
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()

Removed: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp?rev=309003&view=auto
==
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (original)
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (removed)
@@ -1,60 +0,0 @@

Re: [PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Eric Christopher via cfe-commits
I've reverted this and Nemanja's attempt at fixing in:

echristo@athyra ~/s/l/t/clang> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
D test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
M lib/Sema/SemaStmtAsm.cpp
M test/CodeGen/ms-inline-asm.c
M test/CodeGenCXX/ms-inline-asm-return.cpp
Committed r309004

-eric

On Tue, Jul 25, 2017 at 11:07 AM Nico Weber  wrote:

> The test also fails on many other bots on http://lab.llvm.org:8011/console
> , a short excerpt:
>
>
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/9702/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/5197/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> On Tue, Jul 25, 2017 at 1:52 PM, Kostya Serebryany via Phabricator via
> cfe-commits  wrote:
>
>> kcc added a comment.
>>
>> Hi.
>> This patch causes the msan bots to complain. Please fix or revert ASAP.
>>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
>> Testing: 0 .. 10..
>> FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)
>>
>> - TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 
>>
>> Script:
>> ---
>>
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/clang
>> -cc1 -internal-isystem
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/6.0.0/include
>> -nostdsysteminc -triple x86_64-pc-win32 -fasm-blocks -emit-llvm
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>> -o - |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>>
>> --
>>
>> Exit Code: 2
>>
>> Command Output (stderr):
>> 
>>
>> 4713==WARNING: MemorySanitizer: use-of-uninitialized-value
>> --
>>
>>   #0 0x3143ba3 in (anonymous
>> namespace)::X86AsmParser::ParseIntelIdentifier(llvm::MCExpr const*&,
>> llvm::StringRef&, llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
>>   #1 0x313f288 in (anonymous
>> namespace)::X86AsmParser::ParseIntelExpression((anonymous
>> namespace)::X86AsmParser::IntelExprStateMachine&, llvm::SMLoc&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
>>   #2 0x31389e7 in (anonymous
>> namespace)::X86AsmParser::ParseIntelBracExpression(unsigned int,
>> llvm::SMLoc, long, bool, unsigned int)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
>>   #3 0x31307f8 in ParseIntelOperand
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1961:12
>>   #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand()
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
>>   #5 0x3118cda in (anonymous
>> namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
>> llvm::StringRef, llvm::SMLoc,
>> llvm::SmallVectorImpl> std::__1::default_delete > >&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
>>   #6 0x4bb9a48 in (anonymous
>> namespace)::AsmParser::parseStatement((anonymous
>> namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/AsmParser.cpp:2034:42
>>   #7 0x4ba63a3 in (anonymous
>> namespace)::AsmParser::parseMSInlineAsm(void*, std::__1::basic_string> std::__1::char_traits, std::__1::allocator >&, unsigned int&,
>> unsigned int&, llvm::SmallVectorImpl >&,

Re: [PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Eric Christopher via cfe-commits
And this:

echristo@athyra ~/s/llvm> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/llvm/trunk ...
M include/llvm/MC/MCParser/MCAsmParser.h
M lib/Target/X86/AsmParser/X86AsmParser.cpp
Committed r309005



On Tue, Jul 25, 2017 at 12:18 PM Eric Christopher 
wrote:

> I've reverted this and Nemanja's attempt at fixing in:
>
> echristo@athyra ~/s/l/t/clang> git svn dcommit
> Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
> D test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
> M lib/Sema/SemaStmtAsm.cpp
> M test/CodeGen/ms-inline-asm.c
> M test/CodeGenCXX/ms-inline-asm-return.cpp
> Committed r309004
>
> -eric
>
> On Tue, Jul 25, 2017 at 11:07 AM Nico Weber  wrote:
>
>> The test also fails on many other bots on
>> http://lab.llvm.org:8011/console , a short excerpt:
>>
>>
>> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/9702/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/5197/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> On Tue, Jul 25, 2017 at 1:52 PM, Kostya Serebryany via Phabricator via
>> cfe-commits  wrote:
>>
>>> kcc added a comment.
>>>
>>> Hi.
>>> This patch causes the msan bots to complain. Please fix or revert ASAP.
>>>
>>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
>>> Testing: 0 .. 10..
>>> FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)
>>>
>>> - TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 
>>>
>>> Script:
>>> ---
>>>
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/clang
>>> -cc1 -internal-isystem
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/6.0.0/include
>>> -nostdsysteminc -triple x86_64-pc-win32 -fasm-blocks -emit-llvm
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>>> -o - |
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>>>
>>> --
>>>
>>> Exit Code: 2
>>>
>>> Command Output (stderr):
>>> 
>>>
>>> 4713==WARNING: MemorySanitizer: use-of-uninitialized-value
>>> --
>>>
>>>   #0 0x3143ba3 in (anonymous
>>> namespace)::X86AsmParser::ParseIntelIdentifier(llvm::MCExpr const*&,
>>> llvm::StringRef&, llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
>>>   #1 0x313f288 in (anonymous
>>> namespace)::X86AsmParser::ParseIntelExpression((anonymous
>>> namespace)::X86AsmParser::IntelExprStateMachine&, llvm::SMLoc&)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
>>>   #2 0x31389e7 in (anonymous
>>> namespace)::X86AsmParser::ParseIntelBracExpression(unsigned int,
>>> llvm::SMLoc, long, bool, unsigned int)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
>>>   #3 0x31307f8 in ParseIntelOperand
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1961:12
>>>   #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand()
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
>>>   #5 0x3118cda in (anonymous
>>> namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
>>> llvm::StringRef, llvm::SMLoc,
>>> llvm::SmallVectorImpl>> std::__1::default_delete > >&)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
>>>   #6 0x4bb9a48 in (anonymous
>>> namespace)::AsmParser::parseStatement((anonymous
>>> namesp

r309006 - [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-25 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Tue Jul 25 12:23:23 2017
New Revision: 309006

URL: http://llvm.org/viewvc/llvm-project?rev=309006&view=rev
Log:
[StaticAnalyzer] Completely unrolling specific loops with known bound option

This feature allows the analyzer to consider loops to completely unroll.
New requirements/rules (for unrolling) can be added easily via ASTMatchers.

Right now it is hidden behind a flag, the aim is to find the correct heuristic
and create a solution which results higher coverage % and more precise
analysis, thus can be enabled by default.

Right now the blocks which belong to an unrolled loop are marked by the
LoopVisitor which adds them to the ProgramState.
Then whenever we encounter a CFGBlock in the processCFGBlockEntrance which is
marked then we skip its investigating. That means, it won't be considered to
be visited more than the maximal bound for visiting since it won't be checked.

Added:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
cfe/trunk/test/Analysis/loop-unrolling.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=309006&r1=309005&r2=309006&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Tue Jul 25 
12:23:23 2017
@@ -275,6 +275,9 @@ private:
   /// \sa shouldWidenLoops
   Optional WidenLoops;
 
+  /// \sa shouldUnrollLoops
+  Optional UnrollLoops;
+
   /// \sa shouldDisplayNotesAsEvents
   Optional DisplayNotesAsEvents;
 
@@ -560,6 +563,10 @@ public:
   /// This is controlled by the 'widen-loops' config option.
   bool shouldWidenLoops();
 
+  /// Returns true if the analysis should try to unroll loops with known 
bounds.
+  /// This is controlled by the 'unroll-loops' config option.
+  bool shouldUnrollLoops();
+
   /// Returns true if the bug reporter should transparently treat extra note
   /// diagnostic pieces as event diagnostic pieces. Useful when the diagnostic
   /// consumer doesn't support the extra note pieces.

Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h?rev=309006&view=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
(added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
Tue Jul 25 12:23:23 2017
@@ -0,0 +1,34 @@
+//===--- LoopUnrolling.h - Unroll loops -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// This header contains the declarations of functions which are used to decide
+/// which loops should be completely unrolled and mark their corresponding
+/// CFGBlocks.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
+
+#include "clang/Analysis/CFG.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+
+namespace clang {
+namespace ento {
+ProgramStateRef markLoopAsUnrolled(const Stmt *Term, ProgramStateRef State,
+   const FunctionDecl *FD);
+bool isUnrolledLoopBlock(const CFGBlock *Block, ExplodedNode *Pred,
+ AnalysisManager &AMgr);
+bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx);
+
+} // end namespace ento
+} // end namespace clang
+
+#endif

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=309006&r1=309005&r2=309006&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.

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

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D28691#820489, @yaxunl wrote:

> In https://reviews.llvm.org/D28691#820466, @b-sumner wrote:
>
> > Can we drop the "opencl" part of the name and use something like 
> > __scoped_atomic_*?   Also, it may not make sense to support non-constant 
> > scope here since we can't predict what other scopes may be added by other 
> > languages in the future.
>
>
> we could use the approach of LangAS, i.e. we allow targets to map all 
> language specific scopes to target-specific scope names, since IR only cares 
> about scope names, which are target specific. And this is what the current 
> implementation does.
>
> I have no objection to use the __scoped_atomic_ name. It is more general and 
> extensible. John/Anastasia, any comments? Thanks.


I think I would prefer __opencl_atomic_* until we have some evidence that this 
concept is more general than just OpenCL.


https://reviews.llvm.org/D28691



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


r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-25 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Jul 25 12:34:23 2017
New Revision: 309007

URL: http://llvm.org/viewvc/llvm-project?rev=309007&view=rev
Log:
[ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

The instrumentation generated by -fsanitize=vptr does not null check a
user pointer before loading from it. This causes crashes in the face of
UB member calls (this=nullptr), i.e it's causing user programs to crash
only after UBSan is turned on.

The fix is to make run-time null checking a prerequisite for enabling
-fsanitize=vptr, and to then teach UBSan to reuse these run-time null
checks to make -fsanitize=vptr safe.

Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build

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

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/rtti-options.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309007&r1=309006&r2=309007&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
@@ -155,7 +155,9 @@ Static Analyzer
 Undefined Behavior Sanitizer (UBSan)
 
 
-...
+The C++ dynamic type check now requires run-time null checking (i.e,
+`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change does
+not impact users who rely on UBSan check groups (e.g `-fsanitize=undefined`).
 
 Core Analysis Improvements
 ==

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=309007&r1=309006&r2=309007&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23 2017
@@ -130,11 +130,11 @@ Available checks are:
  it is often unintentional, so UBSan offers to catch it.
   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
  does not evaluate to a positive value.
-  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
- it is of the wrong dynamic type, or that its lifetime has not
- begun or has ended. Incompatible with ``-fno-rtti``. Link must
- be performed by ``clang++``, not ``clang``, to make sure C++-specific
- parts of the runtime library and C++ standard libraries are present.
+  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that it is of
+ the wrong dynamic type, or that its lifetime has not begun or has ended.
+ Incompatible with ``-fno-rtti`` and ``-fno-sanitize=null``. Link must be
+ performed by ``clang++``, not ``clang``, to make sure C++-specific parts 
of
+ the runtime library and C++ standard libraries are present.
 
 You can also use the following check groups:
   -  ``-fsanitize=undefined``: All of the checks listed above other than

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=309007&r1=309006&r2=309007&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jul 25 12:34:23 
2017
@@ -230,7 +230,10 @@ def warn_drv_enabling_rtti_with_exceptio
   InGroup>;
 def warn_drv_disabling_vptr_no_rtti_default : Warning<
   "implicitly disabling vptr sanitizer because rtti wasn't enabled">,
-  InGroup>;
+  InGroup;
+def warn_drv_disabling_vptr_no_null_check : Warning<
+  "implicitly disabling vptr sanitizer because null checking wasn't enabled">,
+  InGroup;
 def warn_drv_object_size_disabled_O0 : Warning<
   "the object size sanitizer has no effect at -O0, but is explicitly enabled: 
%0">,
   InGroup;

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=309007&r1=309006&r2=309007&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jul 25 12:34:23 2017
@@ -27,6 +27,

[PATCH] D35735: [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309007: [ubsan] Null-check pointers in -fsanitize=vptr 
(PR33881) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D35735?vs=107741&id=108133#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35735

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
  cfe/trunk/test/Driver/fsanitize.c
  cfe/trunk/test/Driver/rtti-options.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -27,6 +27,7 @@
 def GNUAutoType : DiagGroup<"gnu-auto-type">;
 def ArrayBounds : DiagGroup<"array-bounds">;
 def ArrayBoundsPointerArithmetic : DiagGroup<"array-bounds-pointer-arithmetic">;
+def AutoDisableVptrSanitizer : DiagGroup<"auto-disable-vptr-sanitizer">;
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -230,7 +230,10 @@
   InGroup>;
 def warn_drv_disabling_vptr_no_rtti_default : Warning<
   "implicitly disabling vptr sanitizer because rtti wasn't enabled">,
-  InGroup>;
+  InGroup;
+def warn_drv_disabling_vptr_no_null_check : Warning<
+  "implicitly disabling vptr sanitizer because null checking wasn't enabled">,
+  InGroup;
 def warn_drv_object_size_disabled_O0 : Warning<
   "the object size sanitizer has no effect at -O0, but is explicitly enabled: %0">,
   InGroup;
Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -58,6 +58,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-RTTI
 // CHECK-UNDEFINED-NO-RTTI-NOT: vptr
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-sanitize=null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
+// CHECK-VPTR-NO-NULL: warning: implicitly disabling vptr sanitizer because null checking wasn't enabled
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
 // CHECK-SANA-SANT: '-fsanitize=address' not allowed with '-fsanitize=thread'
 
@@ -362,8 +366,8 @@
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.8 -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-OLD
 // CHECK-VPTR-DARWIN-OLD: unsupported option '-fsanitize=vptr' for target 'x86_64-apple-darwin10'
 
-// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.9 -fsanitize=alignment,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-NEW
-// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.9 -fsanitize=alignment,null,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-NEW
+// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,null,vptr
 
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
 // CHECK-ASAN-IOS: -fsanitize=address
Index: cfe/trunk/test/Driver/rtti-options.cpp
===
--- cfe/trunk/test/Driver/rtti-options.cpp
+++ cfe/trunk/test/Driver/rtti-options.cpp
@@ -16,14 +16,14 @@
 // Make sure we only error/warn once, when trying to enable vptr and
 // undefined and have -fno-rtti
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
+// RUN: %clang -

[PATCH] D35735: [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked an inline comment as done.
vsk added a comment.

I made the suggested test changes and updated the release notes: r309007


Repository:
  rL LLVM

https://reviews.llvm.org/D35735



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


[PATCH] D35736: [ubsan] -fsanitize=vptr now requires -fsanitize=null, update tests

2017-07-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk closed this revision.
vsk added a comment.

Thanks! This landed in r309008.


https://reviews.llvm.org/D35736



___
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-07-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In https://reviews.llvm.org/D28691#820526, @rjmccall wrote:

> In https://reviews.llvm.org/D28691#820489, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D28691#820466, @b-sumner wrote:
> >
> > > Can we drop the "opencl" part of the name and use something like 
> > > __scoped_atomic_*?   Also, it may not make sense to support non-constant 
> > > scope here since we can't predict what other scopes may be added by other 
> > > languages in the future.
> >
> >
> > we could use the approach of LangAS, i.e. we allow targets to map all 
> > language specific scopes to target-specific scope names, since IR only 
> > cares about scope names, which are target specific. And this is what the 
> > current implementation does.
> >
> > I have no objection to use the __scoped_atomic_ name. It is more general 
> > and extensible. John/Anastasia, any comments? Thanks.
>
>
> I think I would prefer __opencl_atomic_* until we have some evidence that 
> this concept is more general than just OpenCL.


There are other languages for heterogeneous compute that have scopes, although 
not exposed quite as explicitly as OpenCL.  For example AMD's "HC" language.  
And any language making use of clang and targeting SPIR-V would likely use 
these builtins.  I think a more generic prefix is appropriate, and "scoped" 
tells us exactly when these are needed.


https://reviews.llvm.org/D28691



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


Re: [PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jul 25, 2017 at 03:09:00PM -0400, Nico Weber via cfe-commits wrote:
> On Tue, Jul 25, 2017 at 2:53 PM, Joerg Sonnenberger  wrote:
> 
> > On Sun, Jul 23, 2017 at 07:06:25PM -0400, Nico Weber via cfe-commits wrote:
> > > If you need this behavior for something, that sounds like something a
> > > -nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
> > > stdlib and nothing else.
> >
> > But the -lm is only there because -lc++ alone (or -lstdc++ for that
> > matter) wouldn't really work.
> >
> 
> Do you have a reference for that? Several toolchains link in -lm in C mode
> even.

UNIX history?

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


r309013 - [Frontend] Mark some ASTUnit methods as const. NFC.

2017-07-25 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Jul 25 12:53:27 2017
New Revision: 309013

URL: http://llvm.org/viewvc/llvm-project?rev=309013&view=rev
Log:
[Frontend] Mark some ASTUnit methods as const. NFC.

Patch by Hamza Sood!

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

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

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=309013&r1=309012&r2=309013&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Jul 25 12:53:27 2017
@@ -448,7 +448,7 @@ public:
 
   IntrusiveRefCntPtr getASTReader() const;
 
-  StringRef getOriginalSourceFileName() {
+  StringRef getOriginalSourceFileName() const {
 return OriginalSourceFile;
   }
 
@@ -524,26 +524,26 @@ public:
   /// \brief If \p Loc is a loaded location from the preamble, returns
   /// the corresponding local location of the main file, otherwise it returns
   /// \p Loc.
-  SourceLocation mapLocationFromPreamble(SourceLocation Loc);
+  SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
 
   /// \brief If \p Loc is a local location of the main file but inside the
   /// preamble chunk, returns the corresponding loaded location from the
   /// preamble, otherwise it returns \p Loc.
-  SourceLocation mapLocationToPreamble(SourceLocation Loc);
+  SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
 
-  bool isInPreambleFileID(SourceLocation Loc);
-  bool isInMainFileID(SourceLocation Loc);
-  SourceLocation getStartOfMainFileID();
-  SourceLocation getEndOfPreambleFileID();
+  bool isInPreambleFileID(SourceLocation Loc) const;
+  bool isInMainFileID(SourceLocation Loc) const;
+  SourceLocation getStartOfMainFileID() const;
+  SourceLocation getEndOfPreambleFileID() const;
 
   /// \see mapLocationFromPreamble.
-  SourceRange mapRangeFromPreamble(SourceRange R) {
+  SourceRange mapRangeFromPreamble(SourceRange R) const {
 return SourceRange(mapLocationFromPreamble(R.getBegin()),
mapLocationFromPreamble(R.getEnd()));
   }
 
   /// \see mapLocationToPreamble.
-  SourceRange mapRangeToPreamble(SourceRange R) {
+  SourceRange mapRangeToPreamble(SourceRange R) const {
 return SourceRange(mapLocationToPreamble(R.getBegin()),
mapLocationToPreamble(R.getEnd()));
   }
@@ -607,7 +607,7 @@ public:
 
   /// \brief Returns true if the ASTUnit was constructed from a serialized
   /// module file.
-  bool isModuleFile();
+  bool isModuleFile() const;
 
   std::unique_ptr
   getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=309013&r1=309012&r2=309013&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Jul 25 12:53:27 2017
@@ -2395,7 +2395,7 @@ SourceLocation ASTUnit::getLocation(cons
 /// \brief If \arg Loc is a loaded location from the preamble, returns
 /// the corresponding local location of the main file, otherwise it returns
 /// \arg Loc.
-SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2416,7 +2416,7 @@ SourceLocation ASTUnit::mapLocationFromP
 /// \brief If \arg Loc is a local location of the main file but inside the
 /// preamble chunk, returns the corresponding loaded location from the
 /// preamble, otherwise it returns \arg Loc.
-SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2434,7 +2434,7 @@ SourceLocation ASTUnit::mapLocationToPre
   return Loc;
 }
 
-bool ASTUnit::isInPreambleFileID(SourceLocation Loc) {
+bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2445,7 +2445,7 @@ bool ASTUnit::isInPreambleFileID(SourceL
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-bool ASTUnit::isInMainFileID(SourceLocation Loc) {
+bool ASTUnit::isInMainFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getMainFileID();
@@ -2456,7 +2456,7 @@ bool ASTUnit::isInMainFileID(SourceLocat
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-SourceLocation ASTUnit::getEndOfPreambleFileID() {
+SourceLocation ASTUnit::getEndOfPreambleFileID() const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID()

r309014 - [ExternalASTMerger] Import Objective-C classes

2017-07-25 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Jul 25 12:54:22 2017
New Revision: 309014

URL: http://llvm.org/viewvc/llvm-project?rev=309014&view=rev
Log:
[ExternalASTMerger] Import Objective-C classes

This patch adds functionality and a test for importing Objective-C classes
and their methods.

It also adds a flag to clang-import-test to set the language used for
parsing. This takes the same argument format as the -x option to the
driver.

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

Added:
cfe/trunk/test/Import/objc-method/
  - copied from r308993, cfe/trunk/test/Import/member-in-struct/
cfe/trunk/test/Import/objc-method/Inputs/S.m
  - copied, changed from r308993, 
cfe/trunk/test/Import/member-in-struct/Inputs/S.c
cfe/trunk/test/Import/objc-method/test.m
  - copied, changed from r308993, 
cfe/trunk/test/Import/member-in-struct/test.c
Removed:
cfe/trunk/test/Import/objc-method/Inputs/S.c
cfe/trunk/test/Import/objc-method/test.c
Modified:
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=309014&r1=309013&r2=309014&view=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Tue Jul 25 12:54:22 2017
@@ -44,6 +44,9 @@ public:
   ToTag->setMustBuildLookupTable();
 } else if (auto ToNamespace = dyn_cast(To)) {
   ToNamespace->setHasExternalVisibleStorage();
+} else if (auto ToContainer = dyn_cast(To)) {
+  ToContainer->setHasExternalLexicalStorage();
+  ToContainer->setMustBuildLookupTable();
 }
 return ASTImporter::Imported(From, To);
   }
@@ -80,11 +83,12 @@ LookupSameContext(Source(D)); // TODO handle this case
   if (auto TD = dyn_cast(D)) {
 return !TD->isThisDeclarationADefinition();
   } else if (auto FD = dyn_cast(D)) {
 return !FD->isThisDeclarationADefinition();
+  } else if (auto OID = dyn_cast(D)) {
+ return OID->isThisDeclarationADefinition();
   } else {
 return false;
   }

Removed: cfe/trunk/test/Import/objc-method/Inputs/S.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/member-in-struct/Inputs/S.c?rev=308993&view=auto
==
--- cfe/trunk/test/Import/objc-method/Inputs/S.c (original)
+++ cfe/trunk/test/Import/objc-method/Inputs/S.c (removed)
@@ -1,3 +0,0 @@
-struct S {
-  int a;
-};

Copied: cfe/trunk/test/Import/objc-method/Inputs/S.m (from r308993, 
cfe/trunk/test/Import/member-in-struct/Inputs/S.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-method/Inputs/S.m?p2=cfe/trunk/test/Import/objc-method/Inputs/S.m&p1=cfe/trunk/test/Import/member-in-struct/Inputs/S.c&r1=308993&r2=309014&rev=309014&view=diff
==
--- cfe/trunk/test/Import/member-in-struct/Inputs/S.c (original)
+++ cfe/trunk/test/Import/objc-method/Inputs/S.m Tue Jul 25 12:54:22 2017
@@ -1,3 +1,4 @@
-struct S {
-  int a;
-};
+@interface C {
+}
+-(int)m;
+@end

Removed: cfe/trunk/test/Import/objc-method/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/member-in-struct/test.c?rev=308993&view=auto
==
--- cfe/trunk/test/Import/objc-method/test.c (original)
+++ cfe/trunk/test/Import/objc-method/test.c (removed)
@@ -1,5 +0,0 @@
-// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
-void expr() {
-  struct S MyS;
-  MyS.a = 3;
-}

Copied: cfe/trunk/test/Import/objc-method/test.m (from r308993, 
cfe/trunk/test/Import/member-in-struct/test.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-method/test.m?p2=cfe/trunk/test/Import/objc-method/test.m&p1=cfe/trunk/test/Import/member-in-struct/test.c&r1=308993&r2=309014&rev=309014&view=diff
==
--- cfe/trunk/test/Import/member-in-struct/test.c (original)
+++ cfe/trunk/test/Import/objc-method/test.m Tue Jul 25 12:54:22 2017
@@ -1,5 +1,5 @@
-// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
+// RUN: clang-import-test -x objective-c++ -import %S/Inputs/S.m -expression %s
 void expr() {
-  struct S MyS;
-  MyS.a = 3;
+  C *c;
+  int i = [c m];
 }

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=309014&r1=309013&r2=309014&view=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Jul 25 12:54:22 
2017
@@ -17,6 +17,7 @@
 #include "clang/Basic/Ta

[PATCH] D35729: [Frontend] - Mark some ASTUnit methods as const

2017-07-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309013: [Frontend] Mark some ASTUnit methods as const. NFC. 
(authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D35729?vs=107689&id=108138#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35729

Files:
  cfe/trunk/include/clang/Frontend/ASTUnit.h
  cfe/trunk/lib/Frontend/ASTUnit.cpp

Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -448,7 +448,7 @@
 
   IntrusiveRefCntPtr getASTReader() const;
 
-  StringRef getOriginalSourceFileName() {
+  StringRef getOriginalSourceFileName() const {
 return OriginalSourceFile;
   }
 
@@ -524,26 +524,26 @@
   /// \brief If \p Loc is a loaded location from the preamble, returns
   /// the corresponding local location of the main file, otherwise it returns
   /// \p Loc.
-  SourceLocation mapLocationFromPreamble(SourceLocation Loc);
+  SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
 
   /// \brief If \p Loc is a local location of the main file but inside the
   /// preamble chunk, returns the corresponding loaded location from the
   /// preamble, otherwise it returns \p Loc.
-  SourceLocation mapLocationToPreamble(SourceLocation Loc);
+  SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
 
-  bool isInPreambleFileID(SourceLocation Loc);
-  bool isInMainFileID(SourceLocation Loc);
-  SourceLocation getStartOfMainFileID();
-  SourceLocation getEndOfPreambleFileID();
+  bool isInPreambleFileID(SourceLocation Loc) const;
+  bool isInMainFileID(SourceLocation Loc) const;
+  SourceLocation getStartOfMainFileID() const;
+  SourceLocation getEndOfPreambleFileID() const;
 
   /// \see mapLocationFromPreamble.
-  SourceRange mapRangeFromPreamble(SourceRange R) {
+  SourceRange mapRangeFromPreamble(SourceRange R) const {
 return SourceRange(mapLocationFromPreamble(R.getBegin()),
mapLocationFromPreamble(R.getEnd()));
   }
 
   /// \see mapLocationToPreamble.
-  SourceRange mapRangeToPreamble(SourceRange R) {
+  SourceRange mapRangeToPreamble(SourceRange R) const {
 return SourceRange(mapLocationToPreamble(R.getBegin()),
mapLocationToPreamble(R.getEnd()));
   }
@@ -607,7 +607,7 @@
 
   /// \brief Returns true if the ASTUnit was constructed from a serialized
   /// module file.
-  bool isModuleFile();
+  bool isModuleFile() const;
 
   std::unique_ptr
   getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);
Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -2395,7 +2395,7 @@
 /// \brief If \arg Loc is a loaded location from the preamble, returns
 /// the corresponding local location of the main file, otherwise it returns
 /// \arg Loc.
-SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2416,7 +2416,7 @@
 /// \brief If \arg Loc is a local location of the main file but inside the
 /// preamble chunk, returns the corresponding loaded location from the
 /// preamble, otherwise it returns \arg Loc.
-SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2434,7 +2434,7 @@
   return Loc;
 }
 
-bool ASTUnit::isInPreambleFileID(SourceLocation Loc) {
+bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2445,7 +2445,7 @@
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-bool ASTUnit::isInMainFileID(SourceLocation Loc) {
+bool ASTUnit::isInMainFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getMainFileID();
@@ -2456,7 +2456,7 @@
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-SourceLocation ASTUnit::getEndOfPreambleFileID() {
+SourceLocation ASTUnit::getEndOfPreambleFileID() const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2467,7 +2467,7 @@
   return SourceMgr->getLocForEndOfFile(FID);
 }
 
-SourceLocation ASTUnit::getStartOfMainFileID() {
+SourceLocation ASTUnit::getStartOfMainFileID() const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getMainFileID();
@@ -2543,7 +2543,7 @@
   return nullptr;
 }
 
-bool ASTUnit::isModuleFile() {
+bool ASTUnit::isModuleFile() const {
   return isMainFileAST() && getLangOpts().isCompilingModule();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.

[PATCH] D35673: [analyzer] A better CFG-based suppress-on-sink.

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp:3313
 
+static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
+  const CFG &Cfg = N->getCFG();

Do you really mean "is dominated by"? That is, "every path from the entry to 
N's block goes through a no-return block"? Or do you mean "the exit block is 
not reachable from N's block"?


Repository:
  rL LLVM

https://reviews.llvm.org/D35673



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


r309018 - Fix a bot by linking clang-import-test against libclangDriver

2017-07-25 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Jul 25 13:09:30 2017
New Revision: 309018

URL: http://llvm.org/viewvc/llvm-project?rev=309018&view=rev
Log:
Fix a bot by linking clang-import-test against libclangDriver

Modified:
cfe/trunk/tools/clang-import-test/CMakeLists.txt

Modified: cfe/trunk/tools/clang-import-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/CMakeLists.txt?rev=309018&r1=309017&r2=309018&view=diff
==
--- cfe/trunk/tools/clang-import-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-import-test/CMakeLists.txt Tue Jul 25 13:09:30 2017
@@ -17,6 +17,7 @@ set(CLANG_IMPORT_TEST_LIB_DEPS
   clangAST
   clangBasic
   clangCodeGen
+  clangDriver
   clangFrontend
   clangLex
   clangParse


___
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-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D28691#820541, @b-sumner wrote:

> There are other languages for heterogeneous compute that have scopes, 
> although not exposed quite as explicitly as OpenCL.  For example AMD's "HC" 
> language.  And any language making use of clang and targeting SPIR-V would 
> likely use these builtins.  I think a more generic prefix is appropriate, and 
> "scoped" tells us exactly when these are needed.


But would those languages use the same language design for these scopes as 
OpenCL if they did expose them, as opposed to some more elaborate scoping 
specification?  My objection is not that the concept is inherently 
OpenCL-specific, it's that the presentation in the language might be inherently 
OpenCL-specific, which makes staying in the opencl namespace is prudent.


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] D32842: Specify which sanitizers are covered by a sanitizer blacklist

2017-07-25 Thread Han Shen via Phabricator via cfe-commits
shenhan added a comment.

Thanks. Can you update "SanitizerArgs::collectDefaultBlacklists" to include 
"ubsan_blacklist.txt"?


https://reviews.llvm.org/D32842



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


  1   2   >