[PATCH] D27504: Compilation database test: don't try to output to CWD

2016-12-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

bkramer: summoning my lit guru for guidance, is there a better way?


https://reviews.llvm.org/D27504



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


[PATCH] D27504: Compilation database test: don't try to output to CWD

2016-12-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: bkramer.
sammccall added subscribers: cfe-commits, joerg.

Write output from compilation database test to %T rather than the working dir.
Sometimes CWD isn't writable!
Also specify no-canonical-prefixes so that clang has 'clang' in the name.


https://reviews.llvm.org/D27504

Files:
  test/Driver/compilation_database.c


Index: test/Driver/compilation_database.c
===
--- test/Driver/compilation_database.c
+++ test/Driver/compilation_database.c
@@ -1,8 +1,8 @@
-// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
2>&1 | FileCheck %s
-// RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck 
--check-prefix=ERROR %s
+// RUN: cd "%T" && %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s 
-Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
+// RUN: cd "%T" && not %clang -c -x c %s -MJ %s/non-existant 
-no-canonical-prefixes 2>&1 | FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {


Index: test/Driver/compilation_database.c
===
--- test/Driver/compilation_database.c
+++ test/Driver/compilation_database.c
@@ -1,8 +1,8 @@
-// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
-// RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck --check-prefix=ERROR %s
+// RUN: cd "%T" && %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - -no-canonical-prefixes 2>&1 | FileCheck %s
+// RUN: cd "%T" && not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=ERROR %s
 
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "{{.*}}",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be opened:
 
 int main(void) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r285301 - Attempt to make clang-format.py python 3 - compatible.

2016-12-06 Thread Vedant Kumar via cfe-commits
Hi Alexander,

I think this will cause an error if used with python3 (at least, it fails on my
system). Here's the problem:

  line.decode(encoding)

When vim is compiled against python3, the type of 'line' remains 'str' -- not
'bytes'. There isn't a 'decode' method on strings: it only exists for bytes. I
take this to mean that vim has done the decoding already. If not, there's a bug
in vim.

I've attached a small patch that addresses this issue. Wdyt?



cf.patch
Description: Binary data


thanks,
vedant


> On Oct 27, 2016, at 8:15 AM, Alexander Kornienko via cfe-commits 
>  wrote:
> 
> Author: alexfh
> Date: Thu Oct 27 10:15:23 2016
> New Revision: 285301
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285301=rev
> Log:
> Attempt to make clang-format.py python 3 - compatible.
> 
> Modified:
>cfe/trunk/tools/clang-format/clang-format.py
> 
> Modified: cfe/trunk/tools/clang-format/clang-format.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=285301=285300=285301=diff
> ==
> --- cfe/trunk/tools/clang-format/clang-format.py (original)
> +++ cfe/trunk/tools/clang-format/clang-format.py Thu Oct 27 10:15:23 2016
> @@ -51,7 +51,7 @@ if vim.eval('exists("g:clang_format_fall
> def main():
>   # Get the current text.
>   encoding = vim.eval("")
> -  buf = [ unicode(line, encoding) for line in vim.current.buffer ]
> +  buf = [ line.decode(encoding) for line in vim.current.buffer ]
>   text = '\n'.join(buf)
> 
>   # Determine range to format.
> 
> 
> ___
> 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


Re: r288093 - Use ${:uid} to generate unique MS asm labels, not {:uid}

2016-12-06 Thread Sean Silva via cfe-commits
Thanks.

2016-12-06 16:28 GMT-08:00 Reid Kleckner :

> Comments in r288868. It implements GCC's %= inline asm feature, and we're
> just using it from MS-style inline asm to avoid duplicate labels clashing.
>
> 2016-12-01 0:37 GMT-08:00 Sean Silva :
>
>> what is this ${:uid} thing? Could the comment
>> in Sema::GetOrCreateMSAsmLabel explain it?
>>
>> -- Sean Silva
>>
>> On Mon, Nov 28, 2016 at 4:39 PM, Reid Kleckner via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rnk
>>> Date: Mon Nov 28 18:39:37 2016
>>> New Revision: 288093
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=288093=rev
>>> Log:
>>> Use ${:uid} to generate unique MS asm labels, not {:uid}
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
>>> cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
>>> cfe/trunk/test/CodeGen/ms-inline-asm.c
>>> cfe/trunk/test/CodeGen/ms-inline-asm.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaS
>>> tmtAsm.cpp?rev=288093=288092=288093=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Nov 28 18:39:37 2016
>>> @@ -753,7 +753,7 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S
>>>  // Create an internal name for the label.  The name should not be a
>>> valid mangled
>>>  // name, and should be unique.  We use a dot to make the name an
>>> invalid mangled
>>>  // name.
>>> -OS << "__MSASMLABEL_.{:uid}__";
>>> +OS << "__MSASMLABEL_.${:uid}__";
>>>  for (char C : ExternalLabelName) {
>>>OS << C;
>>>// We escape '$' in asm strings by replacing it with "$$"
>>>
>>> Modified: cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/m
>>> ozilla-ms-inline-asm.c?rev=288093=288092=288093=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c (original)
>>> +++ cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c Mon Nov 28 18:39:37
>>> 2016
>>> @@ -20,7 +20,7 @@ void invoke(void* that, unsigned methodI
>>>  // CHECK: call void asm sideeffect inteldialect
>>>  // CHECK: mov edx,dword ptr $1
>>>  // CHECK: test edx,edx
>>> -// CHECK: jz {{[^_]*}}__MSASMLABEL_.{:uid}__noparams
>>> +// CHECK: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
>>>  // ^ Can't use {{.*}} here because the matching is greedy.
>>>  // CHECK: mov eax,edx
>>>  // CHECK: shl eax,$$3
>>> @@ -28,7 +28,7 @@ void invoke(void* that, unsigned methodI
>>>  // CHECK: mov ecx,esp
>>>  // CHECK: push dword ptr $0
>>>  // CHECK: call dword ptr $2
>>> -// CHECK: {{.*}}__MSASMLABEL_.{:uid}__noparams:
>>> +// CHECK: {{.*}}__MSASMLABEL_.${:uid}__noparams:
>>>  // CHECK: mov ecx,dword ptr $3
>>>  // CHECK: push ecx
>>>  // CHECK: mov edx,[ecx]
>>>
>>> Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/m
>>> s-inline-asm.c?rev=288093=288092=288093=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
>>> +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Nov 28 18:39:37 2016
>>> @@ -249,7 +249,7 @@ void t23() {
>>>the_label:
>>>}
>>>  // CHECK: t23
>>> -// CHECK: call void asm sideeffect inteldialect
>>> "{{.*}}__MSASMLABEL_.{:uid}__the_label:", "~{dirflag},~{fpsr},~{flags}"(
>>> )
>>> +// CHECK: call void asm sideeffect inteldialect
>>> "{{.*}}__MSASMLABEL_.${:uid}__the_label:",
>>> "~{dirflag},~{fpsr},~{flags}"()
>>>  }
>>>
>>>  void t24_helper(void) {}
>>> @@ -595,7 +595,7 @@ void label1() {
>>>  jmp label
>>>}
>>>// CHECK-LABEL: define void @label1()
>>> -  // CHECK: call void asm sideeffect inteldialect
>>> "{{.*}}__MSASMLABEL_.{:uid}__label:\0A\09jmp
>>> {{.*}}__MSASMLABEL_.{:uid}__label", "~{dirflag},~{fpsr},~{flags}"()
>>> [[ATTR1:#[0-9]+]]
>>> +  // CHECK: call void asm sideeffect inteldialect
>>> "{{.*}}__MSASMLABEL_.${:uid}__label:\0A\09jmp
>>> {{.*}}__MSASMLABEL_.${:uid}__label", "~{dirflag},~{fpsr},~{flags}"()
>>> [[ATTR1:#[0-9]+]]
>>>  }
>>>
>>>  void label2() {
>>> @@ -604,7 +604,7 @@ void label2() {
>>>  label:
>>>}
>>>// CHECK-LABEL: define void @label2
>>> -  // CHECK: call void asm sideeffect inteldialect "jmp
>>> {{.*}}__MSASMLABEL_.{:uid}__label\0A\09{{.*}}__MSASMLABEL_.{:uid}__label:",
>>> "~{dirflag},~{fpsr},~{flags}"()
>>> +  // CHECK: call void asm sideeffect inteldialect "jmp
>>> {{.*}}__MSASMLABEL_.${:uid}__label\0A\09{{.*}}__MSASMLABEL_.${:uid}__label:",
>>> "~{dirflag},~{fpsr},~{flags}"()
>>>  }
>>>
>>>  void label3() {
>>> @@ -613,7 +613,7 @@ void label3() {
>>>  mov eax, label
>>>}
>>>// CHECK-LABEL: define void @label3
>>> -  // CHECK: call void asm 

[PATCH] D25809: [CUDA] Improved target attribute-based overloading.

2016-12-06 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

If you would like me to have another look at this, is it possible to make an 
interdiff of your changes between this and the last version I reviewed?  phab's 
interdiff is useless because it straddles a rebase.


https://reviews.llvm.org/D25809



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


[PATCH] D25809: [CUDA] Improved target attribute-based overloading.

2016-12-06 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

(Alternatively I'm happy not to have another look if you don't think you need 
it.)


https://reviews.llvm.org/D25809



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


[PATCH] D27501: clang-format-vsix: add command to format document

2016-12-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 80533.
amaiorano added a comment.

My first patch accidentally included the changes from 
https://reviews.llvm.org/D27440


https://reviews.llvm.org/D27501

Files:
  tools/clang-format-vs/.gitignore
  tools/clang-format-vs/ClangFormat/ClangFormat.vsct
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/PkgCmdID.cs
  tools/clang-format-vs/README.txt

Index: tools/clang-format-vs/README.txt
===
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -25,3 +25,27 @@
 ClangFormat/source.extension.vsixmanifest. Once the plug-in has been built with
 CMake once, it can be built manually from the ClangFormat.sln solution in Visual
 Studio.
+
+===
+ Debugging
+===
+
+Once you've built the clang_format_vsix project from LLVM.sln at least once,
+open ClangFormat.sln in Visual Studio, then:
+
+- Make sure the "Debug" target is selected
+- Open the ClangFormat project properties
+- Select the Debug tab
+- Set "Start external program:" to where your devenv.exe is installed. Typically
+  it's "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"
+- Set "Command line arguments" to: /rootsuffix Exp
+- You can now set breakpoints if you like
+- Press F5 to build and run with debugger
+
+If all goes well, a new instance of Visual Studio will be launched in a special
+mode where it uses the experimental hive instead of the normal configuration hive.
+By default, when you build a VSIX project in Visual Studio, it auto-registers the
+extension in the experimental hive, allowing you to test it. In the new Visual Studio
+instance, open or create a C++ solution, and you should now see the Clang Format
+entries in the Tool menu. You can test it out, and any breakpoints you set will be
+hit where you can debug as usual.
Index: tools/clang-format-vs/ClangFormat/PkgCmdID.cs
===
--- tools/clang-format-vs/ClangFormat/PkgCmdID.cs
+++ tools/clang-format-vs/ClangFormat/PkgCmdID.cs
@@ -2,6 +2,7 @@
 {
 static class PkgCmdIDList
 {
-public const uint cmdidClangFormat = 0x100;
+public const uint cmdidClangFormatSelection = 0x100;
+public const uint cmdidClangFormatDocument = 0x101;
 };
 }
\ No newline at end of file
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -180,41 +180,86 @@
 var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
 if (commandService != null)
 {
-var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormat);
-var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
-commandService.AddCommand(menuItem);
+{
+var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatSelection);
+var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+commandService.AddCommand(menuItem);
+}
+
+{
+var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatDocument);
+var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+commandService.AddCommand(menuItem);
+}
 }
 }
 #endregion
 
 private void MenuItemCallback(object sender, EventArgs args)
 {
+var mc = sender as System.ComponentModel.Design.MenuCommand;
+if (mc == null)
+return;
+
+switch (mc.CommandID.ID)
+{
+case (int)PkgCmdIDList.cmdidClangFormatSelection:
+FormatSelection();
+break;
+
+case (int)PkgCmdIDList.cmdidClangFormatDocument:
+FormatDocument();
+break;
+}
+}
+
+/// 
+/// Runs clang-format on the current selection
+/// 
+private void FormatSelection()
+{
 IWpfTextView view = GetCurrentView();
 if (view == null)
 // We're not in a text view.
 return;
 string text = view.TextBuffer.CurrentSnapshot.GetText();
 int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
 int end = view.Selection.End.Position.GetContainingLine().End.Position;
 int length = end - start;
+
 // clang-format doesn't support formatting a range 

[PATCH] D27501: clang-format-vsix: add command to format document

2016-12-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano created this revision.
amaiorano added reviewers: hans, zturner, klimek.
amaiorano added a subscriber: cfe-commits.

Bound to Ctrl+R, Ctrl+D by default. Also added section on how to debug the 
extension to the Readme.


https://reviews.llvm.org/D27501

Files:
  tools/clang-format-vs/.gitignore
  tools/clang-format-vs/ClangFormat/ClangFormat.vsct
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/PkgCmdID.cs
  tools/clang-format-vs/README.txt

Index: tools/clang-format-vs/README.txt
===
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -25,3 +25,27 @@
 ClangFormat/source.extension.vsixmanifest. Once the plug-in has been built with
 CMake once, it can be built manually from the ClangFormat.sln solution in Visual
 Studio.
+
+===
+ Debugging
+===
+
+Once you've built the clang_format_vsix project from LLVM.sln at least once,
+open ClangFormat.sln in Visual Studio, then:
+
+- Make sure the "Debug" target is selected
+- Open the ClangFormat project properties
+- Select the Debug tab
+- Set "Start external program:" to where your devenv.exe is installed. Typically
+  it's "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"
+- Set "Command line arguments" to: /rootsuffix Exp
+- You can now set breakpoints if you like
+- Press F5 to build and run with debugger
+
+If all goes well, a new instance of Visual Studio will be launched in a special
+mode where it uses the experimental hive instead of the normal configuration hive.
+By default, when you build a VSIX project in Visual Studio, it auto-registers the
+extension in the experimental hive, allowing you to test it. In the new Visual Studio
+instance, open or create a C++ solution, and you should now see the Clang Format
+entries in the Tool menu. You can test it out, and any breakpoints you set will be
+hit where you can debug as usual.
Index: tools/clang-format-vs/ClangFormat/PkgCmdID.cs
===
--- tools/clang-format-vs/ClangFormat/PkgCmdID.cs
+++ tools/clang-format-vs/ClangFormat/PkgCmdID.cs
@@ -2,6 +2,7 @@
 {
 static class PkgCmdIDList
 {
-public const uint cmdidClangFormat = 0x100;
+public const uint cmdidClangFormatSelection = 0x100;
+public const uint cmdidClangFormatDocument = 0x101;
 };
 }
\ No newline at end of file
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -180,41 +180,86 @@
 var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
 if (commandService != null)
 {
-var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormat);
-var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
-commandService.AddCommand(menuItem);
+{
+var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatSelection);
+var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+commandService.AddCommand(menuItem);
+}
+
+{
+var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatDocument);
+var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+commandService.AddCommand(menuItem);
+}
 }
 }
 #endregion
 
 private void MenuItemCallback(object sender, EventArgs args)
 {
+var mc = sender as System.ComponentModel.Design.MenuCommand;
+if (mc == null)
+return;
+
+switch (mc.CommandID.ID)
+{
+case (int)PkgCmdIDList.cmdidClangFormatSelection:
+FormatSelection();
+break;
+
+case (int)PkgCmdIDList.cmdidClangFormatDocument:
+FormatDocument();
+break;
+}
+}
+
+/// 
+/// Runs clang-format on the current selection
+/// 
+private void FormatSelection()
+{
 IWpfTextView view = GetCurrentView();
 if (view == null)
 // We're not in a text view.
 return;
 string text = view.TextBuffer.CurrentSnapshot.GetText();
 int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
 int end = view.Selection.End.Position.GetContainingLine().End.Position;
 int length = end - start;
+   

[PATCH] D27299: [Sema] C++11 opaque enums should avoid the "case value not in enumerated type" switch warning

2016-12-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

That makes sense. Thanks for the explanation.


Repository:
  rL LLVM

https://reviews.llvm.org/D27299



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


[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

2016-12-06 Thread ZiXuan Wu via Phabricator via cfe-commits
Zeson marked 2 inline comments as done.
Zeson added a comment.

Hi, All.

The revision has been updated, please review it again. 
Thanks a lot.


https://reviews.llvm.org/D27251



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


[PATCH] D27409: [analyzer] RetainCountChecker: Improve support for libdispatch APIs.

2016-12-06 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

The analyzer currently doesn't do any checking for dispatch retain/release APIs 
in C. It similarly doesn't do any checking in Objective-C when 
OS_OBJECT_USE_OBJC is 0 (and thus the dispatch types are defined to their 
C-struct versions). This happens when the user explicitly sets 
-DOS_OBJECT_USE_OBJC=0 (to safely share dispatch between ARC and non-ARC 
projects) and also under certain combinations of deployment targets and 
architectures where the runtime support for the feature is not present (for 
example, earlier than iOS 6.0).

My feeling is that for this patch it is fine to continue the policy of not 
diagnosing dispatch leaks/overreleases when OS_OBJECT_USE_OBJC is 0. Adding 
this support to the retain count checker is a larger project and in my opinion 
it should be done separately. To that end, I would recommend removing the 
summary creation for dispatch_retain/dispatch_release().

That said, people do use these APIs in C (and with -DOS_OBJECT_USE_OBJC=0 in 
ObjC), so it would be great test to make sure that this patch don't introduce 
any new false positives in these situations. I think it important to suck in 
enough of the header typedefs used when -DOS_OBJECT_USE_OBJC=0 to write these 
tests to make sure we don't regress when using the C-based APIs.




Comment at: test/Analysis/dispatch-data-leak.m:4
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks 
-DDISPATCH_MACROS -analyze -analyzer-output=text 
-analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks 
-DDISPATCH_MARCOS -fobjc-arc -analyze -analyzer-output=text 
-analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+

Looks like there is a typo here ('MARCOS' vs. 'MACROS')?


https://reviews.llvm.org/D27409



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


[PATCH] D27438: clang-format-vsix: add a date stamp to the VSIX version number to ensure upgradability

2016-12-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

> Yes, I think this is still a worthwhile change. Let's add the hour and minute 
> and get it landed.

Alright, added hour and minute. How do we land this change? Is this something I 
can now do myself? Or would you need to commit this for me again?

I have a couple of more interesting changes coming. Perhaps it would make sense 
to grant me commit rights?


https://reviews.llvm.org/D27438



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


[PATCH] D27438: clang-format-vsix: add a date stamp to the VSIX version number to ensure upgradability

2016-12-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 80527.
amaiorano added a comment.

Added hour and minute.


https://reviews.llvm.org/D27438

Files:
  tools/clang-format-vs/CMakeLists.txt


Index: tools/clang-format-vs/CMakeLists.txt
===
--- tools/clang-format-vs/CMakeLists.txt
+++ tools/clang-format-vs/CMakeLists.txt
@@ -11,8 +11,11 @@
   "${CLANG_SOURCE_DIR}/LICENSE.TXT"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
 
+  # Build number added to Clang version to ensure that new VSIX can be upgraded
+  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
+
   if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
   endif()
 
   configure_file("source.extension.vsixmanifest.in"


Index: tools/clang-format-vs/CMakeLists.txt
===
--- tools/clang-format-vs/CMakeLists.txt
+++ tools/clang-format-vs/CMakeLists.txt
@@ -11,8 +11,11 @@
   "${CLANG_SOURCE_DIR}/LICENSE.TXT"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
 
+  # Build number added to Clang version to ensure that new VSIX can be upgraded
+  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
+
   if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+set(CLANG_FORMAT_VS_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
   endif()
 
   configure_file("source.extension.vsixmanifest.in"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25809: [CUDA] Improved target attribute-based overloading.

2016-12-06 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 80522.
tra added a comment.

Removed HD overloading checks for using declarations.
'using' exposes number of issues with the way we handle overloading of HD 
functions vs H/D.
The issues will be addressed in a separate patch.


https://reviews.llvm.org/D25809

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCUDA/launch-bounds.cu
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/function-template-overload.cu
  test/SemaCUDA/target_attr_inheritance.cu

Index: test/SemaCUDA/target_attr_inheritance.cu
===
--- test/SemaCUDA/target_attr_inheritance.cu
+++ /dev/null
@@ -1,29 +0,0 @@
-// Verifies correct inheritance of target attributes during template
-// instantiation and specialization.
-
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
-
-#include "Inputs/cuda.h"
-
-// Function must inherit target attributes during instantiation, but not during
-// specialization.
-template  __host__ __device__ T function_template(const T );
-
-// Specialized functions have their own attributes.
-// expected-note@+1 {{candidate function not viable: call to __host__ function from __device__ function}}
-template <> __host__ float function_template(const float );
-
-// expected-note@+1 {{candidate function not viable: call to __device__ function from __host__ function}}
-template <> __device__ double function_template(const double );
-
-__host__ void hf() {
-  function_template(1.0f); // OK. Specialization is __host__.
-  function_template(2.0); // expected-error {{no matching function for call to 'function_template'}}
-  function_template(1);   // OK. Instantiated function template is HD.
-}
-__device__ void df() {
-  function_template(3.0f); // expected-error {{no matching function for call to 'function_template'}}
-  function_template(4.0); // OK. Specialization is __device__.
-  function_template(1);   // OK. Instantiated function template is HD.
-}
Index: test/SemaCUDA/function-template-overload.cu
===
--- /dev/null
+++ test/SemaCUDA/function-template-overload.cu
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+
+#include "Inputs/cuda.h"
+
+struct HType {}; // expected-note-re 6 {{candidate constructor {{.*}} not viable: no known conversion from 'DType'}}
+struct DType {}; // expected-note-re 6 {{candidate constructor {{.*}} not viable: no known conversion from 'HType'}}
+struct HDType {};
+
+template  __host__ HType overload_h_d(T a) { return HType(); }
+// expected-note@-1 2 {{candidate template ignored: could not match 'HType' against 'DType'}}
+// expected-note@-2 2 {{candidate template ignored: target attributes do not match}}
+template  __device__ DType overload_h_d(T a) { return DType(); }
+// expected-note@-1 2 {{candidate template ignored: could not match 'DType' against 'HType'}}
+// expected-note@-2 2 {{candidate template ignored: target attributes do not match}}
+
+// Check explicit instantiation.
+template  __device__ __host__ DType overload_h_d(int a); // There's no HD template...
+// expected-error@-1 {{explicit instantiation of 'overload_h_d' does not refer to a function template, variable template, member function, member class, or static data member}}
+template  __device__ __host__ HType overload_h_d(int a); // There's no HD template...
+// expected-error@-1 {{explicit instantiation of 'overload_h_d' does not refer to a function template, variable template, member function, member class, or static data member}}
+template  __device__ DType overload_h_d(int a); // OK. instantiates D
+template  __host__ HType overload_h_d(int a); // OK. instantiates H
+
+// Check explicit specialization.
+template  <> __device__ __host__ DType overload_h_d(long a); // There's no HD template...
+// expected-error@-1 {{no function template matches function template specialization 'overload_h_d'}}
+template  <> __device__ __host__ HType overload_h_d(long a); // There's no HD template...
+// expected-error@-1 {{no function template matches function template specialization 'overload_h_d'}}
+template  <> __device__ DType overload_h_d(long a); // OK. instantiates D
+template  <> __host__ HType overload_h_d(long a); // OK. instantiates H
+
+
+// Can't overload HD template with H or D template, though functions are OK.
+template  __host__ __device__ HDType overload_hd(T a) { return HDType(); }
+// expected-note@-1 {{previous declaration is here}}
+// expected-note@-2 2 {{candidate template ignored: could not match 'HDType' against 

[PATCH] D25669: [Driver] Simplify ToolChain::GetCXXStdlibType (NFC)

2016-12-06 Thread Lei Zhang via Phabricator via cfe-commits
zlei added a comment.

LGTM


https://reviews.llvm.org/D25669



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


[PATCH] D25796: [CUDA] Create __host__ and device variants of standard allocator declarations.

2016-12-06 Thread Artem Belevich via Phabricator via cfe-commits
tra closed this revision.
tra added a comment.

Landed in r284879.


https://reviews.llvm.org/D25796



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


r288872 - Driver: Remove support for -fobjc-gc*

2016-12-06 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Dec  6 18:31:10 2016
New Revision: 288872

URL: http://llvm.org/viewvc/llvm-project?rev=288872=rev
Log:
Driver: Remove support for -fobjc-gc*

As a first step toward removing Objective-C garbage collection from
Clang, remove support from the driver.  I'm hoping this will flush out
any expected bots/configurations/whatever that might rely on it.

I've left the options behind temporarily in -cc1 to keep tests passing.
I'll kill them off entirely in a follow up when I've had a chance to
update/delete the rest of Clang.

Removed:
cfe/trunk/test/Driver/darwin-objc-gc.m
Modified:
cfe/trunk/docs/CommandGuide/clang.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=288872=288871=288872=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Tue Dec  6 18:31:10 2016
@@ -167,16 +167,6 @@ Language Selection and Mode Options
 
  Enable the "Blocks" language feature.
 
-.. option:: -fobjc-gc-only
-
- Indicate that Objective-C code should be compiled in GC-only mode, which only
- works when Objective-C Garbage Collection is enabled.
-
-.. option:: -fobjc-gc
-
- Indicate that Objective-C code should be compiled in hybrid-GC mode, which
- works with both GC and non-GC mode.
-
 .. option:: -fobjc-abi-version=version
 
  Select the Objective-C ABI version to use. Available versions are 1 (legacy

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=288872=288871=288872=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Dec  6 18:31:10 
2016
@@ -137,8 +137,6 @@ def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
 def err_drv_conflicting_deployment_targets : Error<
   "conflicting deployment targets, both '%0' and '%1' are present in 
environment">;
-def err_drv_objc_gc_arr : Error<
-  "cannot specify both '-fobjc-arc' and '%0'">;
 def err_arc_unsupported_on_runtime : Error<
   "-fobjc-arc is not supported on platforms using the legacy runtime">;
 def err_arc_unsupported_on_toolchain : Error< // feel free to generalize this
@@ -211,8 +209,6 @@ def warn_drv_overriding_flag_option : Wa
 def warn_drv_treating_input_as_cxx : Warning<
   "treating '%0' input as '%1' when in C++ mode, this behavior is deprecated">,
   InGroup;
-def warn_drv_objc_gc_unsupported : Warning<
-  "Objective-C garbage collection is not supported on this platform, ignoring 
'%0'">;
 def warn_drv_pch_not_first_include : Warning<
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;
 def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=288872=288871=288872=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Dec  6 18:31:10 2016
@@ -641,6 +641,12 @@ def fdefault_calling_conv_EQ : Joined<["
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
   HelpText<"Include the default header file for OpenCL">;
 
+// FIXME: Remove these entirely once functionality/tests have been excised.
+def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group,
+  HelpText<"Use GC exclusively for Objective-C related memory management">;
+def fobjc_gc : Flag<["-"], "fobjc-gc">, Group,
+  HelpText<"Enable Objective-C garbage collection">;
+
 
//===--===//
 // Header Search Options
 
//===--===//

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=288872=288871=288872=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Dec  6 18:31:10 2016
@@ -1092,10 +1092,6 @@ def : Flag<["-"], "faligned-new">, Alias
 def : Flag<["-"], "fno-aligned-new">, Alias;
 def faligned_new_EQ : Joined<["-"], "faligned-new=">;
 
-def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group, 
Flags<[CC1Option]>,
-  HelpText<"Use GC 

r288870 - Fix test.

2016-12-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec  6 18:24:40 2016
New Revision: 288870

URL: http://llvm.org/viewvc/llvm-project?rev=288870=rev
Log:
Fix test.

Modified:
cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp

Modified: cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp?rev=288870=288869=288870=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp Tue Dec  6 18:24:40 2016
@@ -124,7 +124,7 @@ struct AsBase : Noncopyable {
   AsBase() : Noncopyable(make()) {} // expected-error {{deleted}}
 };
 struct AsDelegating final {
-  AsDelegating(const AsDelegating &) = delete;
+  AsDelegating(const AsDelegating &) = delete; // expected-note {{deleted}}
   static AsDelegating make(int);
 
   // The base constructor version of this is problematic; the complete object


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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288869: [MS-ABI]V-base dtor called more than needed when 
throw happens in v-base ctor… (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D27358?vs=80491=80505#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27358

Files:
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -165,6 +165,9 @@
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) override;
@@ -1135,6 +1138,25 @@
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1512,11 +1534,21 @@
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 getFromDtorType(Type));
+  if (BaseDtorEndBB) {
+// Complete object handler should continue to be the remaining 
+CGF.Builder.CreateBr(BaseDtorEndBB);
+CGF.EmitBlock(BaseDtorEndBB);
+  } 
 }
 
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
Index: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -278,3 +278,38 @@
 // WIN32-LIFETIME: %[[bc2:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8*
 // WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc2]])
 }
+
+struct class_2 {
+  class_2();
+  virtual ~class_2();
+};
+struct class_1 : virtual class_2 {
+  class_1(){throw "Unhandled exception";}
+  virtual ~class_1() {}
+};
+struct class_0 : class_1 {
+  class_0() ;
+  virtual ~class_0() {}
+};
+
+class_0::class_0() {
+  // WIN32: define x86_thiscallcc %struct.class_0* @"\01??0class_0@@QAE@XZ"(%struct.class_0* returned %this, i32 %is_most_derived) 
+  // WIN32: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
+  // WIN32: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
+  // WIN32: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
+  // WIN32: [[INIT_VBASES]]
+  // WIN32: br label %[[SKIP_VBASES]]
+  // WIN32: [[SKIP_VBASES]]
+// ehcleanup:
+  // WIN32: %[[CLEANUPPAD:.*]] = cleanuppad within none []
+  // WIN32-NEXT: bitcast %{{.*}}* %{{.*}} to i8*
+  // WIN32-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i{{.*}} {{.}} 
+  // WIN32-NEXT: bitcast i8* %{{.*}} to %{{.*}}*
+  // WIN32-NEXT: %[[SHOULD_CALL_VBASE_DTOR:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32-NEXT: br i1 %[[SHOULD_CALL_VBASE_DTOR]], label %[[DTOR_VBASE:.*]], label %[[SKIP_VBASE:.*]]
+  // WIN32: [[DTOR_VBASE]]
+  // WIN32-NEXT: call x86_thiscallcc void @"\01??1class_2@@UAE@XZ"
+  // WIN32: br label %[[SKIP_VBASE]]
+  // WIN32: [[SKIP_VBASE]]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288869 - [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Dec  6 18:21:45 2016
New Revision: 288869

URL: http://llvm.org/viewvc/llvm-project?rev=288869=rev
Log:
[MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor 
in window. Need add "complete object flag" check in eh cleanup code.

The problem only happen on window ( A MS-ABI issuer )

The nature of the problem is virtual base dtor called more than it is needed 
after exception throw in inheriting base class(with virtual bases) ctor.

The root problem is when throw happen, not all virtual base classes have been 
contructed, so not all virtual base dtors are need to call for ehcleanup.

clang has code to handle vbase initialization: basically add check for 
"complete object flag" before call to v-base ctor.
But that part is missing for cleanup code.

To fix this add similar code as v-base init to cleanup code, same algorithm.

1> Add new routine:
EmitDtorCompleteObjectHandler

With corresponding to EmitCtorCompleteObjectHandler

2> In the EmitDestructorCal
Call EmitDtorCompleteObjectHandler when generate ehcleanup inside ctor.

Just add check for "complete object flag" before call to v-base dtor.

Without my change:
ehcleanup: ; preds = %ctor.skip_vbases

%13 = cleanuppad within none [], !dbg !66
%14 = bitcast %struct.class_0* %this1 to i8*, !dbg !66
%15 = getelementptr inbounds i8, i8* %14, i64 8, !dbg !66
%16 = bitcast i8* %15 to %struct.class_2*, !dbg !66
call void @"\01??1class_2@@UEAA@XZ"(%struct.class_2* %16) #6 [ "funclet"(token

%13) ], !dbg !66

cleanupret from %13 unwind to caller, !dbg !66

with my change:
ehcleanup: ; preds = %ctor.skip_vbases

%13 = cleanuppad within none [], !dbg !66
%14 = bitcast %struct.class_0* %this1 to i8*, !dbg !66
%15 = getelementptr inbounds i8, i8* %14, i64 8, !dbg !66
%16 = bitcast i8* %15 to %struct.class_2*, !dbg !66
%is_complete_object4 = icmp ne i32 %is_most_derived2, 0, !dbg !66
br i1 %is_complete_object4, label %Dtor.dtor_vbase, label %Dtor.skip_vbase, !d

bg !66

Dtor.dtor_vbase: ; preds = %ehcleanup

call void @"\01??1class_2@@UEAA@XZ"(%struct.class_2* %16) #6 [ "funclet"(token

%13) ], !dbg !66

br label %Dtor.skip_vbase, !dbg !66

Dtor.skip_vbase: ; preds = %Dtor.dtor_vbase, %ehcleanup

cleanupret from %13 unwind to caller, !dbg !66

Please let me know you need more info.

Patch by Jennifer Yu.

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


Modified:
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=288869=288868=288869=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Tue Dec  6 18:21:45 2016
@@ -165,6 +165,9 @@ public:
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) 
override;
@@ -1135,6 +1138,25 @@ MicrosoftCXXABI::EmitCtorCompleteObjectH
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit 
parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = 
CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = 
CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1512,11 +1534,21 @@ void MicrosoftCXXABI::EmitDestructorCall
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 

Re: r288093 - Use ${:uid} to generate unique MS asm labels, not {:uid}

2016-12-06 Thread Reid Kleckner via cfe-commits
Comments in r288868. It implements GCC's %= inline asm feature, and we're
just using it from MS-style inline asm to avoid duplicate labels clashing.

2016-12-01 0:37 GMT-08:00 Sean Silva :

> what is this ${:uid} thing? Could the comment
> in Sema::GetOrCreateMSAsmLabel explain it?
>
> -- Sean Silva
>
> On Mon, Nov 28, 2016 at 4:39 PM, Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rnk
>> Date: Mon Nov 28 18:39:37 2016
>> New Revision: 288093
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=288093=rev
>> Log:
>> Use ${:uid} to generate unique MS asm labels, not {:uid}
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
>> cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
>> cfe/trunk/test/CodeGen/ms-inline-asm.c
>> cfe/trunk/test/CodeGen/ms-inline-asm.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaS
>> tmtAsm.cpp?rev=288093=288092=288093=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Nov 28 18:39:37 2016
>> @@ -753,7 +753,7 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S
>>  // Create an internal name for the label.  The name should not be a
>> valid mangled
>>  // name, and should be unique.  We use a dot to make the name an
>> invalid mangled
>>  // name.
>> -OS << "__MSASMLABEL_.{:uid}__";
>> +OS << "__MSASMLABEL_.${:uid}__";
>>  for (char C : ExternalLabelName) {
>>OS << C;
>>// We escape '$' in asm strings by replacing it with "$$"
>>
>> Modified: cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/
>> mozilla-ms-inline-asm.c?rev=288093=288092=288093=diff
>> 
>> ==
>> --- cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c (original)
>> +++ cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c Mon Nov 28 18:39:37
>> 2016
>> @@ -20,7 +20,7 @@ void invoke(void* that, unsigned methodI
>>  // CHECK: call void asm sideeffect inteldialect
>>  // CHECK: mov edx,dword ptr $1
>>  // CHECK: test edx,edx
>> -// CHECK: jz {{[^_]*}}__MSASMLABEL_.{:uid}__noparams
>> +// CHECK: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
>>  // ^ Can't use {{.*}} here because the matching is greedy.
>>  // CHECK: mov eax,edx
>>  // CHECK: shl eax,$$3
>> @@ -28,7 +28,7 @@ void invoke(void* that, unsigned methodI
>>  // CHECK: mov ecx,esp
>>  // CHECK: push dword ptr $0
>>  // CHECK: call dword ptr $2
>> -// CHECK: {{.*}}__MSASMLABEL_.{:uid}__noparams:
>> +// CHECK: {{.*}}__MSASMLABEL_.${:uid}__noparams:
>>  // CHECK: mov ecx,dword ptr $3
>>  // CHECK: push ecx
>>  // CHECK: mov edx,[ecx]
>>
>> Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/
>> ms-inline-asm.c?rev=288093=288092=288093=diff
>> 
>> ==
>> --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
>> +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Nov 28 18:39:37 2016
>> @@ -249,7 +249,7 @@ void t23() {
>>the_label:
>>}
>>  // CHECK: t23
>> -// CHECK: call void asm sideeffect inteldialect
>> "{{.*}}__MSASMLABEL_.{:uid}__the_label:", "~{dirflag},~{fpsr},~{flags}"()
>> +// CHECK: call void asm sideeffect inteldialect
>> "{{.*}}__MSASMLABEL_.${:uid}__the_label:", "~{dirflag},~{fpsr},~{flags}"(
>> )
>>  }
>>
>>  void t24_helper(void) {}
>> @@ -595,7 +595,7 @@ void label1() {
>>  jmp label
>>}
>>// CHECK-LABEL: define void @label1()
>> -  // CHECK: call void asm sideeffect inteldialect
>> "{{.*}}__MSASMLABEL_.{:uid}__label:\0A\09jmp
>> {{.*}}__MSASMLABEL_.{:uid}__label", "~{dirflag},~{fpsr},~{flags}"()
>> [[ATTR1:#[0-9]+]]
>> +  // CHECK: call void asm sideeffect inteldialect
>> "{{.*}}__MSASMLABEL_.${:uid}__label:\0A\09jmp
>> {{.*}}__MSASMLABEL_.${:uid}__label", "~{dirflag},~{fpsr},~{flags}"()
>> [[ATTR1:#[0-9]+]]
>>  }
>>
>>  void label2() {
>> @@ -604,7 +604,7 @@ void label2() {
>>  label:
>>}
>>// CHECK-LABEL: define void @label2
>> -  // CHECK: call void asm sideeffect inteldialect "jmp
>> {{.*}}__MSASMLABEL_.{:uid}__label\0A\09{{.*}}__MSASMLABEL_.{:uid}__label:",
>> "~{dirflag},~{fpsr},~{flags}"()
>> +  // CHECK: call void asm sideeffect inteldialect "jmp
>> {{.*}}__MSASMLABEL_.${:uid}__label\0A\09{{.*}}__MSASMLABEL_.${:uid}__label:",
>> "~{dirflag},~{fpsr},~{flags}"()
>>  }
>>
>>  void label3() {
>> @@ -613,7 +613,7 @@ void label3() {
>>  mov eax, label
>>}
>>// CHECK-LABEL: define void @label3
>> -  // CHECK: call void asm sideeffect inteldialect
>> "{{.*}}__MSASMLABEL_.{:uid}__label:\0A\09mov eax,
>> {{.*}}__MSASMLABEL_.{:uid}__label", "~{eax},~{dirflag},~{fpsr},~{f
>> lags}"()
>> +  // CHECK: call void asm sideeffect 

r288868 - Address review feedback by adding comments about ${:uid}

2016-12-06 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Dec  6 18:17:18 2016
New Revision: 288868

URL: http://llvm.org/viewvc/llvm-project?rev=288868=rev
Log:
Address review feedback by adding comments about ${:uid}

Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=288868=288867=288868=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Dec  6 18:17:18 2016
@@ -750,9 +750,11 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S
 // Otherwise, insert it, but only resolve it if we have seen the label 
itself.
 std::string InternalName;
 llvm::raw_string_ostream OS(InternalName);
-// Create an internal name for the label.  The name should not be a valid 
mangled
-// name, and should be unique.  We use a dot to make the name an invalid 
mangled
-// name.
+// Create an internal name for the label.  The name should not be a valid
+// mangled name, and should be unique.  We use a dot to make the name an
+// invalid mangled name. We use LLVM's inline asm ${:uid} escape so that a
+// unique label is generated each time this blob is emitted, even after
+// inlining or LTO.
 OS << "__MSASMLABEL_.${:uid}__";
 for (char C : ExternalLabelName) {
   OS << C;


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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 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 good, please commit. If you don't have commit access, ask a coworker who 
does to land it, otherwise I'll try to get around to it at some point. Thanks 
for the fix!


Repository:
  rL LLVM

https://reviews.llvm.org/D27358



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


[PATCH] D27345: [OpenMP] Sema and parsing for 'teams distribute parallel for' pragma

2016-12-06 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 marked an inline comment as done.
kkwli0 added inline comments.



Comment at: lib/Basic/OpenMPKinds.cpp:757
  Kind == OMPD_distribute_parallel_for_simd ||
  Kind == OMPD_distribute_simd;
   // TODO add next directives.

ABataev wrote:
> Should it be added here along with OMPD_teams_distribute_parallel_for_simd? 
The isOpenMPNestingDistributeDirective is for the construct that has distribute 
be the outermost (e.g. distribute *) so that it can be checked against the 
nesting region whether it is teams or not.  I do not think it is necessary to 
add it here.


https://reviews.llvm.org/D27345



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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I'll land it, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D27358



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


r288866 - [c++17] P0135R1: Guaranteed copy elision.

2016-12-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec  6 17:52:28 2016
New Revision: 288866

URL: http://llvm.org/viewvc/llvm-project?rev=288866=rev
Log:
[c++17] P0135R1: Guaranteed copy elision.

When an object of class type is initialized from a prvalue of the same type
(ignoring cv qualifications), use the prvalue to initialize the object directly
instead of inserting a redundant elidable call to a copy constructor.

Added:
cfe/trunk/test/CodeGenCXX/cxx1z-copy-omission.cpp
cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/drs/dr10xx.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=288866=288865=288866=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Dec  6 17:52:28 2016
@@ -3786,7 +3786,7 @@ public:
 
   /// \brief Build an empty initializer list.
   explicit InitListExpr(EmptyShell Empty)
-: Expr(InitListExprClass, Empty) { }
+: Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
 
   unsigned getNumInits() const { return InitExprs.size(); }
 
@@ -3894,6 +3894,11 @@ public:
   // literal or an @encode?
   bool isStringLiteralInit() const;
 
+  /// Is this a transparent initializer list (that is, an InitListExpr that is
+  /// purely syntactic, and whose semantics are that of the sole contained
+  /// initializer)?
+  bool isTransparent() const;
+
   SourceLocation getLBraceLoc() const { return LBraceLoc; }
   void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
   SourceLocation getRBraceLoc() const { return RBraceLoc; }

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=288866=288865=288866=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Dec  6 17:52:28 2016
@@ -1864,6 +1864,24 @@ bool InitListExpr::isStringLiteralInit()
   return isa(Init) || isa(Init);
 }
 
+bool InitListExpr::isTransparent() const {
+  assert(isSemanticForm() && "syntactic form never semantically transparent");
+
+  // A glvalue InitListExpr is always just sugar.
+  if (isGLValue()) {
+assert(getNumInits() == 1 && "multiple inits in glvalue init list");
+return true;
+  }
+
+  // Otherwise, we're sugar if and only if we have exactly one initializer that
+  // is of the same type.
+  if (getNumInits() != 1 || !getInit(0))
+return false;
+
+  return getType().getCanonicalType() ==
+ getInit(0)->getType().getCanonicalType();
+}
+
 SourceLocation InitListExpr::getLocStart() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
@@ -2246,12 +2264,15 @@ bool Expr::isUnusedResultAWarning(const
 // effects (e.g. a placement new with an uninitialized POD).
   case CXXDeleteExprClass:
 return false;
+  case MaterializeTemporaryExprClass:
+return cast(this)->GetTemporaryExpr()
+   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
   case CXXBindTemporaryExprClass:
-return (cast(this)
-->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx));
+return cast(this)->getSubExpr()
+   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
   case ExprWithCleanupsClass:
-return (cast(this)
-->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx));
+return cast(this)->getSubExpr()
+   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
   }
 }
 

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=288866=288865=288866=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec  6 17:52:28 2016
@@ -5670,6 +5670,9 @@ bool RecordExprEvaluator::VisitCastExpr(
 }
 
 bool RecordExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
+  if (E->isTransparent())
+return Visit(E->getInit(0));
+
   const RecordDecl *RD = E->getType()->castAs()->getDecl();
   if (RD->isInvalidDecl()) return false;
   const ASTRecordLayout  = Info.Ctx.getASTRecordLayout(RD);

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 

[PATCH] D27486: Correct class-template deprecation behavior

2016-12-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D27486#615174, @rsmith wrote:

> Thanks!
>
> If you look at `Sema::InstantiateClass`, we instantiate all of the attributes 
> there. The problem seems to be that that happens only when instantiating the 
> class definition, which happens after the point at which we would diagnose 
> use of a deprecated declaration.
>
> This change will result in us having two copies of the `deprecated` attribute 
> after we instantiate the class definition -- one from instantiating the 
> declaration and another from instantiating the definition.


Well darn, I didn't notice this.

> Perhaps a better way to handle this would be to add a flag to the attribute 
> definitions (in Attr.td) to indicate whether they apply to a declaration or 
> just a definition (and thus whether they should be instantiated with a 
> declaration, or only with a definition), and then instantiate the relevant 
> subset when creating the `ClassTemplateSpecializationDecl` (and other kinds 
> of decl -- I expect the same thing will happen for member classes of class 
> templates, for function templates, and so on).

I can definitely look into this.  I have a feeling (based on the fact that this 
attribute IS picked up by function-template-instantiations) that it likely 
wouldn't be necessary for the others, but I can start to look into the 
scaffolding to get this to happen.

> @aaron.ballman Does that seem reasonable to you? If so, we should do some 
> investigation of the attribute set to figure out what the best default is.

As far as this investigation, I'd suspect that the current behavior (never 
applies to declaration) is likely the correct 'default' is. I suspect that 
there is also a massive work-item to go through the current list to see which 
SHOULD apply to declarations.


https://reviews.llvm.org/D27486



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


[PATCH] D27488: Fixing test to work when the compiler defaults to a different c++ standard version.

2016-12-06 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added a comment.

I am okay with the changes.  Thanks.  Alexey will have the final say.


https://reviews.llvm.org/D27488



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


Re: [PATCH] D27005: [lit] Support custom parsers in parseIntegratedTestScript

2016-12-06 Thread Eric Fiselier via cfe-commits
Fixed in r288863.

On Tue, Dec 6, 2016 at 4:00 PM, Eric Fiselier  wrote:

> Investigating right now. Sorry for the breakage.
>
> On Dec 6, 2016 3:55 PM, "Matthias Braun via Phabricator" <
> revi...@reviews.llvm.org> wrote:
>
> MatzeB added a comment.
>
> This breaks the test-suite lit scripts:
>
> Exception during script execution:
> Traceback (most recent call last):
>
>   File "/Users/mbraun/dev/public_llvm/utils/lit/lit/run.py", line 183, in
> execute_test
> result = test.config.test_format.execute(test, self.lit_config)
>   File "/Users/mbraun/dev/test-suite/litsupport/test.py", line 73, in
> execute
> testfile.parse(context, test.getSourcePath())
>   File "/Users/mbraun/dev/test-suite/litsupport/testfile.py", line 45, in
> parse
> command_type,))
>
> ValueError: unknown script command type: 'RUN:'
>
>
> https://reviews.llvm.org/D27005
>
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27488: Fixing test to work when the compiler defaults to a different c++ standard version.

2016-12-06 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.
dyung added a reviewer: kkwli0.
dyung added a subscriber: cfe-commits.

This test as originally written fails when run with a compiler that defaults to 
a different C++ standard. This patch fixes up the test and adds testing it 
explicitly using c++98 and c++11. The changes were adapted from similar work 
done in distribute_parallel_for_simd_collapse_messages.cpp.


https://reviews.llvm.org/D27488

Files:
  teams_distribute_simd_collapse_messages.cpp


Index: teams_distribute_simd_collapse_messages.cpp
===
--- teams_distribute_simd_collapse_messages.cpp
+++ teams_distribute_simd_collapse_messages.cpp
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -50,9 +55,12 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 
for loops after '#pragma omp teams distribute simd', but found only 1}}
 
-// expected-error@+4 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
-// expected-error@+3 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+// expected-error@+7 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
+// expected-error@+6 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+// expected-error@+5 2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), 
collapse (-5)
   for (int i = ST; i < N; i++)
@@ -62,7 +70,11 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
 
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+#if __cplusplus <= 199711L
+  // expected-error@+5 2 {{expression is not an integral constant expression}}
+#else
+  // expected-error@+3 2 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++)
@@ -110,14 +122,20 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for 
loops after '#pragma omp teams distribute simd', but found only 1}}
 
+#if __cplusplus >= 201103L
+  // expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(1) > 0 ? 1 : 2) // 
expected-error {{expression is not an integral constant expression}}
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+4 {{expression is not an integral constant expression}}
-// expected-error@+3 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
-// expected-error@+2 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+// expected-error@+7 {{expression is not an integral constant expression}}
+// expected-error@+6 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
+// expected-error@+5 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+#if __cplusplus >= 201103L
+// expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), 
collapse (-5) 
   for (int i = 4; i < 12; i++)
@@ -128,7 +146,11 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+  // expected-error@+5 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#else
+  // expected-error@+3 {{expression is not an integral constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = 4; i < 12; i++)


Index: teams_distribute_simd_collapse_messages.cpp
===
--- teams_distribute_simd_collapse_messages.cpp
+++ teams_distribute_simd_collapse_messages.cpp
@@ -1,8 +1,13 @@
 // RUN: 

r288862 - [OpenMP] Fix typo in the run command in the test case. NFC.

2016-12-06 Thread Kelvin Li via cfe-commits
Author: kli
Date: Tue Dec  6 17:18:06 2016
New Revision: 288862

URL: http://llvm.org/viewvc/llvm-project?rev=288862=rev
Log:
[OpenMP] Fix typo in the run command in the test case. NFC.

Modified:
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp?rev=288862=288861=288862=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp 
(original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp Tue 
Dec  6 17:18:06 2016
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
-// rUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
-// rUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
 // expected-no-diagnostics
 
 #ifndef HEADER


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


[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/APValue.h:379
   void setLValue(LValueBase B, const CharUnits , NoLValuePath,
- unsigned CallIndex);
+ unsigned CallIndex, bool IsNuppPtr);
   void setLValue(LValueBase B, const CharUnits ,

Typo.



Comment at: lib/AST/ExprConstant.cpp:1153
+IsNullPtr = false;
+}
+void adjustOffsetAndIndex(EvalInfo , const Expr *E, uint64_t Index,

Hmm.  I think the code would be clearer overall if this were conditionalized in 
the callers instead of here.



Comment at: lib/CodeGen/CGExprScalar.cpp:1532
+  return llvm::ConstantInt::get(ConvertType(DestTy),
+  CGF.getContext().getTargetNullPtrValue(E->getType()));
 assert(!DestTy->isBooleanType() && "bool should use PointerToBool");

yaxunl wrote:
> rjmccall wrote:
> > Why is this necessary?  ptrtoint on the recursively-emitted null pointer 
> > should do this automatically.
> Since the target knows the value in the null pointers, it can fold a null 
> pointer to integer literal directly.
> 
> The above code does that, e.g.
> 
> ```
> void test_cast_null_pointer_to_sizet_calee(size_t arg_private,
>size_t arg_local,
>size_t arg_global,
>size_t arg_constant,
>size_t arg_generic);
> 
> // CHECK-LABEL: test_cast_null_pointer_to_sizet
> // CHECK: call void @test_cast_null_pointer_to_sizet_calee(i64 -1, i64 -1, 
> i64 0, i64 0, i64 0)
> void test_cast_null_pointer_to_sizet(void) {
>   test_cast_null_pointer_to_sizet_calee((size_t)((private char*)0),
> (size_t)((local char*)0),
> (size_t)((global char*)0),
> (size_t)((constant char*)0),
> (size_t)((generic char*)0));
> }
> 
> ```
> 
> Without the above code, we only get ptrtoint instructions.
Oh, does the constant folder not know how to fold ptrtoint(inttoptr(X)) -> X?  
I guess that's probably LLVM's nominal target-independence rearing its head.

Is getting a slightly LLVM constant actually important here?  I would prefer to 
avoid this complexity (and unnecessary recursive walk) if possible.



Comment at: lib/CodeGen/TargetInfo.h:236
+  virtual llvm::Value *performAddrSpaceCast(CodeGen::CodeGenFunction ,
+  Expr *E, QualType DestTy) const;
+

This should just take a Value* and the source and dest types.


https://reviews.llvm.org/D26196



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


[PATCH] D27486: Correct class-template deprecation behavior

2016-12-06 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Thanks!

If you look at `Sema::InstantiateClass`, we instantiate all of the attributes 
there. The problem seems to be that that happens only when instantiating the 
class definition, which happens after the point at which we would diagnose use 
of a deprecated declaration.

This change will result in us having two copies of the `deprecated` attribute 
after we instantiate the class definition -- one from instantiating the 
declaration and another from instantiating the definition. Perhaps a better way 
to handle this would be to add a flag to the attribute definitions (in Attr.td) 
to indicate whether they apply to a declaration or just a definition (and thus 
whether they should be instantiated with a declaration, or only with a 
definition), and then instantiate the relevant subset when creating the 
`ClassTemplateSpecializationDecl` (and other kinds of decl -- I expect the same 
thing will happen for member classes of class templates, for function 
templates, and so on).

@aaron.ballman Does that seem reasonable to you? If so, we should do some 
investigation of the attribute set to figure out what the best default is.


https://reviews.llvm.org/D27486



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


Re: [PATCH] D27005: [lit] Support custom parsers in parseIntegratedTestScript

2016-12-06 Thread Eric Fiselier via cfe-commits
Investigating right now. Sorry for the breakage.

On Dec 6, 2016 3:55 PM, "Matthias Braun via Phabricator" <
revi...@reviews.llvm.org> wrote:

MatzeB added a comment.

This breaks the test-suite lit scripts:

Exception during script execution:
Traceback (most recent call last):

  File "/Users/mbraun/dev/public_llvm/utils/lit/lit/run.py", line 183, in
execute_test
result = test.config.test_format.execute(test, self.lit_config)
  File "/Users/mbraun/dev/test-suite/litsupport/test.py", line 73, in
execute
testfile.parse(context, test.getSourcePath())
  File "/Users/mbraun/dev/test-suite/litsupport/testfile.py", line 45, in
parse
command_type,))

ValueError: unknown script command type: 'RUN:'


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


[PATCH] D27005: [lit] Support custom parsers in parseIntegratedTestScript

2016-12-06 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added a comment.

This breaks the test-suite lit scripts:

Exception during script execution:
Traceback (most recent call last):

  File "/Users/mbraun/dev/public_llvm/utils/lit/lit/run.py", line 183, in 
execute_test
result = test.config.test_format.execute(test, self.lit_config)
  File "/Users/mbraun/dev/test-suite/litsupport/test.py", line 73, in execute
testfile.parse(context, test.getSourcePath())
  File "/Users/mbraun/dev/test-suite/litsupport/testfile.py", line 45, in parse
command_type,))

ValueError: unknown script command type: 'RUN:'


https://reviews.llvm.org/D27005



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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 80491.
jyu2 added a comment.

last one missing test part diff.  Sorry for that


Repository:
  rL LLVM

https://reviews.llvm.org/D27358

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -164,6 +164,9 @@
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) override;
@@ -1127,6 +1130,25 @@
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1502,11 +1524,21 @@
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 getFromDtorType(Type));
+  if (BaseDtorEndBB) {
+// Complete object handler should continue to be the remaining 
+CGF.Builder.CreateBr(BaseDtorEndBB);
+CGF.EmitBlock(BaseDtorEndBB);
+  } 
 }
 
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -278,3 +278,38 @@
 // WIN32-LIFETIME: %[[bc2:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8*
 // WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc2]])
 }
+
+struct class_2 {
+  class_2();
+  virtual ~class_2();
+};
+struct class_1 : virtual class_2 {
+  class_1(){throw "Unhandled exception";}
+  virtual ~class_1() {}
+};
+struct class_0 : class_1 {
+  class_0() ;
+  virtual ~class_0() {}
+};
+
+class_0::class_0() {
+  // WIN32: define x86_thiscallcc %struct.class_0* @"\01??0class_0@@QAE@XZ"(%struct.class_0* returned %this, i32 %is_most_derived) 
+  // WIN32: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
+  // WIN32: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
+  // WIN32: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
+  // WIN32: [[INIT_VBASES]]
+  // WIN32: br label %[[SKIP_VBASES]]
+  // WIN32: [[SKIP_VBASES]]
+// ehcleanup:
+  // WIN32: %[[CLEANUPPAD:.*]] = cleanuppad within none []
+  // WIN32-NEXT: bitcast %{{.*}}* %{{.*}} to i8*
+  // WIN32-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i{{.*}} {{.}} 
+  // WIN32-NEXT: bitcast i8* %{{.*}} to %{{.*}}*
+  // WIN32-NEXT: %[[SHOULD_CALL_VBASE_DTOR:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32-NEXT: br i1 %[[SHOULD_CALL_VBASE_DTOR]], label %[[DTOR_VBASE:.*]], label %[[SKIP_VBASE:.*]]
+  // WIN32: [[DTOR_VBASE]]
+  // WIN32-NEXT: call x86_thiscallcc void @"\01??1class_2@@UAE@XZ"
+  // WIN32: br label %[[SKIP_VBASE]]
+  // WIN32: [[SKIP_VBASE]]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27486: Correct class-template deprecation behavior

2016-12-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane removed rL LLVM as the repository for this revision.
erichkeane updated this revision to Diff 80489.
erichkeane added a comment.

Corrected single line statement formatting re-squiggly braces.


https://reviews.llvm.org/D27486

Files:
  lib/Sema/SemaTemplate.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2352,6 +2352,9 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  if (auto *attr = ClassTemplate->getTemplatedDecl()
+   ->getAttr())
+Decl->addAttr(attr->clone(Context));
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
@@ -23,7 +23,8 @@
 X x1;
 X x2; // expected-warning {{'X' is deprecated}}
 
-template  class [[deprecated]] X2 {};
+template  class [[deprecated]] X2 {}; //expected-note {{'X2' 
has been explicitly marked deprecated here}}
 template <> class X2 {};
-X2 x3; // FIXME: no warning!
-X2 x4;
+X2 x3; // expected-warning {{'X2' is deprecated}}
+X2 x4; // No warning, the specialization removes it.
+


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2352,6 +2352,9 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  if (auto *attr = ClassTemplate->getTemplatedDecl()
+   ->getAttr())
+Decl->addAttr(attr->clone(Context));
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
@@ -23,7 +23,8 @@
 X x1;
 X x2; // expected-warning {{'X' is deprecated}}
 
-template  class [[deprecated]] X2 {};
+template  class [[deprecated]] X2 {}; //expected-note {{'X2' has been explicitly marked deprecated here}}
 template <> class X2 {};
-X2 x3; // FIXME: no warning!
-X2 x4;
+X2 x3; // expected-warning {{'X2' is deprecated}}
+X2 x4; // No warning, the specialization removes it.
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27486: Correct class-template deprecation behavior

2016-12-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: cfe-commits, chandlerc, majnemer.
erichkeane set the repository for this revision to rL LLVM.

Based on the comment in the test, and my reading of the standard, a deprecated 
warning should be issued in the following case:
template [[deprecated]] class Foo{};  Foo f;

This was not the case, because the ClassTemplateSpecializationDecl creation did 
not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should 
be copied, so instead I simply copy ONLY the deprecated attribute.


Repository:
  rL LLVM

https://reviews.llvm.org/D27486

Files:
  lib/Sema/SemaTemplate.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2352,6 +2352,10 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  if (auto *attr = ClassTemplate->getTemplatedDecl()
+   ->getAttr()) {
+Decl->addAttr(attr->clone(Context));
+  }
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
@@ -23,7 +23,8 @@
 X x1;
 X x2; // expected-warning {{'X' is deprecated}}
 
-template  class [[deprecated]] X2 {};
+template  class [[deprecated]] X2 {}; //expected-note {{'X2' 
has been explicitly marked deprecated here}}
 template <> class X2 {};
-X2 x3; // FIXME: no warning!
-X2 x4;
+X2 x3; // expected-warning {{'X2' is deprecated}}
+X2 x4; // No warning, the specialization removes it.
+


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2352,6 +2352,10 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  if (auto *attr = ClassTemplate->getTemplatedDecl()
+   ->getAttr()) {
+Decl->addAttr(attr->clone(Context));
+  }
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
@@ -23,7 +23,8 @@
 X x1;
 X x2; // expected-warning {{'X' is deprecated}}
 
-template  class [[deprecated]] X2 {};
+template  class [[deprecated]] X2 {}; //expected-note {{'X2' has been explicitly marked deprecated here}}
 template <> class X2 {};
-X2 x3; // FIXME: no warning!
-X2 x4;
+X2 x3; // expected-warning {{'X2' is deprecated}}
+X2 x4; // No warning, the specialization removes it.
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27422: Fix stack-use-after-scope in CheckExplicitlyDefaultedMemberExceptionSpec

2016-12-06 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Phabricator doesn't let me retroactively approve, but LGTM, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D27422



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


[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 80488.
yaxunl added a comment.

Fix some missed function name and remove accidentally added #if 0.


https://reviews.llvm.org/D26196

Files:
  include/clang/AST/APValue.h
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/APValue.cpp
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,529 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
+
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test constant folding of null pointer.
+// A null pointer should be folded to a null pointer in the target address space.
+
+// CHECK: @fold_generic = local_unnamed_addr addrspace(1) global i32 addrspace(4)* null, align 4
+generic int *fold_generic = (global int*)(generic float*)(private char*)0;
+
+// CHECK: @fold_priv = local_unnamed_addr addrspace(1) global i16* addrspacecast (i16 addrspace(4)* null to i16*), align 4
+private short *fold_priv = (private short*)(generic int*)(global void*)0;
+
+// CHECK: @fold_priv_arith = local_unnamed_addr addrspace(1) global i8* inttoptr (i32 9 to i8*), align 4
+private char *fold_priv_arith = (private char*)0 + 10;
+
+// CHECK: @fold_int = local_unnamed_addr addrspace(1) global i32 13, align 4
+int fold_int = (int)(private void*)(generic char*)(global int*)0 + 14;
+
+// CHECK: @fold_int2 = local_unnamed_addr addrspace(1) global i32 12, align 4
+int fold_int2 = (int) ((private void*)0 + 13);
+
+// CHECK: @fold_int3 = local_unnamed_addr addrspace(1) global i32 -1, align 4
+int fold_int3 = (int) ((private int*)0);
+
+// CHECK: @fold_int4 = local_unnamed_addr addrspace(1) global i32 7, align 4
+int fold_int4 = (int) &((private int*)0)[2];
+
+// CHECK: @fold_int5 = local_unnamed_addr addrspace(1) global i32 3, align 4
+int fold_int5 = (int) &((private StructTy1*)0)->p2;
+
+// Test static variable initialization.
+
+// NOOPT: @test_static_var.sp1 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp2 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp3 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp4 = internal addrspace(1) global i8* null, align 4
+// NOOPT: @test_static_var.sp5 = internal addrspace(1) global i8* null, align 4
+// NOOPT: @test_static_var.SS1 

[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 80487.
jyu2 added a comment.

Remove unnecessary check.


Repository:
  rL LLVM

https://reviews.llvm.org/D27358

Files:
  CodeGen/MicrosoftCXXABI.cpp


Index: CodeGen/MicrosoftCXXABI.cpp
===
--- CodeGen/MicrosoftCXXABI.cpp
+++ CodeGen/MicrosoftCXXABI.cpp
@@ -164,6 +164,9 @@
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) 
override;
@@ -1127,6 +1130,25 @@
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit 
parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = 
CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = 
CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1502,11 +1524,21 @@
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 getFromDtorType(Type));
+  if (BaseDtorEndBB) {
+// Complete object handler should continue to be the remaining 
+CGF.Builder.CreateBr(BaseDtorEndBB);
+CGF.EmitBlock(BaseDtorEndBB);
+  } 
 }
 
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,


Index: CodeGen/MicrosoftCXXABI.cpp
===
--- CodeGen/MicrosoftCXXABI.cpp
+++ CodeGen/MicrosoftCXXABI.cpp
@@ -164,6 +164,9 @@
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) override;
@@ -1127,6 +1130,25 @@
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1502,11 +1524,21 @@
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 getFromDtorType(Type));
+  if (BaseDtorEndBB) {
+// Complete object handler should continue to be the remaining 
+CGF.Builder.CreateBr(BaseDtorEndBB);
+

[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

I changed!  Thank you do much.  Upload new patch.




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1530-1532
+const CXXRecordDecl *ClassDecl =
+ cast(CGF.CurCodeDecl)->getParent();
+if (ClassDecl != nullptr && ClassDecl->getNumVBases())

rnk wrote:
> jyu2 wrote:
> > rnk wrote:
> > > These checks seem unnecessary. ForVirtualBase should never be true if 
> > > there are no vbases, and the IsMostDerivedClass assert will catch it if 
> > > not.
> > Yes, you are right.  I can either check here, or check if 
> > IsMostDerivedClass is nullptr return instead assertion inside 
> > EmitDtorCompleteObjectHandler.
> > 
> > As you know ForVirutalBase is set also for destructor.  But we only need 
> > this for ctor.  
> > 
> > 
> Yes, the first if check is necessary, but the second check for `ClassDecl != 
> nullptr && ClassDecl->getNumVBases()` should never be false when 
> ForVirtualBase is true.
Yes, make sense!! I don't know what I was think.  Changed.   


Repository:
  rL LLVM

https://reviews.llvm.org/D27358



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


[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 80485.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by John's comments.

Changed Ptr in function names to Pointer.
Added TargetCodeGenInfo::performAddrSpaceCast.
Fixed folding addrspacecast of null pointer with side effect and added a test.


https://reviews.llvm.org/D26196

Files:
  include/clang/AST/APValue.h
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/APValue.cpp
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,529 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
+
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test constant folding of null pointer.
+// A null pointer should be folded to a null pointer in the target address space.
+
+// CHECK: @fold_generic = local_unnamed_addr addrspace(1) global i32 addrspace(4)* null, align 4
+generic int *fold_generic = (global int*)(generic float*)(private char*)0;
+
+// CHECK: @fold_priv = local_unnamed_addr addrspace(1) global i16* addrspacecast (i16 addrspace(4)* null to i16*), align 4
+private short *fold_priv = (private short*)(generic int*)(global void*)0;
+
+// CHECK: @fold_priv_arith = local_unnamed_addr addrspace(1) global i8* inttoptr (i32 9 to i8*), align 4
+private char *fold_priv_arith = (private char*)0 + 10;
+
+// CHECK: @fold_int = local_unnamed_addr addrspace(1) global i32 13, align 4
+int fold_int = (int)(private void*)(generic char*)(global int*)0 + 14;
+
+// CHECK: @fold_int2 = local_unnamed_addr addrspace(1) global i32 12, align 4
+int fold_int2 = (int) ((private void*)0 + 13);
+
+// CHECK: @fold_int3 = local_unnamed_addr addrspace(1) global i32 -1, align 4
+int fold_int3 = (int) ((private int*)0);
+
+// CHECK: @fold_int4 = local_unnamed_addr addrspace(1) global i32 7, align 4
+int fold_int4 = (int) &((private int*)0)[2];
+
+// CHECK: @fold_int5 = local_unnamed_addr addrspace(1) global i32 3, align 4
+int fold_int5 = (int) &((private StructTy1*)0)->p2;
+
+// Test static variable initialization.
+
+// NOOPT: @test_static_var.sp1 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp2 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp3 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: 

[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 7 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:1532
+  return llvm::ConstantInt::get(ConvertType(DestTy),
+  CGF.getContext().getTargetNullPtrValue(E->getType()));
 assert(!DestTy->isBooleanType() && "bool should use PointerToBool");

rjmccall wrote:
> Why is this necessary?  ptrtoint on the recursively-emitted null pointer 
> should do this automatically.
Since the target knows the value in the null pointers, it can fold a null 
pointer to integer literal directly.

The above code does that, e.g.

```
void test_cast_null_pointer_to_sizet_calee(size_t arg_private,
   size_t arg_local,
   size_t arg_global,
   size_t arg_constant,
   size_t arg_generic);

// CHECK-LABEL: test_cast_null_pointer_to_sizet
// CHECK: call void @test_cast_null_pointer_to_sizet_calee(i64 -1, i64 -1, i64 
0, i64 0, i64 0)
void test_cast_null_pointer_to_sizet(void) {
  test_cast_null_pointer_to_sizet_calee((size_t)((private char*)0),
(size_t)((local char*)0),
(size_t)((global char*)0),
(size_t)((constant char*)0),
(size_t)((generic char*)0));
}

```

Without the above code, we only get ptrtoint instructions.


https://reviews.llvm.org/D26196



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


r288850 - Disable -Wweak-vtables when there are no key functions

2016-12-06 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Dec  6 15:44:41 2016
New Revision: 288850

URL: http://llvm.org/viewvc/llvm-project?rev=288850=rev
Log:
Disable -Wweak-vtables when there are no key functions

Our -Wweak-vtables diagnostic is powered by our key function
calculation, which checks if key functions are enabled. We won't find
any key functions in C++ ABIs that lack key functions, so -Wweak-vtables
was warning on every dynamic class before this change. So, turn off this
warning in ABIs without key functions.

Addresses PR31220

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/warn-weak-vtables.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=288850=288849=288850=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Dec  6 15:44:41 2016
@@ -14281,6 +14281,8 @@ bool Sema::DefineUsedVTables() {
 CXXRecordDecl *Class = VTableUses[I].first->getDefinition();
 if (!Class)
   continue;
+TemplateSpecializationKind ClassTSK =
+Class->getTemplateSpecializationKind();
 
 SourceLocation Loc = VTableUses[I].second;
 
@@ -14304,9 +14306,8 @@ bool Sema::DefineUsedVTables() {
   // of an explicit instantiation declaration, suppress the
   // vtable; it will live with the explicit instantiation
   // definition.
-  bool IsExplicitInstantiationDeclaration
-= Class->getTemplateSpecializationKind()
-  == TSK_ExplicitInstantiationDeclaration;
+  bool IsExplicitInstantiationDeclaration =
+  ClassTSK == TSK_ExplicitInstantiationDeclaration;
   for (auto R : Class->redecls()) {
 TemplateSpecializationKind TSK
   = cast(R)->getTemplateSpecializationKind();
@@ -14339,17 +14340,20 @@ bool Sema::DefineUsedVTables() {
 if (VTablesUsed[Canonical])
   Consumer.HandleVTable(Class);
 
-// Optionally warn if we're emitting a weak vtable.
-if (Class->isExternallyVisible() &&
-Class->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
+// Warn if we're emitting a weak vtable. The vtable will be weak if there 
is
+// no key function or the key function is inlined. Don't warn in C++ ABIs
+// that lack key functions, since the user won't be able to make one.
+if (Context.getTargetInfo().getCXXABI().hasKeyFunctions() &&
+Class->isExternallyVisible() && ClassTSK != TSK_ImplicitInstantiation) 
{
   const FunctionDecl *KeyFunctionDef = nullptr;
-  if (!KeyFunction || 
-  (KeyFunction->hasBody(KeyFunctionDef) && 
-   KeyFunctionDef->isInlined()))
-Diag(Class->getLocation(), Class->getTemplateSpecializationKind() ==
- TSK_ExplicitInstantiationDefinition 
- ? diag::warn_weak_template_vtable : diag::warn_weak_vtable) 
-  << Class;
+  if (!KeyFunction || (KeyFunction->hasBody(KeyFunctionDef) &&
+   KeyFunctionDef->isInlined())) {
+Diag(Class->getLocation(),
+ ClassTSK == TSK_ExplicitInstantiationDefinition
+ ? diag::warn_weak_template_vtable
+ : diag::warn_weak_vtable)
+<< Class;
+  }
 }
   }
   VTableUses.clear();

Modified: cfe/trunk/test/SemaCXX/warn-weak-vtables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-weak-vtables.cpp?rev=288850=288849=288850=diff
==
--- cfe/trunk/test/SemaCXX/warn-weak-vtables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-weak-vtables.cpp Tue Dec  6 15:44:41 2016
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple 
-Wweak-vtables -Wweak-template-vtables
-// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wno-weak-vtables -Wno-weak-template-vtables
+//
+// Check that this warning is disabled on MS ABI targets which don't have key
+// functions.
+// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 


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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Looks pretty good, just one more thing.




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1530-1532
+const CXXRecordDecl *ClassDecl =
+ cast(CGF.CurCodeDecl)->getParent();
+if (ClassDecl != nullptr && ClassDecl->getNumVBases())

jyu2 wrote:
> rnk wrote:
> > These checks seem unnecessary. ForVirtualBase should never be true if there 
> > are no vbases, and the IsMostDerivedClass assert will catch it if not.
> Yes, you are right.  I can either check here, or check if IsMostDerivedClass 
> is nullptr return instead assertion inside EmitDtorCompleteObjectHandler.
> 
> As you know ForVirutalBase is set also for destructor.  But we only need this 
> for ctor.  
> 
> 
Yes, the first if check is necessary, but the second check for `ClassDecl != 
nullptr && ClassDecl->getNumVBases()` should never be false when ForVirtualBase 
is true.


Repository:
  rL LLVM

https://reviews.llvm.org/D27358



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


[PATCH] D27447: [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

2016-12-06 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 80465.
malcolm.parsons added a comment.

Use AST_TYPE_TRAVERSE_MATCHER.


https://reviews.llvm.org/D27447

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


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2204,5 +2204,22 @@
functionDecl(hasName("bar"));
 }
 
+TEST(SubstTemplateTypeParmType, HasReplacementType)
+{
+  std::string Fragment = "template"
+ "double F(T t);"
+ "int i;"
+ "double j = F(i);";
+  EXPECT_TRUE(matches(Fragment, substTemplateTypeParmType(hasReplacementType(
+qualType(asString("int"));
+  EXPECT_TRUE(notMatches(Fragment, 
substTemplateTypeParmType(hasReplacementType(
+   qualType(asString("double"));
+  EXPECT_TRUE(
+  notMatches("template"
+ "double F();"
+ "double j = F<5>();",
+ substTemplateTypeParmType(hasReplacementType(qualType();
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -252,6 +252,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReplacementType);
   REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5019,6 +5019,22 @@
 /// \c substTemplateTypeParmType() matches the type of 't' but not '1'
 AST_TYPE_MATCHER(SubstTemplateTypeParmType, substTemplateTypeParmType);
 
+/// \brief Matches template type parameter substitutions that have a 
replacement
+/// type that matches the provided matcher.
+///
+/// Given
+/// \code
+///   template 
+///   double F(T t);
+///   int i;
+///   double j = F(i);
+/// \endcode
+///
+/// \c substTemplateTypeParmType(hasReplacementType(type())) matches int
+AST_TYPE_TRAVERSE_MATCHER(
+hasReplacementType, getReplacementType,
+AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType));
+
 /// \brief Matches template type parameter types.
 ///
 /// Example matches T, but not int.
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -5421,6 +5421,20 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html;>SubstTemplateTypeParmTypehasReplacementTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>Type
+Matches template 
type parameter substitutions that have a replacement
+type that matches the provided matcher.
+
+Given
+  template typename T
+  double F(T t);
+  int i;
+  double j = F(i);
+
+substTemplateTypeParmType(hasReplacementType(type())) matches int
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html;>SwitchStmtforEachSwitchCaseMatcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html;>SwitchCase
 InnerMatcher
 Matches each case 
or default statement belonging to the given switch
 statement. This matcher may produce multiple matches.


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2204,5 +2204,22 @@
functionDecl(hasName("bar"));
 }
 
+TEST(SubstTemplateTypeParmType, HasReplacementType)
+{
+  std::string Fragment = "template"
+ "double F(T t);"
+ "int i;"
+ "double j = F(i);";
+  EXPECT_TRUE(matches(Fragment, substTemplateTypeParmType(hasReplacementType(
+qualType(asString("int"));
+  EXPECT_TRUE(notMatches(Fragment, substTemplateTypeParmType(hasReplacementType(
+   qualType(asString("double"));
+  EXPECT_TRUE(
+  notMatches("template"
+ "double F();"
+ "double j = F<5>();",
+ substTemplateTypeParmType(hasReplacementType(qualType();
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp

[PATCH] D27478: Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls

2016-12-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 80464.
ahatanak added a comment.

Call getTypeInfoImpl from getDeclAlign to get the alignment of functions.


https://reviews.llvm.org/D27478

Files:
  lib/AST/ASTContext.cpp
  test/Sema/warn-cast-align.c


Index: test/Sema/warn-cast-align.c
===
--- test/Sema/warn-cast-align.c
+++ test/Sema/warn-cast-align.c
@@ -59,3 +59,11 @@
   i = (int *)
   i = (int *)a;
 }
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+  return (FnTy)
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1455,7 +1455,9 @@
 T = getPointerType(RT->getPointeeType());
 }
 QualType BaseT = getBaseElementType(T);
-if (!BaseT->isIncompleteType() && !T->isFunctionType()) {
+if (T->isFunctionType())
+  Align = getTypeInfoImpl(T.getTypePtr()).Align;
+else if (!BaseT->isIncompleteType()) {
   // Adjust alignments of declarations with array type by the
   // large-array alignment on the target.
   if (const ArrayType *arrayType = getAsArrayType(T)) {


Index: test/Sema/warn-cast-align.c
===
--- test/Sema/warn-cast-align.c
+++ test/Sema/warn-cast-align.c
@@ -59,3 +59,11 @@
   i = (int *)
   i = (int *)a;
 }
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+  return (FnTy)
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1455,7 +1455,9 @@
 T = getPointerType(RT->getPointeeType());
 }
 QualType BaseT = getBaseElementType(T);
-if (!BaseT->isIncompleteType() && !T->isFunctionType()) {
+if (T->isFunctionType())
+  Align = getTypeInfoImpl(T.getTypePtr()).Align;
+else if (!BaseT->isIncompleteType()) {
   // Adjust alignments of declarations with array type by the
   // large-array alignment on the target.
   if (const ArrayType *arrayType = getAsArrayType(T)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r288089 - Avoid lambdas in default member initializers to work around clang bug

2016-12-06 Thread Benjamin Kramer via cfe-commits
Leaving it as it is now is fine with me.

On Tue, Dec 6, 2016 at 8:38 PM, Reid Kleckner  wrote:
> This can be reverted now that PR31197 is fixed. I kind of like the new code
> better, so up to you, Benjamin.
>
> On Mon, Nov 28, 2016 at 3:58 PM, Reid Kleckner via cfe-commits
>  wrote:
>>
>> Author: rnk
>> Date: Mon Nov 28 17:58:04 2016
>> New Revision: 288089
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=288089=rev
>> Log:
>> Avoid lambdas in default member initializers to work around clang bug
>>
>> On Windows, Clang is mangling lambdas in default member initializers
>> incorrectly. See PR31197.
>>
>> This is causing redness on the self-host bots. Work around the problem
>> locally so we aren't blind to further issues.
>>
>> Modified:
>> cfe/trunk/unittests/Tooling/LookupTest.cpp
>>
>> Modified: cfe/trunk/unittests/Tooling/LookupTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/LookupTest.cpp?rev=288089=288088=288089=diff
>>
>> ==
>> --- cfe/trunk/unittests/Tooling/LookupTest.cpp (original)
>> +++ cfe/trunk/unittests/Tooling/LookupTest.cpp Mon Nov 28 17:58:04 2016
>> @@ -13,18 +13,19 @@ using namespace clang;
>>
>>  namespace {
>>  struct GetDeclsVisitor : TestVisitor {
>> -  std::function OnCall = [&](CallExpr *Expr) {};
>> -  std::function OnRecordTypeLoc = [&](RecordTypeLoc
>> Type) {
>> -  };
>> +  std::function OnCall;
>> +  std::function OnRecordTypeLoc;
>>SmallVector DeclStack;
>>
>>bool VisitCallExpr(CallExpr *Expr) {
>> -OnCall(Expr);
>> +if (OnCall)
>> +  OnCall(Expr);
>>  return true;
>>}
>>
>>bool VisitRecordTypeLoc(RecordTypeLoc Loc) {
>> -OnRecordTypeLoc(Loc);
>> +if (OnRecordTypeLoc)
>> +  OnRecordTypeLoc(Loc);
>>  return true;
>>}
>>
>>
>>
>> ___
>> 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] D27478: Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls

2016-12-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, doug.gregor.
ahatanak added a subscriber: cfe-commits.

This patch silences an incorrect warning that is issued when a function pointer 
is cast to another function pointer type. The warning gets issued because 
alignments of the source and destination do not match in Sema::CheckCastAlign, 
which happens because ASTContext::getTypeInfoImpl and ASTContext::getDeclAlign 
return different values for functions (the former returns 4 while the latter 
returns 1).


https://reviews.llvm.org/D27478

Files:
  lib/AST/ASTContext.cpp
  test/Sema/warn-cast-align.c


Index: test/Sema/warn-cast-align.c
===
--- test/Sema/warn-cast-align.c
+++ test/Sema/warn-cast-align.c
@@ -59,3 +59,11 @@
   i = (int *)
   i = (int *)a;
 }
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+  return (FnTy)
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1501,7 +1501,9 @@
 
 Align = std::min(Align, FieldAlign);
   }
-}
+} else if (isa(VD))
+  // GCC extension: alignment of functions is 32 bits
+  Align = 32;
   }
 
   return toCharUnitsFromBits(Align);


Index: test/Sema/warn-cast-align.c
===
--- test/Sema/warn-cast-align.c
+++ test/Sema/warn-cast-align.c
@@ -59,3 +59,11 @@
   i = (int *)
   i = (int *)a;
 }
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+  return (FnTy)
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1501,7 +1501,9 @@
 
 Align = std::min(Align, FieldAlign);
   }
-}
+} else if (isa(VD))
+  // GCC extension: alignment of functions is 32 bits
+  Align = 32;
   }
 
   return toCharUnitsFromBits(Align);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 set the repository for this revision to rL LLVM.
jyu2 updated this revision to Diff 80462.
jyu2 added a comment.

A typo.


Repository:
  rL LLVM

https://reviews.llvm.org/D27358

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -164,6 +164,9 @@
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) override;
@@ -1127,6 +1130,25 @@
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1502,11 +1524,24 @@
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+const CXXRecordDecl *ClassDecl =
+ cast(CGF.CurCodeDecl)->getParent();
+if (ClassDecl != nullptr && ClassDecl->getNumVBases())
+  BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 getFromDtorType(Type));
+  if (BaseDtorEndBB) {
+// Complete object handler should continue to be the remaining 
+CGF.Builder.CreateBr(BaseDtorEndBB);
+CGF.EmitBlock(BaseDtorEndBB);
+  } 
 }
 
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -278,3 +278,38 @@
 // WIN32-LIFETIME: %[[bc2:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8*
 // WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc2]])
 }
+
+struct class_2 {
+  class_2();
+  virtual ~class_2();
+};
+struct class_1 : virtual class_2 {
+  class_1(){throw "Unhandled exception";}
+  virtual ~class_1() {}
+};
+struct class_0 : class_1 {
+  class_0() ;
+  virtual ~class_0() {}
+};
+
+class_0::class_0() {
+  // WIN32: define x86_thiscallcc %struct.class_0* @"\01??0class_0@@QAE@XZ"(%struct.class_0* returned %this, i32 %is_most_derived) 
+  // WIN32: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
+  // WIN32: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
+  // WIN32: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
+  // WIN32: [[INIT_VBASES]]
+  // WIN32: br label %[[SKIP_VBASES]]
+  // WIN32: [[SKIP_VBASES]]
+// ehcleanup:
+  // WIN32: %[[CLEANUPPAD:.*]] = cleanuppad within none []
+  // WIN32-NEXT: bitcast %{{.*}}* %{{.*}} to i8*
+  // WIN32-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i{{.*}} {{.}} 
+  // WIN32-NEXT: bitcast i8* %{{.*}} to %{{.*}}*
+  // WIN32-NEXT: %[[SHOULD_CALL_VBASE_DTOR:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32-NEXT: br i1 %[[SHOULD_CALL_VBASE_DTOR]], label %[[DTOR_VBASE:.*]], label %[[SKIP_VBASE:.*]]
+  // WIN32: [[DTOR_VBASE]]
+  // WIN32-NEXT: call x86_thiscallcc void @"\01??1class_2@@UAE@XZ"
+  // WIN32: br label %[[SKIP_VBASE]]
+  // WIN32: [[SKIP_VBASE]]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

Hi Reid,

I know some problems(ms compatibility) when throw inside destructor.  I have 
not yet look like those problems.  I am new for clang.  I need sometime to 
catch up.  -:)

Thank you so much for your code review.  I had add new patch to address your 
suggestion.

Please take look.  Let me know if you need more info.

Thanks.
Jennifer




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1530-1532
+const CXXRecordDecl *ClassDecl =
+ cast(CGF.CurCodeDecl)->getParent();
+if (ClassDecl != nullptr && ClassDecl->getNumVBases())

rnk wrote:
> These checks seem unnecessary. ForVirtualBase should never be true if there 
> are no vbases, and the IsMostDerivedClass assert will catch it if not.
Yes, you are right.  I can either check here, or check if IsMostDerivedClass is 
nullptr return instead assertion inside EmitDtorCompleteObjectHandler.

As you know ForVirutalBase is set also for destructor.  But we only need this 
for ctor.  





Comment at: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp:285
+  int var_0;
+  class_2() {};
+  virtual ~class_2() {

rnk wrote:
> Most of these can be declarations to reduce the output size.
Thank you!  I changed, see my new diff



Comment at: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp:316
+  // WIN32: [[DTOR_VBASE]]
+  // WIN32: br label %[[SKIP_VBASE]]
+  // WIN32: [[SKIP_VBASE]]

rnk wrote:
> Check for a call to the class_2 destructor here
Thank you so much.  I changed see my new diff.


https://reviews.llvm.org/D27358



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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 removed rL LLVM as the repository for this revision.
jyu2 updated this revision to Diff 80459.
jyu2 added a comment.

Update patch to address Reid's suggestion


https://reviews.llvm.org/D27358

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -164,6 +164,9 @@
   llvm::BasicBlock *
   EmitCtorCompleteObjectHandler(CodeGenFunction ,
 const CXXRecordDecl *RD) override;
+  
+  llvm::BasicBlock *
+  EmitDtorCompleteObjectHandler(CodeGenFunction );
 
   void initializeHiddenVirtualInheritanceMembers(CodeGenFunction ,
   const CXXRecordDecl *RD) override;
@@ -1127,6 +1130,25 @@
   return SkipVbaseCtorsBB;
 }
 
+llvm::BasicBlock *
+MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction ) {
+  llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
+  assert(IsMostDerivedClass &&
+ "ctor for a class with virtual bases must have an implicit parameter");
+  llvm::Value *IsCompleteObject =
+  CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
+
+  llvm::BasicBlock *CallVbaseDtorsBB = CGF.createBasicBlock("Dtor.dtor_vbases");
+  llvm::BasicBlock *SkipVbaseDtorsBB = CGF.createBasicBlock("Dtor.skip_vbases");
+  CGF.Builder.CreateCondBr(IsCompleteObject,
+   CallVbaseDtorsBB, SkipVbaseDtorsBB);
+
+  CGF.EmitBlock(CallVbaseDtorsBB);
+  // CGF will put the base dtor calls in this basic block for us later.
+
+  return SkipVbaseDtorsBB;
+}
+
 void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
 CodeGenFunction , const CXXRecordDecl *RD) {
   // In most cases, an override for a vbase virtual method can adjust
@@ -1502,11 +1524,24 @@
 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
 This, false);
   }
+  
+  llvm::BasicBlock *BaseDtorEndBB = nullptr;
+  if (ForVirtualBase && isa(CGF.CurCodeDecl)) {
+const CXXRecordDecl *ClassDecl =
+ cast(CGF.CurCodeDecl)->getParent();
+if (ClassDecl != nullptr && ClassDecl->getNumVBases())
+  BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF);
+  }  
 
   CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(),
 /*ImplicitParam=*/nullptr,
 /*ImplicitParamTy=*/QualType(), nullptr,
 getFromDtorType(Type));
+  if (BaseDtorEndBB) {
+// Complete object handler should continue to be the remaining 
+CGF.Builder.CreateBr(BaseDtorEndBB);
+CGF.EmitBlock(BaseDtorEndBB);
+  } 
 }
 
 void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -278,3 +278,39 @@
 // WIN32-LIFETIME: %[[bc2:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8*
 // WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc2]])
 }
+
+struct class_2 {
+  int var_0;
+  class_2();
+  virtual ~class_2();
+};
+struct class_1 : virtual class_2 {
+  class_1(){throw "Unhandled exception";}
+  virtual ~class_1() {}
+};
+struct class_0 : class_1 {
+  class_0() ;
+  virtual ~class_0() {}
+};
+
+class_0::class_0() {
+  // WIN32: define x86_thiscallcc %struct.class_0* @"\01??0class_0@@QAE@XZ"(%struct.class_0* returned %this, i32 %is_most_derived) 
+  // WIN32: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
+  // WIN32: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
+  // WIN32: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
+  // WIN32: [[INIT_VBASES]]
+  // WIN32: br label %[[SKIP_VBASES]]
+  // WIN32: [[SKIP_VBASES]]
+// ehcleanup:
+  // WIN32: %[[CLEANUPPAD:.*]] = cleanuppad within none []
+  // WIN32-NEXT: bitcast %{{.*}}* %{{.*}} to i8*
+  // WIN32-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i{{.*}} {{.}} 
+  // WIN32-NEXT: bitcast i8* %{{.*}} to %{{.*}}*
+  // WIN32-NEXT: %[[SHOULD_CALL_VBASE_DTOR:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
+  // WIN32-NEXT: br i1 %[[SHOULD_CALL_VBASE_DTOR]], label %[[DTOR_VBASE:.*]], label %[[SKIP_VBASE:.*]]
+  // WIN32: call x86_thiscallcc void @"\01??1class_2@@UAE@XZ"
+  // WIN32: [[DTOR_VBASE]]
+  // WIN32: br label %[[SKIP_VBASE]]
+  // WIN32: [[SKIP_VBASE]]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27438: clang-format-vsix: add a date stamp to the VSIX version number to ensure upgradability

2016-12-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D27438#614223, @amaiorano wrote:

> In https://reviews.llvm.org/D27438#614219, @hans wrote:
>
> > When building the snapshots and releases, I usually put the SVN revision 
> > number in there to avoid this same problem: 
> > http://llvm-cs.pcc.me.uk/utils/release/build_llvm_package.bat#25
>
>
> Ah, right, I was wondering how that worked. Well, if you don't think it's 
> necessary, we don't have to do it. I didn't realize we had this script to 
> build the official VSIX. Do you think you'd switch to using this method? Or 
> would you prefer that the official releases be bound to the SVN rev number?


I'd prefer to keep the official releases on the SVN rev.

>> Your patch seems like a good default though. Should we put the hour and 
>> minute in there as well, in case one builds multiple versions the same day?
> 
> If you still want this change, I can definitely add the hour and minute. Let 
> me know!

Yes, I think this is still a worthwhile change. Let's add the hour and minute 
and get it landed.


https://reviews.llvm.org/D27438



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


Re: r288689 - Fix stack-use-after-scope in CheckExplicitlyDefaultedMemberExceptionSpec

2016-12-06 Thread Vitaly Buka via cfe-commits
Hi Alex,



On Tue, Dec 6, 2016 at 11:14 AM Alex L  wrote:

Hi Vitaly,

I noticed that you posted this patch up for review at
https://reviews.llvm.org/D27422, but then committed it instantly without
waiting for approval (and you did the same for r288685 as well). Is there
any particular reason why you did this? I think that you should've waited
for approval before committing.


We had broken build bots, so seem like this trivial change is better than
reverting patches.
No.3 of http://llvm.org/docs/DeveloperPolicy.html#code-reviews allows after
commit review for changes like this.


This patch is pretty small, and so it looks to me like it could have been
reviewed after it was committed, but patches that get post-commit reviews
shouldn't get explicit review requests like this one did.


Sorry, probably I did the same few time before. I can't find exact details
in the policy, but I assumed that was a reasonable approach.
So what is the process for after commit review?



Alex

On 5 December 2016 at 19:25, Vitaly Buka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

Author: vitalybuka
Date: Mon Dec  5 13:25:00 2016
New Revision: 288689

URL: http://llvm.org/viewvc/llvm-project?rev=288689=rev
Log:
Fix stack-use-after-scope in CheckExplicitlyDefaultedMemberExceptionSpec

Summary:
Similar to r288685.
getExceptionSpec returned structure with pointers to temporarily object
created
by computeImplicitExceptionSpec.

Reviewers: rsmith

Subscribers: aizatsky, cfe-commits

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

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=288689=288688=288689=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec  5 13:25:00 2016
@@ -6299,8 +6299,8 @@ void Sema::CheckExplicitlyDefaultedMembe
   CallingConv CC =
Context.getDefaultCallingConvention(/*IsVariadic=*/false,

/*IsCXXMethod=*/true);
   FunctionProtoType::ExtProtoInfo EPI(CC);
-  EPI.ExceptionSpec = computeImplicitExceptionSpec(*this,
MD->getLocation(), MD)
-  .getExceptionSpec();
+  auto IES = computeImplicitExceptionSpec(*this, MD->getLocation(), MD);
+  EPI.ExceptionSpec = IES.getExceptionSpec();
   const FunctionProtoType *ImplicitType = cast(
 Context.getFunctionType(Context.VoidTy, None, EPI));



___
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


Re: r288089 - Avoid lambdas in default member initializers to work around clang bug

2016-12-06 Thread Reid Kleckner via cfe-commits
This can be reverted now that PR31197 is fixed. I kind of like the new code
better, so up to you, Benjamin.

On Mon, Nov 28, 2016 at 3:58 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Mon Nov 28 17:58:04 2016
> New Revision: 288089
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288089=rev
> Log:
> Avoid lambdas in default member initializers to work around clang bug
>
> On Windows, Clang is mangling lambdas in default member initializers
> incorrectly. See PR31197.
>
> This is causing redness on the self-host bots. Work around the problem
> locally so we aren't blind to further issues.
>
> Modified:
> cfe/trunk/unittests/Tooling/LookupTest.cpp
>
> Modified: cfe/trunk/unittests/Tooling/LookupTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/
> Tooling/LookupTest.cpp?rev=288089=288088=288089=diff
> 
> ==
> --- cfe/trunk/unittests/Tooling/LookupTest.cpp (original)
> +++ cfe/trunk/unittests/Tooling/LookupTest.cpp Mon Nov 28 17:58:04 2016
> @@ -13,18 +13,19 @@ using namespace clang;
>
>  namespace {
>  struct GetDeclsVisitor : TestVisitor {
> -  std::function OnCall = [&](CallExpr *Expr) {};
> -  std::function OnRecordTypeLoc = [&](RecordTypeLoc
> Type) {
> -  };
> +  std::function OnCall;
> +  std::function OnRecordTypeLoc;
>SmallVector DeclStack;
>
>bool VisitCallExpr(CallExpr *Expr) {
> -OnCall(Expr);
> +if (OnCall)
> +  OnCall(Expr);
>  return true;
>}
>
>bool VisitRecordTypeLoc(RecordTypeLoc Loc) {
> -OnRecordTypeLoc(Loc);
> +if (OnRecordTypeLoc)
> +  OnRecordTypeLoc(Loc);
>  return true;
>}
>
>
>
> ___
> 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


Re: r288689 - Fix stack-use-after-scope in CheckExplicitlyDefaultedMemberExceptionSpec

2016-12-06 Thread Alex L via cfe-commits
Hi Vitaly,

I noticed that you posted this patch up for review at
https://reviews.llvm.org/D27422, but then committed it instantly without
waiting for approval (and you did the same for r288685 as well). Is there
any particular reason why you did this? I think that you should've waited
for approval before committing. This patch is pretty small, and so it looks
to me like it could have been reviewed after it was committed, but patches
that get post-commit reviews shouldn't get explicit review requests like
this one did.

Alex

On 5 December 2016 at 19:25, Vitaly Buka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vitalybuka
> Date: Mon Dec  5 13:25:00 2016
> New Revision: 288689
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288689=rev
> Log:
> Fix stack-use-after-scope in CheckExplicitlyDefaultedMemberExceptionSpec
>
> Summary:
> Similar to r288685.
> getExceptionSpec returned structure with pointers to temporarily object
> created
> by computeImplicitExceptionSpec.
>
> Reviewers: rsmith
>
> Subscribers: aizatsky, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D27422
>
> 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=288689=288688=288689=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec  5 13:25:00 2016
> @@ -6299,8 +6299,8 @@ void Sema::CheckExplicitlyDefaultedMembe
>CallingConv CC = Context.getDefaultCallingConvention(/*
> IsVariadic=*/false,
>
> /*IsCXXMethod=*/true);
>FunctionProtoType::ExtProtoInfo EPI(CC);
> -  EPI.ExceptionSpec = computeImplicitExceptionSpec(*this,
> MD->getLocation(), MD)
> -  .getExceptionSpec();
> +  auto IES = computeImplicitExceptionSpec(*this, MD->getLocation(), MD);
> +  EPI.ExceptionSpec = IES.getExceptionSpec();
>const FunctionProtoType *ImplicitType = cast(
>  Context.getFunctionType(Context.VoidTy, None, EPI));
>
>
>
> ___
> 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] D27403: [OpenCL] Added a LIT test for ensuring address space mangling is done the same both in OpenCL1.2 and OpenCL2.0.

2016-12-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D27403



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


RE: [PATCH] D27334: [OpenCL] Ambiguous function call.

2016-12-06 Thread Anastasia Stulova via cfe-commits
I think we can’t avoid deviating from C/C++ implementation completely. But we 
should certainly try to avoid it in unnecessary situations as much as we can.

In this case it seems like the spec enforces the rules for resolving the 
ambiguity that seems logical to me.

Is this possibly a better way to deviate OpenCL implementation than giving a 
hypothetical warning and an error in the case the ambiguity wasn’t resolved?

Cheers,
Anastasia

From: Bader, Alexey [mailto:alexey.ba...@intel.com]
Sent: 06 December 2016 12:17
To: Anastasia Stulova; Richard Smith; Bruno Cardoso Lopes via Phabricator; 
reviews+d27334+public+f2c5a66032c4c...@reviews.llvm.org
Cc: egor.chur...@gmail.com; yaxun@amd.com; cfe-commits@lists.llvm.org; nd
Subject: RE: [PATCH] D27334: [OpenCL] Ambiguous function call.

Actually OpenCL specification has the following text in “Built-in Functions” 
chapter (OpenCL C 2.0 rev. 33):

“ User defined OpenCL C functions, behave per C standard rules for functions 
(C99, TC2, Section
6.9.1). On entry to the function, the size of each variably modified parameter 
is evaluated and
the value of each argument expression is converted to the type of the 
corresponding parameter as
per usual arithmetic conversion rules described in section 6.2.6. Built-in 
functions described in
this section behave similarly, except that in order to avoid ambiguity between 
multiple forms of
the same built-in function, implicit scalar widening shall not occur. Note that 
some built-in
functions described in this section do have forms that operate on mixed scalar 
and vector types,
however.”

If I understand it correctly this text can help to resolve the overloading, 
since “usual arithmetic conversion rules” from section 6.2.6 rank floating 
point and integer data types including vector flavors. On the other hand I 
don’t think it’s good idea to adopt this rule, since it doesn’t follow C++ 
overloading rules and definitely will deviate OpenCL behavior from C or C++.

Thanks,
Alexey

From: Anastasia Stulova [mailto:anastasia.stul...@arm.com]
Sent: Monday, December 5, 2016 9:21 PM
To: Richard Smith >; Bruno 
Cardoso Lopes via Phabricator 
>; 
reviews+d27334+public+f2c5a66032c4c...@reviews.llvm.org
Cc: Bader, Alexey >; 
egor.chur...@gmail.com; 
yaxun@amd.com; 
cfe-commits@lists.llvm.org; nd 
>
Subject: RE: [PATCH] D27334: [OpenCL] Ambiguous function call.

> Perhaps that is the problem (that there are two modes that do different 
> things)? Could we make the double overload be present but unselectable to 
> diagnose this problem in that mode too?

If we could resolve the overload candidate to prefer ‘int -> float’ than 
‘int->double’, it would work best.

From: meta...@gmail.com [mailto:meta...@gmail.com] On 
Behalf Of Richard Smith
Sent: 05 December 2016 17:53
To: Bruno Cardoso Lopes via Phabricator; 
reviews+d27334+public+f2c5a66032c4c...@reviews.llvm.org
Cc: alexey.ba...@intel.com; 
egor.chur...@gmail.com; 
yaxun@amd.com; Anastasia Stulova; 
cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D27334: [OpenCL] Ambiguous function call.

On 5 Dec 2016 9:42 am, "Anastasia Stulova via Phabricator via cfe-commits" 
> wrote:
Anastasia added a comment.

In https://reviews.llvm.org/D27334#612858, @bader wrote:

> In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:
>
> > This change seems to modify normal C behavior again. Is there any strong 
> > motivation for doing this and if yes could it be done generically with C?
>
>
> Motivation:
>
>   // Non-portable OpenCL 1.2 code
>   __kernel void foo(global float* out) {
> out[get_global_id(0)] = sin(get_global_id(0));
>   }
>
>
> This program compiles fine on OpenCL platform w/o doubles support

Perhaps that is the problem (that there are two modes that do different 
things)? Could we make the double overload be present but unselectable to 
diagnose this problem in that mode too?

and fails otherwise.
>  If OpenCL driver supports doubles it provides at least two versions of 'sin' 
> built-in math function and compiler will not be able to choose the right one 
> for 'size_t' argument.

Do you have a real example? If someone passes an integer to 'sin', I think 
there's a better warning we can give them :)

>  The goal of this warning is to let OpenCL developer know about potential 
> issues with code portability.
I would argue this improves the 

[PATCH] D27334: [OpenCL] Ambiguous function call.

2016-12-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D27334#614389, @bader wrote:

> In https://reviews.llvm.org/D27334#613504, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D27334#612858, @bader wrote:
> >
> > > In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:
> > >
> > > > This change seems to modify normal C behavior again. Is there any 
> > > > strong motivation for doing this and if yes could it be done 
> > > > generically with C?
> > >
> > >
> > > Motivation:
> > >
> > >   // Non-portable OpenCL 1.2 code 
> > >   __kernel void foo(global float* out) {
> > > out[get_global_id(0)] = sin(get_global_id(0));
> > >   }
> > >
> > >
> > > This program compiles fine on OpenCL platform w/o doubles support and 
> > > fails otherwise.
> > >  If OpenCL driver supports doubles it provides at least two versions of 
> > > 'sin' built-in math function and compiler will not be able to choose the 
> > > right one for 'size_t' argument.
> > >  The goal of this warning is to let OpenCL developer know about potential 
> > > issues with code portability.
> >
> >
> > I would argue this improves the portability much as it can also be 
> > misleading in some situations (because it refers to a potentially 
> > hypothetical problem). For example there can be builtin functions that only 
> > have a float parameter (without a double version of it). This is for 
> > example the case with read_image functions that take a float coordinate 
> > value between 0 and 1. Unfortunately this warning won't be triggered on 
> > read_image functions because there is an overload candidate with an int 
> > type of the same parameter too. But we can't exclude this situations to 
> > appear in the future or from some vendor extensions or even custom OpenCL 
> > code.
>
>
> As much as any other warning it's not always means that there is an error in 
> the code. It just means that developer should inspect the construction 
> triggering a warning.
>  Passing integer value to a function with floating point parameters is not 
> always an error, but some times it might be so.
>  Do you suggest dropping the diagnostics at all or changing the diagnostics 
> message?


I agree warnings don't always signal a definite issue (even thought it's good 
to make them as precise as we can). We could try to reword the diagnostic 
message. However, the biggest issue I have here is that the message can be 
given in the situations that are unrelated to the problem (i.e. the overload 
candidates that don't have anything to do with the parameter being diagnosed or 
don't overload with the double precision). Therefore, it feels like the 
diagnostic can be confusing in some cases even though they are not very 
probable ones.


https://reviews.llvm.org/D27334



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


[PATCH] D27473: Bring back note about not supporting global register variables

2016-12-06 Thread Michael Kuperstein via Phabricator via cfe-commits
mkuper created this revision.
mkuper added a reviewer: rengolin.
mkuper added a subscriber: cfe-commits.

This partially reverts r260506 which removed this note.

Renato, the part about "not being implemented soon because it requires backend 
support" was taken verbatim from the original text, pre-r260506, I only added 
the fact non-allocatable registers are now supported.
If you prefer to have strong wording, feel free to make suggestions.


https://reviews.llvm.org/D27473

Files:
  docs/UsersManual.rst


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1830,6 +1830,10 @@
  ...
  local_function(1);
 
+-  clang only supports global register variables when the register specified
+   is non-allocatable (e.g. the stack pointer). Support for general global
+   register variables is unlikely to be implemented soon because it requires
+   additional LLVM backend support.
 -  clang does not support static initialization of flexible array
members. This appears to be a rarely used extension, but could be
implemented pending user demand.


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1830,6 +1830,10 @@
  ...
  local_function(1);
 
+-  clang only supports global register variables when the register specified
+   is non-allocatable (e.g. the stack pointer). Support for general global
+   register variables is unlikely to be implemented soon because it requires
+   additional LLVM backend support.
 -  clang does not support static initialization of flexible array
members. This appears to be a rarely used extension, but could be
implemented pending user demand.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288838 - [OpenMP] Fix typo in the test case. NFC.

2016-12-06 Thread Kelvin Li via cfe-commits
Author: kli
Date: Tue Dec  6 12:50:20 2016
New Revision: 288838

URL: http://llvm.org/viewvc/llvm-project?rev=288838=rev
Log:
[OpenMP] Fix typo in the test case. NFC.

Modified:
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp?rev=288838=288837=288838=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp 
Tue Dec  6 12:50:20 2016
@@ -16,8 +16,7 @@ int tmain(T argc, S **argv) {
 #pragma omp teams distribute parallel for simd if // expected-error {{expected 
'(' after 'if'}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd if ( // expected-error {{expected 
expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for simd if ( // expected-error 
{{expected expression}} expected-error {{expected ')'}} expected-note {{to 
match this '('}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target
 #pragma omp teams distribute parallel for simd if () // expected-error 
{{expected expression}}


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


[PATCH] D27408: [analyzer] RetainCountChecker: remove unused enum value; NFC.

2016-12-06 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

LGTM.


https://reviews.llvm.org/D27408



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


[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:306
+  /// \param AddrSpace address space of pointee in source language.
+  virtual uint64_t getNullPtrValue(unsigned AddrSpace) const {
+return 0;

We normally spell out "Pointer", I think.



Comment at: lib/AST/APValue.cpp:585
+bool APValue::isNullPtr() const {
+  return isLValue() && ((const LV*)(const char*)Data.buffer)->IsNullPtr;
+}

Seems reasonable to assert isLValue() here.



Comment at: lib/CodeGen/CGExprAgg.cpp:1054
+return ICE->getCastKind() == CK_NullToPointer &&
+CGF.getTypes().isZeroInitializable(E->getType());
   // '\0'

This is probably a common enough case that it's worth "inlining", i.e. adding a 
isPointerZeroInitializable() method that asserts that it's been given a pointer 
type and does the right thing with it.



Comment at: lib/CodeGen/CGExprScalar.cpp:1407
 return Builder.CreatePointerBitCastOrAddrSpaceCast(Src,
ConvertType(DestTy));
   }

As discussed, please also delegate addrspace conversions into 
TargetCodeGenInfo.  You don't have to implement them for your target if you 
don't want, but please do the delegation correctly.

Also, even if you decide not to implement the actual dynamic comparison logic, 
you should at least teach your target's implementation to recognize when the 
original pointer is a constant null pointer and just produce the correct new 
constant.  That should eliminate the need for this special case here, as well 
as fixing the case where E is a null pointer with side effects like (foo(), 
NULL).



Comment at: lib/CodeGen/CGExprScalar.cpp:1532
+  return llvm::ConstantInt::get(ConvertType(DestTy),
+  CGF.getContext().getTargetNullPtrValue(E->getType()));
 assert(!DestTy->isBooleanType() && "bool should use PointerToBool");

Why is this necessary?  ptrtoint on the recursively-emitted null pointer should 
do this automatically.



Comment at: lib/CodeGen/CodeGenModule.h:1156
+  /// Get target specific null pointer.
+  llvm::Constant *getNullPtr(llvm::PointerType *T, QualType QT);
+

Like above, this should be getNullPointer.  Also, please document which type QT 
is: the pointer type or the pointee type.



Comment at: lib/CodeGen/TargetInfo.h:228
+  virtual llvm::Constant *getNullPtr(const CodeGen::CodeGenModule ,
+  llvm::PointerType *T, QualType QT) const;
+

Same as the comment on getNullPtr above.


https://reviews.llvm.org/D26196



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


[PATCH] D27358: [MS-ABI]V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.

2016-12-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This highlights an interesting MS/Itanium C++ ABI difference. GCC and Clang 
emit cleanup landing pads in destructors to ensure that all subobjects are 
destroyed even if one throws an exception. In Mingw, both GCC and Clang print 
~A and ~B for this program, but MSVC does not:

  extern "C" int puts(const char *);
  struct A { virtual ~A() noexcept(false) { puts("~A"); } };
  struct B { virtual ~B() noexcept(false) { puts("~B"); } };
  struct C : virtual A, virtual B { virtual ~C() noexcept(false) { throw 1; } };
  int main() {
try {
  C c;
} catch (...) {
  puts("caught");
}
  }

I encountered this while tracing out call sites in clang where `ForVirtualBase` 
is set to true in EmitCXXDestructorCall.




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1530-1532
+const CXXRecordDecl *ClassDecl =
+ cast(CGF.CurCodeDecl)->getParent();
+if (ClassDecl != nullptr && ClassDecl->getNumVBases())

These checks seem unnecessary. ForVirtualBase should never be true if there are 
no vbases, and the IsMostDerivedClass assert will catch it if not.



Comment at: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp:285
+  int var_0;
+  class_2() {};
+  virtual ~class_2() {

Most of these can be declarations to reduce the output size.



Comment at: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp:316
+  // WIN32: [[DTOR_VBASE]]
+  // WIN32: br label %[[SKIP_VBASE]]
+  // WIN32: [[SKIP_VBASE]]

Check for a call to the class_2 destructor here


Repository:
  rL LLVM

https://reviews.llvm.org/D27358



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


[PATCH] D16533: Bug 20796 - GCC's -Wstrict-prototypes warning not implemented in Clang

2016-12-06 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D16533



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


[PATCH] D27409: [analyzer] RetainCountChecker: Improve support for libdispatch APIs.

2016-12-06 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D27409#614601, @NoQ wrote:

> Not sure we need to stay merged with `retain-release-arc.m`, as we're not 
> really reusing many declarations across these files.


I find it more helpful to organize tests around functionality ('retain count 
checker') than around bugs ('dispatch data leak', 'PRxyzab.c').  Organizing 
around functionality helps future contributors and maintainers know where to 
add a new test and where to look for existing tests. In my view this critical 
for developers who are new to the project or who are learning a new subsystem. 
It also typically reduces the number of 'clang' RUN lines, which have a cost in 
maintenance and running time.


https://reviews.llvm.org/D27409



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


r288828 - Fix FileCheck pattern.

2016-12-06 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Dec  6 11:06:33 2016
New Revision: 288828

URL: http://llvm.org/viewvc/llvm-project?rev=288828=rev
Log:
Fix FileCheck pattern.

Modified:
cfe/trunk/test/Driver/compilation_database.c

Modified: cfe/trunk/test/Driver/compilation_database.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compilation_database.c?rev=288828=288827=288828=diff
==
--- cfe/trunk/test/Driver/compilation_database.c (original)
+++ cfe/trunk/test/Driver/compilation_database.c Tue Dec  6 11:06:33 2016
@@ -1,8 +1,8 @@
 // RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck 
--check-prefix=ERROR %s
 
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",.* "--target={{[^"]+}}"]},
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",.* "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",{{.*}} "--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {


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


r288827 - Allow additional output since e.g. OSX appends flags like

2016-12-06 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Dec  6 11:02:41 2016
New Revision: 288827

URL: http://llvm.org/viewvc/llvm-project?rev=288827=rev
Log:
Allow additional output since e.g. OSX appends flags like
"-mlinker-version=264.3.102" automatically. Wiring down a target on the
other hand is problematic as this actually needs to run codegen and
doesn't work with -###.

Modified:
cfe/trunk/test/Driver/compilation_database.c

Modified: cfe/trunk/test/Driver/compilation_database.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compilation_database.c?rev=288827=288826=288827=diff
==
--- cfe/trunk/test/Driver/compilation_database.c (original)
+++ cfe/trunk/test/Driver/compilation_database.c Tue Dec  6 11:02:41 2016
@@ -1,8 +1,8 @@
 // RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck 
--check-prefix=ERROR %s
 
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall", "--target={{[^"]+}}"]},
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall", "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",.* "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall",.* "--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {


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


[PATCH] D27453: [OpenCL] Enable unroll hint for OpenCL 1.x.

2016-12-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaStmtAttr.cpp:232
 
-  if (S.getLangOpts().OpenCLVersion < 200) {
-S.Diag(A.getLoc(), diag::err_attribute_requires_opencl_version)

The comment above refers to v2.0, could we update it reflecting the fact that 
we now allow the feature in all OpenCL versions.


https://reviews.llvm.org/D27453



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


[PATCH] D27226: [MS ABI] Implement more of the Itanium mangling rules

2016-12-06 Thread David Majnemer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288826: [MS ABI] Implement more of the Itanium mangling 
rules (authored by majnemer).

Changed prior to commit:
  https://reviews.llvm.org/D27226?vs=80096=80437#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27226

Files:
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp

Index: cfe/trunk/lib/AST/MicrosoftMangle.cpp
===
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp
@@ -66,6 +66,16 @@
   }
 };
 
+static const DeclContext *
+getLambdaDefaultArgumentDeclContext(const Decl *D) {
+  if (const auto *RD = dyn_cast(D))
+if (RD->isLambda())
+  if (const auto *Parm =
+  dyn_cast_or_null(RD->getLambdaContextDecl()))
+return Parm->getDeclContext();
+  return nullptr;
+}
+
 /// \brief Retrieve the declaration context that should be used when mangling
 /// the given declaration.
 static const DeclContext *getEffectiveDeclContext(const Decl *D) {
@@ -75,12 +85,8 @@
   // not the case: the lambda closure type ends up living in the context
   // where the function itself resides, because the function declaration itself
   // had not yet been created. Fix the context here.
-  if (const CXXRecordDecl *RD = dyn_cast(D)) {
-if (RD->isLambda())
-  if (ParmVarDecl *ContextParam =
-  dyn_cast_or_null(RD->getLambdaContextDecl()))
-return ContextParam->getDeclContext();
-  }
+  if (const auto *LDADC = getLambdaDefaultArgumentDeclContext(D))
+return LDADC;
 
   // Perform the same check for block literals.
   if (const BlockDecl *BD = dyn_cast(D)) {
@@ -112,14 +118,6 @@
   return FD;
 }
 
-static bool isLambda(const NamedDecl *ND) {
-  const CXXRecordDecl *Record = dyn_cast(ND);
-  if (!Record)
-return false;
-
-  return Record->isLambda();
-}
-
 /// MicrosoftMangleContextImpl - Overrides the default MangleContext for the
 /// Microsoft Visual C++ ABI.
 class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
@@ -200,9 +198,11 @@
 
 // Lambda closure types are already numbered, give out a phony number so
 // that they demangle nicely.
-if (isLambda(ND)) {
-  disc = 1;
-  return true;
+if (const auto *RD = dyn_cast(ND)) {
+  if (RD->isLambda()) {
+disc = 1;
+return true;
+  }
 }
 
 // Use the canonical number for externally visible decls.
@@ -824,16 +824,41 @@
   if (const CXXRecordDecl *Record = dyn_cast(TD)) {
 if (Record->isLambda()) {
   llvm::SmallString<10> Name("getLambdaContextDecl();
+  unsigned LambdaManglingNumber = Record->getLambdaManglingNumber();
   unsigned LambdaId;
-  if (Record->getLambdaManglingNumber())
-LambdaId = Record->getLambdaManglingNumber();
+  const ParmVarDecl *Parm =
+  dyn_cast_or_null(LambdaContextDecl);
+  const FunctionDecl *Func =
+  Parm ? dyn_cast(Parm->getDeclContext()) : nullptr;
+
+  if (Func) {
+unsigned DefaultArgNo =
+Func->getNumParams() - Parm->getFunctionScopeIndex();
+Name += llvm::utostr(DefaultArgNo);
+Name += "_";
+  }
+
+  if (LambdaManglingNumber)
+LambdaId = LambdaManglingNumber;
   else
 LambdaId = Context.getLambdaId(Record);
 
   Name += llvm::utostr(LambdaId);
   Name += ">";
 
   mangleSourceName(Name);
+
+  // If the context of a closure type is an initializer for a class
+  // member (static or nonstatic), it is encoded in a qualified name.
+  if (LambdaManglingNumber && LambdaContextDecl) {
+if ((isa(LambdaContextDecl) ||
+ isa(LambdaContextDecl)) &&
+LambdaContextDecl->getDeclContext()->isRecord()) {
+  mangleUnqualifiedName(cast(LambdaContextDecl));
+}
+  }
   break;
 }
   }
@@ -937,16 +962,22 @@
   // for how this should be done.
   Out << "__block_invoke" << Context.getBlockId(BD, false);
   Out << '@';
-  continue;
 } else if (const ObjCMethodDecl *Method = dyn_cast(DC)) {
   mangleObjCMethodName(Method);
 } else if (isa(DC)) {
   ND = cast(DC);
   if (const FunctionDecl *FD = dyn_cast(ND)) {
 mangle(FD, "?");
 break;
-  } else
+  } else {
 mangleUnqualifiedName(ND);
+// Lambdas in default arguments conceptually belong to the function the
+// parameter corresponds to.
+if (const auto *LDADC = getLambdaDefaultArgumentDeclContext(ND)) {
+  DC = LDADC;
+  continue;
+}
+  }
 }
 DC = DC->getParent();
   }
Index: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp

r288826 - [MS ABI] Implement more of the Itanium mangling rules

2016-12-06 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Dec  6 11:01:02 2016
New Revision: 288826

URL: http://llvm.org/viewvc/llvm-project?rev=288826=rev
Log:
[MS ABI] Implement more of the Itanium mangling rules

We didn't implement handle corner cases like:
 - lambdas used to initialize a field
 - lambdas in default argument initializers

This fixes PR31197.

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

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=288826=288825=288826=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Dec  6 11:01:02 2016
@@ -66,6 +66,16 @@ struct msvc_hashing_ostream : public llv
   }
 };
 
+static const DeclContext *
+getLambdaDefaultArgumentDeclContext(const Decl *D) {
+  if (const auto *RD = dyn_cast(D))
+if (RD->isLambda())
+  if (const auto *Parm =
+  dyn_cast_or_null(RD->getLambdaContextDecl()))
+return Parm->getDeclContext();
+  return nullptr;
+}
+
 /// \brief Retrieve the declaration context that should be used when mangling
 /// the given declaration.
 static const DeclContext *getEffectiveDeclContext(const Decl *D) {
@@ -75,12 +85,8 @@ static const DeclContext *getEffectiveDe
   // not the case: the lambda closure type ends up living in the context
   // where the function itself resides, because the function declaration itself
   // had not yet been created. Fix the context here.
-  if (const CXXRecordDecl *RD = dyn_cast(D)) {
-if (RD->isLambda())
-  if (ParmVarDecl *ContextParam =
-  dyn_cast_or_null(RD->getLambdaContextDecl()))
-return ContextParam->getDeclContext();
-  }
+  if (const auto *LDADC = getLambdaDefaultArgumentDeclContext(D))
+return LDADC;
 
   // Perform the same check for block literals.
   if (const BlockDecl *BD = dyn_cast(D)) {
@@ -112,14 +118,6 @@ static const FunctionDecl *getStructor(c
   return FD;
 }
 
-static bool isLambda(const NamedDecl *ND) {
-  const CXXRecordDecl *Record = dyn_cast(ND);
-  if (!Record)
-return false;
-
-  return Record->isLambda();
-}
-
 /// MicrosoftMangleContextImpl - Overrides the default MangleContext for the
 /// Microsoft Visual C++ ABI.
 class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
@@ -200,9 +198,11 @@ public:
 
 // Lambda closure types are already numbered, give out a phony number so
 // that they demangle nicely.
-if (isLambda(ND)) {
-  disc = 1;
-  return true;
+if (const auto *RD = dyn_cast(ND)) {
+  if (RD->isLambda()) {
+disc = 1;
+return true;
+  }
 }
 
 // Use the canonical number for externally visible decls.
@@ -824,9 +824,24 @@ void MicrosoftCXXNameMangler::mangleUnqu
   if (const CXXRecordDecl *Record = dyn_cast(TD)) {
 if (Record->isLambda()) {
   llvm::SmallString<10> Name("getLambdaContextDecl();
+  unsigned LambdaManglingNumber = Record->getLambdaManglingNumber();
   unsigned LambdaId;
-  if (Record->getLambdaManglingNumber())
-LambdaId = Record->getLambdaManglingNumber();
+  const ParmVarDecl *Parm =
+  dyn_cast_or_null(LambdaContextDecl);
+  const FunctionDecl *Func =
+  Parm ? dyn_cast(Parm->getDeclContext()) : nullptr;
+
+  if (Func) {
+unsigned DefaultArgNo =
+Func->getNumParams() - Parm->getFunctionScopeIndex();
+Name += llvm::utostr(DefaultArgNo);
+Name += "_";
+  }
+
+  if (LambdaManglingNumber)
+LambdaId = LambdaManglingNumber;
   else
 LambdaId = Context.getLambdaId(Record);
 
@@ -834,6 +849,16 @@ void MicrosoftCXXNameMangler::mangleUnqu
   Name += ">";
 
   mangleSourceName(Name);
+
+  // If the context of a closure type is an initializer for a class
+  // member (static or nonstatic), it is encoded in a qualified name.
+  if (LambdaManglingNumber && LambdaContextDecl) {
+if ((isa(LambdaContextDecl) ||
+ isa(LambdaContextDecl)) &&
+LambdaContextDecl->getDeclContext()->isRecord()) {
+  mangleUnqualifiedName(cast(LambdaContextDecl));
+}
+  }
   break;
 }
   }
@@ -937,7 +962,6 @@ void MicrosoftCXXNameMangler::mangleNest
   // for how this should be done.
   Out << "__block_invoke" << Context.getBlockId(BD, false);
   Out << '@';
-  continue;
 } else if (const ObjCMethodDecl *Method = dyn_cast(DC)) {
   mangleObjCMethodName(Method);
 } else if (isa(DC)) {
@@ -945,8 +969,15 @@ void MicrosoftCXXNameMangler::mangleNest
   if (const 

[PATCH] D27226: [MS ABI] Implement more of the Itanium mangling rules

2016-12-06 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.

lgtm Thanks, apologies for the scope creep.


https://reviews.llvm.org/D27226



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


r288823 - Make test case slightly more robust by explicitly passing --sysroot.

2016-12-06 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Dec  6 10:47:00 2016
New Revision: 288823

URL: http://llvm.org/viewvc/llvm-project?rev=288823=rev
Log:
Make test case slightly more robust by explicitly passing --sysroot.
Otherwise it would change when DEFAULT_SYSROOT is provided.

Modified:
cfe/trunk/test/Driver/compilation_database.c

Modified: cfe/trunk/test/Driver/compilation_database.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compilation_database.c?rev=288823=288822=288823=diff
==
--- cfe/trunk/test/Driver/compilation_database.c (original)
+++ cfe/trunk/test/Driver/compilation_database.c Tue Dec  6 10:47:00 2016
@@ -1,8 +1,8 @@
-// RUN: %clang -MD -MP -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
+// RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck 
--check-prefix=ERROR %s
 
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
-// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall", "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": 
"[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": 
"compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", 
"[[SRC]]", "--sysroot=somewhere", "-c", "-Wall", "--target={{[^"]+}}"]},
 // ERROR: error: compilation database '{{.*}}/non-existant' could not be 
opened:
 
 int main(void) {


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


[PATCH] D27409: [analyzer] RetainCountChecker: Improve support for libdispatch APIs.

2016-12-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ retitled this revision from "[analyzer] RetainCountChecker: The callback in 
dispatch_data_create() doesn't free the return symbol." to "[analyzer] 
RetainCountChecker: Improve support for libdispatch APIs.".
NoQ updated the summary for this revision.
NoQ updated this revision to Diff 80432.
NoQ added a comment.

Add more tests.

Not sure we need to stay merged with `retain-release-arc.m`, as we're not 
really reusing many declarations across these files.

As well, handle the case when `dispatch_retain` and `dispatch_release` are 
regular functions.


https://reviews.llvm.org/D27409

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/dispatch-data-leak.m

Index: test/Analysis/dispatch-data-leak.m
===
--- /dev/null
+++ test/Analysis/dispatch-data-leak.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks -analyze -analyzer-output=text -analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks -fobjc-arc -analyze -analyzer-output=text -analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks -DDISPATCH_MACROS -analyze -analyzer-output=text -analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks -DDISPATCH_MARCOS -fobjc-arc -analyze -analyzer-output=text -analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator.h"
+#include "Inputs/system-header-simulator-objc.h"
+
+#define NON_ARC !__has_feature(objc_arc)
+
+#if !NON_ARC
+  // expected-no-diagnostics
+#endif
+
+#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
+#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
+
+@protocol OS_dispatch_object
+@end
+@protocol OS_dispatch_data 
+@end
+@protocol OS_dispatch_queue 
+@end
+
+typedef NSObject *dispatch_object_t;
+typedef NSObject *dispatch_data_t;
+typedef NSObject *dispatch_queue_t;
+
+typedef void (^dispatch_block_t)(void);
+
+dispatch_queue_t dispatch_get_main_queue(void);
+
+DISPATCH_RETURNS_RETAINED dispatch_data_t
+dispatch_data_create(const void *buffer, size_t size,
+ dispatch_queue_t _Nullable queue,
+ dispatch_block_t _Nullable destructor);
+
+#ifdef DISPATCH_MACROS
+void _dispatch_object_validate(dispatch_object_t object);
+#define dispatch_retain(object) \
+  __extension__({ dispatch_object_t _o = (object); \
+  _dispatch_object_validate(_o); \
+  (void)[_o retain]; })
+#define dispatch_release(object) \
+  __extension__({ dispatch_object_t _o = (object); \
+  _dispatch_object_validate(_o); \
+  [_o release]; })
+#else
+void dispatch_retain(dispatch_object_t object);
+void dispatch_release(dispatch_object_t object);
+#endif
+
+int buf[1024];
+
+void leaked_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+}
+#if NON_ARC
+  // expected-warning@-2{{Potential leak of an object stored into 'data'}}
+  // expected-note@-5{{Call to function 'dispatch_data_create' returns an Objective-C object with a +1 retain count}}
+  // expected-note@-4{{Object leaked: object allocated and stored into 'data' is not referenced later in this execution path and has a retain count of +1}}
+#endif
+
+void dispatch_released_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if NON_ARC
+  dispatch_release(data); // no-warning
+#endif
+}
+
+void objc_released_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if NON_ARC
+  [data release]; // no-warning
+#endif
+}
+
+void leaked_retained_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if NON_ARC
+  dispatch_retain(data);
+  [data release];
+#endif
+}
+#if NON_ARC
+// expected-warning@-2{{Potential leak of an object stored into 'data'}}
+// expected-note@-9{{Call to function 'dispatch_data_create' returns an Objective-C object with a +1 retain count}}
+// expected-note@-7{{Reference count incremented. The object now has a +2 retain count}}
+// expected-note@-7{{Reference count decremented. The object now has a +1 retain count}}
+// expected-note@-6{{Object leaked: object allocated and stored into 'data' is not referenced later in this execution path and has a retain count of +1}}
+#endif
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ 

[PATCH] D27408: [analyzer] RetainCountChecker: remove unused enum value; NFC.

2016-12-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 80431.
NoQ added a comment.

Remove OwnedAllocatedSymbol instead.


https://reviews.llvm.org/D27408

Files:
  include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -740,7 +740,7 @@
  ObjCAllocRetE(gcenabled
 ? RetEffect::MakeGCNotOwned()
 : (usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC)
-   : RetEffect::MakeOwned(RetEffect::ObjC, true))),
+   : RetEffect::MakeOwned(RetEffect::ObjC))),
  ObjCInitRetE(gcenabled
 ? RetEffect::MakeGCNotOwned()
 : (usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC)
@@ -1086,7 +1086,7 @@
FName == "IOOpenFirmwarePathMatching") {
   // Part of . (IOKit)
   // This should be addressed using a API table.
-  S = getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true),
+  S = getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF),
DoNothing, DoNothing);
 } else if (FName == "IOServiceGetMatchingService" ||
FName == "IOServiceGetMatchingServices") {
@@ -1116,7 +1116,7 @@
   // passed to CGBitmapContextCreateWithData is released via
   // a callback and doing full IPA to make sure this is done correctly.
   ScratchArgs = AF.add(ScratchArgs, 8, StopTracking);
-  S = getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true),
+  S = getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF),
DoNothing, DoNothing);
 } else if (FName == "CVPixelBufferCreateWithPlanarBytes") {
   // FIXES: 
@@ -1292,7 +1292,7 @@
 RetainSummaryManager::getCFSummaryCreateRule(const FunctionDecl *FD) {
   assert (ScratchArgs.isEmpty());
 
-  return getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true));
+  return getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF));
 }
 
 const RetainSummary *
@@ -1322,7 +1322,7 @@
   }
 
   if (D->hasAttr())
-return RetEffect::MakeOwned(RetEffect::CF, true);
+return RetEffect::MakeOwned(RetEffect::CF);
 
   if (D->hasAttr())
 return RetEffect::MakeNotOwned(RetEffect::CF);
@@ -1435,7 +1435,7 @@
   case OMF_new:
   case OMF_copy:
   case OMF_mutableCopy:
-ResultEff = RetEffect::MakeOwned(RetEffect::CF, true);
+ResultEff = RetEffect::MakeOwned(RetEffect::CF);
 break;
   default:
 ResultEff = RetEffect::MakeNotOwned(RetEffect::CF);
@@ -1457,7 +1457,7 @@
   if (cocoa::isCocoaObjectRef(RetTy))
 ResultEff = ObjCAllocRetE;
   else if (coreFoundation::isCFObjectRef(RetTy))
-ResultEff = RetEffect::MakeOwned(RetEffect::CF, true);
+ResultEff = RetEffect::MakeOwned(RetEffect::CF);
   break;
 case OMF_autorelease:
   ReceiverEff = Autorelease;
@@ -1588,7 +1588,7 @@
   // The next methods are allocators.
   const RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE);
   const RetainSummary *CFAllocSumm =
-getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true));
+getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF));
 
   // Create the "retain" selector.
   RetEffect NoRet = RetEffect::MakeNoRet();
@@ -3076,7 +3076,6 @@
   // No work necessary.
   break;
 
-case RetEffect::OwnedAllocatedSymbol:
 case RetEffect::OwnedSymbol: {
   SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol();
   if (!Sym)
Index: include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
===
--- include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
+++ include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
@@ -120,9 +120,6 @@
 NoRet,
 /// Indicates that the returned value is an owned (+1) symbol.
 OwnedSymbol,
-/// Indicates that the returned value is an owned (+1) symbol and
-/// that it should be treated as freshly allocated.
-OwnedAllocatedSymbol,
 /// Indicates that the returned value is an object with retain count
 /// semantics but that it is not owned (+0).  This is the default
 /// for getters, etc.
@@ -163,8 +160,7 @@
   ObjKind getObjKind() const { return O; }
   
   bool isOwned() const {
-return K == OwnedSymbol || K == OwnedAllocatedSymbol ||
-K == OwnedWhenTrackedReceiver;
+return K == OwnedSymbol || K == OwnedWhenTrackedReceiver;
   }
   
   bool notOwned() const {
@@ -179,8 +175,8 @@
 return RetEffect(OwnedWhenTrackedReceiver, ObjC);
   }
   
-  static RetEffect MakeOwned(ObjKind o, bool isAllocated = false) {
-return RetEffect(isAllocated ? OwnedAllocatedSymbol 

r288822 - If clang was configured for a DEFAULT_SYSROOT and no --sysroot argument

2016-12-06 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Dec  6 10:40:57 2016
New Revision: 288822

URL: http://llvm.org/viewvc/llvm-project?rev=288822=rev
Log:
If clang was configured for a DEFAULT_SYSROOT and no --sysroot argument
is seen, record one with the implicit default.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=288822=288821=288822=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Dec  6 10:40:57 2016
@@ -4061,6 +4061,11 @@ void Clang::DumpCompilationDatabase(Comp
   Buf = "-x";
   Buf += types::getTypeName(Input.getType());
   CDB << ", \"" << escape(Buf) << "\"";
+  if (!D.SysRoot.empty() && !Args.hasArg(options::OPT__sysroot_EQ)) {
+Buf = "--sysroot=";
+Buf += D.SysRoot;
+CDB << ", \"" << escape(Buf) << "\"";
+  }
   CDB << ", \"" << escape(Input.getFilename()) << "\"";
   for (auto : Args) {
 auto  = A->getOption();


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


r288821 - Allow clang to write compilation database records.

2016-12-06 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Dec  6 10:33:22 2016
New Revision: 288821

URL: http://llvm.org/viewvc/llvm-project?rev=288821=rev
Log:
Allow clang to write compilation database records.

When integrating compilation database output into existing build
systems, two approaches dominate so far. Ad-hoc implementation of the
JSON output rules or using compiler wrappers. This patch adds a new
option "-MJ foo.json" which gives a slightly cleaned up compilation
record. The output is a fragment, i.e. you still need to add the array
markers, but it allows multiple files to be easy merged.

This way the only change in a build system is adding the option with
potentially a per-target output file and merging the files with
something like
  (echo '['; cat *.o.json; echo ']' > compilation_database.json
or some additional filtering to remove the trailing comma for strict
JSON compliance.

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

Added:
cfe/trunk/test/Driver/compilation_database.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=288821=288820=288821=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Dec  6 10:33:22 
2016
@@ -87,6 +87,8 @@ def err_drv_clang_unsupported_opt_cxx_da
   "the clang compiler does not support '%0' for C++ on Darwin/i386">;
 def err_drv_command_failed : Error<
   "%0 command failed with exit code %1 (use -v to see invocation)">;
+def err_drv_compilationdatabase : Error<
+  "compilation database '%0' could not be opened: %1">;
 def err_drv_command_signalled : Error<
   "%0 command failed due to signal (use -v to see invocation)">;
 def err_drv_force_crash : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=288821=288820=288821=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Dec  6 10:33:22 2016
@@ -266,6 +266,8 @@ def MF : JoinedOrSeparate<["-"], "MF">,
 MetaVarName<"">;
 def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>,
 HelpText<"Add missing headers to depfile">;
+def MJ : JoinedOrSeparate<["-"], "MJ">, Group,
+HelpText<"Write a compilation database entry per input">;
 def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>,
 HelpText<"Create phony target for each dependency (other than main file)">;
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=288821=288820=288821=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Dec  6 10:33:22 2016
@@ -40,9 +40,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/YAMLParser.h"
 
 #ifdef LLVM_ON_UNIX
 #include  // For getuid().
@@ -4030,6 +4030,60 @@ static void AddAssemblerKPIC(const ToolC
 CmdArgs.push_back("-KPIC");
 }
 
+void Clang::DumpCompilationDatabase(Compilation , StringRef Filename,
+StringRef Target, const InputInfo ,
+const InputInfo , const ArgList 
) const {
+  // If this is a dry run, do not create the compilation database file.
+  if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
+return;
+
+  using llvm::yaml::escape;
+  const Driver  = getToolChain().getDriver();
+
+  if (!CompilationDatabase) {
+std::error_code EC;
+auto File = llvm::make_unique(Filename, EC, 
llvm::sys::fs::F_Text);
+if (EC) {
+  D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
+   << EC.message();
+  return;
+}
+CompilationDatabase = std::move(File);
+  }
+  auto  = *CompilationDatabase;
+  SmallString<128> Buf;
+  if (llvm::sys::fs::current_path(Buf))
+Buf = ".";
+  CDB << "{ \"directory\": \"" << escape(Buf) << "\"";
+  CDB << ", \"file\": \"" << escape(Input.getFilename()) << "\"";
+  CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
+  CDB << ", \"arguments\": [\"" << escape(D.ClangExecutable) << "\"";
+  Buf = "-x";
+  Buf += types::getTypeName(Input.getType());
+  CDB << ", \"" << escape(Buf) << 

[PATCH] D27140: Allow clang to write compilation database records

2016-12-06 Thread Joerg Sonnenberger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288821: Allow clang to write compilation database records. 
(authored by joerg).

Changed prior to commit:
  https://reviews.llvm.org/D27140?vs=79997=80429#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27140

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/compilation_database.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -266,6 +266,8 @@
 MetaVarName<"">;
 def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>,
 HelpText<"Add missing headers to depfile">;
+def MJ : JoinedOrSeparate<["-"], "MJ">, Group,
+HelpText<"Write a compilation database entry per input">;
 def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>,
 HelpText<"Create phony target for each dependency (other than main file)">;
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -87,6 +87,8 @@
   "the clang compiler does not support '%0' for C++ on Darwin/i386">;
 def err_drv_command_failed : Error<
   "%0 command failed with exit code %1 (use -v to see invocation)">;
+def err_drv_compilationdatabase : Error<
+  "compilation database '%0' could not be opened: %1">;
 def err_drv_command_signalled : Error<
   "%0 command failed due to signal (use -v to see invocation)">;
 def err_drv_force_crash : Error<
Index: cfe/trunk/test/Driver/compilation_database.c
===
--- cfe/trunk/test/Driver/compilation_database.c
+++ cfe/trunk/test/Driver/compilation_database.c
@@ -0,0 +1,10 @@
+// RUN: %clang -MD -MP -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
+// RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck --check-prefix=ERROR %s
+
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// ERROR: error: compilation database '{{.*}}/non-existant' could not be opened:
+
+int main(void) {
+  return 0;
+}
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -17,6 +17,7 @@
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {
@@ -101,6 +102,12 @@
 
   mutable std::unique_ptr CLFallback;
 
+  mutable std::unique_ptr CompilationDatabase = nullptr;
+  void DumpCompilationDatabase(Compilation , StringRef Filename,
+   StringRef Target,
+   const InputInfo , const InputInfo ,
+   const llvm::opt::ArgList ) const;
+
 public:
   // CAUTION! The first constructor argument ("clang") is not arbitrary,
   // as it is for other tools. Some operations on a Tool actually test
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -40,9 +40,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/YAMLParser.h"
 
 #ifdef LLVM_ON_UNIX
 #include  // For getuid().
@@ -4030,6 +4030,60 @@
 CmdArgs.push_back("-KPIC");
 }
 
+void Clang::DumpCompilationDatabase(Compilation , StringRef Filename,
+StringRef Target, const InputInfo ,
+const InputInfo , const ArgList ) const {
+  // If this is a dry run, do not create the compilation database file.
+  if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
+return;
+
+  using llvm::yaml::escape;
+  const Driver  = getToolChain().getDriver();
+
+  if (!CompilationDatabase) {
+std::error_code EC;
+auto File = llvm::make_unique(Filename, EC, llvm::sys::fs::F_Text);
+if (EC) {
+  D.Diag(clang::diag::err_drv_compilationdatabase) << 

[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 80422.
yaxunl marked 6 inline comments as done.
yaxunl added a comment.

Bring the patch up to date.
Revised by Anastasia's comments.


https://reviews.llvm.org/D21698

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenCLImageTypes.def
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTReader.h
  lib/Basic/Targets.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Headers/opencl-c.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/Parser.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenOpenCL/extension-begin.cl
  test/Parser/opencl-atomics-cl20.cl
  test/Parser/opencl-pragma.cl
  test/SemaOpenCL/extension-begin.cl
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -21,8 +21,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
 
-
-
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
Index: test/SemaOpenCL/extension-begin.cl
===
--- /dev/null
+++ test/SemaOpenCL/extension-begin.cl
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+
+#pragma OPENCL EXTENSION all : begin // expected-warning {{expected 'disable' - ignoring}}
+#pragma OPENCL EXTENSION all : end // expected-warning {{expected 'disable' - ignoring}}
+
+#pragma OPENCL EXTENSION my_ext : begin 
+
+struct A {
+  int a;
+};
+
+typedef struct A TypedefOfA;
+typedef const TypedefOfA* PointerOfA;
+
+void f(void);
+
+__attribute__((overloadable)) void g(long x);
+
+#pragma OPENCL EXTENSION my_ext : end
+#pragma OPENCL EXTENSION my_ext : end // expected-warning {{OpenCL extension end directive mismatches begin directive - ignoring}}
+
+__attribute__((overloadable)) void g(void);
+
+#pragma OPENCL EXTENSION my_ext : enable
+void test_f1(void) {
+  struct A test_A1;
+  f();
+  g(0);
+}
+
+#pragma OPENCL EXTENSION my_ext : disable 
+void test_f2(void) {
+  struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
+  const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
+  TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
+  PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
+  f(); // expected-error {{use of declaration requires my_ext extension to be enabled}}
+  g(0); // expected-error {{no matching function for call to 'g'}}
+// expected-note@-22 {{candidate disabled due to OpenCL extension}}
+// expected-note@-18 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
+}
Index: test/Parser/opencl-pragma.cl
===
--- test/Parser/opencl-pragma.cl
+++ test/Parser/opencl-pragma.cl
@@ -5,9 +5,9 @@
 #pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */
 
 #pragma OPENCL EXTENSION all : disable
-#pragma OPENCL EXTENSION all : enable /* expected-warning {{unknown OpenCL extension 'all' - ignoring}} */
+#pragma OPENCL EXTENSION all : enable /* expected-warning {{expected 'disable' - ignoring}} */
 
-#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable' or 'disable' - ignoring}} */
+#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable', 'disable', 'begin' or 'end' - ignoring}} */
 
 #pragma OPENCL FP_CONTRACT ON
 #pragma OPENCL FP_CONTRACT OFF
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 

[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 15 inline comments as done.
yaxunl added a comment.

Sorry for the delay. I will update this patch.




Comment at: lib/Parse/ParsePragma.cpp:461
+  };
+  typedef std::pair OpenCLExtData;
 }

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Could we use PointerIntPair still but with 2 bits?
> > Using PointerIntPair with 2 bits requires IdentifierInfo to be aligned at 4 
> > bytes, however this is not true. IdentifierInfo has no explicit alignment 
> > specifier, therefore it can only hold 1 bit in PointerIntPair.
> Based on its structure with having a pointer member I think it's reasonable 
> to assume at least 4 bytes alignment... Although this doesn't seem to affect 
> the performance anyways.
You are right. The alignment of IdentifierInfo should be 8 on most systems.

However in IdentifierTable.h there is


```
// Provide PointerLikeTypeTraits for IdentifierInfo pointers, which
// are not guaranteed to be 8-byte aligned.
template<>
class PointerLikeTypeTraits {
public:
  static inline void *getAsVoidPointer(clang::IdentifierInfo* P) {
return P;
  }
  static inline clang::IdentifierInfo *getFromVoidPointer(void *P) {
return static_cast(P);
  }
  enum { NumLowBitsAvailable = 1 };
};

```
Due to the above code there is only 1 bit available for when using 
PointerIntPair with IdentifierInfo*. My guess is that alignment of 
IdentifierInfo is not 8 on certain systems so some one intentionally defined 
the above code to prevent using PointerIntPair with IdentifierInfo* for more 
than 1 bit.




Comment at: lib/Parse/ParsePragma.cpp:1429
   PP.Lex(Tok);
-  if (Tok.isNot(tok::identifier)) {
-PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_enable_disable);
+  if (Tok.isNot(tok::identifier) && Tok.isNot(tok::kw_register)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_predicate) << 0;

Anastasia wrote:
> Not clear why register keyword is here too?
this is old code when I use 'register' to register an extension. will remove it.



Comment at: lib/Sema/Sema.cpp:226
  Context.getAtomicType(Context.UnsignedIntTy));
-  addImplicitTypedef("atomic_long", Context.getAtomicType(Context.LongTy));
-  addImplicitTypedef("atomic_ulong",
- Context.getAtomicType(Context.UnsignedLongTy));
+  auto AtomicLongT = Context.getAtomicType(Context.LongTy);
+  addImplicitTypedef("atomic_long", AtomicLongT);

Anastasia wrote:
> Any reason for changing this too?
To associate atomic long and double types with corresponding extensions so that 
when the extension is disabled, the associated types are also disabled.



Comment at: lib/Sema/Sema.cpp:1558
+  if (Exts.empty())
+return;
+  auto CanT = T.getCanonicalType().getTypePtr();

Anastasia wrote:
> Could we then check for an empty string ExtStr as a first function statement 
> instead?
will do



Comment at: test/Parser/opencl-atomics-cl20.cl:51
 // expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-27 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
enabled}}
-// expected-error-re@-28 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
enabled}}
-// expected-error-re@-29 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
enabled}}
+#if __LP64__
+// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}

Anastasia wrote:
> Why this change?
atomic_intptr_t etc. requires cl_khr_int64_extended_atomics only on 64 bit 
platforms.

This is a bug which was fixed by this patch.



Comment at: test/SemaOpenCL/extension-begin.cl:27
+}
+
+#pragma OPENCL EXTENSION my_ext : disable 

Anastasia wrote:
> Could you please add case with typedef of a type from an 

r288818 - Fix doc string typo: s/@__yes/@__objc_yes/

2016-12-06 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Tue Dec  6 09:45:41 2016
New Revision: 288818

URL: http://llvm.org/viewvc/llvm-project?rev=288818=rev
Log:
Fix doc string typo: s/@__yes/@__objc_yes/

Modified:
cfe/trunk/include/clang/AST/ExprObjC.h

Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=288818=288817=288818=diff
==
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Tue Dec  6 09:45:41 2016
@@ -90,7 +90,7 @@ public:
 /// ObjCBoxedExpr - used for generalized expression boxing.
 /// as in: @(strdup("hello world")), @(random()) or @(view.frame)
 /// Also used for boxing non-parenthesized numeric literals;
-/// as in: @42 or \@true (c++/objc++) or \@__yes (c/objc).
+/// as in: @42 or \@true (c++/objc++) or \@__objc_yes (c/objc).
 class ObjCBoxedExpr : public Expr {
   Stmt *SubExpr;
   ObjCMethodDecl *BoxingMethod;


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


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-06 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a reviewer: djasper.
klimek added a comment.

Adding djasper, who had brought forward the idea.


https://reviews.llvm.org/D27440



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


[PATCH] D27123: Add AVR target and toolchain to Clang

2016-12-06 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D27123#614313, @saaadhu wrote:

> Add testcases to test/Preprocessor/init.c


Awesome, thanks!

> Correct types for WChar and WInt
> 
> The ABI is documented in the avr-gcc wiki (https://gcc.gnu.org/wiki/avr-gcc)
>  I took the output of a trunk build of avr-gcc -dM -E and put that in the 
> Preprocessor/init.c testcase, removing everything clang does not define.

Good plan.

> The conflicting defines were
> 
> 1. DBL and LDBL related defines - clang appears to consider doubles as 64 bit 
> even if DoubleWidth is 32 bit

I /think/ you need to set LongDoubleFormat for that to work.

> 2. SIG_ATOMIC defines.

What are the differences there?


https://reviews.llvm.org/D27123



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


Re: Fix some misc-move-forwarding-reference warnings

2016-12-06 Thread Malcolm Parsons via cfe-commits
On 2 December 2016 at 17:13, Michael Sharpe via cfe-commits
 wrote:
> The attached patch fixes a couple of incorrect uses of std::move as revealed
> by clang-tidy.

LGTM.

Committed as r288813.

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


r288813 - Fix two clang-tidy misc-move-forwarding-reference warnings

2016-12-06 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec  6 08:49:18 2016
New Revision: 288813

URL: http://llvm.org/viewvc/llvm-project?rev=288813=rev
Log:
Fix two clang-tidy misc-move-forwarding-reference warnings

Patch by Michael Sharpe.

Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=288813=288812=288813=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Dec  6 08:49:18 2016
@@ -1057,7 +1057,7 @@ QualType simpleTransform(ASTContext 
   SplitQualType splitType = type.split();
 
   // Visit the type itself.
-  SimpleTransformVisitor visitor(ctx, std::move(f));
+  SimpleTransformVisitor visitor(ctx, std::forward(f));
   QualType result = visitor.Visit(splitType.Ty);
   if (result.isNull())
 return result;

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=288813=288812=288813=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Dec  6 08:49:18 2016
@@ -1941,7 +1941,7 @@ static T *buildByrefHelpers(CodeGenModul
   generator.CopyHelper = buildByrefCopyHelper(CGM, byrefInfo, generator);
   generator.DisposeHelper = buildByrefDisposeHelper(CGM, byrefInfo, generator);
 
-  T *copy = new (CGM.getContext()) T(std::move(generator));
+  T *copy = new (CGM.getContext()) T(std::forward(generator));
   CGM.ByrefHelpersCache.InsertNode(copy, insertPos);
   return copy;
 }


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


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25686#614420, @rengolin wrote:

> I think this patch should move to canonicalise the triple as per all the 
> others, in the right place (vendor/environment).
>
> If you find `hardfloat` or on where the vendor should be, and there are no 
> other possible vendors, just append `hf` to the environment and mark the 
> vendor as `unknown`. This works already with `gnueabihf`, `eabihf` and 
> `muslabihf` (doubts about this last one).
>
> What the clang driver accepts is different than what the rest of the compiler 
> should use.


Ok but I think that then clang will not be able to find the gcc directory. Am I 
missing something obvious?


https://reviews.llvm.org/D25686



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


[PATCH] D27455: UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.

2016-12-06 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added reviewers: rsmith, samsonov.
thakis added a subscriber: cfe-commits.

https://reviews.llvm.org/D27455

Files:
  docs/UndefinedBehaviorSanitizer.rst


Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -117,7 +117,9 @@
   -  ``-fsanitize=unreachable``: If control flow reaches
  ``__builtin_unreachable``.
   -  ``-fsanitize=unsigned-integer-overflow``: Unsigned integer
- overflows.
+ overflows. Note that unlike signed integer overflow, unsigned integer
+ is not undefined behavior. However, while it has well-defined semantics,
+ it is often unintentional, so UBSan offers to catch it.
   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
  does not evaluate to a positive value.
   -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that


Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -117,7 +117,9 @@
   -  ``-fsanitize=unreachable``: If control flow reaches
  ``__builtin_unreachable``.
   -  ``-fsanitize=unsigned-integer-overflow``: Unsigned integer
- overflows.
+ overflows. Note that unlike signed integer overflow, unsigned integer
+ is not undefined behavior. However, while it has well-defined semantics,
+ it is often unintentional, so UBSan offers to catch it.
   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
  does not evaluate to a positive value.
   -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-06 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

I think this patch should move to canonicalise the triple as per all the 
others, in the right place (vendor/environment).

If you find `hardfloat` or on where the vendor should be, and there are no 
other possible vendors, just append `hf` to the environment and mark the vendor 
as `unknown`. This works already with `gnueabihf`, `eabihf` and `muslabihf` 
(doubts about this last one).

What the clang driver accepts is different than what the rest of the compiler 
should use.


https://reviews.llvm.org/D25686



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


RE: [PATCH] D27334: [OpenCL] Ambiguous function call.

2016-12-06 Thread Bader, Alexey via cfe-commits
Actually OpenCL specification has the following text in “Built-in Functions” 
chapter (OpenCL C 2.0 rev. 33):

“ User defined OpenCL C functions, behave per C standard rules for functions 
(C99, TC2, Section
6.9.1). On entry to the function, the size of each variably modified parameter 
is evaluated and
the value of each argument expression is converted to the type of the 
corresponding parameter as
per usual arithmetic conversion rules described in section 6.2.6. Built-in 
functions described in
this section behave similarly, except that in order to avoid ambiguity between 
multiple forms of
the same built-in function, implicit scalar widening shall not occur. Note that 
some built-in
functions described in this section do have forms that operate on mixed scalar 
and vector types,
however.”

If I understand it correctly this text can help to resolve the overloading, 
since “usual arithmetic conversion rules” from section 6.2.6 rank floating 
point and integer data types including vector flavors. On the other hand I 
don’t think it’s good idea to adopt this rule, since it doesn’t follow C++ 
overloading rules and definitely will deviate OpenCL behavior from C or C++.

Thanks,
Alexey

From: Anastasia Stulova [mailto:anastasia.stul...@arm.com]
Sent: Monday, December 5, 2016 9:21 PM
To: Richard Smith ; Bruno Cardoso Lopes via Phabricator 
; 
reviews+d27334+public+f2c5a66032c4c...@reviews.llvm.org
Cc: Bader, Alexey ; egor.chur...@gmail.com; 
yaxun@amd.com; cfe-commits@lists.llvm.org; nd 
Subject: RE: [PATCH] D27334: [OpenCL] Ambiguous function call.

> Perhaps that is the problem (that there are two modes that do different 
> things)? Could we make the double overload be present but unselectable to 
> diagnose this problem in that mode too?

If we could resolve the overload candidate to prefer ‘int -> float’ than 
‘int->double’, it would work best.

From: meta...@gmail.com [mailto:meta...@gmail.com] On 
Behalf Of Richard Smith
Sent: 05 December 2016 17:53
To: Bruno Cardoso Lopes via Phabricator; 
reviews+d27334+public+f2c5a66032c4c...@reviews.llvm.org
Cc: alexey.ba...@intel.com; 
egor.chur...@gmail.com; 
yaxun@amd.com; Anastasia Stulova; 
cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D27334: [OpenCL] Ambiguous function call.

On 5 Dec 2016 9:42 am, "Anastasia Stulova via Phabricator via cfe-commits" 
> wrote:
Anastasia added a comment.

In https://reviews.llvm.org/D27334#612858, @bader wrote:

> In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:
>
> > This change seems to modify normal C behavior again. Is there any strong 
> > motivation for doing this and if yes could it be done generically with C?
>
>
> Motivation:
>
>   // Non-portable OpenCL 1.2 code
>   __kernel void foo(global float* out) {
> out[get_global_id(0)] = sin(get_global_id(0));
>   }
>
>
> This program compiles fine on OpenCL platform w/o doubles support

Perhaps that is the problem (that there are two modes that do different 
things)? Could we make the double overload be present but unselectable to 
diagnose this problem in that mode too?

and fails otherwise.
>  If OpenCL driver supports doubles it provides at least two versions of 'sin' 
> built-in math function and compiler will not be able to choose the right one 
> for 'size_t' argument.

Do you have a real example? If someone passes an integer to 'sin', I think 
there's a better warning we can give them :)

>  The goal of this warning is to let OpenCL developer know about potential 
> issues with code portability.
I would argue this improves the portability much as it can also be misleading 
in some situations (because it refers to a potentially hypothetical problem). 
For example there can be builtin functions that only have a float parameter 
(without a double version of it). This is for example the case with read_image 
functions that take a float coordinate value between 0 and 1. Unfortunately 
this warning won't be triggered on read_image functions because there is an 
overload candidate with an int type of the same parameter too. But we can't 
exclude this situations to appear in the future or from some vendor extensions 
or even custom OpenCL code.


https://reviews.llvm.org/D27334



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



Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation

This 

[PATCH] D27453: [OpenCL] Enable unroll hint for OpenCL 1.x.

2016-12-06 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: bader, cfe-commits, yaxunl.

Although the feature was introduced only in OpenCL C v2.0 spec., it's useful 
for OpenCL 1.x too and doesn't require HW support.


https://reviews.llvm.org/D27453

Files:
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl


Index: test/SemaOpenCL/unroll-hint.cl
===
--- test/SemaOpenCL/unroll-hint.cl
+++ test/SemaOpenCL/unroll-hint.cl
@@ -1,17 +1,5 @@
-//RUN: %clang_cc1 -O0 -fsyntax-only -verify %s
-//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify -DCL20 %s
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
 
-kernel void D (global int *x) {
-  int i = 10;
-#ifndef CL20
-  // expected-error@+2 {{'opencl_unroll_hint' attribute requires OpenCL 
version 2.0 or above}}
-#endif
-  __attribute__((opencl_unroll_hint))
-  do {
-  } while(i--);
-}
-
-#ifdef CL20
 kernel void C (global int *x) {
   int I = 3;
   __attribute__((opencl_unroll_hint(I))) // expected-error 
{{'opencl_unroll_hint' attribute requires an integer constant}}
@@ -27,4 +15,3 @@
   __attribute__((opencl_unroll_hint(-1))) // expected-error 
{{'opencl_unroll_hint' attribute requires a positive integral compile time 
constant expression}}
   for(int i=0; i<100; i++);
 }
-#endif
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- test/CodeGenOpenCL/unroll-hint.cl
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s | FileCheck %s
 
 /*** for ***/
 void for_count()
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -229,12 +229,6 @@
   // determines unrolling factor) or 1 argument (the unroll factor provided
   // by the user).
 
-  if (S.getLangOpts().OpenCLVersion < 200) {
-S.Diag(A.getLoc(), diag::err_attribute_requires_opencl_version)
-<< A.getName() << "2.0" << 1;
-return nullptr;
-  }
-
   unsigned NumArgs = A.getNumArgs();
 
   if (NumArgs > 1) {


Index: test/SemaOpenCL/unroll-hint.cl
===
--- test/SemaOpenCL/unroll-hint.cl
+++ test/SemaOpenCL/unroll-hint.cl
@@ -1,17 +1,5 @@
-//RUN: %clang_cc1 -O0 -fsyntax-only -verify %s
-//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify -DCL20 %s
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
 
-kernel void D (global int *x) {
-  int i = 10;
-#ifndef CL20
-  // expected-error@+2 {{'opencl_unroll_hint' attribute requires OpenCL version 2.0 or above}}
-#endif
-  __attribute__((opencl_unroll_hint))
-  do {
-  } while(i--);
-}
-
-#ifdef CL20
 kernel void C (global int *x) {
   int I = 3;
   __attribute__((opencl_unroll_hint(I))) // expected-error {{'opencl_unroll_hint' attribute requires an integer constant}}
@@ -27,4 +15,3 @@
   __attribute__((opencl_unroll_hint(-1))) // expected-error {{'opencl_unroll_hint' attribute requires a positive integral compile time constant expression}}
   for(int i=0; i<100; i++);
 }
-#endif
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- test/CodeGenOpenCL/unroll-hint.cl
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s | FileCheck %s
 
 /*** for ***/
 void for_count()
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -229,12 +229,6 @@
   // determines unrolling factor) or 1 argument (the unroll factor provided
   // by the user).
 
-  if (S.getLangOpts().OpenCLVersion < 200) {
-S.Diag(A.getLoc(), diag::err_attribute_requires_opencl_version)
-<< A.getName() << "2.0" << 1;
-return nullptr;
-  }
-
   unsigned NumArgs = A.getNumArgs();
 
   if (NumArgs > 1) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [PATCH] D27334: [OpenCL] Ambiguous function call.

2016-12-06 Thread Bader, Alexey via cfe-commits
On 5 Dec 2016 9:42 am, "Anastasia Stulova via Phabricator via cfe-commits" 
> wrote:
Anastasia added a comment.

In https://reviews.llvm.org/D27334#612858, @bader wrote:

> In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:
>
> > This change seems to modify normal C behavior again. Is there any strong 
> > motivation for doing this and if yes could it be done generically with C?
>
>
> Motivation:
>
>   // Non-portable OpenCL 1.2 code
>   __kernel void foo(global float* out) {
> out[get_global_id(0)] = sin(get_global_id(0));
>   }
>
>
> This program compiles fine on OpenCL platform w/o doubles support

Perhaps that is the problem (that there are two modes that do different 
things)? Could we make the double overload be present but unselectable to 
diagnose this problem in that mode too?

and fails otherwise.
>  If OpenCL driver supports doubles it provides at least two versions of 'sin' 
> built-in math function and compiler will not be able to choose the right one 
> for 'size_t' argument.

Do you have a real example? If someone passes an integer to 'sin', I think 
there's a better warning we can give them :)
[AB] As far as I remember the code that I got used some OpenCL math built-in 
function and passed some integer constant like pow(x, 2).
To fix this case is developer can pass ‘float’ literal ‘2.f’ or use ‘pown’ 
built-in math function which accepts integers as second parameter.

>  The goal of this warning is to let OpenCL developer know about potential 
> issues with code portability.

I would argue this improves the portability much as it can also be misleading 
in some situations (because it refers to a potentially hypothetical problem). 
For example there can be builtin functions that only have a float parameter 
(without a double version of it). This is for example the case with read_image 
functions that take a float coordinate value between 0 and 1. Unfortunately 
this warning won't be triggered on read_image functions because there is an 
overload candidate with an int type of the same parameter too. But we can't 
exclude this situations to appear in the future or from some vendor extensions 
or even custom OpenCL code.


https://reviews.llvm.org/D27334



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



Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

How should I proceed, then? Was something along the lines of the earlier diff a 
better idea?


https://reviews.llvm.org/D25686



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


[PATCH] D27334: [OpenCL] Ambiguous function call.

2016-12-06 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In https://reviews.llvm.org/D27334#613504, @Anastasia wrote:

> In https://reviews.llvm.org/D27334#612858, @bader wrote:
>
> > In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:
> >
> > > This change seems to modify normal C behavior again. Is there any strong 
> > > motivation for doing this and if yes could it be done generically with C?
> >
> >
> > Motivation:
> >
> >   // Non-portable OpenCL 1.2 code 
> >   __kernel void foo(global float* out) {
> > out[get_global_id(0)] = sin(get_global_id(0));
> >   }
> >
> >
> > This program compiles fine on OpenCL platform w/o doubles support and fails 
> > otherwise.
> >  If OpenCL driver supports doubles it provides at least two versions of 
> > 'sin' built-in math function and compiler will not be able to choose the 
> > right one for 'size_t' argument.
> >  The goal of this warning is to let OpenCL developer know about potential 
> > issues with code portability.
>
>
> I would argue this improves the portability much as it can also be misleading 
> in some situations (because it refers to a potentially hypothetical problem). 
> For example there can be builtin functions that only have a float parameter 
> (without a double version of it). This is for example the case with 
> read_image functions that take a float coordinate value between 0 and 1. 
> Unfortunately this warning won't be triggered on read_image functions because 
> there is an overload candidate with an int type of the same parameter too. 
> But we can't exclude this situations to appear in the future or from some 
> vendor extensions or even custom OpenCL code.


As much as any other warning it's not always means that there is an error in 
the code. It just means that developer should inspect the construction 
triggering a warning.
Passing integer value to a function with floating point parameters is not 
always an error, but some times it might be so.
Do you suggest dropping the diagnostics at all or changing the diagnostics 
message?


https://reviews.llvm.org/D27334



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


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D27440#614337, @klimek wrote:

> Pondering this a bit - one question is whether we should make clang-format 
> not return 0 if we pass -fallback-style=none (it already has this option) and 
> we can't figure out a style. What do you think?


When you say "it already has this option", do you mean this is what 
fallback-style is set to by default in this extension? Because, in fact, by 
default it's set to LLVM. Personally, I think it should be set to "none" by 
default.

Having said that, to answer your question, personally I think "fallback-style" 
is really an option that only makes sense when "style=file" AND a file is not 
found. If a user has a .clang-format file, and it fails to parse correctly, 
they would likely find it surprising that it would then ignore that file and 
use the fallback style. I would much rather it just fail hard and not use the 
fallback style in this case.


https://reviews.llvm.org/D27440



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


[PATCH] D27403: [OpenCL] Added a LIT test for ensuring address space mangling is done the same both in OpenCL1.2 and OpenCL2.0.

2016-12-06 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 80401.
echuraev marked an inline comment as done.

https://reviews.llvm.org/D27403

Files:
  test/CodeGenOpenCL/address-spaces-mangling.cl


Index: test/CodeGenOpenCL/address-spaces-mangling.cl
===
--- test/CodeGenOpenCL/address-spaces-mangling.cl
+++ test/CodeGenOpenCL/address-spaces-mangling.cl
@@ -1,30 +1,44 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map 
-faddress-space-map-mangling=yes -triple %itanium_abi_triple -emit-llvm -o - | 
FileCheck -check-prefix=ASMANG %s
 // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=no 
-triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefix=NOASMANG 
%s
 
+// We check that the address spaces are mangled the same in both version of 
OpenCL
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm -o 
- | FileCheck -check-prefix=OCL-20 %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -emit-llvm -o 
- | FileCheck -check-prefix=OCL-12 %s
+
 // We can't name this f as private is equivalent to default
 // no specifier given address space so we get multiple definition
 // warnings, but we do want it for comparison purposes.
 __attribute__((overloadable))
 void ff(int *arg) { }
 // ASMANG: @_Z2ffPi
 // NOASMANG: @_Z2ffPi
+// OCL-20-DAG: @_Z2ffPU3AS4i
+// OCL-12-DAG: @_Z2ffPi
 
 __attribute__((overloadable))
 void f(private int *arg) { }
 // ASMANG: @_Z1fPi
 // NOASMANG: @_Z1fPi
+// OCL-20-DAG: @_Z1fPi
+// OCL-12-DAG: @_Z1fPi
 
 __attribute__((overloadable))
 void f(global int *arg) { }
 // ASMANG: @_Z1fPU3AS1i
 // NOASMANG: @_Z1fPU8CLglobali
+// OCL-20-DAG: @_Z1fPU3AS1i
+// OCL-12-DAG: @_Z1fPU3AS1i
 
 __attribute__((overloadable))
 void f(local int *arg) { }
 // ASMANG: @_Z1fPU3AS2i
 // NOASMANG: @_Z1fPU7CLlocali
+// OCL-20-DAG: @_Z1fPU3AS2i
+// OCL-12-DAG: @_Z1fPU3AS2i
 
 __attribute__((overloadable))
 void f(constant int *arg) { }
 // ASMANG: @_Z1fPU3AS3i
 // NOASMANG: @_Z1fPU10CLconstanti
+// OCL-20-DAG: @_Z1fPU3AS3i
+// OCL-12-DAG: @_Z1fPU3AS3i


Index: test/CodeGenOpenCL/address-spaces-mangling.cl
===
--- test/CodeGenOpenCL/address-spaces-mangling.cl
+++ test/CodeGenOpenCL/address-spaces-mangling.cl
@@ -1,30 +1,44 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=yes -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefix=ASMANG %s
 // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=no -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefix=NOASMANG %s
 
+// We check that the address spaces are mangled the same in both version of OpenCL
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm -o - | FileCheck -check-prefix=OCL-20 %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -emit-llvm -o - | FileCheck -check-prefix=OCL-12 %s
+
 // We can't name this f as private is equivalent to default
 // no specifier given address space so we get multiple definition
 // warnings, but we do want it for comparison purposes.
 __attribute__((overloadable))
 void ff(int *arg) { }
 // ASMANG: @_Z2ffPi
 // NOASMANG: @_Z2ffPi
+// OCL-20-DAG: @_Z2ffPU3AS4i
+// OCL-12-DAG: @_Z2ffPi
 
 __attribute__((overloadable))
 void f(private int *arg) { }
 // ASMANG: @_Z1fPi
 // NOASMANG: @_Z1fPi
+// OCL-20-DAG: @_Z1fPi
+// OCL-12-DAG: @_Z1fPi
 
 __attribute__((overloadable))
 void f(global int *arg) { }
 // ASMANG: @_Z1fPU3AS1i
 // NOASMANG: @_Z1fPU8CLglobali
+// OCL-20-DAG: @_Z1fPU3AS1i
+// OCL-12-DAG: @_Z1fPU3AS1i
 
 __attribute__((overloadable))
 void f(local int *arg) { }
 // ASMANG: @_Z1fPU3AS2i
 // NOASMANG: @_Z1fPU7CLlocali
+// OCL-20-DAG: @_Z1fPU3AS2i
+// OCL-12-DAG: @_Z1fPU3AS2i
 
 __attribute__((overloadable))
 void f(constant int *arg) { }
 // ASMANG: @_Z1fPU3AS3i
 // NOASMANG: @_Z1fPU10CLconstanti
+// OCL-20-DAG: @_Z1fPU3AS3i
+// OCL-12-DAG: @_Z1fPU3AS3i
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288793 - Also recognize -std=iso9899:201x

2016-12-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Dec  6 04:23:07 2016
New Revision: 288793

URL: http://llvm.org/viewvc/llvm-project?rev=288793=rev
Log:
Also recognize -std=iso9899:201x

It should already be handled but a typo in the LANGSTANDARD() definition
was introduced in r147220.

Patch by Alexander Richardson, test case by me.

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

Modified:
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=288793=288792=288793=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Tue Dec  6 04:23:07 2016
@@ -81,7 +81,7 @@ LANGSTANDARD(iso9899_2011,
  "iso9899:2011", "ISO C 2011",
  LineComment | C99 | C11 | Digraphs | HexFloat)
 LANGSTANDARD(iso9899_201x,
- "iso9899:2011", "ISO C 2011",
+ "iso9899:201x", "ISO C 2011",
  LineComment | C99 | C11 | Digraphs | HexFloat)
 
 LANGSTANDARD(gnu11, "gnu11",

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=288793=288792=288793=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Dec  6 04:23:07 2016
@@ -64,6 +64,9 @@
 //
 // 
 // RUN: %clang_cc1 -std=c11 -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix C11 %s
+// RUN: %clang_cc1 -std=c1x -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix C11 %s
+// RUN: %clang_cc1 -std=iso9899:2011 -E -dM < /dev/null | FileCheck 
-match-full-lines -check-prefix C11 %s
+// RUN: %clang_cc1 -std=iso9899:201x -E -dM < /dev/null | FileCheck 
-match-full-lines -check-prefix C11 %s
 //
 // C11:#define __STDC_UTF_16__ 1
 // C11:#define __STDC_UTF_32__ 1


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


[PATCH] D26968: [ARM] Add Driver support for emitting the missing Tag_ABI_enum_size build attribute values

2016-12-06 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea abandoned this revision.
labrinea added a comment.

Hi Renato, apologies for the long silence. Unfortunately this work is more 
complicated than I initially thought. We'll have to rethink about it 
thoroughly. I am going to abandon the patch for now. Thank you for reviewing 
this.


https://reviews.llvm.org/D26968



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


[clang-tools-extra] r288791 - [clang-move] ignore unsupported symbol kinds when checking if all symbols are moved.

2016-12-06 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Dec  6 04:12:23 2016
New Revision: 288791

URL: http://llvm.org/viewvc/llvm-project?rev=288791=rev
Log:
[clang-move] ignore unsupported symbol kinds when checking if all symbols are 
moved.

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

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=288791=288790=288791=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Dec  6 04:12:23 2016
@@ -713,7 +713,24 @@ void ClangMoveTool::onEndOfTranslationUn
 
   if (RemovedDecls.empty())
 return;
-  if (UnremovedDeclsInOldHeader.empty() && !Context->Spec.OldHeader.empty()) {
+  // Ignore symbols that are not supported (e.g. typedef and enum) when
+  // checking if there is unremoved symbol in old header. This makes sure that
+  // we always move old files to new files when all symbols produced from
+  // dump_decls are moved.
+  auto IsSupportedKind = [](const clang::NamedDecl *Decl) {
+switch (Decl->getKind()) {
+case Decl::Kind::Function:
+case Decl::Kind::FunctionTemplate:
+case Decl::Kind::ClassTemplate:
+case Decl::Kind::CXXRecord:
+  return true;
+default:
+  return false;
+}
+  };
+  if (std::none_of(UnremovedDeclsInOldHeader.begin(),
+   UnremovedDeclsInOldHeader.end(), IsSupportedKind) &&
+  !Context->Spec.OldHeader.empty()) {
 auto  = RemovedDecls[0]->getASTContext().getSourceManager();
 moveAll(SM, Context->Spec.OldHeader, Context->Spec.NewHeader);
 moveAll(SM, Context->Spec.OldCC, Context->Spec.NewCC);

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=288791=288790=288791=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Tue Dec  6 04:12:23 2016
@@ -95,7 +95,9 @@ struct ClangMoveContext {
 // The goal of this tool is to make the new files as compliable as possible.
 //
 // Note: When all declarations in old header are being moved, all code in
-// old.h/cc will be moved, which means old.h/cc are empty.
+// old.h/cc will be moved, which means old.h/cc are empty. This ignores symbols
+// that are not supported (e.g. typedef and enum) so that we always move old
+// files to new files when all symbols produced from dump_decls are moved.
 class ClangMoveTool : public ast_matchers::MatchFinder::MatchCallback {
 public:
   ClangMoveTool(ClangMoveContext *const Context,

Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=288791=288790=288791=diff
==
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Tue Dec  6 
04:12:23 2016
@@ -330,11 +330,8 @@ TEST(ClangMove, DontMoveAll) {
 "#endif // NEW_FOO_H\n";
   const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
   std::vector TestHeaders = {
-"typedef int Int;\nclass A {\npublic:\n  int f();\n};\n",
-"using Int=int;\nclass A {\npublic:\n  int f();\n};\n",
 "class B {};\nclass A {\npublic:\n  int f();\n};\n",
 "void f() {};\nclass A {\npublic:\n  int f();\n};\n",
-"enum Color { RED };\nclass A {\npublic:\n  int f();\n};\n",
   };
   move::MoveDefinitionSpec Spec;
   Spec.Names.push_back("A");
@@ -351,6 +348,26 @@ TEST(ClangMove, DontMoveAll) {
   }
 }
 
+TEST(ClangMove, IgnoreUnsupportedKindsAndMoveAll) {
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  std::vector TestHeaders = {
+  "typedef int Int;\nclass A {\npublic:\n  int f();\n};\n",
+  "using Int = int;\nclass A {\npublic:\n  int f();\n};\n",
+  "enum Color { RED };\nclass A {\npublic:\n  int f();\n};\n",
+  };
+  move::MoveDefinitionSpec Spec;
+  Spec.Names.push_back("A");
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto  : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+EXPECT_EQ("", Results[Spec.OldHeader]);
+  }
+}
+
 TEST(ClangMove, MacroInFunction) {
   const char TestHeader[] = "#define INT int\n"
 "class A {\npublic:\n  int f();\n};\n"


___

[PATCH] D27140: Allow clang to write compilation database records

2016-12-06 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG. We can always add more intricate ways later on.


Repository:
  rL LLVM

https://reviews.llvm.org/D27140



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


  1   2   >