r292052 - [code-completion] Fix crash when trying to do postfix completion of instance member inside a static function.

2017-01-14 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Sun Jan 15 00:11:04 2017
New Revision: 292052

URL: http://llvm.org/viewvc/llvm-project?rev=292052=rev
Log:
[code-completion] Fix crash when trying to do postfix completion of instance 
member inside a static function.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/CodeCompletion/member-access.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=292052=292051=292052=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Jan 15 00:11:04 2017
@@ -1652,9 +1652,10 @@ Parser::ParsePostfixExpressionSuffix(Exp
 
   if (Tok.is(tok::code_completion)) {
 // Code completion for a member access expression.
-Actions.CodeCompleteMemberReferenceExpr(
-getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow,
-ExprStatementTokLoc == LHS.get()->getLocStart());
+if (Expr *Base = LHS.get())
+  Actions.CodeCompleteMemberReferenceExpr(
+  getCurScope(), Base, OpLoc, OpKind == tok::arrow,
+  ExprStatementTokLoc == Base->getLocStart());
 
 cutOffParsing();
 return ExprError();

Modified: cfe/trunk/test/CodeCompletion/member-access.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=292052=292051=292052=diff
==
--- cfe/trunk/test/CodeCompletion/member-access.cpp (original)
+++ cfe/trunk/test/CodeCompletion/member-access.cpp Sun Jan 15 00:11:04 2017
@@ -27,6 +27,16 @@ public:
 
 void test(const Proxy ) {
   p->
+}
+
+struct Test1 {
+  Base1 b;
+
+  static void sfunc() {
+b. // expected-error {{invalid use of member 'b' in static member 
function}}
+  }
+};
+
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: Base1 : Base1::
   // CHECK-CC1: member1 : [#int#][#Base1::#]member1
@@ -39,4 +49,6 @@ void test(const Proxy ) {
   // CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>)
   // CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>)
   // CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>)
-  
+
+// Make sure this doesn't crash
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:7 %s -verify


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


[PATCH] D28510: Reinstate CWG1607 restrictions on lambdas appearing inside certain constant-expressions

2017-01-14 Thread Faisal Vali via Phabricator via cfe-commits
faisalv updated this revision to Diff 84476.
faisalv added a comment.

The updated patch adds two additional enumerators to 
ExpressionEvaluationContext: ConstantEvaluatedInTemplateArgument and 
ConstantEvaluatedInFunctionSignature and sets them appropriately (as opposed to 
our previous approach of setting the IsLambdaExpressionForbidden flag in those 
locations).

When popping off the EvaluationContext, instead of checking the flag, we now 
check the EvaluationContext directly to determine if the Lambda Expression is 
valid.


Repository:
  rL LLVM

https://reviews.llvm.org/D28510

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -157,6 +157,38 @@
 
 } // end ns1_simple_lambda
 
+namespace test_forbidden_lambda_expressions {
+
+template struct X { }; //expected-error{{lambda expression may not appear}}
+X<[]{return 10; }()> x; //expected-error{{lambda expression may not appear}}
+void f(int arr[([] { return 5; }())]); //expected-error{{lambda expression may not appear}}
+// FIXME: Should this be ok?
+auto L = [](int arr[([] { return 5; }())]) { }; // OK
+
+// These should be allowed:
+struct A {
+  int : ([] { return 5; }());
+};
+
+int arr[([] { return 5; }())];
+enum { E = [] { return 5; }() };
+static_assert([]{return 5; }() == 5);
+int *ip = new int[([] { return 5; })()];
+
+int test_case(int x) {
+  switch(x) {
+case [] { return 5; }(): //OK
+  break;
+case [] (auto a) { return a; }(6): //expected-note{{previous}}
+  break;
+case 6:  //expected-error{{duplicate}}
+  break;
+  }
+  return x;
+}
+
+} // end ns forbidden_lambda_expressions
+
 namespace ns1_unimplemented {
 namespace ns1_captures {
 constexpr auto f(int i) {
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3781,7 +3781,8 @@
   case TemplateArgument::Expression: {
 // Template argument expressions are constant expressions.
 EnterExpressionEvaluationContext Unevaluated(
-getSema(), Uneval ? Sema::Unevaluated : Sema::ConstantEvaluated);
+getSema(),
+Uneval ? Sema::Unevaluated : Sema::ConstantEvaluatedInTemplateArgument);
 
 Expr *InputExpr = Input.getSourceExpression();
 if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2236,8 +2236,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
-EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
-   Sema::ConstantEvaluated);
+EnterExpressionEvaluationContext ConstantEvaluated(
+SemaRef, Sema::ConstantEvaluatedInTemplateArgument);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -3520,8 +3520,8 @@
   for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
 TemplateArgLists.addOuterTemplateArguments(None);
 
-  EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
- Sema::ConstantEvaluated);
+  EnterExpressionEvaluationContext ConstantEvaluated(
+  SemaRef, Sema::ConstantEvaluatedInTemplateArgument);
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 }
 
@@ -5152,8 +5152,8 @@
 
   // The initialization of the parameter from the argument is
   // a constant-evaluated context.
-  EnterExpressionEvaluationContext ConstantEvaluated(*this,
- Sema::ConstantEvaluated);
+  EnterExpressionEvaluationContext ConstantEvaluated(
+  *this, Sema::ConstantEvaluatedInTemplateArgument);
 
   if (getLangOpts().CPlusPlus1z) {
 // C++1z [temp.arg.nontype]p1:
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1591,11 +1591,12 @@
 //   evaluation of e, following the rules of the abstract machine, would
 

[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2017-01-14 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: cfe/trunk/CMakeLists.txt:531
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+add_dependencies(clang-bootstrap-deps lld)
+  elseif(LLVM_BINUTILS_INCDIR)

I come back to this a bit late, sorry, but I'm not sure I understand why this 
dependency on the bootstrap happens only when LTO is used?



Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[libcxx] r292038 - Work around python3 bytes vs str in libc++ test config

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 18:06:02 2017
New Revision: 292038

URL: http://llvm.org/viewvc/llvm-project?rev=292038=rev
Log:
Work around python3 bytes vs str in libc++ test config

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

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=292038=292037=292038=diff
==
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Sat Jan 14 18:06:02 2017
@@ -287,7 +287,8 @@ class CXXCompiler(object):
 # TODO(EricWF): Are there other flags we need to worry about?
 if '-v' in cmd:
 cmd.remove('-v')
-out, err, rc = lit.util.executeCommand(cmd, input='#error\n')
+out, err, rc = lit.util.executeCommand(
+cmd, input=lit.util.to_bytes('#error\n'))
 
 assert rc != 0
 if flag in err:


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


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

2017-01-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Note that my earlier approach of just disabling -Wthread-safety for those few 
functions might be easier.  This should not cause any trouble for any platforms 
which don't use annotated pthread functions.


https://reviews.llvm.org/D28520



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


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

So the problem I got is that every time I want to check if there is already a 
feature in clang-tidy/static-analyzer that solves my issue, I either have to 
deal with static-analyzer command line, which is horrible, or I have to modify 
and recompile the source code.

The case I was looking at is a check to find

  int *p = g():
  *p = 42;
  if(!p) {g(): }

I wanted to find null checks after the pointer was dereferenced, and indeed I 
found it in deadcode or unreachable code analysis in static-analyzer.

I am not sure what you are afraid of - as long as this feature is not turned by 
default everything should be fine. If someone would turn it on then as long as 
he doesn't see any false positives then everything is still fine, and it can 
always disable flag.

AFAIK there is a way to specify in cl::opt that the option is hidden, which 
could probably solve your concerns?


https://reviews.llvm.org/D28729



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


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

2017-01-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In https://reviews.llvm.org/D28520#646564, @EricWF wrote:

> This breaks on all platforms were pthread_mutex_t isn't annotated.


Hm, sorry about that, I didn't realize.  I'm building it on Ubuntu now to see 
what breaks, and how to fix it.


https://reviews.llvm.org/D28520



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


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

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

This breaks on all platforms were pthread_mutex_t isn't annotated.


https://reviews.llvm.org/D28520



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


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

2017-01-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim updated this revision to Diff 84465.
dim added a comment.

Rebase after recent changes.


https://reviews.llvm.org/D28520

Files:
  include/__threading_support


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -40,14 +40,22 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__clang__) && __has_attribute(acquire_capability)
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#else
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
-typedef pthread_mutex_t __libcpp_mutex_t;
+typedef pthread_mutex_t __libcpp_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
-typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+typedef pthread_mutex_t __libcpp_recursive_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
@@ -69,10 +77,12 @@
 #define _LIBCPP_TLS_DESTRUCTOR_CC
 #else
 // Mutex
-typedef SRWLOCK __libcpp_mutex_t;
+typedef SRWLOCK __libcpp_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 #define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
 
-typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 
 // Condition Variable
 typedef CONDITION_VARIABLE __libcpp_condvar_t;
@@ -99,25 +109,31 @@
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(acquire_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(try_acquire_capability(true, *__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(release_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(acquire_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(try_acquire_capability(true, *__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(release_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
@@ -130,11 +146,13 @@
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(requires_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts);
+   timespec *__ts)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(requires_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -40,14 +40,22 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__clang__) && __has_attribute(acquire_capability)
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#else
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
-typedef pthread_mutex_t __libcpp_mutex_t;
+typedef pthread_mutex_t __libcpp_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
-typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+typedef pthread_mutex_t __libcpp_recursive_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
@@ -69,10 +77,12 @@
 #define _LIBCPP_TLS_DESTRUCTOR_CC
 #else
 // Mutex
-typedef SRWLOCK 

[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D28729#646555, @aaron.ballman wrote:

> In https://reviews.llvm.org/D28729#646548, @alexfh wrote:
>
> > As discussed with the Static Analyzer maintainers, alpha checkers are 
> > completely unsupported and are suitable for very early testing only. We had 
> > problems with them routinely, that's why I disabled alpha checkers in 
> > clang-tidy completely. I don't think there should be a user-visible way to 
> > enable them. Developers can locally change the code to get access to alpha 
> > checkers, but released binaries shouldn't provide this possibility.
>
>
> That's good to know -- should it be documented a bit more explicitly,


Yes, a comment to that effect near the relevant code wouldn't hurt. Or do you 
have other suggestions?

>   or perhaps the alpha checks should be removed until they're fit for public 
> consumption? Some of those alpha checks have been in the product for a long 
> time, and if they're so unstable that we cannot expose them in a 
> user-friendly fashion, perhaps they don't belong yet?

As discussed with SA folks, alpha checkers are convenient for them to develop 
new checks, but shouldn't be exposed to users. Some of these experimental 
checkers might deserve being moved out of alpha or removed completely, but that 
should be reported to and discussed with the SA maintainers.


https://reviews.llvm.org/D28729



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


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

2017-01-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: test/clang-tidy/modernize-raw-string-literal.cpp:94
 
+char const *const Concatenated("\"foo\""
+   "\"bar\"");

Does this test fail without the patch? Also, should there be a test covering 
the case where no replacement is made (and the current code issues a warning)?


https://reviews.llvm.org/D28667



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


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

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

In https://reviews.llvm.org/D28729#646548, @alexfh wrote:

> As discussed with the Static Analyzer maintainers, alpha checkers are 
> completely unsupported and are suitable for very early testing only. We had 
> problems with them routinely, that's why I disabled alpha checkers in 
> clang-tidy completely. I don't think there should be a user-visible way to 
> enable them. Developers can locally change the code to get access to alpha 
> checkers, but released binaries shouldn't provide this possibility.


That's good to know -- should it be documented a bit more explicitly, or 
perhaps the alpha checks should be removed until they're fit for public 
consumption? Some of those alpha checks have been in the product for a long 
time, and if they're so unstable that we cannot expose them in a user-friendly 
fashion, perhaps they don't belong yet?


https://reviews.llvm.org/D28729



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


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:296
   const auto  =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
   bool AnalyzerChecksEnabled = false;

This is the place where a small local change will enable alpha checkers, if 
needed. It specifically shouldn't be configurable by users. It might make sense 
to add a comment to this effect here.


https://reviews.llvm.org/D28729



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


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

As discussed with the Static Analyzer maintainers, alpha checkers are 
completely unsupported and are suitable for very early testing only. We had 
problems with them routinely, that's why I disabled alpha checkers in 
clang-tidy completely. I don't think there should be a user-visible way to 
enable them. Developers can locally change the code to get access to alpha 
checkers, but released binaries shouldn't provide this possibility.


https://reviews.llvm.org/D28729



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


Re: r292032 - Fix PR31644 introduced by r287138 and add a regression test.

2017-01-14 Thread Dimitry Andric via cfe-commits
On 14 Jan 2017, at 22:12, Yaron Keren via cfe-commits 
 wrote:
> Author: yrnkrn
> Date: Sat Jan 14 15:12:08 2017
> New Revision: 292032
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=292032=rev
> Log:
> Fix PR31644 introduced by r287138 and add a regression test.
> Thanks Dimitry Andric for the report and fix!

Please merge this to the release_40 branch too. :)

-Dimitry



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


r292032 - Fix PR31644 introduced by r287138 and add a regression test.

2017-01-14 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Sat Jan 14 15:12:08 2017
New Revision: 292032

URL: http://llvm.org/viewvc/llvm-project?rev=292032=rev
Log:
Fix PR31644 introduced by r287138 and add a regression test.
Thanks Dimitry Andric for the report and fix!


Modified:
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/test/Preprocessor/dependencies-and-pp.c

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=292032=292031=292032=diff
==
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Sat Jan 14 15:12:08 2017
@@ -447,9 +447,9 @@ void DFGImpl::OutputDependencyFile() {
   // Create phony targets if requested.
   if (PhonyTarget && !Files.empty()) {
 // Skip the first entry, this is always the input file itself.
-for (StringRef File : Files) {
+for (auto I = Files.begin() + 1, E = Files.end(); I != E; ++I) {
   OS << '\n';
-  PrintFilename(OS, File, OutputFormat);
+  PrintFilename(OS, *I, OutputFormat);
   OS << ":\n";
 }
   }

Modified: cfe/trunk/test/Preprocessor/dependencies-and-pp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/dependencies-and-pp.c?rev=292032=292031=292032=diff
==
--- cfe/trunk/test/Preprocessor/dependencies-and-pp.c (original)
+++ cfe/trunk/test/Preprocessor/dependencies-and-pp.c Sat Jan 14 15:12:08 2017
@@ -32,5 +32,12 @@
 // RUN: FileCheck -check-prefix=TEST5 %s < %t.d
 // TEST5: foo $$(bar) b az qu\ ux \ space:
 
+// Test self dependency, PR31644
+
+// RUN: %clang -E -MD -MP -MF %t.d %s
+// RUN: FileCheck -check-prefix=TEST6 %s < %t.d
+// TEST6: dependencies-and-pp.c
+// TEST6-NOT: dependencies-and-pp.c:
+
 // TODO: Test default target without quoting
 // TODO: Test default target with quoting


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


[libcxx] r292029 - XFAIL native handle tests

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 14:25:25 2017
New Revision: 292029

URL: http://llvm.org/viewvc/llvm-project?rev=292029=rev
Log:
XFAIL native handle tests

Modified:

libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp?rev=292029=292028=292029=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
 Sat Jan 14 14:25:25 2017
@@ -9,6 +9,8 @@
 //
 // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
+// XFAIL: windows
+
 // 
 
 // class condition_variable;

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp?rev=292029=292028=292029=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
 Sat Jan 14 14:25:25 2017
@@ -9,6 +9,8 @@
 //
 // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
+// XFAIL: windows
+
 // 
 
 // class mutex;

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp?rev=292029=292028=292029=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
 Sat Jan 14 14:25:25 2017
@@ -9,6 +9,8 @@
 //
 // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
+// XFAIL: windows
+
 // 
 
 // class recursive_mutex;

Modified: 
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp?rev=292029=292028=292029=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
 Sat Jan 14 14:25:25 2017
@@ -9,6 +9,8 @@
 //
 // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
+// XFAIL: windows
+
 // 
 
 // class thread


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


[libcxx] r292028 - Fix demangle.h on Windows

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 14:21:18 2017
New Revision: 292028

URL: http://llvm.org/viewvc/llvm-project?rev=292028=rev
Log:
Fix demangle.h on Windows

Modified:
libcxx/trunk/test/support/demangle.h

Modified: libcxx/trunk/test/support/demangle.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/demangle.h?rev=292028=292027=292028=diff
==
--- libcxx/trunk/test/support/demangle.h (original)
+++ libcxx/trunk/test/support/demangle.h Sat Jan 14 14:21:18 2017
@@ -16,7 +16,7 @@
 
 #if !defined(TEST_HAS_NO_DEMANGLE)
 # if defined(__GNUC__) || defined(__clang__)
-#   if __has_include("cxxabi.h")
+#   if __has_include("cxxabi.h") && !defined(_LIBCPP_ABI_MICROSOFT)
 # include "cxxabi.h"
 #   else
 # define TEST_HAS_NO_DEMANGLE


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


[libcxx] r292027 - Attempt two at fixing threading on Windows

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 14:19:00 2017
New Revision: 292027

URL: http://llvm.org/viewvc/llvm-project?rev=292027=rev
Log:
Attempt two at fixing threading on Windows

Reviewers: compnerd

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=292027=292026=292027=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Sat Jan 14 14:19:00 2017
@@ -495,7 +495,7 @@ struct __libcpp_beginthreadex_thunk_data
   void *__arg;
 };
 
-static inline _LIBCPP_ALWAYS_INLINE DWORD WINAPI
+static inline _LIBCPP_ALWAYS_INLINE unsigned WINAPI
 __libcpp_beginthreadex_thunk(void *__raw_data)
 {
   auto *__data =
@@ -503,7 +503,7 @@ __libcpp_beginthreadex_thunk(void *__raw
   auto *__func = __data->__func;
   void *__arg = __data->__arg;
   delete __data;
-  return static_cast(reinterpret_cast(__func(__arg)));
+  return static_cast(reinterpret_cast(__func(__arg)));
 }
 
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
@@ -513,13 +513,10 @@ int __libcpp_thread_create(__libcpp_thre
   __data->__func = __func;
   __data->__arg = __arg;
 
-  *__t = CreateThread(
-nullptr, // default security attributes
-0, // default stack size
-__libcpp_beginthreadex_thunk, __data,
-0, // default creation flags
-nullptr // output for thread ID
-  );
+  *__t = reinterpret_cast(_beginthreadex(nullptr, 0,
+ __libcpp_beginthreadex_thunk,
+ __data, 0, nullptr));
+
   if (*__t)
 return 0;
   return GetLastError();


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


[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-01-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I do think that this is an issue.  Particularly for Windows targets, which have 
usually had the different architecture value.


https://reviews.llvm.org/D26796



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


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

2017-01-14 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Hi Alex, thanks for CCing me!




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1157
+def err_objc_method_unsupported_param_ret_type : Error<
+  "%0 %select{parameter|return value}1 is unsupported for this target">;
+

s/return value/return type/? Also, It would be nice to mention what isn't 
supported (vector types) and the version that it becomes supported in.



Comment at: lib/Sema/SemaDeclObjC.cpp:4337
+  VersionTuple MethodVersion = Method->getVersionIntroduced();
+  if (SemaRef.getASTContext().getTargetInfo().getPlatformMinVersion() >=
+  AcceptedInVersion &&

I wonder if this is the right place to check this. If we're compiling using a 
new SDK, but deploying back before vector types were supported we will diagnose 
a method declared in a header even if it is never called. We should probably 
hook this into DiagnoseAvailabilityOfDecl (in SemaExpr.cpp), which is called 
whenever a method is actually used, and diagnose it then.


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


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

2017-01-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Actually, according to 
https://svnweb.freebsd.org/base?view=revision=270943 (where the 
annotations were added), this helped to uncover existing bugs.  I don't see why 
it would interfere with anything; if you ask for -Wthread-safety warnings, you 
should get them, right?  What use are the warnings otherwise?


https://reviews.llvm.org/D28520



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


[libcxx] r292022 - Fix thread creation on Windows

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 13:11:07 2017
New Revision: 292022

URL: http://llvm.org/viewvc/llvm-project?rev=292022=rev
Log:
Fix thread creation on Windows

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=292022=292021=292022=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Sat Jan 14 13:11:07 2017
@@ -495,25 +495,31 @@ struct __libcpp_beginthreadex_thunk_data
   void *__arg;
 };
 
-static inline _LIBCPP_ALWAYS_INLINE unsigned int WINAPI
-__libcpp_beginthreadex_thunk(void *__data)
+static inline _LIBCPP_ALWAYS_INLINE DWORD WINAPI
+__libcpp_beginthreadex_thunk(void *__raw_data)
 {
-  __libcpp_beginthreadex_thunk_data data =
-  *reinterpret_cast<__libcpp_beginthreadex_thunk_data *>(__data);
-  delete reinterpret_cast<__libcpp_beginthreadex_thunk_data *>(__data);
-  return reinterpret_cast(data.__func(data.__arg));
+  auto *__data =
+  static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data);
+  auto *__func = __data->__func;
+  void *__arg = __data->__arg;
+  delete __data;
+  return static_cast(reinterpret_cast(__func(__arg)));
 }
 
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {
-  auto *data = new __libcpp_beginthreadex_thunk_data;
-  data->__func = __func;
-  data->__arg = __arg;
+  auto *__data = new __libcpp_beginthreadex_thunk_data;
+  __data->__func = __func;
+  __data->__arg = __arg;
 
-  *__t = reinterpret_cast(_beginthreadex(NULL, 0,
- __libcpp_beginthreadex_thunk,
- data, 0, NULL));
+  *__t = CreateThread(
+nullptr, // default security attributes
+0, // default stack size
+__libcpp_beginthreadex_thunk, __data,
+0, // default creation flags
+nullptr // output for thread ID
+  );
   if (*__t)
 return 0;
   return GetLastError();


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


[PATCH] D28728: [libc++] Introduce _LIBCPP_EXTERN_VIS to fix __libcpp_debug_function link errors

2017-01-14 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

This will need to be exported on other platforms too when hidden visibility 
happens :)

Is it okay for these to be exported unconditionally, or should their exporting 
be determined by `_LIBCPP_DEBUG`? This LGTM if it's the former.


https://reviews.llvm.org/D28728



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


[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2017-01-14 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292018: [cmake] Handle missing LIBUNWIND_* directories 
gracefully (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25314?vs=73770=84455#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25314

Files:
  libcxxabi/trunk/CMakeLists.txt


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -479,8 +479,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -479,8 +479,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker flags
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r292018 - [cmake] Handle missing LIBUNWIND_* directories gracefully

2017-01-14 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Sat Jan 14 11:05:16 2017
New Revision: 292018

URL: http://llvm.org/viewvc/llvm-project?rev=292018=rev
Log:
[cmake] Handle missing LIBUNWIND_* directories gracefully

Add LIBUNWIND_* directories to include path only if they were actually
found, in order to fix the CMake error. Both of the directories are
usually unnecessary since libcxxabi uses only the common part of
unwind.h that is supplied both by GCC and Clang.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=292018=292017=292018=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Sat Jan 14 11:05:16 2017
@@ -479,8 +479,12 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags


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


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

2017-01-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim updated this revision to Diff 84451.
dim added a comment.

Something like this might work, maybe.  (I haven't yet run the full test suite, 
as that takes quite a while on my machines.)

I did not re-use the `_LIBCPP_THREAD_SAFETY_ANNOTATION` macro from 
`__mutex_base`, since that is included *after* this file, and it is only 
enabled when the user defines `_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS`.  The 
`_LIBCPP_THREAD_SAFETY_ATTRIBUTE` macro is defined iff clang supports any of 
the thread safety stuff.

Note that I had to add a capability attribute to the `__libcpp_mutex` types, 
otherwise this would not work.

Also, I had to place the thread safety attributes *after* the function 
declarations, since otherwise the compiler complains that it does not know the 
parameter name `__m`.

Furthermore, I am still not sure whether the `true` value for the 
`try_acquire_capability` attribute it correct.  If I understand the 
documentation correctly, `true` means that the function only succeeds when 
trying the lock actually acquires it, and it fails when the lock was already 
acquired.


https://reviews.llvm.org/D28520

Files:
  include/__threading_support


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -40,14 +40,22 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__clang__) && __has_attribute(acquire_capability))
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#else
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
-typedef pthread_mutex_t __libcpp_mutex_t;
+typedef pthread_mutex_t __libcpp_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
-typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+typedef pthread_mutex_t __libcpp_recursive_mutex_t
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(capability("mutex"));
 
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
@@ -99,25 +107,31 @@
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(acquire_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(try_acquire_capability(true, *__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(release_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(acquire_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(try_acquire_capability(true, *__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(release_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
@@ -130,11 +144,13 @@
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(requires_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts);
+   timespec *__ts)
+_LIBCPP_THREAD_SAFETY_ATTRIBUTE(requires_capability(*__m));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -40,14 +40,22 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__clang__) && __has_attribute(acquire_capability))
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#else
+#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x))
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // 

[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2017-01-14 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a reviewer: jroelofs.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D25314



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


[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2017-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Second ping.


https://reviews.llvm.org/D25314



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


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

2017-01-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a subscriber: ed.
dim added a comment.

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

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


I wasn't able to figure out how that should work.  The Thread Safety Analysis 
documentation specifies a number of macros that can be used, but does not 
directly document the attributes themselves.  It looks like some of the 
attributes have a slightly different signature than the actual pthread 
functions, and the `__libcpp` wrapper for them, e.g. the example for 
`TRY_ACQUIRE` seems to assume a `bool` return value:

  // Try to acquire the mutex.  Returns true on success, and false on failure.
  bool TryLock() TRY_ACQUIRE(true);

where `TRY_ACQUIRE(true)` gets replaced by `__attribute__ 
((try_acquire_capability(true)))`.  However, the signature for the `__libcpp` 
variant, and the "real" pthread function, is:

  int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)

so the return value is an `int`, where `0` means success, and any other value 
an error.  I am unsure how this can be mapped to the attribute, and the 
documentation does not specify it.

In https://reviews.llvm.org/D28520#646169, @EricWF wrote:

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


Since a few years, FreeBSD's  has locking annotations, for example 
https://svnweb.freebsd.org/base/head/include/pthread.h?view=markup#l228 which 
has:

  int pthread_mutex_init(pthread_mutex_t *__mutex,
  const pthread_mutexattr_t *)
  __requires_unlocked(*__mutex);
  int pthread_mutex_lock(pthread_mutex_t *__mutex)
  __locks_exclusive(*__mutex);
  int pthread_mutex_trylock(pthread_mutex_t *__mutex)
  __trylocks_exclusive(0, *__mutex);
  int pthread_mutex_timedlock(pthread_mutex_t *__mutex,
  const struct timespec *)
  __trylocks_exclusive(0, *__mutex);

These annotations expand to `__attribute__((locks_excluded))`, 
`__attribute__((exclusive_lock_function))`, and so on, if 
`__has_extension(c_thread_safety_attributes)` is true.  Apparently @ed added 
these.


https://reviews.llvm.org/D28520



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


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

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

LGTM with a few minor nits, but in the future, please provide some summary of 
what your patch is going to do rather than leave it entirely blank. It makes it 
easier on the reviewers if they have an idea of what to expect and why it's 
needed. ;-)

Also, this should probably be added to the release notes.




Comment at: clang-tidy/ClangTidyOptions.h:78
 
+  /// \brief Turns on experimental alpha checkers from static-analyzer.
+  llvm::Optional EnableAlphaChecks;

from static-analyzer -> from the static analyzer


https://reviews.llvm.org/D28729



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


Re: [libcxx] r292013 - Fix last_write_time tests for filesystems that don't support negative and very large times

2017-01-14 Thread Eric Fiselier via cfe-commits
+1 from me. @Hans am I OK to merge this?

On Sat, Jan 14, 2017 at 4:53 AM, Hahnfeld, Jonas <
hahnf...@itc.rwth-aachen.de> wrote:

> Hi Hans,
>
> can this be merged for 4.0? Eric suggested this in
> https://reviews.llvm.org/D22452 so I think he should be fine.
>
> Thanks,
> Jonas
>
> Am Samstag, den 14.01.2017, 11:35 + schrieb Jonas Hahnfeld via
> cfe-commits:
>
> Author: hahnfeld
> Date: Sat Jan 14 05:35:15 2017
> New Revision: 292013
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292013=rev
> Log:
> Fix last_write_time tests for filesystems that don't support negative and 
> very large times
>
> Seems to be the case for NFS.
>
> Original patch by Eric Fiselier!
> Differential Revision: https://reviews.llvm.org/D22452
>
> Modified:
> 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>
> Modified: 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=292013=292012=292013=diff
> ==
> --- 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>  Sat Jan 14 05:35:15 2017
> @@ -72,13 +72,60 @@ std::pair GetS
>  return {st.st_atime, st.st_mtime};
>  }
>
> -inline bool TimeIsRepresentableAsTimeT(file_time_type tp) {
> +namespace {
> +bool TestSupportsNegativeTimes() {
> +using namespace std::chrono;
> +std::error_code ec;
> +std::time_t old_write_time, new_write_time;
> +{ // WARNING: Do not assert in this scope.
> +scoped_test_env env;
> +const path file = env.create_file("file", 42);
> +old_write_time = LastWriteTime(file);
> +file_time_type tp(seconds(-5));
> +fs::last_write_time(file, tp, ec);
> +new_write_time = LastWriteTime(file);
> +}
> +return !ec && new_write_time <= -5;
> +}
> +
> +bool TestSupportsMaxTime() {
>  using namespace std::chrono;
>  using Lim = std::numeric_limits;
> -auto sec = duration_cast(tp.time_since_epoch()).count();
> -return (sec >= Lim::min() && sec <= Lim::max());
> +auto max_sec = 
> duration_cast(file_time_type::max().time_since_epoch()).count();
> +if (max_sec > Lim::max()) return false;
> +std::error_code ec;
> +std::time_t old_write_time, new_write_time;
> +{ // WARNING: Do not assert in this scope.
> +scoped_test_env env;
> +const path file = env.create_file("file", 42);
> +old_write_time = LastWriteTime(file);
> +file_time_type tp = file_time_type::max();
> +fs::last_write_time(file, tp, ec);
> +new_write_time = LastWriteTime(file);
> +}
> +return !ec && new_write_time > max_sec - 1;
>  }
>
> +static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
> +static const bool SupportsMaxTime = TestSupportsMaxTime();
> +
> +} // end namespace
> +
> +// Check if a time point is representable on a given filesystem. Check that:
> +// (A) 'tp' is representable as a time_t
> +// (B) 'tp' is non-negative or the filesystem supports negative times.
> +// (C) 'tp' is not 'file_time_type::max()' or the filesystem supports the max
> +// value.
> +inline bool TimeIsRepresentableByFilesystem(file_time_type tp) {
> +using namespace std::chrono;
> +using Lim = std::numeric_limits;
> +auto sec = duration_cast(tp.time_since_epoch()).count();
> +auto microsec = 
> duration_cast(tp.time_since_epoch()).count();
> +if (sec < Lim::min() || sec > Lim::max())   return false;
> +else if (microsec < 0 && !SupportsNegativeTimes) return false;
> +else if (tp == file_time_type::max() && !SupportsMaxTime) return false;
> +return true;
> +}
>
>  TEST_SUITE(exists_test_suite)
>
> @@ -214,15 +261,17 @@ TEST_CASE(set_last_write_time_dynamic_en
>
>  file_time_type  got_time = last_write_time(TC.p);
>
> -TEST_CHECK(got_time != old_time);
> -if (TC.new_time < epoch_time) {
> -TEST_CHECK(got_time <= TC.new_time);
> -TEST_CHECK(got_time > TC.new_time - Sec(1));
> -} else {
> -TEST_CHECK(got_time <= TC.new_time + Sec(1));
> -TEST_CHECK(got_time >= TC.new_time - Sec(1));
> +if (TimeIsRepresentableByFilesystem(TC.new_time)) {
> +TEST_CHECK(got_time != old_time);
> +if (TC.new_time < epoch_time) {
> +TEST_CHECK(got_time <= TC.new_time);
> +TEST_CHECK(got_time > TC.new_time - Sec(1));
> +} else {
> +TEST_CHECK(got_time <= TC.new_time + Sec(1));
> +TEST_CHECK(got_time >= 

[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 84448.
Prazek added a comment.

reformat


https://reviews.llvm.org/D28729

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/enable-alpha-checks.cpp

Index: test/clang-tidy/enable-alpha-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/enable-alpha-checks.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-alpha'
+// RUN: clang-tidy -checks=* -list-checks -enable-alpha-checks | grep 'clang-analyzer-alpha'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -180,6 +180,14 @@
cl::init(false),
cl::cat(ClangTidyCategory));
 
+static cl::opt EnableAlphaChecks("enable-alpha-checks", cl::desc(R"(
+Enable experimental clang-analyzer-alpha-* checks.
+This option overrides the value read from a
+.clang-tidy file.
+)"),
+   cl::init(false),
+   cl::cat(ClangTidyCategory));
+
 static cl::opt ExportFixes("export-fixes", cl::desc(R"(
 YAML file to store suggested fixes in. The
 stored fixes can be applied to the input source
@@ -272,6 +280,7 @@
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
+  DefaultOptions.EnableAlphaChecks = EnableAlphaChecks;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
   // USERNAME is used on Windows.
   if (!DefaultOptions.User)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -75,6 +75,9 @@
   /// \brief Turns on temporary destructor-based analysis.
   llvm::Optional AnalyzeTemporaryDtors;
 
+  /// \brief Turns on experimental alpha checkers from static-analyzer.
+  llvm::Optional EnableAlphaChecks;
+
   /// \brief Specifies the name or e-mail of the user running clang-tidy.
   ///
   /// This option is used, for example, to place the correct user name in TODO()
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -89,6 +89,7 @@
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
+IO.mapOptional("EnableAlphaChecks", Options.EnableAlphaChecks);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
@@ -109,6 +110,7 @@
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
   Options.AnalyzeTemporaryDtors = false;
+  Options.EnableAlphaChecks = false;
   Options.User = llvm::None;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
  E = ClangTidyModuleRegistry::end();
@@ -148,6 +150,7 @@
   overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
   overrideValue(Result.SystemHeaders, Other.SystemHeaders);
   overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors);
+  overrideValue(Result.EnableAlphaChecks, Other.EnableAlphaChecks);
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
   mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -289,11 +289,12 @@
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(GlobList ) {
+static CheckersList getCheckersControlList(GlobList ,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto  =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
@@ -359,7 +360,8 @@
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
 
   GlobList  = Context.getChecksFilter();
-  AnalyzerOptions->CheckersControlList = getCheckersControlList(Filter);
+  AnalyzerOptions->CheckersControlList =
+  getCheckersControlList(Filter, *Context.getOptions().EnableAlphaChecks);
   if 

[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek created this revision.
Prazek added a reviewer: alexfh.
Prazek added a subscriber: cfe-commits.
Herald added a subscriber: JDevlieghere.

https://reviews.llvm.org/D28729

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/enable-alpha-checks.cpp

Index: test/clang-tidy/enable-alpha-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/enable-alpha-checks.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-alpha'
+// RUN: clang-tidy -checks=* -list-checks -enable-alpha-checks | grep 'clang-analyzer-alpha'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -180,6 +180,15 @@
cl::init(false),
cl::cat(ClangTidyCategory));
 
+static cl::opt EnableAlphaChecks("enable-alpha-checks",
+   cl::desc(R"(
+Enable experimental clang-analyzer-alpha-* checks.
+This option overrides the value read from a
+.clang-tidy file.
+)"),
+   cl::init(false),
+   cl::cat(ClangTidyCategory));
+
 static cl::opt ExportFixes("export-fixes", cl::desc(R"(
 YAML file to store suggested fixes in. The
 stored fixes can be applied to the input source
@@ -272,6 +281,7 @@
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
+  DefaultOptions.EnableAlphaChecks = EnableAlphaChecks;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
   // USERNAME is used on Windows.
   if (!DefaultOptions.User)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -75,6 +75,9 @@
   /// \brief Turns on temporary destructor-based analysis.
   llvm::Optional AnalyzeTemporaryDtors;
 
+  /// \brief Turns on experimental alpha checkers from static-analyzer.
+  llvm::Optional EnableAlphaChecks;
+
   /// \brief Specifies the name or e-mail of the user running clang-tidy.
   ///
   /// This option is used, for example, to place the correct user name in TODO()
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -89,6 +89,7 @@
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
+IO.mapOptional("EnableAlphaChecks", Options.EnableAlphaChecks);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
@@ -109,6 +110,7 @@
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
   Options.AnalyzeTemporaryDtors = false;
+  Options.EnableAlphaChecks = false;
   Options.User = llvm::None;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
  E = ClangTidyModuleRegistry::end();
@@ -148,6 +150,7 @@
   overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
   overrideValue(Result.SystemHeaders, Other.SystemHeaders);
   overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors);
+  overrideValue(Result.EnableAlphaChecks, Other.EnableAlphaChecks);
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
   mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -289,11 +289,12 @@
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(GlobList ) {
+static CheckersList getCheckersControlList(GlobList ,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto  =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
@@ -359,7 +360,8 @@
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
 
   GlobList  = Context.getChecksFilter();
-  AnalyzerOptions->CheckersControlList = getCheckersControlList(Filter);
+  

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

2017-01-14 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added inline comments.



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

rnk wrote:
> What are the outstanding issues preventing you from enabling this by default?
Building on Win32 doesn't imply that you'll have the required header;  it 
currently needs to be installed [[ 
https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
 | separately ]] via nuget. While it would be possible to have cmake create a 
packages.config file when configuring a visual studio project, the API is only 
at the RC stage and so the distribution method could potentially change between 
now and the Visual Studio 2017 release (even if that's not a concern, it's 
probably out of the scope of this patch anyway).
Although the code looks useless sitting there ifdefed out, it could be useful 
for someone eager enough to get the package themselves and run a custom Clang 
build.
In the meantime, Visual Studio 2017 installations can only be detected when 
running in the correct developer command prompt, or by putting one of its 
toolchain's bin directories at the top of PATH.


https://reviews.llvm.org/D28365



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


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

2017-01-14 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 84446.
hamzasood added a comment.

Broke up findVCToolChainPath into a few smaller functions.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10809,19 +10809,12 @@
 // making sure that whatever executable that's found is not a same-named exe
 // from clang itself to prevent clang from falling back to itself.
 static std::string FindVisualStudioExecutable(const ToolChain ,
-  const char *Exe,
-  const char *ClangProgramPath) {
+  const char *Exe) {
   const auto  = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation , const JobAction ,
@@ -10830,7 +10823,7 @@
 const ArgList ,
 const char *LinkingOutput) const {
   ArgStringList CmdArgs;
-  const ToolChain  = getToolChain();
+  auto  = static_cast(getToolChain());
 
   assert((Output.isFilename() || Output.isNothing()) && "invalid output");
   if (Output.isFilename())
@@ -10846,37 +10839,20 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
-const auto  = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + TC.getSubDirectoryPath(toolchains::MSVCToolChain
+   ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (TC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (TC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
-if (MSVC.getWindowsSDKLibraryPath(WindowsSdkLibPath))
+if (TC.getWindowsSDKLibraryPath(WindowsSdkLibPath))
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-libpath:") + WindowsSdkLibPath));
   }
@@ -10991,8 +10967,7 @@
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
 // their own link.exe which may come first.
-linkPath = FindVisualStudioExecutable(TC, "link.exe",
-  C.getDriver().getClangProgramPath());
+linkPath = FindVisualStudioExecutable(TC, "link.exe");
   } else {
 linkPath = Linker;
 llvm::sys::path::replace_extension(linkPath, "exe");
@@ -11125,9 +11100,7 @@
   Args.MakeArgString(std::string("/Fo") + Output.getFilename());
   CmdArgs.push_back(Fo);
 
-  const Driver  = getToolChain().getDriver();
-  std::string Exec = FindVisualStudioExecutable(getToolChain(), "cl.exe",
-D.getClangProgramPath());
+  std::string Exec = FindVisualStudioExecutable(getToolChain(), "cl.exe");
   return llvm::make_unique(JA, 

r292016 - Update the tests to match the typo fix done in r292015

2017-01-14 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Sat Jan 14 06:00:40 2017
New Revision: 292016

URL: http://llvm.org/viewvc/llvm-project?rev=292016=rev
Log:
Update the tests to match the typo fix done in r292015

Modified:
cfe/trunk/test/Sema/enable_if.c
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/test/Sema/enable_if.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enable_if.c?rev=292016=292015=292016=diff
==
--- cfe/trunk/test/Sema/enable_if.c (original)
+++ cfe/trunk/test/Sema/enable_if.c Sat Jan 14 06:00:40 2017
@@ -139,8 +139,8 @@ void test7() {
 
 void f4(int m) __attribute__((enable_if(0, "")));
 void test8() {
-  void (*p1)(int) =  // expected-error{{cannot take address of function 
'f4' becuase it has one or more non-tautological enable_if conditions}}
-  void (*p2)(int) = f4; // expected-error{{cannot take address of function 
'f4' becuase it has one or more non-tautological enable_if conditions}}
+  void (*p1)(int) =  // expected-error{{cannot take address of function 
'f4' because it has one or more non-tautological enable_if conditions}}
+  void (*p2)(int) = f4; // expected-error{{cannot take address of function 
'f4' because it has one or more non-tautological enable_if conditions}}
 }
 
 void regular_enable_if(int a) __attribute__((enable_if(a, ""))); // 
expected-note 3{{declared here}}

Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=292016=292015=292016=diff
==
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Sat Jan 14 06:00:40 2017
@@ -246,11 +246,11 @@ namespace FnPtrs {
 
   int noOvlNoCandidate(int m) __attribute__((enable_if(false, "")));
   void test8() {
-int (*p)(int) = noOvlNoCandidate; // expected-error{{cannot take address 
of function 'noOvlNoCandidate' becuase it has one or more non-tautological 
enable_if conditions}}
-int (*p2)(int) =  // expected-error{{cannot take address 
of function 'noOvlNoCandidate' becuase it has one or more non-tautological 
enable_if conditions}}
+int (*p)(int) = noOvlNoCandidate; // expected-error{{cannot take address 
of function 'noOvlNoCandidate' because it has one or more non-tautological 
enable_if conditions}}
+int (*p2)(int) =  // expected-error{{cannot take address 
of function 'noOvlNoCandidate' because it has one or more non-tautological 
enable_if conditions}}
 int (*a)(int);
-a = noOvlNoCandidate; // expected-error{{cannot take address of function 
'noOvlNoCandidate' becuase it has one or more non-tautological enable_if 
conditions}}
-a =  // expected-error{{cannot take address of function 
'noOvlNoCandidate' becuase it has one or more non-tautological enable_if 
conditions}}
+a = noOvlNoCandidate; // expected-error{{cannot take address of function 
'noOvlNoCandidate' because it has one or more non-tautological enable_if 
conditions}}
+a =  // expected-error{{cannot take address of function 
'noOvlNoCandidate' because it has one or more non-tautological enable_if 
conditions}}
   }
 }
 


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


r292015 - fix a few typo in the doc but also in the clang messages

2017-01-14 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Sat Jan 14 05:41:45 2017
New Revision: 292015

URL: http://llvm.org/viewvc/llvm-project?rev=292015=rev
Log:
fix a few typo in the doc but also in the clang messages

Modified:
cfe/trunk/docs/ControlFlowIntegrityDesign.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/docs/ControlFlowIntegrityDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrityDesign.rst?rev=292015=292014=292015=diff
==
--- cfe/trunk/docs/ControlFlowIntegrityDesign.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrityDesign.rst Sat Jan 14 05:41:45 2017
@@ -540,7 +540,7 @@ The bit vector lookup is probably too co
Jump(kFailedCheckTarget);
   }
 
-An alternative and more compact enconding would not use `kFailedCheckTarget`,
+An alternative and more compact encoding would not use `kFailedCheckTarget`,
 and will trap on check failure instead.
 This will allow us to fit the instruction into **8-9 bytes**.
 The cross-DSO checks will be performed by a trap handler and

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=292015=292014=292015=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Sat Jan 14 05:41:45 2017
@@ -2645,7 +2645,7 @@ Execute ``clang-cl /?`` to see a list of
   (overridden by LLVM_PROFILE_FILE env var)
   -fprofile-instr-generate
   Generate instrumented code to collect execution 
counts into default.profraw file
-  (overriden by '=' form of option or 
LLVM_PROFILE_FILE env var)
+  (overridden by '=' form of option or 
LLVM_PROFILE_FILE env var)
   -fprofile-instr-use=
   Use instrumentation data for profile-guided 
optimization
   -fsanitize-blacklist=

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=292015=292014=292015=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sat Jan 14 05:41:45 2017
@@ -340,7 +340,7 @@ class TargetSpecificAttrhttp://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=292015=292014=292015=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sat Jan 14 05:41:45 2017
@@ -883,7 +883,7 @@ def BackendOptimizationFailure : DiagGro
 def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
 
-// AddressSanitizer frontent instrumentation remarks.
+// AddressSanitizer frontend instrumentation remarks.
 def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;
 
 // Issues with serialized diagnostics.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=292015=292014=292015=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 14 05:41:45 
2017
@@ -2268,7 +2268,7 @@ def warn_unsupported_target_attribute
 InGroup;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported for this target">;
-// The err_*_attribute_argument_not_int are seperate because they're used by
+// The err_*_attribute_argument_not_int are separate because they're used by
 // VerifyIntegerConstantExpression.
 def err_aligned_attribute_argument_not_int : Error<
   "'aligned' attribute requires integer constant">;
@@ -3387,7 +3387,7 @@ def note_ovl_candidate_disabled_by_funct
 def note_ovl_candidate_disabled_by_extension : Note<
 "candidate disabled due to OpenCL extension">;
 def err_addrof_function_disabled_by_enable_if_attr : Error<
-"cannot take address of function %0 becuase it has one or more "
+"cannot take address of function %0 because it has one or more "
 "non-tautological enable_if conditions">;
 def note_addrof_ovl_candidate_disabled_by_enable_if_attr : Note<
 "candidate function made ineligible by enable_if">;

Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
URL: 

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

2017-01-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/tool/run-clang-tidy.py:80
+  for arg in extra_arg:
+  start.append('-extra-arg=%s' % arg[0])
+  for arg in extra_arg_before:

Why arg[0] and not just arg?


https://reviews.llvm.org/D28334



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


[libcxx] r292012 - Mark test as UNSUPPORTED on Windows since it hangs forever

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 04:31:43 2017
New Revision: 292012

URL: http://llvm.org/viewvc/llvm-project?rev=292012=rev
Log:
Mark test as UNSUPPORTED on Windows since it hangs forever

Modified:
libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp

Modified: libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp?rev=292012=292011=292012=diff
==
--- libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp Sat 
Jan 14 04:31:43 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
+// FIXME: This test hangs for an unknown reason on Windows. See 
llvm.org/PR31642
+// UNSUPPORTED: windows
+
 // 
 // template 
 // constexpr see below visit(Visitor&& vis, Variants&&... vars);


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


[libcxx] r292011 - Fix Windows try_lock implementation

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 04:27:12 2017
New Revision: 292011

URL: http://llvm.org/viewvc/llvm-project?rev=292011=rev
Log:
Fix Windows try_lock implementation

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/src/mutex.cpp
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=292011=292010=292011=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Sat Jan 14 04:27:12 2017
@@ -102,7 +102,7 @@ _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
@@ -114,7 +114,7 @@ _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
@@ -221,9 +221,9 @@ int __libcpp_recursive_mutex_lock(__libc
   return pthread_mutex_lock(__m);
 }
 
-int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
 {
-  return pthread_mutex_trylock(__m);
+  return pthread_mutex_trylock(__m) == 0;
 }
 
 int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
@@ -241,9 +241,9 @@ int __libcpp_mutex_lock(__libcpp_mutex_t
   return pthread_mutex_lock(__m);
 }
 
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
 {
-  return pthread_mutex_trylock(__m);
+  return pthread_mutex_trylock(__m) == 0;
 }
 
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
@@ -371,10 +371,9 @@ int __libcpp_recursive_mutex_lock(__libc
   return 0;
 }
 
-int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
 {
-  TryEnterCriticalSection(__m);
-  return 0;
+  return TryEnterCriticalSection(__m) != 0;
 }
 
 int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
@@ -395,10 +394,9 @@ int __libcpp_mutex_lock(__libcpp_mutex_t
   return 0;
 }
 
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
 {
-  TryAcquireSRWLockExclusive(__m);
-  return 0;
+  return TryAcquireSRWLockExclusive(__m) != 0;
 }
 
 int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)

Modified: libcxx/trunk/src/mutex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/mutex.cpp?rev=292011=292010=292011=diff
==
--- libcxx/trunk/src/mutex.cpp (original)
+++ libcxx/trunk/src/mutex.cpp Sat Jan 14 04:27:12 2017
@@ -37,7 +37,7 @@ mutex::lock()
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return __libcpp_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_);
 }
 
 void
@@ -83,7 +83,7 @@ recursive_mutex::unlock() _NOEXCEPT
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return __libcpp_recursive_mutex_trylock(&__m_) == 0;
+return __libcpp_recursive_mutex_trylock(&__m_);
 }
 
 // timed_mutex

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292011=292010=292011=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sat Jan 14 04:27:12 2017
@@ -382,6 +382,9 @@ class Configuration(object):
 if '__cpp_structured_bindings' not in macros:
 self.config.available_features.add('libcpp-no-structured-bindings')
 
+if self.is_windows:
+self.config.available_features.add('windows')
+
 def configure_compile_flags(self):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not no_default_flags:


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


[libcxx] r292010 - Fix copy-paste errors in r292001

2017-01-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan 14 04:22:21 2017
New Revision: 292010

URL: http://llvm.org/viewvc/llvm-project?rev=292010=rev
Log:
Fix copy-paste errors in r292001

Modified:
libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake

Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake?rev=292010=292009=292010=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Sat Jan 14 04:22:21 2017
@@ -27,9 +27,9 @@ endmacro()
 macro(remove_flags)
   foreach(var ${ARGN})
 string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_DEBUG 
"${CMAKE_CXX_FLAGS_DEBUG}")
-string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_MINSIZEREL 
"${CMAKE_CXX_FLAGS_DEBUG}")
-string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELEASE 
"${CMAKE_CXX_FLAGS_DEBUG}")
-string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO 
"${CMAKE_CXX_FLAGS_DEBUG}")
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_MINSIZEREL 
"${CMAKE_CXX_FLAGS_MINSIZEREL}")
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELEASE 
"${CMAKE_CXX_FLAGS_RELEASE}")
+string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO 
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
 string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS 
"${CMAKE_EXE_LINKER_FLAGS}")


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


[PATCH] D28727: Add -fstrict-vtable-pointers to UserManual

2017-01-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek created this revision.
Prazek added a reviewer: hans.
Prazek added a subscriber: cfe-commits.

It would be good to merge it to 4.0 branch.


https://reviews.llvm.org/D28727

Files:
  docs/UsersManual.rst


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1097,6 +1097,11 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+
+.. option:: -f[no-]strict-vtable-pointers
+   Enable optimizations based on the strict rules for overwriting polymorphic
+   C++ objects. This enables better devirtualization. Turned off by default.
+
 .. option:: -ffast-math
 
Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1097,6 +1097,11 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+
+.. option:: -f[no-]strict-vtable-pointers
+   Enable optimizations based on the strict rules for overwriting polymorphic
+   C++ objects. This enables better devirtualization. Turned off by default.
+
 .. option:: -ffast-math
 
Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28725: [libc++][CMake] Use debug MSVC runtimes when libc++ is built in debug mode

2017-01-14 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 84440.
EricWF marked 2 inline comments as done.
EricWF added a comment.

- Address inline comments.


https://reviews.llvm.org/D28725

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in
  test/support/set_windows_crt_report_mode.h

Index: test/support/set_windows_crt_report_mode.h
===
--- /dev/null
+++ test/support/set_windows_crt_report_mode.h
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+#ifndef SUPPORT_SET_WINDOWS_CRT_REPORT_MODE_H
+#define SUPPORT_SET_WINDOWS_CRT_REPORT_MODE_H
+
+#ifndef _DEBUG
+#error _DEBUG must be defined when using this header
+#endif
+
+#ifndef _WIN32
+#error This header can only be used when targeting Windows
+#endif
+
+#include 
+
+// On Windows in debug builds the default assertion handler opens a new dialog
+// window which must be dismissed manually by the user. This function overrides
+// that setting and instead changes the assertion handler to log to stderr
+// instead.
+inline int init_crt_report_mode() {
+  _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
+  _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
+  _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
+  return 0;
+}
+
+static int init_crt_anchor = init_crt_report_mode();
+
+#endif // SUPPORT_SET_WINDOWS_CRT_REPORT_MODE_H
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -26,7 +26,7 @@
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.has_libatomic= "@LIBCXX_HAS_ATOMIC_LIB@"
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
-
+config.debug_build  = "@LIBCXX_DEBUG_BUILD@"
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
 config.cxx_ext_threads  = "@LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -68,6 +68,7 @@
 self.cxx_runtime_root = None
 self.abi_library_root = None
 self.link_shared = self.get_lit_bool('enable_shared', default=True)
+self.debug_build = self.get_lit_bool('debug_build',   default=False)
 self.exec_env = {}
 self.use_target = False
 self.use_system_cxx_lib = False
@@ -148,6 +149,7 @@
 self.lit_config.note('Using available_features: %s' %
  list(self.config.available_features))
 self.lit_config.note('Using environment: %r' % self.exec_env)
+sys.stderr.flush()  # Force flushing to avoid broken output on Windows
 
 def get_test_format(self):
 return LibcxxTestFormat(
@@ -438,13 +440,20 @@
 ['-target', self.config.target_triple]):
 self.lit_config.warning('use_target is true but -target is '\
 'not supported by the compiler')
+if self.is_windows and self.debug_build:
+self.cxx.compile_flags += ['-D_DEBUG']
 
 def configure_compile_flags_header_includes(self):
-support_path = os.path.join(self.libcxx_src_root, 'test/support')
+support_path = os.path.join(self.libcxx_src_root, 'test', 'support')
 if self.cxx_stdlib_under_test != 'libstdc++' and \
not self.is_windows:
 self.cxx.compile_flags += [
 '-include', os.path.join(support_path, 'nasty_macros.hpp')]
+if self.is_windows and self.debug_build:
+self.cxx.compile_flags += [
+'-include', os.path.join(support_path,
+ 'set_windows_crt_report_mode.h')
+]
 self.configure_config_site_header()
 cxx_headers = self.get_lit_conf('cxx_headers')
 if cxx_headers == '' or (cxx_headers is None
@@ -667,7 +676,8 @@
 self.cxx.link_flags += ['-lcxxrt']
 elif cxx_abi == 'none' or cxx_abi == 'default':
 if self.is_windows:
-self.cxx.link_flags += ['-lmsvcrt']
+debug_suffix = 'd' if self.debug_build else ''
+self.cxx.link_flags += ['-lmsvcrt%s' % debug_suffix]
 else:
 self.lit_config.fatal(
 'C++ ABI setting %s unsupported for tests' % cxx_abi)
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -35,6 +35,7 @@