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

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

Not gonna submit this till https://reviews.llvm.org/D27430 has been submitted 
(will address comments on that one after holidays).


https://reviews.llvm.org/D25208



___
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-01-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Yeah, that sounds good. I want to do more investigation into this as well.


https://reviews.llvm.org/D25208



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


[PATCH] D28202: [OpenMP] Sema and parsing for 'target teams distribute parallel for simd' pragma

2017-01-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D28202



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


[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2017-01-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:539-542
+llvm::Value *EndArgs[] = {emitUpdateLocation(CGF, Loc), ThreadID};
+CGF.EmitRuntimeCall(
+createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_end_serialized_parallel),
+EndArgs);

It is better to emit this code as PrePostAction, so it is called upon exit of 
any cleanup scope


https://reviews.llvm.org/D28145



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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D28081#633103, @amaiorano wrote:

> Hello everyone, so after a few more tests, I've uncovered a bug and perhaps a 
> different meaning for fallback style. First, the bug: if you set fallback 
> style to "none", clang-format will perform no replacements. This happens 
> because getStyle will first initialize its local Style variable to LLVM 
> style, and then because a fallback style is set, will then set it to the 
> "none" style, will ends up setting Style.DisableFormatting to true. After 
> that, when we parse YAML (either from Style arg or a config file), we use the 
> Style variable as the "template" for fields that haven't been set. In this 
> case, the "none" fallback style causes DisableFormatting to remain true, so 
> no formatting will take place.
>
> As it happens, my first diff patch uploaded here fixed this issue by 
> accident. Instead of reusing the same local Style variable, I declared one 
> for each case where we'd need to parse. The fallback style case would use its 
> own variable, FallbackStyle, which would not be used as the template style 
> when parsing the YAML config.
>
> What's interesting is that the way the code is originally written allows you 
> to use fallback style as a way to set the "base" configuration for which the 
> subsequently parsed YAML overlays. For example, if I don't set fallback 
> style, the assumed base style is "LLVM", and any YAML parsed modifies this 
> LLVM base style. But if I pass a fallback style of "Mozilla", then this 
> becomes the base style over which the YAML overlays.
>
> So to my mind, we have 2 approaches to fix the "none" style bug:
>
> 1. Go with a similar approach to what I did originally; that is, we always 
> assume LLVM as the base style, and make sure that the fallback style is not 
> used as the base style, but rather only as the style to return if none is 
> found. I think this is what FallbackStyle was originally intended for.
> 2. Allow fallback style to maintain its current meaning - that is, as a way 
> to set the base style when "style" is "file" or YAML. In this case, I believe 
> the right thing is to treat FallbackStyle set to "none" as though no fallback 
> style were passed in at all. Concretely, we might want t to modify 
> getPredefinedStyle to return LLVM style when "none" is passed in, instead of 
> what it does now. I personally think this is more confusing, and also 
> introduces more risk.
>
>   Let me know what you think. If we go with option 1, I could fold the fix 
> into this change.


This is a good YAQ, which IMO should be tackled in a separate patch. In this 
patch though, it might be easier to proceed by keeping the original behavior 
and leaving a `FIXME`. In general, reviewers like smaller patches with single 
purpose :)


https://reviews.llvm.org/D28081



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


r290810 - AlignConsecutiveDeclarations type mismatch in documentation

2017-01-02 Thread FIXED-TERM Kammel Fabian (ETAS-PSC/EPE) via cfe-commits
As discussed on the cfe-dev mailing list [1] there is a type mismatch in the 
AlignConsecutiveDeclarations documentation.

Best regards
Fabian

[1] - http://lists.llvm.org/pipermail/cfe-dev/2016-December/051977.html


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


r290811 - Revert "DR1391: Check for implicit conversion sequences for non-dependent function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on

2017-01-02 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Mon Jan  2 05:15:42 2017
New Revision: 290811

URL: http://llvm.org/viewvc/llvm-project?rev=290811&view=rev
Log:
Revert "DR1391: Check for implicit conversion sequences for non-dependent 
function template parameters between deduction and substitution. The idea is to 
accept as many cases as possible, on the basis that substitution failure 
outside the immediate context is much more common during substitution than 
during implicit conversion sequence formation."

This reverts commit r290808, as it broken all ARM and AArch64 test-suite
test: MultiSource/UnitTests/C++11/frame_layout

Also, please, next time, try to write a commit message in according to
our guidelines:

http://llvm.org/docs/DeveloperPolicy.html#commit-messages

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
cfe/trunk/test/SemaCXX/overload-member-call.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=290811&r1=290810&r2=290811&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Mon Jan  2 05:15:42 2017
@@ -531,13 +531,6 @@ namespace clang {
   Ambiguous.construct();
 }
 
-void setAsIdentityConversion(QualType T) {
-  setStandard();
-  Standard.setAsIdentityConversion();
-  Standard.setFromType(T);
-  Standard.setAllToTypes(T);
-}
-
 /// \brief Whether the target is really a std::initializer_list, and the
 /// sequence only represents the worst element conversion.
 bool isStdInitializerListElement() const {
@@ -610,11 +603,6 @@ namespace clang {
 ovl_fail_ext_disabled,
   };
 
-  /// A list of implicit conversion sequences for the arguments of an
-  /// OverloadCandidate.
-  typedef llvm::MutableArrayRef
-  ConversionSequenceList;
-
   /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
   struct OverloadCandidate {
 /// Function - The actual function that this candidate
@@ -639,13 +627,18 @@ namespace clang {
 /// is a surrogate, but only if IsSurrogate is true.
 CXXConversionDecl *Surrogate;
 
-/// The conversion sequences used to convert the function arguments
-/// to the function parameters.
-ConversionSequenceList Conversions;
+/// Conversions - The conversion sequences used to convert the
+/// function arguments to the function parameters, the pointer points to a
+/// fixed size array with NumConversions elements. The memory is owned by
+/// the OverloadCandidateSet.
+ImplicitConversionSequence *Conversions;
 
 /// The FixIt hints which can be used to fix the Bad candidate.
 ConversionFixItGenerator Fix;
 
+/// NumConversions - The number of elements in the Conversions array.
+unsigned NumConversions;
+
 /// Viable - True to indicate that this overload candidate is viable.
 bool Viable;
 
@@ -684,9 +677,9 @@ namespace clang {
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {
-  for (auto &C : Conversions) {
-if (!C.isInitialized()) return false;
-if (C.isAmbiguous()) return true;
+  for (unsigned i = 0, e = NumConversions; i != e; ++i) {
+if (!Conversions[i].isInitialized()) return false;
+if (Conversions[i].isAmbiguous()) return true;
   }
   return false;
 }
@@ -735,7 +728,7 @@ namespace clang {
 SmallVector Candidates;
 llvm::SmallPtrSet Functions;
 
-// Allocator for ConversionSequenceLists. We store the first few
+// Allocator for OverloadCandidate::Conversions. We store the first few
 // elements inline to avoid allocation for small sets.
 llvm::BumpPtrAllocator ConversionSequenceAllocator;
 
@@ -776,45 +769,30 @@ namespace clang {
 size_t size() const { return Candidates.size(); }
 bool empty() const { return Candidates.empty(); }
 
-/// \brief Allocate storage for conversion sequences for NumConversions
-/// conversions.
-ConversionSequenceList
-allocateConversionSequences(unsigned NumConversions) {
-  ImplicitConversionSequence *Conversions;
+/// \brief Add a new candidate with NumConversions conversion sequence 
slots
+/// to the overload set.
+OverloadCandidate &addCandidate(unsigned NumConversions = 0) {
+  Candidates.push_back(OverloadCandidate());
+  OverloadCandidate &C = Candidates.back();
 
   // Assign space from the inline array if there are enough free slots
   // available.
   if 

Re: r290808 - DR1391: Check for implicit conversion sequences for non-dependent function

2017-01-02 Thread Renato Golin via cfe-commits
On 2 January 2017 at 02:42, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Sun Jan  1 20:42:17 2017
> New Revision: 290808
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290808&view=rev
> Log:
> DR1391: Check for implicit conversion sequences for non-dependent function
> template parameters between deduction and substitution. The idea is to accept
> as many cases as possible, on the basis that substitution failure outside
> the immediate context is much more common during substitution than during
> implicit conversion sequence formation.

Hi Richard,

This commit has broken *all* our test-suite bots:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2162

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/772

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/301

http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1634

Are you not receiving emails? It's not the first time that you break
our bots and leave them to dry.

Next time you break a bot, please either revert the commit or contact
the bot owner ASAP to remediate the problem.

If you're having email problems, please contact Galina, copying the
llvm-admin@ mailing list.

I have reverted in r290811.

Also, please, next time, try to write a commit message in according to
our guidelines:

http://llvm.org/docs/DeveloperPolicy.html#commit-messages

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


[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2017-01-02 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:539-542
+llvm::Value *EndArgs[] = {emitUpdateLocation(CGF, Loc), ThreadID};
+CGF.EmitRuntimeCall(
+createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_end_serialized_parallel),
+EndArgs);

ABataev wrote:
> It is better to emit this code as PrePostAction, so it is called upon exit of 
> any cleanup scope
Alexey, do you mean clean up during the execution of the serialized parallel 
region?  Is something like this what you have in mind?  Thanks.

  auto &&SeqGen = [this, Fn, &CapturedVars, &RTLoc, &Loc](CodeGenFunction &CGF,
  PrePostActionTy &) {
auto &&CodeGen = [..](..) {
llvm::Value *Args[] = {RTLoc, ThreadID};
CGF.EmitRuntimeCall(
createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_serialized_parallel),
Args);

llvm::SmallVector OutlinedFnArgs;
OutlinedFnArgs.push_back(
llvm::ConstantPointerNull::get(CGM.Int32Ty->getPointerTo()));
OutlinedFnArgs.push_back(
llvm::ConstantPointerNull::get(CGM.Int32Ty->getPointerTo()));
OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
CGF.EmitCallOrInvoke(Fn, OutlinedFnArgs);
};

RegionCodeGenTy RCG(CodeGen);
CommonActionTy Action(
nullptr, llvm::None,
createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_end_serialized_parallel),
{emitUpdateLocation(CGF, Loc), ThreadID});
RCG.setAction(Action);
RCG(CGF);
  };



https://reviews.llvm.org/D28145



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


[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC

2017-01-02 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a reviewer: chandlerc.
Hahnfeld added a comment.

Ping. Looks like Chandler originally added this logic...


https://reviews.llvm.org/D26244



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


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

2017-01-02 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 82803.
Hahnfeld added a comment.

Resolve errors because of recently enabled warnings


https://reviews.llvm.org/D22452

Files:
  
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Index: test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -72,13 +72,60 @@
 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 @@
 
 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 >= TC.new_time - Sec(1));
+}
+TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
 }
-TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
 }
 }
 
@@ -269,36 +318,26 @@
 const path p = env.create_file("file", 42);
 
 std::error_code ec = GetTestEC();
-file_time_type last_time = last_write_time(p);
 file_time_type new_time = file_time_type::min();
 
 last_write_time(p, new_time, ec);
 file_time_type tt = last_write_time(p);
 
-if (!TimeIsRepresentableAsTimeT(new_time)) {
-TEST_CHECK(ec);
-TEST_CHECK(ec != GetTestEC());
-TEST_CHECK(tt == last_time);
-} else {
+if (TimeIsRepresentableByFilesystem(new_time)) {
 TEST_CHECK(!ec);
 TEST_CHECK(tt >= new_time);
 TEST_CHECK(tt < new_time + Sec(1));
 }
 
 ec = GetTestEC();
 last_write_time(p, Clock::now());
-last_time = last_write_time(p);
 
 new_time = file_time_type::min() + MicroSec(1);
 
 last_write_time(p, new_time, ec);
 tt = last_write_time(p);
 
-if (!TimeIsRepresentableAsTimeT(new_time)) {
-TEST_CHECK(ec);
- 

[PATCH] D27673: [clang-move] Only move used helper declarations.

2017-01-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 82804.
hokein marked 3 inline comments as done.
hokein added a comment.

Add more test cases.


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/HelperDeclRefGraph.cpp
  clang-move/HelperDeclRefGraph.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,388 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// 
+// Test moving used helper function and its transively used functions.
+// 
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+
+// --

[PATCH] D21298: [Clang-tidy] delete null check

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

One more late comment (I should really add a check-list for new checks): this 
check lacks tests with macros and templates with multiple instantiations.

Incorrect handling of templates will likely not manifest in the current state 
of the check, it's brittle, since it relies on the error deduplication 
performed by clang-tidy and it can break easily (e.g. if message text will 
depend on the instantiation or if something changes in the way clang-tidy 
deduplicates messages). However, attempts to apply fixes to code resulting from 
macro expansions is unlikely to result in compilable code.


Repository:
  rL LLVM

https://reviews.llvm.org/D21298



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2017-01-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Awesome! Let's ship it!


https://reviews.llvm.org/D27673



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


[PATCH] D28217: [libc++] Overallocation of am_pm array in locale.cpp

2017-01-02 Thread Daniel C. Dillon via Phabricator via cfe-commits
dcdillon created this revision.
dcdillon added a reviewer: howard.hinnant.
dcdillon added a subscriber: cfe-commits.
Herald added a reviewer: EricWF.

Changed array size from 24 to 2 in init_am_pm() and init_wam_pm()


https://reviews.llvm.org/D28217

Files:
  src/locale.cpp


Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -4640,7 +4640,7 @@
 string*
 init_am_pm()
 {
-static string am_pm[24];
+static string am_pm[2];
 am_pm[0]  = "AM";
 am_pm[1]  = "PM";
 return am_pm;
@@ -4650,7 +4650,7 @@
 wstring*
 init_wam_pm()
 {
-static wstring am_pm[24];
+static wstring am_pm[2];
 am_pm[0]  = L"AM";
 am_pm[1]  = L"PM";
 return am_pm;


Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -4640,7 +4640,7 @@
 string*
 init_am_pm()
 {
-static string am_pm[24];
+static string am_pm[2];
 am_pm[0]  = "AM";
 am_pm[1]  = "PM";
 return am_pm;
@@ -4650,7 +4650,7 @@
 wstring*
 init_wam_pm()
 {
-static wstring am_pm[24];
+static wstring am_pm[2];
 am_pm[0]  = L"AM";
 am_pm[1]  = L"PM";
 return am_pm;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290813 - [OpenMP] Add test cases for the proc_bind and schedule clauses with 'teams distribute parallel for' pragma.

2017-01-02 Thread Kelvin Li via cfe-commits
Author: kli
Date: Mon Jan  2 10:42:11 2017
New Revision: 290813

URL: http://llvm.org/viewvc/llvm-project?rev=290813&view=rev
Log:
[OpenMP] Add test cases for the proc_bind and schedule clauses with 'teams 
distribute parallel for' pragma.

https://reviews.llvm.org/D28205

Added:
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_proc_bind_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_schedule_messages.cpp

Added: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_proc_bind_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_proc_bind_messages.cpp?rev=290813&view=auto
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_proc_bind_messages.cpp 
(added)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_proc_bind_messages.cpp 
Mon Jan  2 10:42:11 2017
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+void foo();
+
+template 
+T tmain(T argc, S **argv) {
+  T i;
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind // expected-error 
{{expected '(' after 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind( // expected-error 
{{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} 
expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind() // expected-error 
{{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(master // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(close), proc_bind(spread) 
// expected-error {{directive '#pragma omp teams distribute parallel for' 
cannot contain more than one 'proc_bind' clause}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(x) // expected-error 
{{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+foo();
+
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(master)
+  for (i = 0; i < argc; ++i)
+foo();
+
+#pragma omp parallel proc_bind(close)
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(spread)
+  for (i = 0; i < argc; ++i)
+foo();
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+  int i;
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind // expected-error 
{{expected '(' after 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind( // expected-error 
{{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} 
expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind() // expected-error 
{{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(master // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(close), proc_bind(spread) 
// expected-error {{directive '#pragma omp teams distribute parallel for' 
cannot contain more than one 'proc_bind' clause}}
+  for (i = 0; i < argc; ++i)
+foo();
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(x) // expected-error 
{{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+foo();
+
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(master)
+  for (i = 0; i < argc; ++i)
+foo();
+
+#pragma omp parallel proc_bind(close)
+#pragma omp target
+#pragma omp teams distribute parallel for proc_bind(spread)
+  for (i = 0; i < argc; ++i)
+foo();
+  return tmain(argc, argv);
+}

Added: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_schedule_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_schedule_messages.cpp?rev=290813&view=auto
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_schedule_messages.cpp 
(added)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_schedule_messages.cpp 
Mon Jan  2 10:42:11 2017
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct

[libcxx] r290823 - locale: update ctype access for MSVC CRT 14+

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 12:41:48 2017
New Revision: 290823

URL: http://llvm.org/viewvc/llvm-project?rev=290823&view=rev
Log:
locale: update ctype access for MSVC CRT 14+

Visual C++ 14 and newer split msvcrt into msvcrt and ucrt with flavours
of the ucrt for different environments.  This changed the access to the
ctype table by introducing the `__pctype_func` and `__pwctype_func`
accessors.  Use this rather than directly accessing `_ctype` which
allows us to be safer in threaded situations by going through the libc
locking.

Modified:
libcxx/trunk/include/support/win32/locale_win32.h
libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/support/win32/locale_win32.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/locale_win32.h?rev=290823&r1=290822&r2=290823&view=diff
==
--- libcxx/trunk/include/support/win32/locale_win32.h (original)
+++ libcxx/trunk/include/support/win32/locale_win32.h Mon Jan  2 12:41:48 2017
@@ -11,8 +11,12 @@
 #ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
 #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
 
+#include 
+
+#if _VC_CRT_MAJOR_VERSION < 14
 // ctype mask table defined in msvcrt.dll
-extern "C" unsigned short  __declspec(dllimport) _ctype[];
+extern "C" unsigned short __declspec(dllimport) _ctype[];
+#endif
 
 #include "support/win32/support.h"
 #include "support/win32/locale_mgmt_win32.h"

Modified: libcxx/trunk/src/locale.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=290823&r1=290822&r2=290823&view=diff
==
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Mon Jan  2 12:41:48 2017
@@ -24,6 +24,9 @@
 #endif
 #include "clocale"
 #include "cstring"
+#if defined(_LIBCPP_MSVCRT)
+#define _CTYPE_DISABLE_MACROS
+#endif
 #include "cwctype"
 #include "__sso_allocator"
 #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
@@ -1108,9 +,13 @@ ctype::classic_table()  _NOEXCEPT
 #elif __sun__
 return __ctype_mask;
 #elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#if _VC_CRT_MAJOR_VERSION < 14
+// This is assumed to be safe, which is a nonsense assumption because we're
+// going to end up dereferencing it later...
 return _ctype+1; // internal ctype mask table defined in msvcrt.dll
-// This is assumed to be safe, which is a nonsense assumption because we're
-// going to end up dereferencing it later...
+#else
+return __pctype_func();
+#endif
 #elif defined(__EMSCRIPTEN__)
 return *__ctype_b_loc();
 #elif defined(_NEWLIB_VERSION)


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


[libcxx] r290824 - chrono: correct the units for the epoch bias

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 12:41:50 2017
New Revision: 290824

URL: http://llvm.org/viewvc/llvm-project?rev=290824&view=rev
Log:
chrono: correct the units for the epoch bias

As pointed out by Howard, this is actually 134774 days (* 24 * 3600),
and therefore seconds, not 100ns units.  Adjust the units to reflect
reality.

Modified:
libcxx/trunk/src/chrono.cpp

Modified: libcxx/trunk/src/chrono.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=290824&r1=290823&r2=290824&view=diff
==
--- libcxx/trunk/src/chrono.cpp (original)
+++ libcxx/trunk/src/chrono.cpp Mon Jan  2 12:41:50 2017
@@ -53,8 +53,7 @@ system_clock::now() _NOEXCEPT
 nanoseconds::period>>;
 
   // The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
-  static _LIBCPP_CONSTEXPR const filetime_duration
-  nt_to_unix_epoch{11644473600};
+  static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
 
   FILETIME ft;
 #if _WIN32_WINNT >= _WIN32_WINNT_WIN8


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


Re: r290808 - DR1391: Check for implicit conversion sequences for non-dependent function

2017-01-02 Thread Richard Smith via cfe-commits
On 2 Jan 2017 3:27 am, "Renato Golin"  wrote:

On 2 January 2017 at 02:42, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Sun Jan  1 20:42:17 2017
> New Revision: 290808
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290808&view=rev
> Log:
> DR1391: Check for implicit conversion sequences for non-dependent function
> template parameters between deduction and substitution. The idea is to
accept
> as many cases as possible, on the basis that substitution failure outside
> the immediate context is much more common during substitution than during
> implicit conversion sequence formation.

Hi Richard,

This commit has broken *all* our test-suite bots:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2162

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/772

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/301

http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1634

Are you not receiving emails? It's not the first time that you break
our bots and leave them to dry.

Next time you break a bot, please either revert the commit or contact
the bot owner ASAP to remediate the problem.

If you're having email problems, please contact Galina, copying the
llvm-admin@ mailing list.


I'm sorry about that. I'm looking into my mail filters; it looks like the
problem is entirety on my end.

I have reverted in r290811.


Thank you, and sorry for the trouble.

Also, please, next time, try to write a commit message in according to
our guidelines:

http://llvm.org/docs/DeveloperPolicy.html#commit-messages


The separate title/description part, or do you want more explanation of
what DR1391 is too?


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


[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2017-01-02 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

Thanks for working on these. imo these are false positives.




Comment at: lib/AST/Expr.cpp:1893
+
+  const IntegerLiteral *lit = dyn_cast(getInit(0));
+  if (!lit) {

I would recommend capital first letter for this variable



Comment at: lib/AST/Expr.cpp:1894
+  const IntegerLiteral *lit = dyn_cast(getInit(0));
+  if (!lit) {
+return false;

I suggest a single line:

```
  return Lit && Lit->getValue() == 0;
```



https://reviews.llvm.org/D28148



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


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

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 14:15:33 2017
New Revision: 290831

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

In the previous fix I used a PMF type as a semi-safe bool type in C++03.
However immediately after committing I realized clang offered explicit
conversion operators as an extension. This patch removes the old fix and
enables _LIBCPP_EXPLICIT using __has_extension instead.

This change also affects the following other classes, which have
'_LIBCPP_EXPLICIT operator bool()'.

* shared_ptr
* unique_ptr
* error_condition
* basic_ios
* function (already C++11 only)
* istream::sentry
* experimental::string_view.

In all of the above cases I believe it is safe to enable the extension, except
in the experimental::string_view case. There seem to be some Clang bugs
affecting the experimental::string_view conversion to std::basic_string. To
work around that I manually disabled _LIBCPP_EXPLICIT in that case.

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

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290831&r1=290830&r2=290831&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan  2 14:15:33 2017
@@ -727,7 +727,7 @@ template  struct __static_asse
 #define _NOALIAS
 #endif
 
-#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
+#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC 
versions
 #   define _LIBCPP_EXPLICIT explicit
 #else

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

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


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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 82814.
amaiorano added a comment.

Reverted the FallbackStyle code and added a FIXME as @ioeric suggested. I'll 
fix the fallback style "none" bug in a separate change.


https://reviews.llvm.org/D28081

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Tooling/Refactoring.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestObjC.cpp

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -69,15 +69,15 @@
 };
 
 TEST_F(FormatTestObjC, DetectsObjCInHeaders) {
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+  Style = *getStyle("LLVM", "a.h", "none", "@interface\n"
   "- (id)init;");
   EXPECT_EQ(FormatStyle::LK_ObjC, Style.Language);
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+  Style = *getStyle("LLVM", "a.h", "none", "@interface\n"
   "+ (id)init;");
   EXPECT_EQ(FormatStyle::LK_ObjC, Style.Language);
 
   // No recognizable ObjC.
-  Style = getStyle("LLVM", "a.h", "none", "void f() {}");
+  Style = *getStyle("LLVM", "a.h", "none", "void f() {}");
   EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);
 }
 
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10945,22 +10945,55 @@
   ASSERT_TRUE(
   FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style1 = getStyle("file", "/a/.clang-format", "Google", "", &FS);
-  ASSERT_EQ(Style1, getLLVMStyle());
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(*Style1, getLLVMStyle());
 
   // Test 2: fallback to default.
   ASSERT_TRUE(
   FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS);
-  ASSERT_EQ(Style2, getMozillaStyle());
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getMozillaStyle());
 
   // Test 3: format file in parent directory.
   ASSERT_TRUE(
   FS.addFile("/c/.clang-format", 0,
  llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
   ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,
  llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", "", &FS);
-  ASSERT_EQ(Style3, getGoogleStyle());
+  ASSERT_TRUE((bool)Style3);
+  ASSERT_EQ(*Style3, getGoogleStyle());
+
+  // Test 4: error on invalid fallback style
+  auto Style4 = getStyle("file", "a.h", "KungFu", "", &FS);
+  ASSERT_FALSE((bool)Style4);
+  auto ErrorMsg4 = llvm::toString(Style4.takeError());
+  ASSERT_GT(ErrorMsg4.length(), 0);
+
+  // Test 5: error on invalid yaml on command line
+  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style5);
+  auto ErrorMsg5 = llvm::toString(Style5.takeError());
+  ASSERT_GT(ErrorMsg5.length(), 0);
+
+  // Test 6: error on invalid style
+  auto Style6 = getStyle("KungFu", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style6);
+  auto ErrorMsg6 = llvm::toString(Style6.takeError());
+  ASSERT_GT(ErrorMsg6.length(), 0);
+
+  // Test 7: found config file, error on parsing it
+  ASSERT_TRUE(
+  FS.addFile("/d/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM\n"
+  "InvalidKey: InvalidValue")));
+  ASSERT_TRUE(
+  FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style7 = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style7);
+  auto ErrorMsg7 = llvm::toString(Style7.takeError());
+  ASSERT_GT(ErrorMsg7.length(), 0);
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -249,8 +249,14 @@
   if (fillRanges(Code.get(), Ranges))
 return true;
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
-  FormatStyle FormatStyle =
+
+  llvm::Expected FormatStyleOrError =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+  if (!FormatStyleOrError) {
+llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
+return true;
+  }
+  FormatStyle FormatStyle = *FormatStyleOrError;
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle.SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;
@@ -334,10 +340,16 @@
 cl::PrintHelpMessage();
 
   if (DumpConfig) {
-std::string Config =
-clang::format::configurationAsText(clang::format::getStyle(
+llvm::Expe

[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

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

Looks good to go once Daniel's and my comments are addressed. Thank you.




Comment at: lib/AST/Expr.cpp:1887
+bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions &LangOpts) 
const {
+  assert(!getSyntacticForm() && "only test syntactic form as zero 
initializer");
+

`!isSyntacticForm()` would be preferable here instead of `!getSyntacticForm()`.


https://reviews.llvm.org/D28148



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


[libcxx] r290835 - win32: temporarily disable setting locale on 14+

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 15:09:16 2017
New Revision: 290835

URL: http://llvm.org/viewvc/llvm-project?rev=290835&view=rev
Log:
win32: temporarily disable setting locale on 14+

The locale structures have been made opaque in CRT 14+.  This currently
prevents building libc++ for Windows.  We can re-enable this in the
future when we have replicated the structure to access the private field
for the name (unless there exists a better supported mechanism to query
the name of a locale given the locale_t).

Modified:
libcxx/trunk/src/support/win32/locale_win32.cpp

Modified: libcxx/trunk/src/support/win32/locale_win32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/win32/locale_win32.cpp?rev=290835&r1=290834&r2=290835&view=diff
==
--- libcxx/trunk/src/support/win32/locale_win32.cpp (original)
+++ libcxx/trunk/src/support/win32/locale_win32.cpp Mon Jan  2 15:09:16 2017
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+#include 
+
 typedef _VSTD::remove_pointer::type __locale_struct;
 typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
 
@@ -29,7 +31,9 @@ locale_t uselocale( locale_t newloc )
 // uselocale sets the thread's locale by definition, so unconditionally 
use thread-local locale
 _configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
 // uselocale sets all categories
+#if _VC_CRT_MAJOR_VERSION < 14
 setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
+#endif
 // uselocale returns the old locale_t
 return old_locale;
 }


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


[libcxx] r290836 - build: make cross-compiling to Windows work on Linux

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 15:09:19 2017
New Revision: 290836

URL: http://llvm.org/viewvc/llvm-project?rev=290836&view=rev
Log:
build: make cross-compiling to Windows work on Linux

Disable the manifest bundling on Windows when cross-compiling on
not-Windows.  With this, it is possible to execute the link command from
CMake which will use cmake to invoke the manifest tool to generate a
manifest and pass that to the linker.

Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290836&r1=290835&r2=290836&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Jan  2 15:09:19 2017
@@ -181,6 +181,13 @@ if (LIBCXX_ENABLE_SHARED)
   SOVERSION "${LIBCXX_ABI_VERSION}"
   )
   list(APPEND LIBCXX_TARGETS "cxx_shared")
+  if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL 
"Windows")
+# Since we most likely do not have a mt.exe replacement, disable the
+# manifest bundling.  This allows a normal cmake invocation to pass which
+# will attempt to use the manifest tool to generate the bundled manifest
+set_target_properties(cxx_shared PROPERTIES
+  APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO")
+  endif()
 endif()
 
 # Build the static library.


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


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added inline comments.



Comment at: src/typeinfo.cpp:28-32
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037;
+  static constexpr const size_t fnv_prime = 10995116282110;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261;
+  static constexpr const size_t fnv_prime = 16777619;

majnemer wrote:
> majnemer wrote:
> > Why make these static? Seems strange to use that storage duration.
> These literals are ill-formed, I think you need a ULL suffix here.
Oh, just to ensure that they are handled as literal constants.  I can drop the 
static if you like, since the compiler should do the right thing anyways.


Repository:
  rL LLVM

https://reviews.llvm.org/D28212



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


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82815.
compnerd added a comment.

Add suffixes


Repository:
  rL LLVM

https://reviews.llvm.org/D28212

Files:
  include/typeinfo
  src/typeinfo.cpp

Index: src/typeinfo.cpp
===
--- src/typeinfo.cpp
+++ src/typeinfo.cpp
@@ -15,6 +15,44 @@
 
 #include "typeinfo"
 
+#if defined(_WIN32)
+#include 
+
+const char *std::type_info::name(std::type_info::data *__data) {
+  // TODO(compnerd) cache demangled &__data.__decorated_name[1]
+  return &__data->__decorated_name[1];
+}
+
+size_t std::type_info::hash(const std::type_info::data *__data) {
+#if defined(_WIN64)
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037ull;
+  static constexpr const size_t fnv_prime = 10995116282110ull;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261ull;
+  static constexpr const size_t fnv_prime = 16777619ull;
+#endif
+
+  size_t value = fnv_offset_basis;
+  for (const char *c = &__data->__decorated_name[1]; *c; ++c) {
+value ^= static_cast(static_cast(*c));
+value *= fnv_prime;
+  }
+
+#if defined(_WIN64)
+  value ^= value >> 32;
+#endif
+
+  return value;
+}
+
+int std::type_info::compare(const std::type_info::data *__lhs,
+const std::type_info::data *__rhs) {
+  if (__lhs == __rhs)
+return 0;
+  return strcmp(&__lhs->__decorated_name[1], &__rhs->__decorated_name[1]);
+}
+#endif
+
 #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
 
 std::type_info::~type_info()
Index: include/typeinfo
===
--- include/typeinfo
+++ include/typeinfo
@@ -72,6 +72,49 @@
 namespace std  // purposefully not using versioning namespace
 {
 
+#if defined(_WIN32)
+class _LIBCPP_EXCEPTION_ABI type_info
+{
+  type_info & operator=(const type_info &) _LIBCPP_EQUAL_DELETE;
+  type_info (const type_info &) _LIBCPP_EQUAL_DELETE;
+
+  mutable struct data {
+const char *__undecorated_name;
+const char __decorated_name[1];
+  } __data;
+
+  static const char *name(type_info::data *__data);
+  static size_t hash(const type_info::data *__data);
+  static int compare(const type_info::data *__l, const type_info::data *__r);
+
+public:
+  virtual ~type_info() _NOEXCEPT;
+
+  _LIBCPP_INLINE_VISIBILITY
+  const char *name() const _NOEXCEPT {
+return name(&__data);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool before(const type_info &__arg) const _NOEXCEPT {
+return compare(&__data, &__arg.__data) < 0;
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  size_t hash_code() const _NOEXCEPT {
+return hash(&__data);
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  bool operator==(const type_info &__arg) const _NOEXCEPT {
+return compare(&__data, &__arg.__data) == 0;
+  }
+
+  bool operator!=(const type_info &__arg) const _NOEXCEPT {
+return compare(&__data, &__arg.__data) != 0;
+  }
+};
+#else
 class _LIBCPP_EXCEPTION_ABI type_info
 {
 type_info& operator=(const type_info&);
@@ -148,6 +191,7 @@
 {return __builtin_strcmp(name(), __arg.name());}
 #endif
 };
+#endif
 
 class _LIBCPP_EXCEPTION_ABI bad_cast
 : public exception
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Some nits. Some is almost good :)

BTW, do you have clang-tools-extra in your source tree? There are also some 
references in the subtree to the changed interface. It would be nice if you 
could also fix them in a separate patch and commit these two patches together 
(I mean, within a short period of time) so that you wouldn't break build bots.

References should be found in these files:

  extra/change-namespace/ChangeNamespace.cpp
  extra/clang-move/ClangMove.cpp
  extra/include-fixer/tool/ClangIncludeFixer.cpp 
  extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  extra/clang-tidy/ClangTidy.cpp

Thanks!




Comment at: lib/Format/Format.cpp:424
 
+llvm::Error make_string_error(const llvm::Twine &Message) {
+  return llvm::make_error(Message,

Maybe make this `inline`?



Comment at: lib/Format/Format.cpp:1901
+  // FIXME: If FallbackStyle is explicitly "none", this effectively disables
+  // replacements. Fix this by setting a separate FormatStyle variable and
+  // returning it when we mean to return the fallback style explicitly.

I'd state the problem with a specific solution only if I am sure it is the best 
solution.



Comment at: lib/Format/Format.cpp:1955
   FS->getBufferForFile(ConfigFile.str());
   if (std::error_code EC = Text.getError()) {
+return make_string_error(EC.message());

Redundant braces. Same below.



Comment at: lib/Tooling/Refactoring.cpp:86
 
-format::FormatStyle CurStyle = format::getStyle(Style, FilePath, "LLVM");
+llvm::Expected FormatStyleOrError =
+format::getStyle(Style, FilePath, "LLVM");

There is a `NewReplacements` below which is also `llvm::Expected`. 
`FormatStyleOrError` is  a fine name, but to be we have been naming `Expected` 
types without `OrError` postfix, so I'd go without `OrError` postfix for 
consistency append `OrError` postfix to other expected variables. Personally, I 
find expected variables without `OrError` postfix easier to understand, 
especially in error checking. For example, `if (!FormatStyleOrError)` is a bit 
awkward to read while `if (!FormatStyle)` is more straight-forward IMO.

Same for other changes.



Comment at: unittests/Format/FormatTest.cpp:10972
+  auto ErrorMsg4 = llvm::toString(Style4.takeError());
+  ASSERT_GT(ErrorMsg4.length(), 0);
+

This is a bit strange... Just `llvm::consumeError(Style.takeError())` if you 
don't bother to check the error message, e.g. with `llvm::StringRef::starswith` 
or RE match.



Comment at: unittests/Format/FormatTestObjC.cpp:72
 TEST_F(FormatTestObjC, DetectsObjCInHeaders) {
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+  Style = *getStyle("LLVM", "a.h", "none", "@interface\n"
   "- (id)init;");

amaiorano wrote:
> In these tests, I'm assuming getStyle returns a valid FormatSyle. I could add 
> the same types of validation as in the FormatStyle.GetStyleOfFile tests.
Please add proper checking as above for returned values.


https://reviews.llvm.org/D28081



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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Oops, sorry about the typo. I mean, code is almost good! :)


https://reviews.llvm.org/D28081



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


[PATCH] D28189: Extend documentation of how to test clang-tidy checks.

2017-01-02 Thread James Dennett via Phabricator via cfe-commits
jdennett marked 2 inline comments as done.
jdennett added a comment.

Thanks for the review.  I've address your comments, and will check over the 
(presumed-final) diff before submitting.




Comment at: docs/clang-tidy/index.rst:558
+typically the basic `CHECK` forms (`CHECK-MESSAGES` and `CHECK-FIXES`)
+are sufficient for matcher tests.  Note that the `FileCheck`
+documentation mostly assumes the default prefix (`CHECK`), and hence

alexfh wrote:
> I'm not sure the term "matcher tests" is used anywhere else in our 
> documentation. And it doesn't seem obvious to me either (if it refers to AST 
> matchers, then it's just an implementation detail of clang-tidy checks, if it 
> refers to the check patterns, then it's not a commonly used term for those 
> either). I don't know what would be a good short replacement, maybe 
> "clang-tidy lit tests" or just "clang-tidy tests".
I went with clang-tidy tests.  (The "matcher test" references are because I was 
thinking about some new matchers such as `argumentsAre(arg1, ..., argn)` at the 
same time, and didn't manage to do a complete context switch when working on 
these docs.  Thanks for catching that.)


https://reviews.llvm.org/D28189



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


[PATCH] D28189: Extend documentation of how to test clang-tidy checks.

2017-01-02 Thread James Dennett via Phabricator via cfe-commits
jdennett updated this revision to Diff 82818.
jdennett added a comment.

Addressed review comments: double-backtick quoting, underscores for references
to FileCheck, and change "matcher tests" to "clang-tidy tests".


https://reviews.llvm.org/D28189

Files:
  docs/clang-tidy/index.rst


Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -546,7 +546,26 @@
 The ``check_clang_tidy.py`` script provides an easy way to test both
 diagnostic messages and fix-its. It filters out ``CHECK`` lines from the test
 file, runs :program:`clang-tidy` and verifies messages and fixes with two
-separate `FileCheck`_ invocations. To use the script, put a .cpp file with the
+separate `FileCheck`_ invocations: once with FileCheck's directive
+prefix set to ``CHECK-MESSAGES``, validating the diagnostic messages,
+and once with the directive prefix set to ``CHECK-FIXES``, running
+against the fixed code (i.e., the code after generated fixits are
+applied). In particular, ``CHECK-FIXES:`` can be used to check
+that code was not modified by fixits, by checking that it is present
+unchanged in the fixed code.  The full set of `FileCheck`_ directives
+is available (e.g., ``CHECK-MESSAGES-SAME:``, ``CHECK-MESSAGES-NOT:``), though
+typically the basic ``CHECK`` forms (``CHECK-MESSAGES`` and ``CHECK-FIXES``)
+are sufficient for clang-tidy tests.  Note that the `FileCheck`_
+documentation mostly assumes the default prefix (``CHECK``), and hence
+describes the directive as ``CHECK:``, ``CHECK-SAME:``, ``CHECK-NOT:``, etc.
+Replace ``CHECK`` by either ``CHECK-FIXES`` or ``CHECK-MESSAGES`` for
+clang-tidy tests.
+
+An additional check enabled by ``check_clang_tidy.py`` ensures that
+if `CHECK-MESSAGES:` is used in a file then every warning or error
+must have an associated CHECK in that file.
+
+To use the ``check_clang_tidy.py`` script, put a .cpp file with the
 appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use
 ``CHECK-MESSAGES:`` and ``CHECK-FIXES:`` lines to write checks against
 diagnostic messages and fixed code.


Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -546,7 +546,26 @@
 The ``check_clang_tidy.py`` script provides an easy way to test both
 diagnostic messages and fix-its. It filters out ``CHECK`` lines from the test
 file, runs :program:`clang-tidy` and verifies messages and fixes with two
-separate `FileCheck`_ invocations. To use the script, put a .cpp file with the
+separate `FileCheck`_ invocations: once with FileCheck's directive
+prefix set to ``CHECK-MESSAGES``, validating the diagnostic messages,
+and once with the directive prefix set to ``CHECK-FIXES``, running
+against the fixed code (i.e., the code after generated fixits are
+applied). In particular, ``CHECK-FIXES:`` can be used to check
+that code was not modified by fixits, by checking that it is present
+unchanged in the fixed code.  The full set of `FileCheck`_ directives
+is available (e.g., ``CHECK-MESSAGES-SAME:``, ``CHECK-MESSAGES-NOT:``), though
+typically the basic ``CHECK`` forms (``CHECK-MESSAGES`` and ``CHECK-FIXES``)
+are sufficient for clang-tidy tests.  Note that the `FileCheck`_
+documentation mostly assumes the default prefix (``CHECK``), and hence
+describes the directive as ``CHECK:``, ``CHECK-SAME:``, ``CHECK-NOT:``, etc.
+Replace ``CHECK`` by either ``CHECK-FIXES`` or ``CHECK-MESSAGES`` for
+clang-tidy tests.
+
+An additional check enabled by ``check_clang_tidy.py`` ensures that
+if `CHECK-MESSAGES:` is used in a file then every warning or error
+must have an associated CHECK in that file.
+
+To use the ``check_clang_tidy.py`` script, put a .cpp file with the
 appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use
 ``CHECK-MESSAGES:`` and ``CHECK-FIXES:`` lines to write checks against
 diagnostic messages and fixed code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r290837 - build: tweak macros for Windows build

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 15:40:17 2017
New Revision: 290837

URL: http://llvm.org/viewvc/llvm-project?rev=290837&view=rev
Log:
build: tweak macros for Windows build

Move the windows specific macro definitions for compiling c++ into the
target.  Add a number of newer options that are necessary to properly
build libc++ for windows.  This ensures that we do not accidentally
autolink msvcprt (Microsoft's C++ runtime library), do not define linker
pragmas which are msvcprt specific, and do not accidentally encode the
incorrect version of the msvc compatibility version.

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290837&r1=290836&r2=290837&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan  2 15:40:17 2017
@@ -442,9 +442,6 @@ if (LIBCXX_ENABLE_ASSERTIONS)
   define_if_not(MSVC -D_DEBUG)
 endif()
 
-# Feature flags ===
-define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
-
 # Modules flags ===
 # FIXME The libc++ sources are fundamentally non-modular. They need special
 # versions of the headers in order to provide C++03 and legacy ABI definitions.

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290837&r1=290836&r2=290837&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Jan  2 15:40:17 2017
@@ -161,6 +161,28 @@ split_list(LIBCXX_LINK_FLAGS)
 
 # Add a object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
+if(WIN32 AND NOT MINGW)
+  target_compile_definitions(cxx_objects
+ PRIVATE
+   # Ignore the -MSC_VER mismatch, as we may build
+   # with a different compatibility version.
+   _ALLOW_MSC_VER_MISMATCH
+   # Don't check the msvcprt iterator debug levels
+   # as we will define the iterator types; libc++
+   # uses a different macro to identify the debug
+   # level.
+   _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
+   # We are building the c++ runtime, don't pull in
+   # msvcprt.
+   _CRTBLD
+   # Don't warn on the use of "deprecated"
+   # "insecure" functions which are standards
+   # specified.
+   _CRT_SECURE_NO_WARNINGS
+   # Use the ISO conforming behaviour for 
conversion
+   # in printf, scanf.
+   _CRT_STDIO_ISO_WIDE_SPECIFIERS)
+endif()
 
 set_target_properties(cxx_objects
   PROPERTIES


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


[PATCH] D28166: Properly merge K&R functions that have attributes

2017-01-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 82816.
aaron.ballman added a comment.

I've updated the patch to not hard code the type adjustments, but instead added 
`Type::getAsAdjusted()` and `TypeLoc::getAsAdjusted()`.

This patch has one broken test case, but I do not think the test case was being 
triggered as its author expected. The failing test is 
clang\test\CodeGen\microsoft-call-conv-x64.c, and the failure is that the call 
to `f7()` does not match the CHECK line. Instead of `call void @f7(i32 0)`, you 
now get `call void bitcast (void (i32)* @f7 to void (i64)*)(i64 0)`.

Sema::BuildDeclarationNameExpr() has some code to check for K&R-style functions 
and ensuring that we lose prototype information in accordance with C DR 316. 
However, under the code prior to this patch, the predicate was false for this 
test case because `FD->hasPrototype()` would return true despite the function 
being a K&R function with no prototype. Since we corrected that behavior 
`FD->hasPrototype()` now returns false, prompting the adjustment, which alters 
the IR we generate. However, I'm not certain whether the altered IR is desired 
or not, so advice on this is welcome.


https://reviews.llvm.org/D28166

Files:
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  lib/Sema/SemaDecl.cpp
  test/Sema/knr-def-call.c
  test/Sema/warn-strict-prototypes.c

Index: test/Sema/warn-strict-prototypes.c
===
--- test/Sema/warn-strict-prototypes.c
+++ test/Sema/warn-strict-prototypes.c
@@ -60,3 +60,8 @@
 // K&R function definition with previous prototype declared is not diagnosed.
 void foo11(int p, int p2);
 void foo11(p, p2) int p; int p2; {}
+
+// PR31020
+void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
+  short d;
+{}
Index: test/Sema/knr-def-call.c
===
--- test/Sema/knr-def-call.c
+++ test/Sema/knr-def-call.c
@@ -39,3 +39,9 @@
   proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
   (&proto)(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
 }
+
+// PR31020
+void func(short d) __attribute__((cdecl)); // expected-note{{previous declaration is here}}
+void __attribute__((cdecl)) func(d)
+  short d; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
+{}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7458,11 +7458,12 @@
 // Determine whether the function was written with a
 // prototype. This true when:
 //   - there is a prototype in the declarator, or
-//   - the type R of the function is some kind of typedef or other reference
-// to a type name (which eventually refers to a function type).
+//   - the type R of the function is some kind of typedef or other non-
+// attributed reference to a type name (which eventually refers to a
+// function type).
 bool HasPrototype =
   (D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) ||
-  (!isa(R.getTypePtr()) && R->isFunctionProtoType());
+  (!R->getAsAdjusted() && R->isFunctionProtoType());
 
 NewFD = FunctionDecl::Create(SemaRef.Context, DC,
  D.getLocStart(), NameInfo, R,
@@ -11950,7 +11951,7 @@
   !LangOpts.CPlusPlus) {
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
-FunctionTypeLoc FTL = TL.castAs();
+FunctionTypeLoc FTL = TL.getAsAdjusted();
 Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1;
   }
 }
Index: include/clang/AST/TypeLoc.h
===
--- include/clang/AST/TypeLoc.h
+++ include/clang/AST/TypeLoc.h
@@ -70,6 +70,26 @@
 return t;
   }
 
+  /// \brief Convert to the specified TypeLoc type, returning a null TypeLoc if
+  /// this TypeLock is not of the desired type. It will consider type
+  /// adjustments from a type that wad written as a T to another type that is
+  /// still canonically a T (ignores parens, attributes, elaborated types, etc).
+  template 
+  T getAsAdjusted() const {
+TypeLoc Cur = *this;
+while (!T::isKind(Cur)) {
+  if (auto PTL = Cur.getAs())
+Cur = PTL.getInnerLoc();
+  else if (auto ATL = Cur.getAs())
+Cur = ATL.getModifiedLoc();
+  else if (auto ETL = Cur.getAs())
+Cur = ETL.getNamedTypeLoc();
+  else
+break;
+}
+return Cur.getAs();
+  }
+
   /// The kinds of TypeLocs.  Equivalent to the Type::TypeClass enum,
   /// except it also defines a Qualified enum that corresponds to the
   /// QualifiedLoc cl

[clang-tools-extra] r290838 - Extend documentation of how to test clang-tidy checks.

2017-01-02 Thread James Dennett via cfe-commits
Author: jdennett
Date: Mon Jan  2 15:45:34 2017
New Revision: 290838

URL: http://llvm.org/viewvc/llvm-project?rev=290838&view=rev
Log:
Extend documentation of how to test clang-tidy checks.

Summary:
The documentation assumed expertise with FileCheck; many clang-tidy check
authors may not have significant exposure to FileCheck, and so it's worth
spending a few more words here to spell things out.

Reviewers: alexfh

Subscribers: cfe-commits, JDevlieghere

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=290838&r1=290837&r2=290838&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Mon Jan  2 15:45:34 2017
@@ -546,7 +546,26 @@ diagnostic messages.
 The ``check_clang_tidy.py`` script provides an easy way to test both
 diagnostic messages and fix-its. It filters out ``CHECK`` lines from the test
 file, runs :program:`clang-tidy` and verifies messages and fixes with two
-separate `FileCheck`_ invocations. To use the script, put a .cpp file with the
+separate `FileCheck`_ invocations: once with FileCheck's directive
+prefix set to ``CHECK-MESSAGES``, validating the diagnostic messages,
+and once with the directive prefix set to ``CHECK-FIXES``, running
+against the fixed code (i.e., the code after generated fixits are
+applied). In particular, ``CHECK-FIXES:`` can be used to check
+that code was not modified by fixits, by checking that it is present
+unchanged in the fixed code.  The full set of `FileCheck`_ directives
+is available (e.g., ``CHECK-MESSAGES-SAME:``, ``CHECK-MESSAGES-NOT:``), though
+typically the basic ``CHECK`` forms (``CHECK-MESSAGES`` and ``CHECK-FIXES``)
+are sufficient for clang-tidy tests.  Note that the `FileCheck`_
+documentation mostly assumes the default prefix (``CHECK``), and hence
+describes the directive as ``CHECK:``, ``CHECK-SAME:``, ``CHECK-NOT:``, etc.
+Replace ``CHECK`` by either ``CHECK-FIXES`` or ``CHECK-MESSAGES`` for
+clang-tidy tests.
+
+An additional check enabled by ``check_clang_tidy.py`` ensures that
+if `CHECK-MESSAGES:` is used in a file then every warning or error
+must have an associated CHECK in that file.
+
+To use the ``check_clang_tidy.py`` script, put a .cpp file with the
 appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use
 ``CHECK-MESSAGES:`` and ``CHECK-FIXES:`` lines to write checks against
 diagnostic messages and fixed code.


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


[libcxx] r290839 - Fix configuring and building libc++ w/o an ABI library.

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 15:58:06 2017
New Revision: 290839

URL: http://llvm.org/viewvc/llvm-project?rev=290839&view=rev
Log:
Fix configuring and building libc++ w/o an ABI library.

Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits
of the C++ STL. However we also support building w/o an ABI library entirely.
This patch fixes building libc++ w/o an ABI library (and incorporates the
`~type_info()` fix in D28211).

The main changes in this patch are:

1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean 
"default".
2) Fix CMake bits which treated "none" as "default" on OS X.
3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`.
4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined.

Unfortunately this patch doesn't help clean up the macro mess that we use to
configure for different ABI libraries.

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/lib/abi/CMakeLists.txt
libcxx/trunk/src/exception.cpp
libcxx/trunk/src/new.cpp
libcxx/trunk/src/stdexcept.cpp
libcxx/trunk/src/typeinfo.cpp

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290839&r1=290838&r2=290839&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan  2 15:58:06 2017
@@ -87,13 +87,13 @@ if (NOT LIBCXX_ENABLE_SHARED AND NOT LIB
 endif()
 
 # ABI Library options -
-set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
-"Specify C++ ABI library to use." FORCE)
-set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
+set(LIBCXX_CXX_ABI "default" CACHE STRING
+"Specify C++ ABI library to use.")
+set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++)
 set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
 
 # Setup the default options if LIBCXX_CXX_ABI is not specified.
-if (NOT LIBCXX_CXX_ABI)
+if (LIBCXX_CXX_ABI STREQUAL "default")
   find_path(
 LIBCXX_LIBCXXABI_INCLUDES_INTERNAL
 cxxabi.h
@@ -107,7 +107,7 @@ if (NOT LIBCXX_CXX_ABI)
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_INTREE 1)
   else()
-set(LIBCXX_CXX_ABI_LIBNAME "none")
+set(LIBCXX_CXX_ABI_LIBNAME "default")
   endif()
 else()
   set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
@@ -125,6 +125,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
 if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
   AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
+  AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
   AND PYTHONINTERP_FOUND
   AND LIBCXX_ENABLE_SHARED)
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=290839&r1=290838&r2=290839&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Mon Jan  2 15:58:06 2017
@@ -102,7 +102,11 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STRE
   setup_abi_lib("-DLIBCXXRT"
 "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
 )
-elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
+elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
+  list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
+elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
+  # Nothing TODO
+else()
   message(FATAL_ERROR
 "Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are "
 "supported for c++ abi."

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290839&r1=290838&r2=290839&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Jan  2 15:58:06 2017
@@ -34,7 +34,7 @@ add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
 if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
-   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
+   LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"))
   set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
 endif()
 

Modified: libcxx/trunk/lib/abi/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CMakeLists.txt?rev=290839&r1=290838&r2=290839&view=diff
==
--- libcxx/trunk/lib/abi/CMakeLists.txt (original)
+++ libcxx/

[PATCH] D28211: typeinfo: provide a destructor for type_info

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

I committed the fix needed for this as part of a larger change in r290839. 
Please abandon this revision.


Repository:
  rL LLVM

https://reviews.llvm.org/D28211



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


[PATCH] D28211: typeinfo: provide a destructor for type_info

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd abandoned this revision.
compnerd added a comment.

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D28211



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


[libcxx] r290840 - Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 16:17:51 2017
New Revision: 290840

URL: http://llvm.org/viewvc/llvm-project?rev=290840&view=rev
Log:
Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.

Currently libc++ compiles a special version of error_category()
into the dylib. This definition is no longer needed, and doesn't
work on Windows due to dllimport/dllexport semantics.

For those reasons this patch introduces an option to
disable/enable this definition. By default the definition
is provided in ABI v1 except on windows. This patch
also addresses D28210.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/system_error
libcxx/trunk/src/system_error.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290840&r1=290839&r2=290840&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan  2 16:17:51 2017
@@ -53,6 +53,10 @@
 // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
 #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
 #elif _LIBCPP_ABI_VERSION == 1
+#if !defined(_WIN32)
+// Enable compiling a definition of error_category() into the libc++ dylib.
+#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
+#endif
 // Feature macros for disabling pre ABI v1 features. All of these options
 // are deprecated.
 #if defined(__FreeBSD__)

Modified: libcxx/trunk/include/system_error
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/system_error?rev=290840&r1=290839&r2=290840&view=diff
==
--- libcxx/trunk/include/system_error (original)
+++ libcxx/trunk/include/system_error Mon Jan  2 16:17:51 2017
@@ -384,7 +384,8 @@ class _LIBCPP_TYPE_VIS error_category
 public:
 virtual ~error_category() _NOEXCEPT;
 
-#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
+#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \
+defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
 error_category() _NOEXCEPT;
 #else
 _LIBCPP_ALWAYS_INLINE

Modified: libcxx/trunk/src/system_error.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_error.cpp?rev=290840&r1=290839&r2=290840&view=diff
==
--- libcxx/trunk/src/system_error.cpp (original)
+++ libcxx/trunk/src/system_error.cpp Mon Jan  2 16:17:51 2017
@@ -29,9 +29,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // class error_category
 
+#if defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
 error_category::error_category() _NOEXCEPT
 {
 }
+#endif
 
 error_category::~error_category() _NOEXCEPT
 {


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


[PATCH] D28210: system_error: inline error_category ctor on Win32

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

I committed a different fix for this patch in r290840.

Instead of just fixing this on Windows it makes the removal of this definition 
an ABI option, which it then disables on Windows by default.


Repository:
  rL LLVM

https://reviews.llvm.org/D28210



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


[libcxx] r290841 - Revert r290839 - Fix configuring and building libc++ w/o an ABI library

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 16:27:45 2017
New Revision: 290841

URL: http://llvm.org/viewvc/llvm-project?rev=290841&view=rev
Log:
Revert r290839 - Fix configuring and building libc++ w/o an ABI library

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/lib/abi/CMakeLists.txt
libcxx/trunk/src/exception.cpp
libcxx/trunk/src/new.cpp
libcxx/trunk/src/stdexcept.cpp
libcxx/trunk/src/typeinfo.cpp

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290841&r1=290840&r2=290841&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan  2 16:27:45 2017
@@ -87,13 +87,13 @@ if (NOT LIBCXX_ENABLE_SHARED AND NOT LIB
 endif()
 
 # ABI Library options -
-set(LIBCXX_CXX_ABI "default" CACHE STRING
-"Specify C++ ABI library to use.")
-set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++)
+set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
+"Specify C++ ABI library to use." FORCE)
+set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
 set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
 
 # Setup the default options if LIBCXX_CXX_ABI is not specified.
-if (LIBCXX_CXX_ABI STREQUAL "default")
+if (NOT LIBCXX_CXX_ABI)
   find_path(
 LIBCXX_LIBCXXABI_INCLUDES_INTERNAL
 cxxabi.h
@@ -107,7 +107,7 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_INTREE 1)
   else()
-set(LIBCXX_CXX_ABI_LIBNAME "default")
+set(LIBCXX_CXX_ABI_LIBNAME "none")
   endif()
 else()
   set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
@@ -125,7 +125,6 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
 if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
   AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
-  AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
   AND PYTHONINTERP_FOUND
   AND LIBCXX_ENABLE_SHARED)
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=290841&r1=290840&r2=290841&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Mon Jan  2 16:27:45 2017
@@ -102,11 +102,7 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STRE
   setup_abi_lib("-DLIBCXXRT"
 "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
 )
-elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
-  list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
-elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
-  # Nothing TODO
-else()
+elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
   message(FATAL_ERROR
 "Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are "
 "supported for c++ abi."

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290841&r1=290840&r2=290841&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Jan  2 16:27:45 2017
@@ -34,7 +34,7 @@ add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
 if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
-   LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"))
+   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
   set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
 endif()
 

Modified: libcxx/trunk/lib/abi/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CMakeLists.txt?rev=290841&r1=290840&r2=290841&view=diff
==
--- libcxx/trunk/lib/abi/CMakeLists.txt (original)
+++ libcxx/trunk/lib/abi/CMakeLists.txt Mon Jan  2 16:27:45 2017
@@ -5,7 +5,7 @@ if (DEFINED TARGET_TRIPLE
 AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist"
 AND TARGET cxx_shared
 AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR
- (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default"))
+ (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none"))
 AND NOT LIBCXX_ABI_UNSTABLE
 AND LIBCXX_ABI_VERSION EQUAL "1")
 set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE INTERNAL "")

Modified: libcxx/trunk/src/exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/exception.cpp?rev=290841&r1=290840&r2=290841&view=diff
=

[PATCH] D28210: system_error: inline error_category ctor on Win32

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd abandoned this revision.
compnerd added a comment.

WFM, that seems like a nicer option.


Repository:
  rL LLVM

https://reviews.llvm.org/D28210



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


Re: [libcxx] r290840 - Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Do we want to enable this by default on other targets under
`LIBCXX_ABI_UNSTABLE` as well?

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

> Author: ericwf
> Date: Mon Jan  2 16:17:51 2017
> New Revision: 290840
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290840&view=rev
> Log:
> Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI
> option.
>
> Currently libc++ compiles a special version of error_category()
> into the dylib. This definition is no longer needed, and doesn't
> work on Windows due to dllimport/dllexport semantics.
>
> For those reasons this patch introduces an option to
> disable/enable this definition. By default the definition
> is provided in ABI v1 except on windows. This patch
> also addresses D28210.
>
> Modified:
> libcxx/trunk/include/__config
> libcxx/trunk/include/system_error
> libcxx/trunk/src/system_error.cpp
>
> Modified: libcxx/trunk/include/__config
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/_
> _config?rev=290840&r1=290839&r2=290840&view=diff
> 
> ==
> --- libcxx/trunk/include/__config (original)
> +++ libcxx/trunk/include/__config Mon Jan  2 16:17:51 2017
> @@ -53,6 +53,10 @@
>  // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
>  #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
>  #elif _LIBCPP_ABI_VERSION == 1
> +#if !defined(_WIN32)
> +// Enable compiling a definition of error_category() into the libc++
> dylib.
> +#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
> +#endif
>  // Feature macros for disabling pre ABI v1 features. All of these options
>  // are deprecated.
>  #if defined(__FreeBSD__)
>
> Modified: libcxx/trunk/include/system_error
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> system_error?rev=290840&r1=290839&r2=290840&view=diff
> 
> ==
> --- libcxx/trunk/include/system_error (original)
> +++ libcxx/trunk/include/system_error Mon Jan  2 16:17:51 2017
> @@ -384,7 +384,8 @@ class _LIBCPP_TYPE_VIS error_category
>  public:
>  virtual ~error_category() _NOEXCEPT;
>
> -#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
> +#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \
> +defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
>  error_category() _NOEXCEPT;
>  #else
>  _LIBCPP_ALWAYS_INLINE
>
> Modified: libcxx/trunk/src/system_error.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/
> system_error.cpp?rev=290840&r1=290839&r2=290840&view=diff
> 
> ==
> --- libcxx/trunk/src/system_error.cpp (original)
> +++ libcxx/trunk/src/system_error.cpp Mon Jan  2 16:17:51 2017
> @@ -29,9 +29,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
>
>  // class error_category
>
> +#if defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
>  error_category::error_category() _NOEXCEPT
>  {
>  }
> +#endif
>
>  error_category::~error_category() _NOEXCEPT
>  {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28218: Small optimizations for SourceManager::getFileID()

2017-01-02 Thread Daniel Jasper via Phabricator via cfe-commits
djasper created this revision.
djasper added a reviewer: rsmith.
djasper added a subscriber: cfe-commits.

Specifically:

- Separate one-entry cache for loaded and local files
- Use bound that can be deduced from that cache for LessIndex
- Address FIXME to use a faster alternative to isOffsetInFileID()

No functional changes intended.


https://reviews.llvm.org/D28218

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp

Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -396,6 +396,7 @@
   LastLineNoFileIDQuery = FileID();
   LastLineNoContentCache = nullptr;
   LastFileIDLookup = FileID();
+  LastLoadedFileIDLookup = FileID();
 
   if (LineTable)
 LineTable->clear();
@@ -580,8 +581,8 @@
 
   // Set LastFileIDLookup to the newly created file.  The next getFileID call is
   // almost guaranteed to be from that file.
-  FileID FID = FileID::get(LocalSLocEntryTable.size()-1);
-  return LastFileIDLookup = FID;
+  LastFileIDLookup = FileID::get(LocalSLocEntryTable.size()-1);
+  return LastFileIDLookup;
 }
 
 SourceLocation
@@ -736,10 +737,16 @@
   // most newly created FileID.
   const SrcMgr::SLocEntry *I;
 
-  if (LastFileIDLookup.ID < 0 ||
-  LocalSLocEntryTable[LastFileIDLookup.ID].getOffset() < SLocOffset) {
-// Neither loc prunes our search.
+  int LastID = LastFileIDLookup.ID;
+  // LessIndex - This is the lower bound of the range that we're searching.
+  // We know that the offset corresponding to the FileID is less than
+  // SLocOffset.
+  unsigned LessIndex = 0;
+  if (LastID < 0) {
+I = LocalSLocEntryTable.end();
+  } else if (LocalSLocEntryTable[LastID].getOffset() < SLocOffset) {
 I = LocalSLocEntryTable.end();
+LessIndex = LastID;
   } else {
 // Perhaps it is near the file point.
 I = LocalSLocEntryTable.begin()+LastFileIDLookup.ID;
@@ -767,18 +774,14 @@
   // Convert "I" back into an index.  We know that it is an entry whose index is
   // larger than the offset we are looking for.
   unsigned GreaterIndex = I - LocalSLocEntryTable.begin();
-  // LessIndex - This is the lower bound of the range that we're searching.
-  // We know that the offset corresponding to the FileID is is less than
-  // SLocOffset.
-  unsigned LessIndex = 0;
   NumProbes = 0;
   while (1) {
 bool Invalid = false;
 unsigned MiddleIndex = (GreaterIndex-LessIndex)/2+LessIndex;
 unsigned MidOffset = getLocalSLocEntry(MiddleIndex, &Invalid).getOffset();
 if (Invalid)
   return FileID::get(0);
-
+
 ++NumProbes;
 
 // If the offset of the midpoint is too large, chop the high side of the
@@ -789,9 +792,7 @@
 }
 
 // If the middle index contains the value, succeed and return.
-// FIXME: This could be made faster by using a function that's aware of
-// being in the local area.
-if (isOffsetInFileID(FileID::get(MiddleIndex), SLocOffset)) {
+if (SLocOffset < LocalSLocEntryTable[MiddleIndex + 1].getOffset()) {
   FileID Res = FileID::get(MiddleIndex);
 
   // If this isn't a macro expansion, remember it.  We have good locality
@@ -823,11 +824,16 @@
 
   // First do a linear scan from the last lookup position, if possible.
   unsigned I;
-  int LastID = LastFileIDLookup.ID;
-  if (LastID >= 0 || getLoadedSLocEntryByID(LastID).getOffset() < SLocOffset)
+  int LastID = LastLoadedFileIDLookup.ID;
+  unsigned LessIndex = LoadedSLocEntryTable.size();
+  if (LastID >= 0) {
 I = 0;
-  else
+  } else if (getLoadedSLocEntryByID(LastID).getOffset() < SLocOffset) {
+I = 0;
+LessIndex = (-LastID - 2);
+  } else {
 I = (-LastID - 2) + 1;
+  }
 
   unsigned NumProbes;
   for (NumProbes = 0; NumProbes < 8; ++NumProbes, ++I) {
@@ -837,7 +843,7 @@
   FileID Res = FileID::get(-int(I) - 2);
 
   if (!E.isExpansion())
-LastFileIDLookup = Res;
+LastLoadedFileIDLookup = Res;
   NumLinearScans += NumProbes + 1;
   return Res;
 }
@@ -847,7 +853,6 @@
   // table: GreaterIndex is the one where the offset is greater, which is
   // actually a lower index!
   unsigned GreaterIndex = I;
-  unsigned LessIndex = LoadedSLocEntryTable.size();
   NumProbes = 0;
   while (1) {
 ++NumProbes;
@@ -868,10 +873,10 @@
   continue;
 }
 
-if (isOffsetInFileID(FileID::get(-int(MiddleIndex) - 2), SLocOffset)) {
+if (getLoadedSLocEntry(MiddleIndex - 1).getOffset() > SLocOffset) {
   FileID Res = FileID::get(-int(MiddleIndex) - 2);
   if (!E.isExpansion())
-LastFileIDLookup = Res;
+LastLoadedFileIDLookup = Res;
   NumBinaryProbes += NumProbes;
   return Res;
 }
Index: include/clang/Basic/SourceManager.h
===
--- include/clang/Basic/SourceManager.h
+++ include/clang/Basic/SourceManager.h
@@ -648,6 +648,9 @@
   /// is very common to look up many tokens from the same file.
   muta

[PATCH] D28207: Add second fast path for DiagnosticsEngine::GetDiagStatePointForLoc

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



Comment at: lib/Basic/Diagnostic.cpp:179
+
+  // 2nd most frequent case: L is before the first diag state change.
+  FullSourceLoc FirstStateChangePos = DiagStatePoints[1].Loc;

It's surprising to me that this would be particularly frequent.

I suspect what you're actually seeing is a consequence of a bug in how we 
manage `DiagStatePoint`s with modules. It looks like 
`ASTReader::InitializeContext` is called once per top-level PCM file that we 
load, and its call to `ReadPragmaDiagnosticMappings` adds entries to the 
`DiagStatePoints` list regardless of whether they've already been added. So, 
we'll end up with duplicates in the `DiagStatePoints` list, and it won't even 
be in translation unit order.

Can you take a look at the `DiagStatePoints` list for a translation unit where 
you see a performance problem and check whether it seems reasonable?


https://reviews.llvm.org/D28207



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


Re: [libcxx] r290840 - Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.

2017-01-02 Thread Eric Fiselier via cfe-commits
It already is. When the macro is defined the old definition is enabled, and
only ABI v1 defines the macro.

On Mon, Jan 2, 2017 at 3:41 PM, Saleem Abdulrasool 
wrote:

> Do we want to enable this by default on other targets under
> `LIBCXX_ABI_UNSTABLE` as well?
>
> On Mon, Jan 2, 2017 at 2:17 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Mon Jan  2 16:17:51 2017
>> New Revision: 290840
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290840&view=rev
>> Log:
>> Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI
>> option.
>>
>> Currently libc++ compiles a special version of error_category()
>> into the dylib. This definition is no longer needed, and doesn't
>> work on Windows due to dllimport/dllexport semantics.
>>
>> For those reasons this patch introduces an option to
>> disable/enable this definition. By default the definition
>> is provided in ABI v1 except on windows. This patch
>> also addresses D28210.
>>
>> Modified:
>> libcxx/trunk/include/__config
>> libcxx/trunk/include/system_error
>> libcxx/trunk/src/system_error.cpp
>>
>> Modified: libcxx/trunk/include/__config
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__
>> config?rev=290840&r1=290839&r2=290840&view=diff
>> 
>> ==
>> --- libcxx/trunk/include/__config (original)
>> +++ libcxx/trunk/include/__config Mon Jan  2 16:17:51 2017
>> @@ -53,6 +53,10 @@
>>  // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
>>  #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
>>  #elif _LIBCPP_ABI_VERSION == 1
>> +#if !defined(_WIN32)
>> +// Enable compiling a definition of error_category() into the libc++
>> dylib.
>> +#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
>> +#endif
>>  // Feature macros for disabling pre ABI v1 features. All of these options
>>  // are deprecated.
>>  #if defined(__FreeBSD__)
>>
>> Modified: libcxx/trunk/include/system_error
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/sys
>> tem_error?rev=290840&r1=290839&r2=290840&view=diff
>> 
>> ==
>> --- libcxx/trunk/include/system_error (original)
>> +++ libcxx/trunk/include/system_error Mon Jan  2 16:17:51 2017
>> @@ -384,7 +384,8 @@ class _LIBCPP_TYPE_VIS error_category
>>  public:
>>  virtual ~error_category() _NOEXCEPT;
>>
>> -#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
>> +#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \
>> +defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
>>  error_category() _NOEXCEPT;
>>  #else
>>  _LIBCPP_ALWAYS_INLINE
>>
>> Modified: libcxx/trunk/src/system_error.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_
>> error.cpp?rev=290840&r1=290839&r2=290840&view=diff
>> 
>> ==
>> --- libcxx/trunk/src/system_error.cpp (original)
>> +++ libcxx/trunk/src/system_error.cpp Mon Jan  2 16:17:51 2017
>> @@ -29,9 +29,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
>>
>>  // class error_category
>>
>> +#if defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
>>  error_category::error_category() _NOEXCEPT
>>  {
>>  }
>> +#endif
>>
>>  error_category::~error_category() _NOEXCEPT
>>  {
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28189: Extend documentation of how to test clang-tidy checks.

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



Comment at: docs/clang-tidy/index.rst:565
+An additional check enabled by ``check_clang_tidy.py`` ensures that
+if `CHECK-MESSAGES:` is used in a file then every warning or error
+must have an associated CHECK in that file.

Looks like you missed this line when changing to double backquotes.


https://reviews.llvm.org/D28189



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


r290842 - Remove isIgnored()-test that is more expensive than the analysis behind it

2017-01-02 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan  2 16:55:45 2017
New Revision: 290842

URL: http://llvm.org/viewvc/llvm-project?rev=290842&view=rev
Log:
Remove isIgnored()-test that is more expensive than the analysis behind it

In many translation units I have tried, the calls to isIgnored() removed
in this patch are more expensive than doing the analysis that is behind
it. The speed-up in translation units I have tried is between 10 and
20%.

Review: https://reviews.llvm.org/D28208

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=290842&r1=290841&r2=290842&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan  2 16:55:45 2017
@@ -4244,7 +4244,7 @@ namespace {
 UnnamedLocalNoLinkageFinder(Sema &S, SourceRange SR) : S(S), SR(SR) { }
 
 bool Visit(QualType T) {
-  return inherited::Visit(T.getTypePtr());
+  return T.isNull() ? false : inherited::Visit(T.getTypePtr());
 }
 
 #define TYPE(Class, Parent) \
@@ -4497,17 +4497,7 @@ bool Sema::CheckTemplateArgument(Templat
   //
   // C++11 allows these, and even in C++03 we allow them as an extension with
   // a warning.
-  bool NeedsCheck;
-  if (LangOpts.CPlusPlus11)
-NeedsCheck =
-!Diags.isIgnored(diag::warn_cxx98_compat_template_arg_unnamed_type,
- SR.getBegin()) ||
-!Diags.isIgnored(diag::warn_cxx98_compat_template_arg_local_type,
- SR.getBegin());
-  else
-NeedsCheck = Arg->hasUnnamedOrLocalType();
-
-  if (NeedsCheck) {
+  if (LangOpts.CPlusPlus11 || Arg->hasUnnamedOrLocalType()) {
 UnnamedLocalNoLinkageFinder Finder(*this, SR);
 (void)Finder.Visit(Context.getCanonicalType(Arg));
   }


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


r290843 - Add testcase for the regression introduced in r290808.

2017-01-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jan  2 17:00:32 2017
New Revision: 290843

URL: http://llvm.org/viewvc/llvm-project?rev=290843&view=rev
Log:
Add testcase for the regression introduced in r290808.

Modified:
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=290843&r1=290842&r2=290843&view=diff
==
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Mon Jan  2 17:00:32 2017
@@ -348,3 +348,17 @@ namespace deduction_substitution_failure
   template int B::error> {}; // expected-note 
{{instantiation of}}
   int bi = B; // expected-note {{during template argument 
deduction for variable template partial specialization 'B::error>' [with T = char]}}
 }
+
+namespace deduction_after_explicit_pack {
+  template int *f(T ...t, int &r, U *u) { // 
expected-note {{couldn't infer template argument 'U'}}
+return u;
+  }
+  template int *g(T ...t, int &r, U *u) {
+return u;
+  }
+  void h(float a, double b, int c) {
+// FIXME: Under DR1388, this appears to be valid.
+f(a, b, c, &c); // expected-error {{no matching}}
+g(a, b, c, &c); // ok
+  }
+}


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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D28081#633521, @ioeric wrote:

> Some nits. Some is almost good :)
>
> BTW, do you have clang-tools-extra in your source tree? There are also some 
> references in the subtree to the changed interface. It would be nice if you 
> could also fix them in a separate patch and commit these two patches together 
> (I mean, within a short period of time) so that you wouldn't break build bots.
>
> References should be found in these files:
>
>   extra/change-namespace/ChangeNamespace.cpp
>   extra/clang-move/ClangMove.cpp
>   extra/include-fixer/tool/ClangIncludeFixer.cpp   
>   extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
>   extra/clang-tidy/ClangTidy.cpp
>
>
> Thanks!


I'll grab clang-tools-extras and make the second patch as you suggest. Btw, can 
you explain how I would avoid breaking build bots? I assume you mean that 
clang-tools-extras gets built separately against some version of clang, which 
gets auto-updated. When would I know the right time to push the second patch 
through?

Also, I assume I'd have to get this second patch approved before ever pushing 
the first, right?




Comment at: lib/Format/Format.cpp:424
 
+llvm::Error make_string_error(const llvm::Twine &Message) {
+  return llvm::make_error(Message,

ioeric wrote:
> Maybe make this `inline`?
Yes.



Comment at: lib/Format/Format.cpp:1901
+  // FIXME: If FallbackStyle is explicitly "none", this effectively disables
+  // replacements. Fix this by setting a separate FormatStyle variable and
+  // returning it when we mean to return the fallback style explicitly.

ioeric wrote:
> I'd state the problem with a specific solution only if I am sure it is the 
> best solution.
Good point, will remove the solution.



Comment at: lib/Tooling/Refactoring.cpp:86
 
-format::FormatStyle CurStyle = format::getStyle(Style, FilePath, "LLVM");
+llvm::Expected FormatStyleOrError =
+format::getStyle(Style, FilePath, "LLVM");

ioeric wrote:
> There is a `NewReplacements` below which is also `llvm::Expected`. 
> `FormatStyleOrError` is  a fine name, but to be we have been naming 
> `Expected` types without `OrError` postfix, so I'd go without `OrError` 
> postfix for consistency append `OrError` postfix to other expected variables. 
> Personally, I find expected variables without `OrError` postfix easier to 
> understand, especially in error checking. For example, `if 
> (!FormatStyleOrError)` is a bit awkward to read while `if (!FormatStyle)` is 
> more straight-forward IMO.
> 
> Same for other changes.
Agreed. For consistency, would you prefer I also use 'auto' for the return type 
rather than llvm::Expected as is done for NewReplacements?



Comment at: unittests/Format/FormatTest.cpp:10972
+  auto ErrorMsg4 = llvm::toString(Style4.takeError());
+  ASSERT_GT(ErrorMsg4.length(), 0);
+

ioeric wrote:
> This is a bit strange... Just `llvm::consumeError(Style.takeError())` if you 
> don't bother to check the error message, e.g. with 
> `llvm::StringRef::starswith` or RE match.
Yeah, I'll go with the consumeError.



Comment at: unittests/Format/FormatTestObjC.cpp:72
 TEST_F(FormatTestObjC, DetectsObjCInHeaders) {
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+  Style = *getStyle("LLVM", "a.h", "none", "@interface\n"
   "- (id)init;");

ioeric wrote:
> amaiorano wrote:
> > In these tests, I'm assuming getStyle returns a valid FormatSyle. I could 
> > add the same types of validation as in the FormatStyle.GetStyleOfFile tests.
> Please add proper checking as above for returned values.
Hmm, so I could replace the Style member of the fixture class with 
Expected, and then change all "Style." with "Style->" in the rest 
of the test file, or only in this specific test, I could store the result in a 
local Expected, check that it's valid, and then assign to Style. 
The latter is simpler; only question I have is how to name the local variable - 
can I go with StyleOrError? Style2?


https://reviews.llvm.org/D28081



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


[PATCH] D28166: Properly merge K&R functions that have attributes

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

The test failure in test/CodeGen/microsoft-call-conv-x64.c definitely indicates 
a problem. The code has defined behavior, but the IR you say we now produce has 
undefined behavior due to a type mismatch between the call and the callee.

It looks to me like unprototyped `__stdcall` lowering is broken (prior to your 
change). Consider:

  void __stdcall g(int n) {}
  void __stdcall (*p)() = g;
  void f() { p(0); }

The types of `p` and `g` are compatible (`g`'s parameter type list does not end 
in an ellipsis and its parameter type `int` is a promoted type, so it is 
compatible with an unprototyped function), so the above program is valid, and a 
call to `f` has defined behavior.

And yet we lower the definition of `g` to `define void @g(i32 %n) ` and the 
call to

  %0 = load void (...)*, void (...)** @p, align 8
  %callee.knr.cast = bitcast void (...)* %0 to void (i64)*
  call void %callee.knr.cast(i64 0)

... resulting in undefined behavior.


https://reviews.llvm.org/D28166



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


[libcxx] r290845 - Fix use of throw(...) spec with GCC in C++17

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 17:27:42 2017
New Revision: 290845

URL: http://llvm.org/viewvc/llvm-project?rev=290845&view=rev
Log:
Fix use of throw(...) spec with GCC in C++17

Modified:
libcxx/trunk/include/new

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=290845&r1=290844&r2=290845&view=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Mon Jan  2 17:27:42 2017
@@ -162,7 +162,7 @@ _LIBCPP_FUNC_VIS new_handler get_new_han
 
 }  // std
 
-#if !__has_feature(cxx_noexcept)
+#if defined(_LIBCPP_CXX03_LANG)
 #define _THROW_BAD_ALLOC throw(std::bad_alloc)
 #else
 #define _THROW_BAD_ALLOC


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


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

slim reader-writer locks are faster than critical sections, I'd recommend your 
implementation switch to those.

Also, why do you use Fls instead of Tls?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[libcxx] r290846 - Re-implement LWG 2770 - Fix tuple_size with structured bindings.

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 17:54:13 2017
New Revision: 290846

URL: http://llvm.org/viewvc/llvm-project?rev=290846&view=rev
Log:
Re-implement LWG 2770 - Fix tuple_size with structured bindings.

This patch implements the correct PR for LWG 2770. It also makes the primary
tuple_size template incomplete again which fixes part of llvm.org/PR31513.

Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/tuple

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp

Modified: libcxx/trunk/include/__tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=290846&r1=290845&r2=290846&view=diff
==
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Mon Jan  2 17:54:13 2017
@@ -22,19 +22,32 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template  class _LIBCPP_TYPE_VIS_ONLY tuple_size {};
+template  class _LIBCPP_TYPE_VIS_ONLY tuple_size;
+
+struct __empty_tuple_size_base {};
+
+template 
+struct __tuple_size_base_type {
+  typedef __empty_tuple_size_base type;
+};
+
+template 
+struct __tuple_size_base_type<_Tp, typename 
__void_t::value)>::type>
+{
+  typedef integral_constant::value> type;
+};
 
 template 
 class _LIBCPP_TYPE_VIS_ONLY tuple_size
-: public tuple_size<_Tp> {};
+: public __tuple_size_base_type<_Tp>::type {};
 
 template 
 class _LIBCPP_TYPE_VIS_ONLY tuple_size
-: public tuple_size<_Tp> {};
+: public __tuple_size_base_type<_Tp>::type {};
 
 template 
 class _LIBCPP_TYPE_VIS_ONLY tuple_size
-: public tuple_size<_Tp> {};
+: public __tuple_size_base_type<_Tp>::type {};
 
 template  class _LIBCPP_TYPE_VIS_ONLY tuple_element;
 

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=290846&r1=290845&r2=290846&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Mon Jan  2 17:54:13 2017
@@ -84,7 +84,7 @@ template 
   constexpr T make_from_tuple(Tuple&& t); // C++17
 
 // 20.4.1.4, tuple helper classes:
-template  class tuple_size;
+template  class tuple_size; // undefined
 template  class tuple_size>;
 template 
  constexpr size_t tuple_size_v = tuple_size::value; // C++17

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp?rev=290846&r1=290845&r2=290846&view=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp
 Mon Jan  2 17:54:13 2017
@@ -21,7 +21,7 @@
 
 int main()
 {
-(void)std::tuple_size &>::value; // expected-error {{no 
member named 'value'}}
-(void)std::tuple_size::value; // expected-error {{no member named 
'value'}}
-(void)std::tuple_size*>::value; // expected-error {{no member 
named 'value'}}
+(void)std::tuple_size &>::value; // expected-error {{implicit 
instantiation of undefined template}}
+(void)std::tuple_size::value; // expected-error {{implicit 
instantiation of undefined template}}
+(void)std::tuple_size*>::value; // expected-error {{implicit 
instantiation of undefined template}}
 }

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp?rev=290846&r1=290845&r2=290846&view=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
 Mon Jan  2 17:54:13 2017
@@ -18,8 +18,6 @@
 // UNSUPPORTED: c++98, c++03
 
 #include 
-#include 
-#include 
 #include 
 
 template ::value)>
@@ -27,27 +25,29 @@ constexpr bool has_value(int) { return t
 template  constexpr bool has_value(long) { return false; }
 template  constexpr bool has_value() { return has_value(0); }
 
+struct Dummy {};
 
 template 
 void test()
 {
-static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::tuple_size >::value), "");
-static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::tuple_size >::value), "");
-static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::t

[libcxxabi] r290847 - Fix new/delete exception specifications to match libc++ after r290845

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 18:16:18 2017
New Revision: 290847

URL: http://llvm.org/viewvc/llvm-project?rev=290847&view=rev
Log:
Fix new/delete exception specifications to match libc++ after r290845

Modified:
libcxxabi/trunk/src/cxa_new_delete.cpp

Modified: libcxxabi/trunk/src/cxa_new_delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_new_delete.cpp?rev=290847&r1=290846&r2=290847&view=diff
==
--- libcxxabi/trunk/src/cxa_new_delete.cpp (original)
+++ libcxxabi/trunk/src/cxa_new_delete.cpp Mon Jan  2 18:16:18 2017
@@ -14,6 +14,11 @@
 #include 
 #include 
 
+#if !defined(_THROW_BAD_ALLOC) || !defined(_NOEXCEPT)
+#error _THROW_BAD_ALLOC and _NOEXCEPT libc++ macros must already be defined \
+   by libc++.
+#endif
+
 /*
 [new.delete.single]
 
@@ -33,10 +38,7 @@
 */
 __attribute__((__weak__, __visibility__("default")))
 void *
-operator new(std::size_t size)
-#if !__has_feature(cxx_noexcept)
-throw(std::bad_alloc)
-#endif
+operator new(std::size_t size) _THROW_BAD_ALLOC
 {
 if (size == 0)
 size = 1;
@@ -70,12 +72,7 @@ that call. Otherwise, returns a null poi
 */
 __attribute__((__weak__, __visibility__("default")))
 void*
-operator new(size_t size, const std::nothrow_t&)
-#if __has_feature(cxx_noexcept)
-noexcept
-#else
-throw()
-#endif
+operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
 void* p = 0;
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
@@ -99,10 +96,7 @@ Returns operator new(size).
 */
 __attribute__((__weak__, __visibility__("default")))
 void*
-operator new[](size_t size)
-#if !__has_feature(cxx_noexcept)
-throw(std::bad_alloc)
-#endif
+operator new[](size_t size) _THROW_BAD_ALLOC
 {
 return ::operator new(size);
 }
@@ -115,12 +109,7 @@ of that call. Otherwise, returns a null
 */
 __attribute__((__weak__, __visibility__("default")))
 void*
-operator new[](size_t size, const std::nothrow_t&)
-#if __has_feature(cxx_noexcept)
-noexcept
-#else
-throw()
-#endif
+operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
 void* p = 0;
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
@@ -145,12 +134,7 @@ earlier call to operator new.
 */
 __attribute__((__weak__, __visibility__("default")))
 void
-operator delete(void* ptr)
-#if __has_feature(cxx_noexcept)
-noexcept
-#else
-throw()
-#endif
+operator delete(void* ptr) _NOEXCEPT
 {
 if (ptr)
 std::free(ptr);
@@ -163,12 +147,7 @@ calls operator delete(ptr)
 */
 __attribute__((__weak__, __visibility__("default")))
 void
-operator delete(void* ptr, const std::nothrow_t&)
-#if __has_feature(cxx_noexcept)
-noexcept
-#else
-throw()
-#endif
+operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
 {
 ::operator delete(ptr);
 }
@@ -180,12 +159,7 @@ Calls operator delete(ptr)
 */
 __attribute__((__weak__, __visibility__("default")))
 void
-operator delete[] (void* ptr)
-#if __has_feature(cxx_noexcept)
-noexcept
-#else
-throw()
-#endif
+operator delete[] (void* ptr) _NOEXCEPT
 {
 ::operator delete(ptr);
 }
@@ -197,12 +171,7 @@ calls operator delete[](ptr)
 */
 __attribute__((__weak__, __visibility__("default")))
 void
-operator delete[] (void* ptr, const std::nothrow_t&)
-#if __has_feature(cxx_noexcept)
-noexcept
-#else
-throw()
-#endif
+operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT
 {
 ::operator delete[](ptr);
 }


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


[PATCH] D28220: provide Win32 native threading

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

Added inline comments.

The main issue is that this patch needs to use the same `<__threading_support>` 
forward declarations as every other supported threading API; Only new 
definitions should be provided.




Comment at: include/__threading_support:33
 #include <__external_threading>
+#elif defined(_WIN32) && defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN

Isn't checking `_LIBCPP_HAS_THREAD_API_WIN32` enough?



Comment at: include/__threading_support:46
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+

The forward declarations of the `__libcpp_` threading wrapper should be shared 
between all API's. Please don't add your own forward declarations for Windows. 



Comment at: src/algorithm.cpp:51
 #ifndef _LIBCPP_HAS_NO_THREADS
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = 
_LIBCPP_MUTEX_INITIALIZER;
+#if !defined(_WIN32)
+_LIBCPP_SAFE_STATIC

This makes me sad because not having constant initialization manifests itself 
as a static initialization order fiasco in libc++. If we do go this route 
please file a libc++ bug stating that Win32 mutex's do not provide constant 
initialization.

I think this should check `_LIBCPP_HAS_THREAD_API_WIN32`?



Comment at: src/memory.cpp:158
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] =
+#if !defined(_WIN32)
+_LIBCPP_SAFE_STATIC

I think this should check _LIBCPP_HAS_THREAD_API_WIN32?



Comment at: src/mutex.cpp:198
 #ifndef _LIBCPP_HAS_NO_THREADS
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
+#if !defined(_WIN32)
+_LIBCPP_SAFE_STATIC

I think this should check _LIBCPP_HAS_THREAD_API_WIN32?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28166: Properly merge K&R functions that have attributes

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

In https://reviews.llvm.org/D28166#633595, @rsmith wrote:

> The test failure in test/CodeGen/microsoft-call-conv-x64.c definitely 
> indicates a problem. The code has defined behavior, but the IR you say we now 
> produce has undefined behavior due to a type mismatch between the call and 
> the callee.
>
> It looks to me like unprototyped `__stdcall` lowering is broken (prior to 
> your change). Consider:
>
>   void __stdcall g(int n) {}
>   void __stdcall (*p)() = g;
>   void f() { p(0); }
>
>
> The types of `p` and `g` are compatible (`g`'s parameter type list does not 
> end in an ellipsis and its parameter type `int` is a promoted type, so it is 
> compatible with an unprototyped function), so the above program is valid, and 
> a call to `f` has defined behavior.
>
> And yet we lower the definition of `g` to `define void @g(i32 %n) ` and the 
> call to
>
>   %0 = load void (...)*, void (...)** @p, align 8
>   %callee.knr.cast = bitcast void (...)* %0 to void (i64)*
>   call void %callee.knr.cast(i64 0)
>
>
> ... resulting in undefined behavior.


Thank you for the explanation -- that makes sense to me.

Do you think this patch should be gated on (or perhaps combined with) a fix for 
the lowering bug, or do you think this patch is reasonable on its own? Given 
that it turns working code into UB, I think my preference is to gate it on a 
fix for the lowering bug, but I'm also not certain I am the right person to 
implement that fix (though I could give it a shot).


https://reviews.llvm.org/D28166



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


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

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

I would really rather see a single definition of the `typeinfo` class between 
all platforms, but I see how that could get messy. How about instead of 
declaring a new one we use the existing class definition, but move all of the 
method definitions out-of-line and then define them in their own `#ifdef` 
blocks?


Repository:
  rL LLVM

https://reviews.llvm.org/D28212



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


[PATCH] D28220: provide Win32 native threading

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

@majnemer Im using the Fls* APIs since they provide the thread termination 
callback, which Tls* doesn't.  Good point about the SRW.  Those are newer, but, 
we can always provide a fallback later.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D28220#633622, @compnerd wrote:

> @majnemer Im using the Fls* APIs since they provide the thread termination 
> callback, which Tls* doesn't.  Good point about the SRW.  Those are newer, 
> but, we can always provide a fallback later.


I don't believe they are newer than the condition variable API so all should be 
fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[libcxx] r290849 - Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 19:18:48 2017
New Revision: 290849

URL: http://llvm.org/viewvc/llvm-project?rev=290849&view=rev
Log:
Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.

This patch re-commits a previous attempt to support building libc++ w/o
an ABI library. That patch was originally reverted because:

1) It forgot to teach the test suite about "default" ABI libraries.

2) Some LLVM builders don't clear the CMake cache between builds. The previous
   patch caused those builders to fail since their old cache entry for
   LIBCXX_CXX_ABI="" is no longer valid.

The updated patch addresses both issues. It works around (2) by adding
a hack to force the builders to update their cache entries. The hack will
be removed shortly once all LLVM builders have run.

Original commit message
---

Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits
of the C++ STL. However we also support building w/o an ABI library entirely.
This patch fixes building libc++ w/o an ABI library (and incorporates the
`~type_info()` fix in D28211).

The main changes in this patch are:

1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean 
"default".
2) Fix CMake bits which treated "none" as "default" on OS X.
3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`.
4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined.

Unfortunately this patch doesn't help clean up the macro mess that we use to
configure for different ABI libraries.

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/lib/abi/CMakeLists.txt
libcxx/trunk/src/exception.cpp
libcxx/trunk/src/new.cpp
libcxx/trunk/src/stdexcept.cpp
libcxx/trunk/src/typeinfo.cpp
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290849&r1=290848&r2=290849&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan  2 19:18:48 2017
@@ -87,13 +87,22 @@ if (NOT LIBCXX_ENABLE_SHARED AND NOT LIB
 endif()
 
 # ABI Library options -
-set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
-"Specify C++ ABI library to use." FORCE)
-set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
+set(LIBCXX_CXX_ABI "default" CACHE STRING
+"Specify C++ ABI library to use.")
+set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++)
 set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
 
+# FIXME: This is a temporary hack to force LLVM buildbots to store
+# the fixed cache entry instead of the previous cache entry. This is needed
+# because some LLVM buildbots don't clear their cache. It will be removed
+# once all LLVM bots have been run.
+if (LIBCXX_CXX_ABI STREQUAL "")
+  set(LIBCXX_CXX_ABI "default" CACHE STRING
+  "Specify the C++ ABI library to use." FORCE)
+endif()
+
 # Setup the default options if LIBCXX_CXX_ABI is not specified.
-if (NOT LIBCXX_CXX_ABI)
+if (LIBCXX_CXX_ABI STREQUAL "default")
   find_path(
 LIBCXX_LIBCXXABI_INCLUDES_INTERNAL
 cxxabi.h
@@ -107,7 +116,7 @@ if (NOT LIBCXX_CXX_ABI)
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_INTREE 1)
   else()
-set(LIBCXX_CXX_ABI_LIBNAME "none")
+set(LIBCXX_CXX_ABI_LIBNAME "default")
   endif()
 else()
   set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
@@ -125,6 +134,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
 if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
   AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
+  AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
   AND PYTHONINTERP_FOUND
   AND LIBCXX_ENABLE_SHARED)
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=290849&r1=290848&r2=290849&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Mon Jan  2 19:18:48 2017
@@ -102,9 +102,14 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STRE
   setup_abi_lib("-DLIBCXXRT"
 "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
 )
-elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
+elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
+  list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
+elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
+  # Nothing TODO
+else()
   message(FATAL_ERROR
-"Currently libstdc++, libs

[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 3 inline comments as done.
compnerd added a comment.

The SRW initializers avoid the initializer changes, so its one less set of 
changes that is necessary.




Comment at: include/__threading_support:33
 #include <__external_threading>
+#elif defined(_WIN32) && defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN

EricWF wrote:
> Isn't checking `_LIBCPP_HAS_THREAD_API_WIN32` enough?
No, because the structure of the header is such that it requires redeclarations 
:-(.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF commandeered this revision.
EricWF edited reviewers, added: compnerd; removed: EricWF.
EricWF added a comment.

Stealing this revision to update with the requested style changes: @compnerd 
please steal this back.


Repository:
  rL LLVM

https://reviews.llvm.org/D28212



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


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF removed rL LLVM as the repository for this revision.
EricWF updated this revision to Diff 82825.
EricWF added a comment.

Update with the prefered style changes. @compnerd please still this revision 
back when ready.


https://reviews.llvm.org/D28212

Files:
  include/typeinfo
  src/typeinfo.cpp

Index: src/typeinfo.cpp
===
--- src/typeinfo.cpp
+++ src/typeinfo.cpp
@@ -14,13 +14,51 @@
 #endif
 
 #include "typeinfo"
+#include "cstring"
 
 #if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
 std::type_info::~type_info()
 {
 }
 #endif
 
+#if defined(_LIBCPP_HAS_WINDOWS_TYPEINFO)
+
+const char *std::type_info::__name(std::type_info::__data_t *__data) {
+  // TODO(compnerd) cache demangled &__data.__decorated_name[1]
+  return &__data->__decorated_name[1];
+}
+
+size_t std::type_info::__hash(const std::type_info::__data_t *__data) {
+#if defined(_WIN64)
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037ull;
+  static constexpr const size_t fnv_prime = 10995116282110ull;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261ull;
+  static constexpr const size_t fnv_prime = 16777619ull;
+#endif
+
+  size_t value = fnv_offset_basis;
+  for (const char *c = &__data->__decorated_name[1]; *c; ++c) {
+value ^= static_cast(static_cast(*c));
+value *= fnv_prime;
+  }
+
+#if defined(_WIN64)
+  value ^= value >> 32;
+#endif
+
+  return value;
+}
+
+int std::type_info::__compare(const std::type_info::__data_t *__lhs,
+  const std::type_info::__data_t *__rhs) {
+  if (__lhs == __rhs)
+return 0;
+  return strcmp(&__lhs->__decorated_name[1], &__rhs->__decorated_name[1]);
+}
+#endif // _LIBCPP_HAS_WINDOWS_TYPEINFO
+
 #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
 
 std::bad_cast::bad_cast() _NOEXCEPT
Index: include/typeinfo
===
--- include/typeinfo
+++ include/typeinfo
@@ -69,86 +69,147 @@
 #pragma GCC system_header
 #endif
 
+#ifdef _LIBCPP_NONUNIQUE_RTTI_BIT
+#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
+#elif defined(_WIN32)
+#define _LIBCPP_HAS_WINDOWS_TYPEINFO
+#else
+#define _LIBCPP_HAS_UNIQUE_TYPEINFO
+#endif
+
 namespace std  // purposefully not using versioning namespace
 {
 
 class _LIBCPP_EXCEPTION_ABI type_info
 {
 type_info& operator=(const type_info&);
 type_info(const type_info&);
 
+#if defined(_LIBCPP_HAS_WINDOWS_TYPEINFO)
+  static const char *__name(type_info::__data_t *__data);
+  static size_t __hash(const type_info::__data_t *__data);
+  static int __compare(const type_info::__data_t *__l,
+   const type_info::__data_t *__r);
+
+  mutable struct __data_t {
+const char *__undecorated_name;
+const char __decorated_name[1];
+  } __data;
+
+#elif defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
+  _LIBCPP_INLINE_VISIBILITY
+  int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
+  { return __builtin_strcmp(name(), __arg.name()); }
+
 protected:
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-const char* __type_name;
-#else
-// A const char* with the non-unique RTTI bit possibly set.
-uintptr_t __type_name;
-#endif
+  uintptr_t __type_name // A const char* with the non-unique RTTI bit possibly set.
 
-_LIBCPP_INLINE_VISIBILITY
-explicit type_info(const char* __n)
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-: __type_name(__n) {}
 #else
-: __type_name(reinterpret_cast(__n)) {}
+protected:
+  const char* __type_name;
 #endif
 
+protected:
+  inline _LIBCPP_INLINE_VISIBILITY
+  explicit type_info(const char* __n);
+
 public:
-virtual ~type_info();
+  virtual ~type_info();
 
-_LIBCPP_INLINE_VISIBILITY
-const char* name() const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name;}
-#else
-{return reinterpret_cast(__type_name & ~_LIBCPP_NONUNIQUE_RTTI_BIT);}
-#endif
+  inline _LIBCPP_INLINE_VISIBILITY
+  const char* name() const _NOEXCEPT;
 
-_LIBCPP_INLINE_VISIBILITY
-bool before(const type_info& __arg) const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name < __arg.__type_name;}
-#else
-{if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
-   return __type_name < __arg.__type_name;
- return __compare_nonunique_names(__arg) < 0;}
-#endif
+  inline _LIBCPP_INLINE_VISIBILITY
+  bool before(const type_info& __arg) const _NOEXCEPT;
 
-_LIBCPP_INLINE_VISIBILITY
-size_t hash_code() const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return reinterpret_cast(__type_name);}
-#else
-{if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
- const char *__ptr = name();
- size_t __hash = 5381;
- while (unsigned char __c = static_cast(*__ptr++))
-   __hash = (__hash * 33) ^ __c;
- return __hash;}
-#endif
+  inline _LIBCPP_INLINE_VISIBILITY
+  size_t hash_code() cons

[PATCH] D28166: Properly merge K&R functions that have attributes

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

In https://reviews.llvm.org/D28166#633621, @aaron.ballman wrote:

> Do you think this patch should be gated on (or perhaps combined with) a fix 
> for the lowering bug, or do you think this patch is reasonable on its own? 
> Given that it turns working code into UB, I think my preference is to gate it 
> on a fix for the lowering bug, but I'm also not certain I am the right person 
> to implement that fix (though I could give it a shot).


The test in question has a comment pointing to PR7117, which in turn indicates 
that we might miscompile parts of FreeBSD if we land this as-is. So I think we 
need to gate this on a fix for the lowering bug.


https://reviews.llvm.org/D28166



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


[libcxx] r290850 - threading_support: refactor for Win32 threading

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 20:00:31 2017
New Revision: 290850

URL: http://llvm.org/viewvc/llvm-project?rev=290850&view=rev
Log:
threading_support: refactor for Win32 threading

Refactor the header to allow us to implement alternate threading models
with alternate data structures.  Take the opportunity to clang-format
the area.  This will allow us to avoid re-declaring the interfaces for
Win32 threading.  NFC

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/test/support/external_threads.cpp

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=290850&r1=290849&r2=290850&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Mon Jan  2 20:00:31 2017
@@ -31,8 +31,11 @@
 __libcpp_has_include(<__external_threading>)
 #include <__external_threading>
 #else
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -42,200 +45,229 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
+// Condition Variable
+typedef pthread_cond_t __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+// THread ID
+typedef pthread_t __libcpp_thread_id;
+
+// Thread
+typedef pthread_t __libcpp_thread_t;
+
+// Thrad Local Storage
+typedef pthread_key_t __libcpp_tls_key;
+#endif
+
+// Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
+int __libcpp_recursive_mutex_init(__libcpp_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_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
 
 // Condition variable
-typedef pthread_cond_t __libcpp_condvar_t;
-#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* 
__m, timespec* __ts);
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
 
-// Thread id
-typedef pthread_t __libcpp_thread_id;
+// Thread ID
 _LIBCPP_THREAD_ABI_VISIBILITY
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
 
 // Thread
-typedef pthread_t __libcpp_thread_t;
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), 
void* __arg);
+int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
+   void *__arg);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 __libcpp_thread_id __libcpp_thread_get_current_id();
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_thread_join(__libcpp_thread_t* __t);
+int __libcpp_thread_join(__libcpp_thread_t *__t);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_thread_detach(__libcpp_thread_t* __t);
+int __libcpp_thread_detach(__libcpp_thread_t *__t);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 void __libcpp_thread_yield();
 
 // Thread local storage
-typedef pthread_key_t __libcpp_tls_key;
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*));
+int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *));
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-void* __libcpp_tls_get(__libcpp_tls_key __key);
+void *__libcpp_tls_get(__libcpp_tls_key __key);
+
 _LIBCPP_THREAD_ABI_VISIBILITY
-void __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
+void __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || 
defined(_LIBCPP_BUILDING_EXTE

[libcxx] r290851 - system_error: provide a thread safe stringification for Windows

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 20:00:33 2017
New Revision: 290851

URL: http://llvm.org/viewvc/llvm-project?rev=290851&view=rev
Log:
system_error: provide a thread safe stringification for Windows

Provide a strerror_r replacement for Windows.  This is needed to build
libc++ for Windows with threading.

Modified:
libcxx/trunk/src/system_error.cpp

Modified: libcxx/trunk/src/system_error.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_error.cpp?rev=290851&r1=290850&r2=290851&view=diff
==
--- libcxx/trunk/src/system_error.cpp (original)
+++ libcxx/trunk/src/system_error.cpp Mon Jan  2 20:00:33 2017
@@ -65,8 +65,16 @@ constexpr size_t strerror_buff_size = 10
 
 string do_strerror_r(int ev);
 
-#if defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC)  
\
-&& (!defined(__ANDROID__) || __ANDROID_API__ >= 23)
+#if defined(_WIN32)
+string do_strerror_r(int ev) {
+  char buffer[strerror_buff_size];
+  if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
+return string(buffer);
+  std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
+  return string(buffer);
+}
+#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && 
\
+(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
 // GNU Extended version
 string do_strerror_r(int ev) {
 char buffer[strerror_buff_size];


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


Fix for Visual Studio 2017

2017-01-02 Thread Hamza Sood via cfe-commits
Visual Studio 2017 changes the layout of its compiler tools (described here: 
https://blogs.msdn.microsoft.com/vcblog/2016/10/07/compiler-tools-layout-in-visual-studio-15/).
If there are no other Visual Studio versions installed, Clang will be unable to 
find link.exe and hence will fail at the linking stage. This patch should fix 
that.



VS2017Fix.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82826.
compnerd added a comment.

Use SRW locks, rebase for avoid redeclaration of interfaces, remove static 
initialization check removals.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -32,9 +32,20 @@
 #include <__external_threading>
 #else

+#if !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) &&\
+!defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#error "unknown threading model"
+#endif
+
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 
+#include 
+#include 
 #endif

 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -62,6 +73,23 @@

 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
 #endif

 // Mutex
@@ -267,6 +295,150 @@
   pthread_setspecific(__key, __p);
 }

+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+{
+  InitializeSRWLock(__m);
+  return 0;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+  AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+  return TryAcquireSRWLockExclusive(__m);
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts)
+{
+  using namespace _VSTD::chrono;
+  auto timeout = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  // TODO(compnerd) handle timeouts < 10ms
+  // TODO(compnerd) handle spurious timeout
+  if (!SleepConditionVariableSRW(__cv, __m,
+ duration_cast(timeout).count(),
+ 0))
+return GetLastError();
+  return 0;
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
+{
+  static_cast(__cv);
+  return 0;
+}
+
+// Thread ID
+bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
+  __libcpp_thread_id __rhs)
+{
+  return __lhs == __rhs;
+}
+
+bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
+{
+  return __lhs < __rhs;
+}
+
+// Thread
+int __libcpp_thread_create(__libcpp_thread_t *__t,
+   unsigned int (* WINAPI __func)(void *), void *__arg)
+{
+  *__t =
+  reinterpret_cast(_beginthreadex(NULL, 0, __func, __arg, 0, NULL));
+  if (*__t)
+return 0;
+  return GetLastError();
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+  return GetCurrentThreadId();
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
+{
+  return GetThreadId(*__t);
+}
+
+int __libcpp_thread_join(__libcpp_thread_t *__t)
+{
+  if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED)
+return GetLastError();
+  if (!CloseHandle(*__t))
+return GetLastError();
+  return 0;
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t *__t)
+{
+  if (!CloseHandle(*__t))
+return GetLastError();
+  return 0;
+}
+
+void __libcpp_thread_yield()
+{
+  SwitchToThread();
+}
+
+// Thread Local Storage
+int __libcpp_tls_create(__libcpp_tls_key *__key, void (* WINAPI __at_exit)(void *))
+{
+  *__key = FlsAlloc(__at_exit);
+  if (*__key == FLS_OUT_OF_INDEXES)
+return GetLastError();
+  return 0;
+}
+
+void *__libcpp_tls_get(__libcpp_tls_key __key)
+{
+  return FlsGetValue(__key);
+}
+
+void __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
+{
+  FlsSetValue(__key, __p);
+}
+
 #endif // _LIBCPP_HAS_THREAD_API_PTHREAD

 _LIBCPP_END_NAMESPACE_STD
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -882,6 +882,8 @@
 defined(__CloudABI__) || \
 defined(__sun__)
 #  define _L

[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: include/__threading_support:300-305
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+{
+  InitializeSRWLock(__m);
+  return 0;
+}
+

I don't think you can use slim rw locks for recursive locks. I think we will 
need to use `CRITICAL_SECTION` for those. std::recursive_mutex can't be used 
with std::condition_variable AFAIK so all you need (I think) is recursive 
versions of `__libcpp_mutex_...`

Recursive locks should be used far less frequently which makes it valuable, 
IMO, to use slim rw locks for the non-recursive mutex implementation.



Comment at: include/__threading_support:355
+  // TODO(compnerd) handle spurious timeout
+  if (!SleepConditionVariableSRW(__cv, __m,
+ duration_cast(timeout).count(),

I don't think it should be `__libcpp_condvar_timedwait'`s problem. 
`__libcpp_condvar_timedwait` wraps `pthread_cond_timedwait` on POSIX platforms 
and the caller of `__libcpp_condvar_wait` properly handles spurious wakeups. 
The caller of `__libcpp_condvar_timedwait` probably should be audited.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added inline comments.



Comment at: unittests/Format/FormatTestObjC.cpp:72
 TEST_F(FormatTestObjC, DetectsObjCInHeaders) {
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+  Style = *getStyle("LLVM", "a.h", "none", "@interface\n"
   "- (id)init;");

amaiorano wrote:
> ioeric wrote:
> > amaiorano wrote:
> > > In these tests, I'm assuming getStyle returns a valid FormatSyle. I could 
> > > add the same types of validation as in the FormatStyle.GetStyleOfFile 
> > > tests.
> > Please add proper checking as above for returned values.
> Hmm, so I could replace the Style member of the fixture class with 
> Expected, and then change all "Style." with "Style->" in the 
> rest of the test file, or only in this specific test, I could store the 
> result in a local Expected, check that it's valid, and then 
> assign to Style. The latter is simpler; only question I have is how to name 
> the local variable - can I go with StyleOrError? Style2?
Another option here is to make this a non-fixture TEST and just declare a local 
Expected Style for this specific test, which would work fine.


https://reviews.llvm.org/D28081



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


[libcxx] r290853 - Fix creating __generated_config on Windows

2017-01-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan  2 21:55:29 2017
New Revision: 290853

URL: http://llvm.org/viewvc/llvm-project?rev=290853&view=rev
Log:
Fix creating __generated_config on Windows

Added:
libcxx/trunk/utils/cat_files.py   (with props)
Modified:
libcxx/trunk/include/CMakeLists.txt

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=290853&r1=290852&r2=290853&view=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Mon Jan  2 21:55:29 2017
@@ -35,8 +35,13 @@ if (LIBCXX_INSTALL_HEADERS)
 # Generate and install a custom __config header. The new header is created
 # by  prepending __config_site to the current __config header.
 add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
-  COMMAND ${CMAKE_COMMAND} -E copy ${LIBCXX_BINARY_DIR}/__config_site 
${LIBCXX_BINARY_DIR}/__generated_config
-  COMMAND ${UNIX_CAT} ${LIBCXX_SOURCE_DIR}/include/__config >> 
${LIBCXX_BINARY_DIR}/__generated_config
+  COMMAND ${CMAKE_COMMAND} -E copy
+${LIBCXX_BINARY_DIR}/__config_site
+${LIBCXX_BINARY_DIR}/__generated_config
+  COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py
+${LIBCXX_BINARY_DIR}/__generated_config
+${LIBCXX_SOURCE_DIR}/include/__config
+-o ${LIBCXX_BINARY_DIR}/__generated_config
   DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config
   ${LIBCXX_BINARY_DIR}/__config_site
 )

Added: libcxx/trunk/utils/cat_files.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/cat_files.py?rev=290853&view=auto
==
--- libcxx/trunk/utils/cat_files.py (added)
+++ libcxx/trunk/utils/cat_files.py Mon Jan  2 21:55:29 2017
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#===--===##
+#
+# 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.
+#
+#===--===##
+
+from argparse import ArgumentParser
+import sys
+
+def print_and_exit(msg):
+sys.stderr.write(msg + '\n')
+sys.exit(1)
+
+def main():
+parser = ArgumentParser(
+description="Concatenate two files into a single file")
+parser.add_argument(
+'-o', '--output', dest='output', required=True,
+help='The output file. stdout is used if not given',
+type=str, action='store')
+parser.add_argument(
+'files', metavar='files',  nargs='+',
+help='The files to concatenate')
+
+args = parser.parse_args()
+
+if len(args.files) < 2:
+print_and_exit('fewer than 2 inputs provided')
+data = ''
+for filename in args.files:
+with open(filename, 'r') as f:
+data += f.read()
+if len(data) != 0 and data[-1] != '\n':
+data += '\n'
+assert len(data) > 0 and "cannot cat empty files"
+with open(args.output, 'w') as f:
+f.write(data)
+
+
+if __name__ == '__main__':
+main()
+sys.exit(0)

Propchange: libcxx/trunk/utils/cat_files.py
--
svn:executable = *


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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-02 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 82831.
amaiorano added a comment.

More changes as suggested by @ioeric. I asked a question earlier about 
clang-tools-extras and understanding how not to break the build bots. If you 
can shed some light on that, I'd appreciate it, thanks :)


https://reviews.llvm.org/D28081

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Tooling/Refactoring.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestObjC.cpp

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -69,16 +69,20 @@
 };
 
 TEST_F(FormatTestObjC, DetectsObjCInHeaders) {
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
-  "- (id)init;");
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style.Language);
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+  auto Style1 = getStyle("LLVM", "a.h", "none", "@interface\n"
+   "- (id)init;");
+  ASSERT_TRUE((bool)Style1);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style1->Language);
+
+  auto Style2 = getStyle("LLVM", "a.h", "none", "@interface\n"
   "+ (id)init;");
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style.Language);
+  ASSERT_TRUE((bool)Style2);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style2->Language);
 
   // No recognizable ObjC.
-  Style = getStyle("LLVM", "a.h", "none", "void f() {}");
-  EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);
+  auto Style3 = getStyle("LLVM", "a.h", "none", "void f() {}");
+  ASSERT_TRUE((bool)Style3);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style3->Language);
 }
 
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10945,22 +10945,51 @@
   ASSERT_TRUE(
   FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style1 = getStyle("file", "/a/.clang-format", "Google", "", &FS);
-  ASSERT_EQ(Style1, getLLVMStyle());
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(*Style1, getLLVMStyle());
 
   // Test 2: fallback to default.
   ASSERT_TRUE(
   FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS);
-  ASSERT_EQ(Style2, getMozillaStyle());
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getMozillaStyle());
 
   // Test 3: format file in parent directory.
   ASSERT_TRUE(
   FS.addFile("/c/.clang-format", 0,
  llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
   ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,
  llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", "", &FS);
-  ASSERT_EQ(Style3, getGoogleStyle());
+  ASSERT_TRUE((bool)Style3);
+  ASSERT_EQ(*Style3, getGoogleStyle());
+
+  // Test 4: error on invalid fallback style
+  auto Style4 = getStyle("file", "a.h", "KungFu", "", &FS);
+  ASSERT_FALSE((bool)Style4);
+  llvm::consumeError(Style4.takeError());
+
+  // Test 5: error on invalid yaml on command line
+  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style5);
+  llvm::consumeError(Style5.takeError());
+
+  // Test 6: error on invalid style
+  auto Style6 = getStyle("KungFu", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style6);
+  llvm::consumeError(Style6.takeError());
+
+  // Test 7: found config file, error on parsing it
+  ASSERT_TRUE(
+  FS.addFile("/d/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM\n"
+  "InvalidKey: InvalidValue")));
+  ASSERT_TRUE(
+  FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style7 = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style7);
+  llvm::consumeError(Style7.takeError());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -249,8 +249,14 @@
   if (fillRanges(Code.get(), Ranges))
 return true;
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
-  FormatStyle FormatStyle =
+
+  llvm::Expected FormatStyleOrError =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+  if (!FormatStyleOrError) {
+llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
+return true;
+  }
+  FormatStyle FormatStyle = *FormatStyleOrError;
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyl

[PATCH] D28222: [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings

2017-01-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, rsmith.
EricWF added a subscriber: cfe-commits.

This patch attempts to re-implement a fix for LWG 2770, but not the actual 
specified PR.

The PR for 2770 specifies tuple_size as only conditionally providing a 
`::value` member. However C++17 structured bindings require `tuple_size` to be complete only if  `tuple_size` is also complete. Therefore 
this patch implements only provides the specialization `tuple_size` iff 
`decltype(tuple_size::value)` is well formed.

Note that the specialization is still provided when `tuple_size::value` is 
well-formed but not a constant expression, meaning that`tuple_size` 
will be ill-formed and generate a diagnostic when used. I believe this behavior 
is preferable to silently not specializing `tuple_size` because it helps 
diagnose users who provide incorrect `tuple_size` specializations.

This fixes http://llvm.org/PR31513.


https://reviews.llvm.org/D28222

Files:
  include/__tuple
  test/libcxx/test/config.py
  
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
  
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  class tuple;
+
+// template 
+//   class tuple_size>
+// : public integral_constant { };
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: libcpp-no-structured-bindings
+
+#include 
+#include 
+#include 
+#include 
+
+struct S { int x; };
+
+void test_decomp_user_type() {
+  {
+S s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &s.x);
+  }
+  {
+S const s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &s.x);
+  }
+}
+
+void test_decomp_tuple() {
+  typedef std::tuple T;
+  {
+T s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+  {
+T const s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+}
+
+
+void test_decomp_pair() {
+  typedef std::pair T;
+  {
+T s{99, 42.1};
+auto [m1, m2] = s;
+auto& [r1, r2] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+  {
+T const s{99, 42.1};
+auto [m1, m2] = s;
+auto& [r1, r2] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+}
+
+void test_decomp_array() {
+  typedef std::array T;
+  {
+T s{{99, 42, -1}};
+auto [m1, m2, m3] = s;
+auto& [r1, r2, r3] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+  {
+T const s{{99, 42, -1}};
+auto [m1, m2, m3] = s;
+auto& [r1, r2, r3] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+}
+
+int main() {
+  test_decomp_user_type();
+  test_decomp_tuple();
+  test_decomp_pair();
+  test_decomp_array();
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
@@ -0,0 +1,65 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  class tuple;
+
+// template 
+//   class tuple_size>
+// : public integral_constant { };
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+#include 
+
+template )>
+constexpr bool is_complete(int) { static_assert(Size > 0, ""); return true; }
+template  constexpr bool is_complete(long) { return false; }
+template  constexpr bool is_complete() { return is_complete(0); }
+
+struct Dummy1 {};
+struct Dummy2 {};
+
+template <>
+class std::tuple_size : public std::integral_constant {};
+
+template 
+void test_complete() {
+  static_assert(is_complete(), "");
+  static_assert(is_complete(), "");
+  static_assert(is_complete(), "");
+  static_assert(is_complete(), "");
+}
+
+template 
+void test_incomplete() {
+  static_assert(!is_complete(), "");
+  static_assert(!is_complete(

[PATCH] D28222: [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings

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

Use the correct patch file this time.


https://reviews.llvm.org/D28222

Files:
  include/__tuple
  test/libcxx/test/config.py
  
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
  
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
  
test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  class tuple;
+
+// template 
+//   class tuple_size>
+// : public integral_constant { };
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: libcpp-no-structured-bindings
+
+#include 
+#include 
+#include 
+#include 
+
+struct S { int x; };
+
+void test_decomp_user_type() {
+  {
+S s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &s.x);
+  }
+  {
+S const s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &s.x);
+  }
+}
+
+void test_decomp_tuple() {
+  typedef std::tuple T;
+  {
+T s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+  {
+T const s{99};
+auto [m1] = s;
+auto& [r1] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+}
+
+
+void test_decomp_pair() {
+  typedef std::pair T;
+  {
+T s{99, 42.1};
+auto [m1, m2] = s;
+auto& [r1, r2] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+  {
+T const s{99, 42.1};
+auto [m1, m2] = s;
+auto& [r1, r2] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+}
+
+void test_decomp_array() {
+  typedef std::array T;
+  {
+T s{{99, 42, -1}};
+auto [m1, m2, m3] = s;
+auto& [r1, r2, r3] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+  {
+T const s{{99, 42, -1}};
+auto [m1, m2, m3] = s;
+auto& [r1, r2, r3] = s;
+assert(m1 == 99);
+assert(&r1 == &std::get<0>(s));
+  }
+}
+
+int main() {
+  test_decomp_user_type();
+  test_decomp_tuple();
+  test_decomp_pair();
+  test_decomp_array();
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
@@ -0,0 +1,65 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  class tuple;
+
+// template 
+//   class tuple_size>
+// : public integral_constant { };
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+#include 
+
+template )>
+constexpr bool is_complete(int) { static_assert(Size > 0, ""); return true; }
+template  constexpr bool is_complete(long) { return false; }
+template  constexpr bool is_complete() { return is_complete(0); }
+
+struct Dummy1 {};
+struct Dummy2 {};
+
+template <>
+class std::tuple_size : public std::integral_constant {};
+
+template 
+void test_complete() {
+  static_assert(is_complete(), "");
+  static_assert(is_complete(), "");
+  static_assert(is_complete(), "");
+  static_assert(is_complete(), "");
+}
+
+template 
+void test_incomplete() {
+  static_assert(!is_complete(), "");
+  static_assert(!is_complete(), "");
+  static_assert(!is_complete(), "");
+  static_assert(!is_complete(), "");
+}
+
+
+int main()
+{
+  test_complete >();
+  test_complete >();
+  test_complete>();
+  test_complete >();
+  test_complete >();
+  test_complete();
+
+  test_incomplete();
+  test_incomplete();
+  test_incomplete&>();
+  test_incomplete();
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp
@@ -0,0 +1,86 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+/

[libcxx] r290857 - clang-format: tweak configuration

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 22:23:52 2017
New Revision: 290857

URL: http://llvm.org/viewvc/llvm-project?rev=290857&view=rev
Log:
clang-format: tweak configuration

Update the configuration to reflect the style more accurately.  Pointers
are tied to the left.  Braces are split on classes/structs and
functions.

Modified:
libcxx/trunk/.clang-format

Modified: libcxx/trunk/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/.clang-format?rev=290857&r1=290856&r2=290857&view=diff
==
--- libcxx/trunk/.clang-format (original)
+++ libcxx/trunk/.clang-format Mon Jan  2 22:23:52 2017
@@ -4,6 +4,12 @@ BasedOnStyle: LLVM
 Language: Cpp
 
 AlwaysBreakTemplateDeclarations: true
+AllowShortFunctionsOnASingleLine: Inline
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterClass: true
+  AfterFunction: true
+PointerAlignment: Left
 
 # Disable formatting options which may break tests.
 SortIncludes: false


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


[libcxx] r290856 - build: remove now unused UNIX_CAT

2017-01-02 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Jan  2 22:23:50 2017
New Revision: 290856

URL: http://llvm.org/viewvc/llvm-project?rev=290856&view=rev
Log:
build: remove now unused UNIX_CAT

THe previous change replaced the use of `cat` or `type` with a custom
python script.  Remove the now unused command determining.

Modified:
libcxx/trunk/include/CMakeLists.txt

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=290856&r1=290855&r2=290856&view=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Mon Jan  2 22:23:50 2017
@@ -28,10 +28,6 @@ if (LIBCXX_INSTALL_HEADERS)
   )
 
   if (LIBCXX_NEEDS_SITE_CONFIG)
-set(UNIX_CAT cat)
-if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
-  set(UNIX_CAT type)
-endif()
 # Generate and install a custom __config header. The new header is created
 # by  prepending __config_site to the current __config header.
 add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config


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


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/__threading_support:300-305
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+{
+  InitializeSRWLock(__m);
+  return 0;
+}
+

majnemer wrote:
> I don't think you can use slim rw locks for recursive locks. I think we will 
> need to use `CRITICAL_SECTION` for those. std::recursive_mutex can't be used 
> with std::condition_variable AFAIK so all you need (I think) is recursive 
> versions of `__libcpp_mutex_...`
> 
> Recursive locks should be used far less frequently which makes it valuable, 
> IMO, to use slim rw locks for the non-recursive mutex implementation.
You are absolutely right.  That was something that I looked at originally and 
went with the CS.  However, the overhead of a tagged struct is 5 or 9 bytes 
(sizeof(void *) + 1) bytes (ignoring padding for MS ABI).  Going with that 
should give the benefits of always being able to properly initialize the CS 
instead of the kludge.



Comment at: include/__threading_support:355
+  // TODO(compnerd) handle spurious timeout
+  if (!SleepConditionVariableSRW(__cv, __m,
+ duration_cast(timeout).count(),

majnemer wrote:
> I don't think it should be `__libcpp_condvar_timedwait'`s problem. 
> `__libcpp_condvar_timedwait` wraps `pthread_cond_timedwait` on POSIX 
> platforms and the caller of `__libcpp_condvar_wait` properly handles spurious 
> wakeups. The caller of `__libcpp_condvar_timedwait` probably should be 
> audited.
SG; seems that there is a single user in condition_variable.cpp


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82834.
compnerd added a comment.

switch between a CRITICAL_SECTION and SRWLOCK


Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -32,9 +32,20 @@
 #include <__external_threading>
 #else

+#if !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) &&\
+!defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#error "unknown threading model"
+#endif
+
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 
+#include 
+#include 
 #endif

 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -62,6 +73,28 @@

 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+// Mutex
+typedef struct {
+  CRITICAL_SECTION __mutex;
+  SRWLOCK __lock;
+  unsigned char __use_mutex : 1;
+  unsigned char __reserved : 7;
+} __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER {{0}, SRWLOCK_INIT, 0}
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
 #endif

 // Mutex
@@ -267,6 +300,192 @@
   pthread_setspecific(__key, __p);
 }

+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{
+  if (__m->__use_mutex)
+return 0;
+  InitializeCriticalSection(&__m->__mutex);
+  __m->__use_mutex = 1;
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
+{
+  if (__m->__use_mutex)
+EnterCriticalSection(&__m->__mutex);
+  else
+AcquireSRWLockExclusive(&__m->__lock);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
+{
+  if (__m->__use_mutex)
+return TryEnterCriticalSection(&__m->__mutex);
+  return TryAcquireSRWLockExclusive(&__m->__lock);
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
+{
+  if (__m->__use_mutex)
+LeaveCriticalSection(&__m->__mutex);
+  else
+ReleaseSRWLockExclusive(&__m->__lock);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
+{
+  if (__m->__use_mutex)
+SleepConditionVariableCS(__cv, &__m->__mutex, INFINITE);
+  else
+SleepConditionVariableSRW(__cv, &__m->__lock, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m,
+   timespec* __ts)
+{
+  using namespace _VSTD::chrono;
+  auto timeout = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  if (__m->__use_mutex) {
+if (!SleepConditionVariableCS(__cv, &__m->__mutex,
+  duration_cast(timeout).count()))
+  return GetLastError();
+  } else {
+// TODO(compnerd) handle timeouts < 10ms
+if (!SleepConditionVariableSRW(__cv, &__m->__lock,
+   duration_cast(timeout).count(),
+   0))
+  return GetLastError();
+  }
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+  static_cast(__cv);
+  return 0;
+}
+
+// Thread ID
+_LIBCPP_ALWAYS_INLINE
+bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
+  __libcpp_thread_id __rhs)
+{
+  return __lhs == __rhs;
+}
+
+_LIBCPP_ALWAYS_INLINE
+bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
+{
+  return __lhs < __rhs;
+}
+
+// Thread
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*),
+   void* __arg)
+{
+  // TODO(compnerd) provide a wrapper for CC adjustment
+  *__t = reinterpret_cast(_beginthreadex(
+  NULL, 0, (unsigned int(WINAPI*)(void*))__func, __arg, 0, NULL));
+  if (*__t)
+return 0;
+  return GetLastError();
+}
+
+_LIBCPP_ALWAYS_INLINE
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+  return GetCurrentThreadId();
+}
+
+_LIBCPP_ALWAYS_INLINE
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
+{
+  return GetThreadId(*__t);
+}
+
+_LIB

[PATCH] D28220: provide Win32 native threading

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

Could you upload this patch with more context?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: include/__threading_support:300-305
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+{
+  InitializeSRWLock(__m);
+  return 0;
+}
+

compnerd wrote:
> majnemer wrote:
> > I don't think you can use slim rw locks for recursive locks. I think we 
> > will need to use `CRITICAL_SECTION` for those. std::recursive_mutex can't 
> > be used with std::condition_variable AFAIK so all you need (I think) is 
> > recursive versions of `__libcpp_mutex_...`
> > 
> > Recursive locks should be used far less frequently which makes it valuable, 
> > IMO, to use slim rw locks for the non-recursive mutex implementation.
> You are absolutely right.  That was something that I looked at originally and 
> went with the CS.  However, the overhead of a tagged struct is 5 or 9 bytes 
> (sizeof(void *) + 1) bytes (ignoring padding for MS ABI).  Going with that 
> should give the benefits of always being able to properly initialize the CS 
> instead of the kludge.
Er, isn't the overhead much more than that? IIRC, `CRITICAL_SECTION` is quite 
large. You'd be making all the users of `std::mutex` pay for the space of 
`std::recursive_mutex`...


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28220: provide Win32 native threading

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



Comment at: include/__threading_support:83
+} __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER {{0}, SRWLOCK_INIT, 0}
+

Why not a tagged union?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28220: provide Win32 native threading

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



Comment at: include/__threading_support:300-305
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+{
+  InitializeSRWLock(__m);
+  return 0;
+}
+

majnemer wrote:
> compnerd wrote:
> > majnemer wrote:
> > > I don't think you can use slim rw locks for recursive locks. I think we 
> > > will need to use `CRITICAL_SECTION` for those. std::recursive_mutex can't 
> > > be used with std::condition_variable AFAIK so all you need (I think) is 
> > > recursive versions of `__libcpp_mutex_...`
> > > 
> > > Recursive locks should be used far less frequently which makes it 
> > > valuable, IMO, to use slim rw locks for the non-recursive mutex 
> > > implementation.
> > You are absolutely right.  That was something that I looked at originally 
> > and went with the CS.  However, the overhead of a tagged struct is 5 or 9 
> > bytes (sizeof(void *) + 1) bytes (ignoring padding for MS ABI).  Going with 
> > that should give the benefits of always being able to properly initialize 
> > the CS instead of the kludge.
> Er, isn't the overhead much more than that? IIRC, `CRITICAL_SECTION` is quite 
> large. You'd be making all the users of `std::mutex` pay for the space of 
> `std::recursive_mutex`...
Yeah, CRITICAL_SECTION is 24 bytes vs 4 bytes for a SRWLOCK.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


LLVM buildmaster will be restarted in few minutes

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

LLVM buildmaster will be updated and restarted in few minutes.

Thanks

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


[PATCH] D28223: clean up use of _WIN32

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: EricWF, mclow.lists, smeenai.
compnerd added a subscriber: cfe-commits.
compnerd set the repository for this revision to rL LLVM.

Replace the use of `_WIN32` in libc++.  Replace most use with a C runtime check 
`_LIBCPP_MSVCRT` or the new `_LIBCPP_WIN32` to indicate that we are using the 
Win32 API.  Use a new `_LIBCPP_WCHAR_IS_UCS2` to indicate that we are on an 
environment that has a short `wchar_t`.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223

Files:
  include/__config
  include/__locale
  include/support/win32/support.h
  include/type_traits
  src/chrono.cpp
  src/include/config_elast.h
  src/locale.cpp
  src/new.cpp
  src/system_error.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -24,16 +24,17 @@
 # endif // defined(BSD)
 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
-#if !defined(_WIN32)
+#if defined(__unix__) || defined(__APPLE__)
 # include 
-#endif // !_WIN32
+#endif // defined(__unix__) || defined(__APPLE__)
 
 #if defined(__NetBSD__)
 #pragma weak pthread_create // Do not create libpthread dependency
 #endif
-#if defined(_WIN32)
+
+#if defined(_LIBCPP_WIN32)
 #include 
-#endif
+#endif // defined(_LIBCPP_WIN32)
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -91,7 +92,7 @@
 if (result < 0)
 return 0;
 return static_cast(result);
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_WIN32)
 SYSTEM_INFO info;
 GetSystemInfo(&info);
 return info.dwNumberOfProcessors;
Index: src/system_error.cpp
===
--- src/system_error.cpp
+++ src/system_error.cpp
@@ -65,7 +65,7 @@
 
 string do_strerror_r(int ev);
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSVCRT)
 string do_strerror_r(int ev) {
   char buffer[strerror_buff_size];
   if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -72,7 +72,7 @@
 if (static_cast(alignment) < sizeof(void*))
   alignment = std::align_val_t(sizeof(void*));
 void* p;
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSVCRT)
 while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr)
 #else
 while (::posix_memalign(&p, static_cast(alignment), size) != 0)
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -3254,7 +3254,7 @@
 const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
 extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
 {
-#if _WIN32
+#if defined(_LIBCPP_WCHAR_IS_UCS2)
 const uint16_t* _frm = reinterpret_cast(frm);
 const uint16_t* _frm_end = reinterpret_cast(frm_end);
 const uint16_t* _frm_nxt = _frm;
@@ -3266,7 +3266,7 @@
 uint8_t* _to = reinterpret_cast(to);
 uint8_t* _to_end = reinterpret_cast(to_end);
 uint8_t* _to_nxt = _to;
-#if _WIN32
+#if defined(_LIBCPP_WCHAR_IS_UCS2)
 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
 _Maxcode_, _Mode_);
 #else
@@ -3286,7 +3286,7 @@
 const uint8_t* _frm = reinterpret_cast(frm);
 const uint8_t* _frm_end = reinterpret_cast(frm_end);
 const uint8_t* _frm_nxt = _frm;
-#if _WIN32
+#if defined(_LIBCCPP_WCHAR_IS_UCS2)
 uint16_t* _to = reinterpret_cast(to);
 uint16_t* _to_end = reinterpret_cast(to_end);
 uint16_t* _to_nxt = _to;
Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -10,7 +10,7 @@
 #ifndef _LIBCPP_CONFIG_ELAST
 #define _LIBCPP_CONFIG_ELAST
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSCVRT)
 #include 
 #else
 #include 
@@ -28,7 +28,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_MSCVRT)
 #define _LIBCPP_ELAST _sys_nerr
 #else
 // Warn here so that the person doing the libcxx port has an easier time:
Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,7 +12,7 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_WIN32)
 #define WIN32_LEAN_AND_MEAN
 #define VC_EXTRA_LEAN
 #include 
@@ -22,13 +22,13 @@
 #else
 #if !defined(CLOCK_REALTIME)
 #include // for gettimeofday and timeval
-#endif
-#endif
+#endif // !defined(CLOCK_REALTIME)
+#endif // defined(_LIBCPP_WIN32)
 
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_WIN32) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32) &&

[PATCH] D28223: clean up use of _WIN32

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

Sweet.




Comment at: include/__config:158
+#if defined(_WIN32)
+#  define _LIBCPP_WIN32 1
 #  define _LIBCPP_LITTLE_ENDIAN 1

Perhaps `_LIBCPP_WIN32API` instead, to be clear that this is specific to the 
usage of Win32 APIs, rather than just a general catch-all libc++ on Windows 
macro?



Comment at: include/__config:791
 // Most unix variants have catopen.  These are the specific ones that don't.
-#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
 #define _LIBCPP_HAS_CATOPEN 1

Windows has `catopen`?



Comment at: include/type_traits:1684
 // PE/COFF does not support alignment beyond 8192 (=0x2000)
-#if !defined(_WIN32)
+#if !defined(__ELF__) && !defined(__MACH__)
 _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);

Might be cleaner to have a `_LIBCPP_COFF` macro (both here and for the similar 
`__config` change), to make the intent clearer?


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28224: [libcxx, regex] Throw exception after too many steps.

2017-01-02 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
timshen added a subscriber: cfe-commits.
Herald added a reviewer: EricWF.

This prevents the backtracking regex engines from "hanging forever"
under certain input.


https://reviews.llvm.org/D28224

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
  libcxx/test/std/re/re.alg/re.alg.search/exponential.pass.cpp

Index: libcxx/test/std/re/re.alg/re.alg.search/exponential.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/exponential.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// Throw exception after spent too many cycles with respect to the length of the input string.
+
+#include 
+#include 
+
+int main() {
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+try {
+  std::regex_search(
+  "",
+  std::regex(
+  "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?",
+  op));
+  assert(false);
+} catch (const std::regex_error &e) {
+  assert(e.code() == std::regex_constants::error_complexity);
+}
+  }
+  std::string s(10, 'a');
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+assert(std::regex_search(s, std::regex("a*", op)));
+  }
+  return 0;
+}
Index: libcxx/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// Throw exception after spent too many cycles with respect to the length of the input string.
+
+#include 
+#include 
+
+int main() {
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+try {
+  std::regex_match(
+  "",
+  std::regex(
+  "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?",
+  op));
+  assert(false);
+} catch (const std::regex_error &e) {
+  assert(e.code() == std::regex_constants::error_complexity);
+}
+  }
+  std::string s(10, 'a');
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+assert(std::regex_match(s, std::regex("a*", op)));
+  }
+  return 0;
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -771,6 +771,8 @@
 #pragma GCC system_header
 #endif
 
+#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace regex_constants
@@ -5551,8 +5553,14 @@
 __states.back().__node_ = __st;
 __states.back().__flags_ = __flags;
 __states.back().__at_first_ = __at_first;
+int __counter = 0;
+int __length = __last - __first;
 do
 {
+++__counter;
+if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
+__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
+  __throw_regex_error();
 __state& __s = __states.back();
 if (__s.__node_)
 __s.__node_->__exec(__s);
@@ -5626,8 +5634,14 @@
 __states.back().__flags_ = __flags;
 __states.back().__at_first_ = __at_first;

[PATCH] D28224: [libcxx, regex] Throw exception after too many steps.

2017-01-02 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 82840.
timshen added a comment.

Detect user defined _LIBCPP_REGEX_COMPLEXITY_FACTOR first.


https://reviews.llvm.org/D28224

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
  libcxx/test/std/re/re.alg/re.alg.search/exponential.pass.cpp

Index: libcxx/test/std/re/re.alg/re.alg.search/exponential.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/exponential.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// Throw exception after spent too many cycles with respect to the length of the input string.
+
+#include 
+#include 
+
+int main() {
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+try {
+  std::regex_search(
+  "",
+  std::regex(
+  "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?",
+  op));
+  assert(false);
+} catch (const std::regex_error &e) {
+  assert(e.code() == std::regex_constants::error_complexity);
+}
+  }
+  std::string s(10, 'a');
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+assert(std::regex_search(s, std::regex("a*", op)));
+  }
+  return 0;
+}
Index: libcxx/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// Throw exception after spent too many cycles with respect to the length of the input string.
+
+#include 
+#include 
+
+int main() {
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+try {
+  std::regex_match(
+  "",
+  std::regex(
+  "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?",
+  op));
+  assert(false);
+} catch (const std::regex_error &e) {
+  assert(e.code() == std::regex_constants::error_complexity);
+}
+  }
+  std::string s(10, 'a');
+  for (std::regex_constants::syntax_option_type op :
+   {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
+std::regex::awk}) {
+assert(std::regex_match(s, std::regex("a*", op)));
+  }
+  return 0;
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -771,6 +771,10 @@
 #pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_REGEX_COMPLEXITY_FACTOR)
+#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace regex_constants
@@ -5551,8 +,14 @@
 __states.back().__node_ = __st;
 __states.back().__flags_ = __flags;
 __states.back().__at_first_ = __at_first;
+int __counter = 0;
+int __length = __last - __first;
 do
 {
+++__counter;
+if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
+__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
+  __throw_regex_error();
 __state& __s = __states.back();
 if (__s.__node_)
 __s.__node_->__exec(__s);
@@ -5626,8 +5636,14 @@
 __states.back().__flags_ = __flags;
 __states.back().__at_first_ = __at_first;
 bool __matched = false;
+int __

[PATCH] D28224: [libcxx, regex] Throw exception after too many steps.

2017-01-02 Thread Tim Shen via Phabricator via cfe-commits
timshen added a comment.

I defined and exported a macro _LIBCPP_REGEX_COMPLEXITY_FACTOR in the hope that 
even when the library is shipped to the user, and when the user finds the 
factor to be inappropriate, they can override it.

I'm not aware of and exported macro policy though, please advice. :)


https://reviews.llvm.org/D28224



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


Re: [libcxx] r290856 - build: remove now unused UNIX_CAT

2017-01-02 Thread Eric Fiselier via cfe-commits
Woops. Thanks for cleaning up that dead code.

On Mon, Jan 2, 2017 at 9:23 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Mon Jan  2 22:23:50 2017
> New Revision: 290856
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290856&view=rev
> Log:
> build: remove now unused UNIX_CAT
>
> THe previous change replaced the use of `cat` or `type` with a custom
> python script.  Remove the now unused command determining.
>
> Modified:
> libcxx/trunk/include/CMakeLists.txt
>
> Modified: libcxx/trunk/include/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> CMakeLists.txt?rev=290856&r1=290855&r2=290856&view=diff
> 
> ==
> --- libcxx/trunk/include/CMakeLists.txt (original)
> +++ libcxx/trunk/include/CMakeLists.txt Mon Jan  2 22:23:50 2017
> @@ -28,10 +28,6 @@ if (LIBCXX_INSTALL_HEADERS)
>)
>
>if (LIBCXX_NEEDS_SITE_CONFIG)
> -set(UNIX_CAT cat)
> -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
> -  set(UNIX_CAT type)
> -endif()
>  # Generate and install a custom __config header. The new header is
> created
>  # by  prepending __config_site to the current __config header.
>  add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
>
>
> ___
> 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] D28220: provide Win32 native threading

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



Comment at: include/__threading_support:44
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 

Do these definitions have any affect when `` has already been 
included?
Also are these definitions required before including the header, or merely 
beneficial? If they are required this will make the `` header a pain 
to use with modules.





Comment at: include/__threading_support:306
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{

The initial `__libcpp_foo` declarations specify the correct linkage and 
visibility attributes. Please don't decorate the definitions.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82843.
compnerd added a comment.

update for separation of mutex and recursive_mutex.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -32,9 +32,20 @@
 #include <__external_threading>
 #else
 
+#if !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) &&\
+!defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#error "unknown threading model"
+#endif
+
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 
+#include 
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -64,6 +75,25 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
 #endif
 
 struct __libcpp_mutex_reference {
@@ -306,6 +336,192 @@
   pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+EnterCriticalSection(__m);
+  else
+AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+return TryEnterCriticalSection(__m);
+  return TryAcquireSRWLockExclusive(__m);
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+LeaveCriticalSection(__m);
+  else
+ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_reference&& __m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv,
+  __libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+SleepConditionVariableCS(__cv, __m, INFINITE);
+  else
+SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference&& __m,
+   timespec* __ts)
+{
+  using namespace _VSTD::chrono;
+  auto timeout = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+
+  // TODO(compnerd) handle timeouts < 10ms
+  if (__m.__recursive) {
+if (!SleepConditionVariableCS(__cv, __m,
+  duration_cast(timeout).count()))
+  return GetLastError();
+  } else {
+if (!SleepConditionVariableSRW(__cv, __m,
+   duration_cast(timeout).count(),
+   0))
+  return GetLastError();
+  }
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+  static_cast(__cv);
+  return 0;
+}
+
+// Thread ID
+_LIBCPP_ALWAYS_INLINE
+bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
+  __libcpp_thread_id __rhs)
+{
+  return __lhs == __rhs;
+}
+
+_LIBCPP_ALWAYS_INLINE
+bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
+{
+  return __lhs < __rhs;
+}
+
+// Thread
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*),
+   void* __arg)
+{
+  // TODO(compnerd) provide a wrapper for CC adjustment
+  *__t = reinterpret_cast(_beginthreadex(
+  NULL, 0, (unsigned int(WINAPI*)(void*))__func, __arg, 0, NULL));
+  if (*__t)
+return 0;
+  return GetLastError();
+}
+
+_LIBCPP_ALWAYS_INLINE
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+  return GetCurrentThreadId();
+}
+
+_LIBCPP_ALWAYS_INLINE
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
+{
+  return GetThreadId(*__t);
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_join(__libcpp_thread_t* __t)
+{
+  if (WaitForSing

[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: EricWF, mclow.lists.
compnerd added subscribers: majnemer, smeenai, kastiglione, cfe-commits.
compnerd set the repository for this revision to rL LLVM.

Introduce the new `__libcpp_recursive_mutex_t` which differentiates
between a recursive and non-recursive mutex.  This is motivated by
windows, where a much lighter wait alternative exists for non-recursive
locks.  On pthreads, the same lock type is available with a different
typename and no static initializer value.

Introduce an internal `__libcpp_mutex_reference` to provide an
implicitly move constructed with type-erasure to let the condition
variable handling get a type-erased discriminated-union which we can
handle appropriately.


Repository:
  rL LLVM

https://reviews.llvm.org/D28226

Files:
  include/__threading_support
  include/mutex

Index: include/mutex
===
--- include/mutex
+++ include/mutex
@@ -206,7 +206,7 @@
 
 class _LIBCPP_TYPE_VIS recursive_mutex
 {
-__libcpp_mutex_t __m_;
+__libcpp_recursive_mutex_t __m_;
 
 public:
  recursive_mutex();
@@ -221,7 +221,7 @@
 bool try_lock() _NOEXCEPT;
 void unlock()  _NOEXCEPT;
 
-typedef __libcpp_mutex_t* native_handle_type;
+typedef __libcpp_recursive_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY
 native_handle_type native_handle() {return &__m_;}
 };
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -50,6 +50,8 @@
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
+typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
@@ -64,21 +66,56 @@
 typedef pthread_key_t __libcpp_tls_key;
 #endif
 
+struct __libcpp_mutex_reference {
+  const bool __recursive;
+  void * const __value;
+
+  _LIBCPP_CONSTEXPR
+  __libcpp_mutex_reference(__libcpp_mutex_t* m) _NOEXCEPT
+  : __recursive(false), __value(m)
+  {
+  }
+
+  template ::value>::type>
+  _LIBCPP_CONSTEXPR
+  __libcpp_mutex_reference(__libcpp_recursive_mutex_t* m) _NOEXCEPT
+  : __recursive(true), __value(m)
+  {
+  }
+
+  operator __libcpp_mutex_t*() const _NOEXCEPT
+  {
+return reinterpret_cast<__libcpp_mutex_t*>(__value);
+  }
+
+  template ::value>::type>
+  operator __libcpp_recursive_mutex_t*() const _NOEXCEPT
+  {
+return reinterpret_cast<__libcpp_recursive_mutex_t*>(__value);
+  }
+};
+
 // Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
+int __libcpp_mutex_destroy(__libcpp_mutex_reference&& __m);
 
 // Condition variable
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -88,11 +125,12 @@
 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_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts);
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference&& __m, timespec* __ts);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
@@ -136,7 +174,7 @@
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
   pthread_mutexattr_t attr;
   int __ec = pthread_mutexattr_init(&attr);
@@ -160,22 +198,22 @@
   return 0;
 }
 
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_lock(__m);
 }
 
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_trylock(__m);
 }
 
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_unlock(__m);
 }
 
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+int __libcpp

[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82845.
compnerd added a comment.

add more context


Repository:
  rL LLVM

https://reviews.llvm.org/D28226

Files:
  include/__threading_support
  include/mutex

Index: include/mutex
===
--- include/mutex
+++ include/mutex
@@ -206,7 +206,7 @@
 
 class _LIBCPP_TYPE_VIS recursive_mutex
 {
-__libcpp_mutex_t __m_;
+__libcpp_recursive_mutex_t __m_;
 
 public:
  recursive_mutex();
@@ -221,7 +221,7 @@
 bool try_lock() _NOEXCEPT;
 void unlock()  _NOEXCEPT;
 
-typedef __libcpp_mutex_t* native_handle_type;
+typedef __libcpp_recursive_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY
 native_handle_type native_handle() {return &__m_;}
 };
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -50,6 +50,8 @@
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
+typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
@@ -64,21 +66,56 @@
 typedef pthread_key_t __libcpp_tls_key;
 #endif
 
+struct __libcpp_mutex_reference {
+  const bool __recursive;
+  void * const __value;
+
+  _LIBCPP_CONSTEXPR
+  __libcpp_mutex_reference(__libcpp_mutex_t* m) _NOEXCEPT
+  : __recursive(false), __value(m)
+  {
+  }
+
+  template ::value>::type>
+  _LIBCPP_CONSTEXPR
+  __libcpp_mutex_reference(__libcpp_recursive_mutex_t* m) _NOEXCEPT
+  : __recursive(true), __value(m)
+  {
+  }
+
+  operator __libcpp_mutex_t*() const _NOEXCEPT
+  {
+return reinterpret_cast<__libcpp_mutex_t*>(__value);
+  }
+
+  template ::value>::type>
+  operator __libcpp_recursive_mutex_t*() const _NOEXCEPT
+  {
+return reinterpret_cast<__libcpp_recursive_mutex_t*>(__value);
+  }
+};
+
 // Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
+int __libcpp_mutex_destroy(__libcpp_mutex_reference&& __m);
 
 // Condition variable
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -88,11 +125,12 @@
 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_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts);
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference&& __m, timespec* __ts);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
@@ -136,7 +174,7 @@
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
   pthread_mutexattr_t attr;
   int __ec = pthread_mutexattr_init(&attr);
@@ -160,22 +198,22 @@
   return 0;
 }
 
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_lock(__m);
 }
 
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_trylock(__m);
 }
 
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_unlock(__m);
 }
 
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+int __libcpp_mutex_destroy(__libcpp_mutex_reference&& __m)
 {
   return pthread_mutex_destroy(__m);
 }
@@ -191,13 +229,14 @@
   return pthread_cond_broadcast(__cv);
 }
 
-int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv,
+  __libcpp_mutex_reference&& __m)
 {
   return pthread_cond_wait(__cv, __m);
 }
 
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts)
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference&& __m, timespec* __ts)
 

[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82846.
compnerd added a comment.

add more context


Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -32,9 +32,20 @@
 #include <__external_threading>
 #else
 
+#if !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) &&\
+!defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#error "unknown threading model"
+#endif
+
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 
+#include 
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -64,6 +75,25 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
 #endif
 
 struct __libcpp_mutex_reference {
@@ -306,6 +336,192 @@
   pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+EnterCriticalSection(__m);
+  else
+AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+return TryEnterCriticalSection(__m);
+  return TryAcquireSRWLockExclusive(__m);
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+LeaveCriticalSection(__m);
+  else
+ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_reference&& __m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv,
+  __libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+SleepConditionVariableCS(__cv, __m, INFINITE);
+  else
+SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference&& __m,
+   timespec* __ts)
+{
+  using namespace _VSTD::chrono;
+  auto timeout = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+
+  // TODO(compnerd) handle timeouts < 10ms
+  if (__m.__recursive) {
+if (!SleepConditionVariableCS(__cv, __m,
+  duration_cast(timeout).count()))
+  return GetLastError();
+  } else {
+if (!SleepConditionVariableSRW(__cv, __m,
+   duration_cast(timeout).count(),
+   0))
+  return GetLastError();
+  }
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+  static_cast(__cv);
+  return 0;
+}
+
+// Thread ID
+_LIBCPP_ALWAYS_INLINE
+bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
+  __libcpp_thread_id __rhs)
+{
+  return __lhs == __rhs;
+}
+
+_LIBCPP_ALWAYS_INLINE
+bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
+{
+  return __lhs < __rhs;
+}
+
+// Thread
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*),
+   void* __arg)
+{
+  // TODO(compnerd) provide a wrapper for CC adjustment
+  *__t = reinterpret_cast(_beginthreadex(
+  NULL, 0, (unsigned int(WINAPI*)(void*))__func, __arg, 0, NULL));
+  if (*__t)
+return 0;
+  return GetLastError();
+}
+
+_LIBCPP_ALWAYS_INLINE
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+  return GetCurrentThreadId();
+}
+
+_LIBCPP_ALWAYS_INLINE
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
+{
+  return GetThreadId(*__t);
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_join(__libcpp_thread_t* __t)
+{
+  if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) =

[PATCH] D28220: provide Win32 native threading

2017-01-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/__threading_support:46
+inline _LIBCPP_INLINE_VISIBILITY
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+

EricWF wrote:
> The forward declarations of the `__libcpp_` threading wrapper should be 
> shared between all API's. Please don't add your own forward declarations for 
> Windows. 
Yeah, restructed that.  There is now the dependent patch for the type-erased 
mutex handling.



Comment at: include/__threading_support:44
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 

EricWF wrote:
> Do these definitions have any affect when `` has already been 
> included?
> Also are these definitions required before including the header, or merely 
> beneficial? If they are required this will make the `` header a 
> pain to use with modules.
> 
> 
No, they dont effect it once it has been included.  They are beneficial since 
they reduce the amount of stuff that gets included (including things which, at 
least when I last checked, can cause clang to choke).


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

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



Comment at: include/__threading_support:82
+typename = typename _VSTD::enable_if::value>::type>
+  _LIBCPP_CONSTEXPR

indentation looks a bit strange 


Repository:
  rL LLVM

https://reviews.llvm.org/D28226



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