[PATCH] D26082: Support for Python 3 in libclang python bindings

2017-01-13 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

Sadly I can't run valgrind on macOS Sierra.

I'll try and look at the effects of bindings/python/clang/cindex.py L181 in 
more detail today.

Just out of curiosity, will you be using the Python 3 bindings for anything? If 
so what?


Repository:
  rL LLVM

https://reviews.llvm.org/D26082



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


[PATCH] D28667: [clang-tidy] Don't modernize-raw-string-literal if replacement is longer.

2017-01-13 Thread András Leitereg via Phabricator via cfe-commits
leanil created this revision.
leanil added reviewers: alexfh, LegalizeAdulthood, xazax.hun.
leanil added a subscriber: cfe-commits.
leanil added a project: clang-tools-extra.
Herald added a subscriber: JDevlieghere.

modernize-raw-string-literal suggests to replace e.g.:

  std::string s{ "foo \"" } with std::string s{R"(foo ")" };
  std::string s{ ":)\"" }   with std::string s{R"lit(:)")lit" };

which are not necessarily improvements.
Maybe it should only suggest replacements, that are not longer than the 
original.

Fixes PR30964


https://reviews.llvm.org/D28667

Files:
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.h
  test/clang-tidy/modernize-raw-string-literal.cpp


Index: test/clang-tidy/modernize-raw-string-literal.cpp
===
--- test/clang-tidy/modernize-raw-string-literal.cpp
+++ test/clang-tidy/modernize-raw-string-literal.cpp
@@ -91,6 +91,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw 
string literal
 // CHECK-FIXES: {{^}}char const *const HexPrintable(R"(@\)");{{$}}
 
+char const *const Concatenated("\"foo\""
+   "\"bar\"");
+// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: {{.*}} can be written as a raw 
string literal
+// CHECK-FIXES: {{^}}char const *const Concatenated(R"("foo""bar")");{{$}}
+
 char const *const prettyFunction(__PRETTY_FUNCTION__);
 char const *const function(__FUNCTION__);
 char const *const func(__func__);
Index: clang-tidy/modernize/RawStringLiteralCheck.h
===
--- clang-tidy/modernize/RawStringLiteralCheck.h
+++ clang-tidy/modernize/RawStringLiteralCheck.h
@@ -32,7 +32,7 @@
 private:
   void replaceWithRawStringLiteral(
   const ast_matchers::MatchFinder::MatchResult &Result,
-  const StringLiteral *Literal);
+  const StringLiteral *Literal, StringRef Replacement);
 
   std::string DelimiterStem;
 };
Index: clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -121,19 +121,24 @@
   if (Literal->getLocStart().isMacroID())
 return;
 
-  if (containsEscapedCharacters(Result, Literal))
-replaceWithRawStringLiteral(Result, Literal);
+  if (containsEscapedCharacters(Result, Literal)) {
+std::string Replacement = asRawStringLiteral(Literal, DelimiterStem);
+if (Replacement.length() <=
+Lexer::MeasureTokenLength(Literal->getLocStart(), 
*Result.SourceManager,
+  getLangOpts()))
+  replaceWithRawStringLiteral(Result, Literal, Replacement);
+  }
 }
 
 void RawStringLiteralCheck::replaceWithRawStringLiteral(
-const MatchFinder::MatchResult &Result, const StringLiteral *Literal) {
+const MatchFinder::MatchResult &Result, const StringLiteral *Literal,
+StringRef Replacement) {
   CharSourceRange CharRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Literal->getSourceRange()),
   *Result.SourceManager, getLangOpts());
   diag(Literal->getLocStart(),
"escaped string literal can be written as a raw string literal")
-  << FixItHint::CreateReplacement(
- CharRange, asRawStringLiteral(Literal, DelimiterStem));
+  << FixItHint::CreateReplacement(CharRange, Replacement);
 }
 
 } // namespace modernize


Index: test/clang-tidy/modernize-raw-string-literal.cpp
===
--- test/clang-tidy/modernize-raw-string-literal.cpp
+++ test/clang-tidy/modernize-raw-string-literal.cpp
@@ -91,6 +91,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal
 // CHECK-FIXES: {{^}}char const *const HexPrintable(R"(@\)");{{$}}
 
+char const *const Concatenated("\"foo\""
+   "\"bar\"");
+// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const Concatenated(R"("foo""bar")");{{$}}
+
 char const *const prettyFunction(__PRETTY_FUNCTION__);
 char const *const function(__FUNCTION__);
 char const *const func(__func__);
Index: clang-tidy/modernize/RawStringLiteralCheck.h
===
--- clang-tidy/modernize/RawStringLiteralCheck.h
+++ clang-tidy/modernize/RawStringLiteralCheck.h
@@ -32,7 +32,7 @@
 private:
   void replaceWithRawStringLiteral(
   const ast_matchers::MatchFinder::MatchResult &Result,
-  const StringLiteral *Literal);
+  const StringLiteral *Literal, StringRef Replacement);
 
   std::string DelimiterStem;
 };
Index: clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tidy/modernize/RawStringLit

[clang-tools-extra] r291892 - Fix the build of the include-fixer plugin for some shared cmake builds and MSVC.

2017-01-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jan 13 04:14:07 2017
New Revision: 291892

URL: http://llvm.org/viewvc/llvm-project?rev=291892&view=rev
Log:
Fix the build of the include-fixer plugin for some shared cmake builds and MSVC.

- The include fixer plugin does not directly depend on pthread, but can
pick up pthread references transitively through inlining. Just add
pthreads to the linked libs unconditionally.
- MSVC emits bogus warnings when including  and building without
exceptions. Blacklist the warnings explicitly.

Modified:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
clang-tools-extra/trunk/include-fixer/plugin/CMakeLists.txt

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?rev=291892&r1=291891&r2=291892&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h Fri Jan 13 
04:14:07 2017
@@ -13,8 +13,19 @@
 #include "SymbolIndex.h"
 #include "find-all-symbols/SymbolInfo.h"
 #include "llvm/ADT/StringRef.h"
+
+#ifdef _MSC_VER
+// Disable warnings from ppltasks.h transitively included by .
+#pragma warning(push)
+#pragma warning(disable:4530)
+#endif
+
 #include 
 
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
 namespace clang {
 namespace include_fixer {
 

Modified: clang-tools-extra/trunk/include-fixer/plugin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/plugin/CMakeLists.txt?rev=291892&r1=291891&r2=291892&view=diff
==
--- clang-tools-extra/trunk/include-fixer/plugin/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/plugin/CMakeLists.txt Fri Jan 13 
04:14:07 2017
@@ -9,4 +9,5 @@ add_clang_library(clangIncludeFixerPlugi
   clangParse
   clangSema
   clangTooling
+  ${PTHREAD_LIB}
   )


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


Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.

2017-01-13 Thread Benjamin Kramer via cfe-commits
Committed r291892. Should also resolve the bogus MSVC warnings.

On Fri, Jan 13, 2017 at 12:00 AM, Bill Seurer via cfe-commits
 wrote:
> On 01/10/2017 01:53 PM, Benjamin Kramer wrote:
>>
>> I didn't manage to reproduce this. Does adding ${PTHREAD_LIB} to
>> LINK_LIBS of tools/clang/tools/extra/include-fixer/plugin/CMakeLists.txt
>> help?
>
>
> That does seem to make it work.
>
>
>> On Tue, Jan 10, 2017 at 8:31 PM, Bill Seurer 
>> wrote:
>>>
>>> On 01/09/2017 09:18 AM, Benjamin Kramer via cfe-commits wrote:


 Author: d0k
 Date: Mon Jan  9 09:18:28 2017
 New Revision: 291446

 URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev
 Log:
 [include-fixer] Load symbol index asynchronously.

 We don't actually need the index until parse time, so fetch it in the
 background and start parsing. By the time it is actually needed it's
 likely that the loading phase has completed in the background.
>>>
>>>
>>>
>>> This update causes a linker error on ppc64le on a Release+Asserts+Shared
>>> build.
>>>
>>> cmake with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
>>> -DBUILD_SHARED_LIBS=ON
>>>
>>>
>>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/754
>>>
>>>
>>> Details:
>>>
>>> [117/123] Linking CXX shared library
>>> lib/libclangIncludeFixerPlugin.so.40.0svn
>>> FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++  -fPIC -fPIC
>>> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter
>>> -Wwrite-strings
>>> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
>>> -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
>>> -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections
>>> -fno-common
>>> -Woverloaded-virtual -fno-strict-aliasing -O3
>>> -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs
>>> -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib  -Wl,-O3
>>> -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o
>>> lib/libclangIncludeFixerPlugin.so.40.0svn
>>>
>>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
>>> lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn
>>> lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn
>>> lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn
>>> lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn
>>> -Wl,-rpath,"\$ORIGIN/../lib" && :
>>>
>>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0):
>>> undefined reference to `pthread_create'
>>> collect2: error: ld returned 1 exit status
>>> [117/123] Building CXX object
>>>
>>> tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o
>>> ninja: build stopped: subcommand failed.
>>> [1/7] Linking CXX shared library
>>> lib/libclangIncludeFixerPlugin.so.40.0svn
>>> FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++  -fPIC -fPIC
>>> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter
>>> -Wwrite-strings
>>> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
>>> -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
>>> -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections
>>> -fno-common
>>> -Woverloaded-virtual -fno-strict-aliasing -O3
>>> -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs
>>> -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib  -Wl,-O3
>>> -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o
>>> lib/libclangIncludeFixerPlugin.so.40.0svn
>>>
>>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
>>> lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn
>>> lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn
>>> lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn
>>> lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn
>>> -Wl,-rpath,"\$ORIGIN/../lib" && :
>>>
>>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0):
>>> undefined reference to `pthread_create'
>>> collect2: error: ld returned 1 exit status
>>>
>>>
>>>
>>>
>>>
 Modified:
 clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
 clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
 clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp
 clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
 clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

 Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
 URL:

 http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff


 =

[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D28080#644222, @yaxunl wrote:

> > @yaxunl Sam, I think it would be nice to describe your recent change for 
> > adding OpenCL extensions. Would you like to write up some text? Otherwise I 
> > can draft something and you can review. :)
>
> Anastasia, I am busy with some other work. If you can add it I will be happy 
> to review it. Thanks!


Sure. No worries!


https://reviews.llvm.org/D28080



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


[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-13 Thread Pekka Jääskeläinen via Phabricator via cfe-commits
pekka.jaaskelainen accepted this revision.
pekka.jaaskelainen added inline comments.
This revision is now accepted and ready to land.



Comment at: docs/UsersManual.rst:2130
+
+- x86 is used by some implementations that are x86 compatible
+  (e.g. `POCL `_) and currently remains for backwards

Anastasia wrote:
> pekka.jaaskelainen wrote:
> > Anastasia wrote:
> > > pekka.jaaskelainen wrote:
> > > > This is a bit confusing paragraph, probably due to my confusing 
> > > > explanations of the problems with pocl. Currently pocl tries not to use 
> > > > FASM for preserving logical AS IDs to LLVM IR due to the bunch of 
> > > > problems it constantly produces with seemingly little benefits for 
> > > > common CPUs. My patch related to this considered only the argument info 
> > > > switch. Now pocl only derives the logical iDS from kernel arguments 
> > > > (and all other IDs within the body of the IR function are lost for flat 
> > > > machines).  In my patch, the argument info's address space IDs were 
> > > > made constant and identical to SPIR's as previously they were the 
> > > > target's (which meant losing the AS IDs altogether for flat AS 
> > > > machines).
> > > > 
> > > > You seem to document the arg-info md switch later, so this paragraph 
> > > > might be removed or converted to my pocl blurb which mentions the need 
> > > > for further processing for CPUs.
> > > Yes, it's perhaps a bit confusing indeed. I find the usage of the x86 
> > > backend for OpenCL is generally a bit confusing. Also there are a lot of 
> > > program paths even in Clang that don't play well for OpenCL purposes or 
> > > are not handled properly and are therefore a source of bugs.
> > > 
> > > I was just wondering whether it would be possible to switch to using SPIR 
> > > as a generic target at some point in the future and "deprecate" the x86 
> > > target for OpenCL . Do you think this might work for POCL? At the same 
> > > time we have upcoming SPIR-V support as a new feature that might reshape 
> > > things.
> > > 
> > > Regarding the address space I just know that it's common to use fake 
> > > address space map with the x86 backend for some out of tree 
> > > implementations to add missing memory segments to this target. That's why 
> > > I added this text here.
> > > 
> > > 
> > We have considered using SPIR internally, but it is likely to bring the 
> > same problems as with the FASM as we need to convert to the target bitcode 
> > to ensure all target specific IR level optimizations (especially 
> > vectorization) is applied properly. Why do you think using the real target 
> > when generating from OpenCL C kernels is problematic? 
> Perhaps, it would be nice to understand better how you use x86 backend in 
> your toolchain. What I have seen in some projects that some invalid IR was 
> produced or Clang hit an asset in the place which has to be done differently 
> in some CodeGen paths just for OpenCL. So the typical fix for this to 
> specialize on the OpenCL is not that easy to get into upstream because the 
> target hasn't been created for what it's being used for and people like to 
> see more modular code in general anyways.
> 
> The target is ideally not just a processor architecture but a combination of 
> hardware and runtime software layers (i.e. OpenCL runtime in our case). Btw 
> what triple do you use exactly while compiling OpenCL for x86?
We use just the regular target triplet without any opencl specific parts.This 
is because of at least two reasons a) we link in builtins as target-specific 
bitcodes b) we want to ensure all ordinary LLVM IR optimizations (some of which 
are target specific) are applied to the fully linked kernel bitcode to get all 
the performance improvements. Apart from the address spaces, I'm not sure which 
OpenCL-specific code paths you might mean in the code gen. I'd turn it the 
other way: if there's no need such special casing, it's better to do like with 
other frontends and have the usual hardware target instead of SPIR (which then 
needs to be converted to the target IR just for optimizations and bitcode 
linking).



Comment at: docs/UsersManual.rst:2133
+
+- x86 is used by some implementations that are x86 compatible and currently
+  remains for backwards compatibility (with older implementations prior to

Anastasia wrote:
> pekka.jaaskelainen wrote:
> > ARM (and others) are treated similarly in pocl: OpenCL C is just yet 
> > another frontend language in this picture, like C/C++. I would not 
> > "deprecate" that path as of yet as forcing to another intermediate 
> > representation (which SPIR basically is, albeit derived from LLVM IR) 
> > always loses some information on the way.
> I have removed the deprecation bit from the documentation now. Do you want me 
> to change anything else here?
> 
> I think the idea of SPIR target was not to force the developers to yet 
> another IR 

[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-01-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: gparker42, mehdi_amini, erik.pilkington.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch adds a new error that disallows methods that have parameters/return 
values with a vector type on certain older X86 targets. This is diagnostic is 
needed because objc_msgSend doesn't support SIMD vector registers/return values 
on X86 in iOS < 9 and OS X < 10.11.


Repository:
  rL LLVM

https://reviews.llvm.org/D28670

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclBase.cpp
  lib/Sema/SemaDeclObjC.cpp
  test/SemaObjC/x86-method-vector-values.m

Index: test/SemaObjC/x86-method-vector-values.m
===
--- /dev/null
+++ test/SemaObjC/x86-method-vector-values.m
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -verify -triple=i686-apple-macosx10.10 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -triple=i686-apple-macosx10.4 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -triple=i686-apple-darwin14 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -triple=i686-apple-ios8 -Wno-objc-root-class %s
+
+// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-macosx10.11 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-darwin15 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DIOS -triple=i686-apple-ios9 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-watchos -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-tvos -Wno-objc-root-class %s
+
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=x86_64-apple-macosx10.10 -Wno-objc-root-class %s
+
+// rdar://21662309
+
+typedef __attribute__((__ext_vector_type__(3))) float float3;
+
+#define AVAILABLE_MACOS_10_10 __attribute__((availability(macos, introduced = 10.10)))
+#define AVAILABLE_MACOS_10_11 __attribute__((availability(macos, introduced = 10.11)))
+
+#define AVAILABLE_IOS_8 __attribute__((availability(ios, introduced = 8.0)))
+#define AVAILABLE_IOS_9 __attribute__((availability(ios, introduced = 9.0)))
+
+@interface VectorMethods
+
+-(void)takeVector:(float3)v; // there should be no diagnostic at declaration
+
+@end
+
+@implementation VectorMethods
+
+#ifndef ALLOW
+
+-(void)takeVector:(float3)v { // expected-error {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+}
+
+-(float3)retVector { // expected-error {{'float3' (vector of 3 'float' values) return value is unsupported for this target}}
+}
+
+-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 { // expected-error {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+}
+
+-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // expected-error {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+}
+
+-(void)takeVector4:(float3)v AVAILABLE_IOS_8 { // expected-error {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+}
+
+-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // expected-error {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+}
+
+#else
+
+-(void)takeVector:(float3)v {
+}
+
+-(float3)retVector {
+  return 0;
+}
+
+-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 {
+#ifdef MAC
+// expected-error@-2 {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+#endif
+}
+
+-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // no error
+}
+
+-(void)takeVector4:(float3)v AVAILABLE_IOS_8 {
+#ifdef IOS
+  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter is unsupported for this target}}
+#endif
+}
+
+-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // no error
+}
+
+#ifdef OTHER
+// expected-no-diagnostics
+#endif
+
+#endif
+
+-(void)doStuff:(int)m { // no error
+}
+
+@end
Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -4302,6 +4302,47 @@
   }
 }
 
+/// Verify that the method parameters/return value have types that are supported
+/// by the x86 target.
+static void checkObjCMethodX86VectorTypes(Sema &SemaRef,
+  const ObjCMethodDecl *Method) {
+  SourceLocation Loc;
+  QualType T;
+  for (const ParmVarDecl *P : Method->parameters()) {
+if (P->getType()->isVectorType()) {
+  Loc = P->getLocStart();
+  T = P->getType();
+  break;
+}
+  }
+  if (Loc.isInvalid()) {
+if (Method->getReturnType()->isVectorType()) {
+  Loc = Method->getReturnTypeSourceRange().getBegin();
+  T = Method->getReturnType();
+} else
+  return;
+  }
+
+  // Vector parameters/return values are not supported by objc_msgSend on x86 in
+  // iOS < 9 and macOS < 10.11.
+  const auto &Triple = SemaRef.getASTContext()

[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-01-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: hokein.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D28671

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

You also need to add a new generated document 
(`docs/LibASTMatchersReference.html`) for that. Please run 
`clang/docs/tools/dump_ast_matchers.py`, it will do the stuff for you.


https://reviews.llvm.org/D28671



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


Re: r284890 - DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.

2017-01-13 Thread Dimitry Andric via cfe-commits
On 22 Oct 2016, at 00:00, Richard Smith via cfe-commits 
 wrote:
> 
> Author: rsmith
> Date: Fri Oct 21 17:00:42 2016
> New Revision: 284890
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=284890&view=rev
> Log:
> DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
> This has two significant effects:
> 
> 1) Direct relational comparisons between null pointer constants (0 and 
> nullopt)
>   and pointers are now ill-formed. This was always the case for C, and it
>   appears that C++ only ever permitted by accident. For instance, cases like
> nullptr < &a
>   are now rejected.
> 
> 2) Comparisons and conditional operators between differently-cv-qualified
>   pointer types now work, and produce a composite type that both source
>   pointer types can convert to (when possible). For instance, comparison
>   between 'int **' and 'const int **' is now valid, and uses an intermediate
>   type of 'const int *const *'.
> 
> Clang previously supported #2 as an extension.
> 
> We do not accept the cases in #1 as an extension. I've tested a fair amount of
> code to check that this doesn't break it, but if it turns out that someone is
> relying on this, we can easily add it back as an extension.
> 
> This is a re-commit of r284800.

Hi Richard,

This indeed leads to a bit of breakage when we compile lots of FreeBSD ports, 
for example openjdk7 (https://bugs.freebsd.org/216016), ptlib 
(https://bugs.freebsd.org/216019), spidermonkey24 
(https://bugs.freebsd.org/216010), and webkit-qt4 
(https://bugs.freebsd.org/216015) will now produce errors similar to:

vidinput_v4l.cxx:981:23: error: ordered comparison between pointer and zero 
('BYTE *' (aka 'unsigned char *') and 'int')
  if (videoBuffer < 0) {
  ~~~ ^ ~

There will probably be more of these.  Is it the intent of this change that 
such software must now be patched up?

-Dimitry



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28672: [ASTMatchers] update doc by running dump_ast_matchers.py

2017-01-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: klimek.
ioeric added a subscriber: cfe-commits.

https://reviews.llvm.org/D28672

Files:
  docs/LibASTMatchersReference.html

Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -111,7 +111,7 @@
 
 
 
-MatcherDecl>accessSpecDeclMatcherAccessSpecDecl>...
+MatcheraccessSpecDeclMatcherAccessSpecDecl>...
 Matches C++ access specifier declarations.
 
 Given
@@ -124,15 +124,15 @@
 
 
 
-MatcherDecl>classTemplateDeclMatcherClassTemplateDecl>...
+MatcherclassTemplateDeclMatcherClassTemplateDecl>...
 Matches C++ class template declarations.
 
 Example matches Z
   template class Z {};
 
 
 
-MatcherDecl>classTemplateSpecializationDeclMatcherClassTemplateSpecializationDecl>...
+MatcherclassTemplateSpecializationDeclMatcherClassTemplateSpecializationDecl>...
 Matches C++ class template specializations.
 
 Given
@@ -144,7 +144,7 @@
 
 
 
-MatcherDecl>cxxConstructorDeclMatcherCXXConstructorDecl>...
+MatchercxxConstructorDeclMatcherCXXConstructorDecl>...
 Matches C++ constructor declarations.
 
 Example matches Foo::Foo() and Foo::Foo(int)
@@ -157,15 +157,15 @@
 
 
 
-MatcherDecl>cxxConversionDeclMatcherCXXConversionDecl>...
+MatchercxxConversionDeclMatcherCXXConversionDecl>...
 Matches conversion operator declarations.
 
 Example matches the operator.
   class X { operator int() const; };
 
 
 
-MatcherDecl>cxxDestructorDeclMatcherCXXDestructorDecl>...
+MatchercxxDestructorDeclMatcherCXXDestructorDecl>...
 Matches explicit C++ destructor declarations.
 
 Example matches Foo::~Foo()
@@ -176,24 +176,24 @@
 
 
 
-MatcherDecl>cxxMethodDeclMatcherCXXMethodDecl>...
+MatchercxxMethodDeclMatcherCXXMethodDecl>...
 Matches method declarations.
 
 Example matches y
   class X { void y(); };
 
 
 
-MatcherDecl>cxxRecordDeclMatcherCXXRecordDecl>...
+MatchercxxRecordDeclMatcherCXXRecordDecl>...
 Matches C++ class declarations.
 
 Example matches X, Z
   class X;
   template class Z {};
 
 
 
-MatcherDecl>declMatcherDecl>...
+MatcherdeclMatcher...
 Matches declarations.
 
 Examples matches X, C, and the friend declaration inside C;
@@ -204,7 +204,7 @@
 
 
 
-MatcherDecl>declaratorDeclMatcherDeclaratorDecl>...
+MatcherdeclaratorDeclMatcherDeclaratorDecl>...
 Matches declarator declarations (field, variable, function
 and non-type template parameter declarations).
 
@@ -215,7 +215,7 @@
 
 
 
-MatcherDecl>enumConstantDeclMatcherEnumConstantDecl>...
+MatcherenumConstantDeclMatcherEnumConstantDecl>...
 Matches enum constants.
 
 Example matches A, B, C
@@ -225,7 +225,7 @@
 
 
 
-MatcherDecl>enumDeclMatcher

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not used}}
+

malcolm.parsons wrote:
> I don't know why the unevaluated context warning didn't work here.
Hmm, it should have, come to think of it. I don't think that's an odr-use (when 
I get near a standard, I'll double-check), and it is unevaluated. Worth poking 
at.


https://reviews.llvm.org/D28467



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


[PATCH] D28144: clang support for Mageia 6 distro

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

lgtm


https://reviews.llvm.org/D28144



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


[PATCH] D28334: [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

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

This looks useful to me.


https://reviews.llvm.org/D28334



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not used}}
+

aaron.ballman wrote:
> malcolm.parsons wrote:
> > I don't know why the unevaluated context warning didn't work here.
> Hmm, it should have, come to think of it. I don't think that's an odr-use 
> (when I get near a standard, I'll double-check), and it is unevaluated. Worth 
> poking at.
The unevaluated context warning worked on line 38 where it's not in a template 
and on line 85 where it's `sizeof` instead of `decltype`.

Somehow the template instantiation is avoiding some work when the capture 
doesn't have a dependent type.


https://reviews.llvm.org/D28467



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not used}}
+

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > I don't know why the unevaluated context warning didn't work here.
> > Hmm, it should have, come to think of it. I don't think that's an odr-use 
> > (when I get near a standard, I'll double-check), and it is unevaluated. 
> > Worth poking at.
> The unevaluated context warning worked on line 38 where it's not in a 
> template and on line 85 where it's `sizeof` instead of `decltype`.
> 
> Somehow the template instantiation is avoiding some work when the capture 
> doesn't have a dependent type.
That might make some degree of sense. Btw, I did double check, and it's 
definitely not an odr-use.

I think this edge case can be handled in a follow-up patch if you want to get 
the primary work in. If you'd prefer to have it fixed for the initial commit, 
that's obviously fine too.


https://reviews.llvm.org/D28467



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


r291905 - [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 09:01:06 2017
New Revision: 291905

URL: http://llvm.org/viewvc/llvm-project?rev=291905&view=rev
Log:
[Sema] Add warning for unused lambda captures

Summary:
Warn when a lambda explicitly captures something that is not used in its body.

The warning is part of -Wunused and can be enabled with -Wunused-lambda-capture.

Reviewers: rsmith, arphaman, jbcoe, aaron.ballman

Subscribers: Quuxplusone, arphaman, cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
cfe/trunk/test/SemaCXX/uninitialized.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=291905&r1=291904&r2=291905&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 13 09:01:06 2017
@@ -480,6 +480,7 @@ def UnusedFunction : DiagGroup<"unused-f
 def UnusedMemberFunction : DiagGroup<"unused-member-function",
  [UnneededMemberFunction]>;
 def UnusedLabel : DiagGroup<"unused-label">;
+def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
 def UnusedParameter : DiagGroup<"unused-parameter">;
 def UnusedResult : DiagGroup<"unused-result">;
 def PotentiallyEvaluatedExpression : 
DiagGroup<"potentially-evaluated-expression">;
@@ -617,8 +618,9 @@ def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
-UnusedPrivateField, UnusedLocalTypedef,
-UnusedValue, UnusedVariable, UnusedPropertyIvar]>,
+UnusedPrivateField, UnusedLambdaCapture,
+UnusedLocalTypedef, UnusedValue, UnusedVariable,
+UnusedPropertyIvar]>,
 DiagCategory<"Unused Entity Issue">;
 
 // Format settings.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291905&r1=291904&r2=291905&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13 09:01:06 
2017
@@ -316,6 +316,9 @@ def warn_unneeded_member_function : Warn
   InGroup, DefaultIgnore;
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup, DefaultIgnore;
+def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
+  "%select{used|required to be captured for use in an unevaluated context}1">,
+  InGroup, DefaultIgnore;
 
 def warn_parameter_size: Warning<
   "%0 is a large (%1 bytes) pass-by-value argument; "

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=291905&r1=291904&r2=291905&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Fri Jan 13 09:01:06 2017
@@ -452,6 +452,14 @@ public:
 /// non-static data member that would hold the capture.
 QualType CaptureType;
 
+/// \brief Whether an explicit capture has been odr-used in the body of the
+/// lambda.
+bool ODRUsed;
+
+/// \brief Whether an explicit capture has been non-odr-used in the body of
+/// the lambda.
+bool NonODRUsed;
+
   public:
 Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
 SourceLocation Loc, SourceLocation EllipsisLoc,
@@ -460,7 +468,8 @@ public:
   InitExprAndCaptureKind(
   Cpy, !Var ? Cap_VLA : Block ? Cap_Block : ByRef ? Cap_ByRef
   : Cap_ByCopy),
-  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType) {}
+  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType),
+  O

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291905: [Sema] Add warning for unused lambda captures 
(authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D28467?vs=84122&id=84305#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28467

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/ScopeInfo.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
  cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
  cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
  cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
  cfe/trunk/test/SemaCXX/uninitialized.cpp
  cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -5323,6 +5323,9 @@
   ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
  Scope *CurScope);
 
+  /// \brief Diagnose if an explicit lambda capture is unused.
+  void DiagnoseUnusedLambdaCapture(const sema::LambdaScopeInfo::Capture &From);
+
   /// \brief Complete a lambda-expression having processed and attached the
   /// lambda body.
   ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
Index: cfe/trunk/include/clang/Sema/ScopeInfo.h
===
--- cfe/trunk/include/clang/Sema/ScopeInfo.h
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h
@@ -452,23 +452,33 @@
 /// non-static data member that would hold the capture.
 QualType CaptureType;
 
+/// \brief Whether an explicit capture has been odr-used in the body of the
+/// lambda.
+bool ODRUsed;
+
+/// \brief Whether an explicit capture has been non-odr-used in the body of
+/// the lambda.
+bool NonODRUsed;
+
   public:
 Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
 SourceLocation Loc, SourceLocation EllipsisLoc,
 QualType CaptureType, Expr *Cpy)
 : VarAndNestedAndThis(Var, IsNested ? IsNestedCapture : 0),
   InitExprAndCaptureKind(
   Cpy, !Var ? Cap_VLA : Block ? Cap_Block : ByRef ? Cap_ByRef
   : Cap_ByCopy),
-  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType) {}
+  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType),
+  ODRUsed(false), NonODRUsed(false) {}
 
 enum IsThisCapture { ThisCapture };
 Capture(IsThisCapture, bool IsNested, SourceLocation Loc,
 QualType CaptureType, Expr *Cpy, const bool ByCopy)
 : VarAndNestedAndThis(
   nullptr, (IsThisCaptured | (IsNested ? IsNestedCapture : 0))),
   InitExprAndCaptureKind(Cpy, ByCopy ? Cap_ByCopy : Cap_ByRef),
-  Loc(Loc), EllipsisLoc(), CaptureType(CaptureType) {}
+  Loc(Loc), EllipsisLoc(), CaptureType(CaptureType), ODRUsed(false),
+  NonODRUsed(false) {}
 
 bool isThisCapture() const {
   return VarAndNestedAndThis.getInt() & IsThisCaptured;
@@ -491,6 +501,9 @@
 bool isNested() const {
   return VarAndNestedAndThis.getInt() & IsNestedCapture;
 }
+bool isODRUsed() const { return ODRUsed; }
+bool isNonODRUsed() const { return NonODRUsed; }
+void markUsed(bool IsODRUse) { (IsODRUse ? ODRUsed : NonODRUsed) = true; }
 
 VarDecl *getVariable() const {
   return VarAndNestedAndThis.getPointer();
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -480,6 +480,7 @@
 def UnusedMemberFunction : DiagGroup<"unused-member-function",
  [UnneededMemberFunction]>;
 def UnusedLabel : DiagGroup<"unused-label">;
+def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
 def UnusedParameter : DiagGroup<"unused-parameter">;
 def UnusedResult : DiagGroup<"unused-result">;
 def PotentiallyEvaluatedExpression : DiagGroup<"potentially-evaluated-expression">;
@@ -617,8 +618,9 @@
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
 // UnusedMemberFunction, (clean-up llvm before enabling)
-UnusedPrivateField, UnusedLocalTypedef,
-UnusedValue, UnusedVariable, UnusedPropertyIvar]>,
+UnusedPrivateField, Unuse

Re: r284890 - DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.

2017-01-13 Thread Richard Smith via cfe-commits
On 13 Jan 2017 4:40 am, "Dimitry Andric via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

On 22 Oct 2016, at 00:00, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>
> Author: rsmith
> Date: Fri Oct 21 17:00:42 2016
> New Revision: 284890
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284890&view=rev
> Log:
> DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type'
rules.
> This has two significant effects:
>
> 1) Direct relational comparisons between null pointer constants (0 and
nullopt)
>   and pointers are now ill-formed. This was always the case for C, and it
>   appears that C++ only ever permitted by accident. For instance, cases
like
> nullptr < &a
>   are now rejected.
>
> 2) Comparisons and conditional operators between differently-cv-qualified
>   pointer types now work, and produce a composite type that both source
>   pointer types can convert to (when possible). For instance, comparison
>   between 'int **' and 'const int **' is now valid, and uses an
intermediate
>   type of 'const int *const *'.
>
> Clang previously supported #2 as an extension.
>
> We do not accept the cases in #1 as an extension. I've tested a fair
amount of
> code to check that this doesn't break it, but if it turns out that
someone is
> relying on this, we can easily add it back as an extension.
>
> This is a re-commit of r284800.

Hi Richard,

This indeed leads to a bit of breakage when we compile lots of FreeBSD
ports, for example openjdk7 (https://bugs.freebsd.org/216016), ptlib (
https://bugs.freebsd.org/216019), spidermonkey24 (https://bugs.freebsd.org/
216010), and webkit-qt4 (https://bugs.freebsd.org/216015) will now produce
errors similar to:

vidinput_v4l.cxx:981:23: error: ordered comparison between pointer and zero
('BYTE *' (aka 'unsigned char *') and 'int')
  if (videoBuffer < 0) {
  ~~~ ^ ~

There will probably be more of these.  Is it the intent of this change that
such software must now be patched up?


That is the intent; such code is not valid c++ any more per the latest
defect resolutions (and is not valid C). Depending on the level of pain, we
could allow these comparisons as an extension, so I would welcome your
input here. However (for instance) the example above looks like a bug.

-Dimitry


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


r291907 - Revert "Support for Python 3 in libclang python bindings"

2017-01-13 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Fri Jan 13 10:06:59 2017
New Revision: 291907

URL: http://llvm.org/viewvc/llvm-project?rev=291907&view=rev
Log:
Revert "Support for Python 3 in libclang python bindings"

This reverts commit 4464581bb63e9789e9ee231a8c8800be5f614743.

Memory access issues on Linux were reported by Mathieu Duponchelle and
discussed here: https://reviews.llvm.org/D26082.

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=291907&r1=291906&r2=291907&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Fri Jan 13 10:06:59 2017
@@ -64,7 +64,6 @@ call is efficient.
 
 from ctypes import *
 import collections
-import sys
 
 import clang.enumerations
 
@@ -74,33 +73,6 @@ import clang.enumerations
 # this by marshalling object arguments as void**.
 c_object_p = POINTER(c_void_p)
 
-if sys.version_info[0] > 2:
-# Python 3 strings are unicode, translate them to/from utf8 for C-interop
-# Python 3 replaces xrange with range, we want xrange behaviour
-xrange = range
-
-class c_string_p(c_char_p):
-def __init__(self, p=None):
-if type(p) == str:
-p = p.encode("utf8")
-super(c_char_p, self).__init__(p)
-
-def __str__(self):
-return str(self.value)
-
-@property
-def value(self):
-if super(c_char_p, self).value is None:
-return None
-return super(c_char_p, self).value.decode("utf8")
-
-@classmethod
-def from_param(cls, param):
-return cls(param)
-else:
-c_string_p = c_char_p
-
-
 callbacks = {}
 
 ### Exception Classes ###
@@ -175,7 +147,7 @@ class CachedProperty(object):
 class _CXString(Structure):
 """Helper for transforming CXString results."""
 
-_fields_ = [("spelling", c_string_p), ("free", c_int)]
+_fields_ = [("spelling", c_char_p), ("free", c_int)]
 
 def __del__(self):
 conf.lib.clang_disposeString(self)
@@ -357,7 +329,7 @@ class Diagnostic(object):
 
 @property
 def spelling(self):
-return str(conf.lib.clang_getDiagnosticSpelling(self))
+return conf.lib.clang_getDiagnosticSpelling(self)
 
 @property
 def ranges(self):
@@ -386,8 +358,8 @@ class Diagnostic(object):
 
 def __getitem__(self, key):
 range = SourceRange()
-value = str(conf.lib.clang_getDiagnosticFixIt(self.diag, key,
-byref(range)))
+value = conf.lib.clang_getDiagnosticFixIt(self.diag, key,
+byref(range))
 if len(value) == 0:
 raise IndexError
 
@@ -420,12 +392,12 @@ class Diagnostic(object):
 @property
 def category_name(self):
 """The string name of the category for this diagnostic."""
-return str(conf.lib.clang_getDiagnosticCategoryText(self))
+return conf.lib.clang_getDiagnosticCategoryText(self)
 
 @property
 def option(self):
 """The command-line option that enables this diagnostic."""
-return str(conf.lib.clang_getDiagnosticOption(self, None))
+return conf.lib.clang_getDiagnosticOption(self, None)
 
 @property
 def disable_option(self):
@@ -433,7 +405,7 @@ class Diagnostic(object):
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
 
-return str(conf.lib.clang_getCString(disable))
+return conf.lib.clang_getCString(disable)
 
 def format(self, options=None):
 """
@@ -582,8 +554,8 @@ class BaseEnumeration(object):
 if value >= len(self.__class__._kinds):
 self.__class__._kinds += [None] * (value - 
len(self.__class__._kinds) + 1)
 if self.__class__._kinds[value] is not None:
-raise ValueError('{0} value {1} already loaded'.format(
-str(self.__class__), value))
+raise ValueError,'{0} value {1} already loaded'.format(
+str(self.__class__), value)
 self.value = value
 self.__class__._kinds[value] = self
 self.__class__._name_map = None
@@ -600,12 +572,12 @@ class BaseEnumeration(object):
 for key, value in self.__class__.__dict__.items():
 if isinstance(value, self.__class__):
 self._name_map[value] = key
-return str(self._name_map[self])
+return self._name_map[self]
 
 @classmethod
 def from_id(cls, id):
 if id >= len(cls._kinds) or cls._kinds[id] is None:
-raise ValueError('Unknown template argument kind %d' % id)
+raise ValueError,'Unknown template argument kind %d' % id
 retu

[PATCH] D27800: Add overload of TransformToPotentiallyEvaluated for TypeSourceInfo

2017-01-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

Has this been fixed upstream already?


https://reviews.llvm.org/D27800



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/1122/steps/bootstrap%20clang/logs/stdio

  
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1116:17:
 error: lambda capture 'BitWidth' is not used [-Werror,-Wunused-lambda-capture]
  auto KOF = [BitWidth](const APInt &KnownOne, unsigned ShiftAmt) {
  ^
  
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1127:17:
 error: lambda capture 'BitWidth' is not used [-Werror,-Wunused-lambda-capture]
  auto KZF = [BitWidth](const APInt &KnownZero, unsigned ShiftAmt) {
  ^
  
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1131:17:
 error: lambda capture 'BitWidth' is not used [-Werror,-Wunused-lambda-capture]
  auto KOF = [BitWidth](const APInt &KnownOne, unsigned ShiftAmt) {
  ^
  3 errors generated.

The warnings are correct.

Should I remove the unused lambda captures or revert this changeset?


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

IMO, you can go ahead and commit a fix that removes the captures, and the fix 
can be reviewed post-commit. I don't think you should revert this patch as 
you'll have to remove the captures anyway before reinstating this patch, so 
might as well do it now.


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2017-01-13 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

I've reverted this change and submitted https://reviews.llvm.org/D28682 to 
explicitly check the Python version.

I'll pick this up again, I do want Python 3 support.


Repository:
  rL LLVM

https://reviews.llvm.org/D26082



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D28467#645348, @malcolm.parsons wrote:

> http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/1122/steps/bootstrap%20clang/logs/stdio
>
>   
> /home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1116:17:
>  error: lambda capture 'BitWidth' is not used 
> [-Werror,-Wunused-lambda-capture]
>   auto KOF = [BitWidth](const APInt &KnownOne, unsigned ShiftAmt) {
>   ^
>   
> /home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1127:17:
>  error: lambda capture 'BitWidth' is not used 
> [-Werror,-Wunused-lambda-capture]
>   auto KZF = [BitWidth](const APInt &KnownZero, unsigned ShiftAmt) {
>   ^
>   
> /home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm/lib/Analysis/ValueTracking.cpp:1131:17:
>  error: lambda capture 'BitWidth' is not used 
> [-Werror,-Wunused-lambda-capture]
>   auto KOF = [BitWidth](const APInt &KnownOne, unsigned ShiftAmt) {
>   ^
>   3 errors generated.
>
>
> The warnings are correct.
>
> Should I remove the unused lambda captures or revert this changeset?


The warnings look correct to me; I think you should remove the unused lambda 
captures (no need for a test or review since changes are NFC).


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

There are quite a few of them!


Repository:
  rL LLVM

https://reviews.llvm.org/D28467



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


Re: r291865 - Improve handling of instantiated thread_local variables in Itanium C++ ABI.

2017-01-13 Thread Hans Wennborg via cfe-commits
Merged in r291912.

Thanks,
Hans

On Thu, Jan 12, 2017 at 5:50 PM, Richard Smith  wrote:
> This should go onto the 4.0 branch.
>
> -- Forwarded message --
> From: Richard Smith via cfe-commits 
> Date: 12 January 2017 at 16:43
> Subject: r291865 - Improve handling of instantiated thread_local variables
> in Itanium C++ ABI.
> To: cfe-commits@lists.llvm.org
>
>
> Author: rsmith
> Date: Thu Jan 12 18:43:31 2017
> New Revision: 291865
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291865&view=rev
> Log:
> Improve handling of instantiated thread_local variables in Itanium C++ ABI.
>
>  * Do not initialize these variables when initializing the rest of the
>thread_locals in the TU; they have unordered initialization so they can
> be
>initialized by themselves.
>
>This fixes a rejects-valid bug: we would make the per-variable
> initializer
>function internal, but put it in a comdat keyed off the variable,
> resulting
>in link errors when the comdat is selected from a different TU (as the
> per
>TU TLS init function tries to call an init function that does not exist).
>
>  * On Darwin, when we decide that we're not going to emit a thread wrapper
>function at all, demote its linkage to External. Fixes a verifier failure
>on explicit instantiation of a thread_local variable on Darwin.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
> cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=291865&r1=291864&r2=291865&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Jan 12 18:43:31 2017
> @@ -353,9 +353,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
>
>if (D->getTLSKind()) {
>  // FIXME: Should we support init_priority for thread_local?
> -// FIXME: Ideally, initialization of instantiated thread_local static
> data
> -// members of class templates should not trigger initialization of
> other
> -// entities in the TU.
>  // FIXME: We only need to register one __cxa_thread_atexit function for
> the
>  // entire TU.
>  CXXThreadLocalInits.push_back(Fn);
>
> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=291865&r1=291864&r2=291865&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Jan 12 18:43:31 2017
> @@ -2272,7 +2272,21 @@ void ItaniumCXXABI::EmitThreadLocalInitF
>  ArrayRef CXXThreadLocalInits,
>  ArrayRef CXXThreadLocalInitVars) {
>llvm::Function *InitFunc = nullptr;
> -  if (!CXXThreadLocalInits.empty()) {
> +
> +  // Separate initializers into those with ordered (or partially-ordered)
> +  // initialization and those with unordered initialization.
> +  llvm::SmallVector OrderedInits;
> +  llvm::SmallDenseMap UnorderedInits;
> +  for (unsigned I = 0; I != CXXThreadLocalInits.size(); ++I) {
> +if (isTemplateInstantiation(
> +CXXThreadLocalInitVars[I]->getTemplateSpecializationKind()))
> +  UnorderedInits[CXXThreadLocalInitVars[I]->getCanonicalDecl()] =
> +  CXXThreadLocalInits[I];
> +else
> +  OrderedInits.push_back(CXXThreadLocalInits[I]);
> +  }
> +
> +  if (!OrderedInits.empty()) {
>  // Generate a guarded initialization function.
>  llvm::FunctionType *FTy =
>  llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
> @@ -2289,24 +2303,28 @@ void ItaniumCXXABI::EmitThreadLocalInitF
>  CharUnits GuardAlign = CharUnits::One();
>  Guard->setAlignment(GuardAlign.getQuantity());
>
> -CodeGenFunction(CGM)
> -.GenerateCXXGlobalInitFunc(InitFunc, CXXThreadLocalInits,
> -   Address(Guard, GuardAlign));
> +CodeGenFunction(CGM).GenerateCXXGlobalInitFunc(InitFunc, OrderedInits,
> +   Address(Guard,
> GuardAlign));
>  // On Darwin platforms, use CXX_FAST_TLS calling convention.
>  if (CGM.getTarget().getTriple().isOSDarwin()) {
>InitFunc->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
>InitFunc->addFnAttr(llvm::Attribute::NoUnwind);
>  }
>}
> +
> +  // Emit thread wrappers.
>for (const VarDecl *VD : CXXThreadLocals) {
>  llvm::GlobalVariable *Var =
>
> cast(CGM.GetGlobalValue(CGM.getMangledName(VD)));
> +llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Var);
>
>  // Some targets require that all access to thread local variables go
> through
>  // the thread wrapper.  This means that we cannot attempt to create

Re: r291871 - Update C++ status pages for Clang 4 branch:

2017-01-13 Thread Hans Wennborg via cfe-commits
On Thu, Jan 12, 2017 at 4:57 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Jan 12 18:57:54 2017
> New Revision: 291871
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291871&view=rev
> Log:
> Update C++ status pages for Clang 4 branch:
>
>  * Update version number in DR tests from 4.0 to 4
>  * Teach make_cxx_dr_status script about version numbers that don't contain a
>period.
>  * Update cxx_status.html and cxx_dr_status.html to list Clang 4 features as
>"Clang 4" rather than "SVN"
>
> Clang 4 features are still listed in yellow rather than green until release.

Thanks! I've merged this to the branch in r291913, though I suppose
the contents of www/ isn't really that important for the branch since
it's only trunk's www/ that ends up actually on the web.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28058: [OpenCL] Correct ndrange_t implementation

2017-01-13 Thread Dmitry Borisenkov via Phabricator via cfe-commits
dmitry added a comment.

@yaxunl, we already have the similar issue for atomics. Probably we can extend 
typedef semantic checks but I don't think it's a good idea since C and C++ have 
the similar problem but they don't provide special treatment for types from 
their standard libraries. I think the proposed approach conforms to general 
practice and I also think that it's better than to check canonical type and 
therefore to restrict ndrange_t with a particular non-standard implementation 
or do you envision something different from the canonical type checking in mind?


https://reviews.llvm.org/D28058



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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2017-01-13 Thread Mathieu Duponchelle via Phabricator via cfe-commits
MathieuDuponchelle added a comment.

In https://reviews.llvm.org/D26082#645361, @jbcoe wrote:

> I've reverted this change and submitted https://reviews.llvm.org/D28682 to 
> explicitly check the Python version.
>
> I'll pick this up again, I do want Python 3 support.


I'm not entirely sure why you reverted the patch altogether, apart from the 
problem I raised it worked flawlessly, and in any case did not create any 
problems when the bindings were used from python 2.


Repository:
  rL LLVM

https://reviews.llvm.org/D26082



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


r291917 - Use less byval on 32-bit Windows x86 for classes with bases

2017-01-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Jan 13 11:18:19 2017
New Revision: 291917

URL: http://llvm.org/viewvc/llvm-project?rev=291917&view=rev
Log:
Use less byval on 32-bit Windows x86 for classes with bases

This comes up in V8, which has a Handle template class that wraps a
typed pointer, and is frequently passed by value. The pointer is stored
in the base, HandleBase. This change allows us to pass the struct as a
pointer instead of using byval. This avoids creating tons of temporary
allocas that we copy from during call lowering.

Eventually, it would be good to use FCAs here instead.

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=291917&r1=291916&r2=291917&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Jan 13 11:18:19 2017
@@ -1197,6 +1197,39 @@ static bool is32Or64BitBasicType(QualTyp
   return Size == 32 || Size == 64;
 }
 
+static bool addFieldSizes(ASTContext &Context, const RecordDecl *RD,
+  uint64_t &Size) {
+  for (const auto *FD : RD->fields()) {
+// Scalar arguments on the stack get 4 byte alignment on x86. If the
+// argument is smaller than 32-bits, expanding the struct will create
+// alignment padding.
+if (!is32Or64BitBasicType(FD->getType(), Context))
+  return false;
+
+// FIXME: Reject bit-fields wholesale; there are two problems, we don't 
know
+// how to expand them yet, and the predicate for telling if a bitfield 
still
+// counts as "basic" is more complicated than what we were doing 
previously.
+if (FD->isBitField())
+  return false;
+
+Size += Context.getTypeSize(FD->getType());
+  }
+  return true;
+}
+
+static bool addBaseAndFieldSizes(ASTContext &Context, const CXXRecordDecl *RD,
+ uint64_t &Size) {
+  // Don't do this if there are any non-empty bases.
+  for (const CXXBaseSpecifier &Base : RD->bases()) {
+if (!addBaseAndFieldSizes(Context, Base.getType()->getAsCXXRecordDecl(),
+  Size))
+  return false;
+  }
+  if (!addFieldSizes(Context, RD, Size))
+return false;
+  return true;
+}
+
 /// Test whether an argument type which is to be passed indirectly (on the
 /// stack) would have the equivalent layout if it was expanded into separate
 /// arguments. If so, we prefer to do the latter to avoid inhibiting
@@ -1207,8 +1240,9 @@ bool X86_32ABIInfo::canExpandIndirectArg
   if (!RT)
 return false;
   const RecordDecl *RD = RT->getDecl();
+  uint64_t Size = 0;
   if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) {
-if (!IsWin32StructABI ) {
+if (!IsWin32StructABI) {
   // On non-Windows, we have to conservatively match our old bitcode
   // prototypes in order to be ABI-compatible at the bitcode level.
   if (!CXXRD->isCLike())
@@ -1217,30 +1251,12 @@ bool X86_32ABIInfo::canExpandIndirectArg
   // Don't do this for dynamic classes.
   if (CXXRD->isDynamicClass())
 return false;
-  // Don't do this if there are any non-empty bases.
-  for (const CXXBaseSpecifier &Base : CXXRD->bases()) {
-if (!isEmptyRecord(getContext(), Base.getType(), /*AllowArrays=*/true))
-  return false;
-  }
 }
-  }
-
-  uint64_t Size = 0;
-
-  for (const auto *FD : RD->fields()) {
-// Scalar arguments on the stack get 4 byte alignment on x86. If the
-// argument is smaller than 32-bits, expanding the struct will create
-// alignment padding.
-if (!is32Or64BitBasicType(FD->getType(), getContext()))
+if (!addBaseAndFieldSizes(getContext(), CXXRD, Size))
   return false;
-
-// FIXME: Reject bit-fields wholesale; there are two problems, we don't 
know
-// how to expand them yet, and the predicate for telling if a bitfield 
still
-// counts as "basic" is more complicated than what we were doing 
previously.
-if (FD->isBitField())
+  } else {
+if (!addFieldSizes(getContext(), RD, Size))
   return false;
-
-Size += getContext().getTypeSize(FD->getType());
   }
 
   // We can do this if there was no alignment padding.

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp?rev=291917&r1=291916&r2=291917&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp Fri Jan 13 
11:18:19 2017
@@ -64,6 +64,10 @@ struct BigWithDtor {
   int a, b, c, d, e, f;
 };
 
+struct BaseNoByval : Small {
+  int bb;
+};
+
 // WIN32: declare void @"{{.*take_bools_and_chars.*}}"
 // WIN32:

[PATCH] D27800: Add overload of TransformToPotentiallyEvaluated for TypeSourceInfo

2017-01-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

Ah no, my mistake. I had the patch applied when I ran the test.


https://reviews.llvm.org/D27800



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


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I've actually figured out how to fix the diagnosis location.  I switched the 
diagnosis to use the location of the actual [[deprecated]] attribute instead of 
the Declaration location.  IMO, this is a BETTER note anyway (since the arrow 
points to the actual [[deprecated]] label!).  I'll be uploading a new diff once 
I clean up a few things.


https://reviews.llvm.org/D27486



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


r291919 - unique_ptrify createDriverOptTable

2017-01-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 13 11:34:15 2017
New Revision: 291919

URL: http://llvm.org/viewvc/llvm-project?rev=291919&view=rev
Log:
unique_ptrify createDriverOptTable

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Options.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/DriverOptions.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=291919&r1=291918&r2=291919&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Jan 13 11:34:15 2017
@@ -62,7 +62,7 @@ enum LTOKind {
 /// Driver - Encapsulate logic for constructing compilation processes
 /// from a set of gcc-driver-like command line arguments.
 class Driver {
-  llvm::opt::OptTable *Opts;
+  std::unique_ptr Opts;
 
   DiagnosticsEngine &Diags;
 

Modified: cfe/trunk/include/clang/Driver/Options.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.h?rev=291919&r1=291918&r2=291919&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.h (original)
+++ cfe/trunk/include/clang/Driver/Options.h Fri Jan 13 11:34:15 2017
@@ -10,6 +10,8 @@
 #ifndef LLVM_CLANG_DRIVER_OPTIONS_H
 #define LLVM_CLANG_DRIVER_OPTIONS_H
 
+#include 
+
 namespace llvm {
 namespace opt {
 class OptTable;
@@ -44,7 +46,7 @@ enum ID {
   };
 }
 
-llvm::opt::OptTable *createDriverOptTable();
+std::unique_ptr createDriverOptTable();
 }
 }
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=291919&r1=291918&r2=291919&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 13 11:34:15 2017
@@ -86,8 +86,6 @@ Driver::Driver(StringRef ClangExecutable
 }
 
 Driver::~Driver() {
-  delete Opts;
-
   llvm::DeleteContainerSeconds(ToolChains);
 }
 
@@ -214,9 +212,9 @@ phases::ID Driver::getFinalPhase(const D
   return FinalPhase;
 }
 
-static Arg *MakeInputArg(DerivedArgList &Args, OptTable *Opts,
+static Arg *MakeInputArg(DerivedArgList &Args, OptTable &Opts,
  StringRef Value) {
-  Arg *A = new Arg(Opts->getOption(options::OPT_INPUT), Value,
+  Arg *A = new Arg(Opts.getOption(options::OPT_INPUT), Value,
Args.getBaseArgs().MakeIndex(Value), Value.data());
   Args.AddSynthesizedArg(A);
   A->claim();
@@ -287,7 +285,7 @@ DerivedArgList *Driver::TranslateInputAr
 if (A->getOption().matches(options::OPT__DASH_DASH)) {
   A->claim();
   for (StringRef Val : A->getValues())
-DAL->append(MakeInputArg(*DAL, Opts, Val));
+DAL->append(MakeInputArg(*DAL, *Opts, Val));
   continue;
 }
 
@@ -1561,14 +1559,14 @@ void Driver::BuildInputs(const ToolChain
 } else if (A->getOption().matches(options::OPT__SLASH_Tc)) {
   StringRef Value = A->getValue();
   if (DiagnoseInputExistence(*this, Args, Value, types::TY_C)) {
-Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
+Arg *InputArg = MakeInputArg(Args, *Opts, A->getValue());
 Inputs.push_back(std::make_pair(types::TY_C, InputArg));
   }
   A->claim();
 } else if (A->getOption().matches(options::OPT__SLASH_Tp)) {
   StringRef Value = A->getValue();
   if (DiagnoseInputExistence(*this, Args, Value, types::TY_CXX)) {
-Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
+Arg *InputArg = MakeInputArg(Args, *Opts, A->getValue());
 Inputs.push_back(std::make_pair(types::TY_CXX, InputArg));
   }
   A->claim();
@@ -1594,7 +1592,7 @@ void Driver::BuildInputs(const ToolChain
   if (CCCIsCPP() && Inputs.empty()) {
 // If called as standalone preprocessor, stdin is processed
 // if no other input is present.
-Arg *A = MakeInputArg(Args, Opts, "-");
+Arg *A = MakeInputArg(Args, *Opts, "-");
 Inputs.push_back(std::make_pair(types::TY_C, A));
   }
 }
@@ -2497,7 +2495,7 @@ void Driver::BuildActions(Compilation &C
 const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType);
 llvm::SmallVector PCHPL;
 types::getCompilationPhases(HeaderType, PCHPL);
-Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
+Arg *PchInputArg = MakeInputArg(Args, *Opts, YcArg->getValue());
 
 // Build the pipeline for the pch file.
 Action *ClangClPch =

Modified: cfe/trunk/lib/Driver/DriverOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/DriverOptions.cpp?rev=291919&r1=291918&r2=291919&view

[libcxx] r291921 - Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 12:03:46 2017
New Revision: 291921

URL: http://llvm.org/viewvc/llvm-project?rev=291921&view=rev
Log:
Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."

This reverts commit 3a1b90a866b6d5d62a5f37fbfb3a1ee36cc70dd1.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/experimental/string_view
libcxx/trunk/include/ios

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291921&r1=291920&r2=291921&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan 13 12:03:46 2017
@@ -772,7 +772,7 @@ template  struct __static_asse
 #define _NOALIAS
 #endif
 
-#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
+#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC 
versions
 #   define _LIBCPP_EXPLICIT explicit
 #else

Modified: libcxx/trunk/include/experimental/string_view
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=291921&r1=291920&r2=291921&view=diff
==
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Fri Jan 13 12:03:46 2017
@@ -340,12 +340,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 // [string.view.ops], string operations:
 template
 _LIBCPP_INLINE_VISIBILITY
-// Clang's extended C++11 explict conversions don't work with
-// string_view in C++03.
-#ifndef _LIBCPP_CXX03_LANG
-_LIBCPP_EXPLICIT
-#endif
-operator basic_string<_CharT, _Traits, _Allocator>() const
+_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() 
const
 { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
 
 template >

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=291921&r1=291920&r2=291921&view=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Fri Jan 13 12:03:46 2017
@@ -572,6 +572,13 @@ ios_base::exceptions(iostate __iostate)
 clear(__rdstate_);
 }
 
+#if defined(_LIBCPP_CXX03_LANG)
+struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+  typedef void (__cxx03_bool::*__bool_type)();
+  void __true_value() {}
+};
+#endif
+
 template 
 class _LIBCPP_TEMPLATE_VIS basic_ios
 : public ios_base
@@ -585,8 +592,18 @@ public:
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
 
+  // __true_value will generate undefined references when linking unless
+  // we give it internal linkage.
+
+#if defined(_LIBCPP_CXX03_LANG)
+_LIBCPP_ALWAYS_INLINE
+operator __cxx03_bool::__bool_type() const {
+return !fail() ? &__cxx03_bool::__true_value : nullptr;
+}
+#else
 _LIBCPP_ALWAYS_INLINE
 _LIBCPP_EXPLICIT operator bool() const {return !fail();}
+#endif
 
 _LIBCPP_ALWAYS_INLINE bool operator!() const{return  fail();}
 _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return 
ios_base::rdstate();}


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


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 84330.
erichkeane added a comment.

Fixed the deprecated location 'note'.  Observe the changes to a variety of 
tests.


https://reviews.llvm.org/D27486

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
  test/Sema/attr-deprecated.c
  test/SemaCXX/attr-deprecated.cpp
  test/SemaObjC/attr-deprecated.m
  test/SemaObjC/special-dep-unavail-warning.m
  test/SemaObjC/warn-deprecated-implementations.m
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1882,6 +1882,9 @@
   namespace sema {
 Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S,
 const MultiLevelTemplateArgumentList &TemplateArgs);
+Attr *instantiateTemplateAttributeForDecl(
+const Attr *At, ASTContext &C, Sema &S,
+const MultiLevelTemplateArgumentList &TemplateArgs);
   }
 }
 
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2390,6 +2390,13 @@
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
 }
 
+if (Decl->getSpecializationKind()  == TSK_Undeclared) {
+  MultiLevelTemplateArgumentList TemplateArgLists;
+  TemplateArgLists.addOuterTemplateArguments(Converted);
+  InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
+  Decl);
+}
+
 // Diagnose uses of this specialization.
 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -328,6 +328,35 @@
   Attr.getRange());
 }
 
+bool DeclContainsAttr(Decl* D, attr::Kind K) {
+  if (!D->hasAttrs())
+return false;
+  for (auto&& attr : D->getAttrs())
+if (attr->getKind() == K)
+  return true;
+  return false;
+}
+
+void Sema::InstantiateAttrsForDecl(
+const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Tmpl,
+Decl *New, LateInstantiatedAttrVec *LateAttrs,
+LocalInstantiationScope *OuterMostScope) {
+  if (NamedDecl *ND = dyn_cast(New)) {
+for (const auto *TmplAttr : Tmpl->attrs()) {
+  // FIXME: If any of the special case versions from InstantiateAttrs become
+  // applicable to template declaration, we'll need to add them here.
+  CXXThisScopeRAII ThisScope(
+  *this, dyn_cast_or_null(ND->getDeclContext()),
+  /*TypeQuals*/ 0, ND->isCXXInstanceMember());
+
+  Attr *NewAttr = sema::instantiateTemplateAttributeForDecl(
+  TmplAttr, Context, *this, TemplateArgs);
+  if (NewAttr && !DeclContainsAttr(New, NewAttr->getKind()))
+New->addAttr(NewAttr);
+}
+  }
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
@@ -421,7 +450,8 @@
 
   Attr *NewAttr = sema::instantiateTemplateAttribute(TmplAttr, Context,
  *this, TemplateArgs);
-  if (NewAttr)
+
+  if (NewAttr && !DeclContainsAttr(New, NewAttr->getKind()))
 New->addAttr(NewAttr);
 }
   }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6611,6 +6611,7 @@
   // Diagnostics for deprecated or unavailable.
   unsigned diag, diag_message, diag_fwdclass_message;
   unsigned diag_available_here = diag::note_availability_specified_here;
+  SourceLocation NoteLocation = D->getLocation();
 
   // Matches 'diag::note_property_attribute' options.
   unsigned property_note_select;
@@ -6633,6 +6634,8 @@
 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
 property_note_select = /* deprecated */ 0;
 available_here_select_kind = /* deprecated */ 2;
+if (auto *attr = D->getAttr())
+  NoteLocation = attr->getLocation();
 break;
 
   case AR_Unavailable:
@@ -6751,7 +6754,7 @@
 }
   }
   else
-S.Diag(D->getLocation(), diag_available_here)
+S.Diag(NoteLocation, diag_available_here)
 << D << available_here_select_kind;
 
   if (K == AR_NotYetIntroduced)
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2451,26 +2451,19 @@
   O

[libcxx] r291922 - Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 12:08:23 2017
New Revision: 291922

URL: http://llvm.org/viewvc/llvm-project?rev=291922&view=rev
Log:
Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."


Modified:
libcxx/branches/release_40/include/__config
libcxx/branches/release_40/include/experimental/string_view
libcxx/branches/release_40/include/ios

Modified: libcxx/branches/release_40/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/__config?rev=291922&r1=291921&r2=291922&view=diff
==
--- libcxx/branches/release_40/include/__config (original)
+++ libcxx/branches/release_40/include/__config Fri Jan 13 12:08:23 2017
@@ -772,7 +772,7 @@ template  struct __static_asse
 #define _NOALIAS
 #endif
 
-#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
+#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC 
versions
 #   define _LIBCPP_EXPLICIT explicit
 #else

Modified: libcxx/branches/release_40/include/experimental/string_view
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/experimental/string_view?rev=291922&r1=291921&r2=291922&view=diff
==
--- libcxx/branches/release_40/include/experimental/string_view (original)
+++ libcxx/branches/release_40/include/experimental/string_view Fri Jan 13 
12:08:23 2017
@@ -340,12 +340,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 // [string.view.ops], string operations:
 template
 _LIBCPP_INLINE_VISIBILITY
-// Clang's extended C++11 explict conversions don't work with
-// string_view in C++03.
-#ifndef _LIBCPP_CXX03_LANG
-_LIBCPP_EXPLICIT
-#endif
-operator basic_string<_CharT, _Traits, _Allocator>() const
+_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() 
const
 { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
 
 template >

Modified: libcxx/branches/release_40/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/ios?rev=291922&r1=291921&r2=291922&view=diff
==
--- libcxx/branches/release_40/include/ios (original)
+++ libcxx/branches/release_40/include/ios Fri Jan 13 12:08:23 2017
@@ -572,6 +572,13 @@ ios_base::exceptions(iostate __iostate)
 clear(__rdstate_);
 }
 
+#if defined(_LIBCPP_CXX03_LANG)
+struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+  typedef void (__cxx03_bool::*__bool_type)();
+  void __true_value() {}
+};
+#endif
+
 template 
 class _LIBCPP_TEMPLATE_VIS basic_ios
 : public ios_base
@@ -585,8 +592,18 @@ public:
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
 
+  // __true_value will generate undefined references when linking unless
+  // we give it internal linkage.
+
+#if defined(_LIBCPP_CXX03_LANG)
+_LIBCPP_ALWAYS_INLINE
+operator __cxx03_bool::__bool_type() const {
+return !fail() ? &__cxx03_bool::__true_value : nullptr;
+}
+#else
 _LIBCPP_ALWAYS_INLINE
 _LIBCPP_EXPLICIT operator bool() const {return !fail();}
+#endif
 
 _LIBCPP_ALWAYS_INLINE bool operator!() const{return  fail();}
 _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return 
ios_base::rdstate();}


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


[libcxx] r291925 - Fix merge conflict caused by r291921

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 12:25:13 2017
New Revision: 291925

URL: http://llvm.org/viewvc/llvm-project?rev=291925&view=rev
Log:
Fix merge conflict caused by r291921

Modified:
libcxx/trunk/include/ios

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=291925&r1=291924&r2=291925&view=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Fri Jan 13 12:25:13 2017
@@ -573,7 +573,7 @@ ios_base::exceptions(iostate __iostate)
 }
 
 #if defined(_LIBCPP_CXX03_LANG)
-struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+struct _LIBCPP_TYPE_VIS __cxx03_bool {
   typedef void (__cxx03_bool::*__bool_type)();
   void __true_value() {}
 };


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


[libcxx] r291935 - Fix merge error caused by r291922

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 12:42:41 2017
New Revision: 291935

URL: http://llvm.org/viewvc/llvm-project?rev=291935&view=rev
Log:
Fix merge error caused by r291922

Modified:
libcxx/branches/release_40/include/ios

Modified: libcxx/branches/release_40/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/ios?rev=291935&r1=291934&r2=291935&view=diff
==
--- libcxx/branches/release_40/include/ios (original)
+++ libcxx/branches/release_40/include/ios Fri Jan 13 12:42:41 2017
@@ -573,7 +573,7 @@ ios_base::exceptions(iostate __iostate)
 }
 
 #if defined(_LIBCPP_CXX03_LANG)
-struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+struct _LIBCPP_TYPE_VIS __cxx03_bool {
   typedef void (__cxx03_bool::*__bool_type)();
   void __true_value() {}
 };
@@ -592,9 +592,6 @@ public:
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
 
-  // __true_value will generate undefined references when linking unless
-  // we give it internal linkage.
-
 #if defined(_LIBCPP_CXX03_LANG)
 _LIBCPP_ALWAYS_INLINE
 operator __cxx03_bool::__bool_type() const {


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


r291938 - unique_ptrify Driver::ToolChains

2017-01-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 13 12:53:43 2017
New Revision: 291938

URL: http://llvm.org/viewvc/llvm-project?rev=291938&view=rev
Log:
unique_ptrify Driver::ToolChains

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=291938&r1=291937&r2=291938&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Jan 13 12:53:43 2017
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Phases.h"
+#include "clang/Driver/ToolChain.h"
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/StringMap.h"
@@ -227,7 +228,7 @@ private:
   /// This maps from the string representation of a triple to a ToolChain
   /// created targeting that triple. The driver owns all the ToolChain objects
   /// stored in it, and will clean them up when torn down.
-  mutable llvm::StringMap ToolChains;
+  mutable llvm::StringMap> ToolChains;
 
 private:
   /// TranslateInputArgs - Create a new derived argument list from the input
@@ -264,7 +265,6 @@ public:
   Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
  DiagnosticsEngine &Diags,
  IntrusiveRefCntPtr VFS = nullptr);
-  ~Driver();
 
   /// @name Accessors
   /// @{

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=291938&r1=291937&r2=291938&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 13 12:53:43 2017
@@ -85,10 +85,6 @@ Driver::Driver(StringRef ClangExecutable
   ResourceDir = P.str();
 }
 
-Driver::~Driver() {
-  llvm::DeleteContainerSeconds(ToolChains);
-}
-
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
   auto Default = ToolChain::getTargetAndModeFromProgramName(ProgramName);
@@ -477,12 +473,12 @@ void Driver::CreateOffloadingDeviceToolC
  : "nvptx-nvidia-cuda");
 // Use the CUDA and host triples as the key into the ToolChains map, 
because
 // the device toolchain we create depends on both.
-ToolChain *&CudaTC = ToolChains[CudaTriple.str() + "/" + HostTriple.str()];
+auto &CudaTC = ToolChains[CudaTriple.str() + "/" + HostTriple.str()];
 if (!CudaTC) {
-  CudaTC = new toolchains::CudaToolChain(*this, CudaTriple, *HostTC,
- C.getInputArgs());
+  CudaTC = llvm::make_unique(
+  *this, CudaTriple, *HostTC, C.getInputArgs());
 }
-C.addOffloadDeviceToolChain(CudaTC, Action::OFK_Cuda);
+C.addOffloadDeviceToolChain(CudaTC.get(), Action::OFK_Cuda);
   }
 
   //
@@ -3655,125 +3651,130 @@ std::string Driver::GetClPchPath(Compila
 const ToolChain &Driver::getToolChain(const ArgList &Args,
   const llvm::Triple &Target) const {
 
-  ToolChain *&TC = ToolChains[Target.str()];
+  auto &TC = ToolChains[Target.str()];
   if (!TC) {
 switch (Target.getOS()) {
 case llvm::Triple::Haiku:
-  TC = new toolchains::Haiku(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::CloudABI:
-  TC = new toolchains::CloudABI(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::Darwin:
 case llvm::Triple::MacOSX:
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
-  TC = new toolchains::DarwinClang(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::DragonFly:
-  TC = new toolchains::DragonFly(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::OpenBSD:
-  TC = new toolchains::OpenBSD(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::Bitrig:
-  TC = new toolchains::Bitrig(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::NetBSD:
-  TC = new toolchains::NetBSD(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::FreeBSD:
-  TC = new toolchains::FreeBSD(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::Minix:
-  TC = new toolchains::Minix(*this, Target, Args);
+  TC = llvm::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::Linux:
 case llvm::Triple::ELFIAMCU:
   if (Target.get

r291939 - Remove unused lambda captures. NFC

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 12:55:32 2017
New Revision: 291939

URL: http://llvm.org/viewvc/llvm-project?rev=291939&view=rev
Log:
Remove unused lambda captures. NFC

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=291939&r1=291938&r2=291939&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Jan 13 12:55:32 2017
@@ -52,7 +52,8 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
--  ...
+-  -Wunused-lambda-capture warns when a variable explicitly captured
+   by a lambda is not used in the body of the lambda.
 
 New Compiler Flags
 --

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=291939&r1=291938&r2=291939&view=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Fri Jan 13 12:55:32 2017
@@ -88,7 +88,7 @@ bool CXXRecordDecl::isDerivedFrom(const
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   // FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
   return lookupInBases(
-  [this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
+  [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
 return FindBaseClass(Specifier, Path, BaseDecl);
   },
   Paths);
@@ -109,7 +109,7 @@ bool CXXRecordDecl::isVirtuallyDerivedFr
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   // FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
   return lookupInBases(
-  [this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
+  [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
 return FindVirtualBaseClass(Specifier, Path, BaseDecl);
   },
   Paths);

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=291939&r1=291938&r2=291939&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri Jan 13 12:55:32 2017
@@ -2997,14 +2997,14 @@ void MicrosoftMangleContextImpl::mangleS
   // N.B. The length is in terms of bytes, not characters.
   Mangler.mangleNumber(SL->getByteLength() + SL->getCharByteWidth());
 
-  auto GetLittleEndianByte = [&Mangler, &SL](unsigned Index) {
+  auto GetLittleEndianByte = [&SL](unsigned Index) {
 unsigned CharByteWidth = SL->getCharByteWidth();
 uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
 unsigned OffsetInCodeUnit = Index % CharByteWidth;
 return static_cast((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
   };
 
-  auto GetBigEndianByte = [&Mangler, &SL](unsigned Index) {
+  auto GetBigEndianByte = [&SL](unsigned Index) {
 unsigned CharByteWidth = SL->getCharByteWidth();
 uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
 unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=291939&r1=291938&r2=291939&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Jan 13 12:55:32 2017
@@ -4006,8 +4006,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeG
 DepTaskArgs[5] = CGF.Builder.getInt32(0);
 DepTaskArgs[6] = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
   }
-  auto &&ThenCodeGen = [this, Loc, &Data, TDBase, KmpTaskTQTyRD,
-NumDependencies, &TaskArgs,
+  auto &&ThenCodeGen = [this, &Data, TDBase, KmpTaskTQTyRD, NumDependencies,
+&TaskArgs,
 &DepTaskArgs](CodeGenFunction &CGF, PrePostActionTy &) 
{
 if (!Data.Tied) {
   auto PartIdFI = std::next(KmpTaskTQTyRD->field_begin(), KmpTaskTPartId);
@@ -4562,7 +4562,7 @@ void CGOpenMPRuntime::emitReduction(Code
   }
   if (XExpr) {
 auto *VD = cast(cast(*ILHS)->getDecl());
-auto &&AtomicRedGen = [BO, VD, IPriv,
+auto &&AtomicRedGen = [BO, VD,
Loc](CodeGenFunction &CGF, const Expr *XExpr,
 const Expr *EExpr, const Expr *UpExpr) {
 

[clang-tools-extra] r291940 - Remove unused lambda captures. NFC

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 12:56:04 2017
New Revision: 291940

URL: http://llvm.org/viewvc/llvm-project?rev=291940&view=rev
Log:
Remove unused lambda captures. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=291940&r1=291939&r2=291940&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Jan 13 12:56:04 2017
@@ -487,7 +487,7 @@ runClangTidy(std::unique_ptrhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r291941 - Remove unused lambda captures. NFC

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 13:02:50 2017
New Revision: 291941

URL: http://llvm.org/viewvc/llvm-project?rev=291941&view=rev
Log:
Remove unused lambda captures. NFC

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

Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=291941&r1=291940&r2=291941&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Fri Jan 13 
13:02:50 2017
@@ -207,8 +207,8 @@ runClangMoveOnCode(const move::MoveDefin
   std::vector> FileToSourceText = {
   {TestHeaderName, Header}, {TestCCName, CC}};
 
-  auto CreateFiles = [&FileToSourceText, &Context, &FileToFileID](
-  llvm::StringRef Name, llvm::StringRef Code) {
+  auto CreateFiles = [&Context, &FileToFileID](llvm::StringRef Name,
+   llvm::StringRef Code) {
 if (!Name.empty()) {
   FileToFileID[Name] = Context.createInMemoryFile(Name, Code);
 }


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


Re: LLVM buildmaster will be unavailable on 1/13/17

2017-01-13 Thread Galina Kistanova via cfe-commits
Just a remainder.

LLVM buildmaster will be offline today hopefully for short time due for
replacing network hardware.
Thank you for understanding.

Thanks

Galina


On Thu, Jan 12, 2017 at 8:29 PM, Galina Kistanova 
wrote:

> Hello everyone,
>
> LLVM buildmaster will be offline on 1/13/17 hopefully for short time due
> for replacing network hardware.
> 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] D26057: [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@rsmith Ping. Would you like me to split this up into smaller change sets?


https://reviews.llvm.org/D26057



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


Re: r291877 - [Sema] Restrict explicit instantation definition dllexport

2017-01-13 Thread Hans Wennborg via cfe-commits
Merged in r291943.

Thanks,
Hans

On Thu, Jan 12, 2017 at 5:58 PM, Shoaib Meenai  wrote:
> Requesting a merge to the 4.0 branch. This is a pretty small change, and it
> fixes an assertion failure on Windows (see PR31608 for details).
>
> On 1/12/17, 5:28 PM, "cfe-commits on behalf of Shoaib Meenai via cfe-commits" 
>  
> wrote:
>
> Author: smeenai
> Date: Thu Jan 12 19:28:34 2017
> New Revision: 291877
>
> URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D291877-26view-3Drev&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=UFJ7c0vMtAjKBdgoPzfL-28zDS1KWJTBHGfq_xGDm1s&s=f_XKXZU8x-ZpL2CZ0EhN86GlPYk_1RLL5eWxv3GY-pw&e=
> Log:
> [Sema] Restrict explicit instantation definition dllexport
>
> In the case where the template class itself is already `dllexport`, the
> implicit instantiation will have already emitted all members. When we
> check the explicit instantiation definition, the `Specialization` will
> have inherited the `dllexport` attribute, so we'll attempt to emit all
> members for a second time, which causes an assertion failure. Restrict
> the exporting to when the `dllexport` attribute is newly introduced by
> the explicit instantiation definition.
>
> Fixes PR31608.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r291946 - [libc++abi] Add a silent terminate handler to libcxxabi.

2017-01-13 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Fri Jan 13 13:22:26 2017
New Revision: 291946

URL: http://llvm.org/viewvc/llvm-project?rev=291946&view=rev
Log:
[libc++abi] Add a silent terminate handler to libcxxabi.

The current std::terminate_handler pulls in some string code, some I/O
code, and more. Since it is automatically setup as the default, this
means that any trivial binary linking against libcxxabi will get this
extra bloat.

This patch allows disabling it as a build-time option, if you want to
avoid the extra bloat.

Patch by Tom Rybka!

Reviewers: EricWF

Subscribers: danalbert, llvm-commits, mgorny

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

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/src/config.h
libcxxabi/trunk/src/cxa_default_handlers.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=291946&r1=291945&r2=291946&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Fri Jan 13 13:22:26 2017
@@ -433,6 +433,10 @@ if (LIBCXXABI_USE_LLVM_UNWINDER)
   add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER=1)
 endif()
 
+if (LIBCXXABI_SILENT_TERMINATE)
+  add_definitions(-DLIBCXXABI_SILENT_TERMINATE=1)
+endif()
+
 string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=291946&r1=291945&r2=291946&view=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Fri Jan 13 13:22:26 2017
@@ -23,4 +23,11 @@
 #  define LIBCXXABI_BAREMETAL 0
 #endif
 
+// The default terminate handler attempts to demangle uncaught exceptions, 
which
+// causes extra I/O and demangling code to be pulled in.
+// Set this to make the terminate handler default to a silent alternative.
+#ifndef LIBCXXABI_SILENT_TERMINATE
+#  define LIBCXXABI_SILENT_TERMINATE 0
+#endif
+
 #endif // LIBCXXABI_CONFIG_H

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=291946&r1=291945&r2=291946&view=diff
==
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Fri Jan 13 13:22:26 2017
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "abort_message.h"
 #include "config.h" // For __sync_swap
 #include "cxxabi.h"
@@ -22,7 +23,7 @@
 static const char* cause = "uncaught";
 
 __attribute__((noreturn))
-static void default_terminate_handler()
+static void demangling_terminate_handler()
 {
 // If there might be an uncaught exception
 using namespace __cxxabiv1;
@@ -78,12 +79,19 @@ static void default_terminate_handler()
 }
 
 __attribute__((noreturn))
-static void default_unexpected_handler() 
+static void demangling_unexpected_handler()
 {
 cause = "unexpected";
 std::terminate();
 }
 
+#if !LIBCXXABI_SILENT_TERMINATE
+static std::terminate_handler default_terminate_handler = 
demangling_terminate_handler;
+static std::terminate_handler default_unexpected_handler = 
demangling_unexpected_handler;
+#else
+static std::terminate_handler default_terminate_handler = std::abort;
+static std::terminate_handler default_unexpected_handler = std::abort;
+#endif
 
 //
 // Global variables that hold the pointers to the current handler


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


[PATCH] D21675: New ODR checker for modules

2017-01-13 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu updated this revision to Diff 84340.

https://reviews.llvm.org/D21675

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/ODRHash.h
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSerializationKinds.td
  lib/AST/CMakeLists.txt
  lib/AST/DeclCXX.cpp
  lib/AST/ODRHash.cpp
  lib/AST/StmtProfile.cpp
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/merge-using-decls.cpp
  test/Modules/odr_hash.cpp

Index: test/Modules/odr_hash.cpp
===
--- test/Modules/odr_hash.cpp
+++ test/Modules/odr_hash.cpp
@@ -0,0 +1,1077 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Build module map file
+// RUN: echo "module first {"   >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module second {"  >> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++11
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+#if defined(FIRST)
+struct S1 {
+  public:
+};
+#elif defined(SECOND)
+struct S1 {
+  private:
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'S1' has different definitions in different modules; first difference is definition in module 'first' found public access specifier}}
+// expected-note@second.h:* {{but in 'second' found private access specifier}}
+#endif
+
+#if defined(FIRST)
+struct S2Friend2 {};
+struct S2 {
+  friend S2Friend2;
+};
+#elif defined(SECOND)
+struct S2Friend1 {};
+struct S2 {
+  friend S2Friend1;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{'S2' has different definitions in different modules; first difference is definition in module 'first' found friend 'S2Friend2'}}
+// expected-note@second.h:* {{but in 'second' found other friend 'S2Friend1'}}
+#endif
+
+#if defined(FIRST)
+template
+struct S3Template {};
+struct S3 {
+  friend S3Template;
+};
+#elif defined(SECOND)
+template
+struct S3Template {};
+struct S3 {
+  friend S3Template;
+};
+#else
+S3 s3;
+// expected-error@first.h:* {{'S3' has different definitions in different modules; first difference is definition in module 'first' found friend 'S3Template'}}
+// expected-note@second.h:* {{but in 'second' found other friend 'S3Template'}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  static_assert(1 == 1, "First");
+};
+#elif defined(SECOND)
+struct S4 {
+  static_assert(1 == 1, "Second");
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{'S4' has different definitions in different modules; first difference is definition in module 'first' found static assert with message}}
+// expected-note@second.h:* {{but in 'second' found static assert with different message}}
+#endif
+
+#if defined(FIRST)
+struct S5 {
+  static_assert(1 == 1, "Message");
+};
+#elif defined(SECOND)
+struct S5 {
+  static_assert(2 == 2, "Message");
+};
+#else
+S5 s5;
+// expected-error@first.h:* {{'S5' has different definitions in different modules; first difference is definition in module 'first' found static assert with condition}}
+// expected-note@second.h:* {{but in 'second' found static assert with different condition}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  int First();
+};
+#elif defined(SECOND)
+struct S6 {
+  int Second();
+};
+#else
+S6 s6;
+// expected-error@second.h:* {{'S6::Second' from module 'second' is not present in definition of 'S6' in module 'first'}}
+// expected-note@first.h:* {{definition has no member 'Second'}}
+#endif
+
+#if defined(FIRST)
+struct S7 {
+  double foo();
+};
+#elif defined(SECOND)
+struct S7 {
+  int foo();
+};
+#else
+S7 s7;
+// expected-error@second.h:* {{'S7::foo' from module 'second' is not present in definition of 'S7' in module 'first'}}
+// expected-note@first.h:* {{declaration of 'foo' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S8 {
+  void foo();
+};
+#elif defined(SECOND)
+struct S8 {
+  void foo() {}
+};
+#else
+S8 s8;
+// expected-error@first.h:* {{'S8' has different definitions in different modules; definition in module 'first' is here}}
+// expected-note@second.h:* {{definition in module 'second' is here}}
+#endif
+
+#if defined(FIRST)
+struct S9 {
+  void foo() { int y = 5; }
+};
+#elif defined(SECOND)
+struct S9 {
+  void foo() { int x = 5; }
+};
+#else
+S9 s9;
+// expected-er

[PATCH] D21675: New ODR checker for modules

2017-01-13 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu marked 5 inline comments as done.
rtrieu added a comment.

Comments have been addressed.  I will be testing it for performance impact next.




Comment at: include/clang/AST/ODRHash.h:54
+  // in Pointers.
+  size_type NextFreeIndex;
+

rsmith wrote:
> Is this always the same as `Pointers.size()`?
Yes it is.  It has been removed and Pointers.size() is used now.


https://reviews.llvm.org/D21675



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


Re: r291907 - Revert "Support for Python 3 in libclang python bindings"

2017-01-13 Thread Hans Wennborg via cfe-commits
On Fri, Jan 13, 2017 at 8:06 AM, Jonathan Coe via cfe-commits
 wrote:
> Author: jbcoe
> Date: Fri Jan 13 10:06:59 2017
> New Revision: 291907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291907&view=rev
> Log:
> Revert "Support for Python 3 in libclang python bindings"
>
> This reverts commit 4464581bb63e9789e9ee231a8c8800be5f614743.
>
> Memory access issues on Linux were reported by Mathieu Duponchelle and
> discussed here: https://reviews.llvm.org/D26082.

Merged to the release branch in r291950 as discussed on PR31628.

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


Re: r290392 - Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.

2017-01-13 Thread Chandler Carruth via cfe-commits
Also need to pull in r291881. Sorry about that.

On Thu, Jan 12, 2017 at 3:42 PM Hans Wennborg  wrote:

> On Thu, Jan 12, 2017 at 3:01 PM, Chandler Carruth 
> wrote:
> >> This isn't quite right, it should either be left as-is or dropped
> >> completely. This path was allowing people to spell "-mllvm
> >> -disable-llvm-optzns" for legacy reasons, even though the correct
> >> spelling is "-Xclang -disable-llvm-optzns". There's no need to add
> >> legacy support for "-mllvm -disable-llvm-passes", since that never
> >> worked.
> >
> >
> > Yeah, I don't think this was even really intended.
> >
> > r291850+r291853 fix this to preserve -disable-llvm-optzns exactly as it
> was.
> >
> > I've alse followed up with Hans to make sure LLVM 4 gets this.
>
> Merged in r291860.
>
> Cheers,
> Hans
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r290392 - Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.

2017-01-13 Thread Hans Wennborg via cfe-commits
Merged in r291951.

Thanks,
Hans

On Fri, Jan 13, 2017 at 11:46 AM, Chandler Carruth  wrote:
> Also need to pull in r291881. Sorry about that.
>
>
> On Thu, Jan 12, 2017 at 3:42 PM Hans Wennborg  wrote:
>>
>> On Thu, Jan 12, 2017 at 3:01 PM, Chandler Carruth 
>> wrote:
>> >> This isn't quite right, it should either be left as-is or dropped
>> >> completely. This path was allowing people to spell "-mllvm
>> >> -disable-llvm-optzns" for legacy reasons, even though the correct
>> >> spelling is "-Xclang -disable-llvm-optzns". There's no need to add
>> >> legacy support for "-mllvm -disable-llvm-passes", since that never
>> >> worked.
>> >
>> >
>> > Yeah, I don't think this was even really intended.
>> >
>> > r291850+r291853 fix this to preserve -disable-llvm-optzns exactly as it
>> > was.
>> >
>> > I've alse followed up with Hans to make sure LLVM 4 gets this.
>>
>> Merged in r291860.
>>
>> Cheers,
>> Hans
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r291879 - Add a necessary newline for diagnose_if documentation.

2017-01-13 Thread Hans Wennborg via cfe-commits
Merged in r291952.

Thanks,
Hans

On Thu, Jan 12, 2017 at 5:52 PM, Eric Christopher via cfe-commits
 wrote:
> Author: echristo
> Date: Thu Jan 12 19:52:04 2017
> New Revision: 291879
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291879&view=rev
> Log:
> Add a necessary newline for diagnose_if documentation.
>
> Modified:
> cfe/trunk/include/clang/Basic/AttrDocs.td
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=291879&r1=291878&r2=291879&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Jan 12 19:52:04 2017
> @@ -386,6 +386,7 @@ warnings or errors at compile-time if ca
>  certain user-defined criteria. For example:
>
>  .. code-block:: c
> +
>void abs(int a)
>  __attribute__((diagnose_if(a >= 0, "Redundant abs call", "warning")));
>void must_abs(int a)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Driver/MSVCToolChain.cpp:34
+  #if 0
+#define USE_VS_SETUP_CONFIG
+  #endif

What are the outstanding issues preventing you from enabling this by default?



Comment at: lib/Driver/MSVCToolChain.cpp:160
+
+NotAToolChain:
+  ;

I think it would be clearer if you separated out the PATH search into a 
separate helper. 



Comment at: lib/Driver/MSVCToolChain.cpp:263
+
+ConfigQueryUnsuccessful:
+  ;

Similarly, I think this should be a separate helper. It wouldn't need goto.


https://reviews.llvm.org/D28365



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


[PATCH] D28058: [OpenCL] Correct ndrange_t implementation

2017-01-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D28058#645399, @dmitry wrote:

> @yaxunl, we already have the similar issue for atomics. Probably we can 
> extend typedef semantic checks but I don't think it's a good idea since C and 
> C++ have the similar problem but they don't provide special treatment for 
> types from their standard libraries. I think the proposed approach conforms 
> to general practice and I also think that it's better than to check canonical 
> type and therefore to restrict ndrange_t with a particular non-standard 
> implementation or do you envision something different from the canonical type 
> checking in mind?


My concern is mainly about the representation and name mangling of ndrange_t in 
IR, not just about type checking. However I assume this may not be an issue if 
all users use the same opencl-c.h header file to compile the kernel for spir 
target.

Can you address Anastasia's comment about byval attribute of arguments of 
ndrange_t type? Thanks.


https://reviews.llvm.org/D28058



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


Re: r291879 - Add a necessary newline for diagnose_if documentation.

2017-01-13 Thread Eric Christopher via cfe-commits
Great, thanks!

On Fri, Jan 13, 2017, 11:52 AM Hans Wennborg  wrote:

> Merged in r291952.
>
> Thanks,
> Hans
>
> On Thu, Jan 12, 2017 at 5:52 PM, Eric Christopher via cfe-commits
>  wrote:
> > Author: echristo
> > Date: Thu Jan 12 19:52:04 2017
> > New Revision: 291879
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=291879&view=rev
> > Log:
> > Add a necessary newline for diagnose_if documentation.
> >
> > Modified:
> > cfe/trunk/include/clang/Basic/AttrDocs.td
> >
> > Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=291879&r1=291878&r2=291879&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> > +++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Jan 12 19:52:04 2017
> > @@ -386,6 +386,7 @@ warnings or errors at compile-time if ca
> >  certain user-defined criteria. For example:
> >
> >  .. code-block:: c
> > +
> >void abs(int a)
> >  __attribute__((diagnose_if(a >= 0, "Redundant abs call",
> "warning")));
> >void must_abs(int a)
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291953 - Fix shared library build after r291938 by adding missing dependency on libOption

2017-01-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 13 13:47:55 2017
New Revision: 291953

URL: http://llvm.org/viewvc/llvm-project?rev=291953&view=rev
Log:
Fix shared library build after r291938 by adding missing dependency on libOption

Thanks to Reid Kleckner for the help reproducing/fixing.

Modified:
cfe/trunk/unittests/Driver/CMakeLists.txt

Modified: cfe/trunk/unittests/Driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/CMakeLists.txt?rev=291953&r1=291952&r2=291953&view=diff
==
--- cfe/trunk/unittests/Driver/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Driver/CMakeLists.txt Fri Jan 13 13:47:55 2017
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
+  Option
   )
 
 add_clang_unittest(ClangDriverTests


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


[PATCH] D26057: [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.

2017-01-13 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ExprCXX.h:4237
+  /// compiler.
+  bool IsImplicitlyCreated : 1;
+

I would go with just `isImplicit`, to match other similar uses throughout the 
AST. Also maybe sink this into the `Stmt` bitfields to make this class 8 bytes 
smaller



Comment at: lib/AST/ItaniumMangle.cpp:3302-3303
   case Expr::AddrLabelExprClass:
+  // This should no longer exist in the AST by now
+  case Expr::DependentCoawaitExprClass:
   case Expr::DesignatedInitUpdateExprClass:

I don't think "should no longer exist" is true. If `co_await` can appear in a 
function signature at all, it can appear with a dependent operand. This should 
be mangled the same as a non-dependent `co_await` expression.



Comment at: lib/Sema/SemaCoroutine.cpp:33
 /// function type.
 static QualType lookupPromiseType(Sema &S, const FunctionProtoType *FnType,
+  SourceLocation KwLoc,

EricWF wrote:
> The changes to this function are all unrelated cleanup/improvements.
Just go ahead and commit these separately then.



Comment at: lib/Sema/SemaCoroutine.cpp:99
+
+  auto buildNNS = [&]() {
 auto *NNS = NestedNameSpecifier::Create(S.Context, nullptr, StdExp);

`buildElaboratedType` would be a better name for what this does. I also wonder 
if this is really necessary, or whether we can just use %q0 in the diagnostic 
format to request a fully-qualified type name.



Comment at: lib/Sema/SemaCoroutine.cpp:112-116
+  if (S.RequireCompleteType(FuncLoc, buildNNS(),
+diag::err_coroutine_promise_type_incomplete))
+return QualType();
 
   return PromiseType;

We used to return the `ElaboratedType` and don't do so any more.



Comment at: lib/Sema/SemaCoroutine.cpp:409-414
+  return BuildDependentCoawaitExpr(Loc, E,
+   cast(Lookup.get()));
+}
+
+ExprResult Sema::BuildDependentCoawaitExpr(SourceLocation Loc, Expr *E,
+   UnresolvedLookupExpr *Lookup) {

This seems like an odd naming choice. I'd expect `BuildDependentCoawaitExpr` to 
only deal with the case where the expression is dependent (and to never be 
called otherwise), and `BuildCoawaitExpr` to handle both the case where the 
expression is dependent and the case where it is non-dependent. Maybe the other 
function should be called `BuildResolvedCoawaitExpr` or similar.



Comment at: lib/Sema/SemaDecl.cpp:11386
 
-  // If we don't have a visible definition of the function, and it's inline or
+  // If we don't have a viNsible definition of the function, and it's inline or
   // a template, skip the new definition.

Stray change.



Comment at: lib/Sema/TreeTransform.h:6687-6689
+  // Set that we have (possibly-invalid) suspend points before we do anything
+  // that may fail.
+  ScopeInfo->setCoroutineSuspendsInvalid();

Please use a term other than "invalid" here. We generally use "invalid" to mean 
"an error has been diagnosed, use best-effort recovery".



Comment at: lib/Sema/TreeTransform.h:6802
+  return getDerived().RebuildDependentCoawaitExpr(
+  E->getKeywordLoc(), Result.get(), E->getOperatorCoawaitLookup());
+}

You need to transform the UnresolvedLookupExpr here too. (Example: we might 
have a function-local declaration of `operator co_await` that needs to be 
transformed into the version in the instantiated function.)


https://reviews.llvm.org/D26057



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


[PATCH] D21675: New ODR checker for modules

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

Thanks, looks good assuming your performance testing doesn't uncover anything.




Comment at: lib/AST/ODRHash.cpp:319-321
+if (!D) return;
+if (D->isImplicit())
+  return;

I think you can remove these lines: no-one should be calling this function with 
a null declaration or an implicit declaration.


https://reviews.llvm.org/D21675



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


[PATCH] D28691: Support synchronisation scope in atomic builtin functions

2017-01-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader, rjmccall.
yaxunl added a subscriber: cfe-commits.

OpenCL 2.0 atomic builtin functions have a scope argument which is ideally 
represented as synchronization scope argument in LLVM atomic instructions.

Clang supports translating atomic builtin functions to LLVM atomic 
instructions. However it currently does not support synchronization scope of 
LLVM atomic instructions. Without this, users have to use LLVM assembly code to 
implement OpenCL atomic builtin functions.

This patch allows Clang atomic builtin functions to accept an optional 
synchronization scope argument, so that they can be used to implement OpenCL 
atomic builtin functions.

There is no functional change for other languages, since the synchronization 
scope argument is optional, and its default value generates the same LLVM 
instruction as before.

Currently only constant integer argument is supported. Support of non-constant 
synchronization scope will be added later.


https://reviews.llvm.org/D28691

Files:
  include/clang/AST/Expr.h
  lib/AST/Expr.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops.cl
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -92,7 +92,7 @@
   __c11_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
 
   __c11_atomic_load(0); // expected-error {{too few arguments to function}}
-  __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
+  __c11_atomic_load(0,0,0,0); // expected-error {{too many arguments to function}}
   __c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
   __c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
   __c11_atomic_store(i, 0, memory_order_relaxed);
@@ -114,7 +114,7 @@
 
   __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
   __atomic_load(I, *P, memory_order_relaxed);
-  __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
+  __atomic_load(I, *P, memory_order_relaxed, 42, 0); // expected-error {{too many arguments}}
   (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
   __atomic_load(s1, s2, memory_order_acquire);
   __atomic_load(CI, I, memory_order_relaxed);
Index: test/CodeGenOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/atomic-ops.cl
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -O0 -o - -triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
+
+// Also test serialization of atomic operations here, to avoid duplicating the test.
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-pch -O0 -o %t -triple=amdgcn-amd-amdhsa-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include-pch %t -O0 -triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
+
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_consume = __ATOMIC_CONSUME,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+// ToDo: Currently LLVM only supports synchronization scope singlethread
+// and crossthread (default). Add tests for OpenCL synchronization scopes
+// after they are supported by LLVM.
+typedef enum synch_scope
+{
+  synch_scope_single_thread,
+  synch_scope_cross_thread,
+  synch_scope_ocl_work_item,
+  synch_scope_ocl_work_group,
+  synch_scope_ocl_device,
+  synch_scope_ocl_all_svm_devices,
+  synch_scope_ocl_sub_group
+} synch_scope;
+
+void fi1(atomic_int *i, int *j, int cmp) {
+  int x;
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} seq_cst
+  x = __c11_atomic_load(i, memory_order_seq_cst);
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} singlethread seq_cst
+  x = __c11_atomic_load(i, memory_order_seq_cst, synch_scope_single_thread);
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} seq_cst
+  x = __c11_atomic_load(i, memory_order_seq_cst, synch_scope_cross_thread);
+  // CHECK: store atomic i32 %{{[.0-9A-Z_a-z]+}}, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} singlethread seq_cst
+  __c11_atomic_store(i, 1, memory_order_seq_cst, synch_scope_single_thread);
+  // CHECK: atomicrmw and i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} singlethread seq_cst
+  x = __c11_atomic_fetch_and(i, 1, memory_order_seq_cst, synch_scope_single_thread);
+  // CHECK: cmpxchg i32 addrspace(4)*

[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.

2017-01-13 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Looks great to me, thanks! Unless someone else shouts, I'll land this for you 
soon.


https://reviews.llvm.org/D28543



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


r291955 - PR31606: Generalize our tentative DR resolution for inheriting copy/move

2017-01-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 13 14:46:54 2017
New Revision: 291955

URL: http://llvm.org/viewvc/llvm-project?rev=291955&view=rev
Log:
PR31606: Generalize our tentative DR resolution for inheriting copy/move
constructors to better match the pre-P0136R1 behavior.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp
cfe/trunk/test/CXX/drs/dr16xx.cpp
cfe/trunk/test/CXX/drs/dr19xx.cpp
cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
cfe/trunk/test/CXX/special/class.inhctor/p3.cpp
cfe/trunk/test/CXX/special/class.inhctor/p7.cpp
cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
cfe/trunk/test/SemaTemplate/cxx1z-using-declaration.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291955&r1=291954&r2=291955&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13 14:46:54 
2017
@@ -3344,8 +3344,8 @@ def note_ovl_candidate : Note<"candidate
 def note_ovl_candidate_inherited_constructor : Note<
 "constructor from base class %0 inherited here">;
 def note_ovl_candidate_inherited_constructor_slice : Note<
-"constructor inherited from base class cannot be used to initialize from "
-"an argument of the derived class type">;
+"candidate %select{constructor|template}0 ignored: "
+"inherited constructor cannot be used to %select{copy|move}1 object">;
 def note_ovl_candidate_illegal_constructor : Note<
 "candidate %select{constructor|template}0 ignored: "
 "instantiation %select{takes|would take}0 its own class type by value">;

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=291955&r1=291954&r2=291955&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jan 13 14:46:54 2017
@@ -5944,6 +5944,28 @@ Sema::AddOverloadCandidate(FunctionDecl
   Candidate.FailureKind = ovl_fail_illegal_constructor;
   return;
 }
+
+// C++ [over.match.funcs]p8: (proposed DR resolution)
+//   A constructor inherited from class type C that has a first parameter
+//   of type "reference to P" (including such a constructor instantiated
+//   from a template) is excluded from the set of candidate functions when
+//   constructing an object of type cv D if the argument list has exactly
+//   one argument and D is reference-related to P and P is 
reference-related
+//   to C.
+auto *Shadow = dyn_cast(FoundDecl.getDecl());
+if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 &&
+Constructor->getParamDecl(0)->getType()->isReferenceType()) {
+  QualType P = Constructor->getParamDecl(0)->getType()->getPointeeType();
+  QualType C = Context.getRecordType(Constructor->getParent());
+  QualType D = Context.getRecordType(Shadow->getParent());
+  SourceLocation Loc = Args.front()->getExprLoc();
+  if ((Context.hasSameUnqualifiedType(P, C) || IsDerivedFrom(Loc, P, C)) &&
+  (Context.hasSameUnqualifiedType(D, P) || IsDerivedFrom(Loc, D, P))) {
+Candidate.Viable = false;
+Candidate.FailureKind = ovl_fail_inhctor_slice;
+return;
+  }
+}
   }
 
   unsigned NumParams = Proto->getNumParams();
@@ -6016,31 +6038,6 @@ Sema::AddOverloadCandidate(FunctionDecl
 }
   }
 
-  // C++ [over.best.ics]p4+: (proposed DR resolution)
-  //   If the target is the first parameter of an inherited constructor when
-  //   constructing an object of type C with an argument list that has exactly
-  //   one expression, an implicit conversion sequence cannot be formed if C is
-  //   reference-related to the type that the argument would have after the
-  //   application of the user-defined conversion (if any) and before the final
-  //   standard conversion sequence. 
-  auto *Shadow = dyn_cast(FoundDecl.getDecl());
-  if (Shadow && Args.size() == 1 && !isa(Args.front())) {
-bool DerivedToBase, ObjCConversion, ObjCLifetimeConversion;
-QualType ConvertedArgumentType = Args.front()->getType();
-if (Candidate.Conversions[0].isUserDefined())
-  ConvertedArgumentType =
-  Candidate.Conversions[0].UserDefined.After.getFromType();
-if (CompareReferenceRelationship(Args.front()->getLocStart(),
- 
Context.getRecordType(Shadow->getParent()),
- ConvertedArgumentType, DerivedToBase,
- ObjCConversion,
-  

Re: LLVM buildmaster will be unavailable on 1/13/17

2017-01-13 Thread Renato Golin via cfe-commits
Should we slow down, or block commits for the time being?

It could be a total chaos when they get back...

On 13 January 2017 at 19:16, Galina Kistanova via cfe-commits
 wrote:
> Just a remainder.
>
> LLVM buildmaster will be offline today hopefully for short time due for
> replacing network hardware.
> Thank you for understanding.
>
> Thanks
>
> Galina
>
>
>
> On Thu, Jan 12, 2017 at 8:29 PM, Galina Kistanova 
> wrote:
>>
>> Hello everyone,
>>
>> LLVM buildmaster will be offline on 1/13/17 hopefully for short time due
>> for replacing network hardware.
>> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28691: Support synchronisation scope in Clang atomic builtin functions

2017-01-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl retitled this revision from "Support synchronisation scope in atomic 
builtin functions" to "Support synchronisation scope in Clang atomic builtin 
functions".
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 84373.
yaxunl added a comment.

Fix typos and formatting issues.


https://reviews.llvm.org/D28691

Files:
  include/clang/AST/Expr.h
  lib/AST/Expr.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops.cl
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -92,7 +92,7 @@
   __c11_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
 
   __c11_atomic_load(0); // expected-error {{too few arguments to function}}
-  __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
+  __c11_atomic_load(0,0,0,0); // expected-error {{too many arguments to function}}
   __c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
   __c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
   __c11_atomic_store(i, 0, memory_order_relaxed);
@@ -114,7 +114,7 @@
 
   __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
   __atomic_load(I, *P, memory_order_relaxed);
-  __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
+  __atomic_load(I, *P, memory_order_relaxed, 42, 0); // expected-error {{too many arguments}}
   (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
   __atomic_load(s1, s2, memory_order_acquire);
   __atomic_load(CI, I, memory_order_relaxed);
Index: test/CodeGenOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/atomic-ops.cl
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -O0 -o - -triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
+
+// Also test serialization of atomic operations here, to avoid duplicating the test.
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-pch -O0 -o %t -triple=amdgcn-amd-amdhsa-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include-pch %t -O0 -triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
+
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_consume = __ATOMIC_CONSUME,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+// ToDo: Currently LLVM only supports synchronization scope singlethread
+// and crossthread (default). Add tests for OpenCL synchronization scopes
+// after they are supported by LLVM.
+typedef enum synch_scope
+{
+  synch_scope_single_thread,
+  synch_scope_cross_thread,
+  synch_scope_ocl_work_item,
+  synch_scope_ocl_work_group,
+  synch_scope_ocl_device,
+  synch_scope_ocl_all_svm_devices,
+  synch_scope_ocl_sub_group
+} synch_scope;
+
+void fi1(atomic_int *i, int *j, int cmp) {
+  int x;
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} seq_cst
+  x = __c11_atomic_load(i, memory_order_seq_cst);
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} singlethread seq_cst
+  x = __c11_atomic_load(i, memory_order_seq_cst, synch_scope_single_thread);
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} seq_cst
+  x = __c11_atomic_load(i, memory_order_seq_cst, synch_scope_cross_thread);
+  // CHECK: store atomic i32 %{{[.0-9A-Z_a-z]+}}, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} singlethread seq_cst
+  __c11_atomic_store(i, 1, memory_order_seq_cst, synch_scope_single_thread);
+  // CHECK: atomicrmw and i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} singlethread seq_cst
+  x = __c11_atomic_fetch_and(i, 1, memory_order_seq_cst, synch_scope_single_thread);
+  // CHECK: cmpxchg i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} singlethread acquire acquire
+  x = __c11_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire, synch_scope_single_thread);
+}
+
+#endif
\ No newline at end of file
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -2630,27 +2630,30 @@
   DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts());
 
   // All these operations take one of the following forms:
+  // The last optional argument is for synchronization scope. The default value
+  // 1 is for crossthread.
   enum {

[PATCH] D28703: [clang] Emit `diagnose_if` warnings from system headers

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: george.burgess.iv, rsmith, aaron.ballman.
EricWF added a subscriber: cfe-commits.

In order for libc++ to meaningfully use `diagnose_if` warnings they need to be 
emitted from system headers by default. This patch changes the `diagnose_if` 
warning diagnostic to be shown in system headers.


https://reviews.llvm.org/D28703

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  test/Sema/Inputs/diagnose-if-warn-system-header.h
  test/Sema/diagnose_if.c


Index: test/Sema/diagnose_if.c
===
--- test/Sema/diagnose_if.c
+++ test/Sema/diagnose_if.c
@@ -150,3 +150,6 @@
 void runAlwaysWarnWithArg(int a) {
   alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}}
 }
+
+// Test that diagnose_if warnings generated in system headers are not ignored.
+#include "Inputs/diagnose-if-warn-system-header.h"
Index: test/Sema/Inputs/diagnose-if-warn-system-header.h
===
--- /dev/null
+++ test/Sema/Inputs/diagnose-if-warn-system-header.h
@@ -0,0 +1,11 @@
+#pragma GCC system_header
+
+inline int system_header_func(int x)
+  __attribute__((diagnose_if(x == x, "system header warning", "warning"))) // 
expected-note {{from 'diagnose_if' attribute}}
+{
+  return 0;
+}
+
+void test_system_header() {
+  system_header_func(0); // expected-warning {{system header warning}}
+}
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3380,7 +3380,8 @@
 "candidate address cannot be taken because parameter %0 has "
 "pass_object_size attribute">;
 def err_diagnose_if_succeeded : Error<"%0">;
-def warn_diagnose_if_succeeded : Warning<"%0">, InGroup;
+def warn_diagnose_if_succeeded : Warning<"%0">, InGroup,
+ShowInSystemHeader;
 def note_ovl_candidate_disabled_by_function_cond_attr : Note<
 "candidate disabled: %0">;
 def note_ovl_candidate_disabled_by_extension : Note<


Index: test/Sema/diagnose_if.c
===
--- test/Sema/diagnose_if.c
+++ test/Sema/diagnose_if.c
@@ -150,3 +150,6 @@
 void runAlwaysWarnWithArg(int a) {
   alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}}
 }
+
+// Test that diagnose_if warnings generated in system headers are not ignored.
+#include "Inputs/diagnose-if-warn-system-header.h"
Index: test/Sema/Inputs/diagnose-if-warn-system-header.h
===
--- /dev/null
+++ test/Sema/Inputs/diagnose-if-warn-system-header.h
@@ -0,0 +1,11 @@
+#pragma GCC system_header
+
+inline int system_header_func(int x)
+  __attribute__((diagnose_if(x == x, "system header warning", "warning"))) // expected-note {{from 'diagnose_if' attribute}}
+{
+  return 0;
+}
+
+void test_system_header() {
+  system_header_func(0); // expected-warning {{system header warning}}
+}
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3380,7 +3380,8 @@
 "candidate address cannot be taken because parameter %0 has "
 "pass_object_size attribute">;
 def err_diagnose_if_succeeded : Error<"%0">;
-def warn_diagnose_if_succeeded : Warning<"%0">, InGroup;
+def warn_diagnose_if_succeeded : Warning<"%0">, InGroup,
+ShowInSystemHeader;
 def note_ovl_candidate_disabled_by_function_cond_attr : Note<
 "candidate disabled: %0">;
 def note_ovl_candidate_disabled_by_extension : Note<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291961 - Add _LIBCPP_DIAGNOSE_WARNING and _LIBCPP_DIAGNOSE_ERROR macros.

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 16:02:08 2017
New Revision: 291961

URL: http://llvm.org/viewvc/llvm-project?rev=291961&view=rev
Log:
Add _LIBCPP_DIAGNOSE_WARNING and _LIBCPP_DIAGNOSE_ERROR macros.

Clang recently added a `diagnose_if(cond, msg, type)` attribute
which can be used to generate diagnostics when `cond` is a constant
expression that evaluates to true. Otherwise no attribute has no
effect.

This patch adds _LIBCPP_DIAGNOSE_ERROR/WARNING macros which
use this new attribute. Additionally this patch implements
a diagnostic message when a non-const-callable comparator is
given to a container.

Note: For now the warning version of the diagnostic is useless
within libc++ since warning diagnostics are suppressed by the
system header pragma. I'm going to work on fixing this.

Added:

libcxx/trunk/test/libcxx/containers/associative/non_const_comparator.fail.cpp
Modified:
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/__config
libcxx/trunk/include/__tree
libcxx/trunk/include/map
libcxx/trunk/include/type_traits
libcxx/trunk/test/libcxx/compiler.py
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/format.py

libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.fail.cpp

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=291961&r1=291960&r2=291961&view=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Fri Jan 13 16:02:08 2017
@@ -173,3 +173,10 @@ thread safety annotations.
   return Tup{"hello world", 42}; // explicit constructor called. OK.
 }
 
+**_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS**:
+  This macro disables the additional diagnostics generated by libc++ using the
+  `diagnose_if` attribute. These additional diagnostics include checks for:
+
+* Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
+  const callable.
+

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291961&r1=291960&r2=291961&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan 13 16:02:08 2017
@@ -1006,6 +1006,16 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 #endif
 
+#if __has_attribute(diagnose_if) && 
!defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
+# define _LIBCPP_DIAGNOSE_WARNING(...) \
+__attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
+# define _LIBCPP_DIAGNOSE_ERROR(...) \
+__attribute__((__diagnose_if__(__VA_ARGS__, "error")))
+#else
+# define _LIBCPP_DIAGNOSE_WARNING(...)
+# define _LIBCPP_DIAGNOSE_ERROR(...)
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=291961&r1=291960&r2=291961&view=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Fri Jan 13 16:02:08 2017
@@ -41,6 +41,10 @@ template 
 struct __value_type;
 #endif
 
+template ::value && !__libcpp_is_final<_Compare>::value>
+class __map_value_compare;
+
 template  class __map_node_destructor;
 template  class _LIBCPP_TEMPLATE_VIS __map_iterator;
 template  class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
@@ -955,6 +959,30 @@ private:
 
 };
 
+#ifndef _LIBCPP_CXX03_LANG
+template 
+struct __diagnose_tree_helper {
+  static constexpr bool __trigger_diagnostics()
+  _LIBCPP_DIAGNOSE_WARNING(!__is_const_comparable<_Compare, _Tp>::value,
+"the specified comparator type does not provide a const call 
operator")
+  { return true; }
+};
+
+template 
+struct __diagnose_tree_helper<
+__value_type<_Key, _Value>,
+__map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>,
+_Alloc
+>
+{
+  static constexpr bool __trigger_diagnostics()
+  _LIBCPP_DIAGNOSE_WARNING(!__is_const_comparable<_KeyComp, _Key>::value,
+"the specified comparator type does not provide a const call 
operator")
+  { return true; }
+};
+
+#endif
+
 template 
 class __tree
 {
@@ -1787,7 +1815,11 @@ __tree<_Tp, _Compare, _Allocator>::~__tr
 {
 static_assert((is_copy_constructible::value),
  "Comparator must be copy-constructible.");
-destroy(__root());
+#ifndef _LIBCPP_CXX03_LANG
+static_assert((__diagnose_tree_helper<_Tp, _Compare, _Allocator>::
+ __trigger_diagnostics()), "");
+#endif
+  destroy(__root());
 }
 
 template 

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=291961&r1=291960&r2=291961&view=diff
==
--- libcxx/trunk/inclu

[PATCH] D28703: [clang] Emit `diagnose_if` warnings from system headers

2017-01-13 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/D28703



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


r291963 - [clang] Emit `diagnose_if` warnings from system headers

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 16:11:40 2017
New Revision: 291963

URL: http://llvm.org/viewvc/llvm-project?rev=291963&view=rev
Log:
[clang] Emit `diagnose_if` warnings from system headers

Summary: In order for libc++ to meaningfully use `diagnose_if` warnings they 
need to be emitted from system headers by default. This patch changes the 
`diagnose_if` warning diagnostic to be shown in system headers.

Reviewers: george.burgess.iv, rsmith, aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Sema/diagnose_if.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291963&r1=291962&r2=291963&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13 16:11:40 
2017
@@ -3380,7 +3380,8 @@ def note_ovl_candidate_has_pass_object_s
 "candidate address cannot be taken because parameter %0 has "
 "pass_object_size attribute">;
 def err_diagnose_if_succeeded : Error<"%0">;
-def warn_diagnose_if_succeeded : Warning<"%0">, InGroup;
+def warn_diagnose_if_succeeded : Warning<"%0">, InGroup,
+ShowInSystemHeader;
 def note_ovl_candidate_disabled_by_function_cond_attr : Note<
 "candidate disabled: %0">;
 def note_ovl_candidate_disabled_by_extension : Note<

Added: cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h?rev=291963&view=auto
==
--- cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h (added)
+++ cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h Fri Jan 13 
16:11:40 2017
@@ -0,0 +1,11 @@
+#pragma GCC system_header
+
+inline int system_header_func(int x)
+  __attribute__((diagnose_if(x == x, "system header warning", "warning"))) // 
expected-note {{from 'diagnose_if' attribute}}
+{
+  return 0;
+}
+
+void test_system_header() {
+  system_header_func(0); // expected-warning {{system header warning}}
+}

Modified: cfe/trunk/test/Sema/diagnose_if.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diagnose_if.c?rev=291963&r1=291962&r2=291963&view=diff
==
--- cfe/trunk/test/Sema/diagnose_if.c (original)
+++ cfe/trunk/test/Sema/diagnose_if.c Fri Jan 13 16:11:40 2017
@@ -150,3 +150,6 @@ void alwaysWarnWithArg(int a) _diagnose_
 void runAlwaysWarnWithArg(int a) {
   alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}}
 }
+
+// Test that diagnose_if warnings generated in system headers are not ignored.
+#include "Inputs/diagnose-if-warn-system-header.h"


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


r291964 - PR31631: fix bad CFG (and bogus warnings) when an if-statement has an init-statement and has binary operator as its condition.

2017-01-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 13 16:16:41 2017
New Revision: 291964

URL: http://llvm.org/viewvc/llvm-project?rev=291964&view=rev
Log:
PR31631: fix bad CFG (and bogus warnings) when an if-statement has an 
init-statement and has binary operator as its condition.

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/SemaCXX/uninitialized.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=291964&r1=291963&r2=291964&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Jan 13 16:16:41 2017
@@ -2175,19 +2175,15 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
   SaveAndRestore save_scope_pos(ScopePos);
 
   // Create local scope for C++17 if init-stmt if one exists.
-  if (Stmt *Init = I->getInit()) {
-LocalScope::const_iterator BeginScopePos = ScopePos;
+  if (Stmt *Init = I->getInit())
 addLocalScopeForStmt(Init);
-addAutomaticObjDtors(ScopePos, BeginScopePos, I);
-  }
 
   // Create local scope for possible condition variable.
   // Store scope position. Add implicit destructor.
-  if (VarDecl *VD = I->getConditionVariable()) {
-LocalScope::const_iterator BeginScopePos = ScopePos;
+  if (VarDecl *VD = I->getConditionVariable())
 addLocalScopeForVarDecl(VD);
-addAutomaticObjDtors(ScopePos, BeginScopePos, I);
-  }
+
+  addAutomaticObjDtors(ScopePos, save_scope_pos.get(), I);
 
   // The block we were processing is now finished.  Make it the successor
   // block.
@@ -2256,36 +2252,39 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
   // removes infeasible paths from the control-flow graph by having the
   // control-flow transfer of '&&' or '||' go directly into the then/else
   // blocks directly.
-  if (!I->getConditionVariable())
-if (BinaryOperator *Cond =
-dyn_cast(I->getCond()->IgnoreParens()))
-  if (Cond->isLogicalOp())
-return VisitLogicalOperator(Cond, I, ThenBlock, ElseBlock).first;
-
-  // Now create a new block containing the if statement.
-  Block = createBlock(false);
+  BinaryOperator *Cond =
+  I->getConditionVariable()
+  ? nullptr
+  : dyn_cast(I->getCond()->IgnoreParens());
+  CFGBlock *LastBlock;
+  if (Cond && Cond->isLogicalOp())
+LastBlock = VisitLogicalOperator(Cond, I, ThenBlock, ElseBlock).first;
+  else {
+// Now create a new block containing the if statement.
+Block = createBlock(false);
 
-  // Set the terminator of the new block to the If statement.
-  Block->setTerminator(I);
+// Set the terminator of the new block to the If statement.
+Block->setTerminator(I);
 
-  // See if this is a known constant.
-  const TryResult &KnownVal = tryEvaluateBool(I->getCond());
+// See if this is a known constant.
+const TryResult &KnownVal = tryEvaluateBool(I->getCond());
 
-  // Add the successors.  If we know that specific branches are
-  // unreachable, inform addSuccessor() of that knowledge.
-  addSuccessor(Block, ThenBlock, /* isReachable = */ !KnownVal.isFalse());
-  addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
-
-  // Add the condition as the last statement in the new block.  This may create
-  // new blocks as the condition may contain control-flow.  Any newly created
-  // blocks will be pointed to be "Block".
-  CFGBlock *LastBlock = addStmt(I->getCond());
-
-  // If the IfStmt contains a condition variable, add it and its
-  // initializer to the CFG.
-  if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) {
-autoCreateBlock();
-LastBlock = addStmt(const_cast(DS));
+// Add the successors.  If we know that specific branches are
+// unreachable, inform addSuccessor() of that knowledge.
+addSuccessor(Block, ThenBlock, /* isReachable = */ !KnownVal.isFalse());
+addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
+
+// Add the condition as the last statement in the new block.  This may
+// create new blocks as the condition may contain control-flow.  Any newly
+// created blocks will be pointed to be "Block".
+LastBlock = addStmt(I->getCond());
+
+// If the IfStmt contains a condition variable, add it and its
+// initializer to the CFG.
+if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) {
+  autoCreateBlock();
+  LastBlock = addStmt(const_cast(DS));
+}
   }
 
   // Finally, if the IfStmt contains a C++17 init-stmt, add it to the CFG.
@@ -3078,19 +3077,15 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(Sw
   SaveAndRestore save_scope_pos(ScopePos);
 
   // Create local scope for C++17 switch init-stmt if one exists.
-  if (Stmt *Init = Terminator->getInit()) {
-LocalScope::const_iterator BeginScopePos = ScopePos;
+  if (Stmt *Init = Terminator->getInit())
 addLocalScopeForStmt(Init);
-addAutomaticObjDtors(ScopePos, BeginScopePos, Terminator);
-  }
 
   // Create local 

[PATCH] D21675: New ODR checker for modules

2017-01-13 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu marked an inline comment as done.
rtrieu added a comment.

From testing, there is no difference when compiling with pre-compiled headers.  
However, when building the headers, there is a 3-4% impact on compile time.


https://reviews.llvm.org/D21675



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


[PATCH] D28705: [Sema] Fix bug in handling of designated initializer

2017-01-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, rnk, arphaman.
ahatanak added a subscriber: cfe-commits.

CheckDesignatedInitializer wasn't taking into account the base classes when 
computing the index for the field in the derived class, which caused the test 
case to crash during IRGen because of a malformed AST.


https://reviews.llvm.org/D28705

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/designated-initializers-base-class.cpp


Index: test/SemaCXX/designated-initializers-base-class.cpp
===
--- /dev/null
+++ test/SemaCXX/designated-initializers-base-class.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -std=c++1z -ast-dump | FileCheck %s
+
+// CHECK: VarDecl {{.*}} d 'struct D' cinit
+// CHECK: InitListExpr {{.*}} 'struct D'
+// CHECK: InitListExpr {{.*}} 'struct B'
+// CHECK: ImplicitValueInitExpr {{.*}} 'int'
+// CHECK: IntegerLiteral {{.*}} 'int' 1
+
+struct B {
+  int x;
+};
+
+struct D : B {
+  int y;
+};
+
+void test() {
+  D d = { .y = 1 };
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -2247,6 +2247,9 @@
   ++FieldIndex;
 }
 
+if (auto *CXXRD = dyn_cast(RT->getDecl()))
+  FieldIndex += CXXRD->getNumBases();
+
 RecordDecl::field_iterator Field =
 RecordDecl::field_iterator(DeclContext::decl_iterator(KnownField));
 


Index: test/SemaCXX/designated-initializers-base-class.cpp
===
--- /dev/null
+++ test/SemaCXX/designated-initializers-base-class.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -std=c++1z -ast-dump | FileCheck %s
+
+// CHECK: VarDecl {{.*}} d 'struct D' cinit
+// CHECK: InitListExpr {{.*}} 'struct D'
+// CHECK: InitListExpr {{.*}} 'struct B'
+// CHECK: ImplicitValueInitExpr {{.*}} 'int'
+// CHECK: IntegerLiteral {{.*}} 'int' 1
+
+struct B {
+  int x;
+};
+
+struct D : B {
+  int y;
+};
+
+void test() {
+  D d = { .y = 1 };
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -2247,6 +2247,9 @@
   ++FieldIndex;
 }
 
+if (auto *CXXRD = dyn_cast(RT->getDecl()))
+  FieldIndex += CXXRD->getNumBases();
+
 RecordDecl::field_iterator Field =
 RecordDecl::field_iterator(DeclContext::decl_iterator(KnownField));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r291963 - [clang] Emit `diagnose_if` warnings from system headers

2017-01-13 Thread George Burgess IV via cfe-commits
Do we want to consider merging this into the release branch? Seems like
more of a bugfix than a feature to me.

On Fri, Jan 13, 2017 at 2:11 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Jan 13 16:11:40 2017
> New Revision: 291963
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291963&view=rev
> Log:
> [clang] Emit `diagnose_if` warnings from system headers
>
> Summary: In order for libc++ to meaningfully use `diagnose_if` warnings
> they need to be emitted from system headers by default. This patch changes
> the `diagnose_if` warning diagnostic to be shown in system headers.
>
> Reviewers: george.burgess.iv, rsmith, aaron.ballman
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D28703
>
> Added:
> cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/test/Sema/diagnose_if.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Basic/DiagnosticSemaKinds.td?rev=291963&r1=291962&r2=291963&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
> 16:11:40 2017
> @@ -3380,7 +3380,8 @@ def note_ovl_candidate_has_pass_object_s
>  "candidate address cannot be taken because parameter %0 has "
>  "pass_object_size attribute">;
>  def err_diagnose_if_succeeded : Error<"%0">;
> -def warn_diagnose_if_succeeded : Warning<"%0">,
> InGroup;
> +def warn_diagnose_if_succeeded : Warning<"%0">,
> InGroup,
> +ShowInSystemHeader;
>  def note_ovl_candidate_disabled_by_function_cond_attr : Note<
>  "candidate disabled: %0">;
>  def note_ovl_candidate_disabled_by_extension : Note<
>
> Added: cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inpu
> ts/diagnose-if-warn-system-header.h?rev=291963&view=auto
> 
> ==
> --- cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h (added)
> +++ cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h Fri Jan
> 13 16:11:40 2017
> @@ -0,0 +1,11 @@
> +#pragma GCC system_header
> +
> +inline int system_header_func(int x)
> +  __attribute__((diagnose_if(x == x, "system header warning",
> "warning"))) // expected-note {{from 'diagnose_if' attribute}}
> +{
> +  return 0;
> +}
> +
> +void test_system_header() {
> +  system_header_func(0); // expected-warning {{system header warning}}
> +}
>
> Modified: cfe/trunk/test/Sema/diagnose_if.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diag
> nose_if.c?rev=291963&r1=291962&r2=291963&view=diff
> 
> ==
> --- cfe/trunk/test/Sema/diagnose_if.c (original)
> +++ cfe/trunk/test/Sema/diagnose_if.c Fri Jan 13 16:11:40 2017
> @@ -150,3 +150,6 @@ void alwaysWarnWithArg(int a) _diagnose_
>  void runAlwaysWarnWithArg(int a) {
>alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}}
>  }
> +
> +// Test that diagnose_if warnings generated in system headers are not
> ignored.
> +#include "Inputs/diagnose-if-warn-system-header.h"
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291969 - Diagnose non-const-callable hash functions and comparators

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 16:42:53 2017
New Revision: 291969

URL: http://llvm.org/viewvc/llvm-project?rev=291969&view=rev
Log:
Diagnose non-const-callable hash functions and comparators

Added:
libcxx/trunk/test/libcxx/containers/unord/non_const_comparator.fail.cpp
Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__tree
libcxx/trunk/include/type_traits
libcxx/trunk/include/unordered_map

libcxx/trunk/test/libcxx/containers/associative/non_const_comparator.fail.cpp

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=291969&r1=291968&r2=291969&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Jan 13 16:42:53 2017
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include <__undef_min_max>
 
@@ -38,6 +39,15 @@ template 
 struct __hash_value_type;
 #endif
 
+template ::value && !__libcpp_is_final<_Hash>::value>
+class __unordered_map_hasher;
+
+template ::value && !__libcpp_is_final<_Pred>::value
+ >
+class __unordered_map_equal;
+
 #ifndef _LIBCPP_CXX03_LANG
 template 
 struct __is_hash_value_type_imp : false_type {};
@@ -856,6 +866,29 @@ public:
 template  friend class __hash_map_node_destructor;
 };
 
+
+#ifndef _LIBCPP_CXX03_LANG
+template 
+struct __diagnose_hash_table_helper {
+  static constexpr bool __trigger_diagnostics()
+  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
+"the specified hash functor does not provide a const call operator")
+  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key 
const&>::value,
+"the specified comparator type does not provide a const call operator")
+  { return true; }
+};
+
+template 
+struct __diagnose_hash_table_helper<
+  __hash_value_type<_Key, _Value>,
+  __unordered_map_hasher<_Key, __hash_value_type<_Key, _Value>, _Hash>,
+  __unordered_map_equal<_Key, __hash_value_type<_Key, _Value>, _Equal>,
+  _Alloc>
+: __diagnose_hash_table_helper<_Key, _Hash, _Equal, _Alloc>
+{
+};
+#endif // _LIBCPP_CXX03_LANG
+
 template 
 class __hash_table
 {
@@ -1453,6 +1486,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
  "Predicate must be copy-constructible.");
 static_assert((is_copy_constructible::value),
  "Hasher must be copy-constructible.");
+#ifndef _LIBCPP_CXX03_LANG
+static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, 
_Alloc>::__trigger_diagnostics(), "");
+#endif
 __deallocate_node(__p1_.first().__next_);
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__erase_c(this);

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=291969&r1=291968&r2=291969&view=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Fri Jan 13 16:42:53 2017
@@ -963,7 +963,7 @@ private:
 template 
 struct __diagnose_tree_helper {
   static constexpr bool __trigger_diagnostics()
-  _LIBCPP_DIAGNOSE_WARNING(!__is_const_comparable<_Compare, _Tp>::value,
+  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp 
const&>::value,
 "the specified comparator type does not provide a const call 
operator")
   { return true; }
 };
@@ -973,15 +973,10 @@ struct __diagnose_tree_helper<
 __value_type<_Key, _Value>,
 __map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>,
 _Alloc
->
+> : __diagnose_tree_helper<_Key, _KeyComp, _Alloc>
 {
-  static constexpr bool __trigger_diagnostics()
-  _LIBCPP_DIAGNOSE_WARNING(!__is_const_comparable<_KeyComp, _Key>::value,
-"the specified comparator type does not provide a const call 
operator")
-  { return true; }
 };
-
-#endif
+#endif // !_LIBCPP_CXX03_LANG
 
 template 
 class __tree

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=291969&r1=291968&r2=291969&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Jan 13 16:42:53 2017
@@ -4715,15 +4715,6 @@ struct __can_extract_map_key<_ValTy, _Ke
 
 #endif
 
-template 
-struct __is_const_comparable : false_type {};
-
-template 
-struct __is_const_comparable<_Comp, _ValueType, typename __void_t<
-decltype(_VSTD::declval<_Comp const&>()(_VSTD::declval<_ValueType 
const&>(),
-_VSTD::declval<_ValueType 
const&>()))
-  >::type> : true_type {};
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_TYPE_TRAITS

Modified: libcxx/trunk/include/unordered_map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=291969&r1=291968&r2=291969&view=diff
=

Re: r291963 - [clang] Emit `diagnose_if` warnings from system headers

2017-01-13 Thread Eric Fiselier via cfe-commits
I would love to see this merged. It would make it easier to write libc++
tests if the tests didn't have to worry about the old 4.0 behavior.

CC'ing Richard: Would merging this be OK?

On Fri, Jan 13, 2017 at 3:46 PM, George Burgess IV <
george.burgess...@gmail.com> wrote:

> Do we want to consider merging this into the release branch? Seems like
> more of a bugfix than a feature to me.
>
> On Fri, Jan 13, 2017 at 2:11 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Fri Jan 13 16:11:40 2017
>> New Revision: 291963
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291963&view=rev
>> Log:
>> [clang] Emit `diagnose_if` warnings from system headers
>>
>> Summary: In order for libc++ to meaningfully use `diagnose_if` warnings
>> they need to be emitted from system headers by default. This patch changes
>> the `diagnose_if` warning diagnostic to be shown in system headers.
>>
>> Reviewers: george.burgess.iv, rsmith, aaron.ballman
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D28703
>>
>> Added:
>> cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/test/Sema/diagnose_if.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=291963&r1=291962&r2=291963&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
>> 16:11:40 2017
>> @@ -3380,7 +3380,8 @@ def note_ovl_candidate_has_pass_object_s
>>  "candidate address cannot be taken because parameter %0 has "
>>  "pass_object_size attribute">;
>>  def err_diagnose_if_succeeded : Error<"%0">;
>> -def warn_diagnose_if_succeeded : Warning<"%0">,
>> InGroup;
>> +def warn_diagnose_if_succeeded : Warning<"%0">,
>> InGroup,
>> +ShowInSystemHeader;
>>  def note_ovl_candidate_disabled_by_function_cond_attr : Note<
>>  "candidate disabled: %0">;
>>  def note_ovl_candidate_disabled_by_extension : Note<
>>
>> Added: cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inpu
>> ts/diagnose-if-warn-system-header.h?rev=291963&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h (added)
>> +++ cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h Fri Jan
>> 13 16:11:40 2017
>> @@ -0,0 +1,11 @@
>> +#pragma GCC system_header
>> +
>> +inline int system_header_func(int x)
>> +  __attribute__((diagnose_if(x == x, "system header warning",
>> "warning"))) // expected-note {{from 'diagnose_if' attribute}}
>> +{
>> +  return 0;
>> +}
>> +
>> +void test_system_header() {
>> +  system_header_func(0); // expected-warning {{system header warning}}
>> +}
>>
>> Modified: cfe/trunk/test/Sema/diagnose_if.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diag
>> nose_if.c?rev=291963&r1=291962&r2=291963&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Sema/diagnose_if.c (original)
>> +++ cfe/trunk/test/Sema/diagnose_if.c Fri Jan 13 16:11:40 2017
>> @@ -150,3 +150,6 @@ void alwaysWarnWithArg(int a) _diagnose_
>>  void runAlwaysWarnWithArg(int a) {
>>alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}}
>>  }
>> +
>> +// Test that diagnose_if warnings generated in system headers are not
>> ignored.
>> +#include "Inputs/diagnose-if-warn-system-header.h"
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-13 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google abandoned this revision.
jgravelle-google added a comment.

Abandoning this in favor of https://github.com/kripken/emscripten/pull/4846


https://reviews.llvm.org/D28381



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


[PATCH] D28457: Add missing const qualifier to member function Decl::isLocalExternDecl()

2017-01-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a reviewer: ahatanak.
ahatanak added a comment.
This revision is now accepted and ready to land.

This looks OK to commit.


https://reviews.llvm.org/D28457



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


r291974 - clang-format: Fix bug in making line break decisions.

2017-01-13 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Jan 13 17:18:16 2017
New Revision: 291974

URL: http://llvm.org/viewvc/llvm-project?rev=291974&view=rev
Log:
clang-format: Fix bug in making line break decisions.

Here, the optimization to not line wrap when it would not lead to a
reduction in columns was overwriting and enforced break that we want to
do no matter what.

Before:
  int i = someFunction(
  aaa,
  0).aaa(a) *
  aaa +
  aaa;

After:
  int i = someFunction(aaa, 0)
  .aaa(a) *
  aaa +
  aaa;

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=291974&r1=291973&r2=291974&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Jan 13 17:18:16 2017
@@ -191,6 +191,11 @@ bool ContinuationIndenter::mustBreak(con
Current.NestingLevel < State.StartOfLineLevel))
 return true;
 
+  if (startsSegmentOfBuilderTypeCall(Current) &&
+  (State.Stack.back().CallContinuation != 0 ||
+   State.Stack.back().BreakBeforeParameter))
+return true;
+
   if (State.Column <= NewLineColumn)
 return false;
 
@@ -255,11 +260,6 @@ bool ContinuationIndenter::mustBreak(con
   !Previous.is(tok::kw_template) && 
State.Stack.back().BreakBeforeParameter)
 return true;
 
-  if (startsSegmentOfBuilderTypeCall(Current) &&
-  (State.Stack.back().CallContinuation != 0 ||
-   State.Stack.back().BreakBeforeParameter))
-return true;
-
   // The following could be precomputed as they do not depend on the state.
   // However, as they should take effect only if the UnwrappedLine does not fit
   // into the ColumnLimit, they are checked here in the ContinuationIndenter.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=291974&r1=291973&r2=291974&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 13 17:18:16 2017
@@ -3438,6 +3438,12 @@ TEST_F(FormatTest, LineBreakingInBinaryE
   " ||  ||\n"
   ") {\n}",
   OnePerLine);
+
+  verifyFormat("int i = someFunction(aaa, 0)\n"
+   ".aaa(a) *\n"
+   "aaa +\n"
+   "aaa;",
+   getLLVMStyleWithColumns(40));
 }
 
 TEST_F(FormatTest, ExpressionIndentation) {


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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-01-13 Thread Manman Ren via Phabricator via cfe-commits
manmanren updated this revision to Diff 84406.
manmanren marked 7 inline comments as done.
manmanren added a comment.

Add CC1 option to control hashing of the module file content.


https://reviews.llvm.org/D27689

Files:
  include/clang/AST/ExternalASTSource.h
  include/clang/Basic/Module.h
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/PCHContainerOperations.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  lib/Basic/Module.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  lib/Serialization/Module.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/diagnostic-options-out-of-date.m
  test/Modules/module_file_info.m
  test/Modules/rebuild.m

Index: test/Modules/rebuild.m
===
--- test/Modules/rebuild.m
+++ test/Modules/rebuild.m
@@ -19,11 +19,10 @@
 // RUN: diff %t/Module.size %t/Module.size.saved
 // RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
 
-// But the signature at least is expected to change, so we rebuild DependsOnModule.
-// NOTE: if we change how the signature is created, this test may need updating.
+// The signature is the hash of the PCM content, we will not rebuild rebuild DependsOnModule.
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
 // RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
-// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// RUN: diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
 
 // Rebuild Module, reset its timestamp, and verify its size hasn't changed
 // RUN: rm %t/Module.pcm
@@ -34,10 +33,9 @@
 // RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
 
 // Verify again with Module pre-imported.
-// NOTE: if we change how the signature is created, this test may need updating.
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
 // RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
-// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// RUN: diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
 
 #ifdef PREIMPORT
 @import Module;
Index: test/Modules/module_file_info.m
===
--- test/Modules/module_file_info.m
+++ test/Modules/module_file_info.m
@@ -29,11 +29,6 @@
 // CHECK: CPU:
 // CHECK: ABI:
 
-// CHECK: Diagnostic options:
-// CHECK:   IgnoreWarnings: Yes
-// CHECK:   Diagnostic flags:
-// CHECK: -Wunused
-
 // CHECK: Header search options:
 // CHECK:   System root [-isysroot=]: '/'
 // CHECK:   Use builtin include directories [-nobuiltininc]: Yes
@@ -47,3 +42,8 @@
 // CHECK:   Predefined macros:
 // CHECK: -DBLARG
 // CHECK: -DWIBBLE=WOBBLE
+
+// CHECK: Diagnostic options:
+// CHECK:   IgnoreWarnings: Yes
+// CHECK:   Diagnostic flags:
+// CHECK: -Wunused
Index: test/Modules/diagnostic-options-out-of-date.m
===
--- test/Modules/diagnostic-options-out-of-date.m
+++ test/Modules/diagnostic-options-out-of-date.m
@@ -7,6 +7,16 @@
 // RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
 // Make sure we don't error out when using the pch
 // RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation
+
+// Build A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s
+// Build pch that imports A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch
+// We will rebuild A.pcm and overwrite the original A.pcm that the pch imports, but the two versions have the same hash.
+// RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s
+// Make sure we don't error out when using the pch
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify
+
 // expected-no-diagnostics
 
 @import DiagOutOfDate;
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/Module

[libcxx] r291976 - Diagnose invalid memory orderings in

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 17:45:39 2017
New Revision: 291976

URL: http://llvm.org/viewvc/llvm-project?rev=291976&view=rev
Log:
Diagnose invalid memory orderings in 

Added:
libcxx/trunk/test/libcxx/atomics/diagnose_invalid_memory_order.fail.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/atomic

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291976&r1=291975&r2=291976&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan 13 17:45:39 2017
@@ -1008,9 +1008,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 
 #if __has_attribute(diagnose_if) && 
!defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
 # define _LIBCPP_DIAGNOSE_WARNING(...) \
-__attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
+__attribute__((diagnose_if(__VA_ARGS__, "warning")))
 # define _LIBCPP_DIAGNOSE_ERROR(...) \
-__attribute__((__diagnose_if__(__VA_ARGS__, "error")))
+__attribute__((diagnose_if(__VA_ARGS__, "error")))
 #else
 # define _LIBCPP_DIAGNOSE_WARNING(...)
 # define _LIBCPP_DIAGNOSE_ERROR(...)

Modified: libcxx/trunk/include/atomic
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=291976&r1=291975&r2=291976&view=diff
==
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Fri Jan 13 17:45:39 2017
@@ -560,6 +560,22 @@ void atomic_signal_fence(memory_order m)
 # define __cpp_lib_atomic_is_always_lock_free 201603L
 #endif
 
+#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
+  _LIBCPP_DIAGNOSE_WARNING(__m == memory_order_consume || \
+   __m == memory_order_acquire || \
+   __m == memory_order_acq_rel,   \
+"memory order argument to atomic operation is invalid")
+
+#define _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) \
+  _LIBCPP_DIAGNOSE_WARNING(__m == memory_order_release || \
+   __m == memory_order_acq_rel,   \
+"memory order argument to atomic operation is invalid")
+
+#define _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__m, __f) \
+  _LIBCPP_DIAGNOSE_WARNING(__f == memory_order_release || \
+   __f == memory_order_acq_rel,   \
+"memory order argument to atomic operation is invalid")
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 typedef enum memory_order
@@ -881,15 +897,19 @@ struct __atomic_base  // false
 {return static_cast<__atomic_base const 
volatile*>(this)->is_lock_free();}
 _LIBCPP_INLINE_VISIBILITY
 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile 
_NOEXCEPT
+  _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
 {__c11_atomic_store(&__a_, __d, __m);}
 _LIBCPP_INLINE_VISIBILITY
 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+  _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
 {__c11_atomic_store(&__a_, __d, __m);}
 _LIBCPP_INLINE_VISIBILITY
 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+  _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
 {return __c11_atomic_load(&__a_, __m);}
 _LIBCPP_INLINE_VISIBILITY
 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+  _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
 {return __c11_atomic_load(&__a_, __m);}
 _LIBCPP_INLINE_VISIBILITY
 operator _Tp() const volatile _NOEXCEPT {return load();}
@@ -904,18 +924,22 @@ struct __atomic_base  // false
 _LIBCPP_INLINE_VISIBILITY
 bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) volatile 
_NOEXCEPT
+  _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, 
__f);}
 _LIBCPP_INLINE_VISIBILITY
 bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT
+  _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, 
__f);}
 _LIBCPP_INLINE_VISIBILITY
 bool compare_exchange_strong(_Tp& __e, _Tp __d,
  memory_order __s, memory_order __f) volatile 
_NOEXCEPT
+  _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, 
__f);}
 _LIBCPP_INLINE_VISIBILITY
 bool compare_exchange_strong(_Tp& __e, _Tp __d,
  memory_order __s, memory_order __f) _NOEXCEPT
+  _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, 
__f);}
 _LIBCPP_INLINE_VISIBILITY
 bool compare_exchange_weak(_Tp& __e, _Tp __d,
@@ -1181,6 +1205,7 @@ template 
 inline 

Re: r291964 - PR31631: fix bad CFG (and bogus warnings) when an if-statement has an init-statement and has binary operator as its condition.

2017-01-13 Thread Hans Wennborg via cfe-commits
Merged in r291978.

(Please keep the list cc'd on merge requests.)

Thanks,
Hans

On Fri, Jan 13, 2017 at 2:28 PM, Richard Smith  wrote:
> Seems sensible to put this in clang 4.
>
> -- Forwarded message --
> From: Richard Smith via cfe-commits 
> Date: 13 January 2017 at 14:16
> Subject: r291964 - PR31631: fix bad CFG (and bogus warnings) when an
> if-statement has an init-statement and has binary operator as its condition.
> To: cfe-commits@lists.llvm.org
>
>
> Author: rsmith
> Date: Fri Jan 13 16:16:41 2017
> New Revision: 291964
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291964&view=rev
> Log:
> PR31631: fix bad CFG (and bogus warnings) when an if-statement has an
> init-statement and has binary operator as its condition.
>
> Modified:
> cfe/trunk/lib/Analysis/CFG.cpp
> cfe/trunk/test/SemaCXX/uninitialized.cpp
>
> Modified: cfe/trunk/lib/Analysis/CFG.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=291964&r1=291963&r2=291964&view=diff
> ==
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Fri Jan 13 16:16:41 2017
> @@ -2175,19 +2175,15 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
>SaveAndRestore save_scope_pos(ScopePos);
>
>// Create local scope for C++17 if init-stmt if one exists.
> -  if (Stmt *Init = I->getInit()) {
> -LocalScope::const_iterator BeginScopePos = ScopePos;
> +  if (Stmt *Init = I->getInit())
>  addLocalScopeForStmt(Init);
> -addAutomaticObjDtors(ScopePos, BeginScopePos, I);
> -  }
>
>// Create local scope for possible condition variable.
>// Store scope position. Add implicit destructor.
> -  if (VarDecl *VD = I->getConditionVariable()) {
> -LocalScope::const_iterator BeginScopePos = ScopePos;
> +  if (VarDecl *VD = I->getConditionVariable())
>  addLocalScopeForVarDecl(VD);
> -addAutomaticObjDtors(ScopePos, BeginScopePos, I);
> -  }
> +
> +  addAutomaticObjDtors(ScopePos, save_scope_pos.get(), I);
>
>// The block we were processing is now finished.  Make it the successor
>// block.
> @@ -2256,36 +2252,39 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
>// removes infeasible paths from the control-flow graph by having the
>// control-flow transfer of '&&' or '||' go directly into the then/else
>// blocks directly.
> -  if (!I->getConditionVariable())
> -if (BinaryOperator *Cond =
> -dyn_cast(I->getCond()->IgnoreParens()))
> -  if (Cond->isLogicalOp())
> -return VisitLogicalOperator(Cond, I, ThenBlock, ElseBlock).first;
> -
> -  // Now create a new block containing the if statement.
> -  Block = createBlock(false);
> +  BinaryOperator *Cond =
> +  I->getConditionVariable()
> +  ? nullptr
> +  : dyn_cast(I->getCond()->IgnoreParens());
> +  CFGBlock *LastBlock;
> +  if (Cond && Cond->isLogicalOp())
> +LastBlock = VisitLogicalOperator(Cond, I, ThenBlock, ElseBlock).first;
> +  else {
> +// Now create a new block containing the if statement.
> +Block = createBlock(false);
>
> -  // Set the terminator of the new block to the If statement.
> -  Block->setTerminator(I);
> +// Set the terminator of the new block to the If statement.
> +Block->setTerminator(I);
>
> -  // See if this is a known constant.
> -  const TryResult &KnownVal = tryEvaluateBool(I->getCond());
> +// See if this is a known constant.
> +const TryResult &KnownVal = tryEvaluateBool(I->getCond());
>
> -  // Add the successors.  If we know that specific branches are
> -  // unreachable, inform addSuccessor() of that knowledge.
> -  addSuccessor(Block, ThenBlock, /* isReachable = */ !KnownVal.isFalse());
> -  addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
> -
> -  // Add the condition as the last statement in the new block.  This may
> create
> -  // new blocks as the condition may contain control-flow.  Any newly
> created
> -  // blocks will be pointed to be "Block".
> -  CFGBlock *LastBlock = addStmt(I->getCond());
> -
> -  // If the IfStmt contains a condition variable, add it and its
> -  // initializer to the CFG.
> -  if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) {
> -autoCreateBlock();
> -LastBlock = addStmt(const_cast(DS));
> +// Add the successors.  If we know that specific branches are
> +// unreachable, inform addSuccessor() of that knowledge.
> +addSuccessor(Block, ThenBlock, /* isReachable = */
> !KnownVal.isFalse());
> +addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
> +
> +// Add the condition as the last statement in the new block.  This may
> +// create new blocks as the condition may contain control-flow.  Any
> newly
> +// created blocks will be pointed to be "Block".
> +LastBlock = addStmt(I->getCond());
> +
> +// If the IfStmt contains a condition variable, add it and its
> +// initializer to the C

[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-01-13 Thread Manman Ren via Phabricator via cfe-commits
manmanren marked an inline comment as done.
manmanren added inline comments.



Comment at: include/clang/Serialization/Module.h:19
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"

rsmith wrote:
> Redundant include?
Definition of ASTFileSignature is moved from Serialization/Module.h to 
Basic/Module.h so we need to have this include to get the definition.



Comment at: lib/Serialization/ASTWriter.cpp:1356
+  ASTFileSignature RetCode{{0}};
+  if (WritingModule && Context.getLangOpts().ImplicitModules)
+RetCode = WriteHash(0);

rsmith wrote:
> I don't think it makes sense to use `ImplicitModules` to control this. Doing 
> that for the old signature computation was at best a hack.
> 
> If there is no measurable performance difference from the hashing, we should 
> just do it unconditionally in all modes. Otherwise, there should be a 
> separate flag to control it; we should probably force that flag to be enabled 
> when the frontend implicitly builds a module and inserts it into the module 
> cache, but otherwise let the user control it as they see fit.
Use HSOpts.ModulesHashContent to guard the hashing of module file content. This 
flag is set to true when we implicitly build a module.


https://reviews.llvm.org/D27689



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


LLVM buildmaster is back to work

2017-01-13 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster is back to work.
Please let me know if there are any issues.

Thanks 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] D28592: [libcxx] [test] Fix MSVC warning C4127 "conditional expression is constant".

2017-01-13 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT abandoned this revision.
STL_MSFT added a comment.

Actually, this pattern annoys "warning C6326: Potential comparison of a 
constant with another constant." from /analyze. I'll figure out a better fix, 
probably with integral_constant.


https://reviews.llvm.org/D28592



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


[PATCH] D28705: [Sema] Fix bug in handling of designated initializer

2017-01-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

What happens with virtual bases?

  struct B { int x; };
  struct D : virtual B { int y; };
  void test() { D d = {1, .y = 2}; }




Comment at: lib/Sema/SemaInit.cpp:2250
 
+if (auto *CXXRD = dyn_cast(RT->getDecl()))
+  FieldIndex += CXXRD->getNumBases();

Do this before counting fields, IMO it's more intuitive.



Comment at: test/SemaCXX/designated-initializers-base-class.cpp:1
+// RUN: %clang_cc1 %s -std=c++1z -ast-dump | FileCheck %s
+

This might be less fragile as an IRGen test. Alternatively, this is a good 
expected-no-diagnostic test:
  void test() { D d = {1, .y = 2}; }

Right now we emit `warning: initializer overrides prior initialization of this 
subobject`, which is obviously wrong.


https://reviews.llvm.org/D28705



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


[PATCH] D28716: [libc++] Diagnose null inputs in std::string using _LIBCPP_DIAGNOSE_WARNING

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

This patch uses `diagnose_if` to attempt to catch null inputs in `std::string`. 
Note that unlike `__attribute__((non_null))` `diagnose_if` does not affect 
codegen.


https://reviews.llvm.org/D28716

Files:
  include/string
  test/libcxx/strings/diagnose_null_pointer.fail.cpp

Index: test/libcxx/strings/diagnose_null_pointer.fail.cpp
===
--- /dev/null
+++ test/libcxx/strings/diagnose_null_pointer.fail.cpp
@@ -0,0 +1,143 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: diagnose-if-support, verify-support
+
+// Test that libc++ generates a warning diagnostic when the container is
+// provided a non-const callable comparator.
+
+#include 
+#include 
+
+void test_constructors() {
+#if 0 // FIXME: Add diagnose_if to string constructors
+  std::string s1(nullptr); // expected-warning 1+ {{cannot construct string from a null pointer}}
+  std::string s2(nullptr, std::allocator()); // expected-warning 1+ {{cannot construct string from a null pointer}}
+  std::string s3(nullptr, 0);
+  std::string s4(nullptr, 1); // expected-warning 1+ {{cannot construct string from a null pointer}}
+  std::string s5(nullptr, 0, std::allocator());
+  std::string s6(nullptr, 1, std::allocator()); // expected-warning 1+ {{cannot construct string from a null pointer}}
+#endif
+}
+
+void test_assignment() {
+  std::string s1;
+  s1 = nullptr; // expected-warning 1+ {{pointer cannot be null}}
+  s1.assign(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+  s1.assign(nullptr); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_append() {
+  std::string s;
+  s.append(nullptr, 0);
+  s.append(nullptr, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.append(nullptr); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_insert() {
+  std::string s;
+  s.insert(0, nullptr, 0); // OK
+  s.insert(0, nullptr, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.insert(0, nullptr); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_replace() {
+  std::string s;
+  s.replace(0, 0, nullptr, 0);
+  s.replace(0, 0, nullptr, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.replace(0, 0, nullptr); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_find() {
+  std::string s;
+  s.find(nullptr, 0, 0);
+  s.find(nullptr, 0, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.find(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_rfind() {
+  std::string s;
+  s.rfind(nullptr, 0, 0);
+  s.rfind(nullptr, 0, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.rfind(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_find_first_of() {
+  std::string s;
+  s.find_first_of(nullptr, 0, 0);
+  s.find_first_of(nullptr, 0, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.find_first_of(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_find_last_of() {
+  std::string s;
+  s.find_last_of(nullptr, 0, 0);
+  s.find_last_of(nullptr, 0, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.find_last_of(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+
+void test_find_first_not_of() {
+  std::string s;
+  s.find_first_not_of(nullptr, 0, 0);
+  s.find_first_not_of(nullptr, 0, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.find_first_not_of(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_find_last_not_of() {
+  std::string s;
+  s.find_last_not_of(nullptr, 0, 0);
+  s.find_last_not_of(nullptr, 0, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.find_last_not_of(nullptr, 0); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+void test_compare() {
+  std::string s;
+  s.compare(0, 0, nullptr, 0);
+  s.compare(0, 0, nullptr, 1); // expected-warning 1+ {{pointer cannot be null}}
+  s.compare(0, 0, nullptr); // expected-warning 1+ {{pointer cannot be null}}
+  s.compare(nullptr); // expected-warning 1+ {{pointer cannot be null}}
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wunused-comparison"
+#endif
+
+void test_comparison_operators() {
+  std::string s;
+  s == static_cast(nullptr); // expected-warning 1+ {{pointer cannot be null}}
+  static_cast(nullptr) == s; // expected-warning 1+ {{pointer cannot be null}}
+  s != static_cast(nullptr); // expected-warning 1+ {{pointer cannot be null}}
+  static_cast(nullptr) != s; // expected-warning 1+ {{po

[libcxx] r291986 - Remove unused parameters in C++03

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 19:33:53 2017
New Revision: 291986

URL: http://llvm.org/viewvc/llvm-project?rev=291986&view=rev
Log:
Remove unused parameters in C++03

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=291986&r1=291985&r2=291986&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Fri Jan 13 19:33:53 2017
@@ -1542,26 +1542,26 @@ struct _LIBCPP_TEMPLATE_VIS allocator_tr
 #else  // _LIBCPP_HAS_NO_VARIADICS
 template 
 _LIBCPP_INLINE_VISIBILITY
-static void construct(allocator_type& __a, _Tp* __p)
+static void construct(allocator_type&, _Tp* __p)
 {
 ::new ((void*)__p) _Tp();
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
-static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0)
+static void construct(allocator_type&, _Tp* __p, const _A0& __a0)
 {
 ::new ((void*)__p) _Tp(__a0);
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
-static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0,
+static void construct(allocator_type&, _Tp* __p, const _A0& __a0,
   const _A1& __a1)
 {
 ::new ((void*)__p) _Tp(__a0, __a1);
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
-static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0,
+static void construct(allocator_type&, _Tp* __p, const _A0& __a0,
   const _A1& __a1, const _A2& __a2)
 {
 ::new ((void*)__p) _Tp(__a0, __a1, __a2);


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


Re: [libcxx] r291072 - Get test-suite configuring on Windows with clang-cl

2017-01-13 Thread Eric Fiselier via cfe-commits
On Thu, Jan 12, 2017 at 1:17 AM, Shoaib Meenai  wrote:

> What was the rationale for forcing the use of lld? Were errors encountered
> with link? It's slightly annoying to have the extra dependency;



Initially I thought it was required in order to avoid re-writing all of the
linker flags.
However that is probably incorrect, and having the extra dependency is
annoying.

 I've also found link to work fine in my testing.
>

Awesome! I'll confirm and remove the dependency on lld.


>
> On 1/4/17, 7:57 PM, "cfe-commits on behalf of Eric Fiselier via
> cfe-commits"  cfe-commits@lists.llvm.org> wrote:
>
> Author: ericwf
> Date: Wed Jan  4 21:57:40 2017
> New Revision: 291072
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.
> org_viewvc_llvm-2Dproject-3Frev-3D291072-26view-3Drev&d=DgIGaQ&c=
> 5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-
> p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=cUS_8mdoEB_rXOeiVb12wPPxI4SMXpq9A_
> cY9hOGe2g&e=
> Log:
> Get test-suite configuring on Windows with clang-cl
>
> This patch gets the test suite "working" on Windows, although
> none of the tests pass.
>
> In order to reuse the existing configuration, which uses UNIX
> style flags not accepted by clang-cl, this patch only works with
> clang++.
> When clang-cl is specified the test harness secretly looks for
> clang++ and then it configures it using the INCLUDE and LIB enviroment
> variables.
>
> This is very much a work in progress.
>
> Modified:
> libcxx/trunk/test/libcxx/test/config.py
>
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.
> org_viewvc_llvm-2Dproject_libcxx_trunk_test_libcxx_test_
> config.py-3Frev-3D291072-26r1-3D291071-26r2-3D291072-26view-
> 3Ddiff&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-
> p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=VifHtrNoBswm5JlmYYAj81SdYnWxg3
> XJxLzZsaw9vrs&e=
> 
> ==
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Wed Jan  4 21:57:40 2017
> @@ -57,7 +57,9 @@ class Configuration(object):
>  def __init__(self, lit_config, config):
>  self.lit_config = lit_config
>  self.config = config
> +self.is_windows = platform.system() == 'Windows'
>  self.cxx = None
> +self.cxx_is_clang_cl = None
>  self.cxx_stdlib_under_test = None
>  self.project_obj_root = None
>  self.libcxx_src_root = None
> @@ -95,6 +97,13 @@ class Configuration(object):
>  self.lit_config.fatal(
>  "parameter '{}' should be true or false".format(name))
>
> +def make_static_lib_name(self, name):
> +"""Return the full filename for the specified library name"""
> +if self.is_windows:
> +return name + '.lib'
> +else:
> +return 'lib' + name + '.a'
> +
>  def configure(self):
>  self.configure_executor()
>  self.configure_target_info()
> @@ -171,20 +180,25 @@ class Configuration(object):
>  def configure_cxx(self):
>  # Gather various compiler parameters.
>  cxx = self.get_lit_conf('cxx_under_test')
> -
> +self.cxx_is_clang_cl = cxx is not None and \
> +   os.path.basename(cxx) == 'clang-cl.exe'
>  # If no specific cxx_under_test was given, attempt to infer
> it as
>  # clang++.
> -if cxx is None:
> +if cxx is None or self.cxx_is_clang_cl:
>  clangxx = lit.util.which('clang++',
>   self.config.environment['PATH'])
>  if clangxx:
>  cxx = clangxx
>  self.lit_config.note(
>  "inferred cxx_under_test as: %r" % cxx)
> +elif self.cxx_is_clang_cl:
> +self.lit_config.fatal('Failed to find clang++
> substitution for'
> +  ' clang-cl')
>  if not cxx:
>  self.lit_config.fatal('must specify user parameter
> cxx_under_test '
>'(e.g.,
> --param=cxx_under_test=clang++)')
> -self.cxx = CXXCompiler(cxx)
> +self.cxx = CXXCompiler(cxx) if not self.cxx_is_clang_cl else \
> +   self._configure_clang_cl(cxx)
>  cxx_type = self.cxx.type
>  if cxx_type is not None:
>  assert self.cxx.version is not None
> @@ -194,6 +208,25 @@ class Configuration(object):
>  self.config.available_features.add('%s-%s.%s' % (
>  cxx_type, maj_v, min_v))
>
> +def _config

Re: [libcxx] r291072 - Get test-suite configuring on Windows with clang-cl

2017-01-13 Thread Shoaib Meenai via cfe-commits
Ah. lld-link actually only accepts link-style options, so it wouldn't solve
that particular problem. Happily, it seems like we aren't relying on ld-style
options to begin with.

From: Eric Fiselier 
Date: Friday, January 13, 2017 at 5:52 PM
To: Shoaib Meenai 
Cc: "cfe-commits@lists.llvm.org" 
Subject: Re: [libcxx] r291072 - Get test-suite configuring on Windows with 
clang-cl



On Thu, Jan 12, 2017 at 1:17 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:
What was the rationale for forcing the use of lld? Were errors encountered
with link? It's slightly annoying to have the extra dependency;


Initially I thought it was required in order to avoid re-writing all of the 
linker flags.
However that is probably incorrect, and having the extra dependency is annoying.

 I've also found link to work fine in my testing.

Awesome! I'll confirm and remove the dependency on lld.


On 1/4/17, 7:57 PM, "cfe-commits on behalf of Eric Fiselier via cfe-commits" 
mailto:cfe-commits-boun...@lists.llvm.org> 
on behalf of cfe-commits@lists.llvm.org> 
wrote:

Author: ericwf
Date: Wed Jan  4 21:57:40 2017
New Revision: 291072

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D291072-26view-3Drev&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=cUS_8mdoEB_rXOeiVb12wPPxI4SMXpq9A_cY9hOGe2g&e=
Log:
Get test-suite configuring on Windows with clang-cl

This patch gets the test suite "working" on Windows, although
none of the tests pass.

In order to reuse the existing configuration, which uses UNIX
style flags not accepted by clang-cl, this patch only works with clang++.
When clang-cl is specified the test harness secretly looks for
clang++ and then it configures it using the INCLUDE and LIB enviroment
variables.

This is very much a work in progress.

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_test_libcxx_test_config.py-3Frev-3D291072-26r1-3D291071-26r2-3D291072-26view-3Ddiff&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=VifHtrNoBswm5JlmYYAj81SdYnWxg3XJxLzZsaw9vrs&e=

==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Wed Jan  4 21:57:40 2017
@@ -57,7 +57,9 @@ class Configuration(object):
 def __init__(self, lit_config, config):
 self.lit_config = lit_config
 self.config = config
+self.is_windows = platform.system() == 'Windows'
 self.cxx = None
+self.cxx_is_clang_cl = None
 self.cxx_stdlib_under_test = None
 self.project_obj_root = None
 self.libcxx_src_root = None
@@ -95,6 +97,13 @@ class Configuration(object):
 self.lit_config.fatal(
 "parameter '{}' should be true or false".format(name))

+def make_static_lib_name(self, name):
+"""Return the full filename for the specified library name"""
+if self.is_windows:
+return name + '.lib'
+else:
+return 'lib' + name + '.a'
+
 def configure(self):
 self.configure_executor()
 self.configure_target_info()
@@ -171,20 +180,25 @@ class Configuration(object):
 def configure_cxx(self):
 # Gather various compiler parameters.
 cxx = self.get_lit_conf('cxx_under_test')
-
+self.cxx_is_clang_cl = cxx is not None and \
+   os.path.basename(cxx) == 'clang-cl.exe'
 # If no specific cxx_under_test was given, attempt to infer it as
 # clang++.
-if cxx is None:
+if cxx is None or self.cxx_is_clang_cl:
 clangxx = lit.util.which('clang++',
  self.config.environment['PATH'])
 if clangxx:
 cxx = clangxx
 self.lit_config.note(
 "inferred cxx_under_test as: %r" % cxx)
+elif self.cxx_is_clang_cl:
+self.lit_config.fatal('Failed to find clang++ substitution 
for'
+  ' clang-cl')
 if not cxx:
 self.lit_config.fatal('must specify user parameter 
cxx_under_test '
   '(e.g., --param=cxx_under_test=clang++)')
-self.cxx = CXXCompiler(cxx)
+self.cxx = CXXCompiler(cxx) if not self.cxx_is_clang_cl else \
+   self._configure_clang_cl(cxx)
 cxx_type = self.

[libcxx] r291987 - Don't force use of lld in tests on Windows

2017-01-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 13 19:58:01 2017
New Revision: 291987

URL: http://llvm.org/viewvc/llvm-project?rev=291987&view=rev
Log:
Don't force use of lld in tests on Windows

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=291987&r1=291986&r2=291987&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jan 13 19:58:01 2017
@@ -219,7 +219,7 @@ class Configuration(object):
 # FIXME: don't hardcode the target
 flags = ['--target=i686-pc-windows']
 compile_flags = []
-link_flags = ['-fuse-ld=lld']
+link_flags = []
 if 'INCLUDE' in os.environ:
 compile_flags += ['-isystem %s' % p.strip()
   for p in os.environ['INCLUDE'].split(';')


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


r291988 - Give more accurate descriptions of what kind of template we found in diagnostics.

2017-01-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 13 20:19:59 2017
New Revision: 291988

URL: http://llvm.org/viewvc/llvm-project?rev=291988&view=rev
Log:
Give more accurate descriptions of what kind of template we found in 
diagnostics.

We were previouly assuming that every type template was a class template, which
is not true any more.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp
cfe/trunk/test/SemaTemplate/alias-templates.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291988&r1=291987&r2=291988&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13 20:19:59 
2017
@@ -3796,11 +3796,13 @@ def err_template_decl_ref : Error<
 
 // C++ Template Argument Lists
 def err_template_missing_args : Error<
-  "use of class template %0 requires template arguments">;
+  "use of "
+  "%select{class template|function template|variable template|alias template|"
+  "template template parameter|template}0 %1 requires template arguments">;
 def err_template_arg_list_different_arity : Error<
   "%select{too few|too many}0 template arguments for "
-  "%select{class template|function template|template template parameter"
-  "|template}1 %2">;
+  "%select{class template|function template|variable template|alias template|"
+  "template template parameter|template}1 %2">;
 def note_template_decl_here : Note<"template is declared here">;
 def err_template_arg_must_be_type : Error<
   "template argument for template type parameter must be a type">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=291988&r1=291987&r2=291988&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 13 20:19:59 2017
@@ -1689,6 +1689,18 @@ public:
bool IsAddressOfOperand,
std::unique_ptr CCC = nullptr);
 
+  /// Describes the detailed kind of a template name. Used in diagnostics.
+  enum class TemplateNameKindForDiagnostics {
+ClassTemplate,
+FunctionTemplate,
+VarTemplate,
+AliasTemplate,
+TemplateTemplateParam,
+DependentTemplate
+  };
+  TemplateNameKindForDiagnostics
+  getTemplateNameKindForDiagnostics(TemplateName Name);
+
   Decl *ActOnDeclarator(Scope *S, Declarator &D);
 
   NamedDecl *HandleDeclarator(Scope *S, Declarator &D,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=291988&r1=291987&r2=291988&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 13 20:19:59 2017
@@ -656,7 +656,8 @@ void Sema::DiagnoseUnknownTypeName(Ident
Name, nullptr, true, TemplateResult,
MemberOfUnknownSpecialization) == TNK_Type_template) {
   TemplateName TplName = TemplateResult.get();
-  Diag(IILoc, diag::err_template_missing_args) << TplName;
+  Diag(IILoc, diag::err_template_missing_args)
+<< (int)getTemplateNameKindForDiagnostics(TplName) << TplName;
   if (TemplateDecl *TplDecl = TplName.getAsTemplateDecl()) {
 Diag(TplDecl->getLocation(), diag::note_template_decl_here)
   << TplDecl->getTemplateParameters()->getSourceRange();
@@ -1072,6 +1073,24 @@ Corrected:
   return BuildDeclarationNameExpr(SS, Result, ADL);
 }
 
+Sema::TemplateNameKindForDiagnostics
+Sema::getTemplateNameKindForDiagnostics(TemplateName Name) {
+  auto *TD = Name.getAsTemplateDecl();
+  if (!TD)
+return TemplateNameKindForDiagnostics::DependentTemplate;
+  if (isa(TD))
+return TemplateNameKindForDiagnostics::ClassTemplate;
+  if (isa(TD))
+return TemplateNameKindForDiagnostics::FunctionTemplate;
+  if (isa(TD))
+return TemplateNameKindForDiagnostics::VarTemplate;
+  if (isa(TD))
+return TemplateNameKindForDiagnostics::AliasTemplate;
+  if (isa(TD))
+return TemplateNameKindForDiagnostics::TemplateTemplateParam;
+  return TemplateNameKindForDiagnostics::DependentTemplate;
+}
+
 // Determines the context to return to after temporarily entering a
 // context.  This depends in an unnecessarily complicated way on the
 // exact ordering of callbacks from the parser.

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=291988&r1=291987&r2=291988&view=diff
=

[PATCH] D28441: [libc++] [CMake] Link with /nodefaultlibs on Windows

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D28441#639023, @smeenai wrote:

> One potential issue with always forcing the non-debug msvcrt is that any apps 
> that link against libc++ would also then need to use the non-debug CRT 
> libraries, otherwise you'd get all sorts of fun runtime errors (e.g. 
> cross-domain frees). I think the default Visual Studio settings are to link 
> against `msvcrtd`, `ucrtd`, etc. for debug builds and `msvcrt`, `ucrt`, etc. 
> for release builds, so having libc++ unconditionally use the non-debug 
> versions is probably bad for interoperability.


I agree. Forcing the use of release libraries is just a starting point.

> I think the right thing to do would be to either always compile two versions 
> of libc++, one linked against the debug libraries and the other against the 
> non-debug libraries, or make the Debug configuration use the debug libraries 
> and the Release configuration use the release libraries (and have `config.py` 
> deal with this as well).

Is it OK if this is implemented *after* this patch?




Comment at: CMakeLists.txt:43
+if (WIN32 AND NOT MINGW)
+  set(LIBCXX_TARGETING_WINDOWS ON)
+else()

rnk wrote:
> smeenai wrote:
> > EricWF wrote:
> > > EricWF wrote:
> > > > smeenai wrote:
> > > > > Not the biggest fan of this name, since it's not obvious why MinGW 
> > > > > shouldn't count as targeting Windows. I thought of 
> > > > > `LIBCXX_TARGETING_NATIVE_WINDOWS` or `LIBCXX_TARGETING_MSVCRT` 
> > > > > instead, but MinGW is also native Windows and targets MSVCRT, so 
> > > > > those names aren't any better from that perspective either. I can't 
> > > > > think of anything else at the moment, but I'm sure there's a better 
> > > > > name.
> > > > Thanks for the feedback. I'm not exactly sure how this macro should be 
> > > > defined either.
> > > > 
> > > > I thought that `MinGW` provided its own C library runtime wrappers that 
> > > > forward to `MSVCRT`. 
> > > > 
> > > > The difference I was imagining between Native Windows builds and 
> > > > `MinGW` is that it's possible to use
> > > > `pthread` with `MinGW` but not with native Windows targets. 
> > > Another distinction I would like this macro to embody is whether on not 
> > > the compiler defines `_MSC_VER`.  `clang-cl`, `clang++`  on Windows, and 
> > > MSVC `cl` all define this macro.
> > If I recall correctly, MinGW uses `mscvrt.dll` but not `msvcrt.lib` (see my 
> > other comment for the distinction). I'm fine with this name for now then; 
> > we can always bikeshed later.
> > 
> > Btw it's also possible to use pthread with native Windows targets, via 
> > [pthreads-win32](http://www.sourceware.org/pthreads-win32/) or other 
> > libraries.
> I'd call this LIBCXX_TARGETING_MSVCRT. "msvcrt.dll" usually refers to an 
> ancient version (6?) of the Visual C runtime that is distributed as part of 
> Windows. Typically it is found at C:/Windows/system32/msvcrt.dll. Mingw uses 
> this, because it is available on all Windows systems they care to support. 
> This DLL basically never receives updates, so I wouldn't want to build libc++ 
> functionality on top of it. Over time, it seems that mingw has had to 
> implement more and more C runtime functionality itself, and I wouldn't want 
> libc++ to have to do that.
> 
> Until recently, MSVC users were required to redistribute the version of the 
> CRT they chose to link against, and it was expected that all DLLs sharing CRT 
> resources had to link against the same CRT version. Of course, this caused 
> problems, so they went back to the single, OS-provided CRT in VS 2015 
> (https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/).
> 
> My conclusion is that it's no longer worth thinking of that old DLL as the 
> Visual C runtime. It's just an artifact of history at this point. If you say 
> libc++ targets the MSVCRT, you're probably talking about the modern, 
> universal CRT.
> 
> ---
> 
> If you want this option to imply both the C++ ABI and the C runtime, then 
> LIBCXX_TARGETING_MSVC would probably be a more appropriate name. Clang and 
> LLVM have some support for using the Itanium C++ ABI with the MSVCRT, but it 
> is more experimental, and not ABI compatible with any existing software. 
> Saleem could say more about where he thinks this target will go in the future 
> and whether it's worth adding to the libc++ support configuration matrix.
> My conclusion is that it's no longer worth thinking of that old DLL as the 
> Visual C runtime. It's just an artifact of history at this point. If you say 
> libc++ targets the MSVCRT, you're probably talking about the modern, 
> universal CRT.

According to the [docs](https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx) 
`msvcrt` now contains the "startup files" for the universal CRT.

> If you want this option to imply both the C++ ABI and the C runtime, then 
> LIBCXX_TARGETING_MSVC would probably be a more appropriate name.

Ack. Changi

[PATCH] D28441: [libc++] [CMake] Link with /nodefaultlibs on Windows

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 84414.
EricWF added a comment.

Attempt to address review comments

- Rename `LIBCXX_TARGETING_WINDOWS` to `LIBCXX_TARGETING_MSVC`. It is set to on 
when CMake defines `MSVC` to `ON`. This macro is intented to represent cases 
where we are targeting native Windows and the native CRT.

There has been a lot of noise on this patch. What else needs to be done before 
committing?


https://reviews.llvm.org/D28441

Files:
  CMakeLists.txt
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt
  test/libcxx/test/config.py


Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -667,7 +667,7 @@
 self.cxx.link_flags += ['-lcxxrt']
 elif cxx_abi == 'none' or cxx_abi == 'default':
 if self.is_windows:
-self.cxx.link_flags += ['-lmsvcrtd']
+self.cxx.link_flags += ['-lmsvcrt']
 else:
 self.lit_config.fatal(
 'C++ ABI setting %s unsupported for tests' % cxx_abi)
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -104,6 +104,16 @@
 endif()
 add_link_flags_if_supported(-nodefaultlibs)
 
+if (LIBCXX_TARGETING_MSVC)
+  add_compile_flags(/Zl)
+  add_link_flags(/nodefaultlib)
+  add_library_flags(ucrt) # Universal C runtime
+  add_library_flags(vcruntime) # C++ runtime
+  add_library_flags(msvcrt) # C runtime startup files
+  # Required for wide character formatting functions (e.g. `printfw`/`scanfw`)
+  add_library_flags(iso_stdio_wide_specifiers)
+endif()
+
 if (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY)
   if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION)
 set(LIBCXX_LIBCPPABI_VERSION "2") # Default value
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -26,6 +26,10 @@
 # or added in other parts of LLVM's cmake configuration.
 macro(remove_flags)
   foreach(var ${ARGN})
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_DEBUG 
"${CMAKE_CXX_FLAGS_DEBUG}")
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_MINSIZEREL 
"${CMAKE_CXX_FLAGS_DEBUG}")
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELEASE 
"${CMAKE_CXX_FLAGS_DEBUG}")
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO 
"${CMAKE_CXX_FLAGS_DEBUG}")
 string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS 
"${CMAKE_EXE_LINKER_FLAGS}")
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -39,6 +39,12 @@
  build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
  )
 
+if (MSVC)
+  set(LIBCXX_TARGETING_MSVC ON)
+else()
+  set(LIBCXX_TARGETING_MSVC OFF)
+endif()
+
 
#===
 # Setup CMake Options
 
#===
@@ -377,6 +383,11 @@
 endif()
 remove_flags(-stdlib=libc++ -stdlib=libstdc++)
 
+# FIXME: Remove all debug flags and flags that change which Windows
+# default libraries are linked. Currently we only support linking the
+# non-debug DLLs
+remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md" "/RTC1")
+
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
 # so they don't get transformed into -Wno and -errors respectivly.
@@ -474,7 +485,7 @@
 # Assertion flags =
 define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
 define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
-if (LIBCXX_ENABLE_ASSERTIONS)
+if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_TARGETING_MSVC)
   # MSVC doesn't like _DEBUG on release builds. See PR 4379.
   define_if_not(MSVC -D_DEBUG)
 endif()


Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -667,7 +667,7 @@
 self.cxx.link_flags += ['-lcxxrt']
 elif cxx_abi == 'none' or cxx_abi == 'default':
 if self.is_windows:
-self.cxx.link_flags += ['-lmsvcrtd']
+self.cxx.link_flags += ['-lmsvcrt']
 else:
 self.lit_config.fatal(
 'C++ ABI setting %s unsupported for tests' % cxx_abi)
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -104,6 +104,16 @@
 endif()
 add_link_flags_if_supported(-nodefaultlibs)
 
+if (LIBCXX_TARGETING_MSVC)
+  add_compile_flags(/Zl)
+  add_link_flags(/nodefaultl

[PATCH] D28672: [ASTMatchers] update doc by running dump_ast_matchers.py

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not seeing anything wrong, per se, but why has so much of this file changed 
recently?


https://reviews.llvm.org/D28672



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


[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

2017-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I feel like I must be missing something; why is this disabling rather than 
specifying the thread safety behavior? e.g., `__libcpp_mutex_lock()` specifying 
that it acquires the capability and `__libcpp_mutex_unlock()` specifying that 
it releases it?


https://reviews.llvm.org/D28520



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


[PATCH] D28705: [Sema] Fix bug in handling of designated initializer

2017-01-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 84418.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Address review comments.


https://reviews.llvm.org/D28705

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/designated-initializers-base-class.cpp


Index: test/SemaCXX/designated-initializers-base-class.cpp
===
--- /dev/null
+++ test/SemaCXX/designated-initializers-base-class.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides
+// expected-no-diagnostics
+
+struct B {
+  int x;
+};
+
+struct D : B {
+  int y;
+};
+
+void test() { D d = {1, .y = 2}; }
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -2237,6 +2237,10 @@
 }
 
 unsigned FieldIndex = 0;
+
+if (auto *CXXRD = dyn_cast(RT->getDecl()))
+  FieldIndex = CXXRD->getNumBases();
+
 for (auto *FI : RT->getDecl()->fields()) {
   if (FI->isUnnamedBitfield())
 continue;


Index: test/SemaCXX/designated-initializers-base-class.cpp
===
--- /dev/null
+++ test/SemaCXX/designated-initializers-base-class.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides
+// expected-no-diagnostics
+
+struct B {
+  int x;
+};
+
+struct D : B {
+  int y;
+};
+
+void test() { D d = {1, .y = 2}; }
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -2237,6 +2237,10 @@
 }
 
 unsigned FieldIndex = 0;
+
+if (auto *CXXRD = dyn_cast(RT->getDecl()))
+  FieldIndex = CXXRD->getNumBases();
+
 for (auto *FI : RT->getDecl()->fields()) {
   if (FI->isUnnamedBitfield())
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22452: [libcxx] Fix last_write_time tests for filesystems that don't support negative and very large times.

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. Do you need somebody to commit this for you?

Let me know once you've committed it and I'll merge it into the 4.0 branch.


https://reviews.llvm.org/D22452



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


[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D28520#646160, @aaron.ballman wrote:

> I feel like I must be missing something; why is this disabling rather than 
> specifying the thread safety behavior? e.g., `__libcpp_mutex_lock()` 
> specifying that it acquires the capability and `__libcpp_mutex_unlock()` 
> specifying that it releases it?


I agree. Also how is `pthread_mutex_t` getting annotated as a mutex type? Is it 
now done automatically?


https://reviews.llvm.org/D28520



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


[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@cpplearner Do you need somebody to commit this for you?


https://reviews.llvm.org/D27850



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


[PATCH] D28705: [Sema] Fix bug in handling of designated initializer

2017-01-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D28705#646088, @rnk wrote:

> What happens with virtual bases?
>
>   struct B { int x; };
>   struct D : virtual B { int y; };
>   void test() { D d = {1, .y = 2}; }


A class with virtual base is not considered an aggregate, so it doesn't go 
through aggregate initialization (and therefore it doesn't enter 
CheckDesignatedInitializer). Instead, in TryListInitialization, it tries to 
find a matching constructor of D and fails.




Comment at: test/SemaCXX/designated-initializers-base-class.cpp:1
+// RUN: %clang_cc1 %s -std=c++1z -ast-dump | FileCheck %s
+

rnk wrote:
> This might be less fragile as an IRGen test. Alternatively, this is a good 
> expected-no-diagnostic test:
>   void test() { D d = {1, .y = 2}; }
> 
> Right now we emit `warning: initializer overrides prior initialization of 
> this subobject`, which is obviously wrong.
good idea.


https://reviews.llvm.org/D28705



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


[PATCH] D28591: [libcxx] [test] Don't ask whether Incomplete& can be assigned to.

2017-01-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM.

Although `is_assignable` can often get accidentally instantiated with an 
incomplete type by way of `std::tuple` or similar, which is the 
rational for this test case.


https://reviews.llvm.org/D28591



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


  1   2   >