r313521 - Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]

2017-09-18 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Sep 18 01:26:01 2017
New Revision: 313521

URL: http://llvm.org/viewvc/llvm-project?rev=313521&view=rev
Log:
Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]

Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=313521&r1=313520&r2=313521&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Sep 18 01:26:01 2017
@@ -42,7 +42,7 @@ bool Preprocessor::isInPrimaryFile() con
  "Top level include stack isn't our primary lexer?");
   return std::none_of(
   IncludeMacroStack.begin() + 1, IncludeMacroStack.end(),
-  [this](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI); 
});
+  [&](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI); });
 }
 
 /// getCurrentLexer - Return the current file lexer being lexed from.  Note


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


[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

All lit test for clangd are currently failing if I apply your change.
Generally, please run `make check-clang-tools` to make sure your changes do not 
introduce any regressions.

The tests are failing because when `--compile-commands-dir` is not specified 
clangd now shows the cmd arg validation errors (`"path not absolute"`, `"path 
does not exist"`).




Comment at: clangd/tool/ClangdMain.cpp:78
+  if (!llvm::sys::path::is_absolute(CompileCommandsDir)) {
+Out.log("Path specified by --compile-commands-dir must be an absolute "
+"path. The argument will be ignored.\n");

The code doing command line argument validation shows errors using 
`llvm::errs()` and not `Out.log()`. Could you do the same for consistency?

Also, could you put your new code that does argument validation right after the 
previous checks (to line 65)? So that we have a clear structure in the code:
```
/// Validate command line arguments.
...

/// Initialize and run ClangdLSPServer.
...
```


https://reviews.llvm.org/D37150



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


Re: r313521 - Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]

2017-09-18 Thread NAKAMURA Takumi via cfe-commits
Seems fixed! Thanks!

On Mon, Sep 18, 2017 at 5:27 PM Vitaly Buka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vitalybuka
> Date: Mon Sep 18 01:26:01 2017
> New Revision: 313521
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313521&view=rev
> Log:
> Another attempt to fix warning discovered by r313487.
> [-Wunused-lambda-capture]
>
> Modified:
> cfe/trunk/lib/Lex/PPLexerChange.cpp
>
> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=313521&r1=313520&r2=313521&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Sep 18 01:26:01 2017
> @@ -42,7 +42,7 @@ bool Preprocessor::isInPrimaryFile() con
>   "Top level include stack isn't our primary lexer?");
>return std::none_of(
>IncludeMacroStack.begin() + 1, IncludeMacroStack.end(),
> -  [this](const IncludeStackInfo &ISI) -> bool { return
> IsFileLexer(ISI); });
> +  [&](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI);
> });
>  }
>
>  /// getCurrentLexer - Return the current file lexer being lexed from.
> Note
>
>
> ___
> 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] D37903: Fix assume-filename handling in clang-format.el

2017-09-18 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a reviewer: phst.
klimek added a comment.

+Philipp, who is our emacs expert :)


https://reviews.llvm.org/D37903



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


Re: r313521 - Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]

2017-09-18 Thread Faisal Vali via cfe-commits
thanks!
Faisal Vali



On Mon, Sep 18, 2017 at 4:10 AM, NAKAMURA Takumi  wrote:
> Seems fixed! Thanks!
>
> On Mon, Sep 18, 2017 at 5:27 PM Vitaly Buka via cfe-commits
>  wrote:
>>
>> Author: vitalybuka
>> Date: Mon Sep 18 01:26:01 2017
>> New Revision: 313521
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=313521&view=rev
>> Log:
>> Another attempt to fix warning discovered by r313487.
>> [-Wunused-lambda-capture]
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPLexerChange.cpp
>>
>> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=313521&r1=313520&r2=313521&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Sep 18 01:26:01 2017
>> @@ -42,7 +42,7 @@ bool Preprocessor::isInPrimaryFile() con
>>   "Top level include stack isn't our primary lexer?");
>>return std::none_of(
>>IncludeMacroStack.begin() + 1, IncludeMacroStack.end(),
>> -  [this](const IncludeStackInfo &ISI) -> bool { return
>> IsFileLexer(ISI); });
>> +  [&](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI);
>> });
>>  }
>>
>>  /// getCurrentLexer - Return the current file lexer being lexed from.
>> Note
>>
>>
>> ___
>> 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] D37544: [ubsan] Skip alignment checks which are folded away

2017-09-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

It looks like this test passes prior to the code change in this patch. Can you 
please change the test?


https://reviews.llvm.org/D37544



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


[PATCH] D37542: [ubsan] Save a ptrtoint when emitting alignment checks

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

Nice, LGTM


https://reviews.llvm.org/D37542



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


[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR

2017-09-18 Thread jina via Phabricator via cfe-commits
jina.nahias updated this revision to Diff 115622.
jina.nahias added a comment.

rebase on @craig.topper  commit.


https://reviews.llvm.org/D37668

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlintrin.h
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vlbw-builtins.c

Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -2670,28 +2670,195 @@
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
   return _mm256_maskz_broadcastw_epi16(__M, __A);
 }
+__m128i test_mm_mask_set1_epi8 (__m128i __O, __mmask16 __M, char __A){
+  // CHECK-LABEL: @test_mm_mask_set1_epi8
+  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
+  return _mm_mask_set1_epi8(__O, __M, __A);
+}
+__m128i test_mm_maskz_set1_epi8 ( __mmask16 __M, char __A){
+  // CHECK-LABEL: @test_mm_maskz_set1_epi8
+  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
+  return _mm_maskz_set1_epi8( __M, __A);
+}
+
+__m256i test_mm256_mask_set1_epi8(__m256i __O, __mmask32 __M, char __A) {
+  // CHECK-LABEL: @test_mm256_mask_set1_epi8
+  // CHECK: insertelement <32 x i8> undef, i8 %{{.*}}, i32 0
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 16
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 17
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 18
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 19
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 20
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 21
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 22
+  // CHECK: insertelement

[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR

2017-09-18 Thread jina via Phabricator via cfe-commits
jina.nahias added inline comments.



Comment at: lib/Headers/avx512fintrin.h:9742
 
 #ifdef __x86_64__
 static __inline__ __m512i __DEFAULT_FN_ATTRS

craig.topper wrote:
> Please remove the #ifdef __x86_64__ from this. It should work in 32-bits as 
> well.
the current generated code for 32-bit is not optimal, 32-bit needs some more 
work which will be in a following patch .


https://reviews.llvm.org/D37668



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


[PATCH] D37970: [clangd] Added a command-line arg to mirror clangd input into a file.

2017-09-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

The arg is useful for debugging and creating test cases.


https://reviews.llvm.org/D37970

Files:
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/tool/ClangdMain.cpp
  test/clangd/input-mirror.test

Index: test/clangd/input-mirror.test
===
--- /dev/null
+++ test/clangd/input-mirror.test
@@ -0,0 +1,154 @@
+# RUN: clangd -run-synchronously -input-mirror-file %t < %s
+# Note that we have to use '-Z' as -input-mirror-file does not have a newline at the end of file.
+# RUN: diff -Z %t %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":0}}}
+# Go to local variable
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":1}}}
+# Go to local variable, end of token
+
+Content-Length: 214
+
+{"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"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":14}}}
+# Go to field, GNU old-style field designator 
+
+Content-Length: 215
+
+{"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"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":15}}}
+# Go to field, field designator 
+
+Content-Length: 187
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":4},"contentChanges":[{"text":"int main() {\n   main();\n   return 0;\n}"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":3}}}
+# Go to function declaration, function call 
+
+Content-Length: 208
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"struct Foo {\n};\nint main() {\n   Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":3}}}
+# Go to struct declaration, new struct instance 
+
+Content-Length: 231
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"namespace n1 {\nstruct Foo {\n};\n}\nint main() {\n   n1::Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":4}}}
+# Go to struct declaration, new struct instance, qualified name 
+
+Content-Length: 215
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":6},"contentChanges":[{"text":"struct Foo {\n  int x;\n};\nint main() {\n   Foo bar;\n   bar.x;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":7}}}
+# Go to field declaration, field reference 
+
+Content-Length: 220
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":7},"contentChanges":[{"text":"struct Foo {\n  void x();\n};\nint main() {\n   Foo bar;\n   bar.x();\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":7}}}
+# Go to method declaration, method call 
+
+Content-Length: 240
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":7},"contentChanges":[{"text":"struct Foo {\n};\ntypedef Foo TypedefFoo;\nint main() {\n   TypedefFoo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1

[PATCH] D37970: [clangd] Added a command-line arg to mirror clangd input into a file.

2017-09-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 115628.
ilya-biryukov added a comment.

Replaced std::string with Path typedef.


https://reviews.llvm.org/D37970

Files:
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/tool/ClangdMain.cpp
  test/clangd/input-mirror.test

Index: test/clangd/input-mirror.test
===
--- /dev/null
+++ test/clangd/input-mirror.test
@@ -0,0 +1,154 @@
+# RUN: clangd -run-synchronously -input-mirror-file %t < %s
+# Note that we have to use '-Z' as -input-mirror-file does not have a newline at the end of file.
+# RUN: diff -Z %t %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":0}}}
+# Go to local variable
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":1}}}
+# Go to local variable, end of token
+
+Content-Length: 214
+
+{"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"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":14}}}
+# Go to field, GNU old-style field designator 
+
+Content-Length: 215
+
+{"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"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":15}}}
+# Go to field, field designator 
+
+Content-Length: 187
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":4},"contentChanges":[{"text":"int main() {\n   main();\n   return 0;\n}"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":3}}}
+# Go to function declaration, function call 
+
+Content-Length: 208
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"struct Foo {\n};\nint main() {\n   Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":3}}}
+# Go to struct declaration, new struct instance 
+
+Content-Length: 231
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"namespace n1 {\nstruct Foo {\n};\n}\nint main() {\n   n1::Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":4}}}
+# Go to struct declaration, new struct instance, qualified name 
+
+Content-Length: 215
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":6},"contentChanges":[{"text":"struct Foo {\n  int x;\n};\nint main() {\n   Foo bar;\n   bar.x;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":7}}}
+# Go to field declaration, field reference 
+
+Content-Length: 220
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":7},"contentChanges":[{"text":"struct Foo {\n  void x();\n};\nint main() {\n   Foo bar;\n   bar.x();\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":7}}}
+# Go to method declaration, method call 
+
+Content-Length: 240
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":7},"contentChanges":[{"text":"struct Foo {\n};\ntypedef Foo TypedefFoo;\nint main() {\n   TypedefFoo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 1

[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

2017-09-18 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added subscribers: hfinkel, echristo.
nemanjai added a comment.
This revision is now accepted and ready to land.

I hope I haven't lost track of the patches that precluded this. If I remember 
correctly, all the X86 80-bit stuff was sorted out. We now know why those test 
cases were running forever (i.e. a vaarg function invoked as a non-vaarg 
function). So this just enables the truly generic builtins along with some PPC 
builtins. If my understanding is correct, I'd say this is ready to proceed 
(unless it was subsumed by one of the other patches).

Long story short... LGTM.
You may want to get the green light from @hfinkel or @echristo and/or one of 
the compiler-rt experts as well.


https://reviews.llvm.org/D36431



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


[PATCH] D37972: [clangd] Introduced Logger interface.

2017-09-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added a subscriber: mgorny.

This fixes a bunch of logging-related FIXMEs.


https://reviews.llvm.org/D37972

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/JSONRPCDispatcher.h
  clangd/Logger.cpp
  clangd/Logger.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ClangdServer.h"
+#include "Logger.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "llvm/ADT/SmallVector.h"
@@ -302,7 +303,8 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false);
+/*SnippetCompletions=*/false,
+EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
@@ -365,7 +367,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -410,7 +412,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -457,7 +459,8 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
@@ -490,7 +493,8 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -538,7 +542,8 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
 
@@ -597,7 +602,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
@@ -745,7 +750,8 @@
   {
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false);
+/*SnippetCompletions=*/false,
+EmptyLogger::getInstance());
 
 // Prepare some random distributions for the test.
 std::random_device RandGen;
Index: clangd/Logger.h
===
--- /dev/null
+++ clangd/Logger.h
@@ -0,0 +1,41 @@
+//===--- Logger.h - Logger interface for clangd --*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTR

[PATCH] D37973: [clang-format] Fix regression about short functions after #else

2017-09-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: klimek.

This patch fixes a regression introduced in r312904, where the formatter 
confuses
the `else` in `#else` with an `else` of an `if-else` statement.
For example, formatting this code with google style

  #ifdef A
  int f() {}
  #else
  int f() {}
  #endif

resulted in

  #ifdef A
  int f() {}
  #else
  int f() {
  }
  #endif


https://reviews.llvm.org/D37973

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7102,6 +7102,16 @@
"}",
Style);
 }
+TEST_F(FormatTest, KeepShortFunctionAfterPPElse) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  verifyFormat("#ifdef A\n"
+   "int f() {}\n"
+   "#else\n"
+   "int g() {}\n"
+   "#endif",
+   Style);
+}
 
 TEST_F(FormatTest, SplitEmptyClass) {
   FormatStyle Style = getLLVMStyle();
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -466,8 +466,7 @@
 // Check that the current line allows merging. This depends on whether we
 // are in a control flow statements as well as several style flags.
 if (Line.First->isOneOf(tok::kw_else, tok::kw_case) ||
-(Line.First->Next && Line.First->Next->is(tok::kw_else)) ||
-(I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else)))
+(Line.First->Next && Line.First->Next->is(tok::kw_else)))
   return 0;
 if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try,
 tok::kw___try, tok::kw_catch, tok::kw___finally,


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7102,6 +7102,16 @@
"}",
Style);
 }
+TEST_F(FormatTest, KeepShortFunctionAfterPPElse) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  verifyFormat("#ifdef A\n"
+   "int f() {}\n"
+   "#else\n"
+   "int g() {}\n"
+   "#endif",
+   Style);
+}
 
 TEST_F(FormatTest, SplitEmptyClass) {
   FormatStyle Style = getLLVMStyle();
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -466,8 +466,7 @@
 // Check that the current line allows merging. This depends on whether we
 // are in a control flow statements as well as several style flags.
 if (Line.First->isOneOf(tok::kw_else, tok::kw_case) ||
-(Line.First->Next && Line.First->Next->is(tok::kw_else)) ||
-(I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else)))
+(Line.First->Next && Line.First->Next->is(tok::kw_else)))
   return 0;
 if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try,
 tok::kw___try, tok::kw_catch, tok::kw___finally,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37976: [docs][refactor] add refactoring engine design documentation

2017-09-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch adds a refactoring engine design document that talks about the 
design and provides several example of how the engine can be used.


Repository:
  rL LLVM

https://reviews.llvm.org/D37976

Files:
  docs/RefactoringEngine.rst
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -60,6 +60,7 @@
LibASTMatchers
HowToSetupToolingForLLVM
JSONCompilationDatabase
+   RefactoringEngine
 
 Using Clang Tools
 =
Index: docs/RefactoringEngine.rst
===
--- /dev/null
+++ docs/RefactoringEngine.rst
@@ -0,0 +1,253 @@
+==
+Clang's refactoring engine
+==
+
+This document describes the design of Clang's refactoring engine and provides
+a couple of examples that show how various primitives in the refactoring API
+can be used to implement different refactoring actions. The :doc:`LibTooling`
+library provides several other APIs that are used when developing a
+refactoring action.
+
+Refactoring engine can be used to implement local refactorings that are
+initiated using a selection in an editor or an IDE. You can combine
+:doc:`LibASTMatchers` and the refactoring engine to implement
+refactorings that don't lend themselves well to source selection and/or have to
+query ASTs for some particular nodes.
+
+We assume basic knowledge about the Clang AST. See the :doc:`Introduction
+to the Clang AST ` if you want to learn more
+about how the AST is structured.
+
+..  FIXME: create new refactoring action tutorial and link to the tutorial
+
+Introduction
+
+
+Clang's refactoring engine defines a set refactoring actions that implement
+a number of different source transformations. The ``clang-refactor``
+command-line tool can be used to perform these refactorings. Certain
+refactorings are also available in other clients like text editors and IDEs.
+
+A refactoring action is a class that defines a list of related refactoring
+operations (rules). These rules are grouped under a common umbrella - a single
+``clang-refactor`` subcommand. In addition to rules, the refactoring action
+provides the action's command name and description to ``clang-refactor``.
+Each action must implement the ``RefactoringAction`` interface. Here's an
+outline of a ``local-rename`` action:
+
+```
+class LocalRename final : public RefactoringAction {
+public:
+  StringRef getCommand() const override { return "local-rename"; }
+
+  StringRef getDescription() const override {
+return "Finds and renames symbols in code with no indexer support";
+  }
+
+  RefactoringActionRules createActionRules() const override {
+...
+  }
+};
+```
+
+Refactoring Action Rules
+
+
+An individual refactoring action is responsible for creating the set of
+grouped refactoring action rules that represent one refactoring operation.
+Although the rules in one action may have a number of different implementations,
+they should strive to produce a similar result. It should be easy for users to
+identify which refactoring action produced the result regardless of which
+refactoring action rule was used.
+
+The distinction between actions and rules enables the creation of actions
+that define a set of different rules that produce similar results. For example,
+the "add missing switch cases" refactoring operation typically adds missing
+cases to one switch at a time. However, it could be useful to have a
+refactoring that works on all switches that operate on a particular enum, as
+one could then automatically update all of them after adding a new enum
+constant. To achieve that, we can create two different rules that will use one
+``clang-refactor`` subcommand. The first rule will describe a local operation
+that's initiated when the user selects a single switch. The second rule will
+describe a global operation that works across translation units and is initiated
+when the user provides the name of the enum to clang-refactor (or the user could
+select the enum declaration instead). The clang-refactor tool will then analyze
+the selection and other options passed to the refactoring action, and will pick
+the most appropriate rule for the given selection and other options.
+
+Rule Types
+^^
+
+Clang's refactoring engine supports several different refactoring rules:
+
+- ``SourceChangeRefactoringRule`` produces source replacements that are applied
+  to the source files. Subclasses that choose to implement this rule have to
+  implement the ``createSourceReplacements`` member function. This type of
+  rule is typically used to implement local refactorings that transform the
+  source in one translation unit only.
+
+- ``FindSymbolOccurrencesRefactoringRule`` produces a "partial" refactoring
+  result: a set of occurrences that refer to a particular symbol. This type
+  of r

[PATCH] D37023: [analyzer] Fix bugreporter::getDerefExpr() again.

2017-09-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Any news here? I'm wondering mainly because this patch is supposed to fix 
https://bugs.llvm.org/show_bug.cgi?id=34373.


https://reviews.llvm.org/D37023



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


[PATCH] D37972: [clangd] Introduced Logger interface.

2017-09-18 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Looks very nice! Just a few questions.




Comment at: clangd/ClangdServer.h:24
 #include "ClangdUnit.h"
+#include "Logger.h"
 #include "Protocol.h"

forward declare?



Comment at: clangd/ClangdUnit.h:13
 
+#include "Logger.h"
 #include "Path.h"

forward declare?



Comment at: clangd/GlobalCompilationDatabase.cpp:88
   if (!Error.empty()) {
-// FIXME(ibiryukov): logging
-// Output.log("Error when trying to load compilation database from " +
-//Twine(Path) + ": " + Twine(Error) + "\n");
+Logger.log("Error when trying to load compilation database from " +
+   Path + ": " + Twine(Error) + "\n");

Will this log for every parent folder that doesn't contain the compilation 
database? I haven't tried to confirm. Just wondering because it could get very 
spammy.



Comment at: clangd/GlobalCompilationDatabase.h:13
 
+#include "Logger.h"
 #include "Path.h"

forward declare instead?


https://reviews.llvm.org/D37972



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


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

2017-09-18 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik added a comment.

There wasn't any update on this check lately - can I help to make it better?


https://reviews.llvm.org/D33722



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


[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-18 Thread Zbigniew Sarbinowski via Phabricator via cfe-commits
zibi updated this revision to Diff 115643.
zibi added a comment.

Addressing the review.


https://reviews.llvm.org/D37861

Files:
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Preprocessor/pragma_assume_nonnull.c


Index: test/Preprocessor/pragma_assume_nonnull.c
===
--- test/Preprocessor/pragma_assume_nonnull.c
+++ test/Preprocessor/pragma_assume_nonnull.c
@@ -1,23 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -E %s | FileCheck %s
 
-#ifndef NS_ASSUME_NONNULL_BEGIN
-#if __has_feature(assume_nonnull)
-#define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
-#define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
-#else
-#define NS_ASSUME_NONNULL_BEGIN
-#define NS_ASSUME_NONNULL_END
-#endif
-#endif
-
 // CHECK: #pragma clang assume_nonnull begin
-NS_ASSUME_NONNULL_BEGIN
+#pragma clang assume_nonnull begin
 
 int bar(int * ip) { return *ip; }
 
 // CHECK: #pragma clang assume_nonnull end
-NS_ASSUME_NONNULL_END
+#pragma clang assume_nonnull end
 
 int foo(int * _Nonnull ip) { return *ip; }
 
@@ -28,4 +18,3 @@
return bar(0) + foo(0); // expected-warning {{null passed to a callee that 
requires a non-null argument}}
 #endif
 }
-
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -555,15 +555,15 @@
 PragmaAssumeNonNullBegin(SourceLocation Loc) {
   startNewLineIfNeeded();
   MoveToLine(Loc);
-  OS << "#pragma " << "clang assume_nonnull begin";
+  OS << "#pragma clang assume_nonnull begin";
   setEmittedDirectiveOnThisLine();
 }
 
 void PrintPPOutputPPCallbacks::
 PragmaAssumeNonNullEnd(SourceLocation Loc) {
   startNewLineIfNeeded();
   MoveToLine(Loc);
-  OS << "#pragma " << "clang assume_nonnull end";
+  OS << "#pragma clang assume_nonnull end";
   setEmittedDirectiveOnThisLine();
 }
 


Index: test/Preprocessor/pragma_assume_nonnull.c
===
--- test/Preprocessor/pragma_assume_nonnull.c
+++ test/Preprocessor/pragma_assume_nonnull.c
@@ -1,23 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -E %s | FileCheck %s
 
-#ifndef NS_ASSUME_NONNULL_BEGIN
-#if __has_feature(assume_nonnull)
-#define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
-#define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
-#else
-#define NS_ASSUME_NONNULL_BEGIN
-#define NS_ASSUME_NONNULL_END
-#endif
-#endif
-
 // CHECK: #pragma clang assume_nonnull begin
-NS_ASSUME_NONNULL_BEGIN
+#pragma clang assume_nonnull begin
 
 int bar(int * ip) { return *ip; }
 
 // CHECK: #pragma clang assume_nonnull end
-NS_ASSUME_NONNULL_END
+#pragma clang assume_nonnull end
 
 int foo(int * _Nonnull ip) { return *ip; }
 
@@ -28,4 +18,3 @@
return bar(0) + foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
 #endif
 }
-
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -555,15 +555,15 @@
 PragmaAssumeNonNullBegin(SourceLocation Loc) {
   startNewLineIfNeeded();
   MoveToLine(Loc);
-  OS << "#pragma " << "clang assume_nonnull begin";
+  OS << "#pragma clang assume_nonnull begin";
   setEmittedDirectiveOnThisLine();
 }
 
 void PrintPPOutputPPCallbacks::
 PragmaAssumeNonNullEnd(SourceLocation Loc) {
   startNewLineIfNeeded();
   MoveToLine(Loc);
-  OS << "#pragma " << "clang assume_nonnull end";
+  OS << "#pragma clang assume_nonnull end";
   setEmittedDirectiveOnThisLine();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-18 Thread Zbigniew Sarbinowski via Phabricator via cfe-commits
zibi marked 2 inline comments as done.
zibi added a comment.

Good catch, thank you. I submitted a new patch.


https://reviews.llvm.org/D37861



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


[PATCH] D37972: [clangd] Introduced Logger interface.

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

Addressed review comments.

- Replaced include with forward declaration in headers.
- Removed logging on each call to loadFromDirectory.


https://reviews.llvm.org/D37972

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/JSONRPCDispatcher.h
  clangd/Logger.cpp
  clangd/Logger.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ClangdServer.h"
+#include "Logger.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "llvm/ADT/SmallVector.h"
@@ -302,7 +303,8 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false);
+/*SnippetCompletions=*/false,
+EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
@@ -365,7 +367,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -410,7 +412,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -457,7 +459,8 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
@@ -490,7 +493,8 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -538,7 +542,8 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
 
@@ -597,7 +602,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
@@ -745,7 +750,8 @@
   {
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false);
+/*SnippetCompletions=*/false,
+EmptyLogger::getInstance());
 
 // Prepare some random distributions for the test.
 std::random_device RandGen;
Index: clangd/Logger.h
===
--- /dev/null
+++ clangd/Logger.h
@@ -0,0 +1,41 @@
+//===--- Logger.h - Logger interface for clangd --*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// Licens

[PATCH] D37972: [clangd] Introduced Logger interface.

2017-09-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:88
   if (!Error.empty()) {
-// FIXME(ibiryukov): logging
-// Output.log("Error when trying to load compilation database from " +
-//Twine(Path) + ": " + Twine(Error) + "\n");
+Logger.log("Error when trying to load compilation database from " +
+   Path + ": " + Twine(Error) + "\n");

malaperle wrote:
> Will this log for every parent folder that doesn't contain the compilation 
> database? I haven't tried to confirm. Just wondering because it could get 
> very spammy.
You're totally right, it's incredibly spammy. I've removed logging from this 
line.
Thanks for the finding!


https://reviews.llvm.org/D37972



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


[clang-tools-extra] r313536 - [clangd] Fix codeAction not decoded properly when sent from some clients

2017-09-18 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Mon Sep 18 08:02:59 2017
New Revision: 313536

URL: http://llvm.org/viewvc/llvm-project?rev=313536&view=rev
Log:
[clangd] Fix codeAction not decoded properly when sent from some clients

Summary:
Fix for bug https://bugs.llvm.org/show_bug.cgi?id=34559
Also log unknown fields instead of aborting the JSON parsing because it's
common that new optional fields are added either in new versions of the protocol
or extensions.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/test/clangd/fixits.test

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=313536&r1=313535&r2=313536&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Mon Sep 18 08:02:59 2017
@@ -13,13 +13,22 @@
 
//===--===//
 
 #include "Protocol.h"
+#include "JSONRPCDispatcher.h"
+
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang::clangd;
 
+namespace {
+void logIgnoredField(llvm::StringRef KeyValue, JSONOutput &Output) {
+  Output.log(llvm::formatv("Ignored unknown field \"{0}\"\n", KeyValue));
+}
+} // namespace
+
 URI URI::fromUri(llvm::StringRef uri) {
   URI Result;
   Result.uri = uri;
@@ -55,7 +64,8 @@ URI URI::parse(llvm::yaml::ScalarNode *P
 std::string URI::unparse(const URI &U) { return "\"" + U.uri + "\""; }
 
 llvm::Optional
-TextDocumentIdentifier::parse(llvm::yaml::MappingNode *Params) {
+TextDocumentIdentifier::parse(llvm::yaml::MappingNode *Params,
+  JSONOutput &Output) {
   TextDocumentIdentifier Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -74,13 +84,14 @@ TextDocumentIdentifier::parse(llvm::yaml
 } else if (KeyValue == "version") {
   // FIXME: parse version, but only for VersionedTextDocumentIdentifiers.
 } else {
-  return llvm::None;
+  logIgnoredField(KeyValue, Output);
 }
   }
   return Result;
 }
 
-llvm::Optional Position::parse(llvm::yaml::MappingNode *Params) {
+llvm::Optional Position::parse(llvm::yaml::MappingNode *Params,
+ JSONOutput &Output) {
   Position Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -106,7 +117,7 @@ llvm::Optional Position::parse
 return llvm::None;
   Result.character = Val;
 } else {
-  return llvm::None;
+  logIgnoredField(KeyValue, Output);
 }
   }
   return Result;
@@ -119,7 +130,8 @@ std::string Position::unparse(const Posi
   return Result;
 }
 
-llvm::Optional Range::parse(llvm::yaml::MappingNode *Params) {
+llvm::Optional Range::parse(llvm::yaml::MappingNode *Params,
+   JSONOutput &Output) {
   Range Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -135,17 +147,17 @@ llvm::Optional Range::parse(llvm:
 
 llvm::SmallString<10> Storage;
 if (KeyValue == "start") {
-  auto Parsed = Position::parse(Value);
+  auto Parsed = Position::parse(Value, Output);
   if (!Parsed)
 return llvm::None;
   Result.start = std::move(*Parsed);
 } else if (KeyValue == "end") {
-  auto Parsed = Position::parse(Value);
+  auto Parsed = Position::parse(Value, Output);
   if (!Parsed)
 return llvm::None;
   Result.end = std::move(*Parsed);
 } else {
-  return llvm::None;
+  logIgnoredField(KeyValue, Output);
 }
   }
   return Result;
@@ -168,7 +180,7 @@ std::string Location::unparse(const Loca
 }
 
 llvm::Optional
-TextDocumentItem::parse(llvm::yaml::MappingNode *Params) {
+TextDocumentItem::parse(llvm::yaml::MappingNode *Params, JSONOutput &Output) {
   TextDocumentItem Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -195,13 +207,14 @@ TextDocumentItem::parse(llvm::yaml::Mapp
 } else if (KeyValue == "text") {
   Result.text = Value->getValue(Storage);
 } else {
-  return llvm::None;
+  logIgnoredField(KeyValue, Output);
 }
   }
   return Result;
 }
 
-llvm::Optional Metadata::parse(llvm::yaml::MappingNode *Params) {
+llvm::Optional Metadata::parse(llvm::yaml::MappingNode *Params,
+ JSONOutpu

[PATCH] D37978: [analyzer] Fix an assertion fail in VirtualCallChecker

2017-09-18 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.

This patch attempts to fix PR34451.

The `getBestDynamicClassType` call can only handle `RecordDecls` and pointers 
to `RecordDecls`. The code removed all the implicit casts, this includes the 
array to pointer decay. After removing the decay, the checker passed an array 
type to `getBestDynamicClassType` which triggered the assertion.


Repository:
  rL LLVM

https://reviews.llvm.org/D37978

Files:
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp


Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -271,3 +271,24 @@
 #if !PUREONLY
//expected-note-re@-2 2^}}Calling '~E'}}
 #endif
+
+namespace PR34451 {
+struct a {
+  void b() {
+a c[1];
+c->b();
+  }
+};
+
+class e {
+ public:
+  void b() const;
+};
+
+class c {
+  void m_fn2() const;
+  e d[];
+};
+
+void c::m_fn2() const { d->b(); }
+}
Index: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -146,7 +146,7 @@
 if (CME->getQualifier())
   CallIsNonVirtual = true;
 
-if (const Expr *Base = CME->getBase()->IgnoreImpCasts()) {
+if (const Expr *Base = CME->getBase()) {
   // The most derived class is marked final.
   if (Base->getBestDynamicClassType()->hasAttr())
 CallIsNonVirtual = true;


Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -271,3 +271,24 @@
 #if !PUREONLY
 	//expected-note-re@-2 2^}}Calling '~E'}}
 #endif
+
+namespace PR34451 {
+struct a {
+  void b() {
+a c[1];
+c->b();
+  }
+};
+
+class e {
+ public:
+  void b() const;
+};
+
+class c {
+  void m_fn2() const;
+  e d[];
+};
+
+void c::m_fn2() const { d->b(); }
+}
Index: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -146,7 +146,7 @@
 if (CME->getQualifier())
   CallIsNonVirtual = true;
 
-if (const Expr *Base = CME->getBase()->IgnoreImpCasts()) {
+if (const Expr *Base = CME->getBase()) {
   // The most derived class is marked final.
   if (Base->getBestDynamicClassType()->hasAttr())
 CallIsNonVirtual = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35743: [clang-format] Handle Structured binding declaration in C++17

2017-09-18 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D35743#841197, @chh wrote:

> Daniel, Manuel, I will take over this CL since Yan has finished his 
> internship at Google.,
>  Yan's latest patch to tryToParseLambda looks acceptable to me.
>  I think it should take care of new kw_auto in additional to kw_new, 
> ke_delete, etc.
>
> Could you suggest if there is any better way to handle the new syntax?


An alternative would be to look for auto (&&?)? [ with look-ahead, but I agree 
that this fits the "we try to parse a lambda introducer with look-behind" 
strategy we've so far been taking, so I'm fine with this approach.


https://reviews.llvm.org/D35743



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


[PATCH] D37980: [clang-format] Better parsing of lambda captures with initializer expressions.

2017-09-18 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.

This fixes bug #19986 (https://bugs.llvm.org/show_bug.cgi?id=19986).
The code was incorrectly formatted to (mind additional spaces inside brackets) 
when lambda capture contained an initializer expression.
This patch does not handle all possible initializers, but the most common once.
To handle these resting cases, we'd have to parse the whole initializer 
expressions or handle lambda detection differently.

Before:

  int i = 100;
  auto f1 = [ i, value = 23 ]() { return i + value; };
  auto f2 = [ i, value{23} ]() { return i + value; };

After:

  int i = 100;
  auto f1 = [i, value = 23]() { return i + value; };
  auto f2 = [i, value{23}]() { return i + value; };


https://reviews.llvm.org/D37980

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1413,7 +1413,7 @@
   verifyFormat("typedef enum {} EmptyEnum;");
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum {\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -1425,7 +1425,7 @@
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum\n"
"{\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -1574,8 +1574,8 @@
   Style.CompactNamespaces = true;
 
   verifyFormat("namespace A { namespace B {\n"
-			   "}} // namespace A::B",
-			   Style);
+   "}} // namespace A::B",
+   Style);
 
   EXPECT_EQ("namespace out { namespace in {\n"
 "}} // namespace out::in",
@@ -3428,22 +3428,22 @@
   verifyFormat(
   "SomeClass::Constructor() :\n"
   "a(aa), aaa() {}",
-	  Style);
+  Style);
 
   verifyFormat(
   "SomeClass::Constructor() :\n"
   "a(aa), a(aa),\n"
   "a(aa) {}",
-	  Style);
+  Style);
   verifyFormat(
   "SomeClass::Constructor() :\n"
   "aa(aa),\n"
   "aaa() {}",
-	  Style);
+  Style);
   verifyFormat("Constructor(aa ,\n"
"aa ) :\n"
"aa(aa) {}",
-			   Style);
+   Style);
 
   verifyFormat("Constructor() :\n"
"(aaa),\n"
@@ -3450,17 +3450,17 @@
"(aaa,\n"
" aaa),\n"
"aaa() {}",
-			   Style);
+   Style);
 
   verifyFormat("Constructor() :\n"
"(\n"
"a) {}",
-			   Style);
+   Style);
 
   verifyFormat("Constructor(int Parameter = 0) :\n"
"aa(a),\n"
"(a) {}",
-			   Style);
+   Style);
   verifyFormat("Constructor() :\n"
"aa(a), (b) {\n"
"}",
@@ -3468,7 +3468,7 @@
   verifyFormat("Constructor() :\n"
"a(\n"
"a(, )) {}",
-			   Style);
+   Style);
 
   // Here a line could be saved by splitting the second initializer onto two
   // lines, but that is not desirable.
@@ -3476,7 +3476,7 @@
"(),\n"
"aaa(aaa),\n"
"at() {}",
-			   Style);
+   Style);
 
   FormatStyle OnePerLine = Style;
   OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
@@ -3526,7 +3526,7 @@
 format("Constructor() :\n"
"// Comment forcing unwanted break.\n"
"() {}",
-   Style));
+   Style));
 
   Style.ColumnLimit = 0;
   verifyFormat("SomeClass::Constructor() :\n"
@@ -3536,7 +3536,7 @@
"a(a) {}",
Style);
   verifyFormat("SomeClass::Constructor() :\n"
-			   "a(a), b(b), c(c) {}",
+   "a(a), b(b), c

[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Could you please move the test that adds a namespace end comment to 
`unittests/Format/NamespaceEndCommentsFixerTest.cpp`?


https://reviews.llvm.org/D37904



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


[PATCH] D37978: [analyzer] Fix an assertion fail in VirtualCallChecker

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

Looks reasonable, but please wait for someone who actually knows this code.


Repository:
  rL LLVM

https://reviews.llvm.org/D37978



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


[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-18 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In https://reviews.llvm.org/D37904#873860, @krasimir wrote:

> Could you please move the test that adds a namespace end comment to 
> `unittests/Format/NamespaceEndCommentsFixerTest.cpp`?


That's what I wanted to do initially, but the very same tests there passed 
surprisingly. I think that there are some differences related to "messing up" 
the code between both test suites.
I'll have another look at it however.


https://reviews.llvm.org/D37904



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


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D37822#872446, @yaxunl wrote:

> In https://reviews.llvm.org/D37822#872291, @Anastasia wrote:
>
> > Could you please explain a bit more why the alignment have to be put 
> > explicitly in the struct? I am just not very convinced this is general 
> > enough.
>
>
> The captured variables are fields of the block literal struct. Due to 
> alignment requirement of these fields, there is alignment requirement of
>  the block literal struct. The ISA of the block invoke function is generated 
> with the assumption of these alignments. If the block literal is
>  allocated at a memory address not satisfying the alignment requirement, the 
> kernel behavior is undefined.
>
> Generally, __enqueue_kernel library function needs to prepare the kernel 
> argument before launching the kernel. It usually does this by copying
>  the block literal to some buffer then pass the address of the buffer to the 
> kernel. Then the address of the buffer has to satisfy the alignment
>  requirement.
>
> If this block literal struct is not general enough, how about add another 
> field as target reserved size, and leave the remaining space of header for
>  target specific use. And add a target hook to allow target fill the reserved 
> space, e.g.
>
>   struct __opencl_block_literal {
> int total_size;
> int align;
> __generic void *invoke;
> int target_reserved_size; /* round up to 4 bytes */
> int target_reserved[];
> /* captures */
>   };
>


I like the idea of the target reserved part actually. But not sure how it could 
be used without adding any target specific methods?

However, I am still not clear why the alignment of this struct has to be 
different from any other struct Clang produces. Normally the alignment of 
objects have to be known during IR generation to put them correctly in the 
attributes of generated alloca, store and loads. But as a field inside struct I 
don't know how it can be useful. I would imagine `enqueue_kernel` would just 
operate on the block as if it would be an arbitrary buffer of data. Also would 
size of the struct not account for any padding to make sure the alignment can 
be deduced based on it correctly?




Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:108
+llvm::PointerType *CGOpenCLRuntime::getGenericVoidPointerType() {
+  return llvm::IntegerType::getInt8PtrTy(
+  CGM.getLLVMContext(),

Should we put an assert of LangOpts.OpenCL?



Comment at: test/CodeGen/blocks-opencl.cl:1
 // RUN: %clang_cc1 -O0 %s -ffake-address-space-map -emit-llvm -o - -fblocks 
-triple x86_64-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 -O0 %s -emit-llvm -o - -fblocks -triple amdgcn | FileCheck 
%s

Btw, do you think we need this test any more? And if yes, could this be moved 
to CodeGenOpenCL?


https://reviews.llvm.org/D37822



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


[PATCH] D37912: [OpenMP] Bugfix: output file name drops the absolute path where full path is needed.

2017-09-18 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115667.
gtbercea added a reviewer: hfinkel.

Repository:
  rL LLVM

https://reviews.llvm.org/D37912

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -89,7 +89,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" 
"{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -99,7 +99,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
 
-// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" 
"{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,7 +438,7 @@
 if (!II.isFilename())
   continue;
 
-SmallString<256> Name = llvm::sys::path::filename(II.getFilename());
+SmallString<256> Name = StringRef(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");
 
 const char *CubinF =


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -89,7 +89,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
@@ -99,7 +99,7 @@
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
 
-// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
+// CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
 
 /// ###
 
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,7 +438,7 @@
 if (!II.isFilename())
   continue;
 
-SmallString<256> Name = llvm::sys::path::filename(II.getFilename());
+SmallString<256> Name = StringRef(II.getFilename());
 llvm::sys::path::replace_extension(Name, "cubin");
 
 const char *CubinF =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR

2017-09-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D37668



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


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-18 Thread Philipp via Phabricator via cfe-commits
phst added a comment.

Thanks, generally looks good, but a couple of notes:

- This is actually a bug in clang-format, which can easily be triggered with 
`clang-format -output-replacements-xml -assume-filename '' -offset 0 -length 10 
-cursor 5 <<< ' = 1234;'`

  It's fine to work around bugs, but please file a bug against clang-format 
itself and reference it in a comment.

- Not sure whether the `assume-filename` parameter is actually needed. If 
there's no known use case, please don't add it ("YAGNI").

- Prefer quoting function symbols with `#'`: `#'call-process-region`. The 
byte-compiler will then warn if such a symbol is not defined as a function.

- It's more readable to write the non-varying arguments to call-process-region 
as direct arguments to `apply`, like so: `(apply #'call-process-region nil ... 
nil (append '("-output-replacements ...`. The result is equivalent, but this 
structure makes it more obvious which arguments are positional and which are 
rest arguments.

- You can combine the various lists with backquotes and get rid of `append`: 
``("-output-replacements-xml" ,@(and buffer-file-name (list (concat 
"-assume-filename=" buffer-file-name))) "-style" ...)`


https://reviews.llvm.org/D37903



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


[PATCH] D37958: [libc++] Correctly propagate user-defined lookup_classname().

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



Comment at: 
libcxx/test/std/re/re.traits/lookup_classname_user_defined.pass.cpp:46
+// matches all characters (they are classified as alnum)
+std::wstring re1 = L"([[:alnum:]]+)";
+std::regex_search(in, m, std::wregex(re1));

timshen wrote:
> Quuxplusone wrote:
> > Could you add a test here for
> > 
> > std::wstring re3 = L"([[:ALNUM:]]+)";
> > std::regex_search(in, m, std::wregex(re3, std::regex_constants::icase));
> > 
> > std::wstring re4 = L"(\\W+)";
> > std::regex_search(in, m, std::wregex(re4, std::regex_constants::icase));
> > 
> > documenting the expected outputs?  It's unclear to me from cppreference
> > http://en.cppreference.com/w/cpp/regex/regex_traits/lookup_classname
> > whether lookup_classname("W") is supposed to produce a result or not (but 
> > you seem to assume it does).
> > 
> > My understanding is that the "icase" parameter to lookup_classname is 
> > talking about the icaseness of the regex matcher; classnames should always 
> > be matched with exact case, i.e. `[[:alnum:]]` is always a valid classname 
> > and `[[:ALNUM:]]` is always invalid, regardless of regex_constants::icase. 
> > But I'm not sure.
> [re.req] says that, for lookup_classname(), "The value returned shall be 
> independent of the case of the characters in the sequence."
> 
> I take it as regardless of lookup_classname()'s icase argument, [[:ALNUM:]] 
> is always valid.
> 
> There are existing tests that confirms it in 
> std/re/re.traits/lookup_classname.pass.cpp. Search for "AlNum".
> 
> I fixed my patch, since I was misunderstanding it as well (I thought icase is 
> for the input char sequence). Now they are just forwarded into 
> lookup_classname().
> [re.req] says that, for lookup_classname(), "The value returned shall be 
> independent of the case of the characters in the sequence."

Huh. That seems like a defect in the Standard, since although 
lookup_classname() is parameterized on a locale, there is no standard way to 
get case-insensitive string comparison out of an arbitrary locale AFAIK. 
However, that's a problem for the implementer of lookup_classname(), not for 
you. Forwarding straight to lookup_classname() and letting it deal with 
questions of "case" sounds like the right approach to me.

If you *wanted* to go down this rabbit hole, a good test case would be 
`"[[:DIGIT:]]"` in Turkish locale (where lowercasing `"[[:DIGIT:]]"` produces 
`"[[:dıgıt:]]"` not `"[[:digit:]]"`).

(Note— The only place I find "case-insensitive" in N4659 is in the informative 
note on `time_get::get`: "It is unspecified by what means the function performs 
case-insensitive comparison or whether multi-character sequences are considered 
while doing so." —end note)


https://reviews.llvm.org/D37958



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


[PATCH] D37913: [OpenMP] Enable the existing nocudalib flag for OpenMP offloading toolchain.

2017-09-18 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115692.
gtbercea added a comment.

Add test.


Repository:
  rL LLVM

https://reviews.llvm.org/D37913

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -125,3 +125,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib flag is used.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target -march=sm_99 -nocudalib -fopenmp-relocatable-target -save-temps 
-no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
+
+// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -253,7 +253,8 @@
 
   // Obtain architecture from the action.
   CudaArch gpu_arch = StringToCudaArch(GPUArchName);
-  assert(gpu_arch != CudaArch::UNKNOWN &&
+  assert((gpu_arch != CudaArch::UNKNOWN ||
+  Args.hasArg(options::OPT_nocudalib)) &&
  "Device action expected to have an architecture.");
 
   // Check that our installation's ptxas supports gpu_arch.
@@ -492,11 +493,11 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
-
-if (DriverArgs.hasArg(options::OPT_nocudalib))
-  return;
   }
 
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -125,3 +125,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib flag is used.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 -nocudalib -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
+
+// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -253,7 +253,8 @@
 
   // Obtain architecture from the action.
   CudaArch gpu_arch = StringToCudaArch(GPUArchName);
-  assert(gpu_arch != CudaArch::UNKNOWN &&
+  assert((gpu_arch != CudaArch::UNKNOWN ||
+  Args.hasArg(options::OPT_nocudalib)) &&
  "Device action expected to have an architecture.");
 
   // Check that our installation's ptxas supports gpu_arch.
@@ -492,11 +493,11 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
-
-if (DriverArgs.hasArg(options::OPT_nocudalib))
-  return;
   }
 
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-18 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 115697.
gtbercea added a comment.

Only check for -S.


Repository:
  rL LLVM

https://reviews.llvm.org/D37914

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -134,3 +134,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
 
 // CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_99
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib device is 
found when using -c -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -501,6 +501,10 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_S))
+  return;
+
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
 return;
   }


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -134,3 +134,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
 
 // CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_99
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib device is found when using -c -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_99
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -501,6 +501,10 @@
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+DriverArgs.hasArg(options::OPT_S))
+  return;
+
 getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-18 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: test/Driver/openmp-offload-gpu.c:133
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -c -S -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_99 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s

tra wrote:
> I'd have separate runs -- one with -S and another one with -c.
> 
> That would cover openMP compilation changes. There should also be similar 
> test to verify new behavior for CUDA compilation.
There is no new behaviour for CUDA actually, I only introduce this for OpenMP 
offloading.


Repository:
  rL LLVM

https://reviews.llvm.org/D37914



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


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-18 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 115703.
vlad.tsyrklevich added a comment.

Update documentation to mention sections in the blacklist documentation and in 
the CFI documentation (where it's most useful)


https://reviews.llvm.org/D37925

Files:
  docs/ControlFlowIntegrity.rst
  docs/SanitizerSpecialCaseList.rst
  include/clang/Basic/SanitizerBlacklist.h
  include/clang/Basic/SanitizerSpecialCaseList.h
  lib/AST/Decl.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/SanitizerBlacklist.cpp
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/XRayLists.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/Inputs/sanitizer-special-case-list.sanitized.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized1.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized2.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
  test/CodeGen/sanitizer-special-case-list.c
  test/CodeGenCXX/cfi-blacklist.cpp

Index: test/CodeGenCXX/cfi-blacklist.cpp
===
--- test/CodeGenCXX/cfi-blacklist.cpp
+++ test/CodeGenCXX/cfi-blacklist.cpp
@@ -1,6 +1,18 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
-// RUN: echo "type:std::*" > %t.txt
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting cfi and cfi-vcall work correctly
+// RUN: echo "[cfi-vcall]" > %t.vcall.txt
+// RUN: echo "type:std::*" >> %t.vcall.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+//
+// RUN: echo "[cfi]" > %t.cfi.txt
+// RUN: echo "type:std::*" >> %t.cfi.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting non-vcall modes does not affect vcalls
+// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
+// RUN: echo "type:std::*" >> %t.other.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
 
 struct S1 {
   virtual void f();
Index: test/CodeGen/sanitizer-special-case-list.c
===
--- /dev/null
+++ test/CodeGen/sanitizer-special-case-list.c
@@ -0,0 +1,26 @@
+// Verify that blacklist sections correctly select sanitizers to apply blacklist entries to.
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized1.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized2.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized3.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized4.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.sanitized.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=SANITIZED
+
+unsigned i;
+
+// SANITIZED: @overflow
+// UNSANITIZED: @overflow
+unsigned overflow() {
+  // SANITIZED: call {{.*}}void @__ubsan
+  // UNSANITIZED-NOT: call {{.*}}void @__ubsan
+  return i * 37;
+}
+
+// SANITIZED: @cfi
+// UNSANITIZED: @cfi
+void cfi(void (*fp)()) {
+  // SANITIZED: llvm.type.test
+  // UNSANITIZED-NOT: llvm.type.test
+  fp();
+}
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
===
--- /dev/null
+++ test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
@@ -0,0 +1,4 @@
+[c*]
+fun:*cfi*
+[u*]
+fun:*overflow*
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
===
-

[PATCH] D37994: Implement LWG2946: More ambiguity in `string` vs. `string_view`

2017-09-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

See https://wg21.link/lwg2946 for details.

This issue has not yet been adopted by WG21, but I implemented it to make sure 
that there were no problems in the proposed resolution.

It turns out that there was. Making these changes lost the ability to construct 
a `basic_string` (w/o template parameters) from a `string_view`; i.e, the 
implicit deduction guides were no longer sufficient.  So I added a couple of 
explicit deduction guides.

This will not be committed until after WG21 has approved this resolution.


https://reviews.llvm.org/D37994

Files:
  include/string
  test/std/strings/basic.string/string.cons/string_view.pass.cpp
  test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
  test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
  test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp

Index: test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.rfind({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_last_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 // test0();
 // test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_last_not_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_first_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_first_not_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find({"abc", 1}) == std::stri

[PATCH] D37995: [Docs] Document cache pruning support for gold

2017-09-18 Thread Yi Kong via Phabricator via cfe-commits
kongyi created this revision.
kongyi added a project: clang.
Herald added subscribers: eraman, mehdi_amini.

Feature implemented in https://reviews.llvm.org/D37993


Repository:
  rL LLVM

https://reviews.llvm.org/D37995

Files:
  docs/ThinLTO.rst


Index: docs/ThinLTO.rst
===
--- docs/ThinLTO.rst
+++ docs/ThinLTO.rst
@@ -142,9 +142,11 @@
 
 To help keep the size of the cache under control, ThinLTO supports cache
 pruning. Cache pruning is supported with ld64 and ELF and COFF lld, but
-currently only ELF and COFF lld allow you to control the policy with a
+currently only gold, ELF and COFF lld allow you to control the policy with a
 policy string. The cache policy must be specified with a linker option.
 
+- gold (as of LLVM 6.0):
+  ``-Wl,-plugin-opt,cache-policy=POLICY``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
 - COFF lld-link (as of LLVM 6.0):


Index: docs/ThinLTO.rst
===
--- docs/ThinLTO.rst
+++ docs/ThinLTO.rst
@@ -142,9 +142,11 @@
 
 To help keep the size of the cache under control, ThinLTO supports cache
 pruning. Cache pruning is supported with ld64 and ELF and COFF lld, but
-currently only ELF and COFF lld allow you to control the policy with a
+currently only gold, ELF and COFF lld allow you to control the policy with a
 policy string. The cache policy must be specified with a linker option.
 
+- gold (as of LLVM 6.0):
+  ``-Wl,-plugin-opt,cache-policy=POLICY``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
 - COFF lld-link (as of LLVM 6.0):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-18 Thread Galina Kistanova via cfe-commits
Hello Douglas,

Your r313316 commit broke one of our builders on Thursday, Sep-14th.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506

Are you about to commit the fix, or shall I revert that commit to give you
more time?

Thanks

Galina

On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dgregor
> Date: Thu Sep 14 16:38:44 2017
> New Revision: 313316
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313316&view=rev
> Log:
> [Module map] Introduce a private module re-export directive.
>
> Introduce a new "export_as" directive for top-level modules, which
> indicates that the current module is a "private" module whose symbols
> will eventually be exported through the named "public" module. This is
> in support of a common pattern in the Darwin ecosystem where a single
> public framework is constructed of several private frameworks, with
> (currently) header duplication and some support from the linker.
>
> Addresses rdar://problem/34438420.
>
> Added:
> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
> cfe/trunk/test/Modules/export_as_test.c
> Modified:
> cfe/trunk/docs/Modules.rst
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/Basic/Module.cpp
> cfe/trunk/lib/Lex/ModuleMap.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
>
> Modified: cfe/trunk/docs/Modules.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> Modules.rst?rev=313316&r1=313315&r2=313316&view=diff
> 
> ==
> --- cfe/trunk/docs/Modules.rst (original)
> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
> @@ -323,11 +323,12 @@ Module map files use a simplified form o
>
>  .. parsed-literal::
>
> -  ``config_macros`` ``export`` ``private``
> +  ``config_macros`` ``export_as``  ``private``
>``conflict``  ``framework``  ``requires``
>``exclude``   ``header`` ``textual``
>``explicit``  ``link``   ``umbrella``
>``extern````module`` ``use``
> +  ``export``
>
>  Module map file
>  ---
> @@ -387,6 +388,7 @@ Modules can have a number of different k
>  *umbrella-dir-declaration*
>  *submodule-declaration*
>  *export-declaration*
> +*export-as-declaration*
>  *use-declaration*
>  *link-declaration*
>  *config-macros-declaration*
> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>compatibility for programs that rely on transitive inclusion (i.e.,
>all of them).
>
> +Re-export Declaration
> +~~
> +An *export-as-declaration* specifies that the current module is a private
> +module whose interface will be re-exported by the named public module.
> +
> +.. parsed-literal::
> +
> +  *export-as-declaration*:
> +``export_as`` *identifier*
> +
> +The *export-as-declaration* names the public module that the current
> +(private) module will be re-exported through. Only top-level modules
> +can be re-exported, and any given module may only be re-exported
> +through a single public module.
> +
> +**Example:** In the following example, the (private) module
> +``MyFrameworkCore`` will be re-exported via the public module
> +``MyFramework``:
> +
> +.. parsed-literal::
> +
> +  module MyFrameworkCore {
> +export_as MyFramework
> +  }
> +
>  Use declaration
>  ~~~
>  A *use-declaration* specifies another module that the current top-level
> module
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticLexKinds.td?rev=313316&r1=313315&r2=313316&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Sep 14
> 16:38:44 2017
> @@ -674,6 +674,13 @@ def err_mmap_invalid_header_attribute_va
>"expected integer literal as value for header attribute '%0'">;
>  def err_mmap_expected_header_attribute : Error<
>"expected a header attribute name ('size' or 'mtime')">;
> +def err_mmap_conflicting_export_as : Error<
> +  "conflicting re-export of module '%0' as '%1' or '%2'">;
> +def warn_mmap_redundant_export_as : Warning<
> +  "module '%0' already re-exported as '%1'">,
> +  InGroup;
> +def err_mmap_submodule_export_as : Error<
> +  "only top-level modules can be re-exported as public">;
>
>  def warn_auto_module_import : Warning<
>"treating #%select{include|import|include_next|__include_macros}0 as
> an "
>
> Modified: cfe/trunk/include/clang/Basic/Module.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Module.h?rev=313316&r1=313315&r2=313316&view

[PATCH] D37865: [Sema] Fix a pair of crashes when generating exception specifiers with an error'ed field for a template class' default ctor.

2017-09-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping?  I Added the three of you because you were all on the git-blame list, but 
if you have better ideas on someone to review this, it would be appreciated.

-Erich


https://reviews.llvm.org/D37865



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


[PATCH] D35472: Implement P0463R1: "Endian just Endian"

2017-09-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 115714.
mclow.lists added a comment.

Fixed test and #ifdef guard


https://reviews.llvm.org/D35472

Files:
  include/type_traits
  test/std/utilities/meta/meta.type.synop/endian.pass.cpp


Index: test/std/utilities/meta/meta.type.synop/endian.pass.cpp
===
--- test/std/utilities/meta/meta.type.synop/endian.pass.cpp
+++ test/std/utilities/meta/meta.type.synop/endian.pass.cpp
@@ -0,0 +1,47 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+// enum class endian;
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+typedef std::endian E;
+static_assert(std::is_enum::value, "");
+
+// Check that E is a scoped enum by checking for conversions.
+typedef std::underlying_type::type UT;
+static_assert(!std::is_convertible::value, "");
+
+// test that the enumeration values exist
+static_assert( std::endian::little == std::endian::little );
+static_assert( std::endian::big== std::endian::big );
+static_assert( std::endian::native == std::endian::native );
+static_assert( std::endian::little != std::endian::big );
+
+//  Technically not required, but true on all existing machines
+static_assert( std::endian::native == std::endian::little || 
+   std::endian::native == std::endian::big );
+
+//  Try to check at runtime
+{
+uint32_t i = 0x01020304;
+char c[4];
+static_assert(sizeof(i) == sizeof(c));
+std::memcpy(c, &i, sizeof(c));
+
+assert ((c[0] == 1) == (std::endian::native == std::endian::big));
+}
+}
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -4738,6 +4738,21 @@
 
 #endif
 
+#if _LIBCPP_STD_VER > 17
+enum class endian
+{
+little = 0xDEAD,
+big= 0xFACE,
+#if _LIBCPP_LITTLE_ENDIAN
+native = little
+#elif _LIBCPP_BIG_ENDIAN
+native = big
+#else
+native = 0xCAFE
+#endif
+};
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 14


Index: test/std/utilities/meta/meta.type.synop/endian.pass.cpp
===
--- test/std/utilities/meta/meta.type.synop/endian.pass.cpp
+++ test/std/utilities/meta/meta.type.synop/endian.pass.cpp
@@ -0,0 +1,47 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+// enum class endian;
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+typedef std::endian E;
+static_assert(std::is_enum::value, "");
+
+// Check that E is a scoped enum by checking for conversions.
+typedef std::underlying_type::type UT;
+static_assert(!std::is_convertible::value, "");
+
+// test that the enumeration values exist
+static_assert( std::endian::little == std::endian::little );
+static_assert( std::endian::big== std::endian::big );
+static_assert( std::endian::native == std::endian::native );
+static_assert( std::endian::little != std::endian::big );
+
+//  Technically not required, but true on all existing machines
+static_assert( std::endian::native == std::endian::little || 
+   std::endian::native == std::endian::big );
+
+//  Try to check at runtime
+{
+uint32_t i = 0x01020304;
+char c[4];
+static_assert(sizeof(i) == sizeof(c));
+std::memcpy(c, &i, sizeof(c));
+
+assert ((c[0] == 1) == (std::endian::native == std::endian::big));
+}
+}
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -4738,6 +4738,21 @@
 
 #endif
 
+#if _LIBCPP_STD_VER > 17
+enum class endian
+{
+little = 0xDEAD,
+big= 0xFACE,
+#if _LIBCPP_LITTLE_ENDIAN
+native = little
+#elif _LIBCPP_BIG_ENDIAN
+native = big
+#else
+native = 0xCAFE
+#endif
+};
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 14
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37865: [Sema] Fix a pair of crashes when generating exception specifiers with an error'ed field for a template class' default ctor.

2017-09-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks like the correct fix, thanks!


https://reviews.llvm.org/D37865



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


[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

2017-09-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.

This is great with me.


https://reviews.llvm.org/D36431



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


[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It looks like you uploaded a diff against the previous version of the patch 
instead of trunk?


https://reviews.llvm.org/D37861



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


r313569 - [Sema] Fix a pair of crashes when generating exception specifiers with an

2017-09-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Sep 18 14:28:55 2017
New Revision: 313569

URL: http://llvm.org/viewvc/llvm-project?rev=313569&view=rev
Log:
[Sema] Fix a pair of crashes when generating exception specifiers with an
error'ed field for a template class' default ctor.

The two examples in the test would both cause a compiler assert when attempting
to calculate the exception specifier for the default constructor for the
template classes. The problem was that dependents of this function expect that
Field->getInClassInitializer (including canThrow) is not nullptr. However, if
the template's initializer has an error, exactly that situation happens.

This patch simply sets the field to be invalid.

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


Added:
cfe/trunk/test/SemaCXX/init-expr-crash.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=313569&r1=313568&r2=313569&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Sep 18 14:28:55 2017
@@ -12436,7 +12436,8 @@ ExprResult Sema::BuildCXXDefaultInitExpr
   assert(Pattern && "We must have set the Pattern!");
 }
 
-if (InstantiateInClassInitializer(Loc, Field, Pattern,
+if (!Pattern->hasInClassInitializer() ||
+InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field))) {
   // Don't diagnose this again.
   Field->setInvalidDecl();

Added: cfe/trunk/test/SemaCXX/init-expr-crash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/init-expr-crash.cpp?rev=313569&view=auto
==
--- cfe/trunk/test/SemaCXX/init-expr-crash.cpp (added)
+++ cfe/trunk/test/SemaCXX/init-expr-crash.cpp Mon Sep 18 14:28:55 2017
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
+
+// Test reproduces a pair of crashes that were caused by code attempting
+// to materialize a default constructor's exception specifier.
+
+template  struct A {
+  static T tab[];
+
+  const int M = UNDEFINED; // expected-error {{use of undeclared identifier}}
+
+  int main()
+  {
+A a;
+
+return 0;
+  }
+};
+
+template  struct B {
+  static T tab[];
+
+  // expected-error@+1 {{invalid application of 'sizeof' to an incomplete 
type}}
+  const int N = sizeof(B::tab) / sizeof(char);
+
+  int main()
+  {
+B b;
+
+return 0;
+  }
+};


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


[PATCH] D37865: [Sema] Fix a pair of crashes when generating exception specifiers with an error'ed field for a template class' default ctor.

2017-09-18 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313569: [Sema] Fix a pair of crashes when generating 
exception specifiers with an (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D37865?vs=115278&id=115726#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37865

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/init-expr-crash.cpp


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -12436,7 +12436,8 @@
   assert(Pattern && "We must have set the Pattern!");
 }
 
-if (InstantiateInClassInitializer(Loc, Field, Pattern,
+if (!Pattern->hasInClassInitializer() ||
+InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field))) {
   // Don't diagnose this again.
   Field->setInvalidDecl();
Index: cfe/trunk/test/SemaCXX/init-expr-crash.cpp
===
--- cfe/trunk/test/SemaCXX/init-expr-crash.cpp
+++ cfe/trunk/test/SemaCXX/init-expr-crash.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
+
+// Test reproduces a pair of crashes that were caused by code attempting
+// to materialize a default constructor's exception specifier.
+
+template  struct A {
+  static T tab[];
+
+  const int M = UNDEFINED; // expected-error {{use of undeclared identifier}}
+
+  int main()
+  {
+A a;
+
+return 0;
+  }
+};
+
+template  struct B {
+  static T tab[];
+
+  // expected-error@+1 {{invalid application of 'sizeof' to an incomplete 
type}}
+  const int N = sizeof(B::tab) / sizeof(char);
+
+  int main()
+  {
+B b;
+
+return 0;
+  }
+};


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -12436,7 +12436,8 @@
   assert(Pattern && "We must have set the Pattern!");
 }
 
-if (InstantiateInClassInitializer(Loc, Field, Pattern,
+if (!Pattern->hasInClassInitializer() ||
+InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field))) {
   // Don't diagnose this again.
   Field->setInvalidDecl();
Index: cfe/trunk/test/SemaCXX/init-expr-crash.cpp
===
--- cfe/trunk/test/SemaCXX/init-expr-crash.cpp
+++ cfe/trunk/test/SemaCXX/init-expr-crash.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
+
+// Test reproduces a pair of crashes that were caused by code attempting
+// to materialize a default constructor's exception specifier.
+
+template  struct A {
+  static T tab[];
+
+  const int M = UNDEFINED; // expected-error {{use of undeclared identifier}}
+
+  int main()
+  {
+A a;
+
+return 0;
+  }
+};
+
+template  struct B {
+  static T tab[];
+
+  // expected-error@+1 {{invalid application of 'sizeof' to an incomplete type}}
+  const int N = sizeof(B::tab) / sizeof(char);
+
+  int main()
+  {
+B b;
+
+return 0;
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-18 Thread Douglas Gregor via cfe-commits

> On Sep 18, 2017, at 1:45 PM, Galina Kistanova  wrote:
> 
> Hello Douglas,
> 
> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506
>  
> 
> 
> Are you about to commit the fix, or shall I revert that commit to give you 
> more time?

I’m unable to reproduce this issue, and it’s weirdly not hitting the other bots.

Is anyone able to reproduce this? The stack trace is… insufficient… to figure 
out what’s going on.

- Doug

> 
> Thanks
> 
> Galina
> 
> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: dgregor
> Date: Thu Sep 14 16:38:44 2017
> New Revision: 313316
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=313316&view=rev 
> 
> Log:
> [Module map] Introduce a private module re-export directive.
> 
> Introduce a new "export_as" directive for top-level modules, which
> indicates that the current module is a "private" module whose symbols
> will eventually be exported through the named "public" module. This is
> in support of a common pattern in the Darwin ecosystem where a single
> public framework is constructed of several private frameworks, with
> (currently) header duplication and some support from the linker.
> 
> Addresses rdar://problem/34438420.
> 
> Added:
> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
> cfe/trunk/test/Modules/export_as_test.c
> Modified:
> cfe/trunk/docs/Modules.rst
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/Basic/Module.cpp
> cfe/trunk/lib/Lex/ModuleMap.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> 
> Modified: cfe/trunk/docs/Modules.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316&r1=313315&r2=313316&view=diff
>  
> 
> ==
> --- cfe/trunk/docs/Modules.rst (original)
> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
> @@ -323,11 +323,12 @@ Module map files use a simplified form o
> 
>  .. parsed-literal::
> 
> -  ``config_macros`` ``export`` ``private``
> +  ``config_macros`` ``export_as``  ``private``
>``conflict``  ``framework``  ``requires``
>``exclude``   ``header`` ``textual``
>``explicit``  ``link``   ``umbrella``
>``extern````module`` ``use``
> +  ``export``
> 
>  Module map file
>  ---
> @@ -387,6 +388,7 @@ Modules can have a number of different k
>  *umbrella-dir-declaration*
>  *submodule-declaration*
>  *export-declaration*
> +*export-as-declaration*
>  *use-declaration*
>  *link-declaration*
>  *config-macros-declaration*
> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>compatibility for programs that rely on transitive inclusion (i.e.,
>all of them).
> 
> +Re-export Declaration
> +~~
> +An *export-as-declaration* specifies that the current module is a private
> +module whose interface will be re-exported by the named public module.
> +
> +.. parsed-literal::
> +
> +  *export-as-declaration*:
> +``export_as`` *identifier*
> +
> +The *export-as-declaration* names the public module that the current
> +(private) module will be re-exported through. Only top-level modules
> +can be re-exported, and any given module may only be re-exported
> +through a single public module.
> +
> +**Example:** In the following example, the (private) module
> +``MyFrameworkCore`` will be re-exported via the public module
> +``MyFramework``:
> +
> +.. parsed-literal::
> +
> +  module MyFrameworkCore {
> +export_as MyFramework
> +  }
> +
>  Use declaration
>  ~~~
>  A *use-declaration* specifies another module that the current top-level 
> module
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=313316&r1=313315&r2=313316&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Sep 14 16:38:44 
> 2017
> @@ -674,6 +674,13 @@ def err_mmap_invalid_header_attribute_va
>"expected integer literal as value for header attribute '%0'">;
>  def err_mmap_expected_hea

[libcxx] r313576 - Fix failing ASAN test

2017-09-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Sep 18 15:01:18 2017
New Revision: 313576

URL: http://llvm.org/viewvc/llvm-project?rev=313576&view=rev
Log:
Fix failing ASAN test

Modified:
libcxx/trunk/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp

Modified: libcxx/trunk/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp?rev=313576&r1=313575&r2=313576&view=diff
==
--- libcxx/trunk/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp Mon 
Sep 18 15:01:18 2017
@@ -11,5 +11,8 @@
 
 // Test exporting the symbol: "__cxa_deleted_virtual" in macosx
 
-struct S { virtual void f() = delete; };
-int main() { new S; }
+struct S { virtual void f() = delete; virtual ~S() {} };
+int main() {
+  S *s = new S;
+  delete s;
+}


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


Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-18 Thread Richard Smith via cfe-commits
On 18 September 2017 at 14:34, Douglas Gregor via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> On Sep 18, 2017, at 1:45 PM, Galina Kistanova 
> wrote:
>
> Hello Douglas,
>
> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-ubuntu-fast/builds/17506
>
> Are you about to commit the fix, or shall I revert that commit to give you
> more time?
>
>
> I’m unable to reproduce this issue, and it’s weirdly not hitting the other
> bots.
>
> Is anyone able to reproduce this? The stack trace is… insufficient… to
> figure out what’s going on.
>

I think that bot might be the only one with a target whose default C++
language mode is C++11.


> - Doug
>
>
> Thanks
>
> Galina
>
> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dgregor
>> Date: Thu Sep 14 16:38:44 2017
>> New Revision: 313316
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=313316&view=rev
>> Log:
>> [Module map] Introduce a private module re-export directive.
>>
>> Introduce a new "export_as" directive for top-level modules, which
>> indicates that the current module is a "private" module whose symbols
>> will eventually be exported through the named "public" module. This is
>> in support of a common pattern in the Darwin ecosystem where a single
>> public framework is constructed of several private frameworks, with
>> (currently) header duplication and some support from the linker.
>>
>> Addresses rdar://problem/34438420.
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
>> cfe/trunk/test/Modules/export_as_test.c
>> Modified:
>> cfe/trunk/docs/Modules.rst
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Basic/Module.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/Basic/Module.cpp
>> cfe/trunk/lib/Lex/ModuleMap.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>
>> Modified: cfe/trunk/docs/Modules.rst
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.
>> rst?rev=313316&r1=313315&r2=313316&view=diff
>> 
>> ==
>> --- cfe/trunk/docs/Modules.rst (original)
>> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
>> @@ -323,11 +323,12 @@ Module map files use a simplified form o
>>
>>  .. parsed-literal::
>>
>> -  ``config_macros`` ``export`` ``private``
>> +  ``config_macros`` ``export_as``  ``private``
>>``conflict``  ``framework``  ``requires``
>>``exclude``   ``header`` ``textual``
>>``explicit``  ``link``   ``umbrella``
>>``extern````module`` ``use``
>> +  ``export``
>>
>>  Module map file
>>  ---
>> @@ -387,6 +388,7 @@ Modules can have a number of different k
>>  *umbrella-dir-declaration*
>>  *submodule-declaration*
>>  *export-declaration*
>> +*export-as-declaration*
>>  *use-declaration*
>>  *link-declaration*
>>  *config-macros-declaration*
>> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>>compatibility for programs that rely on transitive inclusion (i.e.,
>>all of them).
>>
>> +Re-export Declaration
>> +~~
>> +An *export-as-declaration* specifies that the current module is a private
>> +module whose interface will be re-exported by the named public module.
>> +
>> +.. parsed-literal::
>> +
>> +  *export-as-declaration*:
>> +``export_as`` *identifier*
>> +
>> +The *export-as-declaration* names the public module that the current
>> +(private) module will be re-exported through. Only top-level modules
>> +can be re-exported, and any given module may only be re-exported
>> +through a single public module.
>> +
>> +**Example:** In the following example, the (private) module
>> +``MyFrameworkCore`` will be re-exported via the public module
>> +``MyFramework``:
>> +
>> +.. parsed-literal::
>> +
>> +  module MyFrameworkCore {
>> +export_as MyFramework
>> +  }
>> +
>>  Use declaration
>>  ~~~
>>  A *use-declaration* specifies another module that the current top-level
>> module
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticLexKinds.td?rev=313316&r1=313315&r2=313316&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Sep 14
>> 16:38:44 2017
>> @@ -674,6 +674,13 @@ def err_mmap_invalid_header_attribute_va
>>"expected integer literal as value for header attribute '%0'">;
>>  def err_mmap_expected_header_attribute : Error<
>>"expected a header attribute name ('size' or 'mtime')">;
>> +def err_mmap_conflict

r313579 - [lit] Update clang and lld to use new config helpers.

2017-09-18 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Mon Sep 18 15:26:48 2017
New Revision: 313579

URL: http://llvm.org/viewvc/llvm-project?rev=313579&view=rev
Log:
[lit] Update clang and lld to use new config helpers.

NFC intended here, this only updates clang and lld's lit configs
to use some helper functionality in the lit.llvm submodule.

Modified:
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=313579&r1=313578&r2=313579&view=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Mon Sep 18 15:26:48 2017
@@ -9,39 +9,18 @@ import tempfile
 import lit.formats
 import lit.util
 
+from lit.llvm import llvm_config
+
 # Configuration file for the 'lit' test runner.
 
 # name: The name of this test suite.
 config.name = 'Clang'
 
-# Tweak PATH for Win32
-if platform.system() == 'Windows':
-# Seek sane tools in directories and set to $PATH.
-path = getattr(config, 'lit_tools_dir', None)
-path = lit_config.getToolsPath(path,
-   config.environment['PATH'],
-   ['cmp.exe', 'grep.exe', 'sed.exe'])
-if path is not None:
-path = os.path.pathsep.join((path,
- config.environment['PATH']))
-config.environment['PATH'] = path
-
-# Choose between lit's internal shell pipeline runner and a real shell.  If
-# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
-use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
-if use_lit_shell:
-# 0 is external, "" is default, and everything else is internal.
-execute_external = (use_lit_shell == "0")
-else:
-# Otherwise we default to internal on Windows and external elsewhere, as
-# bash on Windows is usually very slow.
-execute_external = (not sys.platform in ['win32'])
-
 # testFormat: The test format to use to interpret tests.
 #
 # For now we require '&&' between commands, until they get globally killed and
 # the test runner updated.
-config.test_format = lit.formats.ShTest(execute_external)
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', '.ll', '.cl', 
'.s', '.S', '.modulemap', '.test', '.rs']
@@ -81,22 +60,16 @@ possibly_dangerous_env_vars = ['COMPILER
 # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
 if platform.system() != 'Windows':
 possibly_dangerous_env_vars.append('INCLUDE')
-for name in possibly_dangerous_env_vars:
-  if name in config.environment:
-del config.environment[name]
+
+llvm_config.clear_environment(possibly_dangerous_env_vars)
 
 # Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((
-config.clang_tools_dir, config.llvm_tools_dir, 
config.environment['PATH']))
-config.environment['PATH'] = path
-path = os.path.pathsep.join((config.llvm_shlib_dir, config.llvm_libs_dir,
-  config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
+llvm_config.with_environment('PATH', [config.llvm_tools_dir, 
config.clang_tools_dir], append_path=True)
+
+llvm_config.with_environment('LD_LIBRARY_PATH', [config.llvm_shlib_dir, 
config.llvm_libs_dir], append_path=True)
 
 # Propagate path to symbolizer for ASan/MSan.
-for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
-if symbolizer in os.environ:
-config.environment[symbolizer] = os.environ[symbolizer]
+llvm_config.with_system_environment(['ASAN_SYMBOLIZER_PATH', 
'MSAN_SYMBOLIZER_PATH'])
 
 # Discover the 'clang' and 'clangcc' to use.
 
@@ -151,7 +124,7 @@ def getClangBuiltinIncludeDir(clang):
 if not cmd.stdout:
   lit_config.fatal("Couldn't find the include dir for Clang ('%s')" % 
clang)
 dir = cmd.stdout.read().strip()
-if sys.platform in ['win32'] and execute_external:
+if sys.platform in ['win32'] and not llvm_config.use_lit_shell:
 # Don't pass dosish path separator to msys bash.exe.
 dir = dir.replace('\\', '/')
 # Ensure the result is an ascii string, across Python2.5+ - Python3.
@@ -295,18 +268,6 @@ if config.clang_staticanalyzer:
 if platform.system() not in ['FreeBSD']:
 config.available_features.add('crash-recovery')
 
-# Shell execution
-if execute_external:
-config.available_features.add('shell')
-
-# For tests that require Darwin to run.
-# This is used by debuginfo-tests/*block*.m and debuginfo-tests/foreach.m.
-if platform.system() in ['Darwin']:
-config.available_features.add('system-darwin')
-elif platform.system() in ['Windows']:
-# For tests that require Windows to run.
-config.available_features.add('system-windows')
-
 # ANSI escape sequences in non-dumb terminal
 if platform.system() n

Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-18 Thread Douglas Gregor via cfe-commits

> On Sep 18, 2017, at 3:11 PM, Richard Smith  wrote:
> 
> On 18 September 2017 at 14:34, Douglas Gregor via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
>> On Sep 18, 2017, at 1:45 PM, Galina Kistanova > > wrote:
>> 
>> Hello Douglas,
>> 
>> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17506
>>  
>> 
>> 
>> Are you about to commit the fix, or shall I revert that commit to give you 
>> more time?
> 
> I’m unable to reproduce this issue, and it’s weirdly not hitting the other 
> bots.
> 
> Is anyone able to reproduce this? The stack trace is… insufficient… to figure 
> out what’s going on.
> 
> I think that bot might be the only one with a target whose default C++ 
> language mode is C++11.

Hmm. It’s not the C++ RUN lines that are failing, though; it’s the default 
(Objective-C) one.

- Doug

>  
>   - Doug
> 
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: dgregor
>> Date: Thu Sep 14 16:38:44 2017
>> New Revision: 313316
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=313316&view=rev 
>> 
>> Log:
>> [Module map] Introduce a private module re-export directive.
>> 
>> Introduce a new "export_as" directive for top-level modules, which
>> indicates that the current module is a "private" module whose symbols
>> will eventually be exported through the named "public" module. This is
>> in support of a common pattern in the Darwin ecosystem where a single
>> public framework is constructed of several private frameworks, with
>> (currently) header duplication and some support from the linker.
>> 
>> Addresses rdar://problem/34438420 <>.
>> 
>> Added:
>> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
>> cfe/trunk/test/Modules/export_as_test.c
>> Modified:
>> cfe/trunk/docs/Modules.rst
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Basic/Module.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/Basic/Module.cpp
>> cfe/trunk/lib/Lex/ModuleMap.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> 
>> Modified: cfe/trunk/docs/Modules.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=313316&r1=313315&r2=313316&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/docs/Modules.rst (original)
>> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
>> @@ -323,11 +323,12 @@ Module map files use a simplified form o
>> 
>>  .. parsed-literal::
>> 
>> -  ``config_macros`` ``export`` ``private``
>> +  ``config_macros`` ``export_as``  ``private``
>>``conflict``  ``framework``  ``requires``
>>``exclude``   ``header`` ``textual``
>>``explicit``  ``link``   ``umbrella``
>>``extern````module`` ``use``
>> +  ``export``
>> 
>>  Module map file
>>  ---
>> @@ -387,6 +388,7 @@ Modules can have a number of different k
>>  *umbrella-dir-declaration*
>>  *submodule-declaration*
>>  *export-declaration*
>> +*export-as-declaration*
>>  *use-declaration*
>>  *link-declaration*
>>  *config-macros-declaration*
>> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>>compatibility for programs that rely on transitive inclusion (i.e.,
>>all of them).
>> 
>> +Re-export Declaration
>> +~~
>> +An *export-as-declaration* specifies that the current module is a private
>> +module whose interface will be re-exported by the named public module.
>> +
>> +.. parsed-literal::
>> +
>> +  *export-as-declaration*:
>> +``export_as`` *identifier*
>> +
>> +The *export-as-declaration* names the public module that the current
>> +(private) module will be re-exported through. Only top-level modules
>> +can be re-exported, and any given module may only be re-exported
>> +through a single public module.
>> +
>> +**Example:** In the following example, the (private) module
>> +``MyFrameworkCore`` will be re-exported via the public module
>> +``MyFramework``:
>> +
>> +.. parsed-literal::
>> +
>> +  module MyFrameworkCore {
>> +export_as MyFramework
>> +  }
>> +
>>  Use declaration
>>  ~~~
>>  A *use-declaration* specifies another module that the current top-level 
>> module
>> 
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=313316&r1=313315&

[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-18 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 115741.

https://reviews.llvm.org/D35743

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11577,19 +11577,43 @@
   EXPECT_EQ("auto const volatile [a, b] = f();",
 format("auto  const   volatile[a, b] = f();"));
   EXPECT_EQ("auto [a, b, c] = f();", format("auto   [  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto & [a, b, c] = f();",
+  EXPECT_EQ("auto& [a, b, c] = f();",
 format("auto   &[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto && [a, b, c] = f();",
+  EXPECT_EQ("auto&& [a, b, c] = f();",
 format("auto   &&[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto const & [a, b] = f();", format("auto  const&[a, b] = f();"));
-  EXPECT_EQ("auto const volatile && [a, b] = f();",
+  EXPECT_EQ("auto const& [a, b] = f();", format("auto  const&[a, b] = f();"));
+  EXPECT_EQ("auto const volatile&& [a, b] = f();",
 format("auto  const  volatile  &&[a, b] = f();"));
-  EXPECT_EQ("auto && [a, b] = f();", format("auto  &&[a, b] = f();"));
+  EXPECT_EQ("auto const&& [a, b] = f();", format("auto  const   &&  [a, b] = 
f();"));
+  EXPECT_EQ("const auto& [a, b] = f();", format("const  auto  &  [a, b] = 
f();"));
+  EXPECT_EQ("const auto volatile&& [a, b] = f();",
+format("const  auto   volatile  &&[a, b] = f();"));
+  EXPECT_EQ("volatile const auto&& [a, b] = f();",
+format("volatile  const  auto   &&[a, b] = f();"));
+  EXPECT_EQ("const auto&& [a, b] = f();", format("const  auto  &&  [a, b] = 
f();"));
+
+  EXPECT_EQ("for (const auto&& [a, b] : some_range) {\n}",
+format("for (const auto   &&   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto& [a, b] : some_range) {\n}",
+format("for (const auto   &   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto [a, b] : some_range) {\n}",
+format("for (const auto[a, b] : some_range) {\n}"));
+  EXPECT_EQ("auto [x, y](expr);", format("auto[x,y]  (expr);"));
+  EXPECT_EQ("auto& [x, y](expr);", format("auto  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto&& [x, y](expr);", format("auto  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto const& [x, y](expr);", format("auto  const  &  [x,y]  
(expr);"));
+  EXPECT_EQ("auto const&& [x, y](expr);", format("auto  const  &&  [x,y]  
(expr);"));
+  EXPECT_EQ("auto [x, y] { expr };", format("auto[x,y] {expr};"));
+  EXPECT_EQ("auto const& [x, y] { expr };", format("auto  const  &  [x,y]  
{expr};"));
+  EXPECT_EQ("auto const&& [x, y] { expr };", format("auto  const  &&  [x,y]  
{expr};"));
 
   format::FormatStyle Spaces = format::getLLVMStyle();
   Spaces.SpacesInSquareBrackets = true;
   verifyFormat("auto [ a, b ] = f();", Spaces);
-  verifyFormat("auto && [ a, b ] = f();", Spaces);
+  verifyFormat("auto&& [ a, b ] = f();", Spaces);
+  verifyFormat("auto& [ a, b ] = f();", Spaces);
+  verifyFormat("auto const&& [ a, b ] = f();", Spaces);
+  verifyFormat("auto const& [ a, b ] = f();", Spaces);
 }
 
 } // end namespace
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -353,10 +353,10 @@
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->is(TT_Unknown)) {
-  if (isCppStructuredBinding(Left)) {
-Left->Type = TT_StructuredBindingLSquare;
-  } else if (StartsObjCMethodExpr) {
+if (isCppStructuredBinding(Left)) {
+  Left->Type = TT_StructuredBindingLSquare;
+} else if (Left->is(TT_Unknown)) {
+  if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;
   } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
  Contexts.back().ContextKind == tok::l_brace &&
@@ -2193,6 +2193,10 @@
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   const FormatToken &Left,
   const FormatToken &Right) {
+  if (Right.is(TT_StructuredBindingLSquare))
+return true;
+  if (Right.Next && Right.Next->is(TT_StructuredBindingLSquare))
+return false;
   if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
 return true;
   if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty &&
@@ -2522,7 +2526,8 @@
   tok::kw___super, TT_TemplateCloser, 
TT_TemplateOpener));
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
-  if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
+  if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren) &&
+   !(Right.Next && Right.Next->is(TT_StructuredBindingLSquare))) ||
   (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
!Right.is(tok::r_pa

[PATCH] D37132: [clang-format] Add support for C++17 structured bindings.

2017-09-18 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Please review  https://reviews.llvm.org/D35743.
I uploaded there a new diff that should fix the spaces around & and && tokens.
Thanks.


https://reviews.llvm.org/D37132



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


[PATCH] D37995: [Docs] Document cache pruning support for gold

2017-09-18 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM with one fix noted.




Comment at: docs/ThinLTO.rst:144
 To help keep the size of the cache under control, ThinLTO supports cache
 pruning. Cache pruning is supported with ld64 and ELF and COFF lld, but
+currently only gold, ELF and COFF lld allow you to control the policy with a

add gold to this list too.


Repository:
  rL LLVM

https://reviews.llvm.org/D37995



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


[PATCH] D37995: [Docs] Document cache pruning support for gold

2017-09-18 Thread Yi Kong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313591: [Docs] Document cache pruning support for gold 
(authored by kongyi).

Changed prior to commit:
  https://reviews.llvm.org/D37995?vs=115710&id=115745#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37995

Files:
  cfe/trunk/docs/ThinLTO.rst


Index: cfe/trunk/docs/ThinLTO.rst
===
--- cfe/trunk/docs/ThinLTO.rst
+++ cfe/trunk/docs/ThinLTO.rst
@@ -141,10 +141,12 @@
 -
 
 To help keep the size of the cache under control, ThinLTO supports cache
-pruning. Cache pruning is supported with ld64 and ELF and COFF lld, but
-currently only ELF and COFF lld allow you to control the policy with a
+pruning. Cache pruning is supported with gold, ld64 and ELF and COFF lld, but
+currently only gold, ELF and COFF lld allow you to control the policy with a
 policy string. The cache policy must be specified with a linker option.
 
+- gold (as of LLVM 6.0):
+  ``-Wl,-plugin-opt,cache-policy=POLICY``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
 - COFF lld-link (as of LLVM 6.0):


Index: cfe/trunk/docs/ThinLTO.rst
===
--- cfe/trunk/docs/ThinLTO.rst
+++ cfe/trunk/docs/ThinLTO.rst
@@ -141,10 +141,12 @@
 -
 
 To help keep the size of the cache under control, ThinLTO supports cache
-pruning. Cache pruning is supported with ld64 and ELF and COFF lld, but
-currently only ELF and COFF lld allow you to control the policy with a
+pruning. Cache pruning is supported with gold, ld64 and ELF and COFF lld, but
+currently only gold, ELF and COFF lld allow you to control the policy with a
 policy string. The cache policy must be specified with a linker option.
 
+- gold (as of LLVM 6.0):
+  ``-Wl,-plugin-opt,cache-policy=POLICY``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
 - COFF lld-link (as of LLVM 6.0):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313598 - [Coverage] Use a new API to label gap areas

2017-09-18 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Sep 18 16:37:30 2017
New Revision: 313598

URL: http://llvm.org/viewvc/llvm-project?rev=313598&view=rev
Log:
[Coverage] Use a new API to label gap areas

This will make it possible for llvm-cov to pick better line execution
counts, and is part of the fix for llvm.org/PR34612.

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/deferred-region.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=313598&r1=313597&r2=313598&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Sep 18 16:37:30 2017
@@ -48,11 +48,16 @@ class SourceMappingRegion {
   /// Whether this region should be emitted after its parent is emitted.
   bool DeferRegion;
 
+  /// Whether this region is a gap region. The count from a gap region is set
+  /// as the line execution count if there are no other regions on the line.
+  bool GapRegion;
+
 public:
   SourceMappingRegion(Counter Count, Optional LocStart,
-  Optional LocEnd, bool DeferRegion = 
false)
+  Optional LocEnd, bool DeferRegion = 
false,
+  bool GapRegion = false)
   : Count(Count), LocStart(LocStart), LocEnd(LocEnd),
-DeferRegion(DeferRegion) {}
+DeferRegion(DeferRegion), GapRegion(GapRegion) {}
 
   const Counter &getCounter() const { return Count; }
 
@@ -79,6 +84,10 @@ public:
   bool isDeferred() const { return DeferRegion; }
 
   void setDeferred(bool Deferred) { DeferRegion = Deferred; }
+
+  bool isGap() const { return GapRegion; }
+
+  void setGap(bool Gap) { GapRegion = Gap; }
 };
 
 /// Spelling locations for the start and end of a source region.
@@ -322,9 +331,16 @@ public:
   // Find the spelling locations for the mapping region.
   SpellingRegion SR{SM, LocStart, LocEnd};
   assert(SR.isInSourceOrder() && "region start and end out of order");
-  MappingRegions.push_back(CounterMappingRegion::makeRegion(
-  Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart,
-  SR.LineEnd, SR.ColumnEnd));
+
+  if (Region.isGap()) {
+MappingRegions.push_back(CounterMappingRegion::makeGapRegion(
+Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart,
+SR.LineEnd, SR.ColumnEnd));
+  } else {
+MappingRegions.push_back(CounterMappingRegion::makeRegion(
+Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart,
+SR.LineEnd, SR.ColumnEnd));
+  }
 }
   }
 
@@ -496,6 +512,7 @@ struct CounterCoverageMappingBuilder
 if (!SpellingRegion(SM, DR.getStartLoc(), 
DeferredEndLoc).isInSourceOrder())
   return Index;
 
+DR.setGap(true);
 DR.setCounter(Count);
 DR.setEndLoc(DeferredEndLoc);
 handleFileExit(DeferredEndLoc);
@@ -1112,6 +1129,9 @@ static void dump(llvm::raw_ostream &OS,
 case CounterMappingRegion::SkippedRegion:
   OS << "Skipped,";
   break;
+case CounterMappingRegion::GapRegion:
+  OS << "Gap,";
+  break;
 }
 
 OS << "File " << R.FileID << ", " << R.LineStart << ":" << R.ColumnStart

Modified: cfe/trunk/test/CoverageMapping/deferred-region.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/deferred-region.cpp?rev=313598&r1=313597&r2=313598&view=diff
==
--- cfe/trunk/test/CoverageMapping/deferred-region.cpp (original)
+++ cfe/trunk/test/CoverageMapping/deferred-region.cpp Mon Sep 18 16:37:30 2017
@@ -7,7 +7,7 @@
 void foo(int x) {
   if (x == 0) {
 return;
-  } // CHECK: [[@LINE]]:4 -> [[@LINE+2]]:2 = (#0 - #1)
+  } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:2 = (#0 - #1)
 
 }
 
@@ -15,11 +15,11 @@ void foo(int x) {
 void fooo(int x) {
   if (x == 0) {
 return;
-  } // CHECK: [[@LINE]]:4 -> [[@LINE+2]]:3 = (#0 - #1)
+  } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:3 = (#0 - #1)
 
   if (x == 1) {
 return;
-  } // CHECK: [[@LINE]]:4 -> [[@LINE+2]]:2 = ((#0 - #1) - #2)
+  } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:2 = ((#0 - #1) - #2)
 
 }
 
@@ -31,10 +31,10 @@ void baz() { // CHECK: [[@LINE]]:12 -> [
 // CHECK-LABEL: _Z3bari:
 void bar(int x) {
   IF (x)
-return; // CHECK: [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1)
+return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1)
 
   IF (!x)
-return; // CHECK: [[@LINE]]:11 -> [[@LINE+2]]:3 = ((#0 - #1) - #2)
+return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = ((#0 - #1) - 
#2)
 
   foo(x);
 }
@@ -69,34 +69,34 @@ void weird_if() {
   int i = 0;
 
   if (false)
-return; // CHECK: [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1)
+return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #

[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-18 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 115751.
vlad.tsyrklevich added a comment.

Update for SectionsMap refactor in LLVM


https://reviews.llvm.org/D37925

Files:
  docs/ControlFlowIntegrity.rst
  docs/SanitizerSpecialCaseList.rst
  include/clang/Basic/SanitizerBlacklist.h
  include/clang/Basic/SanitizerSpecialCaseList.h
  lib/AST/Decl.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/SanitizerBlacklist.cpp
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/XRayLists.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/Inputs/sanitizer-special-case-list.sanitized.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized1.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized2.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
  test/CodeGen/sanitizer-special-case-list.c
  test/CodeGenCXX/cfi-blacklist.cpp

Index: test/CodeGenCXX/cfi-blacklist.cpp
===
--- test/CodeGenCXX/cfi-blacklist.cpp
+++ test/CodeGenCXX/cfi-blacklist.cpp
@@ -1,6 +1,18 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
-// RUN: echo "type:std::*" > %t.txt
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting cfi and cfi-vcall work correctly
+// RUN: echo "[cfi-vcall]" > %t.vcall.txt
+// RUN: echo "type:std::*" >> %t.vcall.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+//
+// RUN: echo "[cfi]" > %t.cfi.txt
+// RUN: echo "type:std::*" >> %t.cfi.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting non-vcall modes does not affect vcalls
+// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
+// RUN: echo "type:std::*" >> %t.other.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
 
 struct S1 {
   virtual void f();
Index: test/CodeGen/sanitizer-special-case-list.c
===
--- /dev/null
+++ test/CodeGen/sanitizer-special-case-list.c
@@ -0,0 +1,26 @@
+// Verify that blacklist sections correctly select sanitizers to apply blacklist entries to.
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized1.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized2.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized3.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized4.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.sanitized.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=SANITIZED
+
+unsigned i;
+
+// SANITIZED: @overflow
+// UNSANITIZED: @overflow
+unsigned overflow() {
+  // SANITIZED: call {{.*}}void @__ubsan
+  // UNSANITIZED-NOT: call {{.*}}void @__ubsan
+  return i * 37;
+}
+
+// SANITIZED: @cfi
+// UNSANITIZED: @cfi
+void cfi(void (*fp)()) {
+  // SANITIZED: llvm.type.test
+  // UNSANITIZED-NOT: llvm.type.test
+  fp();
+}
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
===
--- /dev/null
+++ test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
@@ -0,0 +1,4 @@
+[c*]
+fun:*cfi*
+[u*]
+fun:*overflow*
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
===
--- /dev/null
+++ test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
@@ -0

[PATCH] D38009: [Sema] Fix using old initializer during switch statement transformation.

2017-09-18 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added subscribers: kristof.beyls, aemerson.

It fixes a crash in CodeGen when we are trying to generate code for
initializer expression created before template instantiation, like

  CallExpr ''
  |-UnresolvedLookupExpr '' lvalue (ADL) = 'parse'
  `-DeclRefExpr 'Buffer' lvalue ParmVar 'buffer' 'Buffer'

rdar://problem/33888545


https://reviews.llvm.org/D38009

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/cxx1z-init-statement-template.cpp


Index: clang/test/SemaCXX/cxx1z-init-statement-template.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx1z-init-statement-template.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s
+// expected-no-diagnostics
+
+// rdar://problem/33888545
+template  class Buffer {};
+
+class A {
+public:
+  int status;
+};
+
+template  A parse(Buffer buffer);
+
+template
+void init_in_if(Buffer buffer) {
+  if (A a = parse(buffer); a.status > 0) {
+  }
+}
+
+template
+void init_in_switch(Buffer buffer) {
+  switch (A a = parse(buffer); a.status) {
+default:
+  break;
+  }
+}
+
+void test() {
+  Buffer<10> buffer;
+  init_in_if(buffer);
+  init_in_switch(buffer);
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6601,8 +6601,7 @@
 
   // Rebuild the switch statement.
   StmtResult Switch
-= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(),
-  S->getInit(), Cond);
+= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
   if (Switch.isInvalid())
 return StmtError();
 


Index: clang/test/SemaCXX/cxx1z-init-statement-template.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx1z-init-statement-template.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s
+// expected-no-diagnostics
+
+// rdar://problem/33888545
+template  class Buffer {};
+
+class A {
+public:
+  int status;
+};
+
+template  A parse(Buffer buffer);
+
+template
+void init_in_if(Buffer buffer) {
+  if (A a = parse(buffer); a.status > 0) {
+  }
+}
+
+template
+void init_in_switch(Buffer buffer) {
+  switch (A a = parse(buffer); a.status) {
+default:
+  break;
+  }
+}
+
+void test() {
+  Buffer<10> buffer;
+  init_in_if(buffer);
+  init_in_switch(buffer);
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6601,8 +6601,7 @@
 
   // Rebuild the switch statement.
   StmtResult Switch
-= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(),
-  S->getInit(), Cond);
+= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
   if (Switch.isInvalid())
 return StmtError();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313591 - [Docs] Document cache pruning support for gold

2017-09-18 Thread Yi Kong via cfe-commits
Author: kongyi
Date: Mon Sep 18 16:24:01 2017
New Revision: 313591

URL: http://llvm.org/viewvc/llvm-project?rev=313591&view=rev
Log:
[Docs] Document cache pruning support for gold

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

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=313591&r1=313590&r2=313591&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Mon Sep 18 16:24:01 2017
@@ -141,10 +141,12 @@ Cache Pruning
 -
 
 To help keep the size of the cache under control, ThinLTO supports cache
-pruning. Cache pruning is supported with ld64 and ELF and COFF lld, but
-currently only ELF and COFF lld allow you to control the policy with a
+pruning. Cache pruning is supported with gold, ld64 and ELF and COFF lld, but
+currently only gold, ELF and COFF lld allow you to control the policy with a
 policy string. The cache policy must be specified with a linker option.
 
+- gold (as of LLVM 6.0):
+  ``-Wl,-plugin-opt,cache-policy=POLICY``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
 - COFF lld-link (as of LLVM 6.0):


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


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-18 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: docs/SanitizerSpecialCaseList.rst:57
+
+Sections are regular expressions written in square brackets that denote which
+sanitizer the following entries apply to. For example, ``[address]`` specifies

Section names are regular expressions

also, not really a regular expression, more like a wildcard; I don't know 
what's the right term for this



Comment at: lib/CodeGen/CGDeclCXX.cpp:322
+  if (getLangOpts().Sanitize.hasOneOf(ASanMask))
+if (!isInSanitizerBlacklist(ASanMask, Fn, Loc))
   Fn->addFnAttr(llvm::Attribute::SanitizeAddress);

vlad.tsyrklevich wrote:
> This use of ASanMask could also confound address & kernel-address as @eugenis 
> pointed out.
It would be more readable to split it in two if-s, IMHO: one for asan, one for 
kernel-asan.



https://reviews.llvm.org/D37925



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


r313603 - [Coverage] Remove deferred region for trailing return, fixes PR34611

2017-09-18 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Sep 18 17:29:46 2017
New Revision: 313603

URL: http://llvm.org/viewvc/llvm-project?rev=313603&view=rev
Log:
[Coverage] Remove deferred region for trailing return, fixes PR34611

As a special case, throw away deferred regions for trailing returns.
This allows the closing curly brace to have a count, and is less
distracting.

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/deferred-region.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=313603&r1=313602&r2=313603&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Sep 18 17:29:46 2017
@@ -770,7 +770,13 @@ struct CounterCoverageMappingBuilder
 Counter ExitCount = propagateCounts(getRegionCounter(Body), Body);
 assert(RegionStack.empty() && "Regions entered but never exited");
 
-// Complete any deferred regions introduced by the last statement in a 
decl.
+// Special case: if the last statement is a return, throw away the
+// deferred region. This allows the closing brace to have a count.
+if (auto *CS = dyn_cast_or_null(Body))
+  if (dyn_cast_or_null(CS->body_back()))
+DeferredRegion = None;
+
+// Complete any deferred regions introduced by the last statement.
 popRegions(completeDeferred(ExitCount, getEnd(Body)));
   }
 

Modified: cfe/trunk/test/CoverageMapping/deferred-region.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/deferred-region.cpp?rev=313603&r1=313602&r2=313603&view=diff
==
--- cfe/trunk/test/CoverageMapping/deferred-region.cpp (original)
+++ cfe/trunk/test/CoverageMapping/deferred-region.cpp Mon Sep 18 17:29:46 2017
@@ -28,6 +28,14 @@ void baz() { // CHECK: [[@LINE]]:12 -> [
   return;// CHECK-NOT: File
 }
 
+// CHECK-LABEL: _Z3mazv:
+void maz() {
+  if (true)
+return; // CHECK: Gap,File 0, [[@LINE]]:11 -> 36:3 = (#0 - #1)
+
+  return; // CHECK-NOT: Gap
+}
+
 // CHECK-LABEL: _Z3bari:
 void bar(int x) {
   IF (x)


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


[PATCH] D37954: Expand absolute system header paths when using -MD depfiles

2017-09-18 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added a comment.

In https://reviews.llvm.org/D37954#873384, @joerg wrote:

> ninja is not the only consumer of this. For human inspection, it can be quite 
> surprising to see symlinks resolved, i.e. /usr/include/machine on NetBSD.


No problem, NetBSD disables this option by default:
https://github.com/IIJ-NetBSD/netbsd-src/blob/dd946191000153f9c8a927e5257e726879f48140/share/mk/bsd.sys.mk#L26
This option was added in 
https://github.com/IIJ-NetBSD/netbsd-src/commit/c7e9228e67fab47a6bbfb548117da93ebb20ff5c
(I am unable to find a (mailing list) discussion about the exact problem 
though.)

> Build systems have different ideas on whether they want absolute resolved 
> paths or not, so it seems like ninja should be able to cope with either 
> format. This is a lossy transformation, so I'm somewhat reluctant to agree 
> with it.

Can you be specific about the build systems you have in mind? Note:

1. GCC has added and enabled this option by default in 2012 
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52974). and
2. Ninja is currently slightly broken with Clang whereas it works fine with GCC.
3. To the best of my knowledge, there are no systems that break after this fix.

Looking at the GCC change, it also checks whether the canonicalized path is 
actually shorter. In that case the documented "shorten header paths" seems to 
make sense.

I thought it would be a good idea to make Clang compatible with GCC in this 
case, not sure what else could break.
If it turns out to be bad, it can be removed and/or worked around with the 
-fno-canonical-system-headers option.


https://reviews.llvm.org/D37954



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


[libcxx] r313606 - Fix llvm-lit script generation in libcxx.

2017-09-18 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Mon Sep 18 19:46:28 2017
New Revision: 313606

URL: http://llvm.org/viewvc/llvm-project?rev=313606&view=rev
Log:
Fix llvm-lit script generation in libcxx.

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=313606&r1=313605&r2=313606&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Sep 18 19:46:28 2017
@@ -653,6 +653,7 @@ endif()
 #
 # However, since some submission systems strip test/ subdirectories, check for
 # it before adding it.
+
 if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
   add_subdirectory(test)
 endif()
@@ -660,6 +661,15 @@ if (LIBCXX_INCLUDE_TESTS)
   add_subdirectory(lib/abi)
 endif()
 
+if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  # Make sure the llvm-lit script is generated into the bin directory, and do
+  # it after adding all tests, since the generated script will only work
+  # correctly discovered tests against test locations from the source tree that
+  # have already been discovered.
+  add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
+   ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
+endif()
+
 if (LIBCXX_INCLUDE_DOCS)
   add_subdirectory(docs)
 endif()

Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=313606&r1=313605&r2=313606&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Mon Sep 18 19:46:28 
2017
@@ -106,6 +106,11 @@ macro(configure_out_of_tree_llvm)
 set(LLVM_ENABLE_SPHINX OFF)
   endif()
 
+  # In a standalone build, we don't have llvm to automatically generate the
+  # llvm-lit script for us.  So we need to provide an explicit directory that
+  # the configurator should write the script into.
+  set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
+
   # Required LIT Configuration 
   # Define the default arguments to use with 'lit', and an option for the user
   # to override.

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=313606&r1=313605&r2=313606&view=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Mon Sep 18 19:46:28 2017
@@ -49,10 +49,9 @@ set(LIBCXX_EXECUTOR "None" CACHE STRING
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")
 
-configure_file(
+configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  @ONLY)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
 
 set(LIBCXX_TEST_DEPS "")
 


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


[libcxx] r313607 - Revert "Fix llvm-lit script generation in libcxx."

2017-09-18 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Mon Sep 18 20:11:35 2017
New Revision: 313607

URL: http://llvm.org/viewvc/llvm-project?rev=313607&view=rev
Log:
Revert "Fix llvm-lit script generation in libcxx."

This reverts commit 4ad71811d45268d81b60f27e3b8b2bcbc23bd7b9.

There is a bot that is checking out libcxx and lit with nothing
else and then running lit.py against the test tree.  Since there's
no LLVM source tree, there's no LLVM CMake.  CMake actually
reports this as a warning saying unsupported libcxx configuration,
but I guess someone is depending on it anyway.

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=313607&r1=313606&r2=313607&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Sep 18 20:11:35 2017
@@ -653,7 +653,6 @@ endif()
 #
 # However, since some submission systems strip test/ subdirectories, check for
 # it before adding it.
-
 if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
   add_subdirectory(test)
 endif()
@@ -661,15 +660,6 @@ if (LIBCXX_INCLUDE_TESTS)
   add_subdirectory(lib/abi)
 endif()
 
-if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
-  # Make sure the llvm-lit script is generated into the bin directory, and do
-  # it after adding all tests, since the generated script will only work
-  # correctly discovered tests against test locations from the source tree that
-  # have already been discovered.
-  add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
-   ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
-endif()
-
 if (LIBCXX_INCLUDE_DOCS)
   add_subdirectory(docs)
 endif()

Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=313607&r1=313606&r2=313607&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Mon Sep 18 20:11:35 
2017
@@ -106,11 +106,6 @@ macro(configure_out_of_tree_llvm)
 set(LLVM_ENABLE_SPHINX OFF)
   endif()
 
-  # In a standalone build, we don't have llvm to automatically generate the
-  # llvm-lit script for us.  So we need to provide an explicit directory that
-  # the configurator should write the script into.
-  set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
-
   # Required LIT Configuration 
   # Define the default arguments to use with 'lit', and an option for the user
   # to override.

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=313607&r1=313606&r2=313607&view=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Mon Sep 18 20:11:35 2017
@@ -49,9 +49,10 @@ set(LIBCXX_EXECUTOR "None" CACHE STRING
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")
 
-configure_lit_site_cfg(
+configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  @ONLY)
 
 set(LIBCXX_TEST_DEPS "")
 


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