[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-02-28 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/functional:1393
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+

smeenai wrote:
> EricWF wrote:
> > What's the rationale for making the dtor out-of-line? Couldn't we just use 
> > `what()` as the key function?
> We could, but this way it's consistent with all the other exception classes.
OK works for me. since it's a virtual function we probably won't see any 
benefits from inlining. 


https://reviews.llvm.org/D27387



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


Re: r296554 - [PS4] Set our default dialect to C++11. NFC for other targets.

2017-02-28 Thread Sean Silva via cfe-commits
Nice!

-- Sean Silva

On Tue, Feb 28, 2017 at 5:01 PM, Paul Robinson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: probinson
> Date: Tue Feb 28 19:01:10 2017
> New Revision: 296554
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296554=rev
> Log:
> [PS4] Set our default dialect to C++11. NFC for other targets.
> Reapplies r296209 now that r296549 has fixed what really seems to be
> the last problematic test.
>
> Modified:
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/CompilerInvocation.cpp?rev=296554=296553=296554=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Feb 28 19:01:10 2017
> @@ -1582,7 +1582,11 @@ void CompilerInvocation::setLangDefaults
>  case IK_PreprocessedCXX:
>  case IK_ObjCXX:
>  case IK_PreprocessedObjCXX:
> -  LangStd = LangStandard::lang_gnucxx98;
> +  // The PS4 uses C++11 as the default C++ standard.
> +  if (T.isPS4())
> +LangStd = LangStandard::lang_gnucxx11;
> +  else
> +LangStd = LangStandard::lang_gnucxx98;
>break;
>  case IK_RenderScript:
>LangStd = LangStandard::lang_c99;
>
>
> ___
> 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] D27387: [libc++] Add a key function for bad_function_call

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/functional:1393
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+

EricWF wrote:
> What's the rationale for making the dtor out-of-line? Couldn't we just use 
> `what()` as the key function?
We could, but this way it's consistent with all the other exception classes.



Comment at: src/functional.cpp:11
+#include "__config"
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+

EricWF wrote:
> Nit, please put the guard inside of the namespace at the smallest possible 
> scope.
> 
> Also there is no need to manually include `__config` before including 
> `functional`.
Will do.


https://reviews.llvm.org/D27387



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D29753#688834, @bruno wrote:

> > It seems to me that the problem here is that `DeclMustBeEmitted` is not 
> > safe to call in the middle of deserialization if anything 
> > partially-deserialized might be reachable from the declaration we're 
> > querying, and yet we're currently calling it in that case.
>
> `DeclMustBeEmitted` name seems misleading since we does more than just 
> checking, it actually tries to emit stuff.


It doesn't emit anything itself. But like most AST interactions, it *can* 
trigger more declarations being imported lazily from an external AST source, 
which can in turn result in them being passed to the AST consumer. And that's 
why the serialization code generally has to be careful to not call unbounded 
operations on the AST, because it doesn't want to reenter itself. But in this 
case we're violating that principle.

> If it's a local module, shouldn't be everything already available? Do we have 
> non-deserialized items for a local module? Maybe I get the wrong idea of what 
> local means in this context..

With this patch, we're calling `DeclMustBeEmitted` in the *non-local* module 
case (where there can be non-deserialized items).

>> I don't see how this patch actually addresses that problem, though: if you 
>> build this testcase as a module instead of a PCH, won't it still fail in the 
>> same way that it does now?
> 
> `D->getImportedOwningModule` calls `isFromASTFile`, which refers to PCH and 
> modules, shouldn't it work for both then?

It only fixes the cases where `getImportedOwningModule` returns 0, which is the 
normal case for a PCH, but is rare for a declaration from a module.

> I couldn't come up with a testcase that triggered it for modules though.

Something like this triggers it for me:

  $ cat test/PCH/empty-def-fwd-struct.modulemap
  module M { header "empty-def-fwd-struct.h" }
  $ clang -cc1 -x c++ -std=c++14 -fmodules -emit-module -fmodule-name=M 
test/PCH/empty-def-fwd-struct.modulemap -o tmp.pcm
  $ cat use.cpp
  #include "test/PCH/empty-def-fwd-struct.h"
  $ clang -cc1 -x c++ -std=c++14 -fmodules -emit-llvm -fmodule-file=tmp.pcm 
use.cpp -o -
  clang: [...]/src/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2933: const 
clang::ASTRecordLayout ::ASTContext::getASTRecordLayout(const 
clang::RecordDecl *) const: Assertion `D && "Cannot get layout of forward 
declarations!"' failed.




Comment at: test/PCH/empty-def-fwd-struct.h:2
+// RUN: %clang_cc1 -emit-pch -x c++-header %s -std=c++14 -o %t.pch
+// RUN: %clang_cc1 -emit-llvm -x c++ /dev/null -std=c++14 -include-pch %t.pch 
-o %t.o
+struct FVector;

Since you don't care about what's in the produced LLVM IR, you can use 
`-emit-llvm-only` instead here.


https://reviews.llvm.org/D29753



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Yes, I'm OK with this as a stopgap fix for 4.0. I would have preferred a more 
full fix for 4.0 but we've run out of time for that, and the PCH case does seem 
more pressing.


https://reviews.llvm.org/D29753



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


r296584 - [Sema] Add variable captured by a block to the enclosing lambda's

2017-02-28 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Mar  1 00:11:25 2017
New Revision: 296584

URL: http://llvm.org/viewvc/llvm-project?rev=296584=rev
Log:
[Sema] Add variable captured by a block to the enclosing lambda's
potential capture list.

Fix Sema::getCurLambda() to return the innermost lambda scope when there
is a block enclosed in the lambda. Previously, the method would return a
nullptr in such cases, which would prevent a variable captured by the
enclosed block to be added to the lambda scope's potential capture list.

rdar://problem/28412462

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjCXX/blocks.mm

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=296584=296583=296584=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Mar  1 00:11:25 2017
@@ -1244,9 +1244,11 @@ public:
   sema::BlockScopeInfo *getCurBlock();
 
   /// Retrieve the current lambda scope info, if any.
-  /// \param IgnoreCapturedRegions true if should find the top-most lambda 
scope
-  /// info ignoring all inner captured regions scope infos.
-  sema::LambdaScopeInfo *getCurLambda(bool IgnoreCapturedRegions = false);
+  /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
+  /// lambda scope info ignoring all inner capturing scopes that are not
+  /// lambda scopes.
+  sema::LambdaScopeInfo *
+  getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
 
   /// \brief Retrieve the current generic lambda info, if any.
   sema::LambdaScopeInfo *getCurGenericLambda();

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=296584=296583=296584=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Mar  1 00:11:25 2017
@@ -1237,14 +1237,14 @@ BlockScopeInfo *Sema::getCurBlock() {
   return CurBSI;
 }
 
-LambdaScopeInfo *Sema::getCurLambda(bool IgnoreCapturedRegions) {
+LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
   if (FunctionScopes.empty())
 return nullptr;
 
   auto I = FunctionScopes.rbegin();
-  if (IgnoreCapturedRegions) {
+  if (IgnoreNonLambdaCapturingScope) {
 auto E = FunctionScopes.rend();
-while (I != E && isa(*I))
+while (I != E && isa(*I) && !isa(*I))
   ++I;
 if (I == E)
   return nullptr;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=296584=296583=296584=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Mar  1 00:11:25 2017
@@ -14303,8 +14303,9 @@ static void DoMarkVarDeclReferenced(Sema
 (SemaRef.CurContext != Var->getDeclContext() &&
  Var->getDeclContext()->isFunctionOrMethod() && 
Var->hasLocalStorage());
 if (RefersToEnclosingScope) {
-  if (LambdaScopeInfo *const LSI =
-  SemaRef.getCurLambda(/*IgnoreCapturedRegions=*/true)) {
+  LambdaScopeInfo *const LSI =
+  SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
+  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
 // If a variable could potentially be odr-used, defer marking it so
 // until we finish analyzing the full expression for any
 // lvalue-to-rvalue

Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/blocks.mm?rev=296584=296583=296584=diff
==
--- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
+++ cfe/trunk/test/SemaObjCXX/blocks.mm Wed Mar  1 00:11:25 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
-std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
-std=c++14 %s
 @protocol NSObject;
 
 void bar(id(^)(void));
@@ -145,6 +145,17 @@ namespace DependentReturn {
   template void f(X);
 }
 
+namespace GenericLambdaCapture {
+int test(int outerp) {
+  auto lambda =[&](auto p) {
+return ^{
+  return p + outerp;
+}();
+  };
+  return lambda(1);
+}
+}
+
 namespace MoveBlockVariable {
 struct B0 {
 };


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


[PATCH] D25556: [Sema] Add variable captured by a block to the enclosing lambda's potential capture list

2017-02-28 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296584: [Sema] Add variable captured by a block to the 
enclosing lambda's (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D25556?vs=86918=90123#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25556

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaObjCXX/blocks.mm


Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -1237,14 +1237,14 @@
   return CurBSI;
 }
 
-LambdaScopeInfo *Sema::getCurLambda(bool IgnoreCapturedRegions) {
+LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
   if (FunctionScopes.empty())
 return nullptr;
 
   auto I = FunctionScopes.rbegin();
-  if (IgnoreCapturedRegions) {
+  if (IgnoreNonLambdaCapturingScope) {
 auto E = FunctionScopes.rend();
-while (I != E && isa(*I))
+while (I != E && isa(*I) && !isa(*I))
   ++I;
 if (I == E)
   return nullptr;
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -14303,8 +14303,9 @@
 (SemaRef.CurContext != Var->getDeclContext() &&
  Var->getDeclContext()->isFunctionOrMethod() && 
Var->hasLocalStorage());
 if (RefersToEnclosingScope) {
-  if (LambdaScopeInfo *const LSI =
-  SemaRef.getCurLambda(/*IgnoreCapturedRegions=*/true)) {
+  LambdaScopeInfo *const LSI =
+  SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
+  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
 // If a variable could potentially be odr-used, defer marking it so
 // until we finish analyzing the full expression for any
 // lvalue-to-rvalue
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1244,9 +1244,11 @@
   sema::BlockScopeInfo *getCurBlock();
 
   /// Retrieve the current lambda scope info, if any.
-  /// \param IgnoreCapturedRegions true if should find the top-most lambda 
scope
-  /// info ignoring all inner captured regions scope infos.
-  sema::LambdaScopeInfo *getCurLambda(bool IgnoreCapturedRegions = false);
+  /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
+  /// lambda scope info ignoring all inner capturing scopes that are not
+  /// lambda scopes.
+  sema::LambdaScopeInfo *
+  getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
 
   /// \brief Retrieve the current generic lambda info, if any.
   sema::LambdaScopeInfo *getCurGenericLambda();
Index: cfe/trunk/test/SemaObjCXX/blocks.mm
===
--- cfe/trunk/test/SemaObjCXX/blocks.mm
+++ cfe/trunk/test/SemaObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
-std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
-std=c++14 %s
 @protocol NSObject;
 
 void bar(id(^)(void));
@@ -145,6 +145,17 @@
   template void f(X);
 }
 
+namespace GenericLambdaCapture {
+int test(int outerp) {
+  auto lambda =[&](auto p) {
+return ^{
+  return p + outerp;
+}();
+  };
+  return lambda(1);
+}
+}
+
 namespace MoveBlockVariable {
 struct B0 {
 };


Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -1237,14 +1237,14 @@
   return CurBSI;
 }
 
-LambdaScopeInfo *Sema::getCurLambda(bool IgnoreCapturedRegions) {
+LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
   if (FunctionScopes.empty())
 return nullptr;
 
   auto I = FunctionScopes.rbegin();
-  if (IgnoreCapturedRegions) {
+  if (IgnoreNonLambdaCapturingScope) {
 auto E = FunctionScopes.rend();
-while (I != E && isa(*I))
+while (I != E && isa(*I) && !isa(*I))
   ++I;
 if (I == E)
   return nullptr;
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -14303,8 +14303,9 @@
 (SemaRef.CurContext != Var->getDeclContext() &&
  Var->getDeclContext()->isFunctionOrMethod() && Var->hasLocalStorage());
 if (RefersToEnclosingScope) {
-  if (LambdaScopeInfo *const LSI =
-  SemaRef.getCurLambda(/*IgnoreCapturedRegions=*/true)) {
+  LambdaScopeInfo *const LSI =
+  SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
+  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
 // If a variable could 

[PATCH] D30459: [libcxxabi] Clean up macro usage

2017-02-28 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I renamed `LIBCXXABI_ARM_EHABI` to `_LIBCXXABI_ARM_EHABI` so you'll have to 
merge this change with that.

Other than that this LGTM.


https://reviews.llvm.org/D30459



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-02-28 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

`__num_get` is externally instantiated.  Adding non-template methods or 
changing method signatures is ABI breaking (As shown by the `check-cxx-abilist` 
rule output ).

This change needs to be made in a way that maintains ABI compatibility, or it 
needs to be guarded under a `_LIBCPP_ABI_FOO` macro and only exposed in ABI v2.


https://reviews.llvm.org/D30268



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


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-02-28 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/functional:1393
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+

What's the rationale for making the dtor out-of-line? Couldn't we just use 
`what()` as the key function?



Comment at: lib/CMakeLists.txt:162
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})

smeenai wrote:
> This may seem like a completely unrelated change, but it's actually important 
> to force cmake to get re-run so that the glob for source files picks up on 
> the new file.
Glad you're on top of this :-)



Comment at: src/functional.cpp:11
+#include "__config"
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+

Nit, please put the guard inside of the namespace at the smallest possible 
scope.

Also there is no need to manually include `__config` before including 
`functional`.


https://reviews.llvm.org/D27387



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


[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296576: [libc++abi] Clean up visibility (authored by 
smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D26949?vs=90119=90120#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26949

Files:
  libcxxabi/trunk/include/__cxxabi_config.h
  libcxxabi/trunk/src/abort_message.cpp
  libcxxabi/trunk/src/abort_message.h
  libcxxabi/trunk/src/cxa_exception.cpp
  libcxxabi/trunk/src/cxa_exception.hpp
  libcxxabi/trunk/src/cxa_handlers.cpp
  libcxxabi/trunk/src/cxa_handlers.hpp
  libcxxabi/trunk/src/cxa_new_delete.cpp
  libcxxabi/trunk/src/cxa_noexception.cpp
  libcxxabi/trunk/src/cxa_thread_atexit.cpp
  libcxxabi/trunk/src/cxa_unexpected.cpp
  libcxxabi/trunk/src/fallback_malloc.cpp
  libcxxabi/trunk/src/fallback_malloc.h
  libcxxabi/trunk/src/private_typeinfo.cpp
  libcxxabi/trunk/src/private_typeinfo.h
  libcxxabi/trunk/src/stdlib_exception.cpp

Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -22,16 +22,13 @@
 #endif // __ANDROID_API__ >= 21
 #endif // __BIONIC__
 
-#pragma GCC visibility push(hidden)
-
 #ifdef __APPLE__
 #   if defined(__has_include) && __has_include()
 #   define HAVE_CRASHREPORTERCLIENT_H
 #   include 
 #   endif
 #endif
 
-__attribute__((visibility("hidden"), noreturn))
 void abort_message(const char* format, ...)
 {
 // write message to stderr
@@ -79,5 +76,3 @@
 
 abort();
 }
-
-#pragma GCC visibility pop
Index: libcxxabi/trunk/src/cxa_new_delete.cpp
===
--- libcxxabi/trunk/src/cxa_new_delete.cpp
+++ libcxxabi/trunk/src/cxa_new_delete.cpp
@@ -11,6 +11,7 @@
 
 #define _LIBCPP_BUILDING_NEW
 
+#include "__cxxabi_config.h"
 #include 
 #include 
 
@@ -36,7 +37,7 @@
 * The loop terminates when an attempt to allocate the requested storage is
   successful or when a called new_handler function does not return.
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void *
 operator new(std::size_t size) _THROW_BAD_ALLOC
 {
@@ -70,7 +71,7 @@
 Calls operator new(size). If the call returns normally, returns the result of
 that call. Otherwise, returns a null pointer.
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
@@ -94,7 +95,7 @@
 
 Returns operator new(size).
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void*
 operator new[](size_t size) _THROW_BAD_ALLOC
 {
@@ -107,7 +108,7 @@
 Calls operator new[](size). If the call returns normally, returns the result
 of that call. Otherwise, returns a null pointer.
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
@@ -132,7 +133,7 @@
 If ptr is null, does nothing. Otherwise, reclaims the storage allocated by the
 earlier call to operator new.
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void
 operator delete(void* ptr) _NOEXCEPT
 {
@@ -145,7 +146,7 @@
 
 calls operator delete(ptr)
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void
 operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
 {
@@ -157,7 +158,7 @@
 
 Calls operator delete(ptr)
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void
 operator delete[] (void* ptr) _NOEXCEPT
 {
@@ -169,7 +170,7 @@
 
 calls operator delete[](ptr)
 */
-__attribute__((__weak__, __visibility__("default")))
+_LIBCXXABI_WEAK
 void
 operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT
 {
Index: libcxxabi/trunk/src/cxa_handlers.hpp
===
--- libcxxabi/trunk/src/cxa_handlers.hpp
+++ libcxxabi/trunk/src/cxa_handlers.hpp
@@ -20,11 +20,11 @@
 namespace std
 {
 
-__attribute__((visibility("hidden"), noreturn))
+_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN
 void
 __unexpected(unexpected_handler func);
 
-__attribute__((visibility("hidden"), noreturn))
+_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN
 void
 __terminate(terminate_handler func) _NOEXCEPT;
 
Index: libcxxabi/trunk/src/stdlib_exception.cpp
===
--- libcxxabi/trunk/src/stdlib_exception.cpp
+++ libcxxabi/trunk/src/stdlib_exception.cpp
@@ -9,8 +9,6 @@
 
 #include 
 
-#pragma GCC visibility push(default)
-
 namespace std
 {
 
@@ -37,5 +35,3 @@
 }
 
 }  // std
-
-#pragma GCC visibility pop
Index: libcxxabi/trunk/src/cxa_unexpected.cpp
===
--- libcxxabi/trunk/src/cxa_unexpected.cpp
+++ libcxxabi/trunk/src/cxa_unexpected.cpp
@@ -14,14 +14,10 @@
 namespace __cxxabiv1
 {
 
-#pragma GCC visibility push(default)
-
 extern "C"
 {
 
 }
 

[libcxxabi] r296576 - [libc++abi] Clean up visibility

2017-02-28 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Tue Feb 28 21:55:57 2017
New Revision: 296576

URL: http://llvm.org/viewvc/llvm-project?rev=296576=rev
Log:
[libc++abi] Clean up visibility

Use the libc++abi visibility macros instead of pragmas or using
visibility attributes directly. Clean up redundant attributes on
definitions (where the declarations already have visibility attributes
applied, from either libc++ or libc++abi headers).

Introduce _LIBCXXABI_WEAK as a drive-by cleanup, which matches the
semantics of _LIBCPP_WEAK.

No functional change. Tested by building on Linux before and after this
change and verifying that the list of exported symbols is identical.

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

Modified:
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/src/abort_message.cpp
libcxxabi/trunk/src/abort_message.h
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception.hpp
libcxxabi/trunk/src/cxa_handlers.cpp
libcxxabi/trunk/src/cxa_handlers.hpp
libcxxabi/trunk/src/cxa_new_delete.cpp
libcxxabi/trunk/src/cxa_noexception.cpp
libcxxabi/trunk/src/cxa_thread_atexit.cpp
libcxxabi/trunk/src/cxa_unexpected.cpp
libcxxabi/trunk/src/fallback_malloc.cpp
libcxxabi/trunk/src/fallback_malloc.h
libcxxabi/trunk/src/private_typeinfo.cpp
libcxxabi/trunk/src/private_typeinfo.h
libcxxabi/trunk/src/stdlib_exception.cpp

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=296576=296575=296576=diff
==
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Tue Feb 28 21:55:57 2017
@@ -56,4 +56,10 @@
  #endif
 #endif
 
+#if defined(_WIN32)
+#define _LIBCXXABI_WEAK
+#else
+#define _LIBCXXABI_WEAK __attribute__((__weak__))
+#endif
+
 #endif // CXXABI_CONFIG_H

Modified: libcxxabi/trunk/src/abort_message.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=296576=296575=296576=diff
==
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Tue Feb 28 21:55:57 2017
@@ -22,8 +22,6 @@ extern "C" void android_set_abort_messag
 #endif // __ANDROID_API__ >= 21
 #endif // __BIONIC__
 
-#pragma GCC visibility push(hidden)
-
 #ifdef __APPLE__
 #   if defined(__has_include) && __has_include()
 #   define HAVE_CRASHREPORTERCLIENT_H
@@ -31,7 +29,6 @@ extern "C" void android_set_abort_messag
 #   endif
 #endif
 
-__attribute__((visibility("hidden"), noreturn))
 void abort_message(const char* format, ...)
 {
 // write message to stderr
@@ -79,5 +76,3 @@ void abort_message(const char* format, .
 
 abort();
 }
-
-#pragma GCC visibility pop

Modified: libcxxabi/trunk/src/abort_message.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.h?rev=296576=296575=296576=diff
==
--- libcxxabi/trunk/src/abort_message.h (original)
+++ libcxxabi/trunk/src/abort_message.h Tue Feb 28 21:55:57 2017
@@ -10,24 +10,18 @@
 #ifndef __ABORT_MESSAGE_H_
 #define __ABORT_MESSAGE_H_
 
-#include 
-
-#pragma GCC visibility push(hidden)
+#include "cxxabi.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-__attribute__((visibility("hidden"), noreturn))
-   void abort_message(const char* format, ...) 
-__attribute__((format(printf, 1, 2)));
-
+_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void
+abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
 #ifdef __cplusplus
 }
 #endif
 
-#pragma GCC visibility pop
-
 #endif
 

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=296576=296575=296576=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Tue Feb 28 21:55:57 2017
@@ -33,8 +33,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(default)
-
 //  Utility routines
 static
 inline
@@ -139,7 +137,7 @@ extern "C" {
 //  object. Zero-fill the object. If memory can't be allocated, call
 //  std::terminate. Return a pointer to the memory to be used for the
 //  user's exception object.
-_LIBCXXABI_FUNC_VIS void *__cxa_allocate_exception(size_t thrown_size) throw() 
{
+void *__cxa_allocate_exception(size_t thrown_size) throw() {
 size_t actual_size = 
cxa_exception_size_from_exception_thrown_size(thrown_size);
 __cxa_exception *exception_header =
 static_cast<__cxa_exception *>(__malloc_with_fallback(actual_size));
@@ -151,7 +149,7 @@ _LIBCXXABI_FUNC_VIS void *__cxa_allocate
 
 
 //  Free a __cxa_exception object allocated with __cxa_allocate_exception.

[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90119.
smeenai added a comment.

Addressing inline comment


https://reviews.llvm.org/D26949

Files:
  include/__cxxabi_config.h
  src/abort_message.cpp
  src/abort_message.h
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_handlers.cpp
  src/cxa_handlers.hpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  src/cxa_thread_atexit.cpp
  src/cxa_unexpected.cpp
  src/fallback_malloc.cpp
  src/fallback_malloc.h
  src/private_typeinfo.cpp
  src/private_typeinfo.h
  src/stdlib_exception.cpp

Index: src/stdlib_exception.cpp
===
--- src/stdlib_exception.cpp
+++ src/stdlib_exception.cpp
@@ -9,8 +9,6 @@
 
 #include 
 
-#pragma GCC visibility push(default)
-
 namespace std
 {
 
@@ -37,5 +35,3 @@
 }
 
 }  // std
-
-#pragma GCC visibility pop
Index: src/private_typeinfo.h
===
--- src/private_typeinfo.h
+++ src/private_typeinfo.h
@@ -16,7 +16,6 @@
 #include 
 
 namespace __cxxabiv1 {
-#pragma GCC visibility push(hidden)
 
 class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info {
 public:
@@ -67,7 +66,7 @@
 
 class _LIBCXXABI_TYPE_VIS __class_type_info;
 
-struct __dynamic_cast_info
+struct _LIBCXXABI_HIDDEN __dynamic_cast_info
 {
 // const data supplied to the search:
 
@@ -153,7 +152,7 @@
   has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;
 };
 
-struct __base_class_type_info
+struct _LIBCXXABI_HIDDEN __base_class_type_info
 {
 public:
 const __class_type_info* __base_type;
@@ -248,8 +247,6 @@
   _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const;
 };
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
 
 #endif  // __PRIVATE_TYPEINFO_H_
Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -55,12 +55,7 @@
 #include 
 #endif
 
-namespace __cxxabiv1
-{
-
-#pragma GCC visibility push(hidden)
-
-inline
+static inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
@@ -73,6 +68,8 @@
 #endif
 }
 
+namespace __cxxabiv1
+{
 
 // __shim_type_info
 
@@ -538,9 +535,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(default)
-
 #ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
@@ -715,9 +709,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(hidden)
-
 // Call this function when you hit a static_type which is a base (above) a dst_type.
 // Let caller know you hit a static_type.  But only start recording details if
 // this is (static_ptr, static_type) -- the node we are casting from.
@@ -1300,6 +1291,4 @@
   use_strcmp);
 }
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
Index: src/fallback_malloc.h
===
--- src/fallback_malloc.h
+++ src/fallback_malloc.h
@@ -10,21 +10,18 @@
 #ifndef _FALLBACK_MALLOC_H
 #define _FALLBACK_MALLOC_H
 
+#include "__cxxabi_config.h"
 #include  // for size_t
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 // Allocate some memory from _somewhere_
-void * __malloc_with_fallback(size_t size);
+_LIBCXXABI_HIDDEN void * __malloc_with_fallback(size_t size);
 
 // Allocate and zero-initialize memory from _somewhere_
-void * __calloc_with_fallback(size_t count, size_t size);
-
-void __free_with_fallback(void *ptr);
+_LIBCXXABI_HIDDEN void * __calloc_with_fallback(size_t count, size_t size);
 
-#pragma GCC visibility pop
+_LIBCXXABI_HIDDEN void __free_with_fallback(void *ptr);
 
 } // namespace __cxxabiv1
 
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -194,8 +194,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 void * __malloc_with_fallback(size_t size) {
 void *ptr = std::malloc(size);
 if (NULL == ptr) // if malloc fails, fall back to emergency stash
@@ -221,6 +219,4 @@
 std::free(ptr);
 }
 
-#pragma GCC visibility pop
-
 } // namespace __cxxabiv1
Index: src/cxa_unexpected.cpp
===
--- src/cxa_unexpected.cpp
+++ src/cxa_unexpected.cpp
@@ -14,14 +14,10 @@
 namespace __cxxabiv1
 {
 
-#pragma GCC visibility push(default)
-
 extern "C"
 {
 
 }
 
-#pragma GCC visibility pop
-
 }  // namespace __cxxabiv1
 
Index: src/cxa_thread_atexit.cpp
===
--- src/cxa_thread_atexit.cpp
+++ src/cxa_thread_atexit.cpp
@@ -20,7 +20,7 @@
 #ifndef HAVE___CXA_THREAD_ATEXIT_IMPL
   // A weak symbol is used to detect this function's presence in the C library
   // at runtime, even if libc++ is built against an 

[PATCH] D30373: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-02-28 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I'm not sure what is going on.

One thing to try is defining the class in clang/test/lit.cfg -- which seems to 
work for Swift. (See 
https://github.com/apple/swift/blob/master/test/lit.cfg#L137) We'd still want 
to only use that class in Analysis/lit.local.cfg.

Another possibility is to not support running with Z3 on Windows, at least for 
now. So in Analysis/lit.local.cfg we would only set the custom test_format if 
`(not sys.platform in ['win32'])` is true.


Repository:
  rL LLVM

https://reviews.llvm.org/D30373



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


[libcxx] r296573 - [libcxx] Support threads on Fuchsia

2017-02-28 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Feb 28 21:09:18 2017
New Revision: 296573

URL: http://llvm.org/viewvc/llvm-project?rev=296573=rev
Log:
[libcxx] Support threads on Fuchsia

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

Modified:
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=296573=296572=296573=diff
==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Tue Feb 28 21:09:18 2017
@@ -24,9 +24,9 @@
 # endif // defined(BSD)
 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || 
defined(__CloudABI__)
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || 
defined(__CloudABI__) || defined(__Fuchsia__)
 # include 
-#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || 
defined(__CloudABI__)
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || 
defined(__CloudABI__) || defined(__Fuchsia__)
 
 #if defined(__NetBSD__)
 #pragma weak pthread_create // Do not create libpthread dependency


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


r296572 - Add warning for inconsistent overrides on destructor.

2017-02-28 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Feb 28 21:07:55 2017
New Revision: 296572

URL: http://llvm.org/viewvc/llvm-project?rev=296572=rev
Log:
Add warning for inconsistent overrides on destructor.

The exisiting warning for inconsistent overrides does not include the destructor
as it was noted in review that it was too noisy.  Instead, add to a separate
warning group that is off by default for users who want consistent warnings
between methods and destructors.

Added:
cfe/trunk/test/SemaCXX/warn-inconsistent-missing-destructor-override
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=296572=296571=296572=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Feb 28 21:07:55 2017
@@ -175,6 +175,8 @@ def CXX98CompatPedantic : DiagGroup<"c++
 
 def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
 
+def CXX11WarnOverrideDestructor :
+  DiagGroup<"inconsistent-missing-destructor-override">;
 def CXX11WarnOverrideMethod : DiagGroup<"inconsistent-missing-override">;
 
 // Original name of this warning in Clang

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=296572=296571=296572=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 28 21:07:55 
2017
@@ -2039,6 +2039,9 @@ def override_keyword_hides_virtual_membe
   "%select{function|functions}1">;
 def err_function_marked_override_not_overriding : Error<
   "%0 marked 'override' but does not override any member functions">;
+def warn_destructor_marked_not_override_overriding : Warning <
+  "%0 overrides a destructor but is not marked 'override'">,
+  InGroup, DefaultIgnore;
 def warn_function_marked_not_override_overriding : Warning <
   "%0 overrides a member function but is not marked 'override'">,
   InGroup;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=296572=296571=296572=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Feb 28 21:07:55 2017
@@ -2716,8 +2716,7 @@ void Sema::DiagnoseAbsenceOfOverrideCont
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
-  if (!MD || MD->isImplicit() || MD->hasAttr() ||
-  isa(MD))
+  if (!MD || MD->isImplicit() || MD->hasAttr())
 return;
 
   SourceLocation Loc = MD->getLocation();
@@ -2727,10 +2726,12 @@ void Sema::DiagnoseAbsenceOfOverrideCont
   SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
   if (SpellingLoc.isValid() && 
getSourceManager().isInSystemHeader(SpellingLoc))
   return;
-
+
   if (MD->size_overridden_methods() > 0) {
-Diag(MD->getLocation(), diag::warn_function_marked_not_override_overriding)
-  << MD->getDeclName();
+unsigned DiagID = isa(MD)
+  ? 
diag::warn_destructor_marked_not_override_overriding
+  : diag::warn_function_marked_not_override_overriding;
+Diag(MD->getLocation(), DiagID) << MD->getDeclName();
 const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
 Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
   }

Added: cfe/trunk/test/SemaCXX/warn-inconsistent-missing-destructor-override
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-inconsistent-missing-destructor-override?rev=296572=auto
==
--- cfe/trunk/test/SemaCXX/warn-inconsistent-missing-destructor-override (added)
+++ cfe/trunk/test/SemaCXX/warn-inconsistent-missing-destructor-override Tue 
Feb 28 21:07:55 2017
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 
-Winconsistent-missing-destructor-override
+
+class A {
+ public:
+  ~A() {}
+  void virtual run() {}
+};
+
+class B : public A {
+ public:
+  void run() override {}
+  ~B() {}
+};
+
+class C {
+ public:
+  virtual void run() {}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() override {}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 
'override'}}
+};
+
+class E : public C {
+ public:
+  void run() override {}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 

[PATCH] D30373: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-02-28 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Saving the relevant portion of the build bot log output before it disappears 
from the bot:

  0.000 [0/1/0] Running all regression tests
  -- Testing: 31894 tests, 80 threads --
  Traceback (most recent call last):
File "", line 1, in 
File "C:\Python27\lib\multiprocessing\forking.py", line 381, in main
  self = load(from_parent)
File "C:\Python27\lib\pickle.py", line 1384, in load
  return Unpickler(file).load()
File "C:\Python27\lib\pickle.py", line 864, in load
  dispatch[key](self)
File "C:\Python27\lib\pickle.py", line 886, in load_eof
  raise EOFError
  EOFError
  lit.py: 
C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/tools/clang/test/lit.cfg:200:
 note: using clang: 
'C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE'
  Traceback (most recent call last):
File 
"C:/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.src/utils/lit/lit.py",
 line 6, in 
  main()
File 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\utils\lit\lit\main.py",
 line 161, in main
  main_with_tmp(builtinParameters)
File 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\utils\lit\lit\main.py",
 line 484, in main_with_tmp
  opts.useProcesses)
File 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\utils\lit\lit\run.py",
 line 272, in execute_tests
  queuer.start()
File "C:\Python27\lib\multiprocessing\process.py", line 130, in start
  self._popen = Popen(self)
File "C:\Python27\lib\multiprocessing\forking.py", line 277, in __init__
  dump(process_obj, to_child, HIGHEST_PROTOCOL)
File "C:\Python27\lib\multiprocessing\forking.py", line 199, in dump
  ForkingPickler(file, protocol).dump(obj)
File "C:\Python27\lib\pickle.py", line 224, in dump
  self.save(obj)
File "C:\Python27\lib\pickle.py", line 331, in save
  self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 425, in save_reduce
  save(state)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 655, in save_dict
  self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
  save(v)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 554, in save_tuple
  save(element)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 606, in save_list
  self._batch_appends(iter(obj))
File "C:\Python27\lib\pickle.py", line 639, in _batch_appends
  save(x)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 731, in save_inst
  save(stuff)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 655, in save_dict
  self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
  save(v)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 731, in save_inst
  save(stuff)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 655, in save_dict
  self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
  save(v)
File "C:\Python27\lib\pickle.py", line 331, in save
  self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 396, in save_reduce
  save(cls)
File "C:\Python27\lib\pickle.py", line 286, in save
  f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 754, in save_global
  (obj, module, name))
  pickle.PicklingError: Can't pickle : 
it's not found as lit.TestingConfig.AnalyzerTest


Repository:
  rL LLVM

https://reviews.llvm.org/D30373



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


[libcxx] r296571 - Mark test as unsupported in C++11

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 20:52:04 2017
New Revision: 296571

URL: http://llvm.org/viewvc/llvm-project?rev=296571=rev
Log:
Mark test as unsupported in C++11

Modified:

libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp

Modified: 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp?rev=296571=296570=296571=diff
==
--- 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 Tue Feb 28 20:52:04 2017
@@ -7,8 +7,12 @@
 //
 
//===--===//
 
-// UNSUPPORTED: c++98, c++03
 // REQUIRES: diagnose-if-support
+// UNSUPPORTED: c++98, c++03
+
+// Libc++ only provides a defined primary template for std::hash in C++14 and
+// newer.
+// UNSUPPORTED: c++11
 
 // 
 


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


[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: src/abort_message.h:19
 
-__attribute__((visibility("hidden"), noreturn))
-   void abort_message(const char* format, ...) 
-__attribute__((format(printf, 1, 2)));
-
+_LIBCXXABI_HIDDEN __attribute__((noreturn)) void
+abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));

EricWF wrote:
> `LIBCXXABI_NORETURN`?
That would also require changing the `__cxxabi_config.h` include to a 
`cxxabi.h` include (since that's where `_LIBCXXABI_NORETURN` is defined). Is 
that acceptable?


https://reviews.llvm.org/D26949



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


[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-28 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 minus inline comments.

@smeenai confirmed that this patch doesn't change the ABI list for 
`libc++abi.dylib` using `sym_check.py`.




Comment at: src/abort_message.h:19
 
-__attribute__((visibility("hidden"), noreturn))
-   void abort_message(const char* format, ...) 
-__attribute__((format(printf, 1, 2)));
-
+_LIBCXXABI_HIDDEN __attribute__((noreturn)) void
+abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));

`LIBCXXABI_NORETURN`?


https://reviews.llvm.org/D26949



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


[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90114.
smeenai added a comment.

Rebase


https://reviews.llvm.org/D26949

Files:
  include/__cxxabi_config.h
  src/abort_message.cpp
  src/abort_message.h
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_handlers.cpp
  src/cxa_handlers.hpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  src/cxa_thread_atexit.cpp
  src/cxa_unexpected.cpp
  src/fallback_malloc.cpp
  src/fallback_malloc.h
  src/private_typeinfo.cpp
  src/private_typeinfo.h
  src/stdlib_exception.cpp

Index: src/stdlib_exception.cpp
===
--- src/stdlib_exception.cpp
+++ src/stdlib_exception.cpp
@@ -9,8 +9,6 @@
 
 #include 
 
-#pragma GCC visibility push(default)
-
 namespace std
 {
 
@@ -37,5 +35,3 @@
 }
 
 }  // std
-
-#pragma GCC visibility pop
Index: src/private_typeinfo.h
===
--- src/private_typeinfo.h
+++ src/private_typeinfo.h
@@ -16,7 +16,6 @@
 #include 
 
 namespace __cxxabiv1 {
-#pragma GCC visibility push(hidden)
 
 class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info {
 public:
@@ -67,7 +66,7 @@
 
 class _LIBCXXABI_TYPE_VIS __class_type_info;
 
-struct __dynamic_cast_info
+struct _LIBCXXABI_HIDDEN __dynamic_cast_info
 {
 // const data supplied to the search:
 
@@ -153,7 +152,7 @@
   has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;
 };
 
-struct __base_class_type_info
+struct _LIBCXXABI_HIDDEN __base_class_type_info
 {
 public:
 const __class_type_info* __base_type;
@@ -248,8 +247,6 @@
   _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const;
 };
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
 
 #endif  // __PRIVATE_TYPEINFO_H_
Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -55,12 +55,7 @@
 #include 
 #endif
 
-namespace __cxxabiv1
-{
-
-#pragma GCC visibility push(hidden)
-
-inline
+static inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
@@ -73,6 +68,8 @@
 #endif
 }
 
+namespace __cxxabiv1
+{
 
 // __shim_type_info
 
@@ -538,9 +535,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(default)
-
 #ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
@@ -715,9 +709,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(hidden)
-
 // Call this function when you hit a static_type which is a base (above) a dst_type.
 // Let caller know you hit a static_type.  But only start recording details if
 // this is (static_ptr, static_type) -- the node we are casting from.
@@ -1300,6 +1291,4 @@
   use_strcmp);
 }
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
Index: src/fallback_malloc.h
===
--- src/fallback_malloc.h
+++ src/fallback_malloc.h
@@ -10,21 +10,18 @@
 #ifndef _FALLBACK_MALLOC_H
 #define _FALLBACK_MALLOC_H
 
+#include "__cxxabi_config.h"
 #include  // for size_t
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 // Allocate some memory from _somewhere_
-void * __malloc_with_fallback(size_t size);
+_LIBCXXABI_HIDDEN void * __malloc_with_fallback(size_t size);
 
 // Allocate and zero-initialize memory from _somewhere_
-void * __calloc_with_fallback(size_t count, size_t size);
-
-void __free_with_fallback(void *ptr);
+_LIBCXXABI_HIDDEN void * __calloc_with_fallback(size_t count, size_t size);
 
-#pragma GCC visibility pop
+_LIBCXXABI_HIDDEN void __free_with_fallback(void *ptr);
 
 } // namespace __cxxabiv1
 
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -194,8 +194,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 void * __malloc_with_fallback(size_t size) {
 void *ptr = std::malloc(size);
 if (NULL == ptr) // if malloc fails, fall back to emergency stash
@@ -221,6 +219,4 @@
 std::free(ptr);
 }
 
-#pragma GCC visibility pop
-
 } // namespace __cxxabiv1
Index: src/cxa_unexpected.cpp
===
--- src/cxa_unexpected.cpp
+++ src/cxa_unexpected.cpp
@@ -14,14 +14,10 @@
 namespace __cxxabiv1
 {
 
-#pragma GCC visibility push(default)
-
 extern "C"
 {
 
 }
 
-#pragma GCC visibility pop
-
 }  // namespace __cxxabiv1
 
Index: src/cxa_thread_atexit.cpp
===
--- src/cxa_thread_atexit.cpp
+++ src/cxa_thread_atexit.cpp
@@ -20,7 +20,7 @@
 #ifndef HAVE___CXA_THREAD_ATEXIT_IMPL
   // A weak symbol is used to detect this function's presence in the C library
   // at runtime, even if libc++ is built against an older libc
-  

[libcxx] r296568 - Fix test failures due to bad test hasher

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 20:34:27 2017
New Revision: 296568

URL: http://llvm.org/viewvc/llvm-project?rev=296568=rev
Log:
Fix test failures due to bad test hasher

Modified:

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp?rev=296568=296567=296568=diff
==
--- 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
 Tue Feb 28 20:34:27 2017
@@ -42,6 +42,8 @@ struct some_hash
 typedef T value_type;
 some_hash();
 some_hash(const some_hash&);
+
+std::size_t operator()(T const&) const;
 };
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp?rev=296568=296567=296568=diff
==
--- 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
 Tue Feb 28 20:34:27 2017
@@ -35,6 +35,8 @@ struct some_hash
 some_hash();
 some_hash(const some_hash&);
 ~some_hash() noexcept(false);
+
+std::size_t operator()(T const&) const;
 };
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp?rev=296568=296567=296568=diff
==
--- 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
 Tue Feb 28 20:34:27 2017
@@ -41,6 +41,8 @@ struct some_hash
 some_hash();
 some_hash(const some_hash&);
 some_hash& operator=(const some_hash&);
+
+std::size_t operator()(T const&) const;
 };
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp?rev=296568=296567=296568=diff
==
--- 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
 Tue Feb 28 20:34:27 2017
@@ -38,6 +38,8 @@ struct some_hash
 typedef T value_type;
 some_hash();
 some_hash(const some_hash&);
+
+std::size_t operator()(T const&) const;

[libcxxabi] r296567 - Fix non-reserved macro names LIBCXXABI_NORETURN and LIBCXXABI_ARM_EHABI.

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 20:23:54 2017
New Revision: 296567

URL: http://llvm.org/viewvc/llvm-project?rev=296567=rev
Log:
Fix non-reserved macro names LIBCXXABI_NORETURN and LIBCXXABI_ARM_EHABI.

This patch adds the required leading underscore to those macros.

Modified:
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/include/cxxabi.h
libcxxabi/trunk/src/cxa_aux_runtime.cpp
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception.hpp
libcxxabi/trunk/src/cxa_personality.cpp
libcxxabi/trunk/src/cxa_virtual.cpp

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=296567=296566=296567=diff
==
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Tue Feb 28 20:23:54 2017
@@ -12,9 +12,9 @@
 
 #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && 
\
 !defined(__ARM_DWARF_EH__)
-#define LIBCXXABI_ARM_EHABI 1
+#define _LIBCXXABI_ARM_EHABI 1
 #else
-#define LIBCXXABI_ARM_EHABI 0
+#define _LIBCXXABI_ARM_EHABI 0
 #endif
 
 #if !defined(__has_attribute)

Modified: libcxxabi/trunk/include/cxxabi.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/cxxabi.h?rev=296567=296566=296567=diff
==
--- libcxxabi/trunk/include/cxxabi.h (original)
+++ libcxxabi/trunk/include/cxxabi.h Tue Feb 28 20:23:54 2017
@@ -21,7 +21,7 @@
 #include <__cxxabi_config.h>
 
 #define _LIBCPPABI_VERSION 1002
-#define LIBCXXABI_NORETURN  __attribute__((noreturn))
+#define _LIBCXXABI_NORETURN  __attribute__((noreturn))
 
 #ifdef __cplusplus
 
@@ -45,7 +45,7 @@ extern _LIBCXXABI_FUNC_VIS void
 __cxa_free_exception(void *thrown_exception) throw();
 
 // 2.4.3 Throwing the Exception Object
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
 __cxa_throw(void *thrown_exception, std::type_info *tinfo,
 void (*dest)(void *));
 
@@ -55,7 +55,7 @@ __cxa_get_exception_ptr(void *exceptionO
 extern _LIBCXXABI_FUNC_VIS void *
 __cxa_begin_catch(void *exceptionObject) throw();
 extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
-#if LIBCXXABI_ARM_EHABI
+#if _LIBCXXABI_ARM_EHABI
 extern _LIBCXXABI_FUNC_VIS bool
 __cxa_begin_cleanup(void *exceptionObject) throw();
 extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
@@ -63,19 +63,19 @@ extern _LIBCXXABI_FUNC_VIS void __cxa_en
 extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
 
 // 2.5.4 Rethrowing Exceptions
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_rethrow();
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
 
 // 2.6 Auxiliary Runtime APIs
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void);
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
 __cxa_throw_bad_array_new_length(void);
 
 // 3.2.6 Pure Virtual Function API
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
 
 // 3.2.7 Deleted Virtual Function API
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void 
__cxa_deleted_virtual(void);
 
 // 3.3.2 One-time Construction API
 #ifdef __arm__

Modified: libcxxabi/trunk/src/cxa_aux_runtime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_aux_runtime.cpp?rev=296567=296566=296567=diff
==
--- libcxxabi/trunk/src/cxa_aux_runtime.cpp (original)
+++ libcxxabi/trunk/src/cxa_aux_runtime.cpp Tue Feb 28 20:23:54 2017
@@ -16,7 +16,7 @@
 
 namespace __cxxabiv1 {
 extern "C" {
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
+_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_cast();
 #else
@@ -24,7 +24,7 @@ _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN v
 #endif
 }
 
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_typeid(void) {
+_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_typeid();
 #else
@@ -32,7 +32,7 @@ _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN v
 #endif
 }
 
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
 __cxa_throw_bad_array_new_length(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_array_new_length();

Modified: 

[libcxx] r296565 - Improve diagnostics when an invalid hash is used in an unordered container.

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 20:02:28 2017
New Revision: 296565

URL: http://llvm.org/viewvc/llvm-project?rev=296565=rev
Log:
Improve diagnostics when an invalid hash is used in an unordered container.

This patch adds a static assertion that the specified hash meets
the requirements of an enabled hash, and it ensures that the static
assertion is evaluated before __compressed_pair is instantiated.
That way the static assertion diagnostic is emitted first.

Added:

libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=296565=296564=296565=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Tue Feb 28 20:02:28 2017
@@ -871,11 +871,20 @@ public:
 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; }
+_LIBCPP_DIAGNOSE_WARNING(__has_enabled_hash<_Key, _Hash>::value
+ && !__invokable<_Hash const&, _Key const&>::value,
+  "the specified hash functor does not provide a const call operator")
+_LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
+  && !__invokable<_Equal const&, _Key const&, _Key 
const&>::value,
+  "the specified comparator type does not provide a const call operator")
+  {
+static_assert(__has_enabled_hash<_Key, _Hash>::value,
+  "the specified hash functor does not meet the requirements for an "
+  "enabled hash");
+static_assert(is_copy_constructible<_Equal>::value,
+  "the specified comparator is required to be copy constructible");
+return true;
+  }
 };
 
 template 
@@ -951,6 +960,10 @@ private:
 typedef allocator_traits<__pointer_allocator>  
__pointer_alloc_traits;
 typedef typename __bucket_list_deleter::pointer   
__node_pointer_pointer;
 
+#ifndef _LIBCPP_CXX03_LANG
+static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, 
_Alloc>::__trigger_diagnostics(), "");
+#endif
+
 // --- Member data begin ---
 __bucket_list __bucket_list_;
 __compressed_pair<__first_node, __node_allocator> __p1_;
@@ -1482,13 +1495,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 template 
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
 {
+#if defined(_LIBCPP_CXX03_LANG)
 static_assert((is_copy_constructible::value),
  "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);

Added: 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp?rev=296565=auto
==
--- 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 Tue Feb 28 20:02:28 2017
@@ -0,0 +1,32 @@
+//===--===//
+//
+// 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
+
+// 
+
+// Test that we generate a reasonable diagnostic when the specified hash is
+// not enabled.
+
+#include 
+#include 
+
+using VT = std::pair;
+using Set = std::unordered_set;
+
+int main() {
+
+  Set s; // expected-error@__hash_table:* {{the specified hash functor does 
not meet the requirements for an enabled hash}}
+
+  // FIXME: It would be great to suppress the below diagnostic all together.
+  //but for now it's sufficient that it appears last. However there is
+  //currently no way to test the order diagnostics are issued.
+  // expected-error@memory:* {{call to 

r296562 - [Analyzer] Fix crash in ObjCPropertyChecker on protocol property

2017-02-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Feb 28 19:47:37 2017
New Revision: 296562

URL: http://llvm.org/viewvc/llvm-project?rev=296562=rev
Log:
[Analyzer] Fix crash in ObjCPropertyChecker on protocol property

Fix a crash in the ObjCPropertyChecker when analyzing a 'copy' property of an
NSMutable* type in a protocol.

rdar://problem/30766684

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp?rev=296562=296561=296562=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp Tue Feb 28 
19:47:37 2017
@@ -58,8 +58,7 @@ void ObjCPropertyChecker::checkCopyMutab
   if (const ObjCInterfaceDecl *IntD =
   dyn_cast(D->getDeclContext())) {
 ImplD = IntD->getImplementation();
-  } else {
-const ObjCCategoryDecl *CatD = cast(D->getDeclContext());
+  } else if (auto *CatD = dyn_cast(D->getDeclContext())) {
 ImplD = CatD->getClassInterface()->getImplementation();
   }
 

Modified: cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m?rev=296562=296561=296562=diff
==
--- cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m (original)
+++ cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m Tue Feb 28 19:47:37 
2017
@@ -59,3 +59,10 @@
 @interface IWithoutImpl : NSObject {}
 @property(copy) NSMutableString *mutableStr; // no-warning
 @end
+
+@protocol SomeProtocol
+// Don't warn on protocol properties because it is possible to
+// conform to them correctly; it is only synthesized setters that
+// that are definitely incorrect.
+@property (copy) NSMutableString *myProp; // no-crash // no-warning
+@end


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


[PATCH] D25208: [libc++] Make _LIBCPP_TYPE_VIS export members

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90109.
smeenai added a comment.

Rebase atop https://reviews.llvm.org/D29157 and switch to 
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS


https://reviews.llvm.org/D25208

Files:
  docs/DesignDocs/VisibilityMacros.rst
  include/__config
  include/__locale
  include/__mutex_base
  include/condition_variable
  include/future
  include/mutex
  include/thread

Index: include/thread
===
--- include/thread
+++ include/thread
@@ -300,7 +300,9 @@
  >
 explicit thread(_Fp&& __f, _Args&&... __args);
 #else  // _LIBCPP_HAS_NO_VARIADICS
-template  explicit thread(_Fp __f);
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+explicit thread(_Fp __f);
 #endif
 ~thread();
 
Index: include/mutex
===
--- include/mutex
+++ include/mutex
@@ -248,6 +248,7 @@
 bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
 {return try_lock_until(chrono::steady_clock::now() + __d);}
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
 void unlock() _NOEXCEPT;
 };
@@ -291,6 +292,7 @@
 bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
 {return try_lock_until(chrono::steady_clock::now() + __d);}
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
 void unlock() _NOEXCEPT;
 };
Index: include/future
===
--- include/future
+++ include/future
@@ -582,6 +582,7 @@
 _LIBCPP_INLINE_VISIBILITY
 wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 future_status
 wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const;
 
@@ -1674,6 +1675,7 @@
 public:
 promise();
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 promise(allocator_arg_t, const _Allocator& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY
Index: include/condition_variable
===
--- include/condition_variable
+++ include/condition_variable
@@ -133,12 +133,14 @@
 void notify_all() _NOEXCEPT;
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 void wait(_Lock& __lock);
 template 
 _LIBCPP_INLINE_VISIBILITY
 void wait(_Lock& __lock, _Predicate __pred);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 cv_status
 wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __t);
Index: include/__mutex_base
===
--- include/__mutex_base
+++ include/__mutex_base
@@ -316,20 +316,24 @@
 
 void wait(unique_lock& __lk) _NOEXCEPT;
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 void wait(unique_lock& __lk, _Predicate __pred);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 cv_status
 wait_until(unique_lock& __lk,
const chrono::time_point<_Clock, _Duration>& __t);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 bool
 wait_until(unique_lock& __lk,
const chrono::time_point<_Clock, _Duration>& __t,
_Predicate __pred);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 cv_status
 wait_for(unique_lock& __lk,
  const chrono::duration<_Rep, _Period>& __d);
Index: include/__locale
===
--- include/__locale
+++ include/__locale
@@ -92,13 +92,16 @@
 
 const locale& operator=(const locale&)  _NOEXCEPT;
 
-template  locale combine(const locale&) const;
+template 
+  inline _LIBCPP_INLINE_VISIBILITY
+  locale combine(const locale&) const;
 
 // locale operations:
 string name() const;
 bool operator==(const locale&) const;
 bool operator!=(const locale& __y) const {return !(*this == __y);}
 template 
+  inline _LIBCPP_INLINE_VISIBILITY
   bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
   const basic_string<_CharT, _Traits, _Allocator>&) const;
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -627,18 +627,22 @@
 
 #ifndef _LIBCPP_TYPE_VIS
 #  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#if __has_attribute(__type_visibility__)
-#  define 

[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90108.
smeenai edited the summary of this revision.
smeenai added a comment.

Addressing comments


https://reviews.llvm.org/D29157

Files:
  docs/DesignDocs/VisibilityMacros.rst
  include/__config
  include/locale
  include/string

Index: include/string
===
--- include/string
+++ include/string
@@ -792,6 +792,7 @@
 basic_string(const basic_string& __str, size_type __pos,
  const _Allocator& __a = _Allocator());
 template
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 basic_string(const _Tp& __t, size_type __pos, size_type __n,
  const allocator_type& __a = allocator_type(),
  typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0);
Index: include/locale
===
--- include/locale
+++ include/locale
@@ -623,16 +623,19 @@
 ~num_get() {}
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 iter_type __do_get_floating_point
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Fp& __v) const;
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 iter_type __do_get_signed
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Signed& __v) const;
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 iter_type __do_get_unsigned
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Unsigned& __v) const;
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -591,6 +591,7 @@
 #define _LIBCPP_EXTERN_VIS  _LIBCPP_DLL_VIS
 #define _LIBCPP_EXCEPTION_ABI   _LIBCPP_DLL_VIS
 #define _LIBCPP_HIDDEN
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 #define _LIBCPP_TEMPLATE_VIS
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
@@ -614,6 +615,8 @@
 #endif
 #endif
 
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDDEN
+
 #ifndef _LIBCPP_FUNC_VIS
 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
@@ -668,7 +671,7 @@
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
-#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
+#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  endif
Index: docs/DesignDocs/VisibilityMacros.rst
===
--- docs/DesignDocs/VisibilityMacros.rst
+++ docs/DesignDocs/VisibilityMacros.rst
@@ -110,6 +110,35 @@
   the extern template declaration) as exported on Windows, as discussed above.
   On all other platforms, this macro has an empty definition.
 
+**_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS**
+  Mark a symbol as hidden so it will not be exported from shared libraries. This
+  is intended specifically for method templates of either classes marked with
+  `_LIBCPP_TYPE_VIS` or classes with an extern template instantiation
+  declaration marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS`.
+
+  When building libc++ with hidden visibility, we want explicit template
+  instantiations to export members, which is consistent with existing Windows
+  behavior. We also want classes annotated with `_LIBCPP_TYPE_VIS` to export
+  their members, which is again consistent with existing Windows behavior.
+  Both these changes are necessary for clients to be able to link against a
+  libc++ DSO built with hidden visibility without encountering missing symbols.
+
+  An unfortunate side effect, however, is that method templates of classes
+  either marked `_LIBCPP_TYPE_VIS` or with extern template instantiation
+  declarations marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` also get default
+  visibility when instantiated. These methods are often implicitly instantiated
+  inside other libraries which use the libc++ headers, and will therefore end up
+  being exported from those libraries, since those implicit instantiations will
+  receive default visibility. This is not acceptable for libraries that wish to
+  control their visibility, and led to PR30642.
+
+  Consequently, all such problematic method templates are explicitly marked
+  either hidden (via this macro) or inline, so that they don't leak into client
+  libraries. The problematic methods were found by running
+  `bad-visibility-finder 

[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/string:1100
 template
+inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if

EricWF wrote:
> smeenai wrote:
> > EricWF wrote:
> > > Why `inline _LIBCPP_INLINE_VISIBILITY` here but `_LIBCPP_HIDDEN` 
> > > everywhere else?
> > This function is really small, so I figured marking it for inlining was 
> > more appropriate.
> This should probably have _LIBCPP_INLINE_VISIBILITY on it then.
I was assuming any client that cares about what they're exporting would build 
with `-fvisibility-inlines-hidden`, in which case just `inline` should be 
enough.


https://reviews.llvm.org/D29157



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


[libcxx] r296561 - Fix PR32097 - is_abstract doesn't work on class templates.

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 19:27:14 2017
New Revision: 296561

URL: http://llvm.org/viewvc/llvm-project?rev=296561=rev
Log:
Fix PR32097 - is_abstract doesn't work on class templates.

This patch fixes llvm.org/PR32097 by using the __is_abstract
builtin type-trait instead of the previous library-only implementation.

All supported compilers provide this trait. I've tested as far
back as Clang 3.2, GCC 4.6 and MSVC trunk.

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=296561=296560=296561=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Feb 28 19:27:14 2017
@@ -1297,18 +1297,8 @@ template  using decay_t = typ
 
 // is_abstract
 
-namespace __is_abstract_imp
-{
-template  char  __test(_Tp (*)[1]);
-template  __two __test(...);
-}
-
-template ::value>
-struct __libcpp_abstract : public integral_constant(0)) != 1> {};
-
-template  struct __libcpp_abstract<_Tp, false> : public false_type 
{};
-
-template  struct _LIBCPP_TEMPLATE_VIS is_abstract : public 
__libcpp_abstract<_Tp> {};
+template  struct _LIBCPP_TEMPLATE_VIS is_abstract
+: public integral_constant {};
 
 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 template  _LIBCPP_CONSTEXPR bool is_abstract_v

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp?rev=296561=296560=296561=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
 Tue Feb 28 19:27:14 2017
@@ -65,6 +65,14 @@ class Abstract
 virtual ~Abstract() = 0;
 };
 
+template 
+struct AbstractTemplate {
+  virtual void test() = 0;
+};
+
+template <>
+struct AbstractTemplate {};
+
 int main()
 {
 test_is_not_abstract();
@@ -81,4 +89,6 @@ int main()
 test_is_not_abstract();
 
 test_is_abstract();
+test_is_abstract();
+test_is_not_abstract();
 }


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


[libcxx] r296558 - Updated the XFAIL comment in variant tests.

2017-02-28 Thread Michael Park via cfe-commits
Author: mpark
Date: Tue Feb 28 19:07:56 2017
New Revision: 296558

URL: http://llvm.org/viewvc/llvm-project?rev=296558=rev
Log:
Updated the XFAIL comment in variant tests.

Summary:
`ConstexprTestTypes::NoCtors` is an aggregate type (and consequently a literal 
type) in C++17,
but not in C++14 since it has a base class. This patch updates the comment to 
accurately describe the reason for the XFAIL.

Reviewers: EricWF

Reviewed By: EricWF

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

Modified:

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp?rev=296558=296557=296558=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
 Tue Feb 28 19:07:56 2017
@@ -10,7 +10,10 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// The following compilers don't allow constexpr variables of non-literal type.
+// The following compilers don't consider a type an aggregate type (and
+// consequently not a literal type) if it has a base class at all.
+// In C++17, an aggregate type is allowed to have a base class if it's not
+// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors).
 // XFAIL: gcc-5, gcc-6
 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
 // XFAIL: apple-clang-6, apple-clang-7, apple-clang-8

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp?rev=296558=296557=296558=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
 Tue Feb 28 19:07:56 2017
@@ -10,7 +10,10 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// The following compilers don't allow constexpr variables of non-literal type.
+// The following compilers don't consider a type an aggregate type (and
+// consequently not a literal type) if it has a base class at all.
+// In C++17, an aggregate type is allowed to have a base class if it's not
+// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors).
 // XFAIL: gcc-5, gcc-6
 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
 // XFAIL: apple-clang-6, apple-clang-7, apple-clang-8


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


r296554 - [PS4] Set our default dialect to C++11. NFC for other targets.

2017-02-28 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Feb 28 19:01:10 2017
New Revision: 296554

URL: http://llvm.org/viewvc/llvm-project?rev=296554=rev
Log:
[PS4] Set our default dialect to C++11. NFC for other targets.
Reapplies r296209 now that r296549 has fixed what really seems to be
the last problematic test.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=296554=296553=296554=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Feb 28 19:01:10 2017
@@ -1582,7 +1582,11 @@ void CompilerInvocation::setLangDefaults
 case IK_PreprocessedCXX:
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
-  LangStd = LangStandard::lang_gnucxx98;
+  // The PS4 uses C++11 as the default C++ standard.
+  if (T.isPS4())
+LangStd = LangStandard::lang_gnucxx11;
+  else
+LangStd = LangStandard::lang_gnucxx98;
   break;
 case IK_RenderScript:
   LangStd = LangStandard::lang_c99;


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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/string:1100
 template
+inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if

smeenai wrote:
> EricWF wrote:
> > Why `inline _LIBCPP_INLINE_VISIBILITY` here but `_LIBCPP_HIDDEN` everywhere 
> > else?
> This function is really small, so I figured marking it for inlining was more 
> appropriate.
This should probably have _LIBCPP_INLINE_VISIBILITY on it then.


https://reviews.llvm.org/D29157



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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 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, but with a macro other than `_LIBCPP_HIDDEN`.

Also could you please add doc explaining the rational for this new macro in 
depth. I think the summary for this revision would be sufficient.


https://reviews.llvm.org/D29157



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


r296549 - [Test] Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Charles Li via cfe-commits
Author: lcharles
Date: Tue Feb 28 18:10:00 2017
New Revision: 296549

URL: http://llvm.org/viewvc/llvm-project?rev=296549=rev
Log:
[Test] Make Lit tests C++11 compatible - IR ordering

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

Modified:
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp

Modified: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-instantiation.cpp?rev=296549=296548=296549=diff
==
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp Tue Feb 28 18:10:00 
2017
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and 
C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK 
and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void 
@_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +153,7 @@ class B {
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


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


[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296549: [Test] Make Lit tests C++11 compatible - IR ordering 
(authored by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D30430?vs=90078=90101#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30430

Files:
  cfe/trunk/test/CodeGenCXX/template-instantiation.cpp


Index: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
===
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and 
C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK 
and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void 
@_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +153,7 @@
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


Index: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
===
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: 

[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

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

In https://reviews.llvm.org/D29753#688845, @bruno wrote:

> > What do folks think?
>
> IMO we should do it.


Go ahead and commit this, but keep the bug open so we can work on fixing it 
properly eventually.


https://reviews.llvm.org/D29753



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


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-02-28 Thread Blaise Watson via Phabricator via cfe-commits
watsond updated this revision to Diff 90087.
watsond marked an inline comment as done.
watsond added a comment.

Fixed logic error, added enum test case


https://reviews.llvm.org/D29858

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  test/clang-tidy/misc-redundant-expression.cpp


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-02-28 Thread Blaise Watson via Phabricator via cfe-commits
watsond marked 2 inline comments as done.
watsond added a comment.

In https://reviews.llvm.org/D29858#675055, @etienneb wrote:

> Could you add some tests with enums (like the one in your description)?
>  This is missing and it's a nice to have.


Added




Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:244
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;

etienneb wrote:
> etienneb wrote:
> > The good news is that this code will be catch by this check!
> > ```
> >   if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)   <<-- redundant expression
> > ```
> > Should be:
> > ```
> >   if (OpcodeLHS == BO_NE || OpcodeRHS == BO_NE) 
> > ```
> > 
> > 
> > 
> btw, it should be:
> 
> ```
>   if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
> ```
Thanks for catching!


https://reviews.llvm.org/D29858



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


Re: r296221 - [ODRHash] Move inherited visitor call to end of function.

2017-02-28 Thread Richard Trieu via cfe-commits
There's no functional change.  This was a mistake I made when splitting the
original patch into pieces and I wanted to correct before proceeding with
additional changes.

On Mon, Feb 27, 2017 at 8:27 AM, David Blaikie  wrote:

> An explanation as to why the code was moved (& possibly test cases, or
> "NFC" in the description) would be handy here.
>
> On Fri, Feb 24, 2017 at 5:41 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Feb 24 19:29:34 2017
>> New Revision: 296221
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=296221=rev
>> Log:
>> [ODRHash] Move inherited visitor call to end of function.
>>
>> Modified:
>> cfe/trunk/lib/AST/ODRHash.cpp
>>
>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
>> ODRHash.cpp?rev=296221=296220=296221=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>> +++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 19:29:34 2017
>> @@ -182,8 +182,6 @@ public:
>>}
>>
>>void VisitFieldDecl(const FieldDecl *D) {
>> -Inherited::VisitFieldDecl(D);
>> -
>>  const bool IsBitfield = D->isBitField();
>>  Hash.AddBoolean(IsBitfield);
>>
>> @@ -193,6 +191,8 @@ public:
>>
>>  Hash.AddBoolean(D->isMutable());
>>  AddStmt(D->getInClassInitializer());
>> +
>> +Inherited::VisitFieldDecl(D);
>>}
>>  };
>>
>>
>>
>> ___
>> 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] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge added a comment.

In https://reviews.llvm.org/D30430#688146, @rjmccall wrote:

> The C++98 behavior here is not really vital to test precisely; it's just 
> minor differences in what gets instantiated and when.


Hi John, my main concern with CHECK-NOT appearing between CHECK lines is that 
it makes the test brittle to the order of the IR.
For this reason I have separated out the CHECK-NOTs to go under a seperate 
prefix with a separate RUN line.
If you would like to old way of a single RUN line, I can do that too.

> I think it's fine to just update the run line to -std=c++11 for things like 
> this.

Done. I have deleted C++98 RUN lines and default (no -std) RUN lines.

>   But if you really want to test both configurations, this LGTM, although 
> please leave a comment in the test explaining that it's just trying to 
> account for differences in instantiation order between C++98 and C++11.

I have added 2 lines of comments. 
One explains why CHECK-DAG is used instead of CHECK.
Another explains why CHECK2-NOT is used instead of CHECK-NOT


https://reviews.llvm.org/D30430



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


r296521 - [ODRHash] Add basic support for CXXRecordDecl

2017-02-28 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Feb 28 15:24:38 2017
New Revision: 296521

URL: http://llvm.org/viewvc/llvm-project?rev=296521=rev
Log:
[ODRHash] Add basic support for CXXRecordDecl

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296521=296520=296521=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Feb 28 
15:24:38 2017
@@ -121,10 +121,10 @@ def err_module_odr_violation_mismatch_de
   "%q0 has different definitions in different modules; first difference is "
   "%select{definition in module '%2'|defined here}1 found "
   "%select{end of class|public access specifier|private access specifier|"
-  "protected access specifier|static assert|field}3">;
+  "protected access specifier|static assert|field|method}3">;
 def note_module_odr_violation_mismatch_decl : Note<"but in '%0' found "
   "%select{end of class|public access specifier|private access specifier|"
-  "protected access specifier|static assert|field}1">;
+  "protected access specifier|static assert|field|method}1">;
 
 def err_module_odr_violation_mismatch_decl_diff : Error<
   "%q0 has different definitions in different modules; first difference is "
@@ -139,7 +139,8 @@ def err_module_odr_violation_mismatch_de
   "bitfield %4 with one width expression|"
   "%select{non-|}5mutable field %4|"
   "field %4 with %select{no|an}5 initalizer|"
-  "field %4 with an initializer}3">;
+  "field %4 with an initializer|"
+  "method %4}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -152,7 +153,8 @@ def note_module_odr_violation_mismatch_d
   "bitfield %2 with different width expression|"
   "%select{non-|}3mutable field %2|"
   "field %2 with %select{no|an}3 initializer|"
-  "field %2 with a different initializer}1">;
+  "field %2 with a different initializer|"
+  "method %2}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296521=296520=296521=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Feb 28 15:24:38 2017
@@ -194,6 +194,14 @@ public:
 
 Inherited::VisitFieldDecl(D);
   }
+
+  void VisitFunctionDecl(const FunctionDecl *D) {
+Inherited::VisitFunctionDecl(D);
+  }
+
+  void VisitCXXMethodDecl(const CXXMethodDecl *D) {
+Inherited::VisitCXXMethodDecl(D);
+  }
 };
 
 // Only allow a small portion of Decl's to be processed.  Remove this once
@@ -206,6 +214,7 @@ bool ODRHash::isWhitelistedDecl(const De
 default:
   return false;
 case Decl::AccessSpec:
+case Decl::CXXMethod:
 case Decl::Field:
 case Decl::StaticAssert:
   return true;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296521=296520=296521=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Feb 28 15:24:38 2017
@@ -8957,6 +8957,7 @@ void ASTReader::diagnoseOdrViolations()
 ProtectedSpecifer,
 StaticAssert,
 Field,
+CXXMethod,
 Other
   } FirstDiffType = Other,
 SecondDiffType = Other;
@@ -8982,6 +8983,8 @@ void ASTReader::diagnoseOdrViolations()
   return StaticAssert;
 case Decl::Field:
   return Field;
+case Decl::CXXMethod:
+  return CXXMethod;
 }
   };
 
@@ -9068,6 +9071,7 @@ void ASTReader::diagnoseOdrViolations()
 FieldSingleMutable,
 FieldSingleInitializer,
 FieldDifferentInitializers,
+MethodName,
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9287,6 +9291,25 @@ void ASTReader::diagnoseOdrViolations()
 }
 
 break;
+  }
+  case CXXMethod: {
+const CXXMethodDecl *FirstMethod = cast(FirstDecl);
+const CXXMethodDecl *SecondMethod = cast(SecondDecl);
+IdentifierInfo *FirstII = FirstMethod->getIdentifier();
+IdentifierInfo *SecondII = SecondMethod->getIdentifier();
+if (FirstII->getName() != SecondII->getName()) {
+  ODRDiagError(FirstMethod->getLocation(),
+   FirstMethod->getSourceRange(), MethodName)
+ 

[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 90078.
tigerleapgorge added a comment.

Updated patch.

Test only runs in C++11.
Added comments to explain CHECK-DAG and CHECK2-NOT.


https://reviews.llvm.org/D30430

Files:
  test/CodeGenCXX/template-instantiation.cpp


Index: test/CodeGenCXX/template-instantiation.cpp
===
--- test/CodeGenCXX/template-instantiation.cpp
+++ test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and 
C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK 
and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void 
@_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +153,7 @@
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


Index: test/CodeGenCXX/template-instantiation.cpp
===
--- test/CodeGenCXX/template-instantiation.cpp
+++ test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// 

[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

2017-02-28 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!

In https://reviews.llvm.org/D30327#688254, @malcolm.parsons wrote:

> I found this FIXME comment in `Expr::HasSideEffects()`:
>
>   case LambdaExprClass: {
> const LambdaExpr *LE = cast(this);
> for (LambdaExpr::capture_iterator I = LE->capture_begin(),
>   E = LE->capture_end(); I != E; ++I)
>   if (I->getCaptureKind() == LCK_ByCopy)
> // FIXME: Only has a side-effect if the variable is volatile or if
> // the copy would invoke a non-trivial copy constructor.
> return true;
> return false;
>   }
>   
>
> It seems a shame not to fix this now, but I don't think I can call Sema code 
> from AST code, and my `CaptureHasSideEffects()` depends on 
> `Sema::getCurrentThisType()`.
>
> Any ideas?


Correct, you cannot call Sema code from AST. I don't know of a good way to 
resolve this off the top of my head given what `getCurrentThisType()` needs to 
do. I agree that this would be good to fix as well, but your patch is a good 
incremental improvement and should't be held up on this.


https://reviews.llvm.org/D30327



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


[PATCH] D30372: [Driver] Consolidate tools and toolchains by target platform. (NFC)

2017-02-28 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

In https://reviews.llvm.org/D30372#688154, @mehdi_amini wrote:

> In https://reviews.llvm.org/D30372#687060, @ahatanak wrote:
>
> > In https://reviews.llvm.org/D30372#687054, @dlj wrote:
> >
> > > In https://reviews.llvm.org/D30372#686871, @ahatanak wrote:
> > >
> > > > Have you considered using "include_directories" in CMakeLists.txt to 
> > > > avoid including "../Something.h"?
> > >
> > >
> > > I don't want to take that approach, and there's a specific reason why: my 
> > > concern isn't with three extra bytes, it's the fact that the headers are 
> > > in an unusual place. It's typical to include headers from a subdirectory, 
> > > or from the includes directory, but far less common to include from a 
> > > parent lib directory. Hiding that fact seems strictly worse to me.
> >
> >
> > OK. I was suggesting that only because LLVM already uses 
> > include_directories to include a header that exists in the parent directory 
> > in some cases. Apparently that's not what you wanted.
>
>
> Yes it seems "common" in LLVM to do this in CMake: `include_directories( 
> ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )`


Actually, since I'm still keeping these files in the clangDriver rule, the 
lib/Driver directory is already on the search path, so I can use a subpath of 
Driver already.


https://reviews.llvm.org/D30372



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296518: Allow attributes before union definition (authored 
by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D28266?vs=90056=90075#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28266

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/transparent-union.c
  cfe/trunk/test/Sema/transparent-union.c

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -3122,6 +3122,8 @@
   void ProcessPragmaWeak(Scope *S, Decl *D);
   // Decl attributes - this routine is the top level dispatcher.
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator );
+  // Helper for delayed proccessing of attributes.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);
   void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
 bool IncludeCXX11Attributes = true);
   bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
Index: cfe/trunk/test/CodeGen/transparent-union.c
===
--- cfe/trunk/test/CodeGen/transparent-union.c
+++ cfe/trunk/test/CodeGen/transparent-union.c
@@ -3,10 +3,21 @@
 // RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 -DINFRONT -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
 
+#ifdef INFRONT
+typedef union __attribute__((transparent_union)) {
+  void *f0;
+} transp_t0;
+#else
 typedef union {
   void *f0;
 } transp_t0 __attribute__((transparent_union));
+#endif
 
 void f0(transp_t0 obj);
 
Index: cfe/trunk/test/Sema/transparent-union.c
===
--- cfe/trunk/test/Sema/transparent-union.c
+++ cfe/trunk/test/Sema/transparent-union.c
@@ -54,11 +54,21 @@
   aligned_struct8 s8; // expected-warning{{alignment of field}}
 } TU1 __attribute__((transparent_union));
 
+typedef union __attribute__((transparent_union)) {
+  aligned_struct4 s4; // expected-note{{alignment of first field}}
+  aligned_struct8 s8; // expected-warning{{alignment of field}}
+} TU1b ;
+
 typedef union {
   char c; // expected-note{{size of first field is 8 bits}}
   int i; // expected-warning{{size of field}}
 } TU2 __attribute__((transparent_union));
 
+typedef union __attribute__((transparent_union)){
+  char c; // expected-note{{size of first field is 8 bits}}
+  int i; // expected-warning{{size of field}}
+} TU2b;
+
 typedef union {
   float f; // expected-warning{{floating}}
 } TU3 __attribute__((transparent_union));
@@ -98,3 +108,17 @@
 union pr30520s { struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
 
 union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
+
+typedef union __attribute__((__transparent_union__)) {
+  int *i;
+  struct st *s;
+} TU6;
+
+void bar(TU6);
+
+void foo11(int *i) {
+  bar(i);
+}
+void foo2(struct st *s) {
+  bar(s);
+}
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1887,6 +1887,10 @@
   ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing of attributes.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), attrs.getList());
+
   const char *PrevSpec = nullptr;
   unsigned DiagID;
   bool Result;
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13637,9 +13637,6 @@
   if (Invalid)
 New->setInvalidDecl();
 
-  if (Attr)
-ProcessDeclAttributeList(S, New, Attr);
-
   // Set the lexical context. If the tag has a C++ scope specifier, the
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
@@ -13658,6 +13655,9 @@
   

r296518 - Allow attributes before union definition

2017-02-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 28 14:44:39 2017
New Revision: 296518

URL: http://llvm.org/viewvc/llvm-project?rev=296518=rev
Log:
Allow attributes before union definition

permits typedef union __attribute__((transparent_union)) {...}

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/transparent-union.c
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=296518=296517=296518=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 28 14:44:39 2017
@@ -3122,6 +3122,8 @@ public:
   void ProcessPragmaWeak(Scope *S, Decl *D);
   // Decl attributes - this routine is the top level dispatcher.
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator );
+  // Helper for delayed proccessing of attributes.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);
   void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
 bool IncludeCXX11Attributes = true);
   bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=296518=296517=296518=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Feb 28 14:44:39 2017
@@ -1887,6 +1887,10 @@ void Parser::ParseClassSpecifier(tok::To
   ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing of attributes.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), 
attrs.getList());
+
   const char *PrevSpec = nullptr;
   unsigned DiagID;
   bool Result;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=296518=296517=296518=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 28 14:44:39 2017
@@ -13637,9 +13637,6 @@ CreateNewDecl:
   if (Invalid)
 New->setInvalidDecl();
 
-  if (Attr)
-ProcessDeclAttributeList(S, New, Attr);
-
   // Set the lexical context. If the tag has a C++ scope specifier, the
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
@@ -13658,6 +13655,9 @@ CreateNewDecl:
   if (TUK == TUK_Definition)
 New->startDefinition();
 
+  if (Attr)
+ProcessDeclAttributeList(S, New, Attr);
+
   // If this has an identifier, add it to the scope stack.
   if (TUK == TUK_Friend) {
 // We might be replacing an existing declaration in the lookup tables;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=296518=296517=296518=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 28 14:44:39 2017
@@ -3193,8 +3193,9 @@ static void handleTransparentUnionAttr(S
   }
 
   if (!RD->isCompleteDefinition()) {
-S.Diag(Attr.getLoc(),
-diag::warn_transparent_union_attribute_not_definition);
+if (!RD->isBeingDefined())
+  S.Diag(Attr.getLoc(),
+ diag::warn_transparent_union_attribute_not_definition);
 return;
   }
 
@@ -6314,6 +6315,15 @@ void Sema::ProcessDeclAttributeList(Scop
   }
 }
 
+// Helper for delayed proccessing TransparentUnion attribute.
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) 
{
+  for (const AttributeList *Attr = AttrList; Attr; Attr = Attr->getNext())
+if (Attr->getKind() == AttributeList::AT_TransparentUnion) {
+  handleTransparentUnionAttr(*this, D, *Attr);
+  break;
+}
+}
+
 // Annotation attributes are the only attributes allowed after an access
 // specifier.
 bool Sema::ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,

Modified: cfe/trunk/test/CodeGen/transparent-union.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union.c?rev=296518=296517=296518=diff
==
--- cfe/trunk/test/CodeGen/transparent-union.c (original)
+++ cfe/trunk/test/CodeGen/transparent-union.c Tue Feb 28 14:44:39 2017
@@ -3,10 +3,21 @@
 // RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck 
%s --check-prefix=ARM
 // RUN: %clang_cc1 -Werror 

[PATCH] D30166: Honor __unaligned in codegen for declarations and expressions

2017-02-28 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.

I think this LGTM, but you should wait for confirmation from one of the other 
reviewers before committing.


https://reviews.llvm.org/D30166



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-28 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, with one formatting nit.




Comment at: lib/Sema/SemaDeclAttr.cpp:6201
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) 
{
+  for (const AttributeList* l = AttrList; l; l = l->getNext())
+if (l->getKind() == AttributeList::AT_TransparentUnion) {

aaron.ballman wrote:
> Nit: the `*` should bind to `l` and `l` should be `L` by our usual naming 
> conventions (but a name better than `L` wouldn't be amiss).
Nit: missing a space before the first `=`. You should run clang-format on the 
patch to catch this sort of thing.


https://reviews.llvm.org/D28266



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-28 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, despite a long-ish comment.




Comment at: lib/Parse/ParseDeclCXX.cpp:3830-3837
+  unsigned NumArgs;
+  // Some Clang-scoped attributes have some special parsing behavior.
+  if (ScopeName && ScopeName->getName() == "clang")
+NumArgs =
+ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, 
ScopeName,
+ScopeLoc, AttributeList::AS_CXX11);
+  else

This code is equivalent to the old code, which is good. However, it points out 
what I think may be a latent bug -- for attributes in the clang namespace that 
are also standard attributes, I'm not certain we should be generating parse 
errors for the clang-namespaced spelling. This only impacts [[fallthrough]] vs 
[[clang::fallthrough]], according to the implementation of 
`IsBuiltInOrStandardCXX11Attribute()`.

All of that is to say: I'm not certain we need to hoist `NumArgs` to get to the 
call to `IsBuiltInOrStandardCXX11Attribute()` below, because attributes in the 
clang namespace are not built-in or standard attributes.

This requires a bit further exploration, but I won't have time to do that for a 
few weeks. I don't want to hold your patch up for that, so I think this is fine 
for now -- I can modify the code later when I have the chance to finish my 
exploration.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> What do folks think?

IMO we should do it.


https://reviews.llvm.org/D29753



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> It seems to me that the problem here is that `DeclMustBeEmitted` is not safe 
> to call in the middle of deserialization if anything partially-deserialized 
> might be reachable from the declaration we're querying, and yet we're 
> currently calling it in that case.

`DeclMustBeEmitted` name seems misleading since we does more than just 
checking, it actually tries to emit stuff. If it's a local module, shouldn't be 
everything already available? Do we have non-deserialized items for a local 
module? Maybe I get the wrong idea of what local means in this context..

> I don't see how this patch actually addresses that problem, though: if you 
> build this testcase as a module instead of a PCH, won't it still fail in the 
> same way that it does now?

`D->getImportedOwningModule` calls `isFromASTFile`, which refers to PCH and 
modules, shouldn't it work for both then? I couldn't come up with a testcase 
that triggered it for modules though.

> I think we probably need to track all the declarations we deserialize in a 
> top-level deserialization,  and only check whether they're interesting when 
> we finish recursive deserialization (somewhere around 
> `ASTReader::FinishedDeserializing`). For the update record case, this will 
> need some care in order to retain the property that we only pass a 
> declaration to the consumer once, but I think we can make that work by 
> observing that it should generally be safe to call `DeclMustBeEmitted` on a 
> declaration that we didn't create in this deserialization step, and when 
> we're loading update records we know whether that's the case.

Right. This is a more involved fix and I don't fully understand all r276159 
consequences yet. OTOH, the current patch improves the situation and unblock 
some big projects to compile with clang ToT, for instance, Unreal Engine 4.


https://reviews.llvm.org/D29753



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: mehdi_amini.
hans added a comment.

To unblock 4.0, I'm leaning towards merging Bruno's patch as a stop-gap fix.

I realize it probably only fixes the problem for PCH, and not modules. But PCH 
is used more widely than modules, so maybe it's good enough for now?

We've run out of time for 4.0, and it seems fixing this properly might be 
involved.

What do folks think?


https://reviews.llvm.org/D29753



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


Re: [PATCH] Improved plugin/tool support by expanding an existing attribute

2017-02-28 Thread Aaron Ballman via cfe-commits
On Fri, Feb 24, 2017 at 8:24 AM, Marcwell Helpdesk  wrote:
>
> As interesting the subject of pluggable attributes may be could we please 
> drop that discussion and focus on the intention of and what the patch 
> actually does? Two revisions of the patch have been supplied and both should 
> reasonable not cause any controversy since they only enriches an already 
> existing functionality.

That discussion and this patch are inextricably linked because they
are competing designs for the same functionality. The question boils
down to which way is the best way forward for users, and I do not
believe extending the annotate attribute in this way is the correct
approach.

> You left out the statement annotation when asking to split the patch, if this 
> is causing the controversy please explain why. It would be very interesting 
> to know the original intention of the annotate attribute should it deviate in 
> any way from being a general purpose information bearer. And as I have tried 
> to explain several times, the statement annotations are as 
> important/irrelevant as any other type of annotations and with the current 
> support in LLVM/clang it won’t support forwarding to IR but it may be used in 
> the AST.

As I've pointed out during the review, the annotate attribute is
inadequate for specifying things like subjects, arguments,
namespacing, or preventing other misuses of custom attributes. It is
error-prone to use, and so extending it to further uses only
exacerbates these problems. These can be solved in an ad hoc manner,
but that only pushes the design closer to a poor implementation of
pluggable attributes.

Just to be explicit: I agree with your assertion that statement
annotations are as important as other attributes and that we should
have a generic way to carry information on various constructs through
the AST (and to the IR when plausible). What I disagree with is the
way in which the functionality is exposed both to end-users and
attribute authors (or tool designers).

> Furthermore, if you don’t like the what the documentation says about using 
> the annotations for tools then drop the documentation or write it yourself, 
> it must not be the show-stopper.

The documentation is fine. I asked for the patch to be split so that
we could accept the documentation (and the C++11 spelling), because
those are not controversial.

~Aaron

>
> Cheers,
> Chris
>
>> On 21 feb 2017, at 15:11, Aaron Ballman  wrote:
>>
>> On Tue, Feb 14, 2017 at 6:05 AM, Marcwell Helpdesk wrote:
>>> The intention of the patch is to extend the functionality of annotations
>>> while utilizing existing infrastructure in the AST and IR as much as
>>> possible. Annotations are indeed a general purpose solution, sufficient for
>>> many use cases, and a complement, not mutual exclusive to pluggable
>>> attributes. And don’t forget the realm of AST tools. The compiler should not
>>> perform any content checking of annotations but leave that to tool
>>> implementations if it is used for other purposes than merely tags. For a
>>> more complete support of annotations the AST and IR needs further work but
>>> this patch is a step on the way.
>>>
>>> Having pluggable attributes would be cool but it would face even greater
>>> problems than you describe. Unless pluggable attributes involves writing
>>> pluggable AST and IR modules the AST and IR must both support some form of
>>> generic containers that could handle any type of attribute with any number
>>> of parameters. In either case, it would most likely involve substantial
>>> architectural changes to many parts.
>>
>> Pluggable attributes do not require these component up front (though
>> they could be explored for later iterations), but you are correct in
>> that they involve more work than simply piggy-backing off the annotate
>> attribute. However, that extra work comes with benefits that expanding
>> the annotate attribute will never realize with the end results being
>> roughly the same (the attribute metadata still gets passed down to the
>> LLVM IR and represented in a manner that AST tools can handle).
>>
>>> I have revised the patch by adding a second, optional parameter that makes
>>> it possible to group annotations, reducing the risk for collisions and since
>>> it is optional it won’t break any existing code. A non-zero group string is
>>> prepended to the value string when forwarded to IR. The C++11 attribute has
>>> been moved to the clang namespace as requested and unit tests and
>>> documentation are updated to reflect the changes.
>>
>> Can you please split this patch? The C++11 attribute name, associated
>> tests, and documentation of what the attribute does currently are not
>> controversial and those changes can go in pretty quickly if separated
>> from the greater discussion about how to allow generic, custom
>> attributes to be exposed.
>>
>> ~Aaron
>>
>>>
>>> Cheers,
>>> Chris
>>>
>>> Modified
>>>  

[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D30345#688298, @arphaman wrote:

> In https://reviews.llvm.org/D30345#688144, @rjmccall wrote:
>
> > You're doing this refactor to... support doing another refactor of the same 
> > code?  Why are these patches separate?
>
>
> Not quite, by "merging block copy/destroy routines" I meant that my next 
> patch will try to generate the IR only for unique copy/destroy functions, so 
> individual functions will be merged.


Ah, okay, sure.




Comment at: lib/CodeGen/CGBlocks.cpp:1380
+/// entity that's captured by a block.
+enum class BlockCaptureEntityType {
+  CXXRecord, // Copy or destroy

BlockCaptureEntityKind, please.



Comment at: lib/CodeGen/CGBlocks.cpp:1389
+/// Represents an entity captured by a block that requires custom operations
+/// to copy/release this entity.
+struct BlockCaptureManagedEntity {

Grammar, and the complementary generic operation to "copy" is "destroy", not 
"release".



Comment at: lib/CodeGen/CGBlocks.cpp:1391
+struct BlockCaptureManagedEntity {
+  BlockCaptureEntityType Type;
+  BlockFieldFlags Flags;

Similarly, please name this Kind.



Comment at: lib/CodeGen/CGBlocks.cpp:1608
+static std::pair
+computeDestroyInfoForBlockCapture(const BlockDecl::Capture , QualType Type,
+  const LangOptions ) {

Please don't name local variables "Type".  "QT" or "T" would be fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


r296499 - clang-format: [Java] Fix bug in enum formatting.

2017-02-28 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Feb 28 12:28:15 2017
New Revision: 296499

URL: http://llvm.org/viewvc/llvm-project?rev=296499=rev
Log:
clang-format: [Java] Fix bug in enum formatting.

Before:
  public enum VeryLongEnum {
ENUM_WITH_MANY_PARAMETERS("aa",
  "bbb",
  "ccc")
,
SECOND_ENUM("a", "b", "c");

private VeryLongEnum(String a, String b, String c) {}
  }

After:
  public enum VeryLongEnum {
ENUM_WITH_MANY_PARAMETERS("aa",
  "bbb",
  "ccc") ,
SECOND_ENUM("a", "b", "c");

private VeryLongEnum(String a, String b, String c) {}
  }

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=296499=296498=296499=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Feb 28 12:28:15 2017
@@ -1083,7 +1083,8 @@ private:
   if (Current.MatchingParen && Current.Next &&
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
- tok::period, tok::arrow, tok::coloncolon))
+ tok::comma, tok::period, tok::arrow,
+ tok::coloncolon))
 if (FormatToken *AfterParen = Current.MatchingParen->Next) {
   // Make sure this isn't the return type of an Obj-C block declaration
   if (AfterParen->Tok.isNot(tok::caret)) {

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=296499=296498=296499=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Feb 28 12:28:15 2017
@@ -225,6 +225,13 @@ TEST_F(FormatTestJava, EnumDeclarations)
"}\n"
"  };\n"
"}");
+  verifyFormat("public enum VeryLongEnum {\n"
+   "  ENUM_WITH_MANY_PARAMETERS(\n"
+   "  \"a\", \"\", 
"
+   "\"\"),\n"
+   "  SECOND_ENUM(\"a\", \"b\", \"c\");\n"
+   "  private VeryLongEnum(String a, String b, String c) {}\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJava, ArrayInitializers) {


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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 6 inline comments as done.
erichkeane added a comment.

Thanks!  Changes incoming.


https://reviews.llvm.org/D28266



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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I will rename it before the upload if that is fine with you.




Comment at: unittests/Format/check-coding-style-mozilla.cpp:77
+return mVar;
+  } // Tiny functions can be written in a single line.
+

krasimir wrote:
> Note that here the trailing comment will make a version of `TinyFunction` on 
> a single line exceed the line limit.
> If the comment is put before the definition of `TinyFunction`, it could 
> really be made tiny, as in:
> ```
>   // Tiny functions can be written in a single line.
>   int TinyFunction() { return mVar; }
> ```
I will remove it for now. I will add it once we have the capability in 
clang-format


https://reviews.llvm.org/D30111



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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 90053.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D30111

Files:
  test/Format/check-coding-style-mozilla.cpp
  unittests/Format/CMakeLists.txt

Index: unittests/Format/CMakeLists.txt
===
--- unittests/Format/CMakeLists.txt
+++ unittests/Format/CMakeLists.txt
@@ -14,6 +14,7 @@
   NamespaceEndCommentsFixerTest.cpp
   SortImportsTestJS.cpp
   SortIncludesTest.cpp
+  check-coding-style-mozilla.cpp
   )
 
 target_link_libraries(FormatTests
Index: test/Format/check-coding-style-mozilla.cpp
===
--- test/Format/check-coding-style-mozilla.cpp
+++ test/Format/check-coding-style-mozilla.cpp
@@ -0,0 +1,130 @@
+// RUN: clang-format -style=Mozilla %s > %T/foo.cpp 2>&1
+// RUN: diff -u %s %T/foo.cpp
+// RUN: rm -rf %T/foo.cpp
+
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+if (true) {
+} else if (false) {
+} else {
+}
+
+while (true) {
+}
+
+do {
+} while (true);
+
+for (auto bar::in) {
+}
+
+switch (var) {
+  case 1: {
+// When you need to declare a variable in a switch, put the block in braces
+int var;
+break;
+  }
+  case 2:
+foo();
+break;
+  default:
+break;
+}
+
+namespace mozilla {
+
+class MyClass : public A
+{
+  void Myclass();
+};
+
+class MyClass : public X // When deriving from more than one class, put each on
+ // its own line.
+,
+public Y
+{
+public:
+  MyClass(int aVar, int aVar2)
+: mVar(aVar)
+, mVar2(aVar2)
+  {
+foo();
+  }
+
+  // Tiny constructors and destructors can be written on a single line.
+  MyClass() {}
+
+  // Unless it's a copy or move constructor or you have a specific reason to
+  // allow implicit conversions, mark all single-argument constructors explicit.
+  explicit MyClass(OtherClass aArg) { bar(); }
+
+  // This constructor can also take a single argument, so it also needs to be
+  // marked explicit.
+  explicit MyClass(OtherClass aArg, AnotherClass aArg2 = AnotherClass())
+  {
+foo();
+  }
+
+  int TinyFunction()
+  {
+return mVar;
+  } // Tiny functions can be written in a single line.
+
+  int LargerFunction()
+  {
+bar();
+foo();
+  }
+
+private:
+  int mVar;
+};
+
+} // namespace mozilla
+
+template // Templates on own line.
+static int
+MyFunction(int a) // Return type on own line for top-level functions.
+{
+  foo();
+}
+
+int
+MyClass::Method(long b)
+{
+  bar();
+}
+
+T* p; // Correct declaration style
+
+// Test the && and || with parentheses
+return (nextKeyframe < aTimeThreshold ||
+(mVideo.mTimeThreshold &&
+ mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold)) &&
+   nextKeyframe.ToMicroseconds() >= 0 && !nextKeyframe.IsInfinite();
+
+// The ? should be placed 2 spaces after the previous declaration
+LOGV("%d audio samples demuxed (sid:%d)",
+ aSamples->mSamples.Length(),
+ aSamples->mSamples[0]->mTrackInfo
+   ? aSamples->mSamples[0]->mTrackInfo->GetID()
+   : 0);
+
+// Test with the 80 chars limit
+return (aDecoder.HasPromise() || aDecoder.mTimeThreshold.isSome()) &&
+   !aDecoder.HasPendingDrain() && !aDecoder.HasFatalError() &&
+   !aDecoder.mDemuxRequest.Exists() && !aDecoder.mOutput.Length() &&
+   !aDecoder.HasInternalSeekPending() && !aDecoder.mDecodeRequest.Exists();
+
+template
+void
+foo();
+
+#define MACRO(V)   \
+  V(Rt2) /* one more char */   \
+  V(Rs)  /* than here  */  \
+/* comment 3 */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296485 - Driver: Update devtoolset usage for RHEL

2017-02-28 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue Feb 28 10:46:19 2017
New Revision: 296485

URL: http://llvm.org/viewvc/llvm-project?rev=296485=rev
Log:
Driver: Update devtoolset usage for RHEL

- remove path to dts-1.x (corresponds to gcc 4.7)
- add path to dts-6 (corresponds to 6.x)

Patch By: Maria Gottschalk

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=296485=296484=296485=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Feb 28 10:46:19 2017
@@ -1438,11 +1438,10 @@ void Generic_GCC::GCCInstallationDetecto
 // Then look for distribution supplied gcc installations.
 if (D.SysRoot.empty()) {
   // Look for RHEL devtoolsets.
+  Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
   Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
   Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
   Prefixes.push_back("/opt/rh/devtoolset-2/root/usr");
-  Prefixes.push_back("/opt/rh/devtoolset-1.1/root/usr");
-  Prefixes.push_back("/opt/rh/devtoolset-1.0/root/usr");
   // And finally in /usr.
   Prefixes.push_back("/usr");
 }


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


r296490 - Migrate all of aarch64-linux-gnu to \01_mcount instead of just when passing along gnueabi as this matches both gcc and what the kernel expects.

2017-02-28 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Feb 28 11:22:05 2017
New Revision: 296490

URL: http://llvm.org/viewvc/llvm-project?rev=296490=rev
Log:
Migrate all of aarch64-linux-gnu to \01_mcount instead of just when passing 
along gnueabi as this matches both gcc and what the kernel expects.

More of PR27311

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Frontend/gnu-mcount.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=296490=296489=296490=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb 28 11:22:05 2017
@@ -5985,8 +5985,9 @@ public:
 // AArch64 targets default to using the ARM C++ ABI.
 TheCXXABI.set(TargetCXXABI::GenericAArch64);
 
-if (Triple.getOS() == llvm::Triple::Linux ||
-Triple.getOS() == llvm::Triple::UnknownOS)
+if (Triple.getOS() == llvm::Triple::Linux)
+  this->MCountName = "\01_mcount";
+else if (Triple.getOS() == llvm::Triple::UnknownOS)
   this->MCountName = Opts.EABIVersion == "gnu" ? "\01_mcount" : "mcount";
   }
 

Modified: cfe/trunk/test/Frontend/gnu-mcount.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/gnu-mcount.c?rev=296490=296489=296490=diff
==
--- cfe/trunk/test/Frontend/gnu-mcount.c (original)
+++ cfe/trunk/test/Frontend/gnu-mcount.c Tue Feb 28 11:22:05 2017
@@ -6,11 +6,11 @@
 // RUN: %clang -target aarch64-unknown-none-eabi -pg -meabi gnu -S -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM64-EABI-MEABI-GNU
 // RUN: %clang -target armv7-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
 // RUN: %clang -target armv7-unknown-linux-gnueabi -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-MEABI-GNU
-// RUN: %clang -target aarch64-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI
+// RUN: %clang -target aarch64-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI-LINUX
 // RUN: %clang -target aarch64-unknown-linux-gnueabi -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM64-EABI-MEABI-GNU
 // RUN: %clang -target armv7-unknown-linux-gnueabihf -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
 // RUN: %clang -target armv7-unknown-linux-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-MEABI-GNU
-// RUN: %clang -target aarch64-unknown-linux-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI
+// RUN: %clang -target aarch64-unknown-linux-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI-LINUX
 // RUN: %clang -target aarch64-unknown-linux-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM64-EABI-MEABI-GNU
 // RUN: %clang -target armv7-unknown-freebsd-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI-FREEBSD
 // RUN: %clang -target armv7-unknown-freebsd-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-FREEBSD
@@ -53,6 +53,7 @@ int f() {
 // CHECK-ARM64-EABI: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="mcount"{{.*}} }
 // CHECK-ARM64-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01_mcount"{{.*}} }
 // CHECK-ARM64-EABI-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-EABI-LINUX: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01_mcount"{{.*}} }
 // CHECK-ARM-EABI-FREEBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="__mcount"{{.*}} }
 // CHECK-ARM-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
 // CHECK-ARM64-EABI-FREEBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"=".mcount"{{.*}} }


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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: djasper.
hans added a comment.

>>> My only nit is that I'd prefer "clang-format" instead of "ClangFormat".
>>> 
>>> Manuel: the menu options under Tools currently say "Clang Format 
>>> {Selection,Document}". What do you think about using "clang-format" here 
>>> instead? That is the name of the tool after all, and I think it also works 
>>> nicely as a verb.
>>> 
>>> I realize the actual extension is called ClangFormat, but maybe there were 
>>> reasons for that, or we have to live with it?
>> 
>> I would also like clang-format in there rather than ClangFormat. One thing 
>> to validate is whether this change would mean people would lose their 
>> changes to the defaults in the configuration panel. I'll run some tests and 
>> see if this is indeed the case. Maybe there's a way to keep the internal 
>> name the same for config purposes, but change the displayed name instead. 
>> Will get back to you.
> 
> Okay, I looked into it, and the good news is that changing the name of the 
> category from ClangFormat to clang-format doesn't reset the previously saved 
> changes made in the options menu. I also changed the menu item names. Here's 
> what both would look like:
> 
> F3119242: pasted_file 
> 
> F3119244: pasted_file 
> 
> Now having said that, I'm not sure if this is the best change because of a 
> few things:
> 
> 1. The extension's name itself is ClangFormat, which was recently added to 
> the Visual Studio market place here: 
> https://marketplace.visualstudio.com/items?itemName=HansWennborg.ClangFormat 
> . Consequently, the extension appears with this name in the Visual Studio 
> extensions dialog: F3119249: pasted_file . 
> I don't think it would be easy to change this. You cannot really take down an 
> extension page on the marketplace once it's there; you'd have to document 
> that it has been deprecated and provide a link to a new page. When searching 
> for it in the Extensions dialog in VS, though, both the old and new extension 
> would show up.
> 2. Although the name of the executable is indeed "clang-format", the 
> documentation here  uses the 
> name ClangFormat: F3119251: pasted_file 
> 
>   So I leave it up to you whether you really want this change or not. We can 
> also decide later rather than fold it into this change.

Personally I think we should refer to the tool and the action of formatting as 
"clang-format" as much as possible. It's unfortunate we can't rename the 
extension, but maybe that slight inconsistency isn't the end of the world.

Manuel, Daniel: I'd like to hear your opinions here.


https://reviews.llvm.org/D29221



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


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added subscribers: a.sidorin, NoQ.
NoQ added a comment.

I think this is great. We've been hearing a lot of complaints on the mailing 
lists recently about that problem.

Did you check that scan-build properly de-duplicates cross-file reports that 
originate from different clang runs but point to the same header? With your 
approach i think it should work out of the box, but i'd rather be sure.

> It's not as immediately clear this is a multi-file output.

I'm still to have a closer look at the actual code, sorry for the delays.

I'm not having problems with that, i think. If you want to fix that, maybe a 
list of files at the header, with links to the beginning of each file, would be 
enough. Or maybe modify arrows between diagnostic pieces to highlight cases 
when they cross file boundaries: `<- 5. Calling foo() -> (into file foo.c)`.


https://reviews.llvm.org/D30406



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


[PATCH] D30465: [mips] Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64

2017-02-28 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.

Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64


Repository:
  rL LLVM

https://reviews.llvm.org/D30465

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8766,6 +8766,8 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // OPENBSD:#define __ELF__ 1
 // OPENBSD:#define __INT16_TYPE__ short
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7577,7 +7577,11 @@
 
   void setN64ABITypes() {
 setN32N64ABITypes();
-Int64Type = SignedLong;
+if (getTriple().getOS() == llvm::Triple::OpenBSD) {
+  Int64Type = SignedLongLong;
+} else {
+  Int64Type = SignedLong;
+}
 IntMaxType = Int64Type;
 LongWidth = LongAlign = 64;
 PointerWidth = PointerAlign = 64;


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8766,6 +8766,8 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // OPENBSD:#define __ELF__ 1
 // OPENBSD:#define __INT16_TYPE__ short
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7577,7 +7577,11 @@
 
   void setN64ABITypes() {
 setN32N64ABITypes();
-Int64Type = SignedLong;
+if (getTriple().getOS() == llvm::Triple::OpenBSD) {
+  Int64Type = SignedLongLong;
+} else {
+  Int64Type = SignedLong;
+}
 IntMaxType = Int64Type;
 LongWidth = LongAlign = 64;
 PointerWidth = PointerAlign = 64;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24933: Enable configuration files in clang

2017-02-28 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Hello,
I work on WebAssembly toolchains (including emscripten, which is more or less 
the "cross-compiler SDK" use case). There's a lot of history in this review and 
I haven't looked at the details yet, but does the current summary text reflect 
the current proposal and/or content of the review?
Thanks!


https://reviews.llvm.org/D24933



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D27054



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:3818-3819
+  if (ScopeName && (ScopeName->getName() == "gnu" ||
+(ScopeName->getName() == "clang" &&
+ AttrName->isStr("external_source_symbol"
 // GNU-scoped attributes have some special cases to handle GNU-specific

aaron.ballman wrote:
> aaron.ballman wrote:
> > I don't really like hard-coding a list of attributes like this. I think you 
> > should handle clang-namespaced attributes with a separate helper function.
> This still isn't quite what I was looking for -- the helper function I was 
> talking about was a replacement for `ParseGNUAttributeArgs()`. I'm sorry if I 
> was unclear.
> 
> I think we should have a `ParseClangAttributeArgs()` that handles your custom 
> parsing; it can then call through to `ParseAttributeArgsCommon()` for common 
> argument handling in the same way `ParseGNUAttributeArgs()` does. So the 
> predicate would be `else if (ScopeName && ScopeName->getName() == "clang")`.
I see, I added `ParseClangAttributeArgs` in the updated patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 90042.
arphaman marked 2 inline comments as done.
arphaman added a comment.

Use `ParseClangAttributeArgs` and add a string to an assert.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Misc/ast-dump-attr.cpp
  test/Parser/attr-external-source-symbol-cxx11.cpp
  test/Parser/attr-external-source-symbol.m
  test/Sema/attr-external-source-symbol.c

Index: test/Sema/attr-external-source-symbol.c
===
--- /dev/null
+++ test/Sema/attr-external-source-symbol.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+
+void twoClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module")));
+
+void fourClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void oneClause() __attribute__((external_source_symbol(generated_declaration)));
+
+void noArguments()
+__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
+
+void namedDeclsOnly() {
+  int (^block)(void) = ^ (void)
+__attribute__((external_source_symbol(language="Swift"))) { // expected-warning {{'external_source_symbol' attribute only applies to named declarations}}
+  return 1;
+  };
+}
Index: test/Parser/attr-external-source-symbol.m
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol.m
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void function() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+
+__attribute__((external_source_symbol(language="Swift", defined_in="module")))
+@interface I
+
+- (void)method __attribute__((external_source_symbol(defined_in= "module")));
+
+@end
+
+enum E {
+  CaseA __attribute__((external_source_symbol(generated_declaration))),
+  CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
+} __attribute__((external_source_symbol(language = "Swift")));
+
+void f2()
+__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f3()
+__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f4()
+__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
+void f5()
+__attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
+
+void f7()
+__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+void f8()
+__attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
+void f9()
+__attribute__((external_source_symbol(defined_in="module", language="Swift", defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
+
+void f10()
+__attribute__((external_source_symbol(generated_declaration, language="Swift", defined_in="foo", generated_declaration, generated_declaration, language="Swift"))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void f11()
+__attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
+
+void f12()
+__attribute__((external_source_symbol(language="C Sharp", defined_in="file:Hello world with spaces. cs")));
+
+void f13()
+__attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
+
+void f14()
+__attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+
+void f15()

[PATCH] D30326: [MS-ABI] Allow #pragma section to choose for ZI data

2017-02-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I'm surprised this is behind a flag. This pragma attempts to be compatible with 
cl.exe. Does cl.exe do this by default? If so, we should do it by default. If 
not, why add this as an incompatible thing to an MS extension instead of keying 
it off some attribute that works in non-MS mode too?


https://reviews.llvm.org/D30326



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-02-28 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

Ping


https://reviews.llvm.org/D30268



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


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1414
+
+} // end anonymous namespace
+

vsk wrote:
> I don't see the need for two GenericInfo types (although it's plausible it'll 
> make sense with your upcoming changes!). I had in mind a single 'enum 
> BlockCaptureOperationType' with 8 entries, and a 'struct 
> BlockCaptureOperation'.
Agreed, fixed.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 90033.
arphaman marked 3 inline comments as done.
arphaman added a comment.

The updated patch uses just one enum and simplifies the capture search loops.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345

Files:
  lib/CodeGen/CGBlocks.cpp

Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1373,6 +1373,105 @@
   return fn;
 }
 
+namespace {
+
+/// Represents a type of copy/destroy operation that should be performed for an
+/// entity that's captured by a block.
+enum class BlockCaptureEntityType {
+  CXXRecord, // Copy or destroy
+  ARCWeak,
+  ARCStrong,
+  BlockObject, // Assign or release
+  None
+};
+
+/// Represents an entity captured by a block that requires custom operations
+/// to copy/release this entity.
+struct BlockCaptureManagedEntity {
+  BlockCaptureEntityType Type;
+  BlockFieldFlags Flags;
+  const BlockDecl::Capture 
+  const CGBlockInfo::Capture 
+
+  BlockCaptureManagedEntity(BlockCaptureEntityType Type, BlockFieldFlags Flags,
+const BlockDecl::Capture ,
+const CGBlockInfo::Capture )
+  : Type(Type), Flags(Flags), CI(CI), Capture(Capture) {}
+};
+
+} // end anonymous namespace
+
+static std::pair
+computeCopyInfoForBlockCapture(const BlockDecl::Capture , QualType Type,
+   const LangOptions ) {
+  if (CI.getCopyExpr()) {
+assert(!CI.isByRef());
+// don't bother computing flags
+return std::make_pair(BlockCaptureEntityType::CXXRecord, BlockFieldFlags());
+  }
+  BlockFieldFlags Flags;
+  if (CI.isByRef()) {
+Flags = BLOCK_FIELD_IS_BYREF;
+if (Type.isObjCGCWeak())
+  Flags |= BLOCK_FIELD_IS_WEAK;
+return std::make_pair(BlockCaptureEntityType::BlockObject, Flags);
+  }
+  if (!Type->isObjCRetainableType())
+// For all other types, the memcpy is fine.
+return std::make_pair(BlockCaptureEntityType::None, Flags);
+
+  Flags = BLOCK_FIELD_IS_OBJECT;
+  bool isBlockPointer = Type->isBlockPointerType();
+  if (isBlockPointer)
+Flags = BLOCK_FIELD_IS_BLOCK;
+
+  // Special rules for ARC captures:
+  Qualifiers QS = Type.getQualifiers();
+
+  // We need to register __weak direct captures with the runtime.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Weak)
+return std::make_pair(BlockCaptureEntityType::ARCWeak, Flags);
+
+  // We need to retain the copied value for __strong direct captures.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Strong) {
+// If it's a block pointer, we have to copy the block and
+// assign that to the destination pointer, so we might as
+// well use _Block_object_assign.  Otherwise we can avoid that.
+return std::make_pair(!isBlockPointer ? BlockCaptureEntityType::ARCStrong
+  : BlockCaptureEntityType::BlockObject,
+  Flags);
+  }
+
+  // Non-ARC captures of retainable pointers are strong and
+  // therefore require a call to _Block_object_assign.
+  if (!QS.getObjCLifetime() && !LangOpts.ObjCAutoRefCount)
+return std::make_pair(BlockCaptureEntityType::BlockObject, Flags);
+
+  // Otherwise the memcpy is fine.
+  return std::make_pair(BlockCaptureEntityType::None, Flags);
+}
+
+/// Find the set of block captures that need to be explicitly copied or destroy.
+static void findBlockCapturedManagedEntities(
+const CGBlockInfo , const LangOptions ,
+SmallVectorImpl ,
+llvm::function_ref(
+const BlockDecl::Capture &, QualType, const LangOptions &)>
+Predicate) {
+  for (const auto  : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+QualType Type = Variable->getType();
+
+const CGBlockInfo::Capture  = BlockInfo.getCapture(Variable);
+if (Capture.isConstant())
+  continue;
+
+auto Info = Predicate(CI, Type, LangOpts);
+if (Info.first != BlockCaptureEntityType::None)
+  ManagedCaptures.emplace_back(Info.first, Info.second, CI, Capture);
+  }
+}
+
 /// Generate the copy-helper function for a block closure object:
 ///   static void block_copy_helper(block_t *dst, block_t *src);
 /// The runtime will have previously initialized 'dst' by doing a
@@ -1431,78 +1530,28 @@
   dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
   dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
 
-  const BlockDecl *blockDecl = blockInfo.getBlockDecl();
-
-  for (const auto  : blockDecl->captures()) {
-const VarDecl *variable = CI.getVariable();
-QualType type = variable->getType();
-
-const CGBlockInfo::Capture  = blockInfo.getCapture(variable);
-if (capture.isConstant()) continue;
-
-const Expr *copyExpr = CI.getCopyExpr();
-BlockFieldFlags flags;
+  SmallVector 

[PATCH] D30412: [clang-tidy] Fix a false positive on modernize-use-nullptr check.

2017-02-28 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296479: [clang-tidy] Fix a false positive on 
modernize-use-nullptr check. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D30412?vs=89894=90032#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30412

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,8 +190,10 @@
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -228,3 +228,19 @@
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,8 +190,10 @@
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -228,3 +228,19 @@
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r296479 - [clang-tidy] Fix a false positive on modernize-use-nullptr check.

2017-02-28 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Feb 28 09:29:52 2017
New Revision: 296479

URL: http://llvm.org/viewvc/llvm-project?rev=296479=rev
Log:
[clang-tidy] Fix a false positive on modernize-use-nullptr check.

Summary:
The false positive happens on two neighbour CXXDefaultArgExpr AST nodes.
like below:

```
CXXFunctionalCastExpr 0x85c9670  'struct ZZ' functional cast to 
struct ZZ 
 `-CXXConstructExpr 0x85c9518  'struct ZZ' 'void (uint64, const 
uint64 *)'
   |-CallExpr 0x85a0a90  'uint64':'unsigned long long'
   | |-ImplicitCastExpr 0x85a0a78  'uint64 (*)(uint64)' 

   | | `-DeclRefExpr 0x85a09f0  'uint64 (uint64)' lvalue Function 
0x85a06a0 'Hash' 'uint64 (uint64)'
   | `-CXXDefaultArgExpr 0x85a0ac8 <> 'uint64':'unsigned long 
long'
   `-CXXDefaultArgExpr 0x85c94f8 <> 'const uint64 *'
```

For each particular CXXDefaultArgExpr node, we need to reset
FirstSubExpr, otherwise FirstSubExpr will refer to an incorrect expr.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=296479=296478=296479=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Tue Feb 28 
09:29:52 2017
@@ -190,8 +190,10 @@ public:
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=296479=296478=296479=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Tue Feb 
28 09:29:52 2017
@@ -228,3 +228,19 @@ struct D {
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}


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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-28 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki marked an inline comment as done.
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:211
   // Generate a report for this bug.
-  StringRef Desc =
-  describeUninitializedArgumentInCall(Call, IsFirstArgument);
+  std::string Desc =
+  describeUninitializedArgumentInCall(Call, ArgumentNumber);

zaks.anna wrote:
> Have you considered using  llvm::raw_svector_ostream here as well as passing 
> it an argument to describeUninitializedArgumentInCall? For example, see  
> MallocChecker.cpp.
I changed so describeUninitializedArgumentInCall() returns an llvm::Twine 
instead of std::string. hope you like it.



Repository:
  rL LLVM

https://reviews.llvm.org/D30341



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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

In https://reviews.llvm.org/D30111#688379, @sylvestre.ledru wrote:

> @krasimir is that ok with you?


Thank you for addressing my comments! The descriptions help to see what's 
supposed to happen.

Now another point with this test is that it tests that already Mozilla-valid 
source is not changed.
Maybe this is the right approach for a full style sanity test, I don't know.




Comment at: unittests/Format/check-coding-style-mozilla.cpp:77
+return mVar;
+  } // Tiny functions can be written in a single line.
+

Note that here the trailing comment will make a version of `TinyFunction` on a 
single line exceed the line limit.
If the comment is put before the definition of `TinyFunction`, it could really 
be made tiny, as in:
```
  // Tiny functions can be written in a single line.
  int TinyFunction() { return mVar; }
```


https://reviews.llvm.org/D30111



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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-28 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 90030.
danielmarjamaki added a comment.

minor updates. Use llvm::getOrdinalNumber(). Use llvm::Twine.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341

Files:
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/diagnostics/undef-value-param.m
  test/Analysis/malloc.m
  test/Analysis/misc-ps-region-store.m
  test/Analysis/misc-ps.m
  test/Analysis/null-deref-ps.c
  test/Analysis/nullptr.cpp
  test/Analysis/uninit-const.c
  test/Analysis/uninit-const.cpp
  test/Analysis/uninit-msg-expr.m
  test/Analysis/uninit-vals-ps.c
  test/Analysis/uninit-vals.cpp

Index: test/Analysis/uninit-vals.cpp
===
--- test/Analysis/uninit-vals.cpp
+++ test/Analysis/uninit-vals.cpp
@@ -27,7 +27,7 @@
   // case with undefined values, too.
   c1.b.a = c2->b.a;
 #else
-  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}}
+  c1.b.a = c2->b.a; // expected-warning{{1st function call argument is an uninitialized value}}
 #endif
 }
 }
Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -14,7 +14,7 @@
 
 int f1_b() {
   int x;
-  return bar(x)+1;  // expected-warning{{Function call argument is an uninitialized value}}
+  return bar(x)+1;  // expected-warning{{1st function call argument is an uninitialized value}}
 }
 
 int f2() {
Index: test/Analysis/uninit-msg-expr.m
===
--- test/Analysis/uninit-msg-expr.m
+++ test/Analysis/uninit-msg-expr.m
@@ -52,5 +52,5 @@
 void f3() {
   NSMutableArray *aArray = [NSArray array];
   NSString *aString;
-  [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}}
+  [aArray addObject:aString]; // expected-warning {{1st argument in message expression is an uninitialized value}}
 }
Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -66,8 +66,8 @@
   int  = t;
   int  = p;
   int  = s;  //expected-note {{'q' initialized here}}
-  doStuff6(q); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
+   //expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
 
 void doStuff6_3(int& q_, int *ptr_) {}
@@ -78,32 +78,32 @@
   int  = t;
   int  = p;
   int  = s;
-  doStuff6_3(q,ptr); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6_3(q,ptr); //expected-warning {{2nd function call argument is an uninitialized value}}
+   //expected-note@-1 {{2nd function call argument is an uninitialized value}}
 
 }
 
 void f6(void) {
   int k;   // expected-note {{'k' declared without an initial value}}
-  doStuff6(k); // expected-warning {{Function call argument is an uninitialized value}}
-   // expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(k); // expected-warning {{1st function call argument is an uninitialized value}}
+   // expected-note@-1 {{1st function call argument is an uninitialized value}}
 
 }
 
 
 
 void f5(void) {
   int t;
   int* tp = // expected-note {{'tp' initialized here}}
-  doStuff_uninit(tp);  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
+   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
 
 
 void f4(void) {
   int y;// expected-note {{'y' declared without an initial value}}
-  doStuff4(y);  // expected-warning {{Function call argument is an uninitialized value}}
-// expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff4(y);  // expected-warning {{1st function call argument is an uninitialized value}}
+// expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
 
 void f3(void) {
@@ -123,6 +123,6 @@
 
 void f_uninit(void) {
   int x;
-  doStuff_uninit();  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit();  

[PATCH] D30192: [Sema] Detecting more array index out of bounds

2017-02-28 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296477: [Sema] Detect more array index out of bounds when 
C++ overloaded operators are… (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D30192?vs=89183=90027#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30192

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/SemaCXX/array-bounds.cpp


Index: cfe/trunk/test/SemaCXX/array-bounds.cpp
===
--- cfe/trunk/test/SemaCXX/array-bounds.cpp
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is 
past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the 
array (which contains 10 elements)}}
+}
+
+int operator+(const struct P , const struct P );
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of 
the array (which contains 10 elements)}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -10609,6 +10609,12 @@
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const auto *OCE = cast(expr);
+for (const auto *Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }


Index: cfe/trunk/test/SemaCXX/array-bounds.cpp
===
--- cfe/trunk/test/SemaCXX/array-bounds.cpp
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@
 	int a[128]; // expected-note {{array 'a' declared here}}
 	a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}}
+}
+
+int operator+(const struct P , const struct P );
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -10609,6 +10609,12 @@
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const auto *OCE = cast(expr);
+for (const auto *Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296477 - [Sema] Detect more array index out of bounds when C++ overloaded operators are used

2017-02-28 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Tue Feb 28 08:53:50 2017
New Revision: 296477

URL: http://llvm.org/viewvc/llvm-project?rev=296477=rev
Log:
[Sema] Detect more array index out of bounds when C++ overloaded operators are 
used

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/array-bounds.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=296477=296476=296477=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Feb 28 08:53:50 2017
@@ -10609,6 +10609,12 @@ void Sema::CheckArrayAccess(const Expr *
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const auto *OCE = cast(expr);
+for (const auto *Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }

Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=296477=296476=296477=diff
==
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Tue Feb 28 08:53:50 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@ void test_rdar10916006(void)
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is 
past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the 
array (which contains 10 elements)}}
+}
+
+int operator+(const struct P , const struct P );
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of 
the array (which contains 10 elements)}}
+}


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


[PATCH] D30459: [libcxxabi] Clean up macro usage

2017-02-28 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.
Herald added a subscriber: mgorny.

Convention in libcxxabi is to use !defined(FOO) not !FOO.


https://reviews.llvm.org/D30459

Files:
  CMakeLists.txt
  include/__cxxabi_config.h
  include/cxxabi.h
  src/abort_message.cpp
  src/config.h
  src/cxa_default_handlers.cpp
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_personality.cpp

Index: src/cxa_personality.cpp
===
--- src/cxa_personality.cpp
+++ src/cxa_personality.cpp
@@ -317,7 +317,7 @@
 std::terminate();
 }
 
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 static const void* read_target2_value(const void* ptr)
 {
 uintptr_t offset = *reinterpret_cast(ptr);
@@ -328,7 +328,7 @@
 // deferred to the linker. For bare-metal they turn into absolute
 // relocations. For linux they turn into GOT-REL relocations."
 // https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00264.html
-#if LIBCXXABI_BAREMETAL
+#if defined(LIBCXXABI_BAREMETAL)
 return reinterpret_cast(reinterpret_cast(ptr) +
  offset);
 #else
@@ -358,7 +358,7 @@
 return reinterpret_cast(
 read_target2_value(ttypePtr));
 }
-#else // !LIBCXXABI_ARM_EHABI
+#else // !defined(LIBCXXABI_ARM_EHABI
 static
 const __shim_type_info*
 get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
@@ -394,7 +394,7 @@
 classInfo -= ttypeIndex;
 return (const __shim_type_info*)readEncodedPointer(, ttypeEncoding);
 }
-#endif // !LIBCXXABI_ARM_EHABI
+#endif // !defined(LIBCXXABI_ARM_EHABI)
 
 /*
 This is checking a thrown exception type, excpType, against a possibly empty
@@ -405,7 +405,7 @@
 the list will catch a excpType.  If any catchType in the list can catch an
 excpType, then this exception spec does not catch the excpType.
 */
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 static
 bool
 exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
@@ -934,7 +934,7 @@
 Else a cleanup is not found: return _URC_CONTINUE_UNWIND
 */
 
-#if !LIBCXXABI_ARM_EHABI
+#if !defined(LIBCXXABI_ARM_EHABI)
 _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
 #ifdef __USING_SJLJ_EXCEPTIONS__
 __gxx_personality_sj0
@@ -1194,7 +1194,7 @@
 u_handler = old_exception_header->unexpectedHandler;
 // If std::__unexpected(u_handler) rethrows the same exception,
 //   these values get overwritten by the rethrow.  So save them now:
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 ttypeIndex = (int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];
 lsda = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[2];
 #else
Index: src/cxa_exception.hpp
===
--- src/cxa_exception.hpp
+++ src/cxa_exception.hpp
@@ -27,7 +27,7 @@
 static const uint64_t get_vendor_and_language = 0xFF00; // mask for CLNGC++
 
 struct __cxa_exception {
-#if defined(__LP64__) || LIBCXXABI_ARM_EHABI
+#if defined(__LP64__) || defined(LIBCXXABI_ARM_EHABI)
 // This is a new field to support C++ 0x exception_ptr.
 // For binary compatibility it is at the start of this
 // struct which is prepended to the object thrown in
@@ -45,7 +45,7 @@
 
 int handlerCount;
 
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 __cxa_exception* nextPropagatingException;
 int propagationCount;
 #else
@@ -56,7 +56,7 @@
 void *adjustedPtr;
 #endif
 
-#if !defined(__LP64__) && !LIBCXXABI_ARM_EHABI
+#if !defined(__LP64__) && !defined(LIBCXXABI_ARM_EHABI)
 // This is a new field to support C++ 0x exception_ptr.
 // For binary compatibility it is placed where the compiler
 // previously adding padded to 64-bit align unwindHeader.
@@ -70,7 +70,7 @@
 // The layout of this structure MUST match the layout of __cxa_exception, with
 // primaryException instead of referenceCount.
 struct __cxa_dependent_exception {
-#if defined(__LP64__) || LIBCXXABI_ARM_EHABI
+#if defined(__LP64__) || defined(LIBCXXABI_ARM_EHABI)
 void* primaryException;
 #endif
 
@@ -83,7 +83,7 @@
 
 int handlerCount;
 
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 __cxa_exception* nextPropagatingException;
 int propagationCount;
 #else
@@ -94,7 +94,7 @@
 void *adjustedPtr;
 #endif
 
-#if !defined(__LP64__) && !LIBCXXABI_ARM_EHABI
+#if !defined(__LP64__) && !defined(LIBCXXABI_ARM_EHABI)
 void* primaryException;
 #endif
 
@@ -104,7 +104,7 @@
 struct __cxa_eh_globals {
 __cxa_exception *   caughtExceptions;
 unsigned intuncaughtExceptions;
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 __cxa_exception* propagatingExceptions;
 #endif
 };
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -237,16 +237,16 @@
 */
 _LIBCXXABI_FUNC_VIS
 void 

[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-28 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 90025.
rmaprath added a comment.

Fixed minor omission.


https://reviews.llvm.org/D29818

Files:
  src/chrono.cpp


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -11,6 +11,7 @@
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+#include "__threading_support"
 
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
@@ -50,7 +51,8 @@
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC) && \
+  !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #error "Monotonic clock not implemented"
 #endif
 #endif
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime())
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __libcpp_clock_monotonic())
+__throw_system_error(errno, "__libcpp_clock_monotonic() failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
 
 // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
 #if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -11,6 +11,7 @@
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+#include "__threading_support"
 
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
@@ -50,7 +51,8 @@
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC) && \
+  !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #error "Monotonic clock not implemented"
 #endif
 #endif
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime())
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != 

[clang-tools-extra] r296472 - Misspelled checker description (argument comment)

2017-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Feb 28 08:13:26 2017
New Revision: 296472

URL: http://llvm.org/viewvc/llvm-project?rev=296472=rev
Log:
Misspelled checker description (argument comment)

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: Eugene.Zelenko

Tags: #clang-tools-extra

Patch by Peter Szecsi!

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst?rev=296472=296471=296472=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst 
Tue Feb 28 08:13:26 2017
@@ -24,5 +24,6 @@ Options
 
 .. option:: StrictMode
 
-   When non-zero, the check will ignore leading and trailing underscores and
-   case when comparing parameter names.
+   When zero (default value), the check will ignore leading and trailing
+   underscores and case when comparing names -- otherwise they are taken into
+   account.


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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 90018.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Return const refs in getXXX.


https://reviews.llvm.org/D27054

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -26,6 +26,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
@@ -102,10 +103,10 @@
 
 // Checks that an llvm::Error instance contains a ReplacementError with expected
 // error code, expected new replacement, and expected existing replacement.
-static bool checkReplacementError(
-llvm::Error&& Error, replacement_error ExpectedErr,
-llvm::Optional ExpectedExisting,
-llvm::Optional ExpectedNew) {
+static bool checkReplacementError(llvm::Error &,
+  replacement_error ExpectedErr,
+  llvm::Optional ExpectedExisting,
+  llvm::Optional ExpectedNew) {
   if (!Error) {
 llvm::errs() << "Error is a success.";
 return false;
@@ -1089,5 +1090,187 @@
   EXPECT_TRUE(FileToReplaces.empty());
 }
 
+class AtomicChangeTest : public ::testing::Test {
+  protected:
+void setUp() {
+  DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
+  DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
+   .getLocWithOffset(20);
+  assert(DefaultLoc.isValid() && "Default location must be valid.");
+}
+
+RewriterTestContext Context;
+std::string DefaultCode = std::string(100, 'a');
+unsigned DefaultOffset = 20;
+SourceLocation DefaultLoc;
+FileID DefaultFileID;
+};
+
+TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
+  setUp();
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  llvm::Error Err =
+  Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = Change.insert(Context.Sources, DefaultLoc.getLocWithOffset(10), "bb",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Change.addHeader("a.h");
+  Change.removeHeader("b.h");
+  std::string YAMLString = Change.toYAMLString();
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_STREQ("---\n"
+   "Key: 'input.cpp:20'\n"
+   "FilePath:input.cpp\n"
+   "Error:   ''\n"
+   "InsertedHeaders: [ a.h ]\n"
+   "RemovedHeaders:  [ b.h ]\n"
+   "Replacements:\n" // Extra whitespace here!
+   "  - FilePath:input.cpp\n"
+   "Offset:  20\n"
+   "Length:  0\n"
+   "ReplacementText: aa\n"
+   "  - FilePath:input.cpp\n"
+   "Offset:  30\n"
+   "Length:  0\n"
+   "ReplacementText: bb\n"
+   "...\n",
+   YAMLString.c_str());
+}
+
+TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
+  setUp();
+  std::string YamlContent = "---\n"
+"Key: 'input.cpp:20'\n"
+"FilePath:input.cpp\n"
+"Error:   'ok'\n"
+"InsertedHeaders: [ a.h ]\n"
+"RemovedHeaders:  [ b.h ]\n"
+"Replacements:\n" // Extra whitespace here!
+"  - FilePath:input.cpp\n"
+"Offset:  20\n"
+"Length:  0\n"
+"ReplacementText: aa\n"
+"  - FilePath:input.cpp\n"
+"Offset:  30\n"
+"Length:  0\n"
+"ReplacementText: bb\n"
+"...\n";
+  AtomicChange ExpectedChange(Context.Sources, DefaultLoc);
+  llvm::Error Err = ExpectedChange.insert(Context.Sources, DefaultLoc, "aa",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = ExpectedChange.insert(Context.Sources, DefaultLoc.getLocWithOffset(10),
+"bb", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+
+  ExpectedChange.addHeader("a.h");
+  ExpectedChange.removeHeader("b.h");
+  

[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

alexshap wrote:
> ioeric wrote:
> > alexshap wrote:
> > > i assume i might be missing smth - why here and above (in getKey, 
> > > getFilePath, getError) std::string is returned by value  ?
> > Otherwise, users would need to worry about the lifetimes of the object. And 
> > these methods are not expected to be called intensively, so performance is 
> > not an issue.
> i see, thanks for the explanation, probably not particularly important
> i thought that if a caller wanted to get a copy / take ownership 
> it would just **accept** it by value, i.e. 
>auto path = change.getFilePath() /* assuming getFilePath returns const ref 
> */ 
> At the same time if for example we need to check the filepath (or just print 
> it),
> not copies would be required:
>llvm::errs() << change.getFilePath();
I don't really have strong opinion about this. Another thing I was considering 
is whether the returned value always has an associated object in the class. For 
example, `getError` might return `Error` plus some extra message so that the 
return string can't be a reference. But these interfaces look pretty stable for 
now. And your examples make sense. Changed them to const ref instead.


https://reviews.llvm.org/D27054



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


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2017-02-28 Thread Zoltán Gera via Phabricator via cfe-commits
gerazo marked an inline comment as done.
gerazo added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/DirtyScalarChecker.cpp:184
+Ty = Ctx.IntTy;
+  if (!Ty->isIntegerType() || Ctx.getIntWidth(Ty) <= TooNarrowForBoundCheck)
+return false;

a.sidorin wrote:
> Does the second check means that we exclude boolean and char values? I cannot 
> find any reason to do it for chars.
Yes, we exclude them.
Using lookup tables especially in cryptography sometimes involve reading a 
value from disk and than using this value immediately with a table lookup. This 
way, you use a dirty value directly in array indexing. Reading a byte and using 
it on a prepared 256 element table is common. As the read value gets bigger it 
is less performant and hence less common to do it.
I've found exactly 1 false positive in openssl without this exclusion.


https://reviews.llvm.org/D27753



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


Re: r296453 - [clang-format] Fix test failure caused by "rm" on some buildbots.

2017-02-28 Thread Nico Weber via cfe-commits
It's needed: when clang-format does leave temp files behind, they will
accumulate over builds and even if that's then fixed, the test would still
fail because of the temp files from prior builds. Thankfully, takuni fixed
this better in r296460.

On Feb 28, 2017 4:14 AM, "Haojian Wu via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: hokein
> Date: Tue Feb 28 03:03:07 2017
> New Revision: 296453
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296453=rev
> Log:
> [clang-format] Fix test failure caused by "rm" on some buildbots.
>
> The begining command "rm" will return 1 when there is not such file to
> delete.
>
> This patch is to remove it, as it's not needed for the test.
>
> Modified:
> cfe/trunk/test/Format/inplace.cpp
>
> Modified: cfe/trunk/test/Format/inplace.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/
> inplace.cpp?rev=296453=296452=296453=diff
> 
> ==
> --- cfe/trunk/test/Format/inplace.cpp (original)
> +++ cfe/trunk/test/Format/inplace.cpp Tue Feb 28 03:03:07 2017
> @@ -1,6 +1,5 @@
>  // Regression test to check that clang-format does not leave behind
> temporary
>  // files on Windows when doing in-place formatting.
> -// RUN: rm %T/inplace*
>  // RUN: cp %s %T/inplace.cpp
>  // RUN: clang-format -style=LLVM -i %T/inplace.cpp
>  // RUN: ls %T > %T/files.txt
>
>
> ___
> 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] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

ioeric wrote:
> alexshap wrote:
> > i assume i might be missing smth - why here and above (in getKey, 
> > getFilePath, getError) std::string is returned by value  ?
> Otherwise, users would need to worry about the lifetimes of the object. And 
> these methods are not expected to be called intensively, so performance is 
> not an issue.
i see, thanks for the explanation, probably not particularly important
i thought that if a caller wanted to get a copy / take ownership 
it would just **accept** it by value, i.e. 
   auto path = change.getFilePath() /* assuming getFilePath returns const ref 
*/ 
At the same time if for example we need to check the filepath (or just print 
it),
not copies would be required:
   llvm::errs() << change.getFilePath();


https://reviews.llvm.org/D27054



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


Re: r296460 - clang/test/Format/inplace.cpp: Avoid using wildcard.

2017-02-28 Thread Nico Weber via cfe-commits
Thanks! That's a good technique, I'll remember it for next time. I wonder
if %T should work like that...

On Feb 28, 2017 5:17 AM, "NAKAMURA Takumi via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Tue Feb 28 04:05:56 2017
> New Revision: 296460
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296460=rev
> Log:
> clang/test/Format/inplace.cpp: Avoid using wildcard.
>
> MSYS' tools don't do globbing.
>
> Modified:
> cfe/trunk/test/Format/inplace.cpp
>
> Modified: cfe/trunk/test/Format/inplace.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/
> inplace.cpp?rev=296460=296459=296460=diff
> 
> ==
> --- cfe/trunk/test/Format/inplace.cpp (original)
> +++ cfe/trunk/test/Format/inplace.cpp Tue Feb 28 04:05:56 2017
> @@ -1,9 +1,11 @@
>  // Regression test to check that clang-format does not leave behind
> temporary
>  // files on Windows when doing in-place formatting.
> -// RUN: cp %s %T/inplace.cpp
> -// RUN: clang-format -style=LLVM -i %T/inplace.cpp
> -// RUN: ls %T > %T/files.txt
> -// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
> +// RUN: rm -rf %t.dir
> +// RUN: mkdir %t.dir
> +// RUN: cp %s %t.dir/inplace.cpp
> +// RUN: clang-format -style=LLVM -i %t.dir/inplace.cpp
> +// RUN: ls %t.dir > %t.dir/files.txt
> +// RUN: FileCheck -strict-whitespace -input-file=%t.dir/files.txt %s
>
>  // CHECK-NOT: RF{{.*}}.TMP
>
>
>
> ___
> 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] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 90012.
ioeric marked an inline comment as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D27054

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -26,6 +26,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
@@ -102,10 +103,10 @@
 
 // Checks that an llvm::Error instance contains a ReplacementError with expected
 // error code, expected new replacement, and expected existing replacement.
-static bool checkReplacementError(
-llvm::Error&& Error, replacement_error ExpectedErr,
-llvm::Optional ExpectedExisting,
-llvm::Optional ExpectedNew) {
+static bool checkReplacementError(llvm::Error &,
+  replacement_error ExpectedErr,
+  llvm::Optional ExpectedExisting,
+  llvm::Optional ExpectedNew) {
   if (!Error) {
 llvm::errs() << "Error is a success.";
 return false;
@@ -1089,5 +1090,187 @@
   EXPECT_TRUE(FileToReplaces.empty());
 }
 
+class AtomicChangeTest : public ::testing::Test {
+  protected:
+void setUp() {
+  DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
+  DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
+   .getLocWithOffset(20);
+  assert(DefaultLoc.isValid() && "Default location must be valid.");
+}
+
+RewriterTestContext Context;
+std::string DefaultCode = std::string(100, 'a');
+unsigned DefaultOffset = 20;
+SourceLocation DefaultLoc;
+FileID DefaultFileID;
+};
+
+TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
+  setUp();
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  llvm::Error Err =
+  Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = Change.insert(Context.Sources, DefaultLoc.getLocWithOffset(10), "bb",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Change.addHeader("a.h");
+  Change.removeHeader("b.h");
+  std::string YAMLString = Change.toYAMLString();
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_STREQ("---\n"
+   "Key: 'input.cpp:20'\n"
+   "FilePath:input.cpp\n"
+   "Error:   ''\n"
+   "InsertedHeaders: [ a.h ]\n"
+   "RemovedHeaders:  [ b.h ]\n"
+   "Replacements:\n" // Extra whitespace here!
+   "  - FilePath:input.cpp\n"
+   "Offset:  20\n"
+   "Length:  0\n"
+   "ReplacementText: aa\n"
+   "  - FilePath:input.cpp\n"
+   "Offset:  30\n"
+   "Length:  0\n"
+   "ReplacementText: bb\n"
+   "...\n",
+   YAMLString.c_str());
+}
+
+TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
+  setUp();
+  std::string YamlContent = "---\n"
+"Key: 'input.cpp:20'\n"
+"FilePath:input.cpp\n"
+"Error:   'ok'\n"
+"InsertedHeaders: [ a.h ]\n"
+"RemovedHeaders:  [ b.h ]\n"
+"Replacements:\n" // Extra whitespace here!
+"  - FilePath:input.cpp\n"
+"Offset:  20\n"
+"Length:  0\n"
+"ReplacementText: aa\n"
+"  - FilePath:input.cpp\n"
+"Offset:  30\n"
+"Length:  0\n"
+"ReplacementText: bb\n"
+"...\n";
+  AtomicChange ExpectedChange(Context.Sources, DefaultLoc);
+  llvm::Error Err = ExpectedChange.insert(Context.Sources, DefaultLoc, "aa",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = ExpectedChange.insert(Context.Sources, DefaultLoc.getLocWithOffset(10),
+"bb", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+
+  ExpectedChange.addHeader("a.h");
+  ExpectedChange.removeHeader("b.h");
+  

[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric marked an inline comment as done.
ioeric added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

alexshap wrote:
> i assume i might be missing smth - why here and above (in getKey, 
> getFilePath, getError) std::string is returned by value  ?
Otherwise, users would need to worry about the lifetimes of the object. And 
these methods are not expected to be called intensively, so performance is not 
an issue.



Comment at: lib/Tooling/Refactoring/AtomicChange.cpp:35
+RemovedHeaders(E.getRemovedHeaders()) {
+std::copy(E.getReplacements().begin(), E.getReplacements().end(),
+  std::back_inserter(Replaces));

alexshap wrote:
> if i am not mistaken this can be done in the intialization list:
> Replaces(E.getReplacements().begin(), E.getReplacements().end())
>  
You are right. 


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: lib/Tooling/Refactoring/AtomicChange.cpp:35
+RemovedHeaders(E.getRemovedHeaders()) {
+std::copy(E.getReplacements().begin(), E.getReplacements().end(),
+  std::back_inserter(Replaces));

if i am not mistaken this can be done in the intialization list:
Replaces(E.getReplacements().begin(), E.getReplacements().end())
 


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

i assume i might be missing smth - why here and above (in getKey, getFilePath, 
getError) std::string is returned by value  ?


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::EditList for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 90011.
ioeric added a comment.

- Addressed review comments.
- Make key customize-able.
- Added replace() and insert() to replace current replacement interfaces.
- s/EditList/AtomicChange/


https://reviews.llvm.org/D27054

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -26,6 +26,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
@@ -102,10 +103,10 @@
 
 // Checks that an llvm::Error instance contains a ReplacementError with expected
 // error code, expected new replacement, and expected existing replacement.
-static bool checkReplacementError(
-llvm::Error&& Error, replacement_error ExpectedErr,
-llvm::Optional ExpectedExisting,
-llvm::Optional ExpectedNew) {
+static bool checkReplacementError(llvm::Error &,
+  replacement_error ExpectedErr,
+  llvm::Optional ExpectedExisting,
+  llvm::Optional ExpectedNew) {
   if (!Error) {
 llvm::errs() << "Error is a success.";
 return false;
@@ -1089,5 +1090,187 @@
   EXPECT_TRUE(FileToReplaces.empty());
 }
 
+class AtomicChangeTest : public ::testing::Test {
+  protected:
+void setUp() {
+  DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
+  DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
+   .getLocWithOffset(20);
+  assert(DefaultLoc.isValid() && "Default location must be valid.");
+}
+
+RewriterTestContext Context;
+std::string DefaultCode = std::string(100, 'a');
+unsigned DefaultOffset = 20;
+SourceLocation DefaultLoc;
+FileID DefaultFileID;
+};
+
+TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
+  setUp();
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  llvm::Error Err =
+  Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = Change.insert(Context.Sources, DefaultLoc.getLocWithOffset(10), "bb",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Change.addHeader("a.h");
+  Change.removeHeader("b.h");
+  std::string YAMLString = Change.toYAMLString();
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_STREQ("---\n"
+   "Key: 'input.cpp:20'\n"
+   "FilePath:input.cpp\n"
+   "Error:   ''\n"
+   "InsertedHeaders: [ a.h ]\n"
+   "RemovedHeaders:  [ b.h ]\n"
+   "Replacements:\n" // Extra whitespace here!
+   "  - FilePath:input.cpp\n"
+   "Offset:  20\n"
+   "Length:  0\n"
+   "ReplacementText: aa\n"
+   "  - FilePath:input.cpp\n"
+   "Offset:  30\n"
+   "Length:  0\n"
+   "ReplacementText: bb\n"
+   "...\n",
+   YAMLString.c_str());
+}
+
+TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
+  setUp();
+  std::string YamlContent = "---\n"
+"Key: 'input.cpp:20'\n"
+"FilePath:input.cpp\n"
+"Error:   'ok'\n"
+"InsertedHeaders: [ a.h ]\n"
+"RemovedHeaders:  [ b.h ]\n"
+"Replacements:\n" // Extra whitespace here!
+"  - FilePath:input.cpp\n"
+"Offset:  20\n"
+"Length:  0\n"
+"ReplacementText: aa\n"
+"  - FilePath:input.cpp\n"
+"Offset:  30\n"
+"Length:  0\n"
+"ReplacementText: bb\n"
+"...\n";
+  AtomicChange ExpectedChange(Context.Sources, DefaultLoc);
+  llvm::Error Err = ExpectedChange.insert(Context.Sources, DefaultLoc, "aa",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = ExpectedChange.insert(Context.Sources, DefaultLoc.getLocWithOffset(10),
+"bb", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+
+  

[PATCH] D27918: [analyzer] OStreamChecker

2017-02-28 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

Hello,
This checker was developed indeed with internal usage in mind. It should not 
necessary be added as a default checker. However I have run it on the 
boost-1.63.0 codebase, and there some some mildly interesting findings in 
examples and tests. There is also a true positive result in the core codebase.

As for the patter described above, it certainly is a possible use-case to set 
streams inside functions, but very few ( if any ) false positives was found 
thanks to that, and the main case for them was that I could not run the 
cross-TU analyzer (boosts bjam build system proved to be reluctant to work 
together with ClangSA).


https://reviews.llvm.org/D27918



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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@krasimir is that ok with you?


https://reviews.llvm.org/D30111



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


[PATCH] D29027: [Stack Protection] Add remark for reasons why Stack Protection has been applied

2017-02-28 Thread James Henderson via Phabricator via cfe-commits
jhenderson abandoned this revision.
jhenderson added a comment.

Abandoning. Due to changes made in https://reviews.llvm.org/D29023, there is no 
more need for this patch. The new method followed in that patch means that 
clang gets support for the new remarks via -Rpass=stack-protector.


https://reviews.llvm.org/D29027



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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296467: Blacklist arbitrary @\\w+ JSDoc tags from wrapping. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D30452?vs=8=90001#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30452

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -620,8 +620,8 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -620,8 +620,8 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296467 - Blacklist arbitrary @\\w+ JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Feb 28 05:08:24 2017
New Revision: 296467

URL: http://llvm.org/viewvc/llvm-project?rev=296467=rev
Log:
Blacklist arbitrary @\\w+ JSDoc tags from wrapping.

Summary:
Also limits the blacklisting to only apply when the tag is actually
followed by a parameter in curly braces.

/** @mods {long.type.must.not.wrap} */

vs

/** @const this is a long description that may wrap. */

Reviewers: djasper

Subscribers: klimek, krasimir, cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296467=296466=296467=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Feb 28 05:08:24 2017
@@ -620,8 +620,8 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=296467=296466=296467=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Feb 28 05:08:24 2017
@@ -1575,6 +1575,30 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {


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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked an inline comment as done.
mprobst added inline comments.



Comment at: lib/Format/Format.cpp:624
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]*[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;

djasper wrote:
> Thinking again, I think the first "*" should probably be a "+", but not sure.
Ah. I tried that initially, and fooled myself into thinking that didn't work. 
Done.


https://reviews.llvm.org/D30452



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


Re: r296408 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-28 Thread NAKAMURA Takumi via cfe-commits
Tweaked in r296460.

On Tue, Feb 28, 2017 at 10:28 AM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Nico,
>
> This commit broke test on one of our builders:
>
> Clang :: Format/inplace.cpp
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6151/steps/test/logs/stdio
>
> Please have a look.
>
> Thanks
>
>
> Galina
>
> On Mon, Feb 27, 2017 at 2:59 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: nico
> Date: Mon Feb 27 16:59:58 2017
> New Revision: 296408
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296408=rev
> Log:
> clang-format: Don't leave behind temp files in -i mode on Windows,
> PR26125, reloaded
>
> Second attempt after
> http://llvm.org/viewvc/llvm-project?rev=296166=rev
>
> In the first attempt, Code (the memory buffer backing the input file) was
> reset
> before overwriteChangedFiles() was called, but overwriteChangedFiles()
> still
> reads from it.  This time, load the whole input file into memory instead of
> using mmap when formatting in-place.
>
> (Since the test is identical to what was in the repo before chapuni's
> revert,
> svn diff doesn't show it – see the above link for the test.)
>
> https://reviews.llvm.org/D30385
>
> Added:
> cfe/trunk/test/Format/inplace.cpp
>   - copied unchanged from r296236, cfe/trunk/test/Format/inplace.cpp
> Modified:
> cfe/trunk/tools/clang-format/ClangFormat.cpp
>
> Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=296408=296407=296408=diff
>
> ==
> --- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
> +++ cfe/trunk/tools/clang-format/ClangFormat.cpp Mon Feb 27 16:59:58 2017
> @@ -236,8 +236,15 @@ static void outputReplacementsXML(const
>
>  // Returns true on error.
>  static bool format(StringRef FileName) {
> +  if (!OutputXML && Inplace && FileName == "-") {
> +errs() << "error: cannot use -i when reading from stdin.\n";
> +return false;
> +  }
> +  // On Windows, overwriting a file with an open file mapping doesn't
> work,
> +  // so read the whole file into memory when formatting in-place.
>ErrorOr CodeOrErr =
> -  MemoryBuffer::getFileOrSTDIN(FileName);
> +  !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
> +  MemoryBuffer::getFileOrSTDIN(FileName);
>if (std::error_code EC = CodeOrErr.getError()) {
>  errs() << EC.message() << "\n";
>  return true;
> @@ -297,9 +304,7 @@ static bool format(StringRef FileName) {
>  Rewriter Rewrite(Sources, LangOptions());
>  tooling::applyAllReplacements(Replaces, Rewrite);
>  if (Inplace) {
> -  if (FileName == "-")
> -errs() << "error: cannot use -i when reading from stdin.\n";
> -  else if (Rewrite.overwriteChangedFiles())
> +  if (Rewrite.overwriteChangedFiles())
>  return true;
>  } else {
>if (Cursor.getNumOccurrences() != 0)
>
>
> ___
> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Format/Format.cpp:624
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]*[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;

Thinking again, I think the first "*" should probably be a "+", but not sure.


https://reviews.llvm.org/D30452



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


  1   2   >