[PATCH] D34496: [clang] Fix printf check for CFIndex

2017-06-26 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.

This looks correct to me. The commit log of the original commit (r163266) 
doesn't say that CFIndex has been dropped intentionally, so this should be fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D34496



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


[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.

2017-06-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: include/clang/Format/Format.h:993
+  /// inside ``IncludeCategories``.
+  bool IncludeRegexCaseInsensitive;
+

Do we really need a flag here? Shouldn't we just always do this?


https://reviews.llvm.org/D33932



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


[PATCH] D34395: clang-format: add options to merge empty record body

2017-06-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I don't know if some style would want different styles, and I agree with you on 
principle; but since the brace wrapping is already configured for each kind of 
record, I choose to keep things consistent and have flags for each kind of 
record.
But I can merge the options, and keep only `SplitEmptyRecord` and 
`SplitEmptyNamespace`, if you really think it is better.


https://reviews.llvm.org/D34395



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


[PATCH] D34395: clang-format: add options to merge empty record body

2017-06-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Yes merge them into those two, please. I think we introduced the others because 
of some linux style, but generally lets try not to introduce options that 
people aren't going to use.


https://reviews.llvm.org/D34395



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


[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-06-26 Thread Serge Preis via Phabricator via cfe-commits
Serge_Preis added a comment.

Is there any meaning in 'test-clang-msc-x64-on-i686-linux-RA' (I just don't 
knwo what this configuration mean) - I tested on Linux that I have at my 
desposal and tesing passes.


Repository:
  rL LLVM

https://reviews.llvm.org/D32439



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


[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-06-26 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment.

In https://reviews.llvm.org/D32439#790248, @Serge_Preis wrote:

> Is there any meaning in 'test-clang-msc-x64-on-i686-linux-RA' (I just don't 
> knwo what this configuration mean) - I tested on Linux that I have at my 
> disposal and tesing passes.


It's cross-compiling.
LLVM_BUILD_32_BITS=ON (-m32)
LLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-win32

See also; 
http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA/builds/3858


Repository:
  rL LLVM

https://reviews.llvm.org/D32439



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


r306280 - [mips] Enable IAS by default for Android 64-bit MIPS target (N64)

2017-06-26 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Mon Jun 26 02:58:01 2017
New Revision: 306280

URL: http://llvm.org/viewvc/llvm-project?rev=306280&view=rev
Log:
[mips] Enable IAS by default for Android 64-bit MIPS target (N64)

IAS is already used for MIPS64 in majority of Android projects.
Android MIPS64 uses N64 ABI. Set IAS as a default now.

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=306280&r1=306279&r2=306280&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Jun 26 02:58:01 2017
@@ -2338,9 +2338,11 @@ bool Generic_GCC::IsIntegratedAssemblerD
 return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-// Enabled for Debian mips64/mips64el only. Other targets are unable to
-// distinguish N32 from N64.
-if (getTriple().getEnvironment() == llvm::Triple::GNUABI64)
+// Enabled for Debian and Android mips64/mipsel, as they can precisely
+// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android).
+// Other targets are unable to distinguish N32 from N64.
+if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
+getTriple().isAndroid())
   return true;
 return false;
   default:


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


[PATCH] D34514: [mips] Enable IAS by default for Android 64-bit MIPS target (N64)

2017-06-26 Thread Petar Jovanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306280: [mips] Enable IAS by default for Android 64-bit MIPS 
target (N64) (authored by petarj).

Changed prior to commit:
  https://reviews.llvm.org/D34514?vs=103574&id=103912#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34514

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -2338,9 +2338,11 @@
 return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-// Enabled for Debian mips64/mips64el only. Other targets are unable to
-// distinguish N32 from N64.
-if (getTriple().getEnvironment() == llvm::Triple::GNUABI64)
+// Enabled for Debian and Android mips64/mipsel, as they can precisely
+// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android).
+// Other targets are unable to distinguish N32 from N64.
+if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
+getTriple().isAndroid())
   return true;
 return false;
   default:


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -2338,9 +2338,11 @@
 return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-// Enabled for Debian mips64/mips64el only. Other targets are unable to
-// distinguish N32 from N64.
-if (getTriple().getEnvironment() == llvm::Triple::GNUABI64)
+// Enabled for Debian and Android mips64/mipsel, as they can precisely
+// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android).
+// Other targets are unable to distinguish N32 from N64.
+if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
+getTriple().isAndroid())
   return true;
 return false;
   default:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations

2017-06-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I don't think the new warning is ideal, e.g.:

  #import 
  
  __attribute__((visibility("default"))) 
__attribute__((availability(macosx,introduced=10_10)))
  @interface Test : NSObject
  
  @end
  
  Test *testVar;

E.g.:

  test.m:13:1: warning: 'Test' is partial: introduced in macOS 10.10 
[-Wunguarded-availability]
  Test *testVar;
  ^
  test.m:6:12: note: 'Test' has been explicitly marked partial here
  @interface Test : NSObject
 ^
  test.m:13:7: note: annotate 'Test' with an availability attribute to silence
  Test *testVar;
^

We are telling the user to annotate the class 'Test' with an availability 
attribute, but that class is already annotated with the attribute in the 
framework!
We should either refer to the `testVar` declaration, or say something like 
`annotate the declaration that uses 'Test' .`.


https://reviews.llvm.org/D33816



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


[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-06-26 Thread Serge Preis via Phabricator via cfe-commits
Serge_Preis added a comment.

In https://reviews.llvm.org/D32439#790252, @chapuni wrote:

> In https://reviews.llvm.org/D32439#790248, @Serge_Preis wrote:
>
> > Is there any meaning in 'test-clang-msc-x64-on-i686-linux-RA' (I just don't 
> > knwo what this configuration mean) - I tested on Linux that I have at my 
> > disposal and tesing passes.
>
>
> It's cross-compiling.
>  LLVM_BUILD_32_BITS=ON (-m32)
>  LLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-win32
>
> See also; 
> http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA/builds/3858


Thank you for clarifications, would you explain how may I reproduce failure 
locally or remotely. I'd like to see c-index-test output before clang-check to 
understand what's going on.


Repository:
  rL LLVM

https://reviews.llvm.org/D32439



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


[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-06-26 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment.

In https://reviews.llvm.org/D32439#790302, @Serge_Preis wrote:

> Thank you for clarifications, would you explain how may I reproduce failure 
> locally or remotely. I'd like to see c-index-test output before clang-check 
> to understand what's going on.


Just change LLVM_DEFAULT_TARGET_TRIPLE, build and run check-clang. You may use 
ccmake for it.
Or, modify RUN line locally like

  RUN: c-index-test (snip) %s -Xclang -triple -Xclang x86_64-pc-win32

Don't forget restore LLVM_DEFAULT_TARGET_TRIPLE to the default value (usually 
it's same as HOST_TRIPLE) later.


Repository:
  rL LLVM

https://reviews.llvm.org/D32439



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


[PATCH] D34329: [GSoC] Clang AST diffing

2017-06-26 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added inline comments.



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:730
+
+Mapping TreeComparator::matchTopDown() const {
+  PriorityList L1(T1);

johannes wrote:
> arphaman wrote:
> > Johannes, it seems to me that your implementation of the top-down portion 
> > of the GumTree algorithm doesn't use the `an empty list A of candidate 
> > mappings` that's described in the paper (and that you have in the Python 
> > prototype). Is that correct or am I missing something?
> Yes, initially I implemented it as it is described in the paper, but then I 
> realized that the list of candidate mappings will always stay empty, because 
> the condition in the top-down algorithm in the paper on line 14 will never be 
> true. Maybe I am mistaken here, but if `t1` and `t2` are isomorphic, then 
> none of the descendants of `t1` will be isomorphic to `t2`. I mean, the 
> height of isomorphic trees must be equal, and the descendant does not have 
> the same height. So to me this looks like an error in the paper, I probably 
> should have communicated this.
> What I did instead is, I had a look at the reference implementation, and what 
> they do instead of using a list of candidate mappings is to just use a data 
> structure for the mapping that allows multiple matches for each node.
> After matching collecting all candidates this way, they extract the 
> unambiguous matches and then sort the ambiguous matches by their parents' 
> similarity.
> [[ 
> https://github.com/GumTreeDiff/gumtree/blob/develop/core/src/main/java/com/github/gumtreediff/matchers/heuristic/gt/AbstractSubtreeMatcher.java
>  | AbstractSubtreeMatcher.java ]]
> [[ 
> https://github.com/GumTreeDiff/gumtree/blob/develop/core/src/main/java/com/github/gumtreediff/matchers/heuristic/gt/GreedySubtreeMatcher.java
>  | GreedySubtreeMatcher.java ]]
> This seems to be a good solution,  I plan to implement that in the future.
My bad, I misread the algorithm in the paper, of course the entire tree is 
searched for other isomorphic subtrees.
I will still stick to the way it is implemented in gumtree, it should be more 
efficient.


https://reviews.llvm.org/D34329



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


[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D34206#783673, @hokein wrote:

> In https://reviews.llvm.org/D34206#780455, @Eugene.Zelenko wrote:
>
> > It'll be good idea to run modernize-make-unique on LLVM/Clang/etc for 
> > llvm::make_unique.
>
>
> +1. See https://reviews.llvm.org/D34334, https://reviews.llvm.org/D34333. And 
> found a few bugs in the check, will work on fixes on them.


Ping me once you're done fixing the bugs.


https://reviews.llvm.org/D34206



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


Re: [clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well

2017-06-26 Thread Serge Pavlov via cfe-commits
2017-06-26 4:05 GMT+07:00 David Blaikie :

> Ah, I see now then.
>
> I have a symlink from the root of my source directory pointing to the
> compile_commands.json in my build directory.
>
> I have this so that the vim YouCompleteMe plugin (& any other clang tools)
> can find it, as they usually should, for using tools with the llvm/clang
> project...
>
> Sounds like this test is incompatible with using the tooling
> infrastructure in the llvm/clang project?
>
Any test that relies on compilation database search can fail in such case.
Maybe the root of the tools test could contain some special
compile_commands.json so that the search will always end up in definite
state?


>
> On Sun, Jun 25, 2017, 10:24 AM Serge Pavlov  wrote:
>
>> 2017-06-25 0:52 GMT+07:00 David Blaikie :
>>
>>>
>>>
>>> On Sat, Jun 24, 2017 at 10:08 AM Serge Pavlov 
>>> wrote:
>>>
 With CMAKE_EXPORT_COMPILE_COMMANDS the file compile_commands.json is
 created in the directory 
 /tools/clang/tools/extra/test/clang-tidy/Output,


>>>
>>> I'd be really surprised if this is the case - why would
>>> cmake/ninja/makefiles put the compile commands for the whole LLVM
>>> project/build in that somewhat random subdirectory?
>>>
>>
>> I was wrong, these json files were not created by cmake run but appear
>> during test run. The file created by cmake is in the build root.
>>
>>
>>>
>>>
 but the tests from /llvm/tools/clang/tools/extra/test/clang-tidy
 run in the directory /tools/clang/tools/extra/test/clang-tidy,
 which does not contain json files. So the test passes successfully. Ubuntu
 16.04, cmake 3.5.1.

>>>
>>> Ah, perhaps you found a compile_commands for one of the test cases, not
>>> the one generated by CMake. CMake 3.5.1 doesn't support
>>> CMAKE_EXPORT_COMPILE_COMMANDS.
>>>
>>> It was added in 3.5.2, according to the documentation: https://cmake.
>>> org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
>>>
>>>
>>
>> It was added in 2.8.5 according to documentation (
>> http://clang.llvm.org/docs/JSONCompilationDatabase.html#supported-systems),
>> at least the version 3.5.1 creates compilation databases.
>>
>> clang-tidy tries to create compilation database from source path, looking
>> for compile_commands.json in the directory where provided source file
>> resides and in all its parent directories. If source tree is in a
>> subdirectory of build tree, then compile_commands.json in the build
>> directory would be found and the test would fail. Is it your case?
>>
>>
 Thanks,
 --Serge

 2017-06-24 9:42 GMT+07:00 David Blaikie :

> Ping (+Manuel, perhaps he's got some ideas about this, given
> background in the tooling & compilation database work, or could point this
> to someone who does?)
>
>
> On Thu, Jun 15, 2017 at 10:40 AM David Blaikie 
> wrote:
>
>> https://sarcasm.github.io/notes/dev/compilation-database.html#cmake
>>
>> If you enable the CMAKE_EXPORT_COMPILE_COMMANDS option in cmake (&
>> have a sufficiently recent cmake), then CMake will generate a
>> compile_commands.json in the root of the build tree. The test finds this 
>> &
>> fails, instead of finding no compilation database & succeeding.
>>
>> (to use this, you can then symlink from the root of the source tree
>> to point to this in your build tree - this is how I get YCM to work for 
>> my
>> LLVM builds & could work for other clang tools as well)
>>
>> On Thu, Jun 15, 2017 at 7:51 AM Serge Pavlov 
>> wrote:
>>
>>> 2017-06-15 2:43 GMT+07:00 David Blaikie :
>>>


 On Wed, Jun 14, 2017, 8:17 AM Serge Pavlov 
 wrote:

> 2017-06-14 4:24 GMT+07:00 David Blaikie :
>
>> Ah, I find that the test passes if I remove the
>> compile_commands.json file from my build directory (I have Ninja 
>> configured
>> to generate a compile_commands.json file).
>>
>> Looks like what happens is it finds the compilation database and
>> fails hard when the database doesn't contain a compile command for 
>> the file
>> in question. If the database is not found, it falls back to some 
>> basic
>> command behavior, perhaps?
>>
>>
> You are right, constructor of `CommonOptionsParser` calls
> `autoDetectFromSource` or `autoDetectFromDirectory` prior to final
> construction of `FixedCompilationDatabase.
>
> Is there some way this test could be fixed to cope with this,
>> otherwise it seems to get in the way of people actually using clang 
>> tools
>> in their LLVM/Clang build environment?
>>
>>
> IIUC, presence of stale compilation database file in test
> directory could break many tests. I don't understand why only
> diagnostic.cpp fails, probably there is something wrong with 

[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D34091



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


[PATCH] D33440: clang-format: properly handle Q_UNUSED and QT_REQUIRE_VERSION

2017-06-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 103935.
Typz added a comment.

Complete refactor to make the processing much more generic


https://reviews.llvm.org/D33440

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/NamespaceEndCommentsFixer.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -53,6 +53,7 @@
 "  int i;\n"
 "  int j;\n"
 "}"));
+
   EXPECT_EQ("namespace {\n"
 "  int i;\n"
 "  int j;\n"
@@ -249,6 +250,85 @@
 "// unrelated"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, AddsMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+
+  EXPECT_EQ("TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("inline TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("inline TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A)",
+fixNamespaceEndComments("TESTSUITE(::A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A::B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(::A::B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(A, B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A, B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(\"Test1\") {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(\"Test1\")",
+fixNamespaceEndComments("TESTSUITE(\"Test1\") {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+}
+
 TEST_F(NamespaceEndCommentsFixerTest, AddsNewlineIfNeeded) {
   EXPECT_EQ("namespace A {\n"
 "  int i;\n"
@@ -381,6 +461,54 @@
 "}; /* unnamed namespace */"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, KeepsValidMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"} // end anonymous TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"  int i;\n"
+"} // end anonymous TESTSUITE()",
+Style));
+  EXPECT_EQ("TESTS

[PATCH] D33440: clang-format: better handle statement and namespace macros

2017-06-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 103937.
Typz added a comment.

Fix typo


https://reviews.llvm.org/D33440

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/NamespaceEndCommentsFixer.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -53,6 +53,7 @@
 "  int i;\n"
 "  int j;\n"
 "}"));
+
   EXPECT_EQ("namespace {\n"
 "  int i;\n"
 "  int j;\n"
@@ -249,6 +250,85 @@
 "// unrelated"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, AddsMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+
+  EXPECT_EQ("TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("inline TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("inline TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A)",
+fixNamespaceEndComments("TESTSUITE(::A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A::B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(::A::B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(A, B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A, B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(\"Test1\") {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(\"Test1\")",
+fixNamespaceEndComments("TESTSUITE(\"Test1\") {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+}
+
 TEST_F(NamespaceEndCommentsFixerTest, AddsNewlineIfNeeded) {
   EXPECT_EQ("namespace A {\n"
 "  int i;\n"
@@ -381,6 +461,54 @@
 "}; /* unnamed namespace */"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, KeepsValidMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"} // end anonymous TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"  int i;\n"
+"} // end anonymous TESTSUITE()",
+Style));
+  EXPECT_EQ("TESTSUITE(A) {\n"
+"  int i;\n"
+  

[PATCH] D32638: [x86][inline-asm][clang]Amend size directive deduction mechanism of unsized memory operands

2017-06-26 Thread coby via Phabricator via cfe-commits
coby abandoned this revision.
coby added a comment.

superseded by https://reviews.llvm.org/rL302179


Repository:
  rL LLVM

https://reviews.llvm.org/D32638



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


[PATCH] D34395: clang-format: add options to merge empty record body

2017-06-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 103939.
Typz added a comment.

Merge `SplitEmptyClass/Struct/Union` options into a single `SplitEmptyRecord` 
option.


https://reviews.llvm.org/D34395

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6509,12 +6509,12 @@
MergeInlineOnly);
 }
 
-TEST_F(FormatTest, SplitEmptyFunctionBody) {
+TEST_F(FormatTest, SplitEmptyFunction) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterFunction = true;
-  Style.BraceWrapping.SplitEmptyFunctionBody = false;
+  Style.BraceWrapping.SplitEmptyFunction = false;
   Style.ColumnLimit = 40;
 
   verifyFormat("int f()\n"
@@ -6577,6 +6577,178 @@
Style);
 }
 
+TEST_F(FormatTest, SplitEmptyClass) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterClass = true;
+  Style.BraceWrapping.SplitEmptyRecord = false;
+
+  verifyFormat("class Foo\n"
+   "{};",
+   Style);
+  verifyFormat("/* something */ class Foo\n"
+   "{};",
+   Style);
+  verifyFormat("template  class Foo\n"
+   "{};",
+   Style);
+  verifyFormat("class Foo\n"
+   "{\n"
+   "  Foo();\n"
+   "};",
+   Style);
+  verifyFormat("typedef class Foo\n"
+   "{\n"
+   "} Foo_t;",
+   Style);
+}
+
+TEST_F(FormatTest, SplitEmptyStruct) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterStruct = true;
+  Style.BraceWrapping.SplitEmptyRecord = false;
+
+  verifyFormat("struct Foo\n"
+   "{};",
+   Style);
+  verifyFormat("/* something */ struct Foo\n"
+   "{};",
+   Style);
+  verifyFormat("template  struct Foo\n"
+   "{};",
+   Style);
+  verifyFormat("struct Foo\n"
+   "{\n"
+   "  Foo();\n"
+   "};",
+   Style);
+  verifyFormat("typedef struct Foo\n"
+   "{\n"
+   "} Foo_t;",
+   Style);
+  //typedef struct Bar {} Bar_t;
+}
+
+TEST_F(FormatTest, SplitEmptyUnion) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterUnion = true;
+  Style.BraceWrapping.SplitEmptyRecord = false;
+
+  verifyFormat("union Foo\n"
+   "{};",
+   Style);
+  verifyFormat("/* something */ union Foo\n"
+   "{};",
+   Style);
+  verifyFormat("union Foo\n"
+   "{\n"
+   "  A,\n"
+   "};",
+   Style);
+  verifyFormat("typedef union Foo\n"
+   "{\n"
+   "} Foo_t;",
+   Style);
+}
+
+TEST_F(FormatTest, SplitEmptyNamespace) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterNamespace = true;
+  Style.BraceWrapping.SplitEmptyNamespace = false;
+
+  verifyFormat("namespace Foo\n"
+   "{};",
+   Style);
+  verifyFormat("/* something */ namespace Foo\n"
+   "{};",
+   Style);
+  verifyFormat("inline namespace Foo\n"
+   "{};",
+   Style);
+  verifyFormat("namespace Foo\n"
+   "{\n"
+   "void Bar();\n"
+   "};",
+   Style);
+}
+
+TEST_F(FormatTest, NeverMergeShortRecords) {
+  FormatStyle Style = getLLVMStyle();
+
+  verifyFormat("class Foo {\n"
+   "  Foo();\n"
+   "};",
+   Style);
+  verifyFormat("typedef class Foo {\n"
+   "  Foo();\n"
+   "} Foo_t;",
+   Style);
+  verifyFormat("struct Foo {\n"
+   "  Foo();\n"
+   "};",
+   Style);
+  verifyFormat("typedef struct Foo {\n"
+   "  Foo();\n"
+   "} Foo_t;",
+   Style);
+  verifyFormat("union Foo {\n"
+   "  A,\n"
+   "};",
+   Style);
+  verifyFormat("typedef union Foo {\n"
+   "  A,\n"
+   "} Foo_t;",
+   Style);
+  verifyFormat("namespace Foo {\n"
+   "void Bar();\n"
+   "};",
+   Style);
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterClass = true;
+  Style.BraceWrapping.AfterStruct = true;
+  Style.BraceWrapping.AfterUnion = true;
+  Style.BraceWrapping.AfterNamespace = true;
+  verifyFormat("class F

[PATCH] D34395: clang-format: add options to merge empty record body

2017-06-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D34395



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


[PATCH] D34299: [ubsan] Improve diagnostics for return value checks (clang)

2017-06-26 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment.

In https://reviews.llvm.org/D34299#788427, @vsk wrote:

> I hope I've cleared this up, but: we need to store the source location 
> constant _somewhere_, before we emit the return value check. That's because 
> we can't infer which return location to use at compile time.


Yes, sorry about that. I was thinking about the code the wrong way around. I'm 
ok with this patch and how it got in. Sorry for the delay in replying.


Repository:
  rL LLVM

https://reviews.llvm.org/D34299



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


[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-06-26 Thread Serge Preis via Phabricator via cfe-commits
Serge_Preis added a comment.

In https://reviews.llvm.org/D32439#790323, @chapuni wrote:

> Just change LLVM_DEFAULT_TARGET_TRIPLE, build and run check-clang. You may 
> use ccmake for it.
>  Or, modify RUN line locally like
>
>   RUN: c-index-test (snip) %s -Xclang -triple -Xclang x86_64-pc-win32
>   
>
> Don't forget restore LLVM_DEFAULT_TARGET_TRIPLE to the default value (usually 
> it's same as HOST_TRIPLE) later.


Thank you for your help. Unfortunately I still cannot reproduce the issue:  
with local correction test passes and all attempts to configure cmake lead to 
missing bits/c++config.h file.


Repository:
  rL LLVM

https://reviews.llvm.org/D32439



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


[PATCH] D33470: [clang-tidy] Add misc-default-numerics

2017-06-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33470#789791, @Prazek wrote:

> In https://reviews.llvm.org/D33470#764846, @aaron.ballman wrote:
>
> > Once you fix the typo in the check, can you run it over some large C++ code 
> > bases to see if it finds any results?
>
>
> I tried it on LLVM code base (after fixing bug with the numeric_limits name) 
> and it didn't find anything suspisious.
>  Unfortunatelly I don't have enough time to try it on different codebases, 
> but I am weiling to fix any bug with this check if it would happen in the 
> future.
>  The release 5.0 is near, so I would like to push it upstream. Does it sound 
> good to you?


My concern is: does this find any actual issues in real world code? This seems 
like such a highly specific check -- not many people use numeric_limits in the 
first place, let alone on non-builtin types, so does it justify running this 
check when someone batch-includes all of the misc checks?

I don't think this check is going to trigger a ton of false positives. I am 
wondering more the opposite: will this check ever trigger on anything other 
than compiler test cases?




Comment at: clang-tidy/misc/DefaultNumericsCheck.h:21
+/// unspecialized types. It is dangerous because it returns T(), which rarely
+/// might be minimum or maximum for this type.
+///

the minimum or maximum (add the "the").



Comment at: test/clang-tidy/misc-default-numerics.cpp:32
+}
+
+template 

Can you add a test case where numeric_limits has been properly specialized for 
the type and the type is not a builtin?


https://reviews.llvm.org/D33470



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


[PATCH] D33406: PR28129 expand vector oparation to an IR constant.

2017-06-26 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon closed this revision.
RKSimon added a comment.

https://reviews.llvm.org/rL305551


https://reviews.llvm.org/D33406



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-06-26 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a reviewer: rsmith.
klimek added a comment.

Richard (added as reviewer) usually owns decisions around clang itself. Writing 
an email to cfe-dev with the numbers and wait for whether others have concerns 
would probably also be good.


https://reviews.llvm.org/D30691



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


[PATCH] D34506: Relax an assert in the comparison of source locations

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

In https://reviews.llvm.org/D34506#787971, @joerg wrote:

> I don't think it is a good idea to make this function non-transitive.


I think this is a good point. However, I am not entirely sure that it is 
transitive right now. Check the "Both are in built-in buffers, but from 
different files" case, which is similar to the separate TU case. 
But I will look if I can come up with an alternative solution.


Repository:
  rL LLVM

https://reviews.llvm.org/D34506



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


[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D34206#790406, @alexfh wrote:

> In https://reviews.llvm.org/D34206#783673, @hokein wrote:
>
> > In https://reviews.llvm.org/D34206#780455, @Eugene.Zelenko wrote:
> >
> > > It'll be good idea to run modernize-make-unique on LLVM/Clang/etc for 
> > > llvm::make_unique.
> >
> >
> > +1. See https://reviews.llvm.org/D34334, https://reviews.llvm.org/D34333. 
> > And found a few bugs in the check, will work on fixes on them.
>
>
> Ping me once you're done fixing the bugs.


I have a fix patch under review: https://reviews.llvm.org/D34286, and the other 
will come afterwards.

I think it is fine to check in this patch before these two bugs are fixed.


https://reviews.llvm.org/D34206



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


r306291 - Improve const-correctness.

2017-06-26 Thread Axel Naumann via cfe-commits
Author: axel
Date: Mon Jun 26 08:06:40 2017
New Revision: 306291

URL: http://llvm.org/viewvc/llvm-project?rev=306291&view=rev
Log:
Improve const-correctness.

Modified:
cfe/trunk/include/clang/Parse/Parser.h

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=306291&r1=306290&r2=306291&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Jun 26 08:06:40 2017
@@ -604,7 +604,7 @@ public:
   }
 
   /// getTypeAnnotation - Read a parsed type out of an annotation token.
-  static ParsedType getTypeAnnotation(Token &Tok) {
+  static ParsedType getTypeAnnotation(const Token &Tok) {
 return ParsedType::getFromOpaquePtr(Tok.getAnnotationValue());
   }
 
@@ -615,7 +615,7 @@ private:
 
   /// \brief Read an already-translated primary expression out of an annotation
   /// token.
-  static ExprResult getExprAnnotation(Token &Tok) {
+  static ExprResult getExprAnnotation(const Token &Tok) {
 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
   }
 


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


[PATCH] D34623: [clang-format] Add a test for associative map proto buffer fields

2017-06-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Can you create a more interesting test case where the map definition spans 
multiple lines? Possibly use qualified names for the field types.


https://reviews.llvm.org/D34623



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


[PATCH] D34580: [CodeGen][ObjC] Load indirect ARC arguments in prolog

2017-06-26 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




Comment at: test/CodeGenObjCXX/arc-indirect.mm:19
+// CHECK-DARWIN: define internal void @"\01-[C object:struct:]"(<{ %0*, i8*, 
i8*, %struct.S, [3 x i8] }>* inalloca)
+// CHECK: %obj = getelementptr inbounds <{ %0*, i8*, i8*, %struct.S, [3 x i8] 
}>, <{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* %0, i32 0, i32 2

You should CHECK for the load and appropriate call here. As written, this test 
would pass if you instead had changed the code to insert a null check.


https://reviews.llvm.org/D34580



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


[PATCH] D34623: [clang-format] Add a test for associative map proto buffer fields

2017-06-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 103962.
krasimir added a comment.

- Add map declarations spanning multiple lines


https://reviews.llvm.org/D34623

Files:
  unittests/Format/FormatTestProto.cpp


Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -61,6 +61,29 @@
"  really.really.long.qualified.type.aaa.aaa.\n"
"  another_field = 2;\n"
"}");
+  verifyFormat("message SomeMessage {\n"
+   "  map projects = 1;\n"
+   "  optional map size_projects = 2;\n"
+   "  map\n"
+   "  projects = 3;\n"
+   "  map projects = 4;\n"
+   "  map\n"
+   "  projects = 5;\n"
+   "  map\n"
+   "  longlonglonglonglonglonglonglonglonglongonglon = 6;\n"
+   "  
map projects = 7;\n"
+   "  
map\n"
+   "  releleallyreallyreallyreallyreallyreallyreallylongnam 
=\n"
+   "  8;\n"
+   "  map projects = 9;\n"
+   "}");
 }
 
 TEST_F(FormatTestProto, KeywordsInOtherLanguages) {


Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -61,6 +61,29 @@
"  really.really.long.qualified.type.aaa.aaa.\n"
"  another_field = 2;\n"
"}");
+  verifyFormat("message SomeMessage {\n"
+   "  map projects = 1;\n"
+   "  optional map size_projects = 2;\n"
+   "  map\n"
+   "  projects = 3;\n"
+   "  map projects = 4;\n"
+   "  map\n"
+   "  projects = 5;\n"
+   "  map\n"
+   "  longlonglonglonglonglonglonglonglonglongonglon = 6;\n"
+   "  map projects = 7;\n"
+   "  map\n"
+   "  releleallyreallyreallyreallyreallyreallyreallylongnam =\n"
+   "  8;\n"
+   "  map projects = 9;\n"
+   "}");
 }
 
 TEST_F(FormatTestProto, KeywordsInOtherLanguages) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-06-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: test/CodeGen/x86-ms-inline-asm-enum_feature.cpp:12
+  const int a = 0;
+  // CHECK-NOT: mov eax, [$$0]
+  __asm mov eax, [a]

rnk wrote:
> mharoush wrote:
> > rnk wrote:
> > > Use CHECK-LABEL, CHECK, and CHECK-SAME the way that the existing 
> > > ms-inline-asm.c tests do so that this test is easier to debug when it 
> > > fails.
> > This test case was just meant verify that other Integer constants are not 
> > folded since we get a different behavior for statements such as mov eax, 
> > [a]. 
> > #---
> > In this example X86AsmParser regards the address of the variable 'a' and 
> > not its value i.e. we end up with the value of 'a' in eax (loaded from the 
> > stack) and not with the value pointed by the const int value of 'a' as its 
> > address.
> > ---#
> > 
> > I can clarify the intention in a comment or completely remove the test case 
> > since this isn't really required here.
> The test case is fine and the intention is clear, I am just suggesting that 
> you use more FileCheck features (CHECK-LABEL and CHECK-SAME) to make the test 
> easier to debug when it fails in the future.
You didn't implement this suggestion, please take a look at ms-inline-asm.c. It 
has tests that look like this:
```
void t13() {
  char i = 1;
  short j = 2;
  __asm movzx eax, i
  __asm movzx eax, j
// CHECK-LABEL: define void @t13()
// CHECK: call void asm sideeffect inteldialect
// CHECK-SAME: movzx eax, byte ptr $0
// CHECK-SAME: movzx eax, word ptr $1
// CHECK-SAME: "*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i8* %{{.*}}i, i16* 
%{{.*}}j)
}
```

This is much less error-prone and easier to debug when it fails.


Repository:
  rL LLVM

https://reviews.llvm.org/D33277



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


[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations

2017-06-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 103958.
erik.pilkington added a comment.

Make the diagnostic reference the context declaration instead of the offending 
decl if no enclosing decl is found, fixing the diagnostic bug @arphaman pointed 
out.


https://reviews.llvm.org/D33816

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DelayedDiagnostic.h
  include/clang/Sema/Sema.h
  lib/Sema/DelayedDiagnostic.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/attr-availability.c
  test/Sema/attr-deprecated.c
  test/Sema/attr-unavailable-message.c
  test/SemaCXX/attr-deprecated.cpp
  test/SemaObjC/attr-availability.m
  test/SemaObjC/unguarded-availability-new.m
  test/SemaObjC/unguarded-availability.m

Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -5,6 +5,8 @@
 #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
 #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
 
+typedef int AVAILABLE_10_12 new_int; // expected-note + {{marked partial here}}
+
 int func_10_11() AVAILABLE_10_11; // expected-note 4 {{'func_10_11' has been explicitly marked partial here}}
 
 #ifdef OBJCPP
@@ -70,9 +72,9 @@
 }
 
 __attribute__((objc_root_class))
-AVAILABLE_10_11 @interface Class_10_11 {
+AVAILABLE_10_11 @interface Class_10_11 { // expected-note{{annotate 'Class_10_11' with an availability attribute to silence}}
   int_10_11 foo;
-  int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
+  int_10_12 bar; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}}
 }
 - (void)method1;
 - (void)method2;
@@ -125,7 +127,7 @@
   };
 }
 
-void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
+void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{annotate 'test_params' with an availability attribute to silence}}
 
 void test_params2(int_10_12 x) AVAILABLE_10_12; // no warn
 
@@ -234,3 +236,23 @@
 }
 
 #endif
+
+struct InStruct { // expected-note{{annotate 'InStruct' with an availability attribute to silence}}
+  new_int mem; // expected-warning{{'new_int' is partial}}
+
+  struct { new_int mem; } anon; // expected-warning{{'new_int' is partial}} expected-note{{annotate '' with an availability attribute}}
+};
+
+@interface InInterface
+-(new_int)meth; // expected-warning{{'new_int' is partial}} expected-note{{annotate 'meth' with an availability attribute}}
+@end
+
+@interface Proper // expected-note{{annotate 'Proper' with an availability attribute}}
+@property (class) new_int x; // expected-warning{{'new_int' is partial}}
+@end
+
+void with_local_struct() {
+  struct local { // expected-note{{annotate 'local' with an availability attribute}}
+new_int x; // expected-warning{{'new_int' is partial}}
+  };
+}
Index: test/SemaObjC/unguarded-availability-new.m
===
--- test/SemaObjC/unguarded-availability-new.m
+++ test/SemaObjC/unguarded-availability-new.m
@@ -96,16 +96,16 @@
 FUNC_AVAILABLE new_int x;
 #ifndef NO_WARNING
 #ifdef MAC
-  // expected-warning@-3 {{'new_int' is partial: introduced in macOS 10.14}} expected-note@-3 {{explicitly redeclare 'new_int' to silence this warning}}
+  // expected-warning@-3 {{'new_int' is partial: introduced in macOS 10.14}} expected-note@-3 {{annotate 'x' with an availability attribute to silence}}
 #endif
 #ifdef IOS
-  // expected-warning@-6 {{'new_int' is partial: introduced in iOS 12}} expected-note@-6 {{explicitly redeclare 'new_int' to silence this warning}}
+  // expected-warning@-6 {{'new_int' is partial: introduced in iOS 12}} expected-note@-6 {{annotate 'x' with an availability attribute to silence}}
 #endif
 #ifdef TVOS
-  // expected-warning@-9 {{'new_int' is partial: introduced in tvOS 13}} expected-note@-9 {{explicitly redeclare 'new_int' to silence this warning}}
+  // expected-warning@-9 {{'new_int' is partial: introduced in tvOS 13}} expected-note@-9 {{annotate 'x' with an availability attribute to silence}}
 #endif
 #ifdef WATCHOS
-  // expected-warning@-12 {{'new_int' is partial: introduced in watchOS 5}} expected-note@-12 {{explicitly redeclare 'new_int' to silence this warning}}
+  // expected-warning@-12 {{'new_int' is partial: introduced in watchOS 5}} expected-note@-12 {{annotate 'x' with an availability attribute to silence}}
 #endif
 #endif
 
Index: test/SemaObjC/attr-availability.m
===
--- test/SemaObjC/attr-availability.m
+++ test/SemaObjC/attr-availability.m
@@ -13,7 +13,7 @@
 @interface A 
 - (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))

[PATCH] D34286: [clang-tidy] Fix type names in modernize-use-unique/shared_ptr checks.

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

LG




Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:23
+ const LangOptions &Lang) {
+  return clang::Lexer::getSourceText(
+  clang::CharSourceRange::getTokenRange(

s/clang:://



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:24
+  return clang::Lexer::getSourceText(
+  clang::CharSourceRange::getTokenRange(
+  
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),

ditto


https://reviews.llvm.org/D34286



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


r306297 - [inline asm][gcc-compatiblity] "=i" output constraint support

2017-06-26 Thread Marina Yatsina via cfe-commits
Author: myatsina
Date: Mon Jun 26 08:55:51 2017
New Revision: 306297

URL: http://llvm.org/viewvc/llvm-project?rev=306297&view=rev
Log:
[inline asm][gcc-compatiblity] "=i" output constraint support

Ignore ‘i’,’n’,’E’,’F’ as output constraints in inline assembly (gcc 
compatibility)

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


Modified:
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/test/Sema/asm.c

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=306297&r1=306296&r2=306297&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Mon Jun 26 08:55:51 2017
@@ -507,6 +507,11 @@ bool TargetInfo::validateOutputConstrain
 case '?': // Disparage slightly code.
 case '!': // Disparage severely.
 case '*': // Ignore for choosing register preferences.
+case 'i': // Ignore i,n,E,F as output constraints (match from the other
+  // chars)
+case 'n':
+case 'E':
+case 'F':
   break;  // Pass them.
 }
 

Modified: cfe/trunk/test/Sema/asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=306297&r1=306296&r2=306297&view=diff
==
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Mon Jun 26 08:55:51 2017
@@ -160,6 +160,41 @@ double test15() {
   return ret;
 }
 
+void iOutputConstraint(int x){
+  __asm ("nop" : "=ir" (x) : :); // no-error
+  __asm ("nop" : "=ri" (x) : :); // no-error
+  __asm ("nop" : "=ig" (x) : :); // no-error
+  __asm ("nop" : "=im" (x) : :); // no-error
+  __asm ("nop" : "=imr" (x) : :); // no-error
+  __asm ("nop" : "=i" (x) : :); // expected-error{{invalid output constraint 
'=i' in asm}}
+  __asm ("nop" : "+i" (x) : :); // expected-error{{invalid output constraint 
'+i' in asm}}
+  __asm ("nop" : "=ii" (x) : :); // expected-error{{invalid output constraint 
'=ii' in asm}}
+  __asm ("nop" : "=nr" (x) : :); // no-error
+  __asm ("nop" : "=rn" (x) : :); // no-error
+  __asm ("nop" : "=ng" (x) : :); // no-error
+  __asm ("nop" : "=nm" (x) : :); // no-error
+  __asm ("nop" : "=nmr" (x) : :); // no-error
+  __asm ("nop" : "=n" (x) : :); // expected-error{{invalid output constraint 
'=n' in asm}}
+  __asm ("nop" : "+n" (x) : :); // expected-error{{invalid output constraint 
'+n' in asm}}
+  __asm ("nop" : "=nn" (x) : :); // expected-error{{invalid output constraint 
'=nn' in asm}}
+  __asm ("nop" : "=Fr" (x) : :); // no-error
+  __asm ("nop" : "=rF" (x) : :); // no-error
+  __asm ("nop" : "=Fg" (x) : :); // no-error
+  __asm ("nop" : "=Fm" (x) : :); // no-error
+  __asm ("nop" : "=Fmr" (x) : :); // no-error
+  __asm ("nop" : "=F" (x) : :); // expected-error{{invalid output constraint 
'=F' in asm}}
+  __asm ("nop" : "+F" (x) : :); // expected-error{{invalid output constraint 
'+F' in asm}}
+  __asm ("nop" : "=FF" (x) : :); // expected-error{{invalid output constraint 
'=FF' in asm}}
+  __asm ("nop" : "=Er" (x) : :); // no-error
+  __asm ("nop" : "=rE" (x) : :); // no-error
+  __asm ("nop" : "=Eg" (x) : :); // no-error
+  __asm ("nop" : "=Em" (x) : :); // no-error
+  __asm ("nop" : "=Emr" (x) : :); // no-error
+  __asm ("nop" : "=E" (x) : :); // expected-error{{invalid output constraint 
'=E' in asm}}
+  __asm ("nop" : "+E" (x) : :); // expected-error{{invalid output constraint 
'+E' in asm}}
+  __asm ("nop" : "=EE" (x) : :); // expected-error{{invalid output constraint 
'=EE' in asm}}
+}
+
 // PR19837
 struct foo {
   int a;


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


[PATCH] D31383: [inline asm] "=i" output constraint support - gcc compatiblity

2017-06-26 Thread Marina Yatsina via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306297: [inline asm][gcc-compatiblity] "=i" output 
constraint support (authored by myatsina).

Changed prior to commit:
  https://reviews.llvm.org/D31383?vs=97602&id=103967#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31383

Files:
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/test/Sema/asm.c


Index: cfe/trunk/test/Sema/asm.c
===
--- cfe/trunk/test/Sema/asm.c
+++ cfe/trunk/test/Sema/asm.c
@@ -160,6 +160,41 @@
   return ret;
 }
 
+void iOutputConstraint(int x){
+  __asm ("nop" : "=ir" (x) : :); // no-error
+  __asm ("nop" : "=ri" (x) : :); // no-error
+  __asm ("nop" : "=ig" (x) : :); // no-error
+  __asm ("nop" : "=im" (x) : :); // no-error
+  __asm ("nop" : "=imr" (x) : :); // no-error
+  __asm ("nop" : "=i" (x) : :); // expected-error{{invalid output constraint 
'=i' in asm}}
+  __asm ("nop" : "+i" (x) : :); // expected-error{{invalid output constraint 
'+i' in asm}}
+  __asm ("nop" : "=ii" (x) : :); // expected-error{{invalid output constraint 
'=ii' in asm}}
+  __asm ("nop" : "=nr" (x) : :); // no-error
+  __asm ("nop" : "=rn" (x) : :); // no-error
+  __asm ("nop" : "=ng" (x) : :); // no-error
+  __asm ("nop" : "=nm" (x) : :); // no-error
+  __asm ("nop" : "=nmr" (x) : :); // no-error
+  __asm ("nop" : "=n" (x) : :); // expected-error{{invalid output constraint 
'=n' in asm}}
+  __asm ("nop" : "+n" (x) : :); // expected-error{{invalid output constraint 
'+n' in asm}}
+  __asm ("nop" : "=nn" (x) : :); // expected-error{{invalid output constraint 
'=nn' in asm}}
+  __asm ("nop" : "=Fr" (x) : :); // no-error
+  __asm ("nop" : "=rF" (x) : :); // no-error
+  __asm ("nop" : "=Fg" (x) : :); // no-error
+  __asm ("nop" : "=Fm" (x) : :); // no-error
+  __asm ("nop" : "=Fmr" (x) : :); // no-error
+  __asm ("nop" : "=F" (x) : :); // expected-error{{invalid output constraint 
'=F' in asm}}
+  __asm ("nop" : "+F" (x) : :); // expected-error{{invalid output constraint 
'+F' in asm}}
+  __asm ("nop" : "=FF" (x) : :); // expected-error{{invalid output constraint 
'=FF' in asm}}
+  __asm ("nop" : "=Er" (x) : :); // no-error
+  __asm ("nop" : "=rE" (x) : :); // no-error
+  __asm ("nop" : "=Eg" (x) : :); // no-error
+  __asm ("nop" : "=Em" (x) : :); // no-error
+  __asm ("nop" : "=Emr" (x) : :); // no-error
+  __asm ("nop" : "=E" (x) : :); // expected-error{{invalid output constraint 
'=E' in asm}}
+  __asm ("nop" : "+E" (x) : :); // expected-error{{invalid output constraint 
'+E' in asm}}
+  __asm ("nop" : "=EE" (x) : :); // expected-error{{invalid output constraint 
'=EE' in asm}}
+}
+
 // PR19837
 struct foo {
   int a;
Index: cfe/trunk/lib/Basic/TargetInfo.cpp
===
--- cfe/trunk/lib/Basic/TargetInfo.cpp
+++ cfe/trunk/lib/Basic/TargetInfo.cpp
@@ -507,6 +507,11 @@
 case '?': // Disparage slightly code.
 case '!': // Disparage severely.
 case '*': // Ignore for choosing register preferences.
+case 'i': // Ignore i,n,E,F as output constraints (match from the other
+  // chars)
+case 'n':
+case 'E':
+case 'F':
   break;  // Pass them.
 }
 


Index: cfe/trunk/test/Sema/asm.c
===
--- cfe/trunk/test/Sema/asm.c
+++ cfe/trunk/test/Sema/asm.c
@@ -160,6 +160,41 @@
   return ret;
 }
 
+void iOutputConstraint(int x){
+  __asm ("nop" : "=ir" (x) : :); // no-error
+  __asm ("nop" : "=ri" (x) : :); // no-error
+  __asm ("nop" : "=ig" (x) : :); // no-error
+  __asm ("nop" : "=im" (x) : :); // no-error
+  __asm ("nop" : "=imr" (x) : :); // no-error
+  __asm ("nop" : "=i" (x) : :); // expected-error{{invalid output constraint '=i' in asm}}
+  __asm ("nop" : "+i" (x) : :); // expected-error{{invalid output constraint '+i' in asm}}
+  __asm ("nop" : "=ii" (x) : :); // expected-error{{invalid output constraint '=ii' in asm}}
+  __asm ("nop" : "=nr" (x) : :); // no-error
+  __asm ("nop" : "=rn" (x) : :); // no-error
+  __asm ("nop" : "=ng" (x) : :); // no-error
+  __asm ("nop" : "=nm" (x) : :); // no-error
+  __asm ("nop" : "=nmr" (x) : :); // no-error
+  __asm ("nop" : "=n" (x) : :); // expected-error{{invalid output constraint '=n' in asm}}
+  __asm ("nop" : "+n" (x) : :); // expected-error{{invalid output constraint '+n' in asm}}
+  __asm ("nop" : "=nn" (x) : :); // expected-error{{invalid output constraint '=nn' in asm}}
+  __asm ("nop" : "=Fr" (x) : :); // no-error
+  __asm ("nop" : "=rF" (x) : :); // no-error
+  __asm ("nop" : "=Fg" (x) : :); // no-error
+  __asm ("nop" : "=Fm" (x) : :); // no-error
+  __asm ("nop" : "=Fmr" (x) : :); // no-error
+  __asm ("nop" : "=F" (x) : :); // expected-error{{invalid output constraint '=F' in asm}}
+  __asm ("nop" : "+F" (x) : :); // expected-error{{invalid output constraint '+F' in asm}}
+  __asm ("nop" : "=FF" (x) : :); // expected-error{{invalid output co

[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations

2017-06-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/SemaObjC/unguarded-availability.m:243
+
+  struct { new_int mem; } anon; // expected-warning{{'new_int' is partial}} 
expected-note{{annotate '' with an availability attribute}}
+};

We should never have something like `annotate ''` presented to the user. This 
should be worded like 'annotate enclosing struct ...' .


https://reviews.llvm.org/D33816



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


r306301 - [inline asm] dot operator while using imm generates wrong ir + asm - clang part

2017-06-26 Thread Marina Yatsina via cfe-commits
Author: myatsina
Date: Mon Jun 26 09:09:55 2017
New Revision: 306301

URL: http://llvm.org/viewvc/llvm-project?rev=306301&view=rev
Log:
[inline asm] dot operator while using imm generates wrong ir + asm - clang part

Inline asm dot operator while using imm generates wrong ir and asm
This is the test for the llvm changes committed in revision 306300

This also fixes bugzilla 32987:
https://bugs.llvm.org//show_bug.cgi?id=32987

The llvm part of the review that contains the test can be found here:
https://reviews.llvm.org/D33039

commit on behald of zizhar

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


Modified:
cfe/trunk/test/CodeGen/ms-inline-asm.c

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=306301&r1=306300&r2=306301&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Jun 26 09:09:55 2017
@@ -627,6 +627,12 @@ void t43() {
 // CHECK: call void asm sideeffect inteldialect "mov eax, $0", 
"*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
+void dot_operator(){
+// CHECK-LABEL: define void @dot_operator
+   __asm { mov eax, 3[ebx]A.b}
+// CHECK: call void asm sideeffect inteldialect "mov eax, $$3[ebx].4", 
"~{eax},~{dirflag},~{fpsr},~{flags}"
+}
+
 void call_clobber() {
   __asm call t41
   // CHECK-LABEL: define void @call_clobber


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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-06-26 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno marked an inline comment as done.
bruno added inline comments.



Comment at: include/__config:234-235
+// a MS compatibility version is specified.
 #  ifndef __MINGW32__
-#define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+#ifdef _MSC_VER
+#  define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library

bcraig wrote:
> majnemer wrote:
> > compnerd wrote:
> > > smeenai wrote:
> > > > You can combine this into just
> > > > 
> > > > ```
> > > > #  if defined(_MSC_VER) && !defined(__MINGW32__)
> > > > ```
> > > > 
> > > > I don't know if `__MINGW32__` and `_MSC_VER` will ever be compiled 
> > > > simultaneously. (clang never defines `_MSC_VER` for its MinGW triples, 
> > > > for example.)
> > > What if MinGW is built with clang/c2 and MSVC extensions?  I think that 
> > > the two could be defined together.  What about cygwin and clang/c2?  I 
> > > guess we can ignore that since cygwin is not under active development.
> > > 
> > > I think this really goes back to my idea for an additional flag to 
> > > indicate the C library in use.  We can interpret it from the 
> > > canonicalized triple that LLVM/clang use.
> > clang/c2 is dead.
> At some point, I would like to see (or will need to introduce) a flag for 
> which Windows C library is in use (so I'm agreeing with / echoing @compnerd). 
>  What all options are there right now?  There's the Visual Studio C-runtime 
> (multiple versions), there's msvcrt (used by the OS and mingw), there's the 
> ancient crtdll that we shouldn't ever support, and there's the kernel C 
> runtime (I'm probably the only person that cares about that).
> 
> I will note that I don't like the name of the macro here.  _LIBCPP_MSVCRT 
> implies that msvcrt.dll is being used, when it isn't.  I don't think that 
> this patch needs to fix that naming though.
Any suggestion on a new name instead of `_LIBCPP_MSVCRT` for a future patch?


https://reviews.llvm.org/D34588



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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-06-26 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 103975.
bruno added a comment.

Update patch after reviewer suggestions!


https://reviews.llvm.org/D34588

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -229,8 +229,9 @@
 #  define _LIBCPP_SHORT_WCHAR   1
 // Both MinGW and native MSVC provide a "MSVC"-like enviroment
 #  define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only.
-#  ifndef __MINGW32__
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || 
defined(__arm__))


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -229,8 +229,9 @@
 #  define _LIBCPP_SHORT_WCHAR   1
 // Both MinGW and native MSVC provide a "MSVC"-like enviroment
 #  define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only.
-#  ifndef __MINGW32__
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34556: [libcxx] Annotate c++17 aligned new/delete operators with availability attribute

2017-06-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D34556



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


[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 103981.
compnerd added a comment.

__ptr64 mangling, add tests for 32-bit.


Repository:
  rL LLVM

https://reviews.llvm.org/D34523

Files:
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenCXX/msabi-blocks.cpp

Index: test/CodeGenCXX/msabi-blocks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/msabi-blocks.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -std=c++11 -fblocks -S -o - -emit-llvm %s | FileCheck %s -check-prefix CHECK-X32
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -std=c++11 -fblocks -S -o - -emit-llvm %s | FileCheck %s -check-prefix CHECK-X64
+
+extern int e(void);
+
+void (^b)() = ^{
+  static int i = 0;
+};
+
+// CHECK-X32-DAG: @"\01?i@?1??_block_invoke@@YAXPAU__block_literal@@@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke@@YAXPEAU__block_literal@@@Z@4HA" ={{.*}} global i32 0
+
+void f(void) {
+  static int i = 0;
+  ^{ static int i = e(); }();
+
+// CHECK-X32-DAG: @"\01?i@?1??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+
+  ^{ static int i = e(); }();
+
+// CHECK-X32-DAG: @"\01?i@?1??_block_invoke_2@@YAXPAU__block_literal_2@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke_2@@YAXPEAU__block_literal_2@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+
+  ^{ ^{ static int i = e(); }(); }();
+
+// CHECK-X32-DAG: @"\01?i@?1??_block_invoke_3@@YAXPAU__block_literal_3@@@Z?1??_block_invoke_4@@YAXPAU__block_literal_4@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke_3@@YAXPEAU__block_literal_3@@@Z?1??_block_invoke_4@@YAXPEAU__block_literal_4@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+}
+
+
+template 
+void g(void) {
+  ^{ static int i = e(); }();
+}
+
+template void g(void);
+
+// CHECK-X32-DAG: @"\01?i@?2??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?2???$g@D@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?2??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?2???$g@D@@YAXXZ@4HA" ={{.*}} global i32 0
+
+template void g(void);
+
+// CHECK-X32-DAG: @"\01?i@?2??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?2???$g@H@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?2??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?2???$g@H@@YAXXZ@4HA" ={{.*}} global i32 0
+
+inline void h(void) {
+  ^{ static int i = e(); }();
+}
+
+// CHECK-X32-DAG: @"\01?i@?2??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?2??h@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?2??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?2??h@@YAXXZ@4HA" ={{.*}} global i32 0
+
+struct s {
+  int i = ^{ static int i = e(); return ++i; }();
+
+// CHECK-X32-DAG: @"\01?i@?0??_block_invoke_1@s@@YAXPAU__block_literal_1@@@Z0@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@s@@YAXPEAU__block_literal_1@@@Z0@4HA" ={{.*}} global i32 0
+
+  int j = ^{ static int i = e(); return ++i; }();
+
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@s@@YAXPEAU__block_literal_1@@@Zj@@4HA" ={{.*}} global i32 0
+
+  void m(int i = ^{ static int i = e(); return ++i; }(),
+ int j = ^{ static int i = e(); return ++i; }()) {}
+
+// CHECK-X32-DAG: @"\01?i@?0??_block_invoke_1@@YAXPAU__block_literal_1@@@Zj@?0??m@s@@QAEXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X32-DAG: @"\01?i@?0??_block_invoke_1@@YAXPAU__block_literal_1@@@Z0?0??m@s@@QAEXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@@YAXPEAU__block_literal_1@@@Zj@?0??m@s@@QEAAXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z0?0??m@s@@QEAAXHH@Z@4HA" ={{.*}} global i32 0
+
+};
+
+struct t {
+  struct u {
+int i = ^{ static int i = e(); return ++i; }();
+
+// CHECK-X32-DAG: @"\01?i@?0??_block_invoke_1@u@t@@YAXPAU__block_literal_1@@@Z0@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@u@t@@YAXPEAU__block_literal_1@@@Z0@4HA" ={{.*}} global i32 0
+
+  };
+};
+
+void j(void) {
+  h();
+  struct s s;
+  s.m();
+  struct t::u t;
+}
+
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -966,16 +966,52 @@
 }
 
 if (const BlockDecl *BD = dyn_cast(DC)) {
-  DiagnosticsEngine &Diags = Context.getDiags();
-  unsigned DiagID =
-  Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle a local inside this block yet");
-  Diags.Report(BD->getLocation(), DiagID);
-
-  // FIXME: This is completely, utterly, wrong; see ItaniumMangle
-  // for how this should be done.
-  Out << "__block_invoke" << Context.getBlockId(BD, false);
-  Out << '@';
+  auto Discriminate = [](StringRef Name,
+   

[PATCH] D34633: [clang-tidy] Fix a bug in android-file-open-flag

2017-06-26 Thread Yan Wang via Phabricator via cfe-commits
yawanng created this revision.
yawanng added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere.

Handle a case when the function is passed as an argument of a function-like 
macro. Plus fix a format that was forgotten to commit last time.


Repository:
  rL LLVM

https://reviews.llvm.org/D34633

Files:
  clang-tidy/android/FileOpenFlagCheck.cpp
  test/clang-tidy/android-file-open-flag.cpp

Index: test/clang-tidy/android-file-open-flag.cpp
===
--- test/clang-tidy/android-file-open-flag.cpp
+++ test/clang-tidy/android-file-open-flag.cpp
@@ -4,6 +4,13 @@
 #define O_EXCL 2
 #define __O_CLOEXEC 3
 #define O_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
 
 extern "C" int open(const char *fn, int flags, ...);
 extern "C" int open64(const char *fn, int flags, ...);
@@ -13,47 +20,80 @@
   open("filename", O_RDWR);
   // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
   // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  TEMP_FAILURE_RETRY(open("filename", O_RDWR));
+  // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: 'open' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
   open("filename", O_RDWR | O_EXCL);
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'open' should use O_CLOEXEC where
   // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+  TEMP_FAILURE_RETRY(open("filename", O_RDWR | O_EXCL));
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: 'open' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
 }
 
 void b() {
   open64("filename", O_RDWR);
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
   // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  TEMP_FAILURE_RETRY(open64("filename", O_RDWR));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: 'open64' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
   open64("filename", O_RDWR | O_EXCL);
   // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'open64' should use O_CLOEXEC where
   // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+  TEMP_FAILURE_RETRY(open64("filename", O_RDWR | O_EXCL));
+  // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: 'open64' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
 }
 
 void c() {
   openat(0, "filename", O_RDWR);
   // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
   // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  TEMP_FAILURE_RETRY(openat(0, "filename", O_RDWR));
+  // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: 'openat' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
   openat(0, "filename", O_RDWR | O_EXCL);
   // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'openat' should use O_CLOEXEC where
   // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+  TEMP_FAILURE_RETRY(openat(0, "filename", O_RDWR | O_EXCL));
+  // CHECK-MESSAGES: :[[@LINE-1]]:59: warning: 'openat' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
 }
 
 void f() {
   open("filename", 3);
   // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
   // CHECK-FIXES: 3 | O_CLOEXEC
+  TEMP_FAILURE_RETRY(open("filename", 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'open' should use O_CLOEXEC where
+  // CHECK-FIXES: 3 | O_CLOEXEC
   open64("filename", 3);
   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
   // CHECK-FIXES: 3 | O_CLOEXEC
+  TEMP_FAILURE_RETRY(open64("filename", 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'open64' should use O_CLOEXEC where
+  // CHECK-FIXES: 3 | O_CLOEXEC
   openat(0, "filename", 3);
   // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
   // CHECK-FIXES: 3 | O_CLOEXEC
+  TEMP_FAILURE_RETRY(openat(0, "filename", 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: 'openat' should use O_CLOEXEC where
+  // CHECK-FIXES: 3 | O_CLOEXEC
 
   int flag = 3;
   open("filename", flag);
   // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(open("filename", flag));
+  // CHECK-MESSAGES-NOT: warning:
   open64("filename", flag);
   // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(open64("filename", flag));
+  // CHECK-MESSAGES-NOT: warning:
   openat(0, "filename", flag);
   // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(openat(0, "filename", flag));
+  // CHECK-MESSAGES-NOT: warning:
 }
 
 namespace i {
@@ -64,10 +104,16 @@
 void d() {
   open("filename", O_RDWR);
   // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(open("filename", O_RDWR));
+  // CHECK-MESSAGES-NOT: warning:
   open64("filename", O_RDWR);

[libcxx] r306310 - [libcxx] Annotate c++17 aligned new/delete operators with availability

2017-06-26 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Jun 26 10:39:48 2017
New Revision: 306310

URL: http://llvm.org/viewvc/llvm-project?rev=306310&view=rev
Log:
[libcxx] Annotate c++17 aligned new/delete operators with availability
attribute.

This is needed because older versions of libc++ do not have these
operators. If users target an older deployment target and try to compile
programs in which these operators are explicitly called, the compiler
will complain.

The following is the list of minimum deployment targets for the four
OSes:

macosx: 10.13
ios: 11.0
tvos: 11.0
watchos: 4.0

rdar://problem/32664169

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

Added:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/new

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=306310&r1=306309&r2=306310&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jun 26 10:39:48 2017
@@ -1176,6 +1176,11 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR 
\
   __attribute__((availability(macosx,strict,introduced=10.9))) 
\
   __attribute__((availability(ios,strict,introduced=7.0)))
+#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
\
+  __attribute__((availability(macosx,strict,introduced=10.13)))
\
+  __attribute__((availability(ios,strict,introduced=11.0)))
\
+  __attribute__((availability(tvos,strict,introduced=11.0)))   
\
+  __attribute__((availability(watchos,strict,introduced=4.0)))
 #else
 #define _LIBCPP_AVAILABILITY_SHARED_MUTEX
 #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
@@ -1187,6 +1192,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
 #define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
 #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
 #endif
 
 // Define availability that depends on _LIBCPP_NO_EXCEPTIONS.

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=306310&r1=306309&r2=306310&view=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Mon Jun 26 10:39:48 2017
@@ -193,20 +193,20 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVA
 #endif
 
 #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, 
std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p, 
std::align_val_t) _NOEXCEPT;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) 
_NOEXCEPT _NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
 #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void  
operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
 #endif
 
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, 
std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete[](void* __p, 
std::align_val_t) _NOEXCEPT;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete[](void* __p, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) 
_NOEXCEPT _NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete[](void* __p, 

[PATCH] D34556: [libcxx] Annotate c++17 aligned new/delete operators with availability attribute

2017-06-26 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306310: [libcxx] Annotate c++17 aligned new/delete operators 
with availability (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D34556?vs=103883&id=103992#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34556

Files:
  libcxx/trunk/include/__config
  libcxx/trunk/include/new
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -1176,6 +1176,11 @@
 #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR 
\
   __attribute__((availability(macosx,strict,introduced=10.9))) 
\
   __attribute__((availability(ios,strict,introduced=7.0)))
+#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
\
+  __attribute__((availability(macosx,strict,introduced=10.13)))
\
+  __attribute__((availability(ios,strict,introduced=11.0)))
\
+  __attribute__((availability(tvos,strict,introduced=11.0)))   
\
+  __attribute__((availability(watchos,strict,introduced=4.0)))
 #else
 #define _LIBCPP_AVAILABILITY_SHARED_MUTEX
 #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
@@ -1187,6 +1192,7 @@
 #define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
 #define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
 #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
 #endif
 
 // Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
Index: libcxx/trunk/include/new
===
--- libcxx/trunk/include/new
+++ libcxx/trunk/include/new
@@ -193,20 +193,20 @@
 #endif
 
 #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, 
std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p, 
std::align_val_t) _NOEXCEPT;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) 
_NOEXCEPT _NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
 #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void  
operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
 #endif
 
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, 
std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete[](void* __p, 
std::align_val_t) _NOEXCEPT;
-_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete[](void* __p, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) 
_NOEXCEPT _NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
 #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void  
operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
 #endif
 #endif
 
Index: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp
===
--- 
libcxx/trunk/test/std/langua

[PATCH] D34580: [CodeGen][ObjC] Load indirect ARC arguments in prolog

2017-06-26 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 103994.
kastiglione added a comment.

CHECK load and call


https://reviews.llvm.org/D34580

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGenObjCXX/arc-indirect.mm


Index: test/CodeGenObjCXX/arc-indirect.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-indirect.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc 
-fobjc-runtime=gnustep -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | 
FileCheck -check-prefixes CHECK,CHECK-GNUSTEP %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc 
-fobjc-runtime=macosx -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | 
FileCheck -check-prefixes CHECK,CHECK-DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc 
-fobjc-runtime=ios -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | 
FileCheck -check-prefixes CHECK,CHECK-DARWIN %s
+
+// non trivially copyable, forces inalloca
+struct S {
+  S(const S &s) {}
+};
+
+@interface C
+@end
+@implementation C
+- (void)object:(id)obj struct:(S)s {
+}
+@end
+
+// CHECK-GNUSTEP: define internal void @_i_C__object_struct_(<{ %0*, i8*, i8*, 
%struct.S, [3 x i8] }>* inalloca)
+// CHECK-DARWIN: define internal void @"\01-[C object:struct:]"(<{ %0*, i8*, 
i8*, %struct.S, [3 x i8] }>* inalloca)
+// CHECK: %obj = getelementptr inbounds <{ %0*, i8*, i8*, %struct.S, [3 x i8] 
}>, <{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* %0, i32 0, i32 2
+// CHECK: %1 = load i8*, i8** %obj, align 4
+// CHECK: call void @objc_storeStrong(i8** %obj, i8* %1)
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1860,6 +1860,10 @@
 lt = Qualifiers::OCL_ExplicitNone;
   }
 
+  // Load objects passed indirectly.
+  if (Arg.isIndirect() && !ArgVal)
+ArgVal = Builder.CreateLoad(DeclPtr);
+
   if (lt == Qualifiers::OCL_Strong) {
 if (!isConsumed) {
   if (CGM.getCodeGenOpts().OptimizationLevel == 0) {


Index: test/CodeGenObjCXX/arc-indirect.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-indirect.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc -fobjc-runtime=gnustep -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,CHECK-GNUSTEP %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc -fobjc-runtime=macosx -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,CHECK-DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-unknown-windows-msvc -fobjc-runtime=ios -fobjc-arc -Wno-objc-root-class -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,CHECK-DARWIN %s
+
+// non trivially copyable, forces inalloca
+struct S {
+  S(const S &s) {}
+};
+
+@interface C
+@end
+@implementation C
+- (void)object:(id)obj struct:(S)s {
+}
+@end
+
+// CHECK-GNUSTEP: define internal void @_i_C__object_struct_(<{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* inalloca)
+// CHECK-DARWIN: define internal void @"\01-[C object:struct:]"(<{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* inalloca)
+// CHECK: %obj = getelementptr inbounds <{ %0*, i8*, i8*, %struct.S, [3 x i8] }>, <{ %0*, i8*, i8*, %struct.S, [3 x i8] }>* %0, i32 0, i32 2
+// CHECK: %1 = load i8*, i8** %obj, align 4
+// CHECK: call void @objc_storeStrong(i8** %obj, i8* %1)
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1860,6 +1860,10 @@
 lt = Qualifiers::OCL_ExplicitNone;
   }
 
+  // Load objects passed indirectly.
+  if (Arg.isIndirect() && !ArgVal)
+ArgVal = Builder.CreateLoad(DeclPtr);
+
   if (lt == Qualifiers::OCL_Strong) {
 if (!isConsumed) {
   if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34286: [clang-tidy] Fix type names in modernize-use-unique/shared_ptr checks.

2017-06-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 103995.
hokein marked 2 inline comments as done.
hokein added a comment.
Herald added a subscriber: JDevlieghere.

Address review comments.


https://reviews.llvm.org/D34286

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


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -49,6 +49,14 @@
 
 struct Empty {};
 
+namespace {
+class Foo {};
+} // namespace
+
+namespace bar {
+class Bar {};
+} // namespace bar
+
 template 
 using unique_ptr_ = std::unique_ptr;
 
@@ -239,6 +247,20 @@
   std::unique_ptr PEmpty = std::unique_ptr(new Empty{});
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = 
std::make_unique(Empty{});
+
+  std::unique_ptr FF = std::unique_ptr(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
+  // CHECK-FIXES: std::unique_ptr FF = std::make_unique();
+  FF.reset(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: FF = std::make_unique();
+
+  std::unique_ptr BB = std::unique_ptr(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  // CHECK-FIXES: std::unique_ptr BB = std::make_unique();
+  BB.reset(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: BB = std::make_unique();
 }
 
 void aliases() {
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -16,6 +16,17 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+StringRef GetNewExprName(const CXXNewExpr *NewExpr,
+ const SourceManager &SM,
+ const LangOptions &Lang) {
+  return Lexer::getSourceText(
+  CharSourceRange::getTokenRange(
+  
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
+  SM, Lang);
+}
+} // namespace
+
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
 const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
@@ -87,7 +98,7 @@
   StringRef ExprStr = Lexer::getSourceText(
   CharSourceRange::getCharRange(
   ConstructCallStart, Construct->getParenOrBraceRange().getBegin()),
-  SM, LangOptions(), &Invalid);
+  SM, getLangOpts(), &Invalid);
   if (Invalid)
 return;
 
@@ -102,7 +113,8 @@
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
 Diag << FixItHint::CreateInsertion(
-ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">");
+ConstructCallEnd,
+"<" + GetNewExprName(New, SM, getLangOpts()).str() + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }
@@ -144,7 +156,7 @@
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + makeSmartPtrFunctionName + "<" +
-   New->getAllocatedType().getAsString(getLangOpts()) + ">")
+   GetNewExprName(New, SM, getLangOpts()) + ">")
   .str());
 
   if (Expr->isArrow())


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -49,6 +49,14 @@
 
 struct Empty {};
 
+namespace {
+class Foo {};
+} // namespace
+
+namespace bar {
+class Bar {};
+} // namespace bar
+
 template 
 using unique_ptr_ = std::unique_ptr;
 
@@ -239,6 +247,20 @@
   std::unique_ptr PEmpty = std::unique_ptr(new Empty{});
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = std::make_unique(Empty{});
+
+  std::unique_ptr FF = std::unique_ptr(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
+  // CHECK-FIXES: std::unique_ptr FF = std::make_unique();
+  FF.reset(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: FF = std::make_unique();
+
+  std::unique_ptr BB = std::unique_ptr(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  // CHECK-FIXES: std::unique_ptr BB = std::make_unique();
+  BB.reset(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: BB = std::make_unique();
 }
 
 void aliases() {
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -16,6 +16,17 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+StringRef GetNewExprName(const CXXNewExpr *NewExpr,
+ const

[PATCH] D34580: [CodeGen][ObjC] Load indirect ARC arguments in prolog

2017-06-26 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

Thanks @rnk.

I don't have commit access; @compnerd, @rnk would either of you mind committing 
this? Thanks in advance!


https://reviews.llvm.org/D34580



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


[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread David Majnemer via Phabricator via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

Looks good to me but I definitely want to hear what @efriedma has to say.


Repository:
  rL LLVM

https://reviews.llvm.org/D34523



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


[PATCH] D34636: [clangd] LLVM-ify codebase

2017-06-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz created this revision.

This patch introduces cosmetic changes while making ClangD code slightly more 
LLVM Coding Standards-compliant by

- Convert names of struct fields in Protocol.h from `camelCase` to `CamelCase`
- Enclose code in .cpp implementation files in appropriate namespaces instead 
of doing `using namespace clang; using namespace clangd;`
- Putting few `const`s and references where appropriate

Testing:
$ ninja check-clang-tools
All ClangD-related tests are green.


https://reviews.llvm.org/D34636

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/DraftStore.cpp
  clangd/GlobalCompilationDatabase.cpp
  clangd/JSONRPCDispatcher.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -139,7 +139,7 @@
   // FIXME: severities returned by clangd should have a descriptive
   // diagnostic severity enum
   const int ErrorSeverity = 1;
-  HadError = DiagAndFixIts.Diag.severity == ErrorSeverity;
+  HadError = DiagAndFixIts.Diag.Severity == ErrorSeverity;
 }
 
 std::lock_guard Lock(Mutex);
@@ -398,7 +398,7 @@
 protected:
   bool ContainsItem(std::vector const &Items, StringRef Name) {
 for (const auto &Item : Items) {
-  if (Item.insertText == Name)
+  if (Item.InsertText == Name)
 return true;
 }
 return false;
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -22,7 +22,7 @@
 
 static llvm::cl::opt
 RunSynchronously("run-synchronously",
- llvm::cl::desc("parse on main thread"),
+ llvm::cl::desc("Parse code in main thread"),
  llvm::cl::init(false), llvm::cl::Hidden);
 
 int main(int argc, char *argv[]) {
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -11,8 +11,9 @@
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "DraftStore.h"
-using namespace clang;
-using namespace clangd;
+
+namespace clang {
+namespace clangd {
 
 namespace {
 
@@ -188,7 +189,7 @@
 
 } // namespace
 
-void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
+void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
  JSONOutput &Out,
  ProtocolCallbacks &Callbacks) {
   Dispatcher.registerHandler(
@@ -220,3 +221,6 @@
   "textDocument/completion",
   llvm::make_unique(Out, Callbacks));
 }
+
+} // namespace clangd
+} // namespace clang
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -31,10 +31,10 @@
 
 struct URI {
   std::string uri;
-  std::string file;
+  std::string File;
 
   static URI fromUri(llvm::StringRef uri);
-  static URI fromFile(llvm::StringRef file);
+  static URI fromFile(llvm::StringRef Filename);
 
   static URI parse(llvm::yaml::ScalarNode *Param);
   static std::string unparse(const URI &U);
@@ -50,36 +50,37 @@
 
 struct Position {
   /// Line position in a document (zero-based).
-  int line;
+  unsigned Line;
 
   /// Character offset on a line in a document (zero-based).
-  int character;
+  unsigned LineOffset;
 
   friend bool operator==(const Position &LHS, const Position &RHS) {
-return std::tie(LHS.line, LHS.character) ==
-   std::tie(RHS.line, RHS.character);
+return std::tie(LHS.Line, LHS.LineOffset) ==
+   std::tie(RHS.Line, RHS.LineOffset);
   }
+
   friend bool operator<(const Position &LHS, const Position &RHS) {
-return std::tie(LHS.line, LHS.character) <
-   std::tie(RHS.line, RHS.character);
+return std::tie(LHS.Line, LHS.LineOffset) <
+   std::tie(RHS.Line, RHS.LineOffset);
   }
 
   static llvm::Optional parse(llvm::yaml::MappingNode *Params);
   static std::string unparse(const Position &P);
 };
 
 struct Range {
   /// The range's start position.
-  Position start;
+  Position Start;
 
   /// The range's end position.
-  Position end;
+  Position End;
 
   friend bool operator==(const Range &LHS, const Range &RHS) {
-return std::tie(LHS.start, LHS.end) == std::tie(RHS.start, RHS.end);
+return std::tie(LHS.Start, LHS.End) == std::tie(RHS.Start, RHS.End);
   }
   friend bool operator<(const Range &LHS, const Range &RHS) {
-return std::tie(LHS.start, LHS.end) < std::tie(RHS.start, RHS.end);
+return std::tie(LHS.Start, LHS.End) < std::tie(RHS.Start, RHS.End);
   }
 
   static llvm::Optional

r306317 - [Sema] Fix a crash-on-invalid when a template parameter list has a class

2017-06-26 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Jun 26 11:46:12 2017
New Revision: 306317

URL: http://llvm.org/viewvc/llvm-project?rev=306317&view=rev
Log:
[Sema] Fix a crash-on-invalid when a template parameter list has a class
definition or non-reference class type.

The crash occurs when there is a template parameter list in a class that
is missing the closing angle bracket followed by a definition of a
struct. For example:

class C0 {
public:
  template) {}
  S0 *m;
};

This happens because the parsed struct is added to the scope of the
enclosing class without having its access specifier set, which results
in an assertion failure in SemaAccess.cpp later.

This commit fixes the crash by adding the parsed struct to the enclosing
file scope and marking structs as invalid if they are defined in
template parameter lists.

rdar://problem/31783961
rdar://problem/19570630

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

Added:
cfe/trunk/test/SemaCXX/invalid-template-params.cpp
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/PR16677.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=306317&r1=306316&r2=306317&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Jun 26 11:46:12 2017
@@ -1852,6 +1852,7 @@ private:
 DSC_trailing, // C++11 trailing-type-specifier in a trailing return type
 DSC_alias_declaration, // C++11 type-specifier-seq in an alias-declaration
 DSC_top_level, // top-level/namespace declaration context
+DSC_template_param, // template parameter context
 DSC_template_type_arg, // template type argument context
 DSC_objc_method_result, // ObjC method result context, enables 
'instancetype'
 DSC_condition // condition declaration context
@@ -1862,6 +1863,7 @@ private:
   static bool isTypeSpecifier(DeclSpecContext DSC) {
 switch (DSC) {
 case DSC_normal:
+case DSC_template_param:
 case DSC_class:
 case DSC_top_level:
 case DSC_objc_method_result:
@@ -1882,6 +1884,7 @@ private:
   static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
 switch (DSC) {
 case DSC_normal:
+case DSC_template_param:
 case DSC_class:
 case DSC_top_level:
 case DSC_condition:

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=306317&r1=306316&r2=306317&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jun 26 11:46:12 2017
@@ -2153,7 +2153,8 @@ public:
  bool &OwnedDecl, bool &IsDependent,
  SourceLocation ScopedEnumKWLoc,
  bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
- bool IsTypeSpecifier, SkipBodyInfo *SkipBody = nullptr);
+ bool IsTypeSpecifier, bool IsTemplateParamOrArg,
+ SkipBodyInfo *SkipBody = nullptr);
 
   Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc,
 unsigned TagSpec, SourceLocation TagLoc,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=306317&r1=306316&r2=306317&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Jun 26 11:46:12 2017
@@ -2629,6 +2629,8 @@ Parser::getDeclSpecContextFromDeclarator
 return DSC_class;
   if (Context == Declarator::FileContext)
 return DSC_top_level;
+  if (Context == Declarator::TemplateParamContext)
+return DSC_template_param;
   if (Context == Declarator::TemplateTypeArgContext)
 return DSC_template_type_arg;
   if (Context == Declarator::TrailingReturnContext)
@@ -4261,7 +4263,9 @@ void Parser::ParseEnumSpecifier(SourceLo
AS, DS.getModulePrivateSpecLoc(), TParams,
Owned, IsDependent, ScopedEnumKWLoc,
IsScopedUsingClassTag, BaseType,
-   DSC == DSC_type_specifier, &SkipBody);
+   DSC == DSC_type_specifier,
+   DSC == DSC_template_param ||
+   DSC == DSC_template_type_arg, &SkipBody);
 
   if (SkipBody.ShouldSkip) {
 assert(TUK == Sema::TUK_Definition && "can onl

[PATCH] D33606: [Sema] Fix a crash-on-invalid when a template parameter list has a class definition or non-reference class type

2017-06-26 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306317: [Sema] Fix a crash-on-invalid when a template 
parameter list has a class (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D33606?vs=100465&id=104000#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33606

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Parse/ParseTemplate.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/SemaCXX/PR16677.cpp
  cfe/trunk/test/SemaCXX/invalid-template-params.cpp

Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1887,7 +1887,8 @@
SourceLocation(), false,
clang::TypeResult(),
DSC == DSC_type_specifier,
-   &SkipBody);
+   DSC == DSC_template_param ||
+   DSC == DSC_template_type_arg, &SkipBody);
 
 // If ActOnTag said the type was dependent, try again with the
 // less common call.
Index: cfe/trunk/lib/Parse/ParseTemplate.cpp
===
--- cfe/trunk/lib/Parse/ParseTemplate.cpp
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp
@@ -674,7 +674,8 @@
   // FIXME: The type should probably be restricted in some way... Not all
   // declarators (parts of declarators?) are accepted for parameters.
   DeclSpec DS(AttrFactory);
-  ParseDeclarationSpecifiers(DS);
+  ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none,
+ DSC_template_param);
 
   // Parse this as a typename.
   Declarator ParamDecl(DS, Declarator::TemplateParamContext);
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -2629,6 +2629,8 @@
 return DSC_class;
   if (Context == Declarator::FileContext)
 return DSC_top_level;
+  if (Context == Declarator::TemplateParamContext)
+return DSC_template_param;
   if (Context == Declarator::TemplateTypeArgContext)
 return DSC_template_type_arg;
   if (Context == Declarator::TrailingReturnContext)
@@ -4261,7 +4263,9 @@
AS, DS.getModulePrivateSpecLoc(), TParams,
Owned, IsDependent, ScopedEnumKWLoc,
IsScopedUsingClassTag, BaseType,
-   DSC == DSC_type_specifier, &SkipBody);
+   DSC == DSC_type_specifier,
+   DSC == DSC_template_param ||
+   DSC == DSC_template_type_arg, &SkipBody);
 
   if (SkipBody.ShouldSkip) {
 assert(TUK == Sema::TUK_Definition && "can only skip a definition");
Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -8612,7 +8612,8 @@
 /*ModulePrivateLoc=*/SourceLocation(),
 MultiTemplateParamsArg(), Owned, IsDependent,
 SourceLocation(), false, TypeResult(),
-/*IsTypeSpecifier*/false);
+/*IsTypeSpecifier*/false,
+/*IsTemplateParamOrArg*/false);
   assert(!IsDependent && "explicit instantiation of dependent name not yet handled");
 
   if (!TagD)
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13090,7 +13090,8 @@
  SourceLocation ScopedEnumKWLoc,
  bool ScopedEnumUsesClassTag,
  TypeResult UnderlyingType,
- bool IsTypeSpecifier, SkipBodyInfo *SkipBody) {
+ bool IsTypeSpecifier, bool IsTemplateParamOrArg,
+ SkipBodyInfo *SkipBody) {
   // If this is not a definition, it must have a name.
   IdentifierInfo *OrigName = Name;
   assert((Name != nullptr || TUK == TUK_Definition) &&
@@ -13360,11 +13361,11 @@
   // also need to do a redeclaration lookup there, just in case
   // there's a shadow friend decl.
   if (Name && Previous.empty() &&
-  (TUK == TUK_Reference || TUK == TUK_Friend)) {
+  (TUK == TUK_Reference || TUK == TUK_Friend || IsTemplateParamOrArg)) {
 if (Invalid) goto CreateNewDecl;
 assert(SS.isEmpty());
 
-if (TUK == TUK_Refe

[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:988
+  if (const auto *RD = dyn_cast(DC))
+mangleName(RD);
+  else

The call to mangleName() looks a little weird... I would have expected a call 
to mangleUnqualifiedName or something like that.  (If there's some reason for 
the asymmetry, a brief comment explaining it would be fine.)



Comment at: lib/AST/MicrosoftMangle.cpp:1008
+if (const auto *ND = dyn_cast(MC))
+  mangleUnqualifiedName(ND);
+

This isn't quite the same thing the Itanium mangling does... 

Itanium has special cases for in-class initializers and default arguments.  
Using the name is fine for in-class initalizers, but it doesn't really work for 
default arguments: arguments aren't required to have names.  Consider, for 
example:

```
extern int e(void);
class C {
  void m(int = ^{ static int i = e(); return ++i; }(),
 int = ^{ static int i = e(); return ++i; }());
};
```



Comment at: test/CodeGenCXX/msabi-blocks.cpp:90
+}
+

The Itanium ABI document lists five cases where the mangling is externally 
visible.  I think this is missing a testcase for the "initializers of 
nonspecialized static members of template classes" case.  (Something like 
"template class X { static T foo; }; template T 
X::foo = ^{static int i = e(); return ++i;}();".)


Repository:
  rL LLVM

https://reviews.llvm.org/D34523



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


r306320 - When preprocessing with -frewrite-imports and -fmodule-file=, do not pass all

2017-06-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 26 12:39:25 2017
New Revision: 306320

URL: http://llvm.org/viewvc/llvm-project?rev=306320&view=rev
Log:
When preprocessing with -frewrite-imports and -fmodule-file=, do not pass all
modules to preprocessing of nested .pcm files.

Making those module files available results in loading more .pcm files than
necessary, and potentially in misbehavior if a module makes itself visible
during its own compilation (as parts of that module that have not yet been
processed would then become visible).

Added:
cfe/trunk/test/Modules/Inputs/preprocess/file.h
cfe/trunk/test/Modules/Inputs/preprocess/other.h
Modified:
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/test/Modules/Inputs/preprocess/fwd.h
cfe/trunk/test/Modules/Inputs/preprocess/module.modulemap
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp?rev=306320&r1=306319&r2=306320&view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp Mon Jun 26 12:39:25 2017
@@ -247,6 +247,8 @@ public:
 Instance.getFrontendOpts().Inputs.clear();
 Instance.getFrontendOpts().Inputs.emplace_back(
 Filename, InputKind(InputKind::Unknown, InputKind::Precompiled));
+Instance.getFrontendOpts().ModuleFiles.clear();
+Instance.getFrontendOpts().ModuleMapFiles.clear();
 // Don't recursively rewrite imports. We handle them all at the top level.
 Instance.getPreprocessorOutputOpts().RewriteImports = false;
 

Added: cfe/trunk/test/Modules/Inputs/preprocess/file.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/file.h?rev=306320&view=auto
==
--- cfe/trunk/test/Modules/Inputs/preprocess/file.h (added)
+++ cfe/trunk/test/Modules/Inputs/preprocess/file.h Mon Jun 26 12:39:25 2017
@@ -0,0 +1,9 @@
+#include "other.h"
+
+#ifndef FILE_H
+#define FILE_H
+struct __FILE;
+#include "fwd.h"
+typedef struct __FILE FILE;
+typedef foo bar;
+#endif

Modified: cfe/trunk/test/Modules/Inputs/preprocess/fwd.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/fwd.h?rev=306320&r1=306319&r2=306320&view=diff
==
--- cfe/trunk/test/Modules/Inputs/preprocess/fwd.h (original)
+++ cfe/trunk/test/Modules/Inputs/preprocess/fwd.h Mon Jun 26 12:39:25 2017
@@ -1 +1,2 @@
+typedef struct foo foo;
 struct __FILE;

Modified: cfe/trunk/test/Modules/Inputs/preprocess/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/module.modulemap?rev=306320&r1=306319&r2=306320&view=diff
==
--- cfe/trunk/test/Modules/Inputs/preprocess/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/preprocess/module.modulemap Mon Jun 26 
12:39:25 2017
@@ -1,5 +1,5 @@
 module fwd { header "fwd.h" export * }
-module file { header "file.h" header "file2.h" export * }
+module file { header "file.h" header "file2.h" header "other.h" export * }
 module nested {
   module a { header "a.h" }
   module b { header "b.h" }

Added: cfe/trunk/test/Modules/Inputs/preprocess/other.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/other.h?rev=306320&view=auto
==
--- cfe/trunk/test/Modules/Inputs/preprocess/other.h (added)
+++ cfe/trunk/test/Modules/Inputs/preprocess/other.h Mon Jun 26 12:39:25 2017
@@ -0,0 +1 @@
+// other.h: empty

Modified: cfe/trunk/test/Modules/preprocess-module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-module.cpp?rev=306320&r1=306319&r2=306320&view=diff
==
--- cfe/trunk/test/Modules/preprocess-module.cpp (original)
+++ cfe/trunk/test/Modules/preprocess-module.cpp Mon Jun 26 12:39:25 2017
@@ -29,15 +29,15 @@
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify 
-fno-modules-error-recovery -DREWRITE -DINCLUDE -I%S/Inputs/preprocess
 
 // Now try building the module when the header files are missing.
-// RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h 
%S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t
+// RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h 
%S/Inputs/preprocess/file2.h %S/Inputs/preprocess/other.h 
%S/Inputs/preprocess/module.modulemap %t
 // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%t 
-x c++-module-map %t/module.modulemap -E -frewrite-includes -o %t/copy.ii
-// RUN: rm %t/fwd.h %

[PATCH] D34508: [Analyzer] Bug Reporter Visitor to Display Values of Variables - PRELIMINARY!

2017-06-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In a perfect world, the analyzer's report would work like a debugger: jumping 
through stack frames, or even through diagnostic pieces, and printing symbolic 
values of variables at every piece would be really great.

I'm not entirely understanding the behavior you intend to have in this patch. 
Are you trying to print out values of all variables as diagnostic pieces? This 
might be a bit of an overkill, because many variables would be irrelevant to 
the bug. It could probably be better if a new kind of diagnostic pieces is 
introduced, instead of `PathDiagnosticEventPiece`, that would be handled by the 
consumers (text, html, plist) to somehow provide values on demand and avoid 
clamping up the screen.

Currently, we already highlight the last assignments for the "interesting" 
variables, which is implemented through, for example, 
`bugreporter::trackNullOrUndefValue()` - see how various checkers use it. This 
is, of course, far from perfect as well, because it's very hard to figure out 
which variables are of interest.

-

In the first example, the user sees the "Entering loop body" control flow piece 
twice, from which it is clear that `i` is equal to 1. I disagree that an 
"assuming..." piece should be added here, because there is no assumption being 
made. The analyzer //knows// that `i` is first equal to 0, then it becomes 1; 
he doesn't need to assume it. A quick discussion on this subject happened in 
https://reviews.llvm.org/D23300.

That said, i agree that it'd be good to improve the existing "Entering loop 
body..." diagnostic to contain information about the value of `i`. The report 
is understandable without it, but it'd make a nice addition.

In the second example, `j` is still not being assumed, however upon meeting the 
condition `j < size + 1`, we should definitely mention that we //assume// that 
`size` is equal to `UINT_MAX` - because this is indeed an assumption, and we're 
failing to display it. It's a bug that definitely needs to be fixed, and the 
aforementioned https://reviews.llvm.org/D23300 was fixing similar bugs.

-

To summarize:

- It's great to improve diagnostics, and you have pointed out some buggy or 
missing diagnostic pieces that make reports confusing.
- I'm not sure if we can, or should, afford the overkill of dumping all 
variables, though in some situations it may indeed be useful.
- I'm not seeing examples that aren't supposed to be covered by existing 
diagnostic mechanisms - fixing bugs in them might be equally useful and much 
easier and safer.
- I remember seeing such examples before, so, generally, i suspect that your 
approach may work, especially with a better UI.
- This is likely to require a more open discussion.


https://reviews.llvm.org/D34508



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


r306325 - Remove some redundant setup when preprocessing .pcm files.

2017-06-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 26 13:15:21 2017
New Revision: 306325

URL: http://llvm.org/viewvc/llvm-project?rev=306325&view=rev
Log:
Remove some redundant setup when preprocessing .pcm files.

Both of these steps are immediately overwritten by the FrontendAction setup.

Modified:
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=306325&r1=306324&r2=306325&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Jun 26 13:15:21 2017
@@ -359,15 +359,6 @@ void SourceManager::initializeForReplay(
 return Clone;
   };
 
-  // Set up our main file ID as a copy of the old source manager's main file.
-  const SLocEntry &OldMainFile = Old.getSLocEntry(Old.getMainFileID());
-  assert(OldMainFile.isFile() && "main file is macro expansion?");
-  auto *MainCC = CloneContentCache(OldMainFile.getFile().getContentCache());
-  MemBufferInfos.push_back(MainCC);
-  setMainFileID(createFileID(MainCC, SourceLocation(),
- OldMainFile.getFile().getFileCharacteristic(),
- 0, 0));
-
   // Ensure all SLocEntries are loaded from the external source.
   for (unsigned I = 0, N = Old.LoadedSLocEntryTable.size(); I != N; ++I)
 if (!Old.SLocEntryLoaded[I])

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=306325&r1=306324&r2=306325&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon Jun 26 13:15:21 2017
@@ -561,7 +561,6 @@ bool FrontendAction::BeginSourceFile(Com
 CI.setFileManager(&AST->getFileManager());
 CI.createSourceManager(CI.getFileManager());
 CI.getSourceManager().initializeForReplay(AST->getSourceManager());
-CI.createPreprocessor(getTranslationUnitKind());
 
 // Set up the input file for replay purposes.
 auto Kind = AST->getInputKind();


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


r306327 - Check that the initializer of a non-dependent constexpr variable is constant even within templates.

2017-06-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 26 13:33:42 2017
New Revision: 306327

URL: http://llvm.org/viewvc/llvm-project?rev=306327&view=rev
Log:
Check that the initializer of a non-dependent constexpr variable is constant 
even within templates.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=306327&r1=306326&r2=306327&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jun 26 13:33:42 2017
@@ -11100,9 +11100,7 @@ void Sema::CheckCompleteVariableDeclarat
   bool IsGlobal = GlobalStorage && !var->isStaticLocal();
   QualType baseType = Context.getBaseElementType(type);
 
-  if (!var->getDeclContext()->isDependentContext() &&
-  Init && !Init->isValueDependent()) {
-
+  if (Init && !Init->isValueDependent()) {
 if (var->isConstexpr()) {
   SmallVector Notes;
   if (!var->evaluateValue(Notes) || !var->isInitICE()) {

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=306327&r1=306326&r2=306327&view=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Mon Jun 26 13:33:42 
2017
@@ -608,7 +608,7 @@ namespace DependentValues {
 
 struct I { int n; typedef I V[10]; };
 I::V x, y;
-int g();
+int g(); // expected-note {{declared here}}
 template struct S : T {
   int k;
   void f() {
@@ -616,13 +616,23 @@ template struct S :
 I &i = cells[k];
 switch (i.n) {}
 
-// FIXME: We should be able to diagnose this.
-constexpr int n = g();
+constexpr int n = g(); // expected-error {{must be initialized by a 
constant expression}} expected-note {{non-constexpr function 'g'}}
 
 constexpr int m = this->g(); // ok, could be constexpr
   }
 };
 
+extern const int n;
+template void f() {
+  // This is ill-formed, because a hypothetical instantiation at the point of
+  // template definition would be ill-formed due to a construct that does not
+  // depend on a template parameter.
+  constexpr int k = n; // expected-error {{must be initialized by a constant 
expression}}
+}
+// It doesn't matter that the instantiation could later become valid:
+constexpr int n = 4;
+template void f();
+
 }
 
 namespace Class {


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


[PATCH] D34506: Relax an assert in the comparison of source locations

2017-06-26 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Comparing SourceLocations from different translation units is not meaningful 
and my concern is that treating source locations like this can very easy lead 
to errors where by mistake the code is resolving a SourceLocation with the 
wrong translation unit and not the translation unit that it came from.

If you intend to sort source locations across translation units I think you 
should use an abstraction that includes the source location _and_ the 
ASTContext or ASTUnit (or something to identify the translation unit) that the 
source location came from, and use that for sorting (by checking whether the TU 
are the same, and if not sort appropriately with the TUs, before sorting the 
SourceLocations).
That way you don't need to 'allow' comparing source locations from different 
TUs, which IMO is a good sanity check to make sure the code did not mix-up the 
source locations by accident.


Repository:
  rL LLVM

https://reviews.llvm.org/D34506



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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-06-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

What's the status of this patch? https://reviews.llvm.org/D34510 is touching on 
a related issue, and we need to resolve how we're going to deal with ODR-like 
issues in C to determine how to address the issue that it is tackling.


https://reviews.llvm.org/D31778



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


[PATCH] D34506: Relax an assert in the comparison of source locations

2017-06-26 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

`FullSourceLoc` could be useful, it wraps the SourceManager that the 
SourceLocation come from.


Repository:
  rL LLVM

https://reviews.llvm.org/D34506



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


[PATCH] D34510: Teach clang how to merge typedef over anonymous structs in C mode.

2017-06-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

https://reviews.llvm.org/D31778 is related. We need to have a design for how 
ODR-like issues in C will be resolved before we'll know what the right fix is 
here. Prior to https://reviews.llvm.org/D31778 my intention had been to 
implement C's structural typing ("compatible type") rules and keep multiple 
definitions of `RecordDecl`s in C as separate entities, but 
https://reviews.llvm.org/D31778 is suggesting that we use something more 
ODR-like instead, which is also more in line with the direction that this patch 
takes.

It's notable that C has no notion of "typedef name for linkage", so this patch 
does not address all the typedef-related issues that might show up in C code. 
For example:

  typedef struct { ... } *ptr;

in two different modules would not be merged into a single type with this 
approach (you'd need to actually implement the C compatible type rules to get 
that to work). But maybe that's OK -- the above also does not (formally) work 
in C++, and it doesn't seem to cause major problems.


Repository:
  rL LLVM

https://reviews.llvm.org/D34510



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


[PATCH] D34059: Get the file name for the symbol from the Module, not the SourceManager.

2017-06-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good, thanks!


https://reviews.llvm.org/D34059



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


[PATCH] D34444: Teach codegen to work in incremental processing mode.

2017-06-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This makes sense to me, but I'd like John's input on whether this is a 
reasonable facility for CodeGen to have, and whether this is sufficient for 
(for example) inline function definitions to be emitted at the right times into 
the right `Module`s. (The tests for this appear to be in 
https://reviews.llvm.org/D34059.)


Repository:
  rL LLVM

https://reviews.llvm.org/D3



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


[PATCH] D16403: Add scope information to CFG

2017-06-26 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> @dcoughlin As a reviewer of both patches - could you tell us what's the 
> difference between them? And how are we going to resolve this issue?

Unfortunately, @dcoughlin is on vacation this week; should be back next week.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D34574: [Sema] Disable c++17 aligned new and delete operators if not implemented in the deployment target's c++ standard library

2017-06-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Duncan and I had a discussion on this.

We are thinking about adding a warning that tells users that aligned allocation 
/deallocation operators are being called but they are not defined in the 
library. If the users haven't defined their own aligned allocation / 
deallocation operators, they will get a link error if the deployment target is 
too old, but the warning will tell them what the root cause of the error is. If 
they have defined their own operators, they will get a false positive warning, 
but it's still possible to turn it off by passing -faligned-allocation. 
Annotating the implicit declarations with availability will cause compile time 
errors, so we can't do so if we just want to issue a warning.

Richard, what do you think?


https://reviews.llvm.org/D34574



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


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-26 Thread Kuang He via Phabricator via cfe-commits
kuang_he updated this revision to Diff 104018.

https://reviews.llvm.org/D33833

Files:
  lib/AST/DeclCXX.cpp
  test/SemaTemplate/destructor-template.cpp


Index: test/SemaTemplate/destructor-template.cpp
===
--- test/SemaTemplate/destructor-template.cpp
+++ test/SemaTemplate/destructor-template.cpp
@@ -86,3 +86,9 @@
   template decltype(S().~S()) f(); // expected-note {{candidate 
template ignored: couldn't infer template argument 'T'}}
   void g() { f(); } // expected-error {{no matching function for call to 'f'}}
 }
+
+class PR33189
+{
+  template 
+  ~PR33189() { } // expected-error{{destructor cannot be declared as a 
template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,11 +1417,8 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {


Index: test/SemaTemplate/destructor-template.cpp
===
--- test/SemaTemplate/destructor-template.cpp
+++ test/SemaTemplate/destructor-template.cpp
@@ -86,3 +86,9 @@
   template decltype(S().~S()) f(); // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
   void g() { f(); } // expected-error {{no matching function for call to 'f'}}
 }
+
+class PR33189
+{
+  template 
+  ~PR33189() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,11 +1417,8 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34574: [Sema] Disable c++17 aligned new and delete operators if not implemented in the deployment target's c++ standard library

2017-06-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D34574#791124, @ahatanak wrote:

> Duncan and I had a discussion on this.
>
> We are thinking about adding a warning that tells users that aligned 
> allocation /deallocation operators are being called but they are not defined 
> in the library.


Likely, something like `-Werror=aligned-allocation-availability` (by default).

> If the users haven't defined their own aligned allocation / deallocation 
> operators, they will get a link error if the deployment target is too old, 
> but the warning will tell them what the root cause of the error is. If they 
> have defined their own operators, they will get a false positive warning, but 
> it's still possible to turn it off by passing -faligned-allocation.

Or by passing `-Wno-aligned-allocation-availability`.

> Annotating the implicit declarations with availability will cause compile 
> time errors, so we can't do so if we just want to issue a warning.
> 
> Richard, what do you think?

I also wonder: should we add a warning for such code in pre-C++17?


https://reviews.llvm.org/D34574



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


[PATCH] D34574: [Sema] Disable c++17 aligned new and delete operators if not implemented in the deployment target's c++ standard library

2017-06-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

So the driver would pass a flag to the frontend to indicate "this target 
probably doesn't have aligned allocation support", and Sema would produce a 
warning if it selects an aligned allocation function when that flag is 
specified? That makes sense to me.

Should we also remove the recently-added availability attributes in libc++ too? 
If I'm using a recent libc++ and providing my own aligned allocation functions, 
we shouldn't reject attempts to call those aligned allocation functions.


https://reviews.llvm.org/D34574



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


[PATCH] D34574: [Sema] Disable c++17 aligned new and delete operators if not implemented in the deployment target's c++ standard library

2017-06-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D34574#791157, @dexonsmith wrote:

> Likely, something like `-Werror=aligned-allocation-availability` (by default).


An error by default seems OK if accompanied with a "use -faligned-allocation if 
you supply your own aligned allocation functions" hint.

> I also wonder: should we add a warning for such code in pre-C++17?

`-Wover-aligned` catches this for pre-C++17. We should probably enable it by 
default, though :)


https://reviews.llvm.org/D34574



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


[PATCH] D34574: [Sema] Disable c++17 aligned new and delete operators if not implemented in the deployment target's c++ standard library

2017-06-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D34574#791158, @rsmith wrote:

> Should we also remove the recently-added availability attributes in libc++ 
> too? If I'm using a recent libc++ and providing my own aligned allocation 
> functions, we shouldn't reject attempts to call those aligned allocation 
> functions.


Ugh; maybe.  There's `-D_LIBCPP_DISABLE_AVAILABILITY` already, but that's too 
big a hammer (disables //all// of the markup).


https://reviews.llvm.org/D34574



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


Re: r306149 - Emit warning when throw exception in destruct or dealloc functions which has a

2017-06-26 Thread Richard Smith via cfe-commits
On 23 June 2017 at 13:22, Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Fri Jun 23 15:22:19 2017
> New Revision: 306149
>
> URL: http://llvm.org/viewvc/llvm-project?rev=306149&view=rev
> Log:
> Emit warning when throw exception in destruct or dealloc functions which
> has a
> (possible implicit) noexcept specifier
>
> Throwing in the destructor is not good (C++11 change try to not allow see
> below).
>  But in reality, those codes are exist.
> C++11 [class.dtor]p3:
>
> A declaration of a destructor that does not have an
> exception-specification is
> implicitly considered to have the same exception specification as an
> implicit
> declaration.
>
> With this change, the application worked before may now run into runtime
> termination. My goal here is to emit a warning to provide only possible
> info to
> where the code may need to be changed.
>
> First there is no way, in compile time to identify the “throw” really
> throw out
> of the function. Things like the call which throw out… To keep this simple,
> when “throw” is seen, checking its enclosing function(only destructor and
> dealloc functions) with noexcept(true) specifier emit warning.
>
> Here is implementation detail:
> A new member function CheckCXXThrowInNonThrowingFunc is added for class
> Sema
> in Sema.h. It is used in the call to both BuildCXXThrow and
> TransformCXXThrowExpr.
>
> The function basic check if the enclosing function with non-throwing
> noexcept
> specifer, if so emit warning for it.
>
> The example of warning message like:
> k1.cpp:18:3: warning: ''~dependent_warn'' has a (possible implicit)
> non-throwing
>
> noexcept specifier. Throwing exception may cause termination.
> [-Wthrow-in-dtor]
> throw 1;
> ^
>
> k1.cpp:43:30: note: in instantiation of member function
>
> 'dependent_warn::~dependent_warn' requested here
>
> dependent_warn f; // cause warning
>
> Differential Revision: https://reviews.llvm.org/D3
>
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> cfe/trunk/test/CXX/except/except.spec/p11.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=306149&r1=306148&r2=306149&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 23
> 15:22:19 2017
> @@ -6351,6 +6351,15 @@ def err_exceptions_disabled : Error<
>"cannot use '%0' with exceptions disabled">;
>  def err_objc_exceptions_disabled : Error<
>"cannot use '%0' with Objective-C exceptions disabled">;
> +def warn_throw_in_noexcept_func
> +: Warning<"%0 has a non-throwing exception specification but can
> still "
> +  "throw, resulting in unexpected program termination">,
>

How do you know it's unexpected? :) You also don't know that this leads to
program termination: a set_unexpected handler could do something else, in
principle. I would just delete the ", resulting in unexpected program
termination" part here.


> +  InGroup;
> +def note_throw_in_dtor
> +: Note<"destructor or deallocator has a (possibly implicit)
> non-throwing "
> +  "excepton specification">;
>

Please figure out which case we're actually in, and just mention that one.
You can use "hasImplicitExceptionSpec" in SemaExceptionSpec.cpp to
determine whether the exception specification is implicit.

Also, typo "excepton".


> +def note_throw_in_function
> +: Note<"non-throwing function declare here">;
>

declare -> declared, but something like "function declared non-throwing
here" would be preferable


>  def err_seh_try_outside_functions : Error<
>"cannot use SEH '__try' in blocks, captured regions, or Obj-C method
> decls">;
>  def err_mixing_cxx_try_seh_try : Error<
>
> Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> AnalysisBasedWarnings.cpp?rev=306149&r1=306148&r2=306149&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
> +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Fri Jun 23 15:22:19 2017
> @@ -279,6 +279,150 @@ static void checkRecursiveFunction(Sema
>  }
>
>  //===---
> ---===//
> +// Check for throw in a non-throwing function.
> +//===--
> ===//
> +enum ThrowState {
> +  FoundNoPathForThrow,
> +  FoundPathForThrow,
> +  FoundPathWithNoThrowOutFunction,
> +};
> +
> +static bool isThrowCaught(const CXXThrowExpr *Throw,
> +  const CXXCatchStmt *Catch) {
> +  co

Few builders are off-line for maintenance

2017-06-26 Thread Galina Kistanova via cfe-commits
Hello everyone,

I took few builders off-line for maintenance. Builders:

llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
clang-with-lto-ubuntu
clang-with-thin-lto-ubuntu

Thank you for understanding.

Thanks

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


[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 2 inline comments as done.
compnerd added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:988
+  if (const auto *RD = dyn_cast(DC))
+mangleName(RD);
+  else

efriedma wrote:
> The call to mangleName() looks a little weird... I would have expected a call 
> to mangleUnqualifiedName or something like that.  (If there's some reason for 
> the asymmetry, a brief comment explaining it would be fine.)
Accounting for the parameter like we do for lambdas makes this unnecessary.



Comment at: lib/AST/MicrosoftMangle.cpp:1008
+if (const auto *ND = dyn_cast(MC))
+  mangleUnqualifiedName(ND);
+

efriedma wrote:
> This isn't quite the same thing the Itanium mangling does... 
> 
> Itanium has special cases for in-class initializers and default arguments.  
> Using the name is fine for in-class initalizers, but it doesn't really work 
> for default arguments: arguments aren't required to have names.  Consider, 
> for example:
> 
> ```
> extern int e(void);
> class C {
>   void m(int = ^{ static int i = e(); return ++i; }(),
>  int = ^{ static int i = e(); return ++i; }());
> };
> ```
Added a test case and handled it.



Comment at: test/CodeGenCXX/msabi-blocks.cpp:90
+}
+

efriedma wrote:
> The Itanium ABI document lists five cases where the mangling is externally 
> visible.  I think this is missing a testcase for the "initializers of 
> nonspecialized static members of template classes" case.  (Something like 
> "template class X { static T foo; }; template T 
> X::foo = ^{static int i = e(); return ++i;}();".)
This is currently broken even under the itanium scheme.  I think that doing 
that in a follow up is reasonable.

```
template 
struct s {
  static T i;
};

template 
T s::i = ^{ static T i = T(); return i; }();

template class s;
template class s;
```


Repository:
  rL LLVM

https://reviews.llvm.org/D34523



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


RE: r306149 - Emit warning when throw exception in destruct or dealloc functions which has a

2017-06-26 Thread Keane, Erich via cfe-commits
Sorry Richard, I thought I gave you enough time before committing this for Jen.

Adding her so she can respond to your comments and fix these.

Thanks,
Erich

From: meta...@gmail.com [mailto:meta...@gmail.com] On Behalf Of Richard Smith
Sent: Monday, June 26, 2017 2:25 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r306149 - Emit warning when throw exception in destruct or dealloc 
functions which has a

On 23 June 2017 at 13:22, Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Fri Jun 23 15:22:19 2017
New Revision: 306149

URL: http://llvm.org/viewvc/llvm-project?rev=306149&view=rev
Log:
Emit warning when throw exception in destruct or dealloc functions which has a
(possible implicit) noexcept specifier

Throwing in the destructor is not good (C++11 change try to not allow see 
below).
 But in reality, those codes are exist.
C++11 [class.dtor]p3:

A declaration of a destructor that does not have an exception-specification is
implicitly considered to have the same exception specification as an implicit
declaration.

With this change, the application worked before may now run into runtime
termination. My goal here is to emit a warning to provide only possible info to
where the code may need to be changed.

First there is no way, in compile time to identify the “throw” really throw out
of the function. Things like the call which throw out… To keep this simple,
when “throw” is seen, checking its enclosing function(only destructor and
dealloc functions) with noexcept(true) specifier emit warning.

Here is implementation detail:
A new member function CheckCXXThrowInNonThrowingFunc is added for class Sema
in Sema.h. It is used in the call to both BuildCXXThrow and
TransformCXXThrowExpr.

The function basic check if the enclosing function with non-throwing noexcept
specifer, if so emit warning for it.

The example of warning message like:
k1.cpp:18:3: warning: ''~dependent_warn'' has a (possible implicit) non-throwing

noexcept specifier. Throwing exception may cause termination.
[-Wthrow-in-dtor]
throw 1;
^

k1.cpp:43:30: note: in instantiation of member function

'dependent_warn::~dependent_warn' requested here

dependent_warn f; // cause warning

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


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/CXX/except/except.spec/p11.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=306149&r1=306148&r2=306149&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 23 15:22:19 
2017
@@ -6351,6 +6351,15 @@ def err_exceptions_disabled : Error<
   "cannot use '%0' with exceptions disabled">;
 def err_objc_exceptions_disabled : Error<
   "cannot use '%0' with Objective-C exceptions disabled">;
+def warn_throw_in_noexcept_func
+: Warning<"%0 has a non-throwing exception specification but can still "
+  "throw, resulting in unexpected program termination">,

How do you know it's unexpected? :) You also don't know that this leads to 
program termination: a set_unexpected handler could do something else, in 
principle. I would just delete the ", resulting in unexpected program 
termination" part here.

+  InGroup;
+def note_throw_in_dtor
+: Note<"destructor or deallocator has a (possibly implicit) non-throwing "
+  "excepton specification">;

Please figure out which case we're actually in, and just mention that one. You 
can use "hasImplicitExceptionSpec" in SemaExceptionSpec.cpp to determine 
whether the exception specification is implicit.

Also, typo "excepton".

+def note_throw_in_function
+: Note<"non-throwing function declare here">;

declare -> declared, but something like "function declared non-throwing here" 
would be preferable

 def err_seh_try_outside_functions : Error<
   "cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls">;
 def err_mixing_cxx_try_seh_try : Error<

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=306149&r1=306148&r2=306149&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Fri Jun 23 15:22:19 2017
@@ -279,6 +279,150 @@ static void checkRecursiveFunction(Sema
 }

 
//===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  Fo

[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: test/CodeGenCXX/msabi-blocks.cpp:90
+}
+

compnerd wrote:
> efriedma wrote:
> > The Itanium ABI document lists five cases where the mangling is externally 
> > visible.  I think this is missing a testcase for the "initializers of 
> > nonspecialized static members of template classes" case.  (Something like 
> > "template class X { static T foo; }; template T 
> > X::foo = ^{static int i = e(); return ++i;}();".)
> This is currently broken even under the itanium scheme.  I think that doing 
> that in a follow up is reasonable.
> 
> ```
> template 
> struct s {
>   static T i;
> };
> 
> template 
> T s::i = ^{ static T i = T(); return i; }();
> 
> template class s;
> template class s;
> ```
Fine; please file a bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D34523



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


[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 2 inline comments as done.
compnerd added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:988
+  if (const auto *RD = dyn_cast(DC))
+mangleName(RD);
+  else

compnerd wrote:
> efriedma wrote:
> > The call to mangleName() looks a little weird... I would have expected a 
> > call to mangleUnqualifiedName or something like that.  (If there's some 
> > reason for the asymmetry, a brief comment explaining it would be fine.)
> Accounting for the parameter like we do for lambdas makes this unnecessary.
Err, still need it for the fields; added a comment.


Repository:
  rL LLVM

https://reviews.llvm.org/D34523



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


[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 104028.
compnerd added a comment.

Handle unnamed parameters, improve mangling for NSDMis.  The one case that we 
dont handle currently causes an assertion even in itanium mode.


https://reviews.llvm.org/D34523

Files:
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenCXX/msabi-blocks.cpp

Index: test/CodeGenCXX/msabi-blocks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/msabi-blocks.cpp
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -std=c++11 -fblocks -S -o - -emit-llvm %s | FileCheck %s -check-prefix CHECK-X86
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -std=c++11 -fblocks -S -o - -emit-llvm %s | FileCheck %s -check-prefix CHECK-X64
+
+extern int e(void);
+
+void (^b)() = ^{
+  static int i = 0;
+};
+
+// CHECK-X86-DAG: @"\01?i@?1??_block_invoke@@YAXPAU__block_literal@@@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke@@YAXPEAU__block_literal@@@Z@4HA" ={{.*}} global i32 0
+
+void f(void) {
+  static int i = 0;
+  ^{ static int i = e(); }();
+
+// CHECK-X86-DAG: @"\01?i@?1??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+
+  ^{ static int i = e(); }();
+
+// CHECK-X86-DAG: @"\01?i@?1??_block_invoke_2@@YAXPAU__block_literal_2@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke_2@@YAXPEAU__block_literal_2@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+
+  ^{ ^{ static int i = e(); }(); }();
+
+// CHECK-X86-DAG: @"\01?i@?1??_block_invoke_3@@YAXPAU__block_literal_3@@@Z?1??_block_invoke_4@@YAXPAU__block_literal_4@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?1??_block_invoke_3@@YAXPEAU__block_literal_3@@@Z?1??_block_invoke_4@@YAXPEAU__block_literal_4@@@Z?1??f@@YAXXZ@4HA" ={{.*}} global i32 0
+}
+
+
+template 
+void g(void) {
+  ^{ static int i = e(); }();
+}
+
+template void g(void);
+
+// CHECK-X86-DAG: @"\01?i@?2??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?2???$g@D@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?2??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?2???$g@D@@YAXXZ@4HA" ={{.*}} global i32 0
+
+template void g(void);
+
+// CHECK-X86-DAG: @"\01?i@?2??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?2???$g@H@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?2??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?2???$g@H@@YAXXZ@4HA" ={{.*}} global i32 0
+
+inline void h(void) {
+  ^{ static int i = e(); }();
+}
+
+// CHECK-X86-DAG: @"\01?i@?2??_block_invoke_1@@YAXPAU__block_literal_1@@@Z?2??h@@YAXXZ@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?2??_block_invoke_1@@YAXPEAU__block_literal_1@@@Z?2??h@@YAXXZ@4HA" ={{.*}} global i32 0
+
+struct s {
+  int i = ^{ static int i = e(); return ++i; }();
+
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1@0s@@YAXPAU__block_literal_1@@@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@0s@@YAXPEAU__block_literal_1@@@Z@4HA" ={{.*}} global i32 0
+
+  int j = ^{ static int i = e(); return ++i; }();
+
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1@j@s@@YAXPAU__block_literal_1@@@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@j@s@@YAXPEAU__block_literal_1@@@Z@4HA" ={{.*}} global i32 0
+
+  void m(int i = ^{ static int i = e(); return ++i; }(),
+ int j = ^{ static int i = e(); return ++i; }()) {}
+
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1_1@@YAXPAU__block_literal_1_1@@@Z?0??m@s@@QAEXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1_2@@YAXPAU__block_literal_1_2@@@Z?0??m@s@@QAEXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1_1@@YAXPEAU__block_literal_1_1@@@Z?0??m@s@@QEAAXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1_2@@YAXPEAU__block_literal_1_2@@@Z?0??m@s@@QEAAXHH@Z@4HA" ={{.*}} global i32 0
+
+  void n(int = ^{ static int i = e(); return ++i; }(),
+ int = ^{ static int i = e(); return ++i; }()) {}
+
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1_1@@YAXPAU__block_literal_1_1@@@Z?0??n@s@@QAEXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1_2@@YAXPAU__block_literal_1_2@@@Z?0??n@s@@QAEXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1_1@@YAXPEAU__block_literal_1_1@@@Z?0??n@s@@QEAAXHH@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1_2@@YAXPEAU__block_literal_1_2@@@Z?0??n@s@@QEAAXHH@Z@4HA" ={{.*}} global i32 0
+
+};
+
+struct t {
+  struct u {
+int i = ^{ static int i = e(); return ++i; }();
+
+// CHECK-X86-DAG: @"\01?i@?0??_block_invoke_1@0u@t@@YAXPAU__block_literal_1@@@Z@4HA" ={{.*}} global i32 0
+// CHECK-X64-DAG: @"\01?i@?0??_block_invoke_1@0u@t@@YAXPEAU__block_literal_1@@@Z@4HA" ={{.*}} global i32 0
+
+  };
+};
+
+void j(void) {
+  h();
+  struct s s;

[PATCH] D34649: Remove addtional parameters in function std::next() and std::prev()

2017-06-26 Thread Jason Liu via Phabricator via cfe-commits
jasonliu created this revision.

Creating a function pointer with proper parameters pointing to std::next() or 
std::prev() should work.
This change moves the invented paramater for enable_if over to the return type 
to resolve this QoI issue.


https://reviews.llvm.org/D34649

Files:
  include/iterator
  test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp


Index: test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -22,6 +22,9 @@
 test(It i, typename std::iterator_traits::difference_type n, It x)
 {
 assert(std::prev(i, n) == x);
+
+It (*prev)(It, typename std::iterator_traits::difference_type) = 
std::prev;
+assert(prev(i, n) == x);
 }
 
 template 
Index: test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -24,6 +24,9 @@
 test(It i, typename std::iterator_traits::difference_type n, It x)
 {
 assert(std::next(i, n) == x);
+
+It (*next)(It, typename std::iterator_traits::difference_type) = 
std::next;
+assert(next(i, n) == x);
 }
 
 template 
Index: include/iterator
===
--- include/iterator
+++ include/iterator
@@ -604,21 +604,27 @@
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_InputIter
+typename enable_if
+<
+__is_input_iterator<_InputIter>::value, 
+_InputIter
+>::type
 next(_InputIter __x,
- typename iterator_traits<_InputIter>::difference_type __n = 1,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0)
+ typename iterator_traits<_InputIter>::difference_type __n = 1)
 {
 _VSTD::advance(__x, __n);
 return __x;
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_BidiretionalIter
+typename enable_if
+<
+__is_bidirectional_iterator<_BidiretionalIter>::value, 
+_BidiretionalIter
+>::type
 prev(_BidiretionalIter __x,
- typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
- typename 
enable_if<__is_bidirectional_iterator<_BidiretionalIter>::value>::type* = 0)
+ typename iterator_traits<_BidiretionalIter>::difference_type __n = 1)
 {
 _VSTD::advance(__x, -__n);
 return __x;


Index: test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -22,6 +22,9 @@
 test(It i, typename std::iterator_traits::difference_type n, It x)
 {
 assert(std::prev(i, n) == x);
+
+It (*prev)(It, typename std::iterator_traits::difference_type) = std::prev;
+assert(prev(i, n) == x);
 }
 
 template 
Index: test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -24,6 +24,9 @@
 test(It i, typename std::iterator_traits::difference_type n, It x)
 {
 assert(std::next(i, n) == x);
+
+It (*next)(It, typename std::iterator_traits::difference_type) = std::next;
+assert(next(i, n) == x);
 }
 
 template 
Index: include/iterator
===
--- include/iterator
+++ include/iterator
@@ -604,21 +604,27 @@
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_InputIter
+typename enable_if
+<
+__is_input_iterator<_InputIter>::value, 
+_InputIter
+>::type
 next(_InputIter __x,
- typename iterator_traits<_InputIter>::difference_type __n = 1,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0)
+ typename iterator_traits<_InputIter>::difference_type __n = 1)
 {
 _VSTD::advance(__x, __n);
 return __x;
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_BidiretionalIter
+typename enable_if
+<
+__is_bidirectional_iterator<_BidiretionalIter>::value, 
+_BidiretionalIter
+>::type
 prev(_BidiretionalIter __x,
- typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
- typename enable_if<__is_bidirectional_iterator<_BidiretionalIter>::value>::type* = 0)
+ typename iterator_traits<_BidiretionalIter>::difference_type __n = 1)
 {
 _VSTD::advance(__x, -__n);

[PATCH] D34649: Remove addtional parameters in function std::next() and std::prev()

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



Comment at: include/iterator:619
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14

Might fix the spelling error in "BidirectionalIter" while you're here.


https://reviews.llvm.org/D34649



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


[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

LGTM (with the caveat that I don't know anything about Microsoft mangling).


https://reviews.llvm.org/D34523



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


[PATCH] D34329: [GSoC] Clang AST diffing

2017-06-26 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 104032.
johannes added a comment.

refactor


https://reviews.llvm.org/D34329

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  lib/Tooling/ASTDiff/CMakeLists.txt
  lib/Tooling/CMakeLists.txt
  test/Tooling/clang-diff-basic.cpp
  tools/CMakeLists.txt
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- /dev/null
+++ tools/clang-diff/ClangDiff.cpp
@@ -0,0 +1,110 @@
+//===- ClangDiff.cpp - compare source files by AST nodes --*- C++ -*- -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements a tool for syntax tree based comparison using
+// Tooling/ASTDiff.
+//
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::tooling;
+
+static cl::OptionCategory ClangDiffCategory("clang-diff options");
+
+static cl::opt
+DumpAST("ast-dump",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt NoCompilationDatabase(
+"no-compilation-database",
+cl::desc(
+"Do not attempt to load build settings from a compilation database"),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt SourcePath(cl::Positional, cl::desc(""),
+   cl::Required,
+   cl::cat(ClangDiffCategory));
+
+static cl::opt DestinationPath(cl::Positional,
+cl::desc(""),
+cl::Optional,
+cl::cat(ClangDiffCategory));
+
+static std::unique_ptr getAST(const StringRef Filename) {
+  std::string ErrorMessage;
+  std::unique_ptr Compilations;
+  if (!NoCompilationDatabase)
+Compilations =
+CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
+  if (!Compilations) {
+if (!NoCompilationDatabase)
+  llvm::errs()
+  << "Error while trying to load a compilation database, running "
+ "without flags.\n"
+  << ErrorMessage;
+Compilations = llvm::make_unique(
+".", std::vector());
+  }
+  std::array Files = {{Filename}};
+  ClangTool Tool(*Compilations, Files);
+  std::vector> ASTs;
+  Tool.buildASTs(ASTs);
+  if (ASTs.size() != Files.size())
+return nullptr;
+  return std::move(ASTs[0]);
+}
+
+int main(int argc, const char **argv) {
+  cl::HideUnrelatedOptions(ClangDiffCategory);
+  if (!cl::ParseCommandLineOptions(argc, argv)) {
+cl::PrintOptionValues();
+return 1;
+  }
+
+  if (DumpAST) {
+if (!DestinationPath.empty()) {
+  llvm::errs() << "Error: Please specify exactly one filename.\n";
+  return 1;
+}
+std::unique_ptr AST = getAST(SourcePath);
+if (!AST)
+  return 1;
+diff::SyntaxTree Tree(AST->getASTContext());
+Tree.printAsJson(llvm::outs());
+return 0;
+  }
+
+  if (DestinationPath.empty()) {
+llvm::errs() << "Error: Exactly two paths are required.\n";
+return 1;
+  }
+
+  std::unique_ptr Src = getAST(SourcePath);
+  std::unique_ptr Dst = getAST(DestinationPath);
+  if (!Src || !Dst)
+return 1;
+
+  diff::ComparisonOptions Options;
+  diff::SyntaxTree SrcTree(Src->getASTContext());
+  diff::SyntaxTree DstTree(Dst->getASTContext());
+  diff::ASTDiff DiffTool(SrcTree, DstTree, &Options);
+  for (const auto &Match : DiffTool.getMatches())
+DiffTool.printMatch(llvm::outs(), Match);
+  for (const auto &Change : DiffTool.getChanges())
+DiffTool.printChange(llvm::outs(), Change);
+
+  return 0;
+}
Index: tools/clang-diff/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-diff/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_executable(clang-diff
+  ClangDiff.cpp
+  )
+
+target_link_libraries(clang-diff
+  clangFrontend
+  clangTooling
+  clangToolingASTDiff
+  )
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_subdirectory(diagtool)
 add_clang_subdirectory(driver)
+add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
Inde

r306343 - [clang] Enable printf check for CFIndex

2017-06-26 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Jun 26 16:02:27 2017
New Revision: 306343

URL: http://llvm.org/viewvc/llvm-project?rev=306343&view=rev
Log:
[clang] Enable printf check for CFIndex

According to 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
CFIndex and NSInteger should be treated the same way (see the section Platform 
Dependencies).
This diff changes the function shouldNotPrintDirectly in SemaChecking.cpp 
accordingly 
and adds tests for the "fixit" and the warning.

Differential revision: https://reviews.llvm.org/D34496

Test plan: make check-all

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/FixIt/fixit-format-darwin.m
cfe/trunk/test/FixIt/format-darwin.m

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=306343&r1=306342&r2=306343&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jun 26 16:02:27 2017
@@ -6000,6 +6000,7 @@ shouldNotPrintDirectly(const ASTContext
   while (const TypedefType *UserTy = TyTy->getAs()) {
 StringRef Name = UserTy->getDecl()->getName();
 QualType CastTy = llvm::StringSwitch(Name)
+  .Case("CFIndex", Context.LongTy)
   .Case("NSInteger", Context.LongTy)
   .Case("NSUInteger", Context.UnsignedLongTy)
   .Case("SInt32", Context.IntTy)

Modified: cfe/trunk/test/FixIt/fixit-format-darwin.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-format-darwin.m?rev=306343&r1=306342&r2=306343&view=diff
==
--- cfe/trunk/test/FixIt/fixit-format-darwin.m (original)
+++ cfe/trunk/test/FixIt/fixit-format-darwin.m Mon Jun 26 16:02:27 2017
@@ -8,12 +8,15 @@
 int printf(const char * restrict, ...);
 
 #if __LP64__
+typedef long CFIndex;
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
 #else
+typedef int CFIndex;
 typedef int NSInteger;
 typedef unsigned int NSUInteger;
 #endif
+CFIndex getCFIndex();
 NSInteger getNSInteger();
 NSUInteger getNSUInteger();
 
@@ -74,3 +77,10 @@ void bug33447() {
   Outer2("test 9: %s %s", getNSInteger(), getNSInteger());
   // CHECK: Outer2("test 9: %ld %ld", (long)getNSInteger(), 
(long)getNSInteger());
 }
+
+void testCFIndex() {
+  printf("test 10: %s", getCFIndex()); 
+  // CHECK: printf("test 10: %ld", (long)getCFIndex());
+  printf("test 11: %s %s", getCFIndex(), getCFIndex());
+  // CHECK: printf("test 11: %ld %ld", (long)getCFIndex(), (long)getCFIndex());
+}

Modified: cfe/trunk/test/FixIt/format-darwin.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/format-darwin.m?rev=306343&r1=306342&r2=306343&view=diff
==
--- cfe/trunk/test/FixIt/format-darwin.m (original)
+++ cfe/trunk/test/FixIt/format-darwin.m Mon Jun 26 16:02:27 2017
@@ -7,13 +7,14 @@
 int printf(const char * restrict, ...);
 
 #if __LP64__
+typedef long CFIndex;
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
 typedef int SInt32;
 typedef unsigned int UInt32;
 
 #else
-
+typedef int CFIndex;
 typedef int NSInteger;
 typedef unsigned int NSUInteger;
 typedef long SInt32;
@@ -27,6 +28,7 @@ typedef enum NSIntegerEnum : NSInteger {
   EnumValueB
 } NSIntegerEnum;
 
+CFIndex getCFIndex();
 NSInteger getNSInteger();
 NSUInteger getNSUInteger();
 SInt32 getSInt32();
@@ -55,6 +57,11 @@ void testCorrectionInAllCases() {
 
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
+
+  printf("%s", getCFIndex()); // expected-warning{{values of type 'CFIndex' 
should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
 }
 
 @interface Foo {
@@ -120,6 +127,11 @@ void testWarn() {
 
   // CHECK-64: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
   // CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
+
+  printf("%d", getCFIndex()); // expected-warning{{values of type 'CFIndex' 
should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+  // CHECK-64: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
+  // CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
 }
 
 void testPreserveHex() {
@@ -167,6 +179,10 @@ void testWarn() {
   printf("%ld", getNSIntegerEnum()); // expected-warning{{enum values with 
underlying type 'NSInteger' should not be used as format arguments; add an 
explicit cast to 'long' instead}}
 
   // CHECK-32: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:17}:"(long)"
+
+  printf("%ld", getCFIndex()); // expected-warning{{values of type 'CFIndex' 
should not be used as f

[PATCH] D34496: [clang] Fix printf check for CFIndex

2017-06-26 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306343: [clang] Enable printf check for CFIndex (authored by 
alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D34496?vs=103536&id=104038#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34496

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/FixIt/fixit-format-darwin.m
  cfe/trunk/test/FixIt/format-darwin.m

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -6000,6 +6000,7 @@
   while (const TypedefType *UserTy = TyTy->getAs()) {
 StringRef Name = UserTy->getDecl()->getName();
 QualType CastTy = llvm::StringSwitch(Name)
+  .Case("CFIndex", Context.LongTy)
   .Case("NSInteger", Context.LongTy)
   .Case("NSUInteger", Context.UnsignedLongTy)
   .Case("SInt32", Context.IntTy)
Index: cfe/trunk/test/FixIt/format-darwin.m
===
--- cfe/trunk/test/FixIt/format-darwin.m
+++ cfe/trunk/test/FixIt/format-darwin.m
@@ -7,13 +7,14 @@
 int printf(const char * restrict, ...);
 
 #if __LP64__
+typedef long CFIndex;
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
 typedef int SInt32;
 typedef unsigned int UInt32;
 
 #else
-
+typedef int CFIndex;
 typedef int NSInteger;
 typedef unsigned int NSUInteger;
 typedef long SInt32;
@@ -27,6 +28,7 @@
   EnumValueB
 } NSIntegerEnum;
 
+CFIndex getCFIndex();
 NSInteger getNSInteger();
 NSUInteger getNSUInteger();
 SInt32 getSInt32();
@@ -55,6 +57,11 @@
 
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
+
+  printf("%s", getCFIndex()); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
 }
 
 @interface Foo {
@@ -120,6 +127,11 @@
 
   // CHECK-64: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
   // CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
+
+  printf("%d", getCFIndex()); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+  // CHECK-64: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
+  // CHECK-64: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:16}:"(long)"
 }
 
 void testPreserveHex() {
@@ -167,6 +179,10 @@
   printf("%ld", getNSIntegerEnum()); // expected-warning{{enum values with underlying type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
 
   // CHECK-32: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:17}:"(long)"
+
+  printf("%ld", getCFIndex()); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
+
+  // CHECK-32: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:17}:"(long)"
 }
 
 void testPreserveHex() {
@@ -218,6 +234,11 @@
 
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:31}:"(long)"
+
+  printf("%s", (CFIndex)0); // expected-warning{{values of type 'CFIndex' should not be used as format arguments; add an explicit cast to 'long' instead}}
+  
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"%ld"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:16-[[@LINE-3]]:25}:"(long)"
 }
 
 void testCapitals() {
Index: cfe/trunk/test/FixIt/fixit-format-darwin.m
===
--- cfe/trunk/test/FixIt/fixit-format-darwin.m
+++ cfe/trunk/test/FixIt/fixit-format-darwin.m
@@ -8,12 +8,15 @@
 int printf(const char * restrict, ...);
 
 #if __LP64__
+typedef long CFIndex;
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
 #else
+typedef int CFIndex;
 typedef int NSInteger;
 typedef unsigned int NSUInteger;
 #endif
+CFIndex getCFIndex();
 NSInteger getNSInteger();
 NSUInteger getNSUInteger();
 
@@ -74,3 +77,10 @@
   Outer2("test 9: %s %s", getNSInteger(), getNSInteger());
   // CHECK: Outer2("test 9: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
 }
+
+void testCFIndex() {
+  printf("test 10: %s", getCFIndex()); 
+  // CHECK: printf("test 10: %ld", (long)getCFIndex());
+  printf("test 11: %s %s", getCFIndex(), getCFIndex());
+  // CHECK: printf("test 11: %ld %ld", (long)getCFIndex(), (long)getCFIndex());
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34329: [GSoC] Clang AST diffing

2017-06-26 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

I'd copy what Hal mentioned in other review thread for other GSoC project. You 
don't want to tag your patches with "[GSoC]" because it doesn't describe 
anything about patch contents and many other unrelated patches could have been 
tagged as single "[GSoC]" tag. Instead, you want to use some other tag that 
describe your patch. Looks like you are adding a new tool, so I'd guess that 
"[clang-diff]" could be a good tag.


https://reviews.llvm.org/D34329



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


r306346 - Revert r301742, which caused us to try to evaluate all full-expressions.

2017-06-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 26 16:19:32 2017
New Revision: 306346

URL: http://llvm.org/viewvc/llvm-project?rev=306346&view=rev
Log:
Revert r301742, which caused us to try to evaluate all full-expressions.

Also add testcases for a bunch of expression forms that cause our evaluator to
crash. See PR33140 and PR32864 for crashes that this was causing.

This reverts r305287, which reverted r305239, which reverted r301742. The
previous revert claimed that buildbots were broken, but did not add any
testcases and the buildbots have lost all memory of what was wrong here.

Changes to test/OpenMP are not reverted; another change has triggered those
tests to change their output in the same way that r301742 did.

Added:
cfe/trunk/test/SemaCXX/eval-crashes.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/integer-overflow.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=306346&r1=306345&r2=306346&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jun 26 16:19:32 2017
@@ -10276,6 +10276,7 @@ private:
   void CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr* RHS);
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
   void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
+  void CheckForIntOverflow(Expr *E);
   void CheckUnsequencedOperations(Expr *E);
 
   /// \brief Perform semantic checks on a completed expression. This will 
either

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=306346&r1=306345&r2=306346&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun 26 16:19:32 2017
@@ -6226,10 +6226,6 @@ bool RecordExprEvaluator::VisitInitListE
 // the initializer list.
 ImplicitValueInitExpr VIE(HaveInit ? Info.Ctx.IntTy : Field->getType());
 const Expr *Init = HaveInit ? E->getInit(ElementNo++) : &VIE;
-if (Init->isValueDependent()) {
-  Success = false;
-  continue;
-}
 
 // Temporarily override This, in case there's a CXXDefaultInitExpr in here.
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
@@ -9940,8 +9936,7 @@ static bool EvaluateAsRValue(EvalInfo &I
 }
 
 static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result,
- const ASTContext &Ctx, bool &IsConst,
- bool IsCheckingForOverflow) {
+ const ASTContext &Ctx, bool &IsConst) {
   // Fast-path evaluations of integer literals, since we sometimes see files
   // containing vast quantities of these.
   if (const IntegerLiteral *L = dyn_cast(Exp)) {
@@ -9962,7 +9957,7 @@ static bool FastEvaluateAsRValue(const E
   // performance problems. Only do so in C++11 for now.
   if (Exp->isRValue() && (Exp->getType()->isArrayType() ||
   Exp->getType()->isRecordType()) &&
-  !Ctx.getLangOpts().CPlusPlus11 && !IsCheckingForOverflow) {
+  !Ctx.getLangOpts().CPlusPlus11) {
 IsConst = false;
 return true;
   }
@@ -9977,7 +9972,7 @@ static bool FastEvaluateAsRValue(const E
 /// will be applied to the result.
 bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const {
   bool IsConst;
-  if (FastEvaluateAsRValue(this, Result, Ctx, IsConst, false))
+  if (FastEvaluateAsRValue(this, Result, Ctx, IsConst))
 return IsConst;
   
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
@@ -10102,7 +10097,7 @@ APSInt Expr::EvaluateKnownConstInt(const
 void Expr::EvaluateForOverflow(const ASTContext &Ctx) const {
   bool IsConst;
   EvalResult EvalResult;
-  if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst, true)) {
+  if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst)) {
 EvalInfo Info(Ctx, EvalResult, EvalInfo::EM_EvaluateForOverflow);
 (void)::EvaluateAsRValue(Info, this, EvalResult.Val);
   }

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=306346&r1=306345&r2=306346&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jun 26 16:19:32 2017
@@ -9936,6 +9936,28 @@ void Sema::CheckBoolLikeConversion(Expr
   ::CheckBoolLikeConversion(*this, E, CC);
 }
 
+/// Diagnose when expression is an integer constant expression and its 
evaluation
+/// results in integer overflow
+void Sema::CheckForIntOverflow (Expr *E) {
+  // Use a work list to deal with nested struct initializers

r306347 - AST: enhance mangling for blocks with MS ABI

2017-06-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jun 26 16:28:42 2017
New Revision: 306347

URL: http://llvm.org/viewvc/llvm-project?rev=306347&view=rev
Log:
AST: enhance mangling for blocks with MS ABI

When generating the decorated name for a static variable inside a
BlockDecl, construct a scope for the block invocation function that
homes the parameter. This allows for arbitrary nesting of the blocks
even if the variables are shadowed. Furthermore, using this for the name
allows for undname to properly undecorated the name for us. It shows up
as the synthetic __block_invocation function that the compiler emitted
in the local scope.

Added:
cfe/trunk/test/CodeGenCXX/msabi-blocks.cpp
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=306347&r1=306346&r2=306347&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Jun 26 16:28:42 2017
@@ -966,16 +966,71 @@ void MicrosoftCXXNameMangler::mangleNest
 }
 
 if (const BlockDecl *BD = dyn_cast(DC)) {
-  DiagnosticsEngine &Diags = Context.getDiags();
-  unsigned DiagID =
-  Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle a local inside this block yet");
-  Diags.Report(BD->getLocation(), DiagID);
-
-  // FIXME: This is completely, utterly, wrong; see ItaniumMangle
-  // for how this should be done.
-  Out << "__block_invoke" << Context.getBlockId(BD, false);
-  Out << '@';
+  auto Discriminate =
+  [](StringRef Name, const unsigned Discriminator,
+ const unsigned ParameterDiscriminator) -> std::string {
+std::string Buffer;
+llvm::raw_string_ostream Stream(Buffer);
+Stream << Name;
+if (Discriminator)
+  Stream << '_' << Discriminator;
+if (ParameterDiscriminator)
+  Stream << '_' << ParameterDiscriminator;
+return Stream.str();
+  };
+
+  unsigned Discriminator = BD->getBlockManglingNumber();
+  if (!Discriminator)
+Discriminator = Context.getBlockId(BD, /*Local=*/false);
+
+  // Mangle the parameter position as a discriminator to deal with unnamed
+  // parameters.  Rather than mangling the unqualified parameter name,
+  // always use the position to give a uniform mangling.
+  unsigned ParameterDiscriminator = 0;
+  if (const auto *MC = BD->getBlockManglingContextDecl())
+if (const auto *P = dyn_cast(MC))
+  if (const auto *F = dyn_cast(P->getDeclContext()))
+ParameterDiscriminator =
+F->getNumParams() - P->getFunctionScopeIndex();
+
+  DC = getEffectiveDeclContext(BD);
+
+  Out << '?';
+  mangleSourceName(Discriminate("_block_invoke", Discriminator,
+ParameterDiscriminator));
+  // If we have a block mangling context, encode that now.  This allows us
+  // to discriminate between named static data initializers in the same
+  // scope.  This is handled differently from parameters, which use
+  // positions to discriminate between multiple instances.
+  if (const auto *MC = BD->getBlockManglingContextDecl())
+if (!isa(MC))
+  if (const auto *ND = dyn_cast(MC))
+mangleUnqualifiedName(ND);
+  // MS ABI and Itanium manglings are in inverted scopes.  In the case of a
+  // RecordDecl, mangle the entire scope hierachy at this point rather than
+  // just the unqualified name to get the ordering correct.
+  if (const auto *RD = dyn_cast(DC))
+mangleName(RD);
+  else
+Out << '@';
+  // void __cdecl
+  Out << "YAX";
+  // struct __block_literal *
+  Out << 'P';
+  // __ptr64
+  if (PointersAre64Bit)
+Out << 'E';
+  Out << 'A';
+  mangleArtificalTagType(TTK_Struct,
+ Discriminate("__block_literal", Discriminator,
+  ParameterDiscriminator));
+  Out << "@Z";
+
+  // If the effective context was a Record, we have fully mangled the
+  // qualified name and do not need to continue.
+  if (isa(DC))
+break;
+  continue;
 } else if (const ObjCMethodDecl *Method = dyn_cast(DC)) {
   mangleObjCMethodName(Method);
 } else if (isa(DC)) {

Added: cfe/trunk/test/CodeGenCXX/msabi-blocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/msabi-blocks.cpp?rev=306347&view=auto
==
--- cfe/trunk/test/CodeGenCXX/msabi-blocks.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/msabi-blocks.cpp Mon Jun 26 16:28:42 2017
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -std=c++11 -fblocks -S -o 
- -emit-llvm

[PATCH] D34523: AST: mangle BlockDecls under MS ABI

2017-06-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r306347

Thanks @efriedma and @majnemer!


https://reviews.llvm.org/D34523



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


[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-26 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

I can merge this for you Andrew.


https://reviews.llvm.org/D34091



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


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-06-26 Thread Todd Lipcon via Phabricator via cfe-commits
toddlipcon created this revision.
toddlipcon added a project: clang-tools-extra.
Herald added a subscriber: JDevlieghere.

This patch adds the ability to specify a regex of headers to exclude from 
clang-tidy diagnostics. This is the inverse of the existing header regex.

In our project we want to do something like include src/.*.h but exclude 
src/some-thirdparty/.*.h. Given only a positive regex configuration, we would 
have had to list all directories aside from 'some-thirdparty' such as 
src/(foo|bar|baz|...)/, which isn't practical or maintainable.

A while back there was a thread 
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046203.html which 
suggested using extended regexes which offer negative lookahead assertions to 
achieve this, but it was rejected due to poor stdlib support. I think an 
"exclude" regex is also more familiar to users since it shows up commonly in 
tools like rsync/tar/etc.

(note: I previously posted this as https://reviews.llvm.org/D34415 but was 
asked to re-post it with cfe-commits as a subscriber. Sorry for the double-post)


Repository:
  rL LLVM

https://reviews.llvm.org/D34654

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst
  test/clang-tidy/file-filter.cpp

Index: test/clang-tidy/file-filter.cpp
===
--- test/clang-tidy/file-filter.cpp
+++ test/clang-tidy/file-filter.cpp
@@ -9,6 +9,7 @@
 //   file-filter\header*.h due to code order between '/' and '\\'.
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -exclude-header-filter='header1\.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5 %s
 
 #include "header1.h"
 // CHECK-NOT: warning:
@@ -19,6 +20,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: header1.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 #include "header2.h"
 // CHECK-NOT: warning:
@@ -29,6 +31,7 @@
 // CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
 // CHECK4: header2.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK5: header2.h:1:12: warning: single-argument constructors
 
 #include 
 // CHECK-NOT: warning:
@@ -39,6 +42,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: system-header.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: system-header.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 class A { A(int); };
 // CHECK: :[[@LINE-1]]:11: warning: single-argument constructors
@@ -49,6 +53,7 @@
 // CHECK3-QUIET: :[[@LINE-6]]:11: warning: single-argument constructors
 // CHECK4: :[[@LINE-7]]:11: warning: single-argument constructors
 // CHECK4-QUIET: :[[@LINE-8]]:11: warning: single-argument constructors
+// CHECK5: :[[@LINE-9]]:11: warning: single-argument constructors
 
 // CHECK-NOT: warning:
 // CHECK-QUIET-NOT: warning:
@@ -58,9 +63,10 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4-NOT: warning:
 // CHECK4-QUIET-NOT: warning:
+// CHECK5-NOT: warning:
 
 // CHECK: Suppressed 3 warnings (3 in non-user code)
-// CHECK: Use -header-filter=.* to display errors from all non-system headers.
+// CHECK: Use -header-filter=.* -exclude-header-filter='' to display errors from all non-system headers.
 // CHECK-QUIET-NOT: Suppressed
 // CHECK2: Suppressed 1 warnings (1 in non-user code)
 // CHECK2: Use -header-filter=.* {{.*}}
@@ -71,3 +77,5 @@
 // CHECK4-NOT: Suppressed {{.*}} warnings
 // CHECK4-NOT: Use -header-filter=.* {{.*}}
 // CHECK4-QUIET-NOT: Suppressed
+// CHECK5: Suppressed 2 warnings (2 in non-user code)
+// CHECK5: Use -header-filter=.* {{.*}}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -238,6 +238,7 @@
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
+  ExcludeHeaderFilterRegex: ''
   AnalyzeTemporaryDtors: false
   FormatStyle: none
   User:user
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -40,6 +40,7 @@
 

[PATCH] D34415: Allow passing a regex for headers to exclude from clang-tidy

2017-06-26 Thread Todd Lipcon via Phabricator via cfe-commits
toddlipcon abandoned this revision.
toddlipcon added a comment.

Re-posted as https://reviews.llvm.org/D34654


Repository:
  rL LLVM

https://reviews.llvm.org/D34415



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


r306349 - Fix this test to use a construct that actually forces struct layout to happen when testing -Wpadded.

2017-06-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 26 17:22:07 2017
New Revision: 306349

URL: http://llvm.org/viewvc/llvm-project?rev=306349&view=rev
Log:
Fix this test to use a construct that actually forces struct layout to happen 
when testing -Wpadded.

Modified:
cfe/trunk/test/Modules/diag-flags.cpp

Modified: cfe/trunk/test/Modules/diag-flags.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diag-flags.cpp?rev=306349&r1=306348&r2=306349&view=diff
==
--- cfe/trunk/test/Modules/diag-flags.cpp (original)
+++ cfe/trunk/test/Modules/diag-flags.cpp Mon Jun 26 17:22:07 2017
@@ -41,4 +41,4 @@ import diag_flags;
 #else
 // expected-no-diagnostics
 #endif
-unsigned n = sizeof(Padded);
+int arr[sizeof(Padded)];


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


[PATCH] D34590: [ubsan] Diagnose invalid uses of builtins (clang)

2017-06-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma resigned from this revision.
efriedma added a comment.

The check itself looks okay, but I'm not really familiar with the other ubsan 
bits.


https://reviews.llvm.org/D34590



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


r306350 - Remove redundant check.

2017-06-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 26 17:29:32 2017
New Revision: 306350

URL: http://llvm.org/viewvc/llvm-project?rev=306350&view=rev
Log:
Remove redundant check.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=306350&r1=306349&r2=306350&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Jun 26 17:29:32 2017
@@ -3455,12 +3455,6 @@ ASTReader::ReadModuleMapFileBlock(Record
   unsigned Idx = 0;
   F.ModuleMapPath = ReadPath(F, Record, Idx);
 
-  if (F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule) {
-// For an explicitly-loaded module, we don't care whether the original
-// module map file exists or matches.
-return Success;
-  }
-
   // Try to resolve ModuleName in the current header search context and
   // verify that it is found in the same module map file as we saved. If the
   // top-level AST file is a main file, skip this check because there is no


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


[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64

2017-06-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think there's something wrong with clang's implementation of __float128. It 
seems fundamentally incompatible with libstdc++'s __is_floating_point_helper 
mechanism. We can definitely take this patch to unblock things, but we should 
file a bug about investigating this all the way. This popped up in mingw, I 
forget elsewhere, and it's wasting peoples' time.


Repository:
  rL LLVM

https://reviews.llvm.org/D34018



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


[PATCH] D33278: [LLVM][x86][Inline Asm] - Enum support for MS syntax

2017-06-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:1382
+if (const MCConstantExpr *CE = 
+dyn_cast_or_null(Val)) {
+  StringRef ErrMsg;

rnk wrote:
> Please use clang-format here and elsewhere
not addressed?


Repository:
  rL LLVM

https://reviews.llvm.org/D33278



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


Re: [clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well

2017-06-26 Thread David Blaikie via cfe-commits
On Mon, Jun 26, 2017 at 5:31 AM Serge Pavlov  wrote:

> 2017-06-26 4:05 GMT+07:00 David Blaikie :
>
>> Ah, I see now then.
>>
>> I have a symlink from the root of my source directory pointing to the
>> compile_commands.json in my build directory.
>>
>> I have this so that the vim YouCompleteMe plugin (& any other clang
>> tools) can find it, as they usually should, for using tools with the
>> llvm/clang project...
>>
>> Sounds like this test is incompatible with using the tooling
>> infrastructure in the llvm/clang project?
>>
> Any test that relies on compilation database search can fail in such case.
> Maybe the root of the tools test could contain some special
> compile_commands.json so that the search will always end up in definite
> state?
>

Perhaps - or maybe tools could have a parameter limiting how many parent
directories to recurse up through? But yeah, dunno what the best solution
would be.


>
>
>>
>> On Sun, Jun 25, 2017, 10:24 AM Serge Pavlov  wrote:
>>
>>> 2017-06-25 0:52 GMT+07:00 David Blaikie :
>>>


 On Sat, Jun 24, 2017 at 10:08 AM Serge Pavlov 
 wrote:

> With CMAKE_EXPORT_COMPILE_COMMANDS the file compile_commands.json is
> created in the directory
> /tools/clang/tools/extra/test/clang-tidy/Output,
>

 I'd be really surprised if this is the case - why would
 cmake/ninja/makefiles put the compile commands for the whole LLVM
 project/build in that somewhat random subdirectory?

>>>
>>> I was wrong, these json files were not created by cmake run but appear
>>> during test run. The file created by cmake is in the build root.
>>>
>>>


> but the tests from
> /llvm/tools/clang/tools/extra/test/clang-tidy run in the
> directory /tools/clang/tools/extra/test/clang-tidy, which does
> not contain json files. So the test passes successfully. Ubuntu 16.04,
> cmake 3.5.1.
>

 Ah, perhaps you found a compile_commands for one of the test cases, not
 the one generated by CMake. CMake 3.5.1 doesn't support
 CMAKE_EXPORT_COMPILE_COMMANDS.

 It was added in 3.5.2, according to the documentation:
 https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html


>>>
>>> It was added in 2.8.5 according to documentation (
>>> http://clang.llvm.org/docs/JSONCompilationDatabase.html#supported-systems),
>>> at least the version 3.5.1 creates compilation databases.
>>>
>>> clang-tidy tries to create compilation database from source path,
>>> looking for compile_commands.json in the directory where provided source
>>> file resides and in all its parent directories. If source tree is in a
>>> subdirectory of build tree, then compile_commands.json in the build
>>> directory would be found and the test would fail. Is it your case?
>>>
>>>
> Thanks,
> --Serge
>
> 2017-06-24 9:42 GMT+07:00 David Blaikie :
>
>> Ping (+Manuel, perhaps he's got some ideas about this, given
>> background in the tooling & compilation database work, or could point 
>> this
>> to someone who does?)
>>
>>
>> On Thu, Jun 15, 2017 at 10:40 AM David Blaikie 
>> wrote:
>>
>>> https://sarcasm.github.io/notes/dev/compilation-database.html#cmake
>>>
>>> If you enable the CMAKE_EXPORT_COMPILE_COMMANDS option in cmake (&
>>> have a sufficiently recent cmake), then CMake will generate a
>>> compile_commands.json in the root of the build tree. The test finds 
>>> this &
>>> fails, instead of finding no compilation database & succeeding.
>>>
>>> (to use this, you can then symlink from the root of the source tree
>>> to point to this in your build tree - this is how I get YCM to work for 
>>> my
>>> LLVM builds & could work for other clang tools as well)
>>>
>>> On Thu, Jun 15, 2017 at 7:51 AM Serge Pavlov 
>>> wrote:
>>>
 2017-06-15 2:43 GMT+07:00 David Blaikie :

>
>
> On Wed, Jun 14, 2017, 8:17 AM Serge Pavlov 
> wrote:
>
>> 2017-06-14 4:24 GMT+07:00 David Blaikie :
>>
>>> Ah, I find that the test passes if I remove the
>>> compile_commands.json file from my build directory (I have Ninja 
>>> configured
>>> to generate a compile_commands.json file).
>>>
>>> Looks like what happens is it finds the compilation database and
>>> fails hard when the database doesn't contain a compile command for 
>>> the file
>>> in question. If the database is not found, it falls back to some 
>>> basic
>>> command behavior, perhaps?
>>>
>>>
>> You are right, constructor of `CommonOptionsParser` calls
>> `autoDetectFromSource` or `autoDetectFromDirectory` prior to final
>> construction of `FixedCompilationDatabase.
>>
>> Is there some way this test could be fixed to cope with this,
>>> otherwise it

[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-06-26 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

LGTM, but you should probably get approval from somebody a bit more senior with 
the project.




Comment at: include/__config:234-235
+// a MS compatibility version is specified.
 #  ifndef __MINGW32__
-#define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+#ifdef _MSC_VER
+#  define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library

bruno wrote:
> bcraig wrote:
> > majnemer wrote:
> > > compnerd wrote:
> > > > smeenai wrote:
> > > > > You can combine this into just
> > > > > 
> > > > > ```
> > > > > #  if defined(_MSC_VER) && !defined(__MINGW32__)
> > > > > ```
> > > > > 
> > > > > I don't know if `__MINGW32__` and `_MSC_VER` will ever be compiled 
> > > > > simultaneously. (clang never defines `_MSC_VER` for its MinGW 
> > > > > triples, for example.)
> > > > What if MinGW is built with clang/c2 and MSVC extensions?  I think that 
> > > > the two could be defined together.  What about cygwin and clang/c2?  I 
> > > > guess we can ignore that since cygwin is not under active development.
> > > > 
> > > > I think this really goes back to my idea for an additional flag to 
> > > > indicate the C library in use.  We can interpret it from the 
> > > > canonicalized triple that LLVM/clang use.
> > > clang/c2 is dead.
> > At some point, I would like to see (or will need to introduce) a flag for 
> > which Windows C library is in use (so I'm agreeing with / echoing 
> > @compnerd).  What all options are there right now?  There's the Visual 
> > Studio C-runtime (multiple versions), there's msvcrt (used by the OS and 
> > mingw), there's the ancient crtdll that we shouldn't ever support, and 
> > there's the kernel C runtime (I'm probably the only person that cares about 
> > that).
> > 
> > I will note that I don't like the name of the macro here.  _LIBCPP_MSVCRT 
> > implies that msvcrt.dll is being used, when it isn't.  I don't think that 
> > this patch needs to fix that naming though.
> Any suggestion on a new name instead of `_LIBCPP_MSVCRT` for a future patch?
_LIBCPP_MS_UCRT? (UCRT for universal C-runtime).  That's more accurate than 
MSVCRT, thought it still isn't entirely accurate, as the UCRT is only a subset 
of the full CRT.

Other brainstormed names...
_LIBCPP_MS_VISUAL_STUDIO_CRT
_LIBCPP_MSVS_CRT
_LIBCPP_MSVC_CRT
_LIBCPP_THE_REAL_MSVC_CRT



https://reviews.llvm.org/D34588



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


[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64

2017-06-26 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

Joerg declines to take this patch as it is, as there is no compiler-rt support 
for __float128 on i386 in compiler-rt. GCC knows __float128 on i386, amd64, 
i64, hppa, powerpc [some variations]; currently I focus on i386/amd64.

My proposal was to check if there is used libstdc++, and conditionally enable 
__float128 for i386/amd64?


Repository:
  rL LLVM

https://reviews.llvm.org/D34018



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


Re: r305850 - Preserve CXX method overrides in ASTImporter

2017-06-26 Thread David Blaikie via cfe-commits
On Tue, Jun 20, 2017 at 2:06 PM Lang Hames via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: lhames
> Date: Tue Jun 20 16:06:00 2017
> New Revision: 305850
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305850&view=rev
> Log:
> Preserve CXX method overrides in ASTImporter
>
> Summary:
> The ASTImporter should import CXX method overrides from the source context
> when it imports a method decl.
>
> Reviewers: spyffe, rsmith, doug.gregor
>
> Reviewed By: spyffe
>
> Differential Revision: https://reviews.llvm.org/D34371
>
> Modified:
> cfe/trunk/lib/AST/ASTDumper.cpp
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/tools/clang-import-test/clang-import-test.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=305850&r1=305849&r2=305850&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:06:00 2017
> @@ -1184,6 +1184,28 @@ void ASTDumper::VisitFunctionDecl(const
>   I != E; ++I)
>dumpCXXCtorInitializer(*I);
>
> +  if (const CXXMethodDecl *MD = dyn_cast(D))
> +if (MD->size_overridden_methods() != 0) {
>

I'd probably make sure CXXMethodDecl has a range-based accessor for
overridden_methods and call it once here, check begin != end, then use it
in the range-based for later. That way it'd avoid multiple lookups of the
CXXMethodDecl in the ASTContext.

Probably not a big deal/efficiency concern, but just a thought :)


> +  auto dumpOverride =
> +[=](const CXXMethodDecl *D) {
> +  SplitQualType T_split = D->getType().split();
> +  OS << D << " " << D->getParent()->getName() << "::"
> + << D->getName() << " '"
> + << QualType::getAsString(T_split) << "'";
> +};
> +
> +  dumpChild([=] {
> +auto FirstOverrideItr = MD->begin_overridden_methods();
> +OS << "Overrides: [ ";
> +dumpOverride(*FirstOverrideItr);
>

Why is this one ^ pulled out separately from the rest of the loop?


> +for (const auto *Override :
> +   llvm::make_range(FirstOverrideItr + 1,
> +MD->end_overridden_methods()))
> +  dumpOverride(Override);
> +OS << " ]";
> +  });
> +}
> +
>if (D->doesThisDeclarationHaveABody())
>  dumpStmt(D->getBody());
>  }
>
> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=305850&r1=305849&r2=305850&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
> +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jun 20 16:06:00 2017
> @@ -319,6 +319,9 @@ namespace clang {
>  bool ImportArrayChecked(const InContainerTy &InContainer, OIter
> Obegin) {
>return ImportArrayChecked(InContainer.begin(), InContainer.end(),
> Obegin);
>  }
> +
> +// Importing overrides.
> +void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl
> *FromMethod);
>};
>  }
>
> @@ -2025,6 +2028,9 @@ Decl *ASTNodeImporter::VisitFunctionDecl
>// Add this function to the lexical context.
>LexicalDC->addDeclInternal(ToFunction);
>
> +  if (auto *FromCXXMethod = dyn_cast(D))
> +ImportOverrides(cast(ToFunction), FromCXXMethod);
> +
>return ToFunction;
>  }
>
> @@ -5499,6 +5505,14 @@ Expr *ASTNodeImporter::VisitSubstNonType
>  Replacement);
>  }
>
> +void ASTNodeImporter::ImportOverrides(CXXMethodDecl *ToMethod,
> +  CXXMethodDecl *FromMethod) {
> +  for (auto *FromOverriddenMethod : FromMethod->overridden_methods())
> +ToMethod->addOverriddenMethod(
> +  cast(Importer.Import(const_cast(
> +FromOverriddenMethod;
> +}
> +
>  ASTImporter::ASTImporter(ASTContext &ToContext, FileManager
> &ToFileManager,
>   ASTContext &FromContext, FileManager
> &FromFileManager,
>   bool MinimalImport)
>
> Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=305850&r1=305849&r2=305850&view=diff
>
> ==
> --- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
> +++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Jun 20
> 16:06:00 2017
> @@ -17,7 +17,9 @@
>  #include "clang/Basic/TargetInfo.h"
>  #include "clang/Basic/TargetOptions.h"
>  #include "clang/CodeGen/ModuleBuilder.h"
> +#include "clang/Frontend/ASTConsumers.h"
>  #include "clang/Frontend/CompilerInstance.h"
> +#include "clang/Frontend/MultiplexConsumer.h"
>  #include "clang/Frontend/TextDiagnosticBuffer.h"
>  #include "clang/Lex/Lexe

[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-06-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Thinking more about this, on Windows, is there a strong reason to default to a 
different libc by default on Windows?  @bruno would reusing `-ffreestanding` 
work for you here?  Or is there something else that we can identify about the 
target environment that can indicate that the MS CRT is unavailable?  I think 
that what is weird to me about this is that this is not about compatibility 
with Visual Studio but about the underlying libc.  It feels like it would be 
similar in spirit to say that libc++ defaults to libSystem as the underlying 
libc on Linux.

@bcraig thoughts on `_LIBCPP_MS_CRT` as the alternate name?


https://reviews.llvm.org/D34588



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


  1   2   >