[clang] af2968e - [clang] Fix invalid comparator in tablegen

2020-04-16 Thread Eric Fiselier via cfe-commits

Author: Eric Fiselier
Date: 2020-04-16T18:38:32-04:00
New Revision: af2968e37f4c95846ffe287b64a4fcd72c765bee

URL: 
https://github.com/llvm/llvm-project/commit/af2968e37f4c95846ffe287b64a4fcd72c765bee
DIFF: 
https://github.com/llvm/llvm-project/commit/af2968e37f4c95846ffe287b64a4fcd72c765bee.diff

LOG: [clang] Fix invalid comparator in tablegen

Summary: The current version of the comparator does not introduce a strict weak 
ordering.

Reviewers: fowles, bkramer, sdesmalen

Reviewed By: sdesmalen

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/SveEmitter.cpp 
b/clang/utils/TableGen/SveEmitter.cpp
index 79258a8fbbf2..8ef65612a243 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -909,9 +910,10 @@ void SVEEmitter::createHeader(raw_ostream ) {
   std::stable_sort(
   Defs.begin(), Defs.end(), [](const std::unique_ptr ,
const std::unique_ptr ) {
-return A->getGuard() < B->getGuard() ||
-   (unsigned)A->getClassKind() < (unsigned)B->getClassKind() ||
-   A->getName() < B->getName();
+auto ToTuple = [](const std::unique_ptr ) {
+  return std::make_tuple(I->getGuard(), (unsigned)I->getClassKind(), 
I->getName());
+};
+return ToTuple(A) < ToTuple(B);
   });
 
   StringRef InGuard = "";



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


Re: [PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Eric Fiselier via cfe-commits
On Wed, Mar 11, 2020 at 8:35 PM Arthur O'Dwyer via Phabricator <
revi...@reviews.llvm.org> wrote:

> Quuxplusone added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h:27
> +class UnintendedADLCheck : public ClangTidyCheck {
> +  const bool IgnoreOverloadedOperators;
> +  const std::vector AllowedIdentifiers;
> 
> EricWF wrote:
> > I think we should always ignore operators. I don't see value in having a
> mode where every comparison triggers this warning.
> >
> I think there's value in that mode, for library writers (not libc++) who
> really care about finding every unintentional ADL in their whole library.
> The standard library is designed not-to-work with types like
> [`Holder`](
> https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/),
> but someone else's library might be designed to work even in that case, and
> then they'd want to hear about ADL lookups for things like `operator,`.
> Besides, it's just 1 extra line of code in the patch, isn't it?
>

I think the matcher you're describing this library to want is:

cxxOperatorCallExpr()

Because every instance of that node denotes a call to an overloaded
operator written using operator syntax.
This check doesn't need to indulge that strange use case.


> However, I now think I may not understand how this check works. I thought
> it looked for unqualified calls (even in templates) that "may" use ADL, but
> now that I look again at the tests, it seems to trigger only on concrete
> calls (in concrete template instantiations) that "do" use ADL, which sounds
> still useful but much less comprehensive than I had thought.
>
> I think it would catch
> ```
> template void foo(T t) { t, 0; }
> struct S { friend void operator,(S, int); };
> template void foo(S);
> ```
> but not
> ```
> template void foo(T t) { t, 0; }
> struct S { friend void operator,(S, int); };
> template void foo(int);
> ```
> or
> ```
> template void foo(T t) { t, 0; }
> ```
> is that right?
>
>
That's correct.


>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D72282/new/
>
> https://reviews.llvm.org/D72282
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 020ed67 - [clang-tidy] Fix check for Abseil internal namespace access

2020-01-21 Thread Eric Fiselier via cfe-commits

Author: Eric Fiselier
Date: 2020-01-21T15:21:53-05:00
New Revision: 020ed6713d889a95f8c98d7725c87b458d99f6b3

URL: 
https://github.com/llvm/llvm-project/commit/020ed6713d889a95f8c98d7725c87b458d99f6b3
DIFF: 
https://github.com/llvm/llvm-project/commit/020ed6713d889a95f8c98d7725c87b458d99f6b3.diff

LOG: [clang-tidy] Fix check for Abseil internal namespace access

This change makes following modifications:
  * If reference originated from macro expansion, we report location inside of
the macro instead of location where macro is referenced.
  * If for any reason deduced location is not correct we silently ignore it.

Patch by Gennadiy Rozental (roge...@google.com)
Reviewed as https://reviews.llvm.org/D72484

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/Inputs/absl/strings/internal-file.h

clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
index dcb8585d55a9..3ce937a75649 100644
--- a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
@@ -37,7 +37,13 @@ void NoInternalDependenciesCheck::check(const 
MatchFinder::MatchResult )
   const auto *InternalDependency =
   Result.Nodes.getNodeAs("InternalDep");
 
-  diag(InternalDependency->getBeginLoc(),
+  SourceLocation LocAtFault =
+  Result.SourceManager->getSpellingLoc(InternalDependency->getBeginLoc());
+
+  if (!LocAtFault.isValid())
+return;
+
+  diag(LocAtFault,
"do not reference any 'internal' namespaces; those implementation "
"details are reserved to Abseil");
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/absl/strings/internal-file.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/absl/strings/internal-file.h
index 6014278e2606..31798661a80f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/absl/strings/internal-file.h
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/absl/strings/internal-file.h
@@ -15,6 +15,8 @@ template  P InternalTemplateFunction(P a) {}
 
 namespace container_internal {
 struct InternalStruct {};
+
+template  struct InternalTemplate {};
 } // namespace container_internal
 } // namespace absl
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
index 272d0060bdb7..2949d7fdd027 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
@@ -44,5 +44,18 @@ std::string Str = absl::StringsFunction("a");
 void MacroUse() {
   USE_INTERNAL(Function); // no-warning
   USE_EXTERNAL(Function);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' 
namespaces; those implementation details are reserved to Abseil
+  // CHECK-MESSAGES: :[[@LINE-5]]:25: warning: do not reference any 'internal' 
namespaces; those implementation details are reserved to Abseil
 }
+
+class A : absl::container_internal::InternalStruct {};
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not reference any 'internal' 
namespaces; those implementation details are reserved to Abseil
+
+template 
+class B : absl::container_internal::InternalTemplate {};
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not reference any 'internal' 
namespaces; those implementation details are reserved to Abseil
+
+template  class C : absl::container_internal::InternalTemplate {
+public:
+  template  static C Make(U *p) { return C{}; }
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:33: warning: do not reference any 'internal' 
namespaces; those implementation details are reserved to Abseil



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


[clang-tools-extra] r367263 - [clang-tidy]: Google: new check 'google-upgrade-googletest-case'

2019-07-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 29 14:38:56 2019
New Revision: 367263

URL: http://llvm.org/viewvc/llvm-project?rev=367263=rev
Log:
[clang-tidy]: Google: new check 'google-upgrade-googletest-case'

Introduce a new check to upgrade user code based on API changes in Googletest.

The check finds uses of old Googletest APIs with "case" in their name and 
replaces them with the new APIs named with "suite".

Patch by Alex Strelnikov (st...@google.com)
Reviewed as D62977.

Added:
clang-tools-extra/trunk/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UpgradeGoogletestCaseCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/google-upgrade-googletest-case.rst
clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/
clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/gtest-typed-test.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/gtest.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/nosuite/
clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/nosuite/gtest/

clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/nosuite/gtest/gtest-typed-test.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/gtest/nosuite/gtest/gtest.h
clang-tools-extra/trunk/test/clang-tidy/google-upgrade-googletest-case.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=367263=367262=367263=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Mon Jul 29 
14:38:56 2019
@@ -17,6 +17,7 @@ add_clang_library(clangTidyGoogleModule
   OverloadedUnaryAndCheck.cpp
   TodoCommentCheck.cpp
   UnnamedNamespaceInHeaderCheck.cpp
+  UpgradeGoogletestCaseCheck.cpp
   UsingNamespaceDirectiveCheck.cpp
 
   LINK_LIBS

Modified: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp?rev=367263=367262=367263=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Mon Jul 29 
14:38:56 2019
@@ -27,6 +27,7 @@
 #include "OverloadedUnaryAndCheck.h"
 #include "TodoCommentCheck.h"
 #include "UnnamedNamespaceInHeaderCheck.h"
+#include "UpgradeGoogletestCaseCheck.h"
 #include "UsingNamespaceDirectiveCheck.h"
 
 using namespace clang::ast_matchers;
@@ -79,6 +80,8 @@ class GoogleModule : public ClangTidyMod
 CheckFactories
 .registerCheck(
 "google-readability-namespace-comments");
+CheckFactories.registerCheck(
+"google-upgrade-googletest-case");
   }
 
   ClangTidyOptions getModuleOptions() override {

Added: clang-tools-extra/trunk/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp?rev=367263=auto
==
--- clang-tools-extra/trunk/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp 
Mon Jul 29 14:38:56 2019
@@ -0,0 +1,354 @@
+//===--- UpgradeGoogletestCaseCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UpgradeGoogletestCaseCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+static const llvm::StringRef RenameCaseToSuiteMessage =
+"Google Test APIs named with 'case' are deprecated; use equivalent APIs "
+"named with 'suite'";
+
+static llvm::Optional
+getNewMacroName(llvm::StringRef MacroName) {
+  std::pair ReplacementMap[] = {
+  {"TYPED_TEST_CASE", "TYPED_TEST_SUITE"},
+  {"TYPED_TEST_CASE_P", "TYPED_TEST_SUITE_P"},
+  {"REGISTER_TYPED_TEST_CASE_P", "REGISTER_TYPED_TEST_SUITE_P"},
+  {"INSTANTIATE_TYPED_TEST_CASE_P", "INSTANTIATE_TYPED_TEST_SUITE_P"},
+  {"INSTANTIATE_TEST_CASE_P", "INSTANTIATE_TEST_SUITE_P"},
+  };
+
+  for (auto  : ReplacementMap) {
+if (MacroName == Mapping.first)
+  

r361920 - Make __has_builtin work with __builtin_LINE and friends.

2019-05-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 28 20:15:36 2019
New Revision: 361920

URL: http://llvm.org/viewvc/llvm-project?rev=361920=rev
Log:
Make __has_builtin work with __builtin_LINE and friends.

The source location builtins are implemented as keywords, but
__has_builtin should still report true for them.

This patch also fixes a test failure on systemz where the alignment
of string literals is 2 not 1.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
cfe/trunk/test/Preprocessor/feature_tests.c

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=361920=361919=361920=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 28 20:15:36 2019
@@ -1620,6 +1620,10 @@ void Preprocessor::ExpandBuiltinMacro(To
   .Case("__is_target_vendor", true)
   .Case("__is_target_os", true)
   .Case("__is_target_environment", true)
+  .Case("__builtin_LINE", true)
+  .Case("__builtin_FILE", true)
+  .Case("__builtin_FUNCTION", true)
+  .Case("__builtin_COLUMN", true)
   .Default(false);
 }
   });

Modified: cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp?rev=361920=361919=361920=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp Tue May 28 20:15:36 2019
@@ -6,7 +6,7 @@ namespace test_func {
 constexpr const char *test_default_arg(const char *f = __builtin_FUNCTION()) {
   return f;
 }
-// CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] 
zeroinitializer, align 1
+// CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] 
zeroinitializer
 
 // CHECK: @_ZN9test_func6globalE = {{(dso_local )?}}global i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0)
 const char *global = test_default_arg();
@@ -16,9 +16,9 @@ const char *global_two = __builtin_FUNCT
 
 const char * const global_three = test_default_arg();
 
-// CHECK: @[[STR_ONE:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_one\00", align 1
-// CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_two\00", align 1
-// CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] 
c"do_default_arg_test\00", align 1
+// CHECK: @[[STR_ONE:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_one\00"
+// CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_two\00"
+// CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] 
c"do_default_arg_test\00"
 
 // CHECK: define {{(dso_local )?}}i8* @_ZN9test_func13test_func_oneEv()
 // CHECK: ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR_ONE]], 
i32 0, i32 0)

Modified: cfe/trunk/test/Preprocessor/feature_tests.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/feature_tests.c?rev=361920=361919=361920=diff
==
--- cfe/trunk/test/Preprocessor/feature_tests.c (original)
+++ cfe/trunk/test/Preprocessor/feature_tests.c Tue May 28 20:15:36 2019
@@ -20,6 +20,15 @@
 #error Clang should have these
 #endif
 
+// These are technically implemented as keywords, but __has_builtin should
+// still return true.
+#if !__has_builtin(__builtin_LINE) || \
+!__has_builtin(__builtin_FILE) || \
+!__has_builtin(__builtin_FUNCTION) || \
+!__has_builtin(__builtin_COLUMN)
+#error Clang should have these
+#endif
+
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif


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


Re: [PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2019-05-28 Thread Eric Fiselier via cfe-commits
* The alignment check can be removed, and I'll do so tomorrow if someone
doesn't beat me to it.

On Tue, May 28, 2019 at 1:54 AM Eric Fiselier  wrote:

> The alignment check can just be removed.
>
> On Mon., May 27, 2019, 7:57 p.m. Ulrich Weigand via Phabricator, <
> revi...@reviews.llvm.org> wrote:
>
>> uweigand added a comment.
>>
>> Looks like this test is failing on SystemZ since it was added, making all
>> our build bots red:
>>
>>
>> /home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/CodeGenCXX/builtin_FUNCTION.cpp:9:11:
>> error: CHECK: expected string not found in input
>>   // CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8]
>> zeroinitializer, align 1
>> ^
>>
>> /home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/tools/clang/test/CodeGenCXX/Output/builtin_FUNCTION.cpp.tmp.ll:1:1:
>> note: scanning from here
>>   ; ModuleID =
>> '/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/CodeGenCXX/builtin_FUNCTION.cpp'
>>   ^
>>
>> /home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/tools/clang/test/CodeGenCXX/Output/builtin_FUNCTION.cpp.tmp.ll:8:1:
>> note: possible intended match here
>>   @.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 2
>>   ^
>>
>> The problem is that string constants are 2-aligned according to the
>> SystemZ ABI (this is a bit different, but deliberate in order to allow
>> computing their addresses with a LARL instruction).  This makes all the
>> "align 1" checks fail.
>>
>> Is this test deliberately verifying the alignment, or could this just be
>> removed?
>>
>>
>> Repository:
>>   rC Clang
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D37035/new/
>>
>> https://reviews.llvm.org/D37035
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2019-05-27 Thread Eric Fiselier via cfe-commits
The alignment check can just be removed.

On Mon., May 27, 2019, 7:57 p.m. Ulrich Weigand via Phabricator, <
revi...@reviews.llvm.org> wrote:

> uweigand added a comment.
>
> Looks like this test is failing on SystemZ since it was added, making all
> our build bots red:
>
>
> /home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/CodeGenCXX/builtin_FUNCTION.cpp:9:11:
> error: CHECK: expected string not found in input
>   // CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8]
> zeroinitializer, align 1
> ^
>
> /home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/tools/clang/test/CodeGenCXX/Output/builtin_FUNCTION.cpp.tmp.ll:1:1:
> note: scanning from here
>   ; ModuleID =
> '/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/CodeGenCXX/builtin_FUNCTION.cpp'
>   ^
>
> /home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/tools/clang/test/CodeGenCXX/Output/builtin_FUNCTION.cpp.tmp.ll:8:1:
> note: possible intended match here
>   @.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 2
>   ^
>
> The problem is that string constants are 2-aligned according to the
> SystemZ ABI (this is a bit different, but deliberate in order to allow
> computing their addresses with a LARL instruction).  This makes all the
> "align 1" checks fail.
>
> Is this test deliberately verifying the alignment, or could this just be
> removed?
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D37035/new/
>
> https://reviews.llvm.org/D37035
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361571 - Fix hang during constant evaluation of union assignment.

2019-05-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May 23 16:34:43 2019
New Revision: 361571

URL: http://llvm.org/viewvc/llvm-project?rev=361571=rev
Log:
Fix hang during constant evaluation of union assignment.

HandleUnionActiveMemberChange forgot to walk over a nop implicit
conversion node and got stuck in the process.

As a cleanup I changed the declaration of `E` so it can't
be accidentally accessed after the loop.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=361571=361570=361571=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu May 23 16:34:43 2019
@@ -4994,9 +4994,8 @@ static bool HandleUnionActiveMemberChang
   llvm::SmallVector, 4> UnionPathLengths;
   // C++ [class.union]p5:
   //   define the set S(E) of subexpressions of E as follows:
-  const Expr *E = LHSExpr;
   unsigned PathLength = LHS.Designator.Entries.size();
-  while (E) {
+  for (const Expr *E = LHSExpr; E != nullptr;) {
 //   -- If E is of the form A.B, S(E) contains the elements of S(A)...
 if (auto *ME = dyn_cast(E)) {
   auto *FD = dyn_cast(ME->getMemberDecl());
@@ -5026,6 +5025,7 @@ static bool HandleUnionActiveMemberChang
 
 } else if (auto *ICE = dyn_cast(E)) {
   // Step over a derived-to-base conversion.
+  E = ICE->getSubExpr();
   if (ICE->getCastKind() == CK_NoOp)
 continue;
   if (ICE->getCastKind() != CK_DerivedToBase &&
@@ -5038,7 +5038,6 @@ static bool HandleUnionActiveMemberChang
   LHS.Designator.Entries[PathLength]
   .getAsBaseOrMember().getPointer()));
   }
-  E = ICE->getSubExpr();
 
 //   -- Otherwise, S(E) is empty.
 } else {

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp?rev=361571=361570=361571=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp Thu May 23 16:34:43 
2019
@@ -513,4 +513,12 @@ namespace Union {
   static_assert(return_init_all().a.p == 7); // expected-error {{}} 
expected-note {{read of member 'p' of union with no active member}}
   static_assert(return_init_all().a.q == 8); // expected-error {{}} 
expected-note {{read of member 'q' of union with no active member}}
   constexpr B init_all = return_init_all();
+
+  constexpr bool test_no_member_change =  []{
+union U { char dummy = {}; };
+U u1;
+U u2;
+u1 = u2;
+return true;
+  }();
 }


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


r360951 - Remove unneeded alignment spec from builtin_FUNCTION.cpp test

2019-05-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May 16 16:07:45 2019
New Revision: 360951

URL: http://llvm.org/viewvc/llvm-project?rev=360951=rev
Log:
Remove unneeded alignment spec from builtin_FUNCTION.cpp test

Modified:
cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp

Modified: cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp?rev=360951=360950=360951=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp Thu May 16 16:07:45 2019
@@ -8,10 +8,10 @@ constexpr const char *test_default_arg(c
 }
 // CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] 
zeroinitializer, align 1
 
-// CHECK: @_ZN9test_func6globalE = {{(dso_local )?}}global i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0), align 8
+// CHECK: @_ZN9test_func6globalE = {{(dso_local )?}}global i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0)
 const char *global = test_default_arg();
 
-// CHECK: @_ZN9test_func10global_twoE = {{(dso_local )?}}global i8* 
getelementptr inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0), 
align 8
+// CHECK: @_ZN9test_func10global_twoE = {{(dso_local )?}}global i8* 
getelementptr inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0)
 const char *global_two = __builtin_FUNCTION();
 
 const char * const global_three = test_default_arg();


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


r360947 - Fix failing source location test on Windows

2019-05-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May 16 15:21:42 2019
New Revision: 360947

URL: http://llvm.org/viewvc/llvm-project?rev=360947=rev
Log:
Fix failing source location test on Windows

Modified:
cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp

Modified: cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp?rev=360947=360946=360947=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp Thu May 16 15:21:42 2019
@@ -8,10 +8,10 @@ constexpr const char *test_default_arg(c
 }
 // CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] 
zeroinitializer, align 1
 
-// CHECK: @_ZN9test_func6globalE = global i8* getelementptr inbounds ([1 x 
i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0), align 8
+// CHECK: @_ZN9test_func6globalE = {{(dso_local )?}}global i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0), align 8
 const char *global = test_default_arg();
 
-// CHECK: @_ZN9test_func10global_twoE = global i8* getelementptr inbounds ([1 
x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0), align 8
+// CHECK: @_ZN9test_func10global_twoE = {{(dso_local )?}}global i8* 
getelementptr inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0), 
align 8
 const char *global_two = __builtin_FUNCTION();
 
 const char * const global_three = test_default_arg();
@@ -20,19 +20,19 @@ const char * const global_three = test_d
 // CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_two\00", align 1
 // CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] 
c"do_default_arg_test\00", align 1
 
-// CHECK: define i8* @_ZN9test_func13test_func_oneEv()
+// CHECK: define {{(dso_local )?}}i8* @_ZN9test_func13test_func_oneEv()
 // CHECK: ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR_ONE]], 
i32 0, i32 0)
 const char *test_func_one() {
   return __builtin_FUNCTION();
 }
 
-// CHECK: define i8* @_ZN9test_func13test_func_twoEv()
+// CHECK: define {{(dso_local )?}}i8* @_ZN9test_func13test_func_twoEv()
 // CHECK: ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR_TWO]], 
i32 0, i32 0)
 const char *test_func_two() {
   return __builtin_FUNCTION();
 }
 
-// CHECK: define void @_ZN9test_func19do_default_arg_testEv()
+// CHECK: define {{(dso_local )?}}void @_ZN9test_func19do_default_arg_testEv()
 // CHECK: %call = call i8* @_ZN9test_func16test_default_argEPKc(i8* 
getelementptr inbounds ([20 x i8], [20 x i8]* @[[STR_THREE]], i32 0, i32 0))
 void do_default_arg_test() {
   test_default_arg();


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


r360943 - Fix PCC test failures for source location builtins

2019-05-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May 16 14:51:39 2019
New Revision: 360943

URL: http://llvm.org/viewvc/llvm-project?rev=360943=rev
Log:
Fix PCC test failures for source location builtins

Modified:
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/builtin_LINE.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp?rev=360943=360942=360943=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp Thu May 16 14:51:39 
2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fblocks %s -triple %itanium_abi_triple 
-emit-llvm -o %t.ll
+// RUN: %clang_cc1 -std=c++2a -fblocks %s -triple x86_64-unknown-unknown 
-emit-llvm -o %t.ll
 
 #line 8 "builtin-source-location.cpp"
 

Modified: cfe/trunk/test/CodeGenCXX/builtin_LINE.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin_LINE.cpp?rev=360943=360942=360943=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin_LINE.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin_LINE.cpp Thu May 16 14:51:39 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -fblocks %s -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++1z -fblocks %s -triple x86_64-unknown-unknown 
-emit-llvm -o - | FileCheck %s
 
 extern "C" int sink;
 extern "C" const volatile void* volatile ptr_sink = nullptr;

Modified: cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=360943=360942=360943=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Thu May 16 14:51:39 2019
@@ -296,7 +296,7 @@ void f24() {
 // CHECK-LABEL: define
 void f25_a(int x = __builtin_LINE()) {}
 void f25() {
-  // CHECK: call void @_Z5f25_ai(i32 2700)
+  // CHECK: call void @_Z5f25_ai(i32 {{(signext )?}}2700)
 #line 2700
   f25_a();
 }


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


r360937 - Implement __builtin_LINE() et. al. to support source location capture.

2019-05-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May 16 14:04:15 2019
New Revision: 360937

URL: http://llvm.org/viewvc/llvm-project?rev=360937=rev
Log:
Implement __builtin_LINE() et. al. to support source location capture.

Summary:
This patch implements the source location builtins `__builtin_LINE(), 
`__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These 
builtins are needed to implement 
[`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation).

With the exception of `__builtin_COLUMN`, GCC also implements these builtins, 
and Clangs behavior is intended to match as closely as possible. 

Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong

Reviewed By: rsmith

Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, 
hfinkel, cfe-commits

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

Added:
cfe/trunk/include/clang/AST/CurrentSourceLocExprScope.h
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
cfe/trunk/test/CodeGenCXX/builtin_LINE.cpp
cfe/trunk/test/Parser/builtin_source_location.c
cfe/trunk/test/Sema/source_location.c
cfe/trunk/test/SemaCXX/Inputs/source-location-file.h
cfe/trunk/test/SemaCXX/source_location.cpp
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=360937=360936=360937=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Thu May 16 14:04:15 2019
@@ -2300,6 +2300,61 @@ automatically will insert one if the fir
 token `none`. If a user calls `__builin_suspend`, clang will insert `token 
none`
 as the first argument to the intrinsic.
 
+Source location builtins
+
+
+Clang provides experimental builtins to support C++ standard library 
implementation
+of ``std::experimental::source_location`` as specified in  
http://wg21.link/N4600.
+With the exception of ``__builtin_COLUMN``, these builtins are also 
implemented by
+GCC.
+
+**Syntax**:
+
+.. code-block:: c
+
+  const char *__builtin_FILE();
+  const char *__builtin_FUNCTION();
+  unsigned__builtin_LINE();
+  unsigned__builtin_COLUMN(); // Clang only
+
+**Example of use**:
+
+.. code-block:: c++
+
+  void my_assert(bool pred, int line = __builtin_LINE(), // Captures line of 
caller
+ const char* file = __builtin_FILE(),
+ const char* function = __builtin_FUNCTION()) {
+if (pred) return;
+printf("%s:%d assertion failed in function %s\n", file, line, function);
+std::abort();
+  }
+
+  struct MyAggregateType {
+int x;
+int line = __builtin_LINE(); // captures line where aggregate 
initialization occurs
+  };
+  static_assert(MyAggregateType{42}.line == __LINE__);
+
+  struct MyClassType {
+int line = __builtin_LINE(); // captures line of the constructor used 
during initialization
+constexpr MyClassType(int) { assert(line == __LINE__); }
+  };
+
+**Description**:
+
+The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, and 
``__builtin_FILE`` return
+the values, at the "invocation point", for ``__LINE__``, ``__FUNCTION__``, and
+``__FILE__`` respectively. These builtins are constant expressions.
+
+When the builtins appear as part of 

Re: r359067 - [Builtins] Implement __builtin_is_constant_evaluated for use in C++2a

2019-05-08 Thread Eric Fiselier via cfe-commits
Sorry, I should have been on top of this.

/Eric

On Wed., May 8, 2019, 11:47 p.m. Richard Smith, 
wrote:

> I went ahead and did this in r360310.
>
> On Thu, 25 Apr 2019 at 14:31, Richard Smith  wrote:
> >
> > On Wed, 24 Apr 2019 at 19:28, Eric Fiselier via cfe-commits
> >  wrote:
> > > Do I just edit the HTML file directly?
> > > Or is it generated by something?
> >
> > Just edit the HTML file directly.
> >
> > > On Wed, Apr 24, 2019 at 3:35 PM Richard Smith 
> wrote:
> > >>
> > >> Thanks! Can you update cxx_status.html to mark P0595R2 as done?
> > >>
> > >> On Tue, 23 Apr 2019 at 19:21, Eric Fiselier via cfe-commits
> > >>  wrote:
> > >> >
> > >> > Author: ericwf
> > >> > Date: Tue Apr 23 19:23:30 2019
> > >> > New Revision: 359067
> > >> >
> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=359067=rev
> > >> > Log:
> > >> > [Builtins] Implement __builtin_is_constant_evaluated for use in
> C++2a
> > >> >
> > >> > Summary:
> > >> > This patch implements `__builtin_is_constant_evaluated` as
> specifier by [P0595R2](https://wg21.link/p0595r2). It is built on the
> back of Bill Wendling's work for `__builtin_constant_p()`.
> > >> >
> > >> > More tests to come, but early feedback is appreciated.
> > >> >
> > >> > I plan to implement warnings for common mis-usages like those
> belowe in a following patch:
> > >> > ```
> > >> > void foo(int x) {
> > >> >   if constexpr (std::is_constant_evaluated())) { // condition is
> always `true`. Should use plain `if` instead.
> > >> >foo_constexpr(x);
> > >> >   } else {
> > >> > foo_runtime(x);
> > >> >   }
> > >> > }
> > >> > ```
> > >> >
> > >> >
> > >> >
> > >> > Reviewers: rsmith, MaskRay, bruno, void
> > >> >
> > >> > Reviewed By: rsmith
> > >> >
> > >> > Subscribers: dexonsmith, zoecarver, fdeazeve, kristina, cfe-commits
> > >> >
> > >> > Differential Revision: https://reviews.llvm.org/D55500
> > >> >
> > >> > Added:
> > >> > cfe/trunk/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
> > >> > cfe/trunk/test/SemaCXX/builtin-is-constant-evaluated.cpp
> > >> > Modified:
> > >> > cfe/trunk/include/clang/Basic/Builtins.def
> > >> > cfe/trunk/lib/AST/ExprConstant.cpp
> > >> > cfe/trunk/lib/Basic/Builtins.cpp
> > >> > cfe/trunk/lib/CodeGen/CGDecl.cpp
> > >> > cfe/trunk/test/Sema/builtins.c
> > >> >
> > >> > Modified: cfe/trunk/include/clang/Basic/Builtins.def
> > >> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=359067=359066=359067=diff
> > >> >
> ==
> > >> > --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> > >> > +++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 23 19:23:30
> 2019
> > >> > @@ -500,6 +500,7 @@ BUILTIN(__builtin_vsprintf, "ic*cC*a", "
> > >> >  BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
> > >> >  BUILTIN(__builtin_thread_pointer, "v*", "nc")
> > >> >  BUILTIN(__builtin_launder, "v*v*", "nt")
> > >> > +LANGBUILTIN(__builtin_is_constant_evaluated, "b", "n", CXX_LANG)
> > >> >
> > >> >  // GCC exception builtins
> > >> >  BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes
> intptr_t, not size_t!
> > >> >
> > >> > Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> > >> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359067=359066=359067=diff
> > >> >
> ==
> > >> > --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> > >> > +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Apr 23 19:23:30 2019
> > >> > @@ -8279,6 +8279,9 @@ bool IntExprEvaluator::VisitBuiltinCallE
> > >> >  return Success(false, E);
> > >>

Re: r359361 - Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC.

2019-04-30 Thread Eric Fiselier via cfe-commits
Jorge,

Why did you revert this?

/Eric

On Sat, Apr 27, 2019 at 6:01 AM Roman Lebedev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Sat, Apr 27, 2019 at 3:29 AM Jorge Gorbe Moya via cfe-commits
>  wrote:
> >
> > Author: jgorbe
> > Date: Fri Apr 26 17:32:04 2019
> > New Revision: 359361
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=359361=rev
> > Log:
> > Revert Fix interactions between __builtin_constant_p and constexpr to
> match current trunk GCC.
> >
> > This reverts r359059 (git commit
> 0b098754b73f3b96d00ecb1c7605760b11c90298)
> It is common to specify the *reason* for the revert, so it is recorded
> in change log.
>
> > Removed:
> > cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
> > Modified:
> > cfe/trunk/lib/AST/ExprConstant.cpp
> > cfe/trunk/lib/Sema/SemaChecking.cpp
> > cfe/trunk/test/SemaCXX/enable_if.cpp
> >
> > Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359361=359360=359361=diff
> >
> ==
> > --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> > +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 26 17:32:04 2019
> > @@ -7801,33 +7801,19 @@ EvaluateBuiltinClassifyType(const CallEx
> >  }
> >
> >  /// EvaluateBuiltinConstantPForLValue - Determine the result of
> > -/// __builtin_constant_p when applied to the given pointer.
> > +/// __builtin_constant_p when applied to the given lvalue.
> >  ///
> > -/// A pointer is only "constant" if it is null (or a pointer cast to
> integer)
> > -/// or it points to the first character of a string literal.
> > -static bool EvaluateBuiltinConstantPForLValue(const APValue ) {
> > -  APValue::LValueBase Base = LV.getLValueBase();
> > -  if (Base.isNull()) {
> > -// A null base is acceptable.
> > -return true;
> > -  } else if (const Expr *E = Base.dyn_cast()) {
> > -if (!isa(E))
> > -  return false;
> > -return LV.getLValueOffset().isZero();
> > -  } else {
> > -// Any other base is not constant enough for GCC.
> > -return false;
> > -  }
> > +/// An lvalue is only "constant" if it is a pointer or reference to the
> first
> > +/// character of a string literal.
> > +template
> > +static bool EvaluateBuiltinConstantPForLValue(const LValue ) {
> > +  const Expr *E = LV.getLValueBase().template dyn_cast();
> > +  return E && isa(E) && LV.getLValueOffset().isZero();
> >  }
> >
> >  /// EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as
> similarly to
> >  /// GCC as we can manage.
> > -static bool EvaluateBuiltinConstantP(EvalInfo , const Expr *Arg) {
> > -  // Constant-folding is always enabled for the operand of
> __builtin_constant_p
> > -  // (even when the enclosing evaluation context otherwise requires a
> strict
> > -  // language-specific constant expression).
> > -  FoldConstant Fold(Info, true);
> > -
> > +static bool EvaluateBuiltinConstantP(ASTContext , const Expr *Arg) {
> >QualType ArgType = Arg->getType();
> >
> >// __builtin_constant_p always has one operand. The rules which gcc
> follows
> > @@ -7835,27 +7821,34 @@ static bool EvaluateBuiltinConstantP(Eva
> >//
> >//  - If the operand is of integral, floating, complex or enumeration
> type,
> >//and can be folded to a known value of that type, it returns 1.
> > -  //  - If the operand can be folded to a pointer to the first character
> > -  //of a string literal (or such a pointer cast to an integral type)
> > -  //or to a null pointer or an integer cast to a pointer, it
> returns 1.
> > +  //  - If the operand and can be folded to a pointer to the first
> character
> > +  //of a string literal (or such a pointer cast to an integral
> type), it
> > +  //returns 1.
> >//
> >// Otherwise, it returns 0.
> >//
> >// FIXME: GCC also intends to return 1 for literals of aggregate
> types, but
> >// its support for this does not currently work.
> > -  if (ArgType->isIntegralOrEnumerationType() ||
> ArgType->isFloatingType() ||
> > -  ArgType->isAnyComplexType() || ArgType->isPointerType() ||
> > -  ArgType->isNullPtrType()) {
> > -APValue V;
> > -if (!::EvaluateAsRValue(Info, Arg, V))
> > +  if (ArgType->isIntegralOrEnumerationType()) {
> > +Expr::EvalResult Result;
> > +if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
> >return false;
> >
> > -// For a pointer (possibly cast to integer), there are special
> rules.
> > +APValue  = Result.Val;
> > +if (V.getKind() == APValue::Int)
> > +  return true;
> >  if (V.getKind() == APValue::LValue)
> >return EvaluateBuiltinConstantPForLValue(V);
> > -
> > -// Otherwise, any constant value is good enough.
> > -return V.getKind() != APValue::Uninitialized;
> > +  } else if (ArgType->isFloatingType() || ArgType->isAnyComplexType()) {
> > +return Arg->isEvaluatable(Ctx);
> > +  } else if 

Re: r359067 - [Builtins] Implement __builtin_is_constant_evaluated for use in C++2a

2019-04-24 Thread Eric Fiselier via cfe-commits
Do I just edit the HTML file directly?
Or is it generated by something?

On Wed, Apr 24, 2019 at 3:35 PM Richard Smith  wrote:

> Thanks! Can you update cxx_status.html to mark P0595R2 as done?
>
> On Tue, 23 Apr 2019 at 19:21, Eric Fiselier via cfe-commits
>  wrote:
> >
> > Author: ericwf
> > Date: Tue Apr 23 19:23:30 2019
> > New Revision: 359067
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=359067=rev
> > Log:
> > [Builtins] Implement __builtin_is_constant_evaluated for use in C++2a
> >
> > Summary:
> > This patch implements `__builtin_is_constant_evaluated` as specifier by
> [P0595R2](https://wg21.link/p0595r2). It is built on the back of Bill
> Wendling's work for `__builtin_constant_p()`.
> >
> > More tests to come, but early feedback is appreciated.
> >
> > I plan to implement warnings for common mis-usages like those belowe in
> a following patch:
> > ```
> > void foo(int x) {
> >   if constexpr (std::is_constant_evaluated())) { // condition is always
> `true`. Should use plain `if` instead.
> >foo_constexpr(x);
> >   } else {
> > foo_runtime(x);
> >   }
> > }
> > ```
> >
> >
> >
> > Reviewers: rsmith, MaskRay, bruno, void
> >
> > Reviewed By: rsmith
> >
> > Subscribers: dexonsmith, zoecarver, fdeazeve, kristina, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D55500
> >
> > Added:
> > cfe/trunk/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
> > cfe/trunk/test/SemaCXX/builtin-is-constant-evaluated.cpp
> > Modified:
> > cfe/trunk/include/clang/Basic/Builtins.def
> > cfe/trunk/lib/AST/ExprConstant.cpp
> > cfe/trunk/lib/Basic/Builtins.cpp
> > cfe/trunk/lib/CodeGen/CGDecl.cpp
> > cfe/trunk/test/Sema/builtins.c
> >
> > Modified: cfe/trunk/include/clang/Basic/Builtins.def
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=359067=359066=359067=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> > +++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 23 19:23:30 2019
> > @@ -500,6 +500,7 @@ BUILTIN(__builtin_vsprintf, "ic*cC*a", "
> >  BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
> >  BUILTIN(__builtin_thread_pointer, "v*", "nc")
> >  BUILTIN(__builtin_launder, "v*v*", "nt")
> > +LANGBUILTIN(__builtin_is_constant_evaluated, "b", "n", CXX_LANG)
> >
> >  // GCC exception builtins
> >  BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not
> size_t!
> >
> > Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359067=359066=359067=diff
> >
> ==
> > --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> > +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Apr 23 19:23:30 2019
> > @@ -8279,6 +8279,9 @@ bool IntExprEvaluator::VisitBuiltinCallE
> >  return Success(false, E);
> >}
> >
> > +  case Builtin::BI__builtin_is_constant_evaluated:
> > +return Success(Info.InConstantContext, E);
> > +
> >case Builtin::BI__builtin_ctz:
> >case Builtin::BI__builtin_ctzl:
> >case Builtin::BI__builtin_ctzll:
> > @@ -11139,6 +11142,7 @@ bool Expr::EvaluateAsConstantExpr(EvalRe
> >EvalInfo::EvaluationMode EM = EvalInfo::EM_ConstantExpression;
> >EvalInfo Info(Ctx, Result, EM);
> >Info.InConstantContext = true;
> > +
> >if (!::Evaluate(Result.Val, Info, this))
> >  return false;
> >
> >
> > Modified: cfe/trunk/lib/Basic/Builtins.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Builtins.cpp?rev=359067=359066=359067=diff
> >
> ==
> > --- cfe/trunk/lib/Basic/Builtins.cpp (original)
> > +++ cfe/trunk/lib/Basic/Builtins.cpp Tue Apr 23 19:23:30 2019
> > @@ -75,9 +75,12 @@ bool Builtin::Context::builtinIsSupporte
> >bool OclCUnsupported = !LangOpts.OpenCL &&
> >   (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);
> >bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs ==
> OMP_LANG;
> > +  bool CPlusPlusUnsupported =
> > +  !LangOpts.CPlusPlus && 

r359067 - [Builtins] Implement __builtin_is_constant_evaluated for use in C++2a

2019-04-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 23 19:23:30 2019
New Revision: 359067

URL: http://llvm.org/viewvc/llvm-project?rev=359067=rev
Log:
[Builtins] Implement __builtin_is_constant_evaluated for use in C++2a

Summary:
This patch implements `__builtin_is_constant_evaluated` as specifier by 
[P0595R2](https://wg21.link/p0595r2). It is built on the back of Bill 
Wendling's work for `__builtin_constant_p()`.

More tests to come, but early feedback is appreciated.

I plan to implement warnings for common mis-usages like those belowe in a 
following patch:
```
void foo(int x) {
  if constexpr (std::is_constant_evaluated())) { // condition is always `true`. 
Should use plain `if` instead.
   foo_constexpr(x);
  } else {
foo_runtime(x);
  }
}
```



Reviewers: rsmith, MaskRay, bruno, void

Reviewed By: rsmith

Subscribers: dexonsmith, zoecarver, fdeazeve, kristina, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
cfe/trunk/test/SemaCXX/builtin-is-constant-evaluated.cpp
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Basic/Builtins.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/Sema/builtins.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=359067=359066=359067=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 23 19:23:30 2019
@@ -500,6 +500,7 @@ BUILTIN(__builtin_vsprintf, "ic*cC*a", "
 BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
 BUILTIN(__builtin_thread_pointer, "v*", "nc")
 BUILTIN(__builtin_launder, "v*v*", "nt")
+LANGBUILTIN(__builtin_is_constant_evaluated, "b", "n", CXX_LANG)
 
 // GCC exception builtins
 BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359067=359066=359067=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Apr 23 19:23:30 2019
@@ -8279,6 +8279,9 @@ bool IntExprEvaluator::VisitBuiltinCallE
 return Success(false, E);
   }
 
+  case Builtin::BI__builtin_is_constant_evaluated:
+return Success(Info.InConstantContext, E);
+
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:
   case Builtin::BI__builtin_ctzll:
@@ -11139,6 +11142,7 @@ bool Expr::EvaluateAsConstantExpr(EvalRe
   EvalInfo::EvaluationMode EM = EvalInfo::EM_ConstantExpression;
   EvalInfo Info(Ctx, Result, EM);
   Info.InConstantContext = true;
+
   if (!::Evaluate(Result.Val, Info, this))
 return false;
 

Modified: cfe/trunk/lib/Basic/Builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Builtins.cpp?rev=359067=359066=359067=diff
==
--- cfe/trunk/lib/Basic/Builtins.cpp (original)
+++ cfe/trunk/lib/Basic/Builtins.cpp Tue Apr 23 19:23:30 2019
@@ -75,9 +75,12 @@ bool Builtin::Context::builtinIsSupporte
   bool OclCUnsupported = !LangOpts.OpenCL &&
  (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);
   bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG;
+  bool CPlusPlusUnsupported =
+  !LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG;
   return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported 
&&
  !OclC1Unsupported && !OclC2Unsupported && !OpenMPUnsupported &&
- !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported;
+ !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
+ !CPlusPlusUnsupported;
 }
 
 /// initializeBuiltins - Mark the identifiers for all the builtins with their

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=359067=359066=359067=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Apr 23 19:23:30 2019
@@ -1783,7 +1783,8 @@ void CodeGenFunction::EmitAutoVarInit(co
   }
 
   llvm::Constant *constant = nullptr;
-  if (emission.IsConstantAggregate || D.isConstexpr()) {
+  if (emission.IsConstantAggregate || D.isConstexpr() ||
+  D.isUsableInConstantExpressions(getContext())) {
 assert(!capturedByInit && "constant init contains a capturing block?");
 constant = ConstantEmitter(*this).tryEmitAbstractForInitializer(D);
 if (constant && trivialAutoVarInit !=

Added: cfe/trunk/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
URL: 

r355743 - [8.0 Regression] Fix handling of `__builtin_constant_p` inside template arguments, enumerators, case statements, and the enable_if attribute.

2019-03-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  8 14:06:48 2019
New Revision: 355743

URL: http://llvm.org/viewvc/llvm-project?rev=355743=rev
Log:
[8.0 Regression] Fix handling of `__builtin_constant_p` inside template 
arguments, enumerators, case statements, and the enable_if attribute.

Summary:
The following code is accepted by Clang 7 and prior but rejected by the 
upcoming 8 release and in trunk [1]

```
// error {{never produces a constant expression}}
void foo(const char* s) __attribute__((enable_if(__builtin_constant_p(*s) == 
false, "trap"))) {}
void test() { foo("abc"); }
```

Prior to Clang 8, the call to `__builtin_constant_p` was a constant expression 
returning false. Currently, it's not a valid constant expression.

The bug is caused because we failed to set `InConstantContext` when attempting 
to evaluate unevaluated constant expressions.

[1]  https://godbolt.org/z/ksAjmq

Reviewers: rsmith, hans, sbenza

Reviewed By: rsmith

Subscribers: kristina, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=355743=355742=355743=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Mar  8 14:06:48 2019
@@ -11131,6 +11131,7 @@ bool Expr::EvaluateAsConstantExpr(EvalRe
   const ASTContext ) const {
   EvalInfo::EvaluationMode EM = EvalInfo::EM_ConstantExpression;
   EvalInfo Info(Ctx, Result, EM);
+  Info.InConstantContext = true;
   if (!::Evaluate(Result.Val, Info, this))
 return false;
 
@@ -11771,6 +11772,7 @@ bool Expr::EvaluateWithSubstitution(APVa
 const Expr *This) const {
   Expr::EvalStatus Status;
   EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpressionUnevaluated);
+  Info.InConstantContext = true;
 
   LValue ThisVal;
   const LValue *ThisPtr = nullptr;
@@ -11854,6 +11856,7 @@ bool Expr::isPotentialConstantExprUneval
 
   EvalInfo Info(FD->getASTContext(), Status,
 EvalInfo::EM_PotentialConstantExpressionUnevaluated);
+  Info.InConstantContext = true;
 
   // Fabricate a call stack frame to give the arguments a plausible cover 
story.
   ArrayRef Args;

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=355743=355742=355743=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Fri Mar  8 14:06:48 
2019
@@ -1135,3 +1135,27 @@ constexpr bool indirect_builtin_constant
   return __builtin_constant_p(*__s);
 }
 constexpr bool n = indirect_builtin_constant_p("a");
+
+__attribute__((enable_if(indirect_builtin_constant_p("a") == n, "OK")))
+int test_in_enable_if() { return 0; }
+int n2 = test_in_enable_if();
+
+template 
+int test_in_template_param() { return 0; }
+int n3 = test_in_template_param();
+
+void test_in_case(int n) {
+  switch (n) {
+case indirect_builtin_constant_p("abc"):
+break;
+  }
+}
+enum InEnum1 {
+  ONE = indirect_builtin_constant_p("abc")
+};
+enum InEnum2 : int {
+  TWO = indirect_builtin_constant_p("abc")
+};
+enum class InEnum3 {
+  THREE = indirect_builtin_constant_p("abc")
+};

Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=355743=355742=355743=diff
==
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Fri Mar  8 14:06:48 2019
@@ -514,3 +514,11 @@ namespace TypeOfFn {
 
   static_assert(is_same<__typeof__(foo)*, decltype()>::value, "");
 }
+
+namespace InConstantContext {
+void foo(const char *s) 
__attribute__((enable_if(((void)__builtin_constant_p(*s), true), "trap"))) {}
+
+void test() {
+  InConstantContext::foo("abc");
+}
+} // namespace InConstantContext


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


r352983 - Correct test my *really really* overaligning a type.

2019-02-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Feb  2 20:10:38 2019
New Revision: 352983

URL: http://llvm.org/viewvc/llvm-project?rev=352983=rev
Log:
Correct test my *really really* overaligning a type.

Modified:
cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp

Modified: cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp?rev=352983=352982=352983=diff
==
--- cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp Sat Feb  2 
20:10:38 2019
@@ -33,7 +33,7 @@ struct B {
 void BTest(B *b) { delete b; }// expected-error {{deleted}}
 
 
-struct alignas(32) C {
+struct alignas(128) C {
 #ifndef HAS_ALIGN
   // expected-note@+2 {{deleted}}
 #endif
@@ -54,7 +54,7 @@ struct D {
 };
 void DTest(D *d) { delete d; } // expected-error {{deleted}}
 
-struct alignas(64) E {
+struct alignas(128) E {
   void operator delete(void*) = delete;
   void operator delete(E*, std::destroying_delete_t) = delete;
   void operator delete(E*, std::destroying_delete_t, std::size_t) = delete;


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


r352980 - Fix handling of usual deallocation functions in various configuratios.

2019-02-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Feb  2 19:44:31 2019
New Revision: 352980

URL: http://llvm.org/viewvc/llvm-project?rev=352980=rev
Log:
Fix handling of usual deallocation functions in various configuratios.

Clang allows users to enable or disable various types of allocation
and deallocation regardless of the C++ dialect. When extended new/delete
overloads are enabled in older dialects, we need to treat them as if
they're usual.

Also, disabling one usual deallocation form shouldn't
disable any others. For example, disabling aligned allocation in C++2a
should have no effect on destroying delete.

Added:
cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=352980=352979=352980=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sat Feb  2 19:44:31 2019
@@ -2091,8 +2091,13 @@ bool CXXMethodDecl::isUsualDeallocationF
 return false;
 
   // In C++17 onwards, all potential usual deallocation functions are actual
-  // usual deallocation functions.
-  if (Context.getLangOpts().AlignedAllocation)
+  // usual deallocation functions. Honor this behavior when post-C++14
+  // deallocation functions are offered as extensions too.
+  // FIXME(EricWF): Destrying Delete should be a language option. How do we
+  // handle when destroying delete is used prior to C++17?
+  if (Context.getLangOpts().CPlusPlus17 ||
+  Context.getLangOpts().AlignedAllocation ||
+  isDestroyingOperatorDelete())
 return true;
 
   // This function is a usual deallocation function if there are no

Modified: cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp?rev=352980=352979=352980=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp Sat Feb  2 19:44:31 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++2a -verify %s
+// RUN: %clang_cc1 -std=c++2a -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a  -verify %s
 
 namespace std {
   using size_t = decltype(sizeof(0));
@@ -58,11 +59,13 @@ namespace delete_selection {
 C();
 void *operator new(std::size_t);
 void operator delete(void*) = delete;
-void operator delete(C *, std::destroying_delete_t) = delete;
+void operator delete(C *, std::destroying_delete_t) = delete; // 
expected-note 0-1 {{deleted here}}
   };
-  // FIXME: This should be ill-formed, but we incorrectly decide that overload
-  // resolution failed (because it selected a deleted function) and thus no
-  // 'operator delete' should be called.
+  // TODO: We only diagnose the use of a deleted operator delete when 
exceptions
+  // are enabled. Otherwise we don't bother doing the lookup.
+#ifdef __EXCEPTIONS
+  // expected-error@+2 {{attempt to use a deleted function}}
+#endif
   C *new_C() { return new C; }
 
   struct D {

Added: cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp?rev=352980=auto
==
--- cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp (added)
+++ cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp Sat Feb  2 
19:44:31 2019
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fexceptions -std=c++2a -fsized-deallocation 
-fno-aligned-allocation -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++17 -fsized-deallocation 
-fno-aligned-allocation -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++14 -fsized-deallocation 
-faligned-allocation -DHAS_ALIGN -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++11 -fsized-deallocation 
-faligned-allocation -DHAS_ALIGN -verify %s
+
+// Test that we handle aligned deallocation, sized deallocation, and destroying
+// delete as usual deallocation functions even if they are used as extensions
+// prior to C++17.
+
+namespace std {
+using size_t = decltype(sizeof(0));
+enum class align_val_t : size_t;
+
+struct destroying_delete_t {
+  struct __construct { explicit __construct() = default; };
+  explicit destroying_delete_t(__construct) {}
+};
+
+inline constexpr destroying_delete_t 
destroying_delete(destroying_delete_t::__construct());
+}
+
+// FIXME: Should destroying delete really be on in all dialects by default?
+struct A {
+  void operator delete(void*) = delete;
+  void operator delete(A*, std::destroying_delete_t) = delete; // 
expected-note {{deleted}}
+};
+void ATest(A* a) { delete a; } // expected-error {{deleted}}
+
+struct B {
+  void operator 

r352927 - Improve diagnostic to tell you a type is incomplete.

2019-02-01 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb  1 14:06:02 2019
New Revision: 352927

URL: http://llvm.org/viewvc/llvm-project?rev=352927=rev
Log:
Improve diagnostic to tell you a type is incomplete.

I recently ran into this code:
```
\#include 
void foo(const std::string , const std::string& = "");
\#include 
void test() { foo(""); }
```

The diagnostic produced said it can't bind char[1] to std::string
const&. It didn't mention std::string is incomplete. The user had to
infer that.

This patch causes the diagnostic to now say "incomplete type".

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
cfe/trunk/test/SemaCXX/decl-init-ref.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=352927=352926=352927=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb  1 14:06:02 
2019
@@ -1828,8 +1828,9 @@ def err_reference_bind_drops_quals : Err
   "'volatile'|'const' and 'volatile'|'restrict' and 'volatile'|"
   "'const', 'restrict', and 'volatile'}2 qualifier%plural{1:|2:|4:|:s}2">;
 def err_reference_bind_failed : Error<
-  "reference %diff{to type $ could not bind to an %select{rvalue|lvalue}1 of "
-  "type $|could not bind to %select{rvalue|lvalue}1 of incompatible type}0,2">;
+  "reference %diff{to %select{type|incomplete type}1 $ could not bind to an "
+  "%select{rvalue|lvalue}2 of type $|could not bind to %select{rvalue|lvalue}2 
of "
+  "incompatible type}0,3">;
 def err_reference_bind_init_list : Error<
   "reference to type %0 cannot bind to an initializer list">;
 def err_init_list_bad_dest_type : Error<

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=352927=352926=352927=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Feb  1 14:06:02 2019
@@ -8450,6 +8450,7 @@ bool InitializationSequence::Diagnose(Se
   case FK_ReferenceInitFailed:
 S.Diag(Kind.getLocation(), diag::err_reference_bind_failed)
   << DestType.getNonReferenceType()
+  << DestType.getNonReferenceType()->isIncompleteType()
   << OnlyArg->isLValue()
   << OnlyArg->getType()
   << Args[0]->getSourceRange();

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=352927=352926=352927=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Fri Feb  1 
14:06:02 2019
@@ -327,7 +327,7 @@ namespace update_rbrace_loc_crash {
   struct A {};
   template 
   std::initializer_list ExplodeImpl(F p1, A) {
-// expected-error@+1 {{reference to type 'const 
update_rbrace_loc_crash::Incomplete' could not bind to an rvalue of type 
'void'}}
+// expected-error@+1 {{reference to incomplete type 'const 
update_rbrace_loc_crash::Incomplete' could not bind to an rvalue of type 
'void'}}
 return {p1(I)...};
   }
   template 

Modified: cfe/trunk/test/SemaCXX/decl-init-ref.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-init-ref.cpp?rev=352927=352926=352927=diff
==
--- cfe/trunk/test/SemaCXX/decl-init-ref.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-init-ref.cpp Fri Feb  1 14:06:02 2019
@@ -36,3 +36,12 @@ namespace PR16502 {
   int f();
   const A  = { 10, ++c.temporary };
 }
+
+namespace IncompleteTest {
+  struct String;
+  // expected-error@+1 {{reference to incomplete type 'const 
IncompleteTest::String' could not bind to an lvalue of type 'const char [1]'}}
+  void takeString(const String& = "") {} // expected-note {{passing argument 
to parameter here}} expected-note {{candidate function}}
+  void test() {
+takeString(); // expected-error {{no matching function for call}}
+  }
+}


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


r352919 - Don't use ASTContext in DeclOpenMP.h because it's still incomplete.

2019-02-01 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb  1 13:19:20 2019
New Revision: 352919

URL: http://llvm.org/viewvc/llvm-project?rev=352919=rev
Log:
Don't use ASTContext in DeclOpenMP.h because it's still incomplete.

Modified:
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/lib/AST/DeclOpenMP.cpp

Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=352919=352918=352919=diff
==
--- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/DeclOpenMP.h Fri Feb  1 13:19:20 2019
@@ -289,14 +289,8 @@ public:
 
   /// Get reference to previous declare mapper construct in the same
   /// scope with the same name.
-  OMPDeclareMapperDecl *getPrevDeclInScope() {
-return cast_or_null(
-PrevDeclInScope.get(getASTContext().getExternalSource()));
-  }
-  const OMPDeclareMapperDecl *getPrevDeclInScope() const {
-return cast_or_null(
-PrevDeclInScope.get(getASTContext().getExternalSource()));
-  }
+  OMPDeclareMapperDecl *getPrevDeclInScope();
+  const OMPDeclareMapperDecl *getPrevDeclInScope() const;
 
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == OMPDeclareMapper; }

Modified: cfe/trunk/lib/AST/DeclOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclOpenMP.cpp?rev=352919=352918=352919=diff
==
--- cfe/trunk/lib/AST/DeclOpenMP.cpp (original)
+++ cfe/trunk/lib/AST/DeclOpenMP.cpp Fri Feb  1 13:19:20 2019
@@ -172,6 +172,16 @@ void OMPDeclareMapperDecl::setClauses(Ar
   std::uninitialized_copy(CL.begin(), CL.end(), Clauses.data());
 }
 
+OMPDeclareMapperDecl *OMPDeclareMapperDecl::getPrevDeclInScope() {
+  return cast_or_null(
+  PrevDeclInScope.get(getASTContext().getExternalSource()));
+}
+
+const OMPDeclareMapperDecl *OMPDeclareMapperDecl::getPrevDeclInScope() const {
+  return cast_or_null(
+  PrevDeclInScope.get(getASTContext().getExternalSource()));
+}
+
 
//===--===//
 // OMPCapturedExprDecl Implementation.
 
//===--===//


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


r351484 - Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined deduction guides.

2019-01-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jan 17 13:44:24 2019
New Revision: 351484

URL: http://llvm.org/viewvc/llvm-project?rev=351484=rev
Log:
Add -Wctad-maybe-unsupported to diagnose CTAD on types with no user defined 
deduction guides.

Summary:
Some style guides want to allow using CTAD only on types that "opt-in"; i.e. on 
types that are designed to support it and not just types that *happen* to work 
with it.

This patch implements the `-Wctad-maybe-unsupported` warning, which is off by 
default, which warns when CTAD is used on a type that does not define any 
deduction guides.

The following pattern can be used to suppress the warning in cases where the 
type intentionally doesn't define any deduction guides:

```
struct allow_ctad_t;

template 
struct TestSuppression {
  TestSuppression(T) {}
};
TestSuppression(allow_ctad_t)->TestSuppression; // guides with incomplete 
parameter types are never considered.
```

Reviewers: rsmith, james.dennett, gromer

Reviewed By: rsmith

Subscribers: jdennett, Quuxplusone, lebedev.ri, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=351484=351483=351484=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jan 17 13:44:24 2019
@@ -1050,3 +1050,5 @@ def NoDeref : DiagGroup<"noderef">;
 
 // A group for cross translation unit static analysis related warnings.
 def CrossTU : DiagGroup<"ctu">;
+
+def CTADMaybeUnsupported : DiagGroup<"ctad-maybe-unsupported">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351484=351483=351484=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 13:44:24 
2019
@@ -2129,6 +2129,12 @@ def warn_cxx14_compat_class_template_arg
   "class template argument deduction is incompatible with C++ standards "
   "before C++17%select{|; for compatibility, use explicit type name %1}0">,
   InGroup, DefaultIgnore;
+def warn_ctad_maybe_unsupported : Warning<
+  "%0 may not intend to support class template argument deduction">,
+  InGroup, DefaultIgnore;
+def note_suppress_ctad_maybe_unsupported : Note<
+  "add a deduction guide to suppress this warning">;
+
 
 // C++14 deduced return types
 def err_auto_fn_deduction_failure : Error<

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=351484=351483=351484=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Jan 17 13:44:24 2019
@@ -9264,9 +9264,14 @@ QualType Sema::DeduceTemplateSpecializat
   OverloadCandidateSet Candidates(Kind.getLocation(),
   OverloadCandidateSet::CSK_Normal);
   OverloadCandidateSet::iterator Best;
+
+  bool HasAnyDeductionGuide = false;
+
   auto tryToResolveOverload =
   [&](bool OnlyListConstructors) -> OverloadingResult {
 Candidates.clear(OverloadCandidateSet::CSK_Normal);
+HasAnyDeductionGuide = false;
+
 for (auto I = Guides.begin(), E = Guides.end(); I != E; ++I) {
   NamedDecl *D = (*I)->getUnderlyingDecl();
   if (D->isInvalidDecl())
@@ -9278,6 +9283,9 @@ QualType Sema::DeduceTemplateSpecializat
   if (!GD)
 continue;
 
+  if (!GD->isImplicit())
+HasAnyDeductionGuide = true;
+
   // C++ [over.match.ctor]p1: (non-list copy-initialization from non-class)
   //   For copy-initialization, the candidate functions are all the
   //   converting constructors (12.3.1) of that class.
@@ -9430,5 +9438,15 @@ QualType Sema::DeduceTemplateSpecializat
   Diag(TSInfo->getTypeLoc().getBeginLoc(),
diag::warn_cxx14_compat_class_template_argument_deduction)
   << TSInfo->getTypeLoc().getSourceRange() << 1 << DeducedType;
+
+  // Warn if CTAD was used on a type that does not have any user-defined
+  // deduction guides.
+  if (!HasAnyDeductionGuide) {
+Diag(TSInfo->getTypeLoc().getBeginLoc(),
+ diag::warn_ctad_maybe_unsupported)
+<< TemplateName;
+Diag(Template->getLocation(), diag::note_suppress_ctad_maybe_unsupported);
+  }
+
   return DeducedType;
 }

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 

r351294 - [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2019-01-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jan 15 18:34:36 2019
New Revision: 351294

URL: http://llvm.org/viewvc/llvm-project?rev=351294=rev
Log:
[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

When -faligned-allocation is specified in C++03 libc++ defines
std::align_val_t as an unscoped enumeration type (because Clang didn't
provide scoped enumerations as an extension until 8.0).
Unfortunately Clang confuses the `align_val_t` overloads of delete with
the sized deallocation overloads which aren't enabled. This caused Clang
to call the aligned deallocation function as if it were the sized
deallocation overload.

For example: https://godbolt.org/z/xXJELh

This patch fixes the confusion.

Added:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=351294=351293=351294=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jan 15 18:34:36 2019
@@ -1511,11 +1511,19 @@ namespace {
 Destroying = true;
 ++NumBaseParams;
   }
-  if (FD->getNumParams() == NumBaseParams + 2)
-HasAlignValT = HasSizeT = true;
-  else if (FD->getNumParams() == NumBaseParams + 1) {
-HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
-HasAlignValT = !HasSizeT;
+
+  if (NumBaseParams < FD->getNumParams() &&
+  S.Context.hasSameUnqualifiedType(
+  FD->getParamDecl(NumBaseParams)->getType(),
+  S.Context.getSizeType())) {
+++NumBaseParams;
+HasSizeT = true;
+  }
+
+  if (NumBaseParams < FD->getNumParams() &&
+  FD->getParamDecl(NumBaseParams)->getType()->isAlignValT()) {
+++NumBaseParams;
+HasAlignValT = true;
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Added: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=351294=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp Tue Jan 
15 18:34:36 2019
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
+// RUN:   -faligned-allocation -emit-llvm -o - -Wno-c++11-extensions | 
FileCheck %s
+
+// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
+// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
+// to support aligned allocation in that dialect.
+
+using size_t = __decltype(sizeof(0));
+
+namespace std {
+enum align_val_t : size_t {};
+}
+_Static_assert(__is_same(__underlying_type(std::align_val_t), size_t), "");
+
+// CHECK-LABEL: define void @_Z1fPi(
+void f(int *p) {
+  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
+  // CHECK: call void @_ZdlPv(
+  // CHECK: ret void
+  delete p;
+}


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


r349195 - [Clang] Add __builtin_launder

2018-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec 14 13:11:28 2018
New Revision: 349195

URL: http://llvm.org/viewvc/llvm-project?rev=349195=rev
Log:
[Clang] Add __builtin_launder

Summary:
This patch adds `__builtin_launder`, which is required to implement 
`std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings 
Clang in-line with GCC.

I'm not exactly sure what magic `__builtin_launder` requires, but  based on 
previous discussions this patch applies a `@llvm.invariant.group.barrier`. As 
noted in previous discussions, this may not be enough to correctly handle 
vtables.

Reviewers: rnk, majnemer, rsmith

Reviewed By: rsmith

Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, 
cfe-commits, Prazek

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

Added:
cfe/trunk/test/CodeGenCXX/builtin-launder.cpp
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtins.c
cfe/trunk/test/Preprocessor/feature_tests.c
cfe/trunk/test/Sema/builtins.c
cfe/trunk/test/SemaCXX/builtins.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=349195=349194=349195=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Dec 14 13:11:28 2018
@@ -498,6 +498,7 @@ BUILTIN(__builtin_snprintf, "ic*zcC*.",
 BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
 BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
 BUILTIN(__builtin_thread_pointer, "v*", "nc")
+BUILTIN(__builtin_launder, "v*v*", "nt")
 
 // GCC exception builtins
 BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=349195=349194=349195=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 14 13:11:28 
2018
@@ -9475,4 +9475,8 @@ def warn_noderef_on_non_pointer_or_array
 def warn_noderef_to_dereferenceable_pointer : Warning<
   "casting to dereferenceable pointer removes 'noderef' attribute">, 
InGroup;
 
+def err_builtin_launder_invalid_arg : Error<
+  "%select{non-pointer|function pointer|void pointer}0 argument to "
+  "'__builtin_launder' is not allowed">;
+
 } // end of sema component.

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=349195=349194=349195=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Dec 14 13:11:28 2018
@@ -6112,7 +6112,8 @@ bool PointerExprEvaluator::VisitBuiltinC
 
 return true;
   }
-
+  case Builtin::BI__builtin_launder:
+return evaluatePointer(E->getArg(0), Result);
   case Builtin::BIstrchr:
   case Builtin::BIwcschr:
   case Builtin::BImemchr:

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=349195=349194=349195=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Dec 14 13:11:28 2018
@@ -25,6 +25,7 @@
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/DataLayout.h"
@@ -1409,6 +1410,42 @@ static llvm::Value *dumpRecord(CodeGenFu
   return Res;
 }
 
+static bool
+TypeRequiresBuiltinLaunderImp(const ASTContext , QualType Ty,
+  llvm::SmallPtrSetImpl ) {
+  if (const auto *Arr = Ctx.getAsArrayType(Ty))
+Ty = Ctx.getBaseElementType(Arr);
+
+  const auto *Record = Ty->getAsCXXRecordDecl();
+  if (!Record)
+return false;
+
+  // We've already checked this type, or are in the process of checking it.
+  if (!Seen.insert(Record).second)
+return false;
+
+  assert(Record->hasDefinition() &&
+ "Incomplete types should already be diagnosed");
+
+  if (Record->isDynamicClass())
+return true;
+
+  for (FieldDecl *F : Record->fields()) {
+if (TypeRequiresBuiltinLaunderImp(Ctx, F->getType(), Seen))
+  return true;
+  }
+  return false;
+}
+
+/// Determine if the specified type requires laundering by checking if it is a
+/// dynamic class type or contains a subobject which is a 

r348977 - [AST] Store "UsesADL" information in CallExpr.

2018-12-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 12 13:50:55 2018
New Revision: 348977

URL: http://llvm.org/viewvc/llvm-project?rev=348977=rev
Log:
[AST] Store "UsesADL" information in CallExpr.

Summary:
Currently the Clang AST doesn't store information about how the callee of a 
CallExpr was found. Specifically if it was found using ADL.

However, this information is invaluable to tooling. Consider a tool which 
renames usages of a function. If the originally CallExpr was formed using ADL, 
then the tooling may need to additionally qualify the replacement.
Without information about how the callee was found, the tooling is left 
scratching it's head. Additionally, we want to be able to match ADL calls as 
quickly as possible, which means avoiding computing the answer on the fly.

This patch changes `CallExpr` to store whether it's callee was found using ADL. 
It does not change the size of any AST nodes.


Reviewers: fowles, rsmith, klimek, shafik

Reviewed By: rsmith

Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits

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

Added:
cfe/trunk/test/Import/call-expr/
cfe/trunk/test/Import/call-expr/Inputs/
cfe/trunk/test/Import/call-expr/Inputs/F.cpp
cfe/trunk/test/Import/call-expr/test.cpp
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/AST/ast-dump-expr.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=348977=348976=348977=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed Dec 12 13:50:55 2018
@@ -2562,6 +2562,28 @@ Example matches f(0, 0) (matcher = callE
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExprusesADL
+Matches call expressions 
which were resolved using ADL.
+
+Example matches y(x) but not y(42) or NS::y(x).
+  namespace NS {
+struct X {};
+void y(X);
+  }
+
+  void y(...);
+
+  void test() {
+NS::X x;
+y(x); // Matches
+NS::y(x); // Doesn't match
+y(42); // Doesn't match
+using NS::y;
+y(x); // Found by both unqualified lookup and ADL, doesn't match
+   }
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CastExpr.html;>CastExprhasCastKindCastKind Kind
 Matches casts that has 
a given cast kind.
 

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=348977=348976=348977=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Dec 12 13:50:55 2018
@@ -2412,14 +2412,20 @@ class CallExpr : public Expr {
 
   void updateDependenciesFromArg(Expr *Arg);
 
+public:
+  enum class ADLCallKind : bool { NotADL, UsesADL };
+  static constexpr ADLCallKind NotADL = ADLCallKind::NotADL;
+  static constexpr ADLCallKind UsesADL = ADLCallKind::UsesADL;
+
 protected:
   // These versions of the constructor are for derived classes.
   CallExpr(const ASTContext , StmtClass SC, Expr *fn,
ArrayRef preargs, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 
0);
+   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
+   ADLCallKind UsesADL = NotADL);
   CallExpr(const ASTContext , StmtClass SC, Expr *fn, ArrayRef args,
QualType t, ExprValueKind VK, SourceLocation rparenloc,
-   unsigned MinNumArgs = 0);
+   unsigned MinNumArgs = 0, ADLCallKind UsesADL = NotADL);
   CallExpr(const ASTContext , StmtClass SC, unsigned NumPreArgs,
unsigned NumArgs, EmptyShell Empty);
 
@@ -2443,7 +2449,8 @@ public:
   /// arguments. The actual number of arguments will be the greater of
   /// args.size() and MinNumArgs.
   CallExpr(const ASTContext , Expr *fn, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 
0);
+   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
+   ADLCallKind UsesADL = NotADL);
 
   /// Build an empty call expression.
   CallExpr(const ASTContext , unsigned 

r348864 - Pass PartialOverloading argument to the correct corresponding parameter

2018-12-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 11 08:53:25 2018
New Revision: 348864

URL: http://llvm.org/viewvc/llvm-project?rev=348864=rev
Log:
Pass PartialOverloading argument to the correct corresponding parameter

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CodeCompletion/function-overloads.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=348864=348863=348864=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Dec 11 08:53:25 2018
@@ -8939,12 +8939,14 @@ Sema::AddArgumentDependentLookupCandidat
   if (ExplicitTemplateArgs)
 continue;
 
-  AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet, false,
+  AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet,
+   /*SupressUserConversions=*/false,
PartialOverloading);
-} else
-  AddTemplateOverloadCandidate(cast(*I),
-   FoundDecl, ExplicitTemplateArgs,
-   Args, CandidateSet, PartialOverloading);
+} else {
+ AddTemplateOverloadCandidate(
+  cast(*I), FoundDecl, ExplicitTemplateArgs, 
Args,
+  CandidateSet, /*SupressUserConversions=*/false, PartialOverloading);
+}
   }
 }
 

Modified: cfe/trunk/test/CodeCompletion/function-overloads.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/function-overloads.cpp?rev=348864=348863=348864=diff
==
--- cfe/trunk/test/CodeCompletion/function-overloads.cpp (original)
+++ cfe/trunk/test/CodeCompletion/function-overloads.cpp Tue Dec 11 08:53:25 
2018
@@ -10,12 +10,27 @@ void test() {
   A a(f(1, 2, 3, 4), 2, 3);
 }
 
+
+namespace NS {
+  struct X { };
+  struct Y { Y(X); };
+  template 
+  void g(X, Y);
+}
+
+void test_adl() {
+  NS::X x;
+  g(x, x);
+}
+
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:9 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:10 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:17 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:19 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:20 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:21 %s -o - | 
FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:7 %s -o - | \
+// RUN:FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC1: OVERLOAD: [#int#]f(<#float x#>, float y)
 // CHECK-CC1: OVERLOAD: [#int#]f(<#int i#>)
 // CHECK-CC1-NOT, CHECK-CC2-NOT: OVERLOAD: A(
@@ -25,3 +40,4 @@ void test() {
 // CHECK-CC3: OVERLOAD: A(<#const A 

[clang-tools-extra] r348633 - [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-12-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec  7 12:03:03 2018
New Revision: 348633

URL: http://llvm.org/viewvc/llvm-project?rev=348633=rev
Log:
[clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

Patch by Alex Strelnikov.
Reviewed as D53830

Introduce a new check to upgrade user code based on upcoming API breaking 
changes to absl::Duration.

The check finds calls to arithmetic operators and factory functions for 
absl::Duration that rely on
an implicit user defined conversion to int64_t. These cases will no longer 
compile after proposed
changes are released. Suggested fixes explicitly cast the argument int64_t.

Added:

clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst

clang-tools-extra/trunk/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp?rev=348633=348632=348633=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp Fri Dec  7 
12:03:03 2018
@@ -20,6 +20,7 @@
 #include "RedundantStrcatCallsCheck.h"
 #include "StringFindStartswithCheck.h"
 #include "StrCatAppendCheck.h"
+#include "UpgradeDurationConversionsCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -47,6 +48,8 @@ public:
 "abseil-str-cat-append");
 CheckFactories.registerCheck(
 "abseil-string-find-startswith");
+CheckFactories.registerCheck(
+"abseil-upgrade-duration-conversions");
   }
 };
 

Modified: clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt?rev=348633=348632=348633=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt Fri Dec  7 
12:03:03 2018
@@ -13,6 +13,7 @@ add_clang_library(clangTidyAbseilModule
   RedundantStrcatCallsCheck.cpp
   StrCatAppendCheck.cpp
   StringFindStartswithCheck.cpp
+  UpgradeDurationConversionsCheck.cpp
 
   LINK_LIBS
   clangAST

Added: 
clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp?rev=348633=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp 
Fri Dec  7 12:03:03 2018
@@ -0,0 +1,158 @@
+//===--- UpgradeDurationConversionsCheck.cpp - clang-tidy 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UpgradeDurationConversionsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+void UpgradeDurationConversionsCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // For the arithmetic calls, we match only the uses of the templated 
operators
+  // where the template parameter is not a built-in type. This means the
+  // instantiation makes use of an available user defined conversion to
+  // `int64_t`.
+  //
+  // The implementation of these templates will be updated to fail SFINAE for
+  // non-integral types. We match them to suggest an explicit cast.
+
+  // Match expressions like `a *= b` and `a /= b` where `a` has type
+  // `absl::Duration` and `b` is not of a built-in type.
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  argumentCountIs(2),
+  hasArgument(
+  0, expr(hasType(cxxRecordDecl(hasName("::absl::Duration"),
+  hasArgument(1, expr().bind("arg")),
+  callee(functionDecl(
+  hasParent(functionTemplateDecl()),
+  unless(hasTemplateArgument(0, refersToType(builtinType(,
+  hasAnyName("operator*=", "operator/=",
+  

Re: r345306 - Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

2018-10-25 Thread Eric Fiselier via cfe-commits
The reason for the revert was that the assertion was triggered by a bunch
of tests. It looks like we diagnose the errors later? I'm not sure yet.

On Thu, Oct 25, 2018 at 4:52 PM Eric Fiselier  wrote:

> Ack. My bad.
>
> On Thu, Oct 25, 2018 at 4:02 PM Richard Smith 
> wrote:
>
>> When reverting (even when reverting your own commit), please include in
>> the commit description a reason for the revert.
>>
>> On Thu, 25 Oct 2018 at 12:52, Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Thu Oct 25 12:50:43 2018
>>> New Revision: 345306
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=345306=rev
>>> Log:
>>> Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in
>>> C++03"
>>>
>>> This reverts commit b5d8d0de744d2c212bdb17d5c5fd4447dd14dbd2.
>>>
>>> Removed:
>>> cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345306=345305=345306=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 25 12:50:43 2018
>>> @@ -1515,11 +1515,8 @@ namespace {
>>>if (FD->getNumParams() == NumBaseParams + 2)
>>>  HasAlignValT = HasSizeT = true;
>>>else if (FD->getNumParams() == NumBaseParams + 1) {
>>> -QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
>>> -HasAlignValT = ParamTy->isAlignValT();
>>> -HasSizeT = !HasAlignValT;
>>> -assert((HasAlignValT || ParamTy->isIntegerType()) &&
>>> -"Candidate is not regular dealloc function");
>>> +HasSizeT =
>>> FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
>>> +HasAlignValT = !HasSizeT;
>>>}
>>>
>>>// In CUDA, determine how much we'd like / dislike to call this.
>>>
>>> Removed:
>>> cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345305=auto
>>>
>>> ==
>>> --- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>>> (original)
>>> +++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>>> (removed)
>>> @@ -1,21 +0,0 @@
>>> -// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
>>> -// RUN:   -faligned-allocation -emit-llvm -o - | FileCheck %s
>>> -
>>> -// Ensure Clang doesn't confuse std::align_val_t with the sized
>>> deallocation
>>> -// parameter when the enum type is unscoped. Libc++ does this in C++03
>>> in order
>>> -// to support aligned allocation in that dialect.
>>> -
>>> -using size_t = __decltype(sizeof(0));
>>> -
>>> -namespace std {
>>> -enum align_val_t { zero = size_t(0),
>>> -   max = size_t(-1) };
>>> -}
>>> -
>>> -// CHECK-LABEL: define void @_Z1fPi(
>>> -void f(int *p) {
>>> -  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
>>> -  // CHECK: call void @_ZdlPv(
>>> -  // CHECK: ret void
>>> -  delete p;
>>> -}
>>>
>>>
>>> ___
>>> 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


Re: r345306 - Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

2018-10-25 Thread Eric Fiselier via cfe-commits
Ack. My bad.

On Thu, Oct 25, 2018 at 4:02 PM Richard Smith  wrote:

> When reverting (even when reverting your own commit), please include in
> the commit description a reason for the revert.
>
> On Thu, 25 Oct 2018 at 12:52, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Thu Oct 25 12:50:43 2018
>> New Revision: 345306
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=345306=rev
>> Log:
>> Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in
>> C++03"
>>
>> This reverts commit b5d8d0de744d2c212bdb17d5c5fd4447dd14dbd2.
>>
>> Removed:
>> cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>> Modified:
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345306=345305=345306=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 25 12:50:43 2018
>> @@ -1515,11 +1515,8 @@ namespace {
>>if (FD->getNumParams() == NumBaseParams + 2)
>>  HasAlignValT = HasSizeT = true;
>>else if (FD->getNumParams() == NumBaseParams + 1) {
>> -QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
>> -HasAlignValT = ParamTy->isAlignValT();
>> -HasSizeT = !HasAlignValT;
>> -assert((HasAlignValT || ParamTy->isIntegerType()) &&
>> -"Candidate is not regular dealloc function");
>> +HasSizeT =
>> FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
>> +HasAlignValT = !HasSizeT;
>>}
>>
>>// In CUDA, determine how much we'd like / dislike to call this.
>>
>> Removed: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345305=auto
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>> (original)
>> +++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
>> (removed)
>> @@ -1,21 +0,0 @@
>> -// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
>> -// RUN:   -faligned-allocation -emit-llvm -o - | FileCheck %s
>> -
>> -// Ensure Clang doesn't confuse std::align_val_t with the sized
>> deallocation
>> -// parameter when the enum type is unscoped. Libc++ does this in C++03
>> in order
>> -// to support aligned allocation in that dialect.
>> -
>> -using size_t = __decltype(sizeof(0));
>> -
>> -namespace std {
>> -enum align_val_t { zero = size_t(0),
>> -   max = size_t(-1) };
>> -}
>> -
>> -// CHECK-LABEL: define void @_Z1fPi(
>> -void f(int *p) {
>> -  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
>> -  // CHECK: call void @_ZdlPv(
>> -  // CHECK: ret void
>> -  delete p;
>> -}
>>
>>
>> ___
>> 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


r345306 - Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

2018-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Oct 25 12:50:43 2018
New Revision: 345306

URL: http://llvm.org/viewvc/llvm-project?rev=345306=rev
Log:
Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

This reverts commit b5d8d0de744d2c212bdb17d5c5fd4447dd14dbd2.

Removed:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345306=345305=345306=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 25 12:50:43 2018
@@ -1515,11 +1515,8 @@ namespace {
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
-HasAlignValT = ParamTy->isAlignValT();
-HasSizeT = !HasAlignValT;
-assert((HasAlignValT || ParamTy->isIntegerType()) &&
-"Candidate is not regular dealloc function");
+HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
+HasAlignValT = !HasSizeT;
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Removed: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345305=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
-// RUN:   -faligned-allocation -emit-llvm -o - | FileCheck %s
-
-// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
-// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
-// to support aligned allocation in that dialect.
-
-using size_t = __decltype(sizeof(0));
-
-namespace std {
-enum align_val_t { zero = size_t(0),
-   max = size_t(-1) };
-}
-
-// CHECK-LABEL: define void @_Z1fPi(
-void f(int *p) {
-  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
-  // CHECK: call void @_ZdlPv(
-  // CHECK: ret void
-  delete p;
-}


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


Re: r345296 - [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-25 Thread Eric Fiselier via cfe-commits
reverting

On Thu., Oct. 25, 2018, 2:18 p.m. Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org wrote:

> Author: ericwf
> Date: Thu Oct 25 11:16:16 2018
> New Revision: 345296
>
> URL: http://llvm.org/viewvc/llvm-project?rev=345296=rev
> Log:
> [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03
>
> Summary:
> When -faligned-allocation is specified in C++03 libc++ defines
> std::align_val_t as an unscoped enumeration type (because Clang didn't
> provide scoped enumerations as an extension until 8.0).
> Unfortunately Clang confuses the `align_val_t` overloads of delete with
> the sized deallocation overloads which aren't enabled. This caused Clang to
> call the aligned deallocation function as if it were the sized deallocation
> overload.
>
> For example: https://godbolt.org/z/xXJELh
>
> This patch fixes the confusion.
>
> Reviewers: rsmith, EricWF
>
> Reviewed By: EricWF
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D53508
>
> Added:
> cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345296=345295=345296=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 25 11:16:16 2018
> @@ -1515,8 +1515,11 @@ namespace {
>if (FD->getNumParams() == NumBaseParams + 2)
>  HasAlignValT = HasSizeT = true;
>else if (FD->getNumParams() == NumBaseParams + 1) {
> -HasSizeT =
> FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
> -HasAlignValT = !HasSizeT;
> +QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
> +HasAlignValT = ParamTy->isAlignValT();
> +HasSizeT = !HasAlignValT;
> +assert((HasAlignValT || ParamTy->isIntegerType()) &&
> +"Candidate is not regular dealloc function");
>}
>
>// In CUDA, determine how much we'd like / dislike to call this.
>
> Added: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345296=auto
>
> ==
> --- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
> (added)
> +++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp Thu
> Oct 25 11:16:16 2018
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
> +// RUN:   -faligned-allocation -emit-llvm -o - | FileCheck %s
> +
> +// Ensure Clang doesn't confuse std::align_val_t with the sized
> deallocation
> +// parameter when the enum type is unscoped. Libc++ does this in C++03 in
> order
> +// to support aligned allocation in that dialect.
> +
> +using size_t = __decltype(sizeof(0));
> +
> +namespace std {
> +enum align_val_t { zero = size_t(0),
> +   max = size_t(-1) };
> +}
> +
> +// CHECK-LABEL: define void @_Z1fPi(
> +void f(int *p) {
> +  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
> +  // CHECK: call void @_ZdlPv(
> +  // CHECK: ret void
> +  delete p;
> +}
>
>
> ___
> 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


r345296 - [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Oct 25 11:16:16 2018
New Revision: 345296

URL: http://llvm.org/viewvc/llvm-project?rev=345296=rev
Log:
[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

Summary:
When -faligned-allocation is specified in C++03 libc++ defines std::align_val_t 
as an unscoped enumeration type (because Clang didn't provide scoped 
enumerations as an extension until 8.0).
Unfortunately Clang confuses the `align_val_t` overloads of delete with the 
sized deallocation overloads which aren't enabled. This caused Clang to call 
the aligned deallocation function as if it were the sized deallocation overload.

For example: https://godbolt.org/z/xXJELh

This patch fixes the confusion.

Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345296=345295=345296=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 25 11:16:16 2018
@@ -1515,8 +1515,11 @@ namespace {
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
-HasAlignValT = !HasSizeT;
+QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
+HasAlignValT = ParamTy->isAlignValT();
+HasSizeT = !HasAlignValT;
+assert((HasAlignValT || ParamTy->isIntegerType()) &&
+"Candidate is not regular dealloc function");
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Added: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345296=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp Thu Oct 
25 11:16:16 2018
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
+// RUN:   -faligned-allocation -emit-llvm -o - | FileCheck %s
+
+// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
+// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
+// to support aligned allocation in that dialect.
+
+using size_t = __decltype(sizeof(0));
+
+namespace std {
+enum align_val_t { zero = size_t(0),
+   max = size_t(-1) };
+}
+
+// CHECK-LABEL: define void @_Z1fPi(
+void f(int *p) {
+  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
+  // CHECK: call void @_ZdlPv(
+  // CHECK: ret void
+  delete p;
+}


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


r345225 - Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

2018-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Oct 24 16:47:04 2018
New Revision: 345225

URL: http://llvm.org/viewvc/llvm-project?rev=345225=rev
Log:
Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

This reverts commit 6f47cdd51341344c0e32630e19e72c94cd25f34e.

Removed:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345225=345224=345225=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 24 16:47:04 2018
@@ -1515,9 +1515,8 @@ namespace {
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
-HasAlignValT = ParamTy->isAlignValT();
-HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
+HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
+HasAlignValT = !HasSizeT;
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Removed: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345224=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
-// RUN:   -emit-llvm -o - | FileCheck %s
-
-// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
-// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
-// to support aligned allocation in that dialect.
-
-using size_t = __decltype(sizeof(0));
-
-namespace std {
-enum align_val_t { zero = size_t(0),
-   max = size_t(-1) };
-}
-
-// CHECK-LABEL: define void @_Z1fPi(
-void f(int *p) {
-  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
-  // CHECK: call void @_ZdlPv(
-  // CHECK: ret void
-  delete p;
-}


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


r345211 - [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Oct 24 15:38:49 2018
New Revision: 345211

URL: http://llvm.org/viewvc/llvm-project?rev=345211=rev
Log:
[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

Summary:
When -faligned-allocation is specified in C++03 libc++ defines std::align_val_t 
as an unscoped enumeration type (because Clang didn't provide scoped 
enumerations as an extension until 8.0).
Unfortunately Clang confuses the `align_val_t` overloads of delete with the 
sized deallocation overloads which aren't enabled. This caused Clang to call 
the aligned deallocation function as if it were the sized deallocation overload.

For example: https://godbolt.org/z/xXJELh

This patch fixes the confusion.

Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345211=345210=345211=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 24 15:38:49 2018
@@ -1515,8 +1515,9 @@ namespace {
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
-HasAlignValT = !HasSizeT;
+QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
+HasAlignValT = ParamTy->isAlignValT();
+HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Added: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345211=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp Wed Oct 
24 15:38:49 2018
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
+// RUN:   -emit-llvm -o - | FileCheck %s
+
+// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
+// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
+// to support aligned allocation in that dialect.
+
+using size_t = __decltype(sizeof(0));
+
+namespace std {
+enum align_val_t { zero = size_t(0),
+   max = size_t(-1) };
+}
+
+// CHECK-LABEL: define void @_Z1fPi(
+void f(int *p) {
+  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
+  // CHECK: call void @_ZdlPv(
+  // CHECK: ret void
+  delete p;
+}


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


Re: [libcxx] r342073 - Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955

2018-10-04 Thread Eric Fiselier via cfe-commits
On Thu, Oct 4, 2018 at 11:42 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Perhaps libc++ could provide a __version file that contains the headers,
> and use #include <__version> internally? We'd still need a  header
> that just includes <__version> for conformance, but that should be after
> user headers on the include path so shouldn't break things.
>

+1

I was going to suggest this exact fix. (But only in the case of 
and not as a general rule going forward.)




>
> On Thu, 4 Oct 2018, 07:10 Marshall Clow via cfe-commits, <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Wed, Oct 3, 2018 at 3:38 AM Christof Douma 
>> wrote:
>>
>>> Hi.
>>>
>>>
>>>
>>> Yes, including  would try to include the “version” file inside
>>> the users project. The problem is not the existence of the header file, but
>>> the #include directive that is not guarded. To give examples on when this
>>> goes wrong:
>>>
>>>
>>>
>>> A project uses VERSION in their source directory to hold some version
>>> string used in the build system. On platforms like Windows and OS X this
>>> file is indistinguishable from the system include file that many headers
>>> include.
>>>
>>>
>>>
>>> I don’t think this is a strange setup, and while I expect that for C++20
>>> code bases, people need to pick a different name, I think that existing
>>> projects should not be bothered by this. It would be nice if everybody was
>>> using -iquote, or better in my opinion, that -I was behaving like -iquote.
>>> But a fix that we can apply now is to use:
>>>
>>>
>>>
>>>   #if _LIBCPP_STD_VER > 17
>>>
>>> #include 
>>>
>>>   #endif
>>>
>>>
>>>
>>> Would that be acceptable?
>>>
>>
>> Christof -
>>
>> There are people in the community who really want these feature macros.
>> In particular, they *really* want them for C++14 and C++17 (not just
>> c++20)
>>
>> In general, I am against back-porting new features to old language
>> versions (string_view being the one large exception), but this seems like a
>> low-risk thing to do.
>>
>> However, it would make your suggestion unfeasible.
>>
>> -- Marshall
>>
>>
>>
>>
>>>
>>>
>>> Thanks,
>>>
>>> Christof
>>>
>>>
>>>
>>> *From: *Eric Fiselier 
>>> *Date: *Tuesday, 2 October 2018 at 19:52
>>> *To: *Christof Douma 
>>> *Cc: *Marshall Clow , cfe-commits <
>>> cfe-commits@lists.llvm.org>, nd 
>>> *Subject: *Re: [libcxx] r342073 - Implement the infrastructure for
>>> feature-test macros. Very few actual feature test macros, though. Reviewed
>>> as: https://reviews.llvm.org/D51955
>>>
>>>
>>>
>>>
>>>
>>> On Tue, Oct 2, 2018 at 1:33 PM Christof Douma via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>> Hi Marshall.
>>>
>>> I think that this patch breaks backwards compatibility.  Assumes that
>>> the header file "version" is used by C++ projects that use a C++ standard
>>> that did not specify a 'version' header. Many toolchains will put search
>>> paths specified with -I in front of the system search path. The result is
>>> that the application header file is included whenever a standard header
>>> file is included. That is unexpected and can break builds.
>>>
>>> Do you agree this is an issue or do you consider this an issue with the
>>> way toolchains handle include search paths?
>>>
>>>
>>>
>>> If I understand correctly, you have user code which provides a header
>>> called "version", and now when files like  include  they
>>> pick up the user header instead of the STL one?
>>>
>>> Are you specifying custom libc++ include paths when this occurs? Or just
>>> passing "-stdlib=libc++" and letting the compiler do the rest?
>>>
>>>
>>>
>>> In general, I don't consider this a bug. There is no way for libc++ to
>>> make the  file disappear in older dialects, and libc++ headers are
>>> free to include w/e additional headers
>>>
>>> they need.
>>>
>>>
>>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r342827 - Fix modules build with shared library.

2018-10-01 Thread Eric Fiselier via cfe-commits
I was building with -DLLVM_ENABLE_MODULES=ON -DBUILD_SHARED_LIBS=ON. I
think that's enough to trigger it?

/Eric

On Mon, Oct 1, 2018 at 4:13 PM David Blaikie  wrote:

> I can't really reproduce this - when I try to build clang/llvm with
> LLVM_ENABLE_MODULES in CMake I'm still seeing an error I reported March on
> a cfe-dev thread - something to do with unique_ptr instantiations for
> MappedBlockStream in the PDB parsing code.
>
> So, I'm wondering what error you hit, Eric/where/how, etc...
>
> On Sun, Sep 30, 2018 at 10:23 AM Eric Fiselier  wrote:
>
>> +rsmith (actually this time)
>>
>> On Sun, Sep 30, 2018 at 12:09 PM Eric Fiselier  wrote:
>>
>>> +rsmith
>>>
>>> Hi All,
>>>
>>> Sorry, I'm not actually sure why this fix is correct.I stole both the
>>> fix and the comment from a similar one on L150 of the module map left by
>>> Richard Smith.
>>>
>>> /Eric
>>>
>>> On Tue, Sep 25, 2018 at 8:36 PM Shuai Wang  wrote:
>>>
>>>> I'd like to understand this better as well, in particular what would be
>>>> a proper fix?
>>>>
>>>> On Tue, Sep 25, 2018 at 2:15 PM David Blaikie 
>>>> wrote:
>>>>
>>>>> +Shuai Wang
>>>>>
>>>>> On Tue, Sep 25, 2018 at 2:14 PM David Blaikie 
>>>>> wrote:
>>>>>
>>>>>> Hey Eric - thanks for the fix - but could you explain the issue here
>>>>>> in a bit more detail, as I'm a bit confused (& really interested in
>>>>>> understanding any layering problems in LLVM - and fixing them/making sure
>>>>>> they're fixed/holding the line/etc)
>>>>>>
>>>>>> What do you mean by "pull all of the AST matchers library into clang"
>>>>>> - how does including a header ever add a link dependency?
>>>>>>
>>>>>> - Dave
>>>>>>
>>>>>>
>>>>>> On Sat, Sep 22, 2018 at 5:49 PM Eric Fiselier via cfe-commits <
>>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>>
>>>>>>> Author: ericwf
>>>>>>> Date: Sat Sep 22 17:48:05 2018
>>>>>>> New Revision: 342827
>>>>>>>
>>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=342827=rev
>>>>>>> Log:
>>>>>>> Fix modules build with shared library.
>>>>>>>
>>>>>>> r341994 caused clangAnalysis to pull all of the AST matchers
>>>>>>> library into clang. Due to inline key functions in the headers,
>>>>>>> importing the AST matchers library gives a link dependency on the
>>>>>>> AST matchers (and thus the AST), which clang should not
>>>>>>> have.
>>>>>>>
>>>>>>> This patch works around the issues by excluding the offending
>>>>>>> libclangAnalysis header in the modulemap.
>>>>>>>
>>>>>>> Modified:
>>>>>>> cfe/trunk/include/clang/module.modulemap
>>>>>>>
>>>>>>> Modified: cfe/trunk/include/clang/module.modulemap
>>>>>>> URL:
>>>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=342827=342826=342827=diff
>>>>>>>
>>>>>>> ==
>>>>>>> --- cfe/trunk/include/clang/module.modulemap (original)
>>>>>>> +++ cfe/trunk/include/clang/module.modulemap Sat Sep 22 17:48:05 2018
>>>>>>> @@ -5,6 +5,12 @@ module Clang_Analysis {
>>>>>>>textual header "Analysis/Analyses/ThreadSafetyOps.def"
>>>>>>>
>>>>>>>module * { export * }
>>>>>>> +
>>>>>>> +  // FIXME: Exclude these headers to avoid pulling all of the AST
>>>>>>> matchers
>>>>>>> +  // library into clang. Due to inline key functions in the headers,
>>>>>>> +  // importing the AST matchers library gives a link dependency on
>>>>>>> the AST
>>>>>>> +  // matchers (and thus the AST), which clang-format should not
>>>>>>> have.
>>>>>>> +  exclude header "Analysis/Analyses/ExprMutationAnalyzer.h"
>>>>>>>  }
>>>>>>>
>>>>>>>  module Clang_AST {
>>>>>>>
>>>>>>>
>>>>>>> ___
>>>>>>> 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


r343420 - Fix linkage error on ProgramPoint's dump method.

2018-09-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep 30 11:05:39 2018
New Revision: 343420

URL: http://llvm.org/viewvc/llvm-project?rev=343420=rev
Log:
Fix linkage error on ProgramPoint's dump method.

Currently, ProgramPoint::dump calls the out-of-line function 
ProgramPoint::print. This causes
libraries which include ProgramPoint.h to become dependent on libclangAnalysis, 
which in turn
causes missing symbol link error when building with -DBUILD_SHARED_LIBS=ON 
-DLLVM_ENABLE_MODULES=ON.

The breakage was introduced in r343160.

This patch fixes the issues by moving ProgramPoint::dump's declaration out of 
line.

Modified:
cfe/trunk/include/clang/Analysis/ProgramPoint.h
cfe/trunk/lib/Analysis/ProgramPoint.cpp

Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=343420=343419=343420=diff
==
--- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Sun Sep 30 11:05:39 2018
@@ -217,9 +217,7 @@ public:
 
   void print(StringRef CR, llvm::raw_ostream ) const;
 
-  LLVM_DUMP_METHOD void dump() const {
-return print(/*CR=*/"\n", llvm::errs());
-  }
+  LLVM_DUMP_METHOD void dump() const;
 
   static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K,
   const LocationContext *LC,

Modified: cfe/trunk/lib/Analysis/ProgramPoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ProgramPoint.cpp?rev=343420=343419=343420=diff
==
--- cfe/trunk/lib/Analysis/ProgramPoint.cpp (original)
+++ cfe/trunk/lib/Analysis/ProgramPoint.cpp Sun Sep 30 11:05:39 2018
@@ -43,6 +43,10 @@ ProgramPoint ProgramPoint::getProgramPoi
   }
 }
 
+LLVM_DUMP_METHOD void ProgramPoint::dump() const {
+  return print(/*CR=*/"\n", llvm::errs());
+}
+
 static void printLocation(raw_ostream , SourceLocation SLoc,
   const SourceManager ,
   StringRef CR,


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


Re: r342827 - Fix modules build with shared library.

2018-09-30 Thread Eric Fiselier via cfe-commits
+rsmith (actually this time)

On Sun, Sep 30, 2018 at 12:09 PM Eric Fiselier  wrote:

> +rsmith
>
> Hi All,
>
> Sorry, I'm not actually sure why this fix is correct.I stole both the fix
> and the comment from a similar one on L150 of the module map left by
> Richard Smith.
>
> /Eric
>
> On Tue, Sep 25, 2018 at 8:36 PM Shuai Wang  wrote:
>
>> I'd like to understand this better as well, in particular what would be a
>> proper fix?
>>
>> On Tue, Sep 25, 2018 at 2:15 PM David Blaikie  wrote:
>>
>>> +Shuai Wang
>>>
>>> On Tue, Sep 25, 2018 at 2:14 PM David Blaikie 
>>> wrote:
>>>
>>>> Hey Eric - thanks for the fix - but could you explain the issue here in
>>>> a bit more detail, as I'm a bit confused (& really interested in
>>>> understanding any layering problems in LLVM - and fixing them/making sure
>>>> they're fixed/holding the line/etc)
>>>>
>>>> What do you mean by "pull all of the AST matchers library into clang" -
>>>> how does including a header ever add a link dependency?
>>>>
>>>> - Dave
>>>>
>>>>
>>>> On Sat, Sep 22, 2018 at 5:49 PM Eric Fiselier via cfe-commits <
>>>> cfe-commits@lists.llvm.org> wrote:
>>>>
>>>>> Author: ericwf
>>>>> Date: Sat Sep 22 17:48:05 2018
>>>>> New Revision: 342827
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=342827=rev
>>>>> Log:
>>>>> Fix modules build with shared library.
>>>>>
>>>>> r341994 caused clangAnalysis to pull all of the AST matchers
>>>>> library into clang. Due to inline key functions in the headers,
>>>>> importing the AST matchers library gives a link dependency on the
>>>>> AST matchers (and thus the AST), which clang should not
>>>>> have.
>>>>>
>>>>> This patch works around the issues by excluding the offending
>>>>> libclangAnalysis header in the modulemap.
>>>>>
>>>>> Modified:
>>>>> cfe/trunk/include/clang/module.modulemap
>>>>>
>>>>> Modified: cfe/trunk/include/clang/module.modulemap
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=342827=342826=342827=diff
>>>>>
>>>>> ==
>>>>> --- cfe/trunk/include/clang/module.modulemap (original)
>>>>> +++ cfe/trunk/include/clang/module.modulemap Sat Sep 22 17:48:05 2018
>>>>> @@ -5,6 +5,12 @@ module Clang_Analysis {
>>>>>textual header "Analysis/Analyses/ThreadSafetyOps.def"
>>>>>
>>>>>module * { export * }
>>>>> +
>>>>> +  // FIXME: Exclude these headers to avoid pulling all of the AST
>>>>> matchers
>>>>> +  // library into clang. Due to inline key functions in the headers,
>>>>> +  // importing the AST matchers library gives a link dependency on
>>>>> the AST
>>>>> +  // matchers (and thus the AST), which clang-format should not have.
>>>>> +  exclude header "Analysis/Analyses/ExprMutationAnalyzer.h"
>>>>>  }
>>>>>
>>>>>  module Clang_AST {
>>>>>
>>>>>
>>>>> ___
>>>>> 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


Re: r342827 - Fix modules build with shared library.

2018-09-30 Thread Eric Fiselier via cfe-commits
+rsmith

Hi All,

Sorry, I'm not actually sure why this fix is correct.I stole both the fix
and the comment from a similar one on L150 of the module map left by
Richard Smith.

/Eric

On Tue, Sep 25, 2018 at 8:36 PM Shuai Wang  wrote:

> I'd like to understand this better as well, in particular what would be a
> proper fix?
>
> On Tue, Sep 25, 2018 at 2:15 PM David Blaikie  wrote:
>
>> +Shuai Wang
>>
>> On Tue, Sep 25, 2018 at 2:14 PM David Blaikie  wrote:
>>
>>> Hey Eric - thanks for the fix - but could you explain the issue here in
>>> a bit more detail, as I'm a bit confused (& really interested in
>>> understanding any layering problems in LLVM - and fixing them/making sure
>>> they're fixed/holding the line/etc)
>>>
>>> What do you mean by "pull all of the AST matchers library into clang" -
>>> how does including a header ever add a link dependency?
>>>
>>> - Dave
>>>
>>>
>>> On Sat, Sep 22, 2018 at 5:49 PM Eric Fiselier via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: ericwf
>>>> Date: Sat Sep 22 17:48:05 2018
>>>> New Revision: 342827
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=342827=rev
>>>> Log:
>>>> Fix modules build with shared library.
>>>>
>>>> r341994 caused clangAnalysis to pull all of the AST matchers
>>>> library into clang. Due to inline key functions in the headers,
>>>> importing the AST matchers library gives a link dependency on the
>>>> AST matchers (and thus the AST), which clang should not
>>>> have.
>>>>
>>>> This patch works around the issues by excluding the offending
>>>> libclangAnalysis header in the modulemap.
>>>>
>>>> Modified:
>>>> cfe/trunk/include/clang/module.modulemap
>>>>
>>>> Modified: cfe/trunk/include/clang/module.modulemap
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=342827=342826=342827=diff
>>>>
>>>> ==
>>>> --- cfe/trunk/include/clang/module.modulemap (original)
>>>> +++ cfe/trunk/include/clang/module.modulemap Sat Sep 22 17:48:05 2018
>>>> @@ -5,6 +5,12 @@ module Clang_Analysis {
>>>>textual header "Analysis/Analyses/ThreadSafetyOps.def"
>>>>
>>>>module * { export * }
>>>> +
>>>> +  // FIXME: Exclude these headers to avoid pulling all of the AST
>>>> matchers
>>>> +  // library into clang. Due to inline key functions in the headers,
>>>> +  // importing the AST matchers library gives a link dependency on the
>>>> AST
>>>> +  // matchers (and thus the AST), which clang-format should not have.
>>>> +  exclude header "Analysis/Analyses/ExprMutationAnalyzer.h"
>>>>  }
>>>>
>>>>  module Clang_AST {
>>>>
>>>>
>>>> ___
>>>> 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


r342827 - Fix modules build with shared library.

2018-09-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Sep 22 17:48:05 2018
New Revision: 342827

URL: http://llvm.org/viewvc/llvm-project?rev=342827=rev
Log:
Fix modules build with shared library.

r341994 caused clangAnalysis to pull all of the AST matchers
library into clang. Due to inline key functions in the headers,
importing the AST matchers library gives a link dependency on the
AST matchers (and thus the AST), which clang should not
have.

This patch works around the issues by excluding the offending
libclangAnalysis header in the modulemap.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=342827=342826=342827=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Sat Sep 22 17:48:05 2018
@@ -5,6 +5,12 @@ module Clang_Analysis {
   textual header "Analysis/Analyses/ThreadSafetyOps.def"
 
   module * { export * }
+
+  // FIXME: Exclude these headers to avoid pulling all of the AST matchers
+  // library into clang. Due to inline key functions in the headers,
+  // importing the AST matchers library gives a link dependency on the AST
+  // matchers (and thus the AST), which clang-format should not have.
+  exclude header "Analysis/Analyses/ExprMutationAnalyzer.h"
 }
 
 module Clang_AST {


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


[libcxx] r340426 - Add diagnostics for min/max algorithms when a InputIterator is used.

2018-08-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Aug 22 10:47:13 2018
New Revision: 340426

URL: http://llvm.org/viewvc/llvm-project?rev=340426=rev
Log:
Add diagnostics for min/max algorithms when a InputIterator is used.

These algorithms require a ForwardIterator or better. Ensure
we diagnose the contract violation at compile time instead of
of silently doing the wrong thing.

Further algorithms will be audited in upcoming patches.

Added:

libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
Modified:
libcxx/trunk/include/algorithm

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=340426=340425=340426=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Aug 22 10:47:13 2018
@@ -2398,6 +2398,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP
 _ForwardIterator
 min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
+static_assert(__is_forward_iterator<_ForwardIterator>::value,
+"std::min_element requires a ForwardIterator");
 if (__first != __last)
 {
 _ForwardIterator __i = __first;
@@ -2462,6 +2464,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP
 _ForwardIterator
 max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
 {
+static_assert(__is_forward_iterator<_ForwardIterator>::value,
+"std::max_element requires a ForwardIterator");
 if (__first != __last)
 {
 _ForwardIterator __i = __first;
@@ -2548,6 +2552,8 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11
 std::pair<_ForwardIterator, _ForwardIterator>
 minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare 
__comp)
 {
+  static_assert(__is_forward_iterator<_ForwardIterator>::value,
+"std::minmax_element requires a ForwardIterator");
   std::pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
   if (__first != __last)
   {

Added: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp?rev=340426=auto
==
--- 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
 Wed Aug 22 10:47:13 2018
@@ -0,0 +1,37 @@
+//===--===//
+//
+// 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
+//   max_element(Iter first, Iter last);
+
+#include 
+#include 
+
+#include "test_iterators.h"
+
+int main() {
+  int arr[] = {1, 2, 3};
+  const int *b = std::begin(arr), *e = std::end(arr);
+  typedef input_iterator Iter;
+  {
+// expected-error@algorithm:* {{"std::min_element requires a 
ForwardIterator"}}
+std::min_element(Iter(b), Iter(e));
+  }
+  {
+// expected-error@algorithm:* {{"std::max_element requires a 
ForwardIterator"}}
+std::max_element(Iter(b), Iter(e));
+  }
+  {
+// expected-error@algorithm:* {{"std::minmax_element requires a 
ForwardIterator"}}
+std::minmax_element(Iter(b), Iter(e));
+  }
+
+}


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


[libcxx] r340406 - Attempt to unbreak filesystem tests on certain linux distros.

2018-08-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Aug 22 06:29:52 2018
New Revision: 340406

URL: http://llvm.org/viewvc/llvm-project?rev=340406=rev
Log:
Attempt to unbreak filesystem tests on certain linux distros.

On some platforms clock_gettime is in librt, which we don't
link by default when building the tests. However it is required
by the filesystem tests.

This patch introduces a workaround which links librt whenever
the filesystem tests are enabled. The workaround should later
be replaced with a patch that selectively links both libc++fs
and librt only when building filesystem specific tests. However,
the way the test configuration is set up right now, this is
non-trivial.

Modified:
libcxx/trunk/utils/libcxx/test/target_info.py

Modified: libcxx/trunk/utils/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/target_info.py?rev=340406=340405=340406=diff
==
--- libcxx/trunk/utils/libcxx/test/target_info.py (original)
+++ libcxx/trunk/utils/libcxx/test/target_info.py Wed Aug 22 06:29:52 2018
@@ -222,12 +222,17 @@ class LinuxLocalTI(DefaultTargetInfo):
   self.full_config.config.available_features)
 llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False)
 shared_libcxx = self.full_config.get_lit_bool('enable_shared', True)
+# FIXME: Remove the need to link -lrt in all the tests, and instead
+# limit it only to the filesystem tests. This ensures we don't cause an
+# implicit dependency on librt except when filesystem is needed.
+enable_fs = self.full_config.get_lit_bool('enable_filesystem',
+  default=False)
 flags += ['-lm']
 if not llvm_unwinder:
 flags += ['-lgcc_s', '-lgcc']
 if enable_threads:
 flags += ['-lpthread']
-if not shared_libcxx:
+if not shared_libcxx or enable_fs:
   flags += ['-lrt']
 flags += ['-lc']
 if llvm_unwinder:


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


[libcxx] r338103 - Move Filesystem namespace definition out of a clang specific ifdef block.

2018-07-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 26 23:12:46 2018
New Revision: 338103

URL: http://llvm.org/viewvc/llvm-project?rev=338103=rev
Log:
Move Filesystem namespace definition out of a clang specific ifdef block.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338103=338102=338103=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Jul 26 23:12:46 2018
@@ -474,19 +474,6 @@ namespace std {
   }
 }
 
-#if _LIBCPP_STD_VER >= 17
-#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
-  _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
-#else
-#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
-  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
-#endif
-
-#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
-  _LIBCPP_END_NAMESPACE_STD } }
-
-#define _VSTD_FS _VSTD::__fs::filesystem
-
 #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
 #define _LIBCPP_HAS_NO_ASAN
 #endif
@@ -659,6 +646,20 @@ namespace std {
 
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
+#if _LIBCPP_STD_VER >= 17
+#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+  _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
+#else
+#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
+  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
+#endif
+
+#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
+  _LIBCPP_END_NAMESPACE_STD } }
+
+#define _VSTD_FS _VSTD::__fs::filesystem
+
+
 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
 #ifdef _DLL


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


[libcxx] r338096 - Add libc++fs to the test deps, and not to the target 'cxx'.

2018-07-26 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 26 20:47:46 2018
New Revision: 338096

URL: http://llvm.org/viewvc/llvm-project?rev=338096=rev
Log:
Add libc++fs to the test deps, and not to the target 'cxx'.

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

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=338096=338095=338096=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Thu Jul 26 20:47:46 2018
@@ -288,6 +288,9 @@ if (LIBCXX_ENABLE_STATIC)
   endif()
 endif()
 
+# Add a meta-target for both libraries.
+add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
+
 if (LIBCXX_ENABLE_FILESYSTEM)
   set(LIBCXX_FILESYSTEM_SOURCES
   ../src/filesystem/operations.cpp
@@ -318,7 +321,6 @@ if (LIBCXX_ENABLE_FILESYSTEM)
   COMPILE_FLAGS "${filesystem_flags}"
   OUTPUT_NAME   "c++fs"
   )
-  list(APPEND LIBCXX_BUILD_TARGETS cxx_filesystem)
 endif()
 
 
@@ -341,14 +343,8 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   COMPILE_FLAGS "${experimental_flags}"
   OUTPUT_NAME   "c++experimental"
   )
-  list(APPEND LIBCXX_BUILD_TARGETS cxx_experimental)
 endif()
 
-
-# Add a meta-target for both libraries.
-add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
-
-
 if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES 
../test/support/external_threads.cpp)
 

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=338096=338095=338096=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Thu Jul 26 20:47:46 2018
@@ -58,7 +58,10 @@ set(AUTO_GEN_COMMENT "## Autogenerated b
 set(LIBCXX_TEST_DEPS "")
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-  set(LIBCXX_TEST_DEPS cxx_experimental)
+  list(APPEND LIBCXX_TEST_DEPS cxx_experimental)
+endif()
+if (LIBCXX_ENABLE_FILESYSTEM)
+  list(APPEND LIBCXX_TEST_DEPS cxx_filesystem)
 endif()
 
 if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)


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


[libcxx] r338095 - Attempt to unbreak *all the bots*

2018-07-26 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 26 20:42:58 2018
New Revision: 338095

URL: http://llvm.org/viewvc/llvm-project?rev=338095=rev
Log:
Attempt to unbreak *all the bots*

The bots were failing to build the cxx_filesystem target, so the
tests were failing. Though this does lead me to wonder how it
was ever working with c++experimental.

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

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=338095=338094=338095=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Jul 26 20:42:58 2018
@@ -72,7 +72,7 @@ set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_E
 if (WIN32)
   set(ENABLE_FILESYSTEM_DEFAULT OFF)
 endif()
-option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of 
libc++experimental.a"
+option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++fs.a"
 ${ENABLE_FILESYSTEM_DEFAULT})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
 
@@ -109,7 +109,7 @@ cmake_dependent_option(LIBCXX_INSTALL_EX
 "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
 cmake_dependent_option(LIBCXX_INSTALL_FILESYSTEM_LIBRARY
 "Install libc++fs.a" ON
-"LIBCXX_ENABLE_FILESYSTEM_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
+"LIBCXX_ENABLE_FILESYSTEM;LIBCXX_INSTALL_LIBRARY" OFF)
 
 if (FUCHSIA)
   set(DEFAULT_ABI_VERSION 2)

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=338095=338094=338095=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Thu Jul 26 20:42:58 2018
@@ -93,6 +93,7 @@ set(files
   ext/__hash
   ext/hash_map
   ext/hash_set
+  filesystem
   float.h
   forward_list
   fstream

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=338095=338094=338095=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Thu Jul 26 20:42:58 2018
@@ -288,10 +288,6 @@ if (LIBCXX_ENABLE_STATIC)
   endif()
 endif()
 
-# Add a meta-target for both libraries.
-add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
-
-
 if (LIBCXX_ENABLE_FILESYSTEM)
   set(LIBCXX_FILESYSTEM_SOURCES
   ../src/filesystem/operations.cpp
@@ -322,6 +318,7 @@ if (LIBCXX_ENABLE_FILESYSTEM)
   COMPILE_FLAGS "${filesystem_flags}"
   OUTPUT_NAME   "c++fs"
   )
+  list(APPEND LIBCXX_BUILD_TARGETS cxx_filesystem)
 endif()
 
 
@@ -344,9 +341,14 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   COMPILE_FLAGS "${experimental_flags}"
   OUTPUT_NAME   "c++experimental"
   )
+  list(APPEND LIBCXX_BUILD_TARGETS cxx_experimental)
 endif()
 
 
+# Add a meta-target for both libraries.
+add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
+
+
 if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES 
../test/support/external_threads.cpp)
 

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=338095=338094=338095=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Thu Jul 26 20:42:58 2018
@@ -105,7 +105,7 @@ if (LIBCXX_CONFIGURE_IDE)
   ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
   add_dependencies(libcxx_test_objects cxx)
 
-  set(STATIC_ROOT 
${LIBCXX_SOURCE_DIR}/test/std/experimental/filesystem/Inputs/static_test_env)
+  set(STATIC_ROOT 
${LIBCXX_SOURCE_DIR}/test/std/input.output/filesystems/Inputs/static_test_env)
   add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}")
 
   set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env)


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


[libcxx] r338094 - Correctly mark the Filesystem status as complete.

2018-07-26 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 26 20:16:02 2018
New Revision: 338094

URL: http://llvm.org/viewvc/llvm-project?rev=338094=rev
Log:
Correctly mark the Filesystem status as complete.

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=338094=338093=338094=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Jul 26 20:16:02 2018
@@ -83,8 +83,8 @@

https://wg21.link/P0024R2;>P0024R2LWGThe 
Parallelism TS Should be 
StandardizedJacksonville
https://wg21.link/P0226R1;>P0226R1LWGMathematical 
Special Functions for C++17Jacksonville
-   https://wg21.link/P0220R1;>P0220R1LWGAdopt Library 
Fundamentals V1 TS Components for 
C++17JacksonvilleComplete7.0
-   https://wg21.link/P0218R1;>P0218R1LWGAdopt the File 
System TS for C++17JacksonvilleIn Progress
+   https://wg21.link/P0220R1;>P0220R1LWGAdopt Library 
Fundamentals V1 TS Components for C++17JacksonvilleIn 
Progress
+   https://wg21.link/P0218R1;>P0218R1LWGAdopt the File 
System TS for C++17JacksonvilleComplete7.0
https://wg21.link/P0033R1;>P0033R1LWGRe-enabling 
shared_from_thisJacksonvilleComplete3.9
https://wg21.link/P0005R4;>P0005R4LWGAdopt not_fn 
from Library Fundamentals 2 for 
C++17JacksonvilleComplete3.9
https://wg21.link/P0152R1;>P0152R1LWGconstexpr 
atomic::is_always_lock_freeJacksonvilleComplete3.9


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


[libcxx] r338093 - Implement

2018-07-26 Thread Eric Fiselier via cfe-commits
Copied: 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp
 (from r338006, 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.factory.pass.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp?p2=libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp=libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.factory.pass.cpp=338006=338093=338093=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.factory.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp
 Thu Jul 26 20:07:09 2018
@@ -9,7 +9,7 @@
 
 // UNSUPPORTED: c++98, c++03
 
-// 
+// 
 
 // template 
 //path u8path(Source const&);

Copied: 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp
 (from r338006, 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp?p2=libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp=libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp=338006=338093=338093=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.pass.cpp
 Thu Jul 26 20:07:09 2018
@@ -9,7 +9,7 @@
 
 // UNSUPPORTED: c++98, c++03
 
-// 
+// 
 
 // class path
 

Copied: 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.unicode_bug.pass.cpp
 (from r338006, 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.io.unicode_bug.pass.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.unicode_bug.pass.cpp?p2=libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.unicode_bug.pass.cpp=libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.io.unicode_bug.pass.cpp=338006=338093=338093=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/path.io.unicode_bug.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/path.io.unicode_bug.pass.cpp
 Thu Jul 26 20:07:09 2018
@@ -9,7 +9,7 @@
 
 // UNSUPPORTED: c++98, c++03
 
-// 
+// 
 
 // class path
 

Copied: 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp
 (from r338006, 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/swap.pass.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp?p2=libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp=libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/swap.pass.cpp=338006=338093=338093=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.nonmember/swap.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/filesystems/class.path/path.nonmember/swap.pass.cpp
 Thu Jul 26 20:07:09 2018
@@ -9,7 +9,7 @@
 
 // UNSUPPORTED: c++98, c++03
 
-// 
+// 
 
 // void swap(path& lhs, path& rhs) noexcept;
 

Copied: 
libcxx/trunk/test/std/input.output/filesystems/class.path/synop.pass.cpp (from 
r338006, 
libcxx/trunk/test/std/experimental/filesystem/class.path/synop.pass.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/filesystems/class.path/synop.pass.cpp?p2=libcxx/trunk/test/std/input.output/filesystems/class.path/synop.pass.cpp=libcxx/trunk/test/std/experimental/filesystem/class.path/synop.pass.cpp=338006=338093=338093=diff
==
--- libcxx/trunk/test/std/experimental/filesystem/class.path/synop.pass.cpp 
(original)
+++ libcxx/trunk/test/std/input.output/filesystems/class.path/synop.pass.cpp 
Thu Jul 26 20:07:09 2018
@@ -9,7 +9,7 @@
 
 // UNSUPPORTED: c++98, c++03
 
-// 
+// 
 
 // class path
 

Copied: 
libcxx/trunk/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp
 (from r338006, 
libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp)
URL: 

[libcxx] r338005 - Copy LLVM CMake configuration for CMake Policy CMP0068

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 22:08:30 2018
New Revision: 338005

URL: http://llvm.org/viewvc/llvm-project?rev=338005=rev
Log:
Copy LLVM CMake configuration for CMake Policy CMP0068

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=338005=338004=338005=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Wed Jul 25 22:08:30 2018
@@ -11,6 +11,10 @@ endif()
 if(POLICY CMP0022)
   cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
 endif()
+if(POLICY CMP0068)
+  cmake_policy(SET CMP0068 NEW)
+  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+endif()
 
 # Add path for custom modules
 set(CMAKE_MODULE_PATH


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


[libcxx] r338002 - Be more consistent about which bool value means an error occurred

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 21:02:06 2018
New Revision: 338002

URL: http://llvm.org/viewvc/llvm-project?rev=338002=rev
Log:
Be more consistent about which bool value means an error occurred

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=338002=338001=338002=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Wed Jul 25 21:02:06 
2018
@@ -433,19 +433,19 @@ bool posix_ftruncate(const FileDescripto
  error_code& ec) {
   if (::ftruncate(fd.fd, to_size) == -1) {
 ec = capture_errno();
-return false;
+return true;
   }
   ec.clear();
-  return true;
+  return false;
 }
 
 bool posix_fchmod(const FileDescriptor& fd, const StatT& st, error_code& ec) {
   if (::fchmod(fd.fd, st.st_mode) == -1) {
 ec = capture_errno();
-return false;
+return true;
   }
   ec.clear();
-  return true;
+  return false;
 }
 
 bool stat_equivalent(const StatT& st1, const StatT& st2) {
@@ -796,9 +796,9 @@ bool __copy_file(const path& from, const
   return err.report(errc::bad_file_descriptor);
 
 // Set the permissions and truncate the file we opened.
-if (!detail::posix_fchmod(to_fd, from_stat, m_ec))
+if (detail::posix_fchmod(to_fd, from_stat, m_ec))
   return err.report(m_ec);
-if (!detail::posix_ftruncate(to_fd, 0, m_ec))
+if (detail::posix_ftruncate(to_fd, 0, m_ec))
   return err.report(m_ec);
   }
 


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


[libcxx] r338001 - Cleanup the last_write_time internals

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 20:57:26 2018
New Revision: 338001

URL: http://llvm.org/viewvc/llvm-project?rev=338001=rev
Log:
Cleanup the last_write_time internals

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=338001=338000=338001=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 
20:57:26 2018
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include  // for ::utimes as used in __last_write_time
 #include  /* values for fchmodat */
 
 #include 
@@ -33,14 +34,6 @@
 #endif
 #endif
 
-#if !defined(_LIBCPP_USE_UTIMENSAT)
-#include  // for ::utimes as used in __last_write_time
-#endif
-
-#if !defined(UTIME_OMIT)
-#include  // for ::utimes as used in __last_write_time
-#endif
-
 #if defined(__GNUC__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-function"
@@ -389,9 +382,11 @@ TimeSpec extract_mtime(StatT const& st)
 TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
 #endif
 
-bool set_file_times(const path& p, std::array const& TS,
+// allow the utimes implementation to compile even it we're not going
+// to use it.
+
+bool posix_utimes(const path& p, std::array const& TS,
 error_code& ec) {
-#if !defined(_LIBCPP_USE_UTIMENSAT)
   using namespace chrono;
   auto Convert = [](long nsec) {
 using int_type = decltype(std::declval<::timeval>().tv_usec);
@@ -400,22 +395,35 @@ bool set_file_times(const path& p, std::
   };
   struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},
  {TS[1].tv_sec, Convert(TS[1].tv_nsec)}};
-  if (::utimes(p.c_str(), ConvertedTS) == -1)
-#else
+  if (::utimes(p.c_str(), ConvertedTS) == -1) {
+ec = capture_errno();
+return true;
+  }
+  return false;
+}
+
+#if defined(_LIBCPP_USE_UTIMENSAT)
+bool posix_utimensat(const path& p, std::array const& TS,
+error_code& ec) {
   if (::utimensat(AT_FDCWD, p.c_str(), TS.data(), 0) == -1)
-#endif
   {
 ec = capture_errno();
 return true;
   }
   return false;
 }
+#endif
 
-bool set_time_spec_to(TimeSpec& TS, file_time_type NewTime) {
-  return !fs_time::set_times_checked(
-  _sec, _nsec, NewTime);
+bool set_file_times(const path& p, std::array const& TS,
+error_code& ec) {
+#if !defined(_LIBCPP_USE_UTIMENSAT)
+  return posix_utimes(p, TS, ec);
+#else
+  return posix_utimensat(p, TS, ec);
+#endif
 }
 
+
 } // namespace
 } // end namespace detail
 

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=338001=338000=338001=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Wed Jul 25 20:57:26 
2018
@@ -1017,6 +1017,7 @@ file_time_type __last_write_time(const p
 void __last_write_time(const path& p, file_time_type new_time,
error_code *ec)
 {
+using detail::fs_time;
 ErrorHandler err("last_write_time", ec, );
 
 error_code m_ec;
@@ -1034,7 +1035,7 @@ void __last_write_time(const path& p, fi
 tbuf[0].tv_sec = 0;
 tbuf[0].tv_nsec = UTIME_OMIT;
 #endif
-if (detail::set_time_spec_to(tbuf[1], new_time))
+if (!fs_time::convert_to_timespec(tbuf[1], new_time))
   return err.report(errc::value_too_large);
 
 detail::set_file_times(p, tbuf, m_ec);


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


[libcxx] r338000 - Correct comment about stat truncating st_mtimespec to seconds

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 20:42:25 2018
New Revision: 338000

URL: http://llvm.org/viewvc/llvm-project?rev=338000=rev
Log:
Correct comment about stat truncating st_mtimespec to seconds

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=338000=337999=338000=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Wed Jul 25 20:42:25 2018
@@ -208,15 +208,11 @@ static const bool SupportsMinTime = [] {
 
 static const bool SupportsNanosecondRoundTrip = [] {
   NanoSec ns(3);
-
-  // Test if the file_time_type period is less than that of nanoseconds.
-  auto ft_dur = duration_cast(ns);
-  if (duration_cast(ft_dur) != ns)
-return false;
+  static_assert(std::is_same::value, "");
 
   // Test that the system call we use to set the times also supports nanosecond
   // resolution. (utimes does not)
-  file_time_type ft(ft_dur);
+  file_time_type ft(ns);
   {
 scoped_test_env env;
 const path p = env.create_file("file", 42);
@@ -225,13 +221,14 @@ static const bool SupportsNanosecondRoun
   }
 }();
 
-
+// The HFS+ filesystem (used by default before macOS 10.13) stores timestamps 
at
+// a 1-second granularity, and APFS (now the default) at a 1 nanosecond 
granularity.
+// 1-second granularity is also the norm on many of the supported filesystems
+// on Linux as well.
 static const bool WorkaroundStatTruncatesToSeconds = [] {
   MicroSec micros(3);
   static_assert(std::is_same::value, "");
 
-  // Test for the behavior of OS X 10.11 and older, which truncates the result
-  // of st_mtimespec to seconds.
   file_time_type ft(micros);
   {
 scoped_test_env env;
@@ -594,14 +591,4 @@ TEST_CASE(test_exists_fails)
 TEST_CHECK_THROW_RESULT(filesystem_error, Checker, last_write_time(file));
 }
 
-// Just for sanity ensure that WorkaroundStatTruncatesToSeconds is only
-// ever true on Apple platforms.
-TEST_CASE(apple_truncates_to_seconds_check) {
-#ifndef __APPLE__
-  TEST_CHECK(!WorkaroundStatTruncatesToSeconds);
-#else
-  TEST_CHECK(SupportsNanosecondRoundTrip != WorkaroundStatTruncatesToSeconds);
-#endif
-}
-
 TEST_SUITE_END()


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


[libcxx] r337999 - Fix attribute placement WRT extern C

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 20:36:37 2018
New Revision: 337999

URL: http://llvm.org/viewvc/llvm-project?rev=337999=rev
Log:
Fix attribute placement WRT extern C

Modified:
libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp

Modified: libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp?rev=337999=337998=337999=diff
==
--- libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp Wed Jul 25 
20:36:37 2018
@@ -19,8 +19,8 @@
 
 #ifndef _LIBCPP_HAS_NO_INT128
 
-__attribute__((no_sanitize("undefined"))) extern "C" __int128_t
-__muloti4(__int128_t a, __int128_t b, int* overflow) {
+extern "C" __attribute__((no_sanitize("undefined")))
+__int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) {
   const int N = (int)(sizeof(__int128_t) * CHAR_BIT);
   const __int128_t MIN = (__int128_t)1 << (N - 1);
   const __int128_t MAX = ~MIN;


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


Re: [libcxx] r337960 - [libc++] Use __int128_t to represent file_time_type.

2018-07-25 Thread Eric Fiselier via cfe-commits
Thank you for the clarification.

On Wed, Jul 25, 2018 at 9:16 PM James Y Knight  wrote:

> As is the case on most modern platforms, the ability to store a high-res
> file timestamp is dependent on the filesystem the file is stored on.
>
> The HFS+ filesystem (used by default before macOS 10.13) stores timestamps
> at a 1-second granularity, and APFS (now the default) at a 1 nanosecond
> granularity.
>
> 1-second granularity is also the norm on many of the supported filesystems
> on Linux as well.
>
> On Wed, Jul 25, 2018 at 10:43 PM Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Looks like macOS 10.11 only supports a resolution of seconds, but I can't
>> find documentation confirming that.
>>
>> I'll adjust the test.
>>
>> /Eric
>>
>> On Wed, Jul 25, 2018 at 8:33 PM Alex L  wrote:
>>
>>> Looks like 'SupportsNanosecondRoundTrip' is set to 0.
>>>
>>> On 25 July 2018 at 19:30, Alex L  wrote:
>>>
>>>> Sure,
>>>>
>>>> Standard Error:
>>>>
>>>> --
>>>>
>>>> PRIOR:3
>>>>
>>>> AFTER:0
>>>>
>>>>
>>>> Diff:
>>>>
>>>>
>>>> -return last_write_time(p) == ft;
>>>>
>>>> +std::cerr << "PRIOR:" << (long long)ft.time_since_epoch().count()
>>>> << std::endl;
>>>>
>>>> +auto ft2 = last_write_time(p);
>>>>
>>>> +std::cerr << "AFTER:" << (long long)ft2.time_since_epoch().count()
>>>> << std::endl;
>>>>
>>>> +return ft2  == ft;
>>>>
>>>> On 25 July 2018 at 19:20, Eric Fiselier  wrote:
>>>>
>>>>> Could you tell me what the value of the initial time point, and the
>>>>> resulting one are on this line?
>>>>>
>>>>>
>>>>> https://github.com/llvm-mirror/libcxx/blob/master/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp#L224
>>>>>
>>>>> On Wed, Jul 25, 2018 at 8:17 PM Alex L  wrote:
>>>>>
>>>>>> Please let me know if this information is helpful. If not, I'll mark
>>>>>> the test as UNSUPPORTED for darwin for the time being and will create an
>>>>>> internal issue to track the investigation into the OS-specific failure.
>>>>>> Cheers,
>>>>>> Alex
>>>>>>
>>>>>> On 25 July 2018 at 19:12, Alex L  wrote:
>>>>>>
>>>>>>> I got the following output on an macOS10.11 machine:
>>>>>>>
>>>>>>> Exit Code: 1
>>>>>>>
>>>>>>> Standard Error:
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Test Case = file, epoch_time
>>>>>>>
>>>>>>> 0
>>>>>>>
>>>>>>> 0
>>>>>>>
>>>>>>> Test Case = dir, epoch_time
>>>>>>>
>>>>>>> 0
>>>>>>>
>>>>>>> 0
>>>>>>>
>>>>>>> Test Case = file, future_time
>>>>>>>
>>>>>>> In set_last_write_time_dynamic_env_test():455 Assertion
>>>>>>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed.
>>>>>>>
>>>>>>> in file:
>>>>>>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 15325819240
>>>>>>>
>>>>>>> 1532581924695307000
>>>>>>>
>>>>>>> Test Case = dir, future_time
>>>>>>>
>>>>>>> In set_last_write_time_dynamic_env_test():455 Assertion
>>>>>>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed.
>>>>>>>
>>>>>>> in file:
>>>>>>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 15325819240
>>&

[libcxx] r337998 - Workaround OS X 10.11 behavior where stat truncates st_mtimespec to seconds.

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 20:28:48 2018
New Revision: 337998

URL: http://llvm.org/viewvc/llvm-project?rev=337998=rev
Log:
Workaround OS X 10.11 behavior where stat truncates st_mtimespec to seconds.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=337998=337997=337998=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Wed Jul 25 20:28:48 2018
@@ -225,6 +225,24 @@ static const bool SupportsNanosecondRoun
   }
 }();
 
+
+static const bool WorkaroundStatTruncatesToSeconds = [] {
+  MicroSec micros(3);
+  static_assert(std::is_same::value, "");
+
+  // Test for the behavior of OS X 10.11 and older, which truncates the result
+  // of st_mtimespec to seconds.
+  file_time_type ft(micros);
+  {
+scoped_test_env env;
+const path p = env.create_file("file", 42);
+if (LastWriteTime(p).tv_nsec != 0)
+  return false;
+last_write_time(p, ft);
+return last_write_time(p) != ft && LastWriteTime(p).tv_nsec == 0;
+  }
+}();
+
 static const bool SupportsMinRoundTrip = [] {
   TimeSpec ts = {};
   if (!ConvertToTimeSpec(ts, file_time_type::min()))
@@ -244,7 +262,8 @@ static bool CompareTime(TimeSpec t1, Tim
 return false;
 
   auto diff = std::abs(t1.tv_nsec - t2.tv_nsec);
-
+  if (WorkaroundStatTruncatesToSeconds)
+   return diff < duration_cast(Sec(1)).count();
   return diff < duration_cast(MicroSec(1)).count();
 }
 
@@ -275,8 +294,9 @@ static bool CompareTime(file_time_type t
 dur = t1 - t2;
   else
 dur = t2 - t1;
-
-  return duration_cast(dur).count() < 1;
+  if (WorkaroundStatTruncatesToSeconds)
+return duration_cast(dur).count() == 0;
+  return duration_cast(dur).count() == 0;
 }
 
 // Check if a time point is representable on a given filesystem. Check that:
@@ -399,7 +419,6 @@ TEST_CASE(get_last_write_time_dynamic_en
 TEST_CASE(set_last_write_time_dynamic_env_test)
 {
 using Clock = file_time_type::clock;
-using SubSecT = file_time_type::duration;
 scoped_test_env env;
 
 const path file = env.create_file("file", 42);
@@ -453,12 +472,6 @@ TEST_CASE(set_last_write_time_dynamic_en
 if (TimeIsRepresentableByFilesystem(TC.new_time)) {
 TEST_CHECK(got_time != old_time);
 TEST_CHECK(CompareTime(got_time, TC.new_time));
-
-// FIXME(EricWF): Remove these after getting information from
-// some failing bots.
-std::cerr << (long long)got_time.time_since_epoch().count() << 
std::endl;
-std::cerr << (long long)TC.new_time.time_since_epoch().count() << 
std::endl;
-
 TEST_CHECK(CompareTime(LastAccessTime(TC.p), old_times.access));
 }
 }
@@ -484,7 +497,11 @@ TEST_CASE(last_write_time_symlink_test)
 
 file_time_type  got_time = last_write_time(sym);
 TEST_CHECK(!CompareTime(got_time, old_times.write));
-TEST_CHECK(got_time == new_time);
+if (!WorkaroundStatTruncatesToSeconds) {
+  TEST_CHECK(got_time == new_time);
+} else {
+  TEST_CHECK(CompareTime(got_time, new_time));
+}
 
 TEST_CHECK(CompareTime(LastWriteTime(file), new_time));
 TEST_CHECK(CompareTime(LastAccessTime(sym), old_times.access));
@@ -577,4 +594,14 @@ TEST_CASE(test_exists_fails)
 TEST_CHECK_THROW_RESULT(filesystem_error, Checker, last_write_time(file));
 }
 
+// Just for sanity ensure that WorkaroundStatTruncatesToSeconds is only
+// ever true on Apple platforms.
+TEST_CASE(apple_truncates_to_seconds_check) {
+#ifndef __APPLE__
+  TEST_CHECK(!WorkaroundStatTruncatesToSeconds);
+#else
+  TEST_CHECK(SupportsNanosecondRoundTrip != WorkaroundStatTruncatesToSeconds);
+#endif
+}
+
 TEST_SUITE_END()


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


[libcxx] r337991 - Add print statements to help debugging

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 18:10:50 2018
New Revision: 337991

URL: http://llvm.org/viewvc/llvm-project?rev=337991=rev
Log:
Add print statements to help debugging

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=337991=337990=337991=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Wed Jul 25 18:10:50 2018
@@ -421,21 +421,23 @@ TEST_CASE(set_last_write_time_dynamic_en
 #endif
 
 struct TestCase {
+  const char * case_name;
   path p;
   file_time_type new_time;
 } cases[] = {
-{file, epoch_time},
-{dir, epoch_time},
-{file, future_time},
-{dir, future_time},
-{file, past_time},
-{dir, past_time},
-{file, before_epoch_time},
-{dir, before_epoch_time},
-{file, just_before_epoch_time},
-{dir, just_before_epoch_time}
+{"file, epoch_time", file, epoch_time},
+{"dir, epoch_time", dir, epoch_time},
+{"file, future_time", file, future_time},
+{"dir, future_time", dir, future_time},
+{"file, past_time", file, past_time},
+{"dir, past_time", dir, past_time},
+{"file, before_epoch_time", file, before_epoch_time},
+{"dir, before_epoch_time", dir, before_epoch_time},
+{"file, just_before_epoch_time", file, just_before_epoch_time},
+{"dir, just_before_epoch_time", dir, just_before_epoch_time}
 };
 for (const auto& TC : cases) {
+std::cerr << "Test Case = " << TC.case_name << "\n";
 const auto old_times = GetTimes(TC.p);
 file_time_type old_time;
 TEST_REQUIRE(ConvertFromTimeSpec(old_time, old_times.write));
@@ -444,11 +446,19 @@ TEST_CASE(set_last_write_time_dynamic_en
 last_write_time(TC.p, TC.new_time, ec);
 TEST_CHECK(!ec);
 
-file_time_type  got_time = last_write_time(TC.p);
+ec = GetTestEC();
+file_time_type  got_time = last_write_time(TC.p, ec);
+TEST_REQUIRE(!ec);
 
 if (TimeIsRepresentableByFilesystem(TC.new_time)) {
 TEST_CHECK(got_time != old_time);
 TEST_CHECK(CompareTime(got_time, TC.new_time));
+
+// FIXME(EricWF): Remove these after getting information from
+// some failing bots.
+std::cerr << (long long)got_time.time_since_epoch().count() << 
std::endl;
+std::cerr << (long long)TC.new_time.time_since_epoch().count() << 
std::endl;
+
 TEST_CHECK(CompareTime(LastAccessTime(TC.p), old_times.access));
 }
 }


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


[libcxx] r337990 - [libc++] Add hack to allow ubsan to work w/o compiler-rt (__muloti4 is undefined)

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 17:34:50 2018
New Revision: 337990

URL: http://llvm.org/viewvc/llvm-project?rev=337990=rev
Log:
[libc++] Add hack to allow ubsan to work w/o compiler-rt (__muloti4 is 
undefined)

Summary:
Using int128_t with UBSAN causes link errors unless compiler-rt is providing 
the runtime library.
Specifically ubsan generates calls to __muloti4 but libgcc doesn't provide a 
definition.

In order to avoid this, and allow users to continue using sanitized versions of 
libc++, this patch introduces a hack.
It adds a cribbed version of  the compiler-rt builtin to the libc++ filesystem 
sources.

I don't think this approach will work in the long run, but it seems OK for now.

Also see:

https://bugs.llvm.org/show_bug.cgi?id=30643
https://bugs.llvm.org/show_bug.cgi?id=16404


Reviewers: mclow.lists, ldionne, rsmith, jyknight, echristo

Reviewed By: echristo

Subscribers: dberris, cfe-commits

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

Added:
libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp

Added: libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp?rev=337990=auto
==
--- libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp (added)
+++ libcxx/trunk/src/experimental/filesystem/int128_builtins.cpp Wed Jul 25 
17:34:50 2018
@@ -0,0 +1,55 @@
+/*===-- int128_builtins.cpp - Implement __muloti4 --===
+ *
+ * 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.
+ *
+ * ===--===
+ *
+ * This file implements __muloti4, and is stolen from the compiler_rt library.
+ *
+ * FIXME: we steal and re-compile it into filesystem, which uses __int128_t,
+ * and requires this builtin when sanitized. See llvm.org/PR30643
+ *
+ * ===--===
+ */
+#include "__config"
+#include "climits"
+
+#ifndef _LIBCPP_HAS_NO_INT128
+
+__attribute__((no_sanitize("undefined"))) extern "C" __int128_t
+__muloti4(__int128_t a, __int128_t b, int* overflow) {
+  const int N = (int)(sizeof(__int128_t) * CHAR_BIT);
+  const __int128_t MIN = (__int128_t)1 << (N - 1);
+  const __int128_t MAX = ~MIN;
+  *overflow = 0;
+  __int128_t result = a * b;
+  if (a == MIN) {
+if (b != 0 && b != 1)
+  *overflow = 1;
+return result;
+  }
+  if (b == MIN) {
+if (a != 0 && a != 1)
+  *overflow = 1;
+return result;
+  }
+  __int128_t sa = a >> (N - 1);
+  __int128_t abs_a = (a ^ sa) - sa;
+  __int128_t sb = b >> (N - 1);
+  __int128_t abs_b = (b ^ sb) - sb;
+  if (abs_a < 2 || abs_b < 2)
+return result;
+  if (sa == sb) {
+if (abs_a > MAX / abs_b)
+  *overflow = 1;
+  } else {
+if (abs_a > MIN / -abs_b)
+  *overflow = 1;
+  }
+  return result;
+}
+
+#endif


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


[libcxx] r337976 - Work around GCC bug in constexpr function

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 15:21:47 2018
New Revision: 337976

URL: http://llvm.org/viewvc/llvm-project?rev=337976=rev
Log:
Work around GCC bug in constexpr function

Modified:
libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp

Modified: 
libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp?rev=337976=337975=337976=diff
==
--- libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp 
(original)
+++ libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp 
Wed Jul 25 15:21:47 2018
@@ -56,11 +56,12 @@ constexpr TestKind getFileTimeTestKind()
   using Rep = typename FileTimeT::rep;
   if (std::is_floating_point::value)
 return TK_FloatingPoint;
-  if (sizeof(Rep) == 16)
+  else if (sizeof(Rep) == 16)
 return TK_128Bit;
-  if (sizeof(Rep) == 8)
+  else if (sizeof(Rep) == 8)
 return TK_64Bit;
-  assert(false && "test kind not supported");
+  else
+assert(false && "test kind not supported");
 }
 
 template http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r337974 - Fix GCC build in C++14 w/o c++14 constexpr

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 15:07:36 2018
New Revision: 337974

URL: http://llvm.org/viewvc/llvm-project?rev=337974=rev
Log:
Fix GCC build in C++14 w/o c++14 constexpr

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337974=337973=337974=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 
15:07:36 2018
@@ -229,7 +229,7 @@ struct time_util_base {
   .count();
 
 private:
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
   static constexpr fs_duration get_min_nsecs() {
 return duration_cast(
 fs_nanoseconds(min_nsec_timespec) -


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


[libcxx] r337971 - Remove test which shouldn't have been committed

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 14:58:37 2018
New Revision: 337971

URL: http://llvm.org/viewvc/llvm-project?rev=337971=rev
Log:
Remove test which shouldn't have been committed

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=337971=337970=337971=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Wed Jul 25 14:58:37 2018
@@ -567,23 +567,4 @@ TEST_CASE(test_exists_fails)
 TEST_CHECK_THROW_RESULT(filesystem_error, Checker, last_write_time(file));
 }
 
-TEST_CASE(my_test) {
-  scoped_test_env env;
-  const path p = env.create_file("file", 42);
-  using namespace std::chrono;
-  using TimeSpec = struct ::timespec;
-  TimeSpec ts[2];
-  ts[0].tv_sec = 0;
-  ts[0].tv_nsec = UTIME_OMIT;
-  ts[1].tv_sec = -1;
-  ts[1].tv_nsec =
-  duration_cast(seconds(1) - nanoseconds(13)).count();
-  if (::utimensat(AT_FDCWD, p.c_str(), ts, 0) == -1) {
-TEST_CHECK(false);
-  }
-  TimeSpec new_ts = LastWriteTime(p);
-  TEST_CHECK(ts[1].tv_sec == new_ts.tv_sec);
-  TEST_CHECK(ts[1].tv_nsec == new_ts.tv_nsec);
-}
-
 TEST_SUITE_END()


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


[libcxx] r337970 - Fix failing test under C++14

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 14:53:43 2018
New Revision: 337970

URL: http://llvm.org/viewvc/llvm-project?rev=337970=rev
Log:
Fix failing test under C++14

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337970=337969=337970=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 
14:53:43 2018
@@ -362,8 +362,8 @@ public:
 // The tv_nsec and tv_usec fields must not be negative so adjust 
accordingly
 if (subsec_dur.count() < 0) {
   if (sec_dur.count() > min_seconds) {
-sec_dur -= fs_seconds(1);
-subsec_dur += fs_seconds(1);
+sec_dur = sec_dur - fs_seconds(1);
+subsec_dur = subsec_dur + fs_seconds(1);
   } else {
 subsec_dur = fs_nanoseconds::zero();
   }


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


[libcxx] r337962 - Make compile with gcc 4.8.5

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 14:01:45 2018
New Revision: 337962

URL: http://llvm.org/viewvc/llvm-project?rev=337962=rev
Log:
Make  compile with gcc 4.8.5

Patch by Victor Zverovich.

This fixes an error when compiling `` with gcc 4.8.5:

```
.../libcxx/src/experimental/filesystem/filesystem_common.h:137:34:
error: redeclaration ‘T
std::experimental::filesystem::v1::detail::{anonymous}::error_value() [with T =
bool]’ d
iffers in ‘constexpr’
 constexpr bool error_value() {
  ^
.../libcxx/src/experimental/filesystem/filesystem_common.h:133:3:
error: from previous declaration ‘T
std::experimental::filesystem::v1::detail::{anonymous}::error_value() [with T
 = bool]’
 T error_value();
   ^
```

Reviewed as https://reviews.llvm.org/D49813

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337962=337961=337962=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 
14:01:45 2018
@@ -118,11 +118,11 @@ T error_value();
 template <>
 _LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value() {}
 template <>
-constexpr bool error_value() {
+bool error_value() {
   return false;
 }
 template <>
-constexpr uintmax_t error_value() {
+uintmax_t error_value() {
   return uintmax_t(-1);
 }
 template <>


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


[libcxx] r337960 - [libc++] Use __int128_t to represent file_time_type.

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 13:51:49 2018
New Revision: 337960

URL: http://llvm.org/viewvc/llvm-project?rev=337960=rev
Log:
[libc++] Use __int128_t to represent file_time_type.

Summary:
The ``file_time_type`` time point is used to represent the write times for 
files.
Its job is to act as part of a C++ wrapper for less ideal system interfaces. The
underlying filesystem uses the ``timespec`` struct for the same purpose.

However, the initial implementation of ``file_time_type`` could not represent
either the range or resolution of ``timespec``, making it unsuitable. Fixing
this requires an implementation which uses more than 64 bits to store the
time point.

I primarily considered two solutions: Using ``__int128_t`` and using a
arithmetic emulation of ``timespec``. Each has its pros and cons, and both
come with more than one complication.

However, after a lot of consideration, I decided on using `__int128_t`. This 
patch implements that change.

Please see the [FileTimeType Design 
Document](http://libcxx.llvm.org/docs/DesignDocs/FileTimeType.html) for more 
information.

Reviewers: mclow.lists, ldionne, joerg, arthur.j.odwyer, EricWF

Reviewed By: EricWF

Subscribers: christof, K-ballo, cfe-commits, BillyONeal

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

Added:
libcxx/trunk/src/include/apple_availability.h
Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/chrono.cpp
libcxx/trunk/src/experimental/filesystem/filesystem_common.h
libcxx/trunk/src/experimental/filesystem/operations.cpp

libcxx/trunk/test/libcxx/experimental/filesystem/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp
libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337960=337959=337960=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Wed Jul 25 13:51:49 2018
@@ -260,7 +260,37 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
-typedef chrono::time_point  file_time_type;
+struct _FilesystemClock {
+#if !defined(_LIBCPP_HAS_NO_INT128)
+  typedef __int128_t rep;
+  typedef nano period;
+#else
+  typedef long long rep;
+  typedef nano period;
+#endif
+
+  typedef chrono::duration duration;
+  typedef chrono::time_point<_FilesystemClock> time_point;
+
+  static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
+
+  _LIBCPP_FUNC_VIS static time_point now() noexcept;
+
+  _LIBCPP_INLINE_VISIBILITY
+  static time_t to_time_t(const time_point& __t) noexcept {
+typedef chrono::duration __secs;
+return time_t(
+chrono::duration_cast<__secs>(__t.time_since_epoch()).count());
+  }
+
+  _LIBCPP_INLINE_VISIBILITY
+  static time_point from_time_t(time_t __t) noexcept {
+typedef chrono::duration __secs;
+return time_point(__secs(__t));
+  }
+};
+
+typedef chrono::time_point<_FilesystemClock> file_time_type;
 
 struct _LIBCPP_TYPE_VIS space_info
 {

Modified: libcxx/trunk/src/chrono.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=337960=337959=337960=diff
==
--- libcxx/trunk/src/chrono.cpp (original)
+++ libcxx/trunk/src/chrono.cpp Wed Jul 25 13:51:49 2018
@@ -11,27 +11,10 @@
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+#include "include/apple_availability.h"
 
-#if (__APPLE__)
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
-#else
-#define _LIBCXX_USE_CLOCK_GETTIME
+#if !defined(__APPLE__)
+#define _LIBCPP_USE_CLOCK_GETTIME
 #endif // __APPLE__
 
 #if defined(_LIBCPP_WIN32API)
@@ -42,7 +25,7 @@
 #include 
 #endif
 #else
-#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME)
+#if !defined(CLOCK_REALTIME) || 

Re: r337790 - Warn if a local variable's initializer retains a pointer/reference to a

2018-07-25 Thread Eric Fiselier via cfe-commits
Nice!

This found one bug in the libc++abi tests (r337906), and started diagnosing
the
dangling tuple reference case that libc++ worked hard to diagnose manually
(r337905).

/Eric

On Mon, Jul 23, 2018 at 6:55 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Jul 23 17:55:08 2018
> New Revision: 337790
>
> URL: http://llvm.org/viewvc/llvm-project?rev=337790=rev
> Log:
> Warn if a local variable's initializer retains a pointer/reference to a
> non-lifetime-extended temporary object.
>
> Added:
> cfe/trunk/test/SemaCXX/warn-dangling-local.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/test/CXX/drs/dr16xx.cpp
> cfe/trunk/test/SemaCXX/address-of-temporary.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=337790=337789=337790=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Jul 23 17:55:08
> 2018
> @@ -273,6 +273,10 @@ def OverloadedShiftOpParentheses: DiagGr
>  def DanglingElse: DiagGroup<"dangling-else">;
>  def DanglingField : DiagGroup<"dangling-field">;
>  def DanglingInitializerList : DiagGroup<"dangling-initializer-list">;
> +def ReturnStackAddress : DiagGroup<"return-stack-address">;
> +def Dangling : DiagGroup<"dangling", [DanglingField,
> +  DanglingInitializerList,
> +  ReturnStackAddress]>;
>  def DistributedObjectModifiers :
> DiagGroup<"distributed-object-modifiers">;
>  def ExpansionToDefined : DiagGroup<"expansion-to-defined">;
>  def FlagEnum : DiagGroup<"flag-enum">;
> @@ -407,7 +411,6 @@ def RedeclaredClassMember : DiagGroup<"r
>  def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">;
>  def RedundantMove : DiagGroup<"redundant-move">;
>  def Register : DiagGroup<"register", [DeprecatedRegister]>;
> -def ReturnStackAddress : DiagGroup<"return-stack-address">;
>  def ReturnTypeCLinkage : DiagGroup<"return-type-c-linkage">;
>  def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>;
>  def BindToTemporaryCopy : DiagGroup<"bind-to-temporary-copy",
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=337790=337789=337790=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 23
> 17:55:08 2018
> @@ -1845,10 +1845,6 @@ def err_reference_bind_failed : Error<
>"type $|could not bind to %select{rvalue|lvalue}1 of incompatible
> type}0,2">;
>  def err_reference_bind_init_list : Error<
>"reference to type %0 cannot bind to an initializer list">;
> -def warn_temporary_array_to_pointer_decay : Warning<
> -  "pointer is initialized by a temporary array, which will be destroyed
> at the "
> -  "end of the full-expression">,
> -  InGroup>;
>  def err_init_list_bad_dest_type : Error<
>"%select{|non-aggregate }0type %1 cannot be initialized with an
> initializer "
>"list">;
> @@ -7876,15 +7872,31 @@ def warn_init_ptr_member_to_parameter_ad
>  def note_ref_or_ptr_member_declared_here : Note<
>"%select{reference|pointer}0 member declared here">;
>
> -def err_bind_ref_member_to_temporary : Error<
> +def err_dangling_member : Error<
>"%select{reference|backing array for 'std::initializer_list'}2 "
>"%select{|subobject of }1member %0 "
>"%select{binds to|is}2 a temporary object "
> -  "whose lifetime would be shorter than the constructed object">;
> +  "whose lifetime would be shorter than the lifetime of "
> +  "the constructed object">;
> +def warn_dangling_member : Warning<
> +  "%select{reference|backing array for 'std::initializer_list'}2 "
> +  "%select{|subobject of }1member %0 "
> +  "%select{binds to|is}2 a temporary object "
> +  "whose lifetime is shorter than the lifetime of the constructed
> object">,
> +  InGroup;
>  def note_lifetime_extending_member_declared_here : Note<
>"%select{%select{reference|'std::initializer_list'}0 member|"
>"member with %select{reference|'std::initializer_list'}0 subobject}1 "
>"declared here">;
> +def warn_dangling_variable : Warning<
> +  "%select{temporary %select{whose address is used as value of|bound to}3
> "
> +  "%select{%select{|reference }3member of local variable|"
> +  "local %select{variable|reference}3}1|"
> +  "array backing "
> +  "%select{initializer list subobject of local variable|"
> +  "local initializer list}1}0 "
> +  "%2 will be destroyed at the end of the 

[libcxxabi] r337906 - Fix dangling reference in test

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 04:19:13 2018
New Revision: 337906

URL: http://llvm.org/viewvc/llvm-project?rev=337906=rev
Log:
Fix dangling reference in test

Modified:
libcxxabi/trunk/test/cxa_bad_cast.pass.cpp

Modified: libcxxabi/trunk/test/cxa_bad_cast.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/cxa_bad_cast.pass.cpp?rev=337906=337905=337906=diff
==
--- libcxxabi/trunk/test/cxa_bad_cast.pass.cpp (original)
+++ libcxxabi/trunk/test/cxa_bad_cast.pass.cpp Wed Jul 25 04:19:13 2018
@@ -21,7 +21,7 @@ class Base {
 
 class Derived : public Base {};
 
-Derived _bad_cast(Base b) {
+Derived _bad_cast(Base& b) {
   return dynamic_cast(b);
 }
 


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


[libcxx] r337905 - Fix diagnostic test to tolerate Clang diagnosing it as well.

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 04:16:39 2018
New Revision: 337905

URL: http://llvm.org/viewvc/llvm-project?rev=337905=rev
Log:
Fix diagnostic test to tolerate Clang diagnosing it as well.

Tuple has tests that ensure we diagnose non-lifetime extended
reference bindings inside tuples constructors. As of yesterday,
Clang now does this for us.

Adjust the test to tolerate the new diagnostics, while still
testing that we emit diagnostics of our own. Maybe after this
version of Clang has been adopted by most users we should
remove our diagnostics; but for now more error detection is
better!

Modified:

libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp

Modified: 
libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp?rev=337905=337904=337905=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
 Wed Jul 25 04:16:39 2018
@@ -46,7 +46,12 @@ void F(typename CannotDeduce(std::make_tuple(1, "abc")); // expected-note 1 
{{requested here}}
   }


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


[libcxx] r337900 - Fix another typo in the FileTimeType docs

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 03:22:07 2018
New Revision: 337900

URL: http://llvm.org/viewvc/llvm-project?rev=337900=rev
Log:
Fix another typo in the FileTimeType docs

Modified:
libcxx/trunk/docs/DesignDocs/FileTimeType.rst

Modified: libcxx/trunk/docs/DesignDocs/FileTimeType.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/FileTimeType.rst?rev=337900=337899=337900=diff
==
--- libcxx/trunk/docs/DesignDocs/FileTimeType.rst (original)
+++ libcxx/trunk/docs/DesignDocs/FileTimeType.rst Wed Jul 25 03:22:07 2018
@@ -224,7 +224,7 @@ code in some way:
 
   // Implicit truncation during conversion bug.
   intmax_t get_time_in_seconds(path p) {
-using fs_seconds = duration;
+using fs_seconds = duration >;
 auto tp = last_write_time(p);
 
 // This works with truncation for __int128_t, but what does it do for


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


[libcxx] r337897 - Fix typos, spelling, and grammar in the FileTimeType design docs.

2018-07-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 25 03:17:04 2018
New Revision: 337897

URL: http://llvm.org/viewvc/llvm-project?rev=337897=rev
Log:
Fix typos, spelling, and grammar in the FileTimeType design docs.

I'm sure I'll discover more mistakes as I go on...

Modified:
libcxx/trunk/docs/DesignDocs/FileTimeType.rst

Modified: libcxx/trunk/docs/DesignDocs/FileTimeType.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/FileTimeType.rst?rev=337897=337896=337897=diff
==
--- libcxx/trunk/docs/DesignDocs/FileTimeType.rst (original)
+++ libcxx/trunk/docs/DesignDocs/FileTimeType.rst Wed Jul 25 03:17:04 2018
@@ -83,14 +83,14 @@ To get the same range, we would need to
 to come close to having the same range.
 
 This begs the question, is the range problem "really a problem"? Sane usages
-of file time stamps shouldn't exceed +/- 300, so should we care to support it?
+of file time stamps shouldn't exceed +/- 300 years, so should we care to 
support it?
 
 I believe the answer is yes. We're not designing the filesystem time API, we're
 providing glorified C++ wrappers for it. If the underlying API supports
 a value, then we should too. Our wrappers should not place artificial 
restrictions
 on users that are not present in the underlying filesystem.
 
-Additionally, having a smaller range that the underlying filesystem forces the
+Having a smaller range that the underlying filesystem forces the
 implementation to report ``value_too_large`` errors when it encounters a time
 point that it can't represent. This can cause the call to ``last_write_time``
 to throw in cases where the user was confident the call should succeed. (See 
below)
@@ -135,7 +135,7 @@ Having a Smaller Resolution than ``times
 -
 
 As mentioned in the previous section, one way to solve the range problem
-is by reducing the resolution, and matching the range of ``timespec`` using a
+is by reducing the resolution. But matching the range of ``timespec`` using a
 64 bit representation requires limiting the resolution to seconds.
 
 So we might ask: Do users "need" nanosecond precision? Is seconds not good 
enough?
@@ -148,16 +148,16 @@ representation, not design it.
 Having a Larger Range than ``timespec``
 
 
-We also should consider the opposite problem of having ``file_time_type``
-be able to represent a larger range than that of ``timespec``. At least in
+We should also consider the opposite problem of having a ``file_time_type``
+that is able to represent a larger range than ``timespec``. At least in
 this case ``last_write_time`` can be used to get and set all possible values
 supported by the underlying filesystem; meaning ``last_write_time(p)`` will
-never throw a overflow error.
+never throw a overflow error when retrieving a value.
 
-However, this introduces a new problem, where users are allowed to create time
-points beyond what the filesystem can represent. Two particular values are
-``file_time_type::min()`` and ``file_time_type::max()``. As such the following
-code would throw:
+However, this introduces a new problem, where users are allowed to attempt to
+create a time point beyond what the filesystem can represent. Two particular
+values which cause this are ``file_time_type::min()`` and
+``file_time_type::max()``. As a result, the following code would throw:
 
 .. code-block:: cpp
 
@@ -167,8 +167,8 @@ code would throw:
   }
 
 Apart from cases explicitly using ``min`` and ``max``, I don't see users taking
-a valid time point, adding a couple hundred billions of years to it in error,
-and then trying to update a files write time with that value very often.
+a valid time point, adding a couple hundred billions of years in error,
+and then trying to update a file's write time to that value very often.
 
 Compared to having a smaller range, this problem seems preferable. At least
 now we can represent any time point the filesystem can, so users won't be 
forced
@@ -190,10 +190,10 @@ than 64 bits. The possible solutions inc
 arithmetic type. All three will solve allow us to, at minimum, match the range
 and resolution, and the last one might even allow us to match them exactly.
 
-But when considering these potential solutions, we need to consider more than
-just the values they can represent. We need to consider the effect they will 
have
-on users and their code. For example, each of them breaks the following code
-in some way:
+But when considering these potential solutions we need to consider more than
+just the values they can represent. We need to consider the effects they will
+have on users and their code. For example, each of them breaks the following
+code in some way:
 
 .. code-block:: cpp
 
@@ -234,12 +234,12 @@ in some way:
 
 
 Each of the above examples would require a user to adjust their filesystem code
-to the particular eccentricities of the 

[libcxx] r337888 - Fix bugs in create_directory implementation.

2018-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 24 21:46:32 2018
New Revision: 337888

URL: http://llvm.org/viewvc/llvm-project?rev=337888=rev
Log:
Fix bugs in create_directory implementation.

Libc++ was incorrectly reporting an error when the target of create_directory
already exists, but was not a directory. This behavior is not specified
in the most recent standard, which says no error should be reported.

Additionally, libc++ failed to report an error when the attribute directory
path didn't exist or didn't name a directory. This has been fixed as well.

Although it's not clear if we should call status or symlink_status on the
attribute directory. This patch chooses to still call status.

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337888=337887=337888=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Tue Jul 24 21:46:32 
2018
@@ -830,7 +830,7 @@ bool __create_directory(const path& p, e
 
   if (::mkdir(p.c_str(), static_cast(perms::all)) == 0)
 return true;
-  if (errno != EEXIST || !is_directory(p))
+  if (errno != EEXIST)
 err.report(capture_errno());
   return false;
 }
@@ -845,10 +845,12 @@ bool __create_directory(path const & p,
   auto st = detail::posix_stat(attributes, attr_stat, );
   if (!status_known(st))
 return err.report(mec);
+  if (!is_directory(st))
+return err.report(errc::not_a_directory, "the specified attribute path is 
invalid");
 
   if (::mkdir(p.c_str(), attr_stat.st_mode) == 0)
 return true;
-  if (errno != EEXIST || !is_directory(p))
+  if (errno != EEXIST)
 err.report(capture_errno());
   return false;
 }

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp?rev=337888=337887=337888=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
 Tue Jul 24 21:46:32 2018
@@ -66,4 +66,36 @@ TEST_CASE(create_directories_multi_level
 TEST_CHECK(is_directory(dir));
 }
 
+TEST_CASE(create_directory_symlinks) {
+  scoped_test_env env;
+  const path root = env.create_dir("dir");
+  const path sym_dest_dead = env.make_env_path("dead");
+  const path dead_sym = env.create_symlink(sym_dest_dead, "dir/sym_dir");
+  const path target = env.make_env_path("dir/sym_dir/foo");
+  {
+std::error_code ec = GetTestEC();
+TEST_CHECK(create_directories(target, ec) == false);
+TEST_CHECK(ec);
+TEST_CHECK(!exists(sym_dest_dead));
+TEST_CHECK(!exists(dead_sym));
+  }
+}
+
+
+TEST_CASE(create_directory_through_symlinks) {
+  scoped_test_env env;
+  const path root = env.create_dir("dir");
+  const path sym_dir = env.create_symlink(root, "sym_dir");
+  const path target = env.make_env_path("sym_dir/foo");
+  const path resolved_target = env.make_env_path("dir/foo");
+  TEST_REQUIRE(is_directory(sym_dir));
+  {
+std::error_code ec = GetTestEC();
+TEST_CHECK(create_directories(target, ec) == true);
+TEST_CHECK(!ec);
+TEST_CHECK(is_directory(target));
+TEST_CHECK(is_directory(resolved_target));
+  }
+}
+
 TEST_SUITE_END()

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp?rev=337888=337887=337888=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp
 Tue Jul 24 21:46:32 2018
@@ -94,9 +94,9 @@ TEST_CASE(dest_is_file)
 {
 scoped_test_env env;
 const path file = env.create_file("file", 42);
-std::error_code ec;
+std::error_code ec = GetTestEC();
 TEST_CHECK(fs::create_directory(file, 

[libcxx] r337886 - Fix missing includes in format_string.hpp helper

2018-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 24 21:21:59 2018
New Revision: 337886

URL: http://llvm.org/viewvc/llvm-project?rev=337886=rev
Log:
Fix missing includes in format_string.hpp helper

Modified:
libcxx/trunk/test/support/format_string.hpp

Modified: libcxx/trunk/test/support/format_string.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/format_string.hpp?rev=337886=337885=337886=diff
==
--- libcxx/trunk/test/support/format_string.hpp (original)
+++ libcxx/trunk/test/support/format_string.hpp Tue Jul 24 21:21:59 2018
@@ -5,23 +5,24 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace format_string_detail {
 inline std::string format_string_imp(const char* msg, ...) {
   // we might need a second shot at this, so pre-emptivly make a copy
   struct GuardVAList {
-va_list& target;
+va_list& xtarget;
 bool active;
-GuardVAList(va_list& target) : target(target), active(true) {}
+GuardVAList(va_list& val) : xtarget(val), active(true) {}
 
 void clear() {
   if (active)
-va_end(target);
+va_end(xtarget);
   active = false;
 }
 ~GuardVAList() {
   if (active)
-va_end(target);
+va_end(xtarget);
 }
   };
   va_list args;


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


[libcxx] r337884 - Make explicitly require C++11.

2018-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 24 20:41:31 2018
New Revision: 337884

URL: http://llvm.org/viewvc/llvm-project?rev=337884=rev
Log:
Make  explicitly require C++11.

Previously the  didn't guard its
contents in any dialect. However, the implementation implicitly
requires at least C++11, and the tests have always been marked
unsupported in C++03. This patch puts a header guard around the
contents to avoid exposing them before C++11.

Additionally, it replaces all of the usages of _NOEXCEPT or
_LIBCPP_CONSTEXPR with the keyword directly, since we can
expect the compiler to implement those by now.

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

libcxx/trunk/test/std/experimental/filesystem/fs.req.macros/feature_macro.pass.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337884=337883=337884=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Tue Jul 24 20:41:31 2018
@@ -16,15 +16,15 @@
 
 class path;
 
-void swap(path& lhs, path& rhs) _NOEXCEPT;
-size_t hash_value(const path& p) _NOEXCEPT;
+void swap(path& lhs, path& rhs) noexcept;
+size_t hash_value(const path& p) noexcept;
 
-bool operator==(const path& lhs, const path& rhs) _NOEXCEPT;
-bool operator!=(const path& lhs, const path& rhs) _NOEXCEPT;
-bool operator< (const path& lhs, const path& rhs) _NOEXCEPT;
-bool operator<=(const path& lhs, const path& rhs) _NOEXCEPT;
-bool operator> (const path& lhs, const path& rhs) _NOEXCEPT;
-bool operator>=(const path& lhs, const path& rhs) _NOEXCEPT;
+bool operator==(const path& lhs, const path& rhs) noexcept;
+bool operator!=(const path& lhs, const path& rhs) noexcept;
+bool operator< (const path& lhs, const path& rhs) noexcept;
+bool operator<=(const path& lhs, const path& rhs) noexcept;
+bool operator> (const path& lhs, const path& rhs) noexcept;
+bool operator>=(const path& lhs, const path& rhs) noexcept;
 
 path operator/ (const path& lhs, const path& rhs);
 
@@ -96,88 +96,88 @@
 
 void copy_symlink(const path& existing_symlink, const path& new_symlink);
 void copy_symlink(const path& existing_symlink, const path& new_symlink,
-  error_code& ec) _NOEXCEPT;
+  error_code& ec) noexcept;
 
 bool create_directories(const path& p);
 bool create_directories(const path& p, error_code& ec);
 
 bool create_directory(const path& p);
-bool create_directory(const path& p, error_code& ec) _NOEXCEPT;
+bool create_directory(const path& p, error_code& ec) noexcept;
 
 bool create_directory(const path& p, const path& attributes);
 bool create_directory(const path& p, const path& attributes,
-  error_code& ec) _NOEXCEPT;
+  error_code& ec) noexcept;
 
 void create_directory_symlink(const path& to, const path& new_symlink);
 void create_directory_symlink(const path& to, const path& new_symlink,
-  error_code& ec) _NOEXCEPT;
+  error_code& ec) noexcept;
 
 void create_hard_link(const path& to, const path& new_hard_link);
 void create_hard_link(const path& to, const path& new_hard_link,
-  error_code& ec) _NOEXCEPT;
+  error_code& ec) noexcept;
 
 void create_symlink(const path& to, const path& new_symlink);
 void create_symlink(const path& to, const path& new_symlink,
-error_code& ec) _NOEXCEPT;
+error_code& ec) noexcept;
 
 path current_path();
 path current_path(error_code& ec);
 void current_path(const path& p);
-void current_path(const path& p, error_code& ec) _NOEXCEPT;
+void current_path(const path& p, error_code& ec) noexcept;
 
-bool exists(file_status s) _NOEXCEPT;
+bool exists(file_status s) noexcept;
 bool exists(const path& p);
-bool exists(const path& p, error_code& ec) _NOEXCEPT;
+bool exists(const path& p, error_code& ec) noexcept;
 
 bool equivalent(const path& p1, const path& p2);
-bool equivalent(const path& p1, const path& p2, error_code& ec) _NOEXCEPT;
+bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
 
 uintmax_tfile_size(const path& p);
-uintmax_tfile_size(const path& p, error_code& ec) _NOEXCEPT;
+uintmax_tfile_size(const path& p, error_code& ec) noexcept;
 
 uintmax_thard_link_count(const path& p);
-uintmax_thard_link_count(const path& p, error_code& ec) _NOEXCEPT;
+uintmax_thard_link_count(const path& p, error_code& 

[libcxx] r337883 - Ensure path::iterator and PathParser share the same enumeration values.

2018-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 24 20:31:48 2018
New Revision: 337883

URL: http://llvm.org/viewvc/llvm-project?rev=337883=rev
Log:
Ensure path::iterator and PathParser share the same enumeration values.

To avoid exposing implementation details, path::iterator and PathParser
both implicitly used the same set of values to represent the state,
but they were defined twice. This could have lead to a mismatch
occuring.

This patch moves all of the parser state values into the filesystem
header and changes PathParser to use those value to avoid this.

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337883=337882=337883=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Tue Jul 24 20:31:48 2018
@@ -1037,7 +1037,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY path extension()  const { return 
string_type(__extension()); }
 
 // query
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
 bool empty() const _NOEXCEPT { return __pn_.empty(); }
 
 _LIBCPP_INLINE_VISIBILITY bool has_root_name()  const { return 
!__root_name().empty(); }
@@ -1170,6 +1170,17 @@ u8path(_InputIt __f, _InputIt __l) {
 class _LIBCPP_TYPE_VIS path::iterator
 {
 public:
+enum _ParserState : unsigned char {
+  _Singular,
+  _BeforeBegin,
+  _InRootName,
+  _InRootDir,
+  _InFilenames,
+  _InTrailingSep,
+  _AtEnd
+};
+
+public:
 typedef bidirectional_iterator_tag iterator_category;
 
 typedef path   value_type;
@@ -1178,10 +1189,11 @@ public:
 typedef const path&reference;
 
 typedef void __stashing_iterator_tag; // See reverse_iterator and 
__is_stashing_iterator
+
 public:
 _LIBCPP_INLINE_VISIBILITY
 iterator() : __stashed_elem_(), __path_ptr_(nullptr),
- __entry_(), __state_(__singular) {}
+ __entry_(), __state_(_Singular) {}
 
 iterator(const iterator&) = default;
 ~iterator() = default;
@@ -1200,9 +1212,9 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 iterator& operator++() {
-_LIBCPP_ASSERT(__state_ != __singular,
+_LIBCPP_ASSERT(__state_ != _Singular,
"attempting to increment a singular iterator");
-_LIBCPP_ASSERT(__state_ != __at_end,
+_LIBCPP_ASSERT(__state_ != _AtEnd,
   "attempting to increment the end iterator");
 return __increment();
 }
@@ -1216,7 +1228,7 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 iterator& operator--() {
-_LIBCPP_ASSERT(__state_ != __singular,
+_LIBCPP_ASSERT(__state_ != _Singular,
"attempting to decrement a singular iterator");
 _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
"attempting to decrement the begin iterator");
@@ -1233,9 +1245,6 @@ public:
 private:
 friend class path;
 
-static constexpr unsigned char __singular = 0;
-static constexpr unsigned char __at_end = 6;
-
 inline _LIBCPP_INLINE_VISIBILITY
 friend bool operator==(const iterator&, const iterator&);
 
@@ -1245,7 +1254,7 @@ private:
 path __stashed_elem_;
 const path* __path_ptr_;
 path::__string_view __entry_;
-unsigned char __state_;
+_ParserState __state_;
 };
 
 inline _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337883=337882=337883=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Tue Jul 24 20:31:48 
2018
@@ -57,12 +57,12 @@ using PosPtr = path::value_type const*;
 struct PathParser {
   enum ParserState : unsigned char {
 // Zero is a special sentinel value used by default constructed iterators.
-PS_BeforeBegin = 1,
-PS_InRootName,
-PS_InRootDir,
-PS_InFilenames,
-PS_InTrailingSep,
-PS_AtEnd
+PS_BeforeBegin = path::iterator::_BeforeBegin,
+PS_InRootName = path::iterator::_InRootName,
+PS_InRootDir = path::iterator::_InRootDir,
+PS_InFilenames = path::iterator::_InFilenames,
+PS_InTrailingSep = path::iterator::_InTrailingSep,
+PS_AtEnd = path::iterator::_AtEnd
   };
 
   const string_view_t Path;
@@ -1548,7 +1548,7 @@ path::iterator path::begin() const
 auto PP = PathParser::CreateBegin(__pn_);
 iterator it;
 it.__path_ptr_ = this;
-it.__state_ = PP.State;
+it.__state_ 

[libcxx] r337880 - Add design docs for upcoming file_time_type change.

2018-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 24 19:53:53 2018
New Revision: 337880

URL: http://llvm.org/viewvc/llvm-project?rev=337880=rev
Log:
Add design docs for upcoming file_time_type change.

In upcoming changes to filesystem I plan to change file_time_type
to use __int128_t as its underlying representation, in order
to allow it to have a range and resolution at least that of
the timespec struct.

There was some pushback against this decision, so I drafted
a document explaining the problems, potential solutions, and
the rational for the decision.

However, it's probably easier to let people read the generated
HTML rather than the raw restructured text. For this reason
I'm commiting the design documents before hand, so they can
be available during any subsequent discussion or code review.

Added:
libcxx/trunk/docs/DesignDocs/FileTimeType.rst
Modified:
libcxx/trunk/docs/Makefile.sphinx
libcxx/trunk/docs/index.rst

Added: libcxx/trunk/docs/DesignDocs/FileTimeType.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/FileTimeType.rst?rev=337880=auto
==
--- libcxx/trunk/docs/DesignDocs/FileTimeType.rst (added)
+++ libcxx/trunk/docs/DesignDocs/FileTimeType.rst Tue Jul 24 19:53:53 2018
@@ -0,0 +1,493 @@
+==
+File Time Type
+==
+
+.. contents::
+   :local:
+
+.. _file-time-type-motivation:
+
+Motivation
+==
+
+The filesystem library provides interfaces for getting and setting the last
+write time of a file or directory. The interfaces use the ``file_time_type``
+type, which is a specialization of ``chrono::time_point`` for the
+"filesystem clock". According to [fs.filesystem.syn]
+
+  trivial-clock is an implementation-defined type that satisfies the
+  Cpp17TrivialClock requirements ([time.clock.req]) and that is capable of
+  representing and measuring file time values. Implementations should ensure
+  that the resolution and range of file_­time_­type reflect the operating
+  system dependent resolution and range of file time values.
+
+
+On POSIX systems, file times are represented using the ``timespec`` struct,
+which is defined as follows:
+
+.. code-block:: cpp
+
+  struct timespec {
+time_t tv_sec;
+long   tv_nsec;
+  };
+
+To represent the range and resolution of ``timespec``, we need to (A) have
+nanosecond resolution, and (B) use more than 64 bits (assuming a 64 bit 
``time_t``).
+
+As the standard requires us to use the ``chrono`` interface, we have to define
+our own filesystem clock which specifies the period and representation of
+the time points and duration it provides. It will look like this:
+
+.. code-block:: cpp
+
+  struct _FilesystemClock {
+using period = nano;
+using rep = TBD; // What is this?
+
+using duration = chrono::duration;
+using time_point = chrono::time_point<_FilesystemClock>;
+
+// ... //
+  };
+
+  using file_time_type = _FilesystemClock::time_point;
+
+
+To get nanosecond resolution, we simply define ``period`` to be ``std::nano``.
+But what type can we use as the arithmetic representation that is capable
+of representing the range of the ``timespec`` struct?
+
+Problems To Consider
+
+
+Before considering solutions, lets consider the problems they should solve,
+and how important solving those problems are:
+
+
+Having a Smaller Range than ``timespec``
+
+
+One solution to the range problem is to simply reduce the resolution of
+``file_time_type`` to be less than that of nanoseconds. This is what libc++'s
+initial implementation of ``file_time_type`` did; it's also what
+``std::system_clock`` does. As a result, it can represent time points about
+292 thousand years on either side of the epoch, as opposed to only 292 years
+at nanosecond resolution.
+
+``timespec`` can represent time points +/- 292 billion years from the epoch
+(just in case you needed a time point 200 billion years before the big bang,
+and with nanosecond resolution).
+
+To get the same range, we would need to drop our resolution to that of seconds
+to come close to having the same range.
+
+This begs the question, is the range problem "really a problem"? Sane usages
+of file time stamps shouldn't exceed +/- 300, so should we care to support it?
+
+I believe the answer is yes. We're not designing the filesystem time API, we're
+providing glorified C++ wrappers for it. If the underlying API supports
+a value, then we should too. Our wrappers should not place artificial 
restrictions
+on users that are not present in the underlying filesystem.
+
+Additionally, having a smaller range that the underlying filesystem forces the
+implementation to report ``value_too_large`` errors when it encounters a time
+point that it can't represent. This can cause the call to ``last_write_time``
+to throw in cases where the user was confident the call should succeed. (See 
below)
+
+
+.. code-block:: cpp
+
+ 

[libcxx] r337817 - Fix use of incorrect _LIBCXX macro (should be _LIBCPP).

2018-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 24 02:15:03 2018
New Revision: 337817

URL: http://llvm.org/viewvc/llvm-project?rev=337817=rev
Log:
Fix use of incorrect _LIBCXX macro (should be _LIBCPP).

Modified:
libcxx/trunk/include/future

Modified: libcxx/trunk/include/future
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=337817=337816=337817=diff
==
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Tue Jul 24 02:15:03 2018
@@ -409,7 +409,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launc
 
 #ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
 
-#ifdef _LIBCXX_UNDERLYING_TYPE
+#ifdef _LIBCPP_UNDERLYING_TYPE
 typedef underlying_type::type __launch_underlying_type;
 #else
 typedef int __launch_underlying_type;


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


Re: [libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.

2018-07-24 Thread Eric Fiselier via cfe-commits
Great, thanks for letting me know.

On Tue, Jul 24, 2018, 1:05 AM Jonas Hahnfeld,  wrote:

> Thanks for your work, the test is now passing on my system.
>
> Cheers,
> Jonas
>
> On 2018-07-24 01:00, Eric Fiselier wrote:
> > Sorry for the repeated emails. I did more digging and we were indeed
> > handling DT_UNKNOWN incorrectly.
> > I've fixed that in r337768.
> >
> > /Eric
> >
> > On Mon, Jul 23, 2018 at 4:43 PM Eric Fiselier  wrote:
> >
> >> Hi Jonas,
> >>
> >> I believe I fixed the issue, and I've recommitted the change as
> >> r337765.
> >> Please let me know if you still see the failures. I think there
> >> might be a lingering issues with how we handle DT_UNKNOWN.
> >>
> >> /Eric
> >>
> >> On Mon, Jul 23, 2018 at 3:53 PM Eric Fiselier  wrote:
> >>
> >> I think I've found the bug, but I need to spend some more time on
> >> it.
> >>
> >> I've reverted in for now in r337749.
> >>
> >> /Eric
> >>
> >> On Mon, Jul 23, 2018 at 1:25 PM Eric Fiselier  wrote:
> >>
> >> Thanks. I'm looking into this.
> >>
> >> /Eric
> >>
> >> On Mon, Jul 23, 2018 at 12:58 PM Jonas Hahnfeld 
> >> wrote:
> >> Hi Eric,
> >>
> >> this breaks
> >>
> >
> test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> for me:
> >> In access_denied_on_recursion_test_case():176 Assertion
> >> TEST_CHECK(ec)
> >> failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In access_denied_on_recursion_test_case():177 Assertion
> >> TEST_CHECK(it ==
> >> endIt) failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In access_denied_on_recursion_test_case():189 Assertion
> >> TEST_REQUIRE_THROW(filesystem_error,++it) failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In test_PR35078():285 Assertion TEST_REQUIRE(it != endIt) failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In test_PR35078_with_symlink():384 Assertion TEST_CHECK(ec) failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In test_PR35078_with_symlink():385 Assertion TEST_CHECK(ec ==
> >> eacess_ec)
> >> failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In test_PR35078_with_symlink_file():461 Assertion TEST_CHECK(*it ==
> >> symFile) failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> In test_PR35078_with_symlink_file():467 Assertion TEST_REQUIRE(it !=
> >>
> >> EndIt) failed.
> >> in file:
> >>
> >
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
> >>
> >> Summary for testsuite recursive_directory_iterator_increment_tests:
> >> 5 of 9 test cases passed.
> >> 156 of 164 assertions passed.
> >> 0 unsupported test cases.
> >>
> >> Do you have an idea? I'm on a local XFS mount, the sources are on
> >> NFS...
> >>
> >> Thanks,
> >> Jonas
> >>
> >> On 2018-07-23 06:55, Eric Fiselier via cfe-commits wrote:
> >>> Author: ericwf
> >>> Date: Sun Jul 22 21:55:57 2018
> >>> New Revision: 337669
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=337669=rev
> >>> Log:
> >>> Use possibly cached directory entry values when performing
> >> recursive
> >>> directory iteration.
> >>>
> >>> Modified:
> >>>
> >> libcxx/trunk/src/experiment

Re: [libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.

2018-07-23 Thread Eric Fiselier via cfe-commits
Sorry for the repeated emails. I did more digging and we were indeed
handling DT_UNKNOWN incorrectly.
I've fixed that in r337768.

/Eric

On Mon, Jul 23, 2018 at 4:43 PM Eric Fiselier  wrote:

> Hi Jonas,
>
> I believe I fixed the issue, and I've recommitted the change as r337765.
> Please let me know if you still see the failures. I think there might be a
> lingering issues with how we handle DT_UNKNOWN.
>
> /Eric
>
> On Mon, Jul 23, 2018 at 3:53 PM Eric Fiselier  wrote:
>
>> I think I've found the bug, but I need to spend some more time on it.
>>
>> I've reverted in for now in r337749.
>>
>> /Eric
>>
>> On Mon, Jul 23, 2018 at 1:25 PM Eric Fiselier  wrote:
>>
>>> Thanks. I'm looking into this.
>>>
>>> /Eric
>>>
>>> On Mon, Jul 23, 2018 at 12:58 PM Jonas Hahnfeld 
>>> wrote:
>>>
>>>> Hi Eric,
>>>>
>>>> this breaks
>>>> test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> for me:
>>>> In access_denied_on_recursion_test_case():176 Assertion TEST_CHECK(ec)
>>>> failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In access_denied_on_recursion_test_case():177 Assertion TEST_CHECK(it
>>>> ==
>>>> endIt) failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In access_denied_on_recursion_test_case():189 Assertion
>>>> TEST_REQUIRE_THROW(filesystem_error,++it) failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In test_PR35078():285 Assertion TEST_REQUIRE(it != endIt) failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In test_PR35078_with_symlink():384 Assertion TEST_CHECK(ec) failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In test_PR35078_with_symlink():385 Assertion TEST_CHECK(ec ==
>>>> eacess_ec)
>>>> failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In test_PR35078_with_symlink_file():461 Assertion TEST_CHECK(*it ==
>>>> symFile) failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> In test_PR35078_with_symlink_file():467 Assertion TEST_REQUIRE(it !=
>>>> EndIt) failed.
>>>>  in file:
>>>>
>>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>>
>>>> Summary for testsuite recursive_directory_iterator_increment_tests:
>>>>  5 of 9 test cases passed.
>>>>  156 of 164 assertions passed.
>>>>  0 unsupported test cases.
>>>>
>>>> Do you have an idea? I'm on a local XFS mount, the sources are on NFS...
>>>>
>>>> Thanks,
>>>> Jonas
>>>>
>>>> On 2018-07-23 06:55, Eric Fiselier via cfe-commits wrote:
>>>> > Author: ericwf
>>>> > Date: Sun Jul 22 21:55:57 2018
>>>> > New Revision: 337669
>>>> >
>>>> > URL: http://llvm.org/viewvc/llvm-project?rev=337669=rev
>>>> > Log:
>>>> > Use possibly cached directory entry values when performing recursive
>>>> > directory iteration.
>>>> >
>>>> > Modified:
>>>> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>>>> >
>>>> > Modified:
>>>> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>>>> > URL:
>>>> >
>>>> http://llvm.org/viewvc/llvm-pr

[libcxx] r337768 - Handle DT_UNKNOWN correctly during directory iteration.

2018-07-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 23 15:58:46 2018
New Revision: 337768

URL: http://llvm.org/viewvc/llvm-project?rev=337768=rev
Log:
Handle DT_UNKNOWN correctly during directory iteration.

Unlike stat and lstat, where unknown really means we know it's something weird,
during directory iteration DT_UNKNOWN simply means that the underlying FS 
doesn't
support the dirent::dt_type field.

This patch fixes libc++ to correctly set the cache to empty when DT_UNKNOWN is 
reported.

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337768=337767=337768=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Mon Jul 23 
15:58:46 2018
@@ -42,8 +42,11 @@ static file_type get_file_type(DirEntT *
 return file_type::regular;
   case DT_SOCK:
 return file_type::socket;
+  // Unlike in lstat, hitting "unknown" here simply means that the underlying
+  // filesystem doesn't support d_type. Report is as 'none' so we correctly
+  // set the cache to empty.
   case DT_UNKNOWN:
-return file_type::unknown;
+break;
   }
   return file_type::none;
 }


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


Re: [libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.

2018-07-23 Thread Eric Fiselier via cfe-commits
Hi Jonas,

I believe I fixed the issue, and I've recommitted the change as r337765.
Please let me know if you still see the failures. I think there might be a
lingering issues with how we handle DT_UNKNOWN.

/Eric

On Mon, Jul 23, 2018 at 3:53 PM Eric Fiselier  wrote:

> I think I've found the bug, but I need to spend some more time on it.
>
> I've reverted in for now in r337749.
>
> /Eric
>
> On Mon, Jul 23, 2018 at 1:25 PM Eric Fiselier  wrote:
>
>> Thanks. I'm looking into this.
>>
>> /Eric
>>
>> On Mon, Jul 23, 2018 at 12:58 PM Jonas Hahnfeld  wrote:
>>
>>> Hi Eric,
>>>
>>> this breaks
>>> test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> for me:
>>> In access_denied_on_recursion_test_case():176 Assertion TEST_CHECK(ec)
>>> failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In access_denied_on_recursion_test_case():177 Assertion TEST_CHECK(it ==
>>> endIt) failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In access_denied_on_recursion_test_case():189 Assertion
>>> TEST_REQUIRE_THROW(filesystem_error,++it) failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In test_PR35078():285 Assertion TEST_REQUIRE(it != endIt) failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In test_PR35078_with_symlink():384 Assertion TEST_CHECK(ec) failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In test_PR35078_with_symlink():385 Assertion TEST_CHECK(ec == eacess_ec)
>>> failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In test_PR35078_with_symlink_file():461 Assertion TEST_CHECK(*it ==
>>> symFile) failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> In test_PR35078_with_symlink_file():467 Assertion TEST_REQUIRE(it !=
>>> EndIt) failed.
>>>  in file:
>>>
>>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>>
>>> Summary for testsuite recursive_directory_iterator_increment_tests:
>>>  5 of 9 test cases passed.
>>>  156 of 164 assertions passed.
>>>  0 unsupported test cases.
>>>
>>> Do you have an idea? I'm on a local XFS mount, the sources are on NFS...
>>>
>>> Thanks,
>>> Jonas
>>>
>>> On 2018-07-23 06:55, Eric Fiselier via cfe-commits wrote:
>>> > Author: ericwf
>>> > Date: Sun Jul 22 21:55:57 2018
>>> > New Revision: 337669
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=337669=rev
>>> > Log:
>>> > Use possibly cached directory entry values when performing recursive
>>> > directory iteration.
>>> >
>>> > Modified:
>>> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>>> >
>>> > Modified:
>>> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>>> > URL:
>>> >
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337669=337668=337669=diff
>>> >
>>> ==
>>> > --- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>>> > (original)
>>> > +++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>>> > Sun Jul 22 21:55:57 2018
>>> > @@ -359,13 +359,13 @@ bool recursive_directory_iterator::__try
>>> >bool skip_rec = false;
>>> >std::error_code m_ec;
>>> >if (!rec_sym) {
>>> > -file_status st = curr_it.__entry_.symlink_status(m_ec);
>>> > +file_status st(curr_it.__entry_.__get_sym_ft(_ec));
>>> >  if (m_ec && status_known(st))
>>> >m_ec.clear();
>>> >  if (m_ec || is_symlink(st) || !is_directory(st))
>>> >skip_rec = true;
>>> >} else {
>>> > -file_status st = curr_it.__entry_.status(m_ec);
>>> > +file_status st(curr_it.__entry_.__get_ft(_ec));
>>> >  if (m_ec && status_known(st))
>>> >m_ec.clear();
>>> >  if (m_ec || !is_directory(st))
>>> >
>>> >
>>> > ___
>>> > cfe-commits mailing list
>>> > cfe-commits@lists.llvm.org
>>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r337765 - Recommit "Use possibly cached directory entry values when performing recursive directory iteration."

2018-07-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 23 15:40:41 2018
New Revision: 337765

URL: http://llvm.org/viewvc/llvm-project?rev=337765=rev
Log:
Recommit "Use possibly cached directory entry values when performing recursive 
directory iteration."

The initial patch didn't correctly handle systems when the dirent struct
didn't provide the d_type member. Specifically it set the cache to the 
incorrect state,
and claimed it was partially populated.

The updated version of this change correctly handles setting up the
cache when the file type is not known (aka file_type::none).

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337765=337764=337765=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Mon Jul 23 15:40:41 2018
@@ -2200,8 +2200,16 @@ private:
 static __cached_data __create_iter_result(file_type __ft) {
   __cached_data __data;
   __data.__type_ = __ft;
-  __data.__cache_type_ =
-  __ft == file_type::symlink ? _IterSymlink : _IterNonSymlink;
+  __data.__cache_type_ = [&]() {
+  switch (__ft) {
+  case file_type::none:
+return _Empty;
+  case file_type::symlink:
+return _IterSymlink;
+  default:
+return _IterNonSymlink;
+  }
+  }();
   return __data;
 }
 

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337765=337764=337765=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Mon Jul 23 
15:40:41 2018
@@ -47,9 +47,10 @@ static file_type get_file_type(DirEntT *
   }
   return file_type::none;
 }
+
 template 
 static file_type get_file_type(DirEntT *ent, long) {
-  return file_type::unknown;
+  return file_type::none;
 }
 
 static pair
@@ -359,13 +360,13 @@ bool recursive_directory_iterator::__try
   bool skip_rec = false;
   error_code m_ec;
   if (!rec_sym) {
-file_status st = curr_it.__entry_.symlink_status(m_ec);
+file_status st(curr_it.__entry_.__get_sym_ft(_ec));
 if (m_ec && status_known(st))
   m_ec.clear();
 if (m_ec || is_symlink(st) || !is_directory(st))
   skip_rec = true;
   } else {
-file_status st = curr_it.__entry_.status(m_ec);
+file_status st(curr_it.__entry_.__get_ft(_ec));
 if (m_ec && status_known(st))
   m_ec.clear();
 if (m_ec || !is_directory(st))


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


[libcxx] r337764 - Fix accidentally removed test.

2018-07-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 23 15:39:56 2018
New Revision: 337764

URL: http://llvm.org/viewvc/llvm-project?rev=337764=rev
Log:
Fix accidentally removed test.

When adding the new tests for the filesystem_error::what method,
I incorrectly removed a test case and replaced it with something else.

This patch restores that test case

Modified:

libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp?rev=337764=337763=337764=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
 Mon Jul 23 15:39:56 2018
@@ -25,8 +25,6 @@
 #include "rapid-cxx-test.hpp"
 #include "filesystem_test_helper.hpp"
 
-#include 
-
 using namespace fs;
 
 TEST_SUITE(recursive_directory_iterator_increment_tests)
@@ -292,6 +290,21 @@ TEST_CASE(test_PR35078)
 }
 {
   bool SeenNestedFile = false;
+  recursive_directory_iterator it = SetupState(true, SeenNestedFile);
+  TEST_REQUIRE(it != endIt);
+  TEST_REQUIRE(*it == nestedDir);
+  ec = GetTestEC();
+  it.increment(ec);
+  TEST_CHECK(!ec);
+  if (SeenNestedFile) {
+TEST_CHECK(it == endIt);
+  } else {
+TEST_REQUIRE(it != endIt);
+TEST_CHECK(*it == nestedFile);
+  }
+}
+{
+  bool SeenNestedFile = false;
   recursive_directory_iterator it = SetupState(false, SeenNestedFile);
   TEST_REQUIRE(it != endIt);
   TEST_REQUIRE(*it == nestedDir);


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


Re: [libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.

2018-07-23 Thread Eric Fiselier via cfe-commits
I think I've found the bug, but I need to spend some more time on it.

I've reverted in for now in r337749.

/Eric

On Mon, Jul 23, 2018 at 1:25 PM Eric Fiselier  wrote:

> Thanks. I'm looking into this.
>
> /Eric
>
> On Mon, Jul 23, 2018 at 12:58 PM Jonas Hahnfeld  wrote:
>
>> Hi Eric,
>>
>> this breaks
>> test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> for me:
>> In access_denied_on_recursion_test_case():176 Assertion TEST_CHECK(ec)
>> failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In access_denied_on_recursion_test_case():177 Assertion TEST_CHECK(it ==
>> endIt) failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In access_denied_on_recursion_test_case():189 Assertion
>> TEST_REQUIRE_THROW(filesystem_error,++it) failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In test_PR35078():285 Assertion TEST_REQUIRE(it != endIt) failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In test_PR35078_with_symlink():384 Assertion TEST_CHECK(ec) failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In test_PR35078_with_symlink():385 Assertion TEST_CHECK(ec == eacess_ec)
>> failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In test_PR35078_with_symlink_file():461 Assertion TEST_CHECK(*it ==
>> symFile) failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> In test_PR35078_with_symlink_file():467 Assertion TEST_REQUIRE(it !=
>> EndIt) failed.
>>  in file:
>>
>> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>>
>> Summary for testsuite recursive_directory_iterator_increment_tests:
>>  5 of 9 test cases passed.
>>  156 of 164 assertions passed.
>>  0 unsupported test cases.
>>
>> Do you have an idea? I'm on a local XFS mount, the sources are on NFS...
>>
>> Thanks,
>> Jonas
>>
>> On 2018-07-23 06:55, Eric Fiselier via cfe-commits wrote:
>> > Author: ericwf
>> > Date: Sun Jul 22 21:55:57 2018
>> > New Revision: 337669
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=337669=rev
>> > Log:
>> > Use possibly cached directory entry values when performing recursive
>> > directory iteration.
>> >
>> > Modified:
>> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>> >
>> > Modified:
>> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>> > URL:
>> >
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337669=337668=337669=diff
>> >
>> ==
>> > --- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>> > (original)
>> > +++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
>> > Sun Jul 22 21:55:57 2018
>> > @@ -359,13 +359,13 @@ bool recursive_directory_iterator::__try
>> >bool skip_rec = false;
>> >std::error_code m_ec;
>> >if (!rec_sym) {
>> > -file_status st = curr_it.__entry_.symlink_status(m_ec);
>> > +file_status st(curr_it.__entry_.__get_sym_ft(_ec));
>> >  if (m_ec && status_known(st))
>> >m_ec.clear();
>> >  if (m_ec || is_symlink(st) || !is_directory(st))
>> >skip_rec = true;
>> >} else {
>> > -file_status st = curr_it.__entry_.status(m_ec);
>> > +file_status st(curr_it.__entry_.__get_ft(_ec));
>> >  if (m_ec && status_known(st))
>> >m_ec.clear();
>> >  if (m_ec || !is_directory(st))
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r337749 - Revert "Use possibly cached directory entry values when performing recursive directory iteration."

2018-07-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 23 14:52:29 2018
New Revision: 337749

URL: http://llvm.org/viewvc/llvm-project?rev=337749=rev
Log:
Revert "Use possibly cached directory entry values when performing recursive 
directory iteration."

This reverts commit 04ce4aef00d3ee508327f6cf7bf1b1d200ab6238.

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337749=337748=337749=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Mon Jul 23 
14:52:29 2018
@@ -359,13 +359,13 @@ bool recursive_directory_iterator::__try
   bool skip_rec = false;
   error_code m_ec;
   if (!rec_sym) {
-file_status st(curr_it.__entry_.__get_sym_ft(_ec));
+file_status st = curr_it.__entry_.symlink_status(m_ec);
 if (m_ec && status_known(st))
   m_ec.clear();
 if (m_ec || is_symlink(st) || !is_directory(st))
   skip_rec = true;
   } else {
-file_status st(curr_it.__entry_.__get_ft(_ec));
+file_status st = curr_it.__entry_.status(m_ec);
 if (m_ec && status_known(st))
   m_ec.clear();
 if (m_ec || !is_directory(st))


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


Re: [libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.

2018-07-23 Thread Eric Fiselier via cfe-commits
Thanks. I'm looking into this.

/Eric

On Mon, Jul 23, 2018 at 12:58 PM Jonas Hahnfeld  wrote:

> Hi Eric,
>
> this breaks
> test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> for me:
> In access_denied_on_recursion_test_case():176 Assertion TEST_CHECK(ec)
> failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In access_denied_on_recursion_test_case():177 Assertion TEST_CHECK(it ==
> endIt) failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In access_denied_on_recursion_test_case():189 Assertion
> TEST_REQUIRE_THROW(filesystem_error,++it) failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In test_PR35078():285 Assertion TEST_REQUIRE(it != endIt) failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In test_PR35078_with_symlink():384 Assertion TEST_CHECK(ec) failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In test_PR35078_with_symlink():385 Assertion TEST_CHECK(ec == eacess_ec)
> failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In test_PR35078_with_symlink_file():461 Assertion TEST_CHECK(*it ==
> symFile) failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> In test_PR35078_with_symlink_file():467 Assertion TEST_REQUIRE(it !=
> EndIt) failed.
>  in file:
>
> <<>>/projects/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
>
> Summary for testsuite recursive_directory_iterator_increment_tests:
>  5 of 9 test cases passed.
>  156 of 164 assertions passed.
>  0 unsupported test cases.
>
> Do you have an idea? I'm on a local XFS mount, the sources are on NFS...
>
> Thanks,
> Jonas
>
> On 2018-07-23 06:55, Eric Fiselier via cfe-commits wrote:
> > Author: ericwf
> > Date: Sun Jul 22 21:55:57 2018
> > New Revision: 337669
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=337669=rev
> > Log:
> > Use possibly cached directory entry values when performing recursive
> > directory iteration.
> >
> > Modified:
> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
> >
> > Modified:
> > libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337669=337668=337669=diff
> >
> ==
> > --- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
> > (original)
> > +++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
> > Sun Jul 22 21:55:57 2018
> > @@ -359,13 +359,13 @@ bool recursive_directory_iterator::__try
> >bool skip_rec = false;
> >std::error_code m_ec;
> >if (!rec_sym) {
> > -file_status st = curr_it.__entry_.symlink_status(m_ec);
> > +file_status st(curr_it.__entry_.__get_sym_ft(_ec));
> >  if (m_ec && status_known(st))
> >m_ec.clear();
> >  if (m_ec || is_symlink(st) || !is_directory(st))
> >skip_rec = true;
> >} else {
> > -file_status st = curr_it.__entry_.status(m_ec);
> > +file_status st(curr_it.__entry_.__get_ft(_ec));
> >  if (m_ec && status_known(st))
> >m_ec.clear();
> >  if (m_ec || !is_directory(st))
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r337685 - Cleanup unnecessary conversions in filesystem.

2018-07-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 23 04:55:13 2018
New Revision: 337685

URL: http://llvm.org/viewvc/llvm-project?rev=337685=rev
Log:
Cleanup unnecessary conversions in filesystem.

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337685=337684=337685=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Mon Jul 23 04:55:13 
2018
@@ -727,10 +727,10 @@ bool __copy_file(const path& from, const
 
   const bool to_exists = exists(to_st);
   if (to_exists && !is_regular_file(to_st))
-return err.report(make_error_code(errc::not_supported));
+return err.report(errc::not_supported);
 
   if (to_exists && detail::stat_equivalent(from_stat, to_stat_path))
-return err.report(make_error_code(errc::file_exists));
+return err.report(errc::file_exists);
 
   if (to_exists && skip_existing)
 return false;


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


[libcxx] r337684 - Cleanup name qualification in the filesystem internals.

2018-07-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 23 04:46:47 2018
New Revision: 337684

URL: http://llvm.org/viewvc/llvm-project?rev=337684=rev
Log:
Cleanup name qualification in the filesystem internals.

In most cases there is no reason why the filesystem internals
use the qualifier std:: or _VSTD::. This patch removes the unneeded
qualifiers, making the sources files more consistent

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
libcxx/trunk/src/experimental/filesystem/filesystem_common.h
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337684=337683=337684=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Mon Jul 23 
04:46:47 2018
@@ -98,8 +98,8 @@ public:
   __dir_stream& operator=(const __dir_stream&) = delete;
 
   __dir_stream(__dir_stream&& __ds) noexcept
-  : __stream_(__ds.__stream_), __root_(std::move(__ds.__root_)),
-__entry_(std::move(__ds.__entry_)) {
+  : __stream_(__ds.__stream_), __root_(move(__ds.__root_)),
+__entry_(move(__ds.__entry_)) {
 __ds.__stream_ = INVALID_HANDLE_VALUE;
   }
 
@@ -107,7 +107,7 @@ public:
   : __stream_(INVALID_HANDLE_VALUE), __root_(root) {
 __stream_ = ::FindFirstFileEx(root.c_str(),  &__data_);
 if (__stream_ == INVALID_HANDLE_VALUE) {
-  ec = error_code(::GetLastError(), std::generic_category());
+  ec = error_code(::GetLastError(), generic_category());
   const bool ignore_permission_denied =
   bool(opts & directory_options::skip_permission_denied);
   if (ignore_permission_denied && ec.value() == ERROR_ACCESS_DENIED)
@@ -138,16 +138,16 @@ public:
   directory_entry::__create_iter_result(get_file_type(__data)));
   return true;
 }
-ec = error_code(::GetLastError(), std::generic_category());
+ec = error_code(::GetLastError(), generic_category());
 close();
 return false;
   }
 
 private:
-  std::error_code close() noexcept {
-std::error_code ec;
+  error_code close() noexcept {
+error_code ec;
 if (!::FindClose(__stream_))
-  ec = error_code(::GetLastError(), std::generic_category());
+  ec = error_code(::GetLastError(), generic_category());
 __stream_ = INVALID_HANDLE_VALUE;
 return ec;
   }
@@ -166,8 +166,8 @@ public:
 __dir_stream& operator=(const __dir_stream&) = delete;
 
 __dir_stream(__dir_stream&& other) noexcept
-: __stream_(other.__stream_), __root_(std::move(other.__root_)),
-  __entry_(std::move(other.__entry_))
+: __stream_(other.__stream_), __root_(move(other.__root_)),
+  __entry_(move(other.__entry_))
 {
 other.__stream_ = nullptr;
 }
@@ -211,8 +211,8 @@ public:
 }
 }
 private:
-std::error_code close() noexcept {
-std::error_code m_ec;
+error_code close() noexcept {
+error_code m_ec;
 if (::closedir(__stream_) == -1)
m_ec = detail::capture_errno();
 __stream_ = nullptr;
@@ -233,7 +233,7 @@ directory_iterator::directory_iterator(c
 {
   ErrorHandler err("directory_iterator::directory_iterator(...)", ec, 
);
 
-  std::error_code m_ec;
+  error_code m_ec;
   __imp_ = make_shared<__dir_stream>(p, opts, m_ec);
   if (ec)
 *ec = m_ec;
@@ -249,9 +249,9 @@ directory_iterator& directory_iterator::
 _LIBCPP_ASSERT(__imp_, "Attempting to increment an invalid iterator");
 ErrorHandler err("directory_iterator::operator++()", ec);
 
-std::error_code m_ec;
+error_code m_ec;
 if (!__imp_->advance(m_ec)) {
-  path root = std::move(__imp_->__root_);
+  path root = move(__imp_->__root_);
   __imp_.reset();
   if (m_ec)
 err.report(m_ec, "at root \"%s\"", root);
@@ -278,16 +278,16 @@ recursive_directory_iterator::recursive_
 {
   ErrorHandler err("recursive_directory_iterator", ec, );
 
-  std::error_code m_ec;
+  error_code m_ec;
   __dir_stream new_s(p, opt, m_ec);
   if (m_ec)
 err.report(m_ec);
   if (m_ec || !new_s.good())
 return;
 
-  __imp_ = _VSTD::make_shared<__shared_imp>();
+  __imp_ = make_shared<__shared_imp>();
   __imp_->__options_ = opt;
-  __imp_->__stack_.push(_VSTD::move(new_s));
+  __imp_->__stack_.push(move(new_s));
 }
 
 void recursive_directory_iterator::__pop(error_code* ec)
@@ -331,7 +331,7 @@ void recursive_directory_iterator::__adv
 
   const directory_iterator end_it;
   auto& stack = __imp_->__stack_;
-  std::error_code m_ec;
+  error_code m_ec;
   while (stack.size() > 0) {
 if (stack.top().advance(m_ec))
   return;
@@ -341,7 +341,7 @@ void recursive_directory_iterator::__adv
   }
 
 if (m_ec) {
-  path root = 

[libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 21:55:57 2018
New Revision: 337669

URL: http://llvm.org/viewvc/llvm-project?rev=337669=rev
Log:
Use possibly cached directory entry values when performing recursive directory 
iteration.

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=337669=337668=337669=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Sun Jul 22 
21:55:57 2018
@@ -359,13 +359,13 @@ bool recursive_directory_iterator::__try
   bool skip_rec = false;
   std::error_code m_ec;
   if (!rec_sym) {
-file_status st = curr_it.__entry_.symlink_status(m_ec);
+file_status st(curr_it.__entry_.__get_sym_ft(_ec));
 if (m_ec && status_known(st))
   m_ec.clear();
 if (m_ec || is_symlink(st) || !is_directory(st))
   skip_rec = true;
   } else {
-file_status st = curr_it.__entry_.status(m_ec);
+file_status st(curr_it.__entry_.__get_ft(_ec));
 if (m_ec && status_known(st))
   m_ec.clear();
 if (m_ec || !is_directory(st))


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


[libcxx] r337666 - Fix use of C++14 syntax in C++11 filesystem tests.

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 20:41:46 2018
New Revision: 337666

URL: http://llvm.org/viewvc/llvm-project?rev=337666=rev
Log:
Fix use of C++14 syntax in C++11 filesystem tests.

Modified:
libcxx/trunk/test/support/format_string.hpp

Modified: libcxx/trunk/test/support/format_string.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/format_string.hpp?rev=337666=337665=337666=diff
==
--- libcxx/trunk/test/support/format_string.hpp (original)
+++ libcxx/trunk/test/support/format_string.hpp Sun Jul 22 20:41:46 2018
@@ -11,7 +11,9 @@ inline std::string format_string_imp(con
   // we might need a second shot at this, so pre-emptivly make a copy
   struct GuardVAList {
 va_list& target;
-bool active = true;
+bool active;
+GuardVAList(va_list& target) : target(target), active(true) {}
+
 void clear() {
   if (active)
 va_end(target);
@@ -24,11 +26,11 @@ inline std::string format_string_imp(con
   };
   va_list args;
   va_start(args, msg);
-  GuardVAList args_guard = {args};
+  GuardVAList args_guard(args);
 
   va_list args_cp;
   va_copy(args_cp, args);
-  GuardVAList args_copy_guard = {args_cp};
+  GuardVAList args_copy_guard(args_cp);
 
   std::array local_buff;
   std::size_t size = local_buff.size();


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


[libcxx] r337665 - Work around various GCC 4.9 build errors

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 20:06:57 2018
New Revision: 337665

URL: http://llvm.org/viewvc/llvm-project?rev=337665=rev
Log:
Work around various GCC 4.9 build errors

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337665=337664=337665=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Sun Jul 22 
20:06:57 2018
@@ -72,6 +72,7 @@ static std::string format_string_imp(con
   struct GuardVAList {
 va_list& target;
 bool active = true;
+GuardVAList(va_list ) : target(target), active(true) {}
 void clear() {
   if (active)
 va_end(target);
@@ -84,11 +85,11 @@ static std::string format_string_imp(con
   };
   va_list args;
   va_start(args, msg);
-  GuardVAList args_guard = {args};
+  GuardVAList args_guard(args);
 
   va_list args_cp;
   va_copy(args_cp, args);
-  GuardVAList args_copy_guard = {args_cp};
+  GuardVAList args_copy_guard(args_cp);
 
   std::array local_buff;
   std::size_t size = local_buff.size();
@@ -131,7 +132,7 @@ std::error_code capture_errno() {
 template 
 T error_value();
 template <>
-constexpr void error_value() {}
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value() {}
 template <>
 constexpr bool error_value() {
   return false;
@@ -141,7 +142,7 @@ constexpr uintmax_t error_value
-constexpr file_time_type error_value() {
+_LIBCPP_CONSTEXPR_AFTER_CXX11 file_time_type error_value() {
   return file_time_type::min();
 }
 template <>
@@ -369,7 +370,7 @@ TimeSpec extract_atime(StatT const& st)
 using TimeStruct = struct ::timeval;
 using TimeStructArray = TimeStruct[2];
 #else
-using TimeStruct = struct ::timespec;
+using TimeStruct = TimeSpec;
 using TimeStructArray = TimeStruct[2];
 #endif
 
@@ -413,8 +414,6 @@ bool SetTimeStructTo(TimeStruct& TS, fil
 
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
-#if defined(__GNUC__)
-#pragma GCC diagnostic pop
-#endif
+
 
 #endif // FILESYSTEM_COMMON_H

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337665=337664=337665=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Sun Jul 22 20:06:57 
2018
@@ -36,6 +36,12 @@
 # define _LIBCPP_USE_COPYFILE
 #endif
 
+#if defined(_LIBCPP_COMPILER_GCC)
+#if _GNUC_VER < 500
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
 filesystem_error::~filesystem_error() {}
@@ -446,7 +452,7 @@ bool stat_equivalent(const StatT& st1, c
 file_status FileDescriptor::refresh_status(std::error_code& ec) {
   // FD must be open and good.
   m_status = file_status{};
-  m_stat = StatT{};
+  m_stat = {};
   std::error_code m_ec;
   if (::fstat(fd, _stat) == -1)
 m_ec = capture_errno();


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


[libcxx] r337664 - Implement filesystem_error::what() and improve reporting.

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 19:00:52 2018
New Revision: 337664

URL: http://llvm.org/viewvc/llvm-project?rev=337664=rev
Log:
Implement filesystem_error::what() and improve reporting.

This patch implements the `what()` for filesystem errors. The message
includes the 'what_arg', any paths that were specified, and the
error code message.

Additionally this patch refactors how errors are created, making it easier
to report them correctly.

Added:
libcxx/trunk/test/support/format_string.hpp
Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
libcxx/trunk/src/experimental/filesystem/filesystem_common.h
libcxx/trunk/src/experimental/filesystem/operations.cpp

libcxx/trunk/test/libcxx/experimental/filesystem/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.mods/refresh.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_size.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.file_size/file_size.pass.cpp
libcxx/trunk/test/support/filesystem_test_helper.hpp
libcxx/trunk/www/cxx2a_status.html

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337664=337663=337664=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Sun Jul 22 19:00:52 2018
@@ -1265,40 +1265,51 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 filesystem_error(const string& __what, error_code __ec)
 : system_error(__ec, __what),
-  __paths_(make_shared<_Storage>(path(), path()))
-{}
+  __storage_(make_shared<_Storage>(path(), path())) {
+  __create_what(0);
+}
 
 _LIBCPP_INLINE_VISIBILITY
 filesystem_error(const string& __what, const path& __p1, error_code __ec)
 : system_error(__ec, __what),
-__paths_(make_shared<_Storage>(__p1, path()))
-{}
+  __storage_(make_shared<_Storage>(__p1, path())) {
+  __create_what(1);
+}
 
 _LIBCPP_INLINE_VISIBILITY
 filesystem_error(const string& __what, const path& __p1, const path& __p2,
  error_code __ec)
 : system_error(__ec, __what),
-  __paths_(make_shared<_Storage>(__p1, __p2))
-{}
+  __storage_(make_shared<_Storage>(__p1, __p2)) {
+  __create_what(2);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-const path& path1() const _NOEXCEPT {
-return __paths_->first;
-}
+const path& path1() const _NOEXCEPT { return __storage_->__p1_; }
 
 _LIBCPP_INLINE_VISIBILITY
-const path& path2() const _NOEXCEPT {
-return __paths_->second;
-}
+const path& path2() const _NOEXCEPT { return __storage_->__p2_; }
 
 ~filesystem_error() override; // key function
 
-// TODO(ericwf): Create a custom error message.
-//const char* what() const _NOEXCEPT;
+_LIBCPP_INLINE_VISIBILITY
+const char* what() const _NOEXCEPT override {
+  return __storage_->__what_.c_str();
+}
+
+_LIBCPP_FUNC_VIS
+void __create_what(int __num_paths);
 
-private:
-typedef pair _Storage;
-shared_ptr<_Storage> __paths_;
+  private:
+struct _Storage {
+  _LIBCPP_INLINE_VISIBILITY
+  _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) 
{}
+
+  path __p1_;
+  path __p2_;
+  string __what_;
+};
+shared_ptr<_Storage> __storage_;
 };
 
 template 
@@ -1315,7 +1326,6 @@ void __throw_filesystem_error(_Args&&...
 }
 #endif
 
-
 // operational functions
 
 _LIBCPP_FUNC_VIS
@@ -2226,12 +2236,13 @@ private:
 return;
   }
   if (__ec && (!__allow_dne || !__is_dne_error(__ec)))
-__throw_filesystem_error(__msg, __p_, _Path{}, __ec);
+__throw_filesystem_error(__msg, __p_, __ec);
 }
 
 _LIBCPP_INLINE_VISIBILITY
 void __refresh(error_code* __ec = nullptr) {
-  __handle_error("refresh", __ec, __do_refresh(), /*allow_dne*/ true);
+  __handle_error("in directory_entry::refresh", __ec, __do_refresh(),
+ /*allow_dne*/ true);
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2322,11 +2333,11 @@ private:
   case _RefreshNonSymlink: {
 error_code __m_ec;
 file_status __st(__get_ft(&__m_ec));
-  

[libcxxabi] r337662 - Add GCC 9 to XFAILs list for test

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 14:58:46 2018
New Revision: 337662

URL: http://llvm.org/viewvc/llvm-project?rev=337662=rev
Log:
Add GCC 9 to XFAILs list for test

Modified:
libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp

Modified: libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp?rev=337662=337661=337662=diff
==
--- libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp (original)
+++ libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp Sun Jul 22 
14:58:46 2018
@@ -13,7 +13,7 @@
 
 // GCC 7 and 8 support noexcept function types but this test still fails.
 // This is likely a bug in their implementation. Investigation needed.
-// XFAIL: gcc-7, gcc-8
+// XFAIL: gcc-7, gcc-8, gcc-9
 
 #include 
 


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


[libcxx] r337661 - Workaround bug in GCC trunk.

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 14:56:40 2018
New Revision: 337661

URL: http://llvm.org/viewvc/llvm-project?rev=337661=rev
Log:
Workaround bug in GCC trunk.

For some reason GCC ToT is failing to deduce the auto type for
a static data member from its initializer in some cases.

Though I'm sure the bug will be short lived, there is a trivial workaround for 
it.
So we might as well get the bot passing again.

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337661=337660=337661=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Sun Jul 22 
14:56:40 2018
@@ -94,18 +94,18 @@ using namespace chrono;
 template ::value>
 struct fs_time_util_base {
-  static constexpr auto max_seconds =
+  static constexpr seconds::rep max_seconds =
   duration_cast(FileTimeT::duration::max()).count();
 
-  static constexpr auto max_nsec =
+  static constexpr nanoseconds::rep max_nsec =
   duration_cast(FileTimeT::duration::max() -
  seconds(max_seconds))
   .count();
 
-  static constexpr auto min_seconds =
+  static constexpr seconds::rep min_seconds =
   duration_cast(FileTimeT::duration::min()).count();
 
-  static constexpr auto min_nsec_timespec =
+  static constexpr nanoseconds::rep min_nsec_timespec =
   duration_cast(
   (FileTimeT::duration::min() - seconds(min_seconds)) + seconds(1))
   .count();


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


[libcxx] r337659 - Harden copy_file even more.

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 14:15:15 2018
New Revision: 337659

URL: http://llvm.org/viewvc/llvm-project?rev=337659=rev
Log:
Harden copy_file even more.

This patch removes the O_CREAT open flag when we first
attempt to open the destination file but we expect it to
already exist.

This theoretically avoids the possibility that it was removed
between when we first stat'ed it, and when we attempt to open it.

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337659=337658=337659=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Sun Jul 22 14:15:15 
2018
@@ -716,7 +716,7 @@ bool __copy_file(const path& from, const
   if (to_exists && skip_existing)
 return false;
 
-  auto ShouldCopy = [&]() {
+  bool ShouldCopy = [&]() {
 if (to_exists && update_existing) {
   auto from_time = detail::extract_mtime(from_stat);
   auto to_time = detail::extract_mtime(to_stat_path);
@@ -730,13 +730,15 @@ bool __copy_file(const path& from, const
 if (!to_exists || overwrite_existing)
   return true;
 return Error(make_error_code(errc::file_exists));
-  };
-  if (!ShouldCopy())
+  }();
+  if (!ShouldCopy)
 return false;
 
   // Don't truncate right away. We may not be opening the file we originally
   // looked at; we'll check this later.
-  int to_open_flags = O_WRONLY | O_CREAT;
+  int to_open_flags = O_WRONLY;
+  if (!to_exists)
+to_open_flags |= O_CREAT;
   FileDescriptor to_fd = FileDescriptor::create_with_status(
   , m_ec, to_open_flags, from_stat.st_mode);
   if (m_ec)
@@ -745,6 +747,7 @@ bool __copy_file(const path& from, const
   if (to_exists) {
 // Check that the file we initially stat'ed is equivalent to the one
 // we opened.
+// FIXME: report this better.
 if (!detail::stat_equivalent(to_stat_path, to_fd.get_stat()))
   return Error(make_error_code(errc::bad_file_descriptor));
 
@@ -761,7 +764,6 @@ bool __copy_file(const path& from, const
   }
 
   return true;
-
 }
 
 void __copy_symlink(const path& existing_symlink, const path& new_symlink,


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


[libcxx] r337658 - fix test failures with older clang versions

2018-07-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 22 13:50:16 2018
New Revision: 337658

URL: http://llvm.org/viewvc/llvm-project?rev=337658=rev
Log:
fix test failures with older clang versions

Added:

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.cons/default_const.pass.cpp
Modified:

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_size.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp

Added: 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.cons/default_const.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.cons/default_const.pass.cpp?rev=337658=auto
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.cons/default_const.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.cons/default_const.pass.cpp
 Sun Jul 22 13:50:16 2018
@@ -0,0 +1,32 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+// XFAIL: apple-clang-7, clang-3.7, clang-3.8
+
+// 
+
+// class directory_entry
+
+//  directory_entry() noexcept = default;
+
+#include "filesystem_include.hpp"
+#include 
+#include 
+
+int main() {
+  using namespace fs;
+  // Default
+  {
+
static_assert(std::is_nothrow_default_constructible::value,
+  "directory_entry must have a nothrow default constructor");
+const directory_entry e;
+assert(e.path() == path());
+  }
+}

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_size.pass.cpp?rev=337658=337657=337658=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_size.pass.cpp
 Sun Jul 22 13:50:16 2018
@@ -30,7 +30,7 @@ TEST_SUITE(directory_entry_obs_testsuite
 TEST_CASE(signatures) {
   using namespace fs;
   {
-const fs::directory_entry e;
+const fs::directory_entry e = {};
 std::error_code ec;
 static_assert(std::is_same::value, "");
 static_assert(std::is_same::value,

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp?rev=337658=337657=337658=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
 Sun Jul 22 13:50:16 2018
@@ -32,7 +32,7 @@ TEST_CASE(file_dne) {
 
 TEST_CASE(signatures) {
   using namespace fs;
-  const directory_entry e;
+  const directory_entry e = {};
   std::error_code ec;
 #define TEST_FUNC(name)
\
   static_assert(std::is_same::value, 
\

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp?rev=337658=337657=337658=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
 Sun Jul 22 13:50:16 2018
@@ -28,7 +28,7 @@ TEST_SUITE(directory_entry_obs_testsuite
 TEST_CASE(signatures) {
   using namespace fs;
   {
-const 

[libcxx] r337649 - Implement a better copy_file.

2018-07-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jul 21 19:00:53 2018
New Revision: 337649

URL: http://llvm.org/viewvc/llvm-project?rev=337649=rev
Log:
Implement a better copy_file.

This patch improves both the performance, and the safety of the
copy_file implementation.

The performance improvements are achieved by using sendfile on
Linux and copyfile on OS X when available.

The TOCTOU hardening is achieved by opening the source and
destination files and then using fstat to check their attributes to
see if we can copy them.

Unfortunately for the destination file, there is no way to open
it without accidentally creating it, so we first have to use
stat to determine if it exists, and if we should copy to it.
Then, once we're sure we should try to copy, we open the dest
file and ensure it names the same entity we previously stat'ed.

Added:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp
Modified:
libcxx/trunk/include/fstream
libcxx/trunk/src/experimental/filesystem/operations.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
libcxx/trunk/test/support/filesystem_test_helper.hpp
libcxx/trunk/test/support/rapid-cxx-test.hpp

Modified: libcxx/trunk/include/fstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=337649=337648=337649=diff
==
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Sat Jul 21 19:00:53 2018
@@ -170,6 +170,7 @@ typedef basic_fstream wfstream;
 #include 
 #include <__locale>
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -217,10 +218,17 @@ public:
 #endif
 _LIBCPP_INLINE_VISIBILITY
 basic_filebuf* open(const string& __s, ios_base::openmode __mode);
+
+_LIBCPP_INLINE_VISIBILITY
+basic_filebuf* __open(int __fd, ios_base::openmode __mode);
 #endif
 basic_filebuf* close();
 
-protected:
+_LIBCPP_INLINE_VISIBILITY
+inline static const char*
+__make_mdstring(ios_base::openmode __mode) _NOEXCEPT;
+
+  protected:
 // 27.9.1.5 Overridden virtual functions:
 virtual int_type underflow();
 virtual int_type pbackfail(int_type __c = traits_type::eof());
@@ -234,25 +242,25 @@ protected:
 virtual void imbue(const locale& __loc);
 
 private:
-char*   __extbuf_;
-const char* __extbufnext_;
-const char* __extbufend_;
-char __extbuf_min_[8];
-size_t __ebs_;
-char_type* __intbuf_;
-size_t __ibs_;
-FILE* __file_;
-const codecvt* __cv_;
-state_type __st_;
-state_type __st_last_;
-ios_base::openmode __om_;
-ios_base::openmode __cm_;
-bool __owns_eb_;
-bool __owns_ib_;
-bool __always_noconv_;
+  char* __extbuf_;
+  const char* __extbufnext_;
+  const char* __extbufend_;
+  char __extbuf_min_[8];
+  size_t __ebs_;
+  char_type* __intbuf_;
+  size_t __ibs_;
+  FILE* __file_;
+  const codecvt* __cv_;
+  state_type __st_;
+  state_type __st_last_;
+  ios_base::openmode __om_;
+  ios_base::openmode __cm_;
+  bool __owns_eb_;
+  bool __owns_ib_;
+  bool __always_noconv_;
 
-bool __read_mode();
-void __write_mode();
+  bool __read_mode();
+  void __write_mode();
 };
 
 template 
@@ -473,6 +481,46 @@ basic_filebuf<_CharT, _Traits>::is_open(
 return __file_ != 0;
 }
 
+template 
+const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(
+ios_base::openmode __mode) _NOEXCEPT {
+  switch (__mode & ~ios_base::ate) {
+  case ios_base::out:
+  case ios_base::out | ios_base::trunc:
+return "w";
+  case ios_base::out | ios_base::app:
+  case ios_base::app:
+return "a";
+  case ios_base::in:
+return "r";
+  case ios_base::in | ios_base::out:
+return "r+";
+  case ios_base::in | ios_base::out | ios_base::trunc:
+return "w+";
+  case ios_base::in | ios_base::out | ios_base::app:
+  case ios_base::in | ios_base::app:
+return "a+";
+  case ios_base::out | ios_base::binary:
+  case ios_base::out | ios_base::trunc | ios_base::binary:
+return "wb";
+  case ios_base::out | ios_base::app | ios_base::binary:
+  case ios_base::app | ios_base::binary:
+return "ab";
+  case ios_base::in | ios_base::binary:
+return "rb";
+  case ios_base::in | ios_base::out | ios_base::binary:
+return "r+b";
+  case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+return "w+b";
+  case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+  case ios_base::in | ios_base::app | ios_base::binary:
+return "a+b";
+  default:
+return nullptr;
+  }
+  _LIBCPP_UNREACHABLE();
+}
+
 #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 template 
 basic_filebuf<_CharT, _Traits>*
@@ -481,79 +529,49 @@ basic_filebuf<_CharT, _Traits>::open(con
 basic_filebuf<_CharT, _Traits>* __rt = 0;
 if (__file_ == 0)
 {
+  if (const char* __mdstr = __make_mdstring(__mode)) 

[libcxx] r337532 - adjust incorrect comment

2018-07-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jul 20 01:36:45 2018
New Revision: 337532

URL: http://llvm.org/viewvc/llvm-project?rev=337532=rev
Log:
adjust incorrect comment

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337532=337531=337532=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Fri Jul 20 01:36:45 
2018
@@ -1426,7 +1426,8 @@ error_code directory_entry::__do_refresh
   __data_.__cache_type_ = directory_entry::_RefreshSymlinkUnresolved;
   return error_code{};
 }
-// Otherwise, we resolved the link as not existing. That's OK.
+// Otherwise, we either resolved the link, potentially as not existing.
+// That's OK.
 __data_.__cache_type_ = directory_entry::_RefreshSymlink;
   }
 


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


[libcxx] r337520 - Fix two test failures in

2018-07-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 19 18:51:48 2018
New Revision: 337520

URL: http://llvm.org/viewvc/llvm-project?rev=337520=rev
Log:
Fix two test failures in 

First,  didn't correctly guard
against min/max macros. This adds the proper push/pop macro guards.

Second, an internal time helper had been renamed but the test for
it hadn't been updated. This patch updates those tests.

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337520=337519=337520=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Thu Jul 19 18:51:48 2018
@@ -251,6 +251,9 @@
 #pragma GCC system_header
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 #define __cpp_lib_experimental_filesystem 201406
 
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
@@ -2647,4 +2650,6 @@ recursive_directory_iterator end(const r
 
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
+_LIBCPP_POP_MACROS
+
 #endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM

Modified: 
libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp?rev=337520=337519=337520=diff
==
--- libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp 
(original)
+++ libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp 
Thu Jul 19 18:51:48 2018
@@ -28,7 +28,7 @@
 using namespace std::chrono;
 namespace fs = std::experimental::filesystem;
 using fs::file_time_type;
-using fs::detail::fs_time_util;
+using fs::detail::time_util::fs_time_util;
 
 enum TestKind { TK_64Bit, TK_32Bit, TK_FloatingPoint };
 


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


[libcxx] r337519 - Use _LIBCPP_UNREACHABLE to convince GCC that non-void functions actually always return

2018-07-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 19 18:44:33 2018
New Revision: 337519

URL: http://llvm.org/viewvc/llvm-project?rev=337519=rev
Log:
Use _LIBCPP_UNREACHABLE to convince GCC that non-void functions actually always 
return

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337519=337518=337519=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Thu Jul 19 18:44:33 2018
@@ -232,6 +232,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2250,6 +2251,7 @@ private:
   __ec->clear();
 return __data_.__type_;
   }
+  _LIBCPP_UNREACHABLE();
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2270,6 +2272,7 @@ private:
 return __data_.__type_;
   }
   }
+  _LIBCPP_UNREACHABLE();
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2284,6 +2287,7 @@ private:
   case _RefreshSymlink:
 return file_status(__get_ft(__ec), __data_.__non_sym_perms_);
   }
+  _LIBCPP_UNREACHABLE();
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2299,6 +2303,7 @@ private:
   case _RefreshSymlinkUnresolved:
 return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);
   }
+  _LIBCPP_UNREACHABLE();
 }
 
 
@@ -2324,6 +2329,7 @@ private:
 return __data_.__size_;
   }
   }
+  _LIBCPP_UNREACHABLE();
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2342,6 +2348,7 @@ private:
 return __data_.__nlink_;
   }
   }
+  _LIBCPP_UNREACHABLE();
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2364,6 +2371,7 @@ private:
 return __data_.__write_time_;
   }
   }
+  _LIBCPP_UNREACHABLE();
 }
 private:
 _Path __p_;

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337519=337518=337519=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Thu Jul 19 
18:44:33 2018
@@ -228,8 +228,8 @@ public:
 } // namespace time_util
 
 
-using TimeSpec = struct timespec;
-using StatT = struct stat;
+using TimeSpec = struct ::timespec;
+using StatT = struct ::stat;
 
 using FSTime = time_util::fs_time_util;
 


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


[libcxx] r337517 - cleanup test assertion inside library

2018-07-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jul 19 18:25:06 2018
New Revision: 337517

URL: http://llvm.org/viewvc/llvm-project?rev=337517=rev
Log:
cleanup test assertion inside library

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337517=337516=337517=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Thu Jul 19 18:25:06 
2018
@@ -25,11 +25,6 @@
 #include   /* values for fchmodat */
 #include 
 
-#ifdef NDEBUG
-#undef NDEBUG
-#endif
-#include 
-
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
 
 filesystem_error::~filesystem_error() {}
@@ -298,7 +293,6 @@ file_status create_file_status(std::erro
struct ::stat& path_stat, std::error_code* ec) {
   if (ec)
 *ec = m_ec;
-  // assert(m_ec.value() != ENOTDIR);
   if (m_ec && (m_ec.value() == ENOENT || m_ec.value() == ENOTDIR)) {
 return file_status(file_type::not_found);
   } else if (m_ec) {


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


[libcxx] r337235 - Address "always inline function is not always inlinable" warning with GCC.

2018-07-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 16 22:48:48 2018
New Revision: 337235

URL: http://llvm.org/viewvc/llvm-project?rev=337235=rev
Log:
Address "always inline function is not always inlinable" warning with GCC.

When an always_inline function is used prior to the functions definition,
the compiler may not be able to inline it as requested by the attribute.
GCC flags the `basic_string(CharT const*)` function as one such example.

This patch supresses the warning, and the problem, by moving the
definition of the string constructor to the inline declaration.
This ensures the body is available when it is first ODR used.

Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=337235=337234=337235=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Mon Jul 16 22:48:48 2018
@@ -807,8 +807,14 @@ public:
 #endif  // _LIBCPP_CXX03_LANG
 
 template ::value, 
nullptr_t>::type>
-_LIBCPP_INLINE_VISIBILITY
-basic_string(const _CharT* __s);
+_LIBCPP_INLINE_VISIBILITY
+basic_string(const _CharT* __s) {
+  _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected 
nullptr");
+  __init(__s, traits_type::length(__s));
+#   if _LIBCPP_DEBUG_LEVEL >= 2
+  __get_db()->__insert_c(this);
+#   endif
+}
 
 template ::value, 
nullptr_t>::type>
 _LIBCPP_INLINE_VISIBILITY
@@ -1774,17 +1780,6 @@ basic_string<_CharT, _Traits, _Allocator
 }
 
 template 
-template 
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s)
-{
-_LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected 
nullptr");
-__init(__s, traits_type::length(__s));
-#if _LIBCPP_DEBUG_LEVEL >= 2
-__get_db()->__insert_c(this);
-#endif
-}
-
-template 
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, 
const _Allocator& __a)
 : __r_(__second_tag(), __a)


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


[libcxx] r337205 - Fix PR38160 - init_priority attribute not supported by GCC on Apple.

2018-07-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 16 13:01:59 2018
New Revision: 337205

URL: http://llvm.org/viewvc/llvm-project?rev=337205=rev
Log:
Fix PR38160 - init_priority attribute not supported by GCC on Apple.

This patch guards the use of __attribute__((init_priority(101)))
within memory_resource.cpp when building with compilers that don't
support it. Specifically GCC on Apple platforms, and MSVC.

Modified:
libcxx/trunk/src/experimental/memory_resource.cpp

Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=337205=337204=337205=diff
==
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Mon Jul 16 13:01:59 2018
@@ -68,12 +68,23 @@ union ResourceInitHelper {
   _LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}
   ~ResourceInitHelper() {}
 };
+
+// Detect if the init_priority attribute is supported.
+#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
+  || defined(_LIBCPP_COMPILER_MSVC)
+// GCC on Apple doesn't support the init priority attribute,
+// and MSVC doesn't support any GCC attributes.
+# define _LIBCPP_INIT_PRIORITY_MAX
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#endif
+
 // When compiled in C++14 this initialization should be a constant expression.
 // Only in C++11 is "init_priority" needed to ensure initialization order.
 #if _LIBCPP_STD_VER > 11
 _LIBCPP_SAFE_STATIC
 #endif
-ResourceInitHelper res_init  __attribute__((init_priority (101)));
+ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
 
 } // end namespace
 


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


[libcxx] r336666 - Remove BUILD file from google-benchmark

2018-07-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jul 10 06:25:26 2018
New Revision: 33

URL: http://llvm.org/viewvc/llvm-project?rev=33=rev
Log:
Remove BUILD file from google-benchmark

Removed:
libcxx/trunk/utils/google-benchmark/test/BUILD

Removed: libcxx/trunk/utils/google-benchmark/test/BUILD
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/google-benchmark/test/BUILD?rev=336665=auto
==
--- libcxx/trunk/utils/google-benchmark/test/BUILD (original)
+++ libcxx/trunk/utils/google-benchmark/test/BUILD (removed)
@@ -1,65 +0,0 @@
-TEST_COPTS = [
-"-pedantic",
-"-pedantic-errors",
-"-std=c++11",
-"-Wall",
-"-Wextra",
-"-Wshadow",
-#"-Wshorten-64-to-32",
-"-Wfloat-equal",
-"-fstrict-aliasing",
-]
-
-PER_SRC_COPTS = ({
-"cxx03_test.cc": ["-std=c++03"],
-# Some of the issues with DoNotOptimize only occur when optimization is 
enabled
-"donotoptimize_test.cc": ["-O3"],
-})
-
-
-TEST_ARGS = ["--benchmark_min_time=0.01"]
-
-PER_SRC_TEST_ARGS = ({
-"user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"],
-})
-
-cc_library(
-name = "output_test_helper",
-testonly = 1,
-srcs = ["output_test_helper.cc"],
-hdrs = ["output_test.h"],
-copts = TEST_COPTS,
-deps = [
-"//:benchmark",
-"//:benchmark_internal_headers",
-],
-)
-
-[
-  cc_test(
-name = test_src[:-len(".cc")],
-size = "small",
-srcs = [test_src],
-args = TEST_ARGS + PER_SRC_TEST_ARGS.get(test_src, []),
-copts = TEST_COPTS + PER_SRC_COPTS.get(test_src, []),
-deps = [
-":output_test_helper",
-"//:benchmark",
-"//:benchmark_internal_headers",
-"@com_google_googletest//:gtest",
-] + (
-["@com_google_googletest//:gtest_main"] if 
(test_src[-len("gtest.cc"):] == "gtest.cc") else []
-),
-  # FIXME: Add support for assembly tests to bazel.
-  # See Issue #556
-  # https://github.com/google/benchmark/issues/556
-  ) for test_src in glob(["*test.cc"], exclude = ["*_assembly_test.cc", 
"link_main_test.cc"])
-]
-
-cc_test(
-name = "link_main_test",
-size = "small",
-srcs = ["link_main_test.cc"],
-copts = TEST_COPTS,
-deps = ["//:benchmark_main"],
-)


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


  1   2   3   4   5   6   7   8   9   10   >