[PATCH] D49657: [clangd] Make SymbolLocation => bool conversion explicitly.
hokein created this revision. hokein added a reviewer: sammccall. Herald added subscribers: arphaman, jkorous, MaskRay, ioeric, ilya-biryukov. The implicit bool conversion could happen superisingly, e.g. when checking `if (Loc1 == Loc2)`, the compiler will convert SymbolLocation to bool before comparing (because we don't define operator `==` for SymbolLocation). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49657 Files: clangd/index/Index.h Index: clangd/index/Index.h === --- clangd/index/Index.h +++ clangd/index/Index.h @@ -30,6 +30,9 @@ uint32_t Line = 0; // 0-based // Using UTF-16 code units. uint32_t Column = 0; // 0-based +bool operator==(const Position& P) const { + return Line == P.Line && Column == P.Column; +} }; // The URI of the source file where a symbol occurs. @@ -39,7 +42,11 @@ Position Start; Position End; - operator bool() const { return !FileURI.empty(); } + explicit operator bool() const { return !FileURI.empty(); } + bool operator==(const SymbolLocation& Loc) const { +return std::tie(FileURI, Start, End) == + std::tie(Loc.FileURI, Loc.Start, Loc.End); + } }; llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolLocation &); Index: clangd/index/Index.h === --- clangd/index/Index.h +++ clangd/index/Index.h @@ -30,6 +30,9 @@ uint32_t Line = 0; // 0-based // Using UTF-16 code units. uint32_t Column = 0; // 0-based +bool operator==(const Position& P) const { + return Line == P.Line && Column == P.Column; +} }; // The URI of the source file where a symbol occurs. @@ -39,7 +42,11 @@ Position Start; Position End; - operator bool() const { return !FileURI.empty(); } + explicit operator bool() const { return !FileURI.empty(); } + bool operator==(const SymbolLocation& Loc) const { +return std::tie(FileURI, Start, End) == + std::tie(Loc.FileURI, Loc.Start, Loc.End); + } }; llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolLocation &); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r337627 - Fold dangling-field warning into general initialization lifetime checks.
Reverted in r337671 On Mon, Jul 23, 2018 at 8:24 AM Ilya Biryukov wrote: > Hi Richard, > > this commit seems to cause invalid warning in the following example: > > struct foo { > foo(char *x) : x_(&x[10]) {} // > private: > char *x_; > }; > > The warning itself: > 1.cpp:2:21: warning: initializing pointer member 'x_' with the stack > address of parameter 'x' [-Wdangling-field] > > I'll revert the change to unbreak our integrate. > > > On Sat, Jul 21, 2018 at 12:31 AM Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: rsmith >> Date: Fri Jul 20 15:25:55 2018 >> New Revision: 337627 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=337627&view=rev >> Log: >> Fold dangling-field warning into general initialization lifetime checks. >> >> Modified: >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> cfe/trunk/lib/Sema/SemaDeclCXX.cpp >> cfe/trunk/lib/Sema/SemaInit.cpp >> cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp >> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=337627&r1=337626&r2=337627&view=diff >> >> == >> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 20 >> 15:25:55 2018 >> @@ -7870,11 +7870,11 @@ def note_ref_var_local_bind : Note< >> // Check for initializing a member variable with the address or a >> reference to >> // a constructor parameter. >> def warn_bind_ref_member_to_parameter : Warning< >> - "binding reference member %0 to stack allocated parameter %1">, >> - InGroup; >> + "binding reference member %0 to stack allocated " >> + "%select{variable|parameter}2 %1">, InGroup; >> def warn_init_ptr_member_to_parameter_addr : Warning< >> - "initializing pointer member %0 with the stack address of parameter >> %1">, >> - InGroup; >> + "initializing pointer member %0 with the stack address of " >> + "%select{variable|parameter}2 %1">, InGroup; >> def note_ref_or_ptr_member_declared_here : Note< >>"%select{reference|pointer}0 member declared here">; >> >> >> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=337627&r1=337626&r2=337627&view=diff >> >> == >> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jul 20 15:25:55 2018 >> @@ -3946,53 +3946,6 @@ Sema::BuildMemInitializer(Decl *Construc >>return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, >> EllipsisLoc); >> } >> >> -/// Checks a member initializer expression for cases where reference (or >> -/// pointer) members are bound to by-value parameters (or their >> addresses). >> -static void CheckForDanglingReferenceOrPointer(Sema &S, ValueDecl >> *Member, >> - Expr *Init, >> - SourceLocation IdLoc) { >> - QualType MemberTy = Member->getType(); >> - >> - // We only handle pointers and references currently. >> - // FIXME: Would this be relevant for ObjC object pointers? Or block >> pointers? >> - if (!MemberTy->isReferenceType() && !MemberTy->isPointerType()) >> -return; >> - >> - const bool IsPointer = MemberTy->isPointerType(); >> - if (IsPointer) { >> -if (const UnaryOperator *Op >> - = dyn_cast(Init->IgnoreParenImpCasts())) { >> - // The only case we're worried about with pointers requires taking >> the >> - // address. >> - if (Op->getOpcode() != UO_AddrOf) >> -return; >> - >> - Init = Op->getSubExpr(); >> -} else { >> - // We only handle address-of expression initializers for pointers. >> - return; >> -} >> - } >> - >> - if (const DeclRefExpr *DRE = >> dyn_cast(Init->IgnoreParens())) { >> -// We only warn when referring to a non-reference parameter >> declaration. >> -const ParmVarDecl *Parameter = dyn_cast(DRE->getDecl()); >> -if (!Parameter || Parameter->getType()->isReferenceType()) >> - return; >> - >> -S.Diag(Init->getExprLoc(), >> - IsPointer ? diag::warn_init_ptr_member_to_parameter_addr >> - : diag::warn_bind_ref_member_to_parameter) >> - << Member << Parameter << Init->getSourceRange(); >> - } else { >> -// Other initializers are fine. >> -return; >> - } >> - >> - S.Diag(Member->getLocation(), >> diag::note_ref_or_ptr_member_declared_here) >> -<< (unsigned)IsPointer; >> -} >> - >> MemInitResult >> Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init, >> SourceLocation IdLoc) { >> @@ -4047,8 +4000,6 @@ Sema::Build
r337671 - Revert "Fold dangling-field warning into general initialization lifetime checks."
Author: ibiryukov Date: Sun Jul 22 23:32:36 2018 New Revision: 337671 URL: http://llvm.org/viewvc/llvm-project?rev=337671&view=rev Log: Revert "Fold dangling-field warning into general initialization lifetime checks." This reverts commit r337627. After the change, clang started producing invalid warning on the following code: struct foo { foo(char *x) : x_(&x[10]) {} private: char *x_; }; 1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field] Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=337671&r1=337670&r2=337671&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jul 22 23:32:36 2018 @@ -7870,11 +7870,11 @@ def note_ref_var_local_bind : Note< // Check for initializing a member variable with the address or a reference to // a constructor parameter. def warn_bind_ref_member_to_parameter : Warning< - "binding reference member %0 to stack allocated " - "%select{variable|parameter}2 %1">, InGroup; + "binding reference member %0 to stack allocated parameter %1">, + InGroup; def warn_init_ptr_member_to_parameter_addr : Warning< - "initializing pointer member %0 with the stack address of " - "%select{variable|parameter}2 %1">, InGroup; + "initializing pointer member %0 with the stack address of parameter %1">, + InGroup; def note_ref_or_ptr_member_declared_here : Note< "%select{reference|pointer}0 member declared here">; Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=337671&r1=337670&r2=337671&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Jul 22 23:32:36 2018 @@ -3946,6 +3946,53 @@ Sema::BuildMemInitializer(Decl *Construc return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc); } +/// Checks a member initializer expression for cases where reference (or +/// pointer) members are bound to by-value parameters (or their addresses). +static void CheckForDanglingReferenceOrPointer(Sema &S, ValueDecl *Member, + Expr *Init, + SourceLocation IdLoc) { + QualType MemberTy = Member->getType(); + + // We only handle pointers and references currently. + // FIXME: Would this be relevant for ObjC object pointers? Or block pointers? + if (!MemberTy->isReferenceType() && !MemberTy->isPointerType()) +return; + + const bool IsPointer = MemberTy->isPointerType(); + if (IsPointer) { +if (const UnaryOperator *Op + = dyn_cast(Init->IgnoreParenImpCasts())) { + // The only case we're worried about with pointers requires taking the + // address. + if (Op->getOpcode() != UO_AddrOf) +return; + + Init = Op->getSubExpr(); +} else { + // We only handle address-of expression initializers for pointers. + return; +} + } + + if (const DeclRefExpr *DRE = dyn_cast(Init->IgnoreParens())) { +// We only warn when referring to a non-reference parameter declaration. +const ParmVarDecl *Parameter = dyn_cast(DRE->getDecl()); +if (!Parameter || Parameter->getType()->isReferenceType()) + return; + +S.Diag(Init->getExprLoc(), + IsPointer ? diag::warn_init_ptr_member_to_parameter_addr + : diag::warn_bind_ref_member_to_parameter) + << Member << Parameter << Init->getSourceRange(); + } else { +// Other initializers are fine. +return; + } + + S.Diag(Member->getLocation(), diag::note_ref_or_ptr_member_declared_here) +<< (unsigned)IsPointer; +} + MemInitResult Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc) { @@ -4000,6 +4047,8 @@ Sema::BuildMemberInitializer(ValueDecl * if (MemberInit.isInvalid()) return true; +CheckForDanglingReferenceOrPointer(*this, Member, MemberInit.get(), IdLoc); + // C++11 [class.base.init]p7: // The initialization of each base and member constitutes a // full-expression. Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=337671&r1=337670&r2=337671&view=diff == --- cfe/trunk/
Re: r337627 - Fold dangling-field warning into general initialization lifetime checks.
Hi Richard, this commit seems to cause invalid warning in the following example: struct foo { foo(char *x) : x_(&x[10]) {} // private: char *x_; }; The warning itself: 1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field] I'll revert the change to unbreak our integrate. On Sat, Jul 21, 2018 at 12:31 AM Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: rsmith > Date: Fri Jul 20 15:25:55 2018 > New Revision: 337627 > > URL: http://llvm.org/viewvc/llvm-project?rev=337627&view=rev > Log: > Fold dangling-field warning into general initialization lifetime checks. > > Modified: > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > cfe/trunk/lib/Sema/SemaInit.cpp > cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp > cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=337627&r1=337626&r2=337627&view=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 20 > 15:25:55 2018 > @@ -7870,11 +7870,11 @@ def note_ref_var_local_bind : Note< > // Check for initializing a member variable with the address or a > reference to > // a constructor parameter. > def warn_bind_ref_member_to_parameter : Warning< > - "binding reference member %0 to stack allocated parameter %1">, > - InGroup; > + "binding reference member %0 to stack allocated " > + "%select{variable|parameter}2 %1">, InGroup; > def warn_init_ptr_member_to_parameter_addr : Warning< > - "initializing pointer member %0 with the stack address of parameter > %1">, > - InGroup; > + "initializing pointer member %0 with the stack address of " > + "%select{variable|parameter}2 %1">, InGroup; > def note_ref_or_ptr_member_declared_here : Note< >"%select{reference|pointer}0 member declared here">; > > > Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=337627&r1=337626&r2=337627&view=diff > > == > --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jul 20 15:25:55 2018 > @@ -3946,53 +3946,6 @@ Sema::BuildMemInitializer(Decl *Construc >return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, > EllipsisLoc); > } > > -/// Checks a member initializer expression for cases where reference (or > -/// pointer) members are bound to by-value parameters (or their > addresses). > -static void CheckForDanglingReferenceOrPointer(Sema &S, ValueDecl *Member, > - Expr *Init, > - SourceLocation IdLoc) { > - QualType MemberTy = Member->getType(); > - > - // We only handle pointers and references currently. > - // FIXME: Would this be relevant for ObjC object pointers? Or block > pointers? > - if (!MemberTy->isReferenceType() && !MemberTy->isPointerType()) > -return; > - > - const bool IsPointer = MemberTy->isPointerType(); > - if (IsPointer) { > -if (const UnaryOperator *Op > - = dyn_cast(Init->IgnoreParenImpCasts())) { > - // The only case we're worried about with pointers requires taking > the > - // address. > - if (Op->getOpcode() != UO_AddrOf) > -return; > - > - Init = Op->getSubExpr(); > -} else { > - // We only handle address-of expression initializers for pointers. > - return; > -} > - } > - > - if (const DeclRefExpr *DRE = > dyn_cast(Init->IgnoreParens())) { > -// We only warn when referring to a non-reference parameter > declaration. > -const ParmVarDecl *Parameter = dyn_cast(DRE->getDecl()); > -if (!Parameter || Parameter->getType()->isReferenceType()) > - return; > - > -S.Diag(Init->getExprLoc(), > - IsPointer ? diag::warn_init_ptr_member_to_parameter_addr > - : diag::warn_bind_ref_member_to_parameter) > - << Member << Parameter << Init->getSourceRange(); > - } else { > -// Other initializers are fine. > -return; > - } > - > - S.Diag(Member->getLocation(), > diag::note_ref_or_ptr_member_declared_here) > -<< (unsigned)IsPointer; > -} > - > MemInitResult > Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init, > SourceLocation IdLoc) { > @@ -4047,8 +4000,6 @@ Sema::BuildMemberInitializer(ValueDecl * > if (MemberInit.isInvalid()) >return true; > > -CheckForDanglingReferenceOrPointer(*this, Member, MemberInit.get(), > IdLoc); > - > // C++11 [class.base.init]p7: > /
[PATCH] D49643: [HIP] pass `-target-cpu` when running the device-mode compiler
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Thanks. This looks reasonable to me. https://reviews.llvm.org/D49643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r337670 - Revert "[CMake] Support statically linking dependencies only to shared or static library"
Author: phosek Date: Sun Jul 22 22:07:44 2018 New Revision: 337670 URL: http://llvm.org/viewvc/llvm-project?rev=337670&view=rev Log: Revert "[CMake] Support statically linking dependencies only to shared or static library" This reverts commit r337668: broke the cxxabi build when using Make. Modified: libcxx/trunk/CMakeLists.txt libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake libcxx/trunk/lib/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=337670&r1=337669&r2=337670&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Sun Jul 22 22:07:44 2018 @@ -155,14 +155,6 @@ endif() # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) -cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY - "Statically link the ABI library to static library" ON - "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF) - -cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY - "Statically link the ABI library to shared library" ON - "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF) - # Generate and install a linker script inplace of libc++.so. The linker script # will link libc++ to the correct ABI library. This option is on by default # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=337670&r1=337669&r2=337670&view=diff == --- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original) +++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Sun Jul 22 22:07:44 2018 @@ -96,10 +96,10 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") if (LIBCXX_CXX_ABI_INTREE) # Link against just-built "cxxabi" target. -if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) - set(CXXABI_LIBNAME cxxabi_static) +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) +set(CXXABI_LIBNAME cxxabi_static) else() - set(CXXABI_LIBNAME cxxabi_shared) +set(CXXABI_LIBNAME cxxabi_shared) endif() set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE) else() Modified: libcxx/trunk/lib/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=337670&r1=337669&r2=337670&view=diff == --- libcxx/trunk/lib/CMakeLists.txt (original) +++ libcxx/trunk/lib/CMakeLists.txt Sun Jul 22 22:07:44 2018 @@ -44,7 +44,7 @@ if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME ST set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON) endif() -if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic") add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}") add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive") @@ -259,14 +259,14 @@ if (LIBCXX_ENABLE_STATIC) list(APPEND LIBCXX_TARGETS "cxx_static") # Attempt to merge the libc++.a archive and the ABI library archive into one. - if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) + if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) set(MERGE_ARCHIVES_SEARCH_PATHS "") if (LIBCXX_CXX_ABI_LIBRARY_PATH) set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") endif() if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI)) - set(MERGE_ARCHIVES_ABI_TARGET "$") + set(MERGE_ARCHIVES_ABI_TARGET "$") else() set(MERGE_ARCHIVES_ABI_TARGET "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r337670 - Revert "[CMake] Support statically linking dependencies only to shared or static library"
Author: phosek Date: Sun Jul 22 22:07:44 2018 New Revision: 337670 URL: http://llvm.org/viewvc/llvm-project?rev=337670&view=rev Log: Revert "[CMake] Support statically linking dependencies only to shared or static library" This reverts commit r337668: broke the cxxabi build when using Make. Modified: libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/src/CMakeLists.txt Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=337670&r1=337669&r2=337670&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Sun Jul 22 22:07:44 2018 @@ -84,13 +84,6 @@ set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CAC option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON) option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON) -cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY - "Statically link the LLVM unwinder to static library" ON - "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF) -cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY - "Statically link the LLVM unwinder to shared library" ON - "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF) - option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF) # The default terminate handler attempts to demangle uncaught exceptions, which # causes extra I/O and demangling code to be pulled in. Modified: libcxxabi/trunk/src/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=337670&r1=337669&r2=337670&view=diff == --- libcxxabi/trunk/src/CMakeLists.txt (original) +++ libcxxabi/trunk/src/CMakeLists.txt Sun Jul 22 22:07:44 2018 @@ -61,27 +61,19 @@ if (LIBCXXABI_USE_LLVM_UNWINDER) # Prefer using the in-tree version of libunwind, either shared or static. If # none are found fall back to using -lunwind. # FIXME: Is it correct to prefer the static version of libunwind? - if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared) - elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_static) + if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_LIBRARIES unwind_shared) + elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_LIBRARIES unwind_static) else() -list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind) - endif() - if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_shared) - elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) - # We handle this by directly merging libunwind objects into libc++abi. - else() -list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind) +list(APPEND LIBCXXABI_LIBRARIES unwind) endif() else() add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s) endif() if (MINGW) # MINGW_LIBRARIES is defined in config-ix.cmake - list(APPEND LIBCXXABI_SHARED_LIBRARIES ${MINGW_LIBRARIES}) - list(APPEND LIBCXXABI_STATIC_LIBRARIES ${MINGW_LIBRARIES}) + list(APPEND LIBCXXABI_LIBRARIES ${MINGW_LIBRARIES}) endif() # Setup flags. @@ -138,7 +130,7 @@ if (LIBCXXABI_ENABLE_SHARED) if(COMMAND llvm_setup_rpath) llvm_setup_rpath(cxxabi_shared) endif() - target_link_libraries(cxxabi_shared ${LIBCXXABI_SHARED_LIBRARIES}) + target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES}) set_target_properties(cxxabi_shared PROPERTIES CXX_EXTENSIONS @@ -163,13 +155,13 @@ endif() # Build the static library. if (LIBCXXABI_ENABLE_STATIC) set(cxxabi_static_sources $) - if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) + if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER) if (TARGET unwind_static OR HAVE_LIBUNWIND) list(APPEND cxxabi_static_sources $) endif() endif() add_library(cxxabi_static STATIC ${cxxabi_static_sources}) - target_link_libraries(cxxabi_static ${LIBCXXABI_STATIC_LIBRARIES}) + target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES}) set_target_properties(cxxabi_static PROPERTIES CXX_EXTENSIONS ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r337669 - Use possibly cached directory entry values when performing recursive directory iteration.
Author: ericwf Date: Sun Jul 22 21:55:57 2018 New Revision: 337669 URL: http://llvm.org/viewvc/llvm-project?rev=337669&view=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&r1=337668&r2=337669&view=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(&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_.status(m_ec); +file_status st(curr_it.__entry_.__get_ft(&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
[libcxxabi] r337668 - [CMake] Support statically linking dependencies only to shared or static library
Author: phosek Date: Sun Jul 22 21:19:55 2018 New Revision: 337668 URL: http://llvm.org/viewvc/llvm-project?rev=337668&view=rev Log: [CMake] Support statically linking dependencies only to shared or static library Currently it's possible to select whether to statically link unwinder or the C++ ABI library, but this option applies to both the shared and static library. However, in some scenarios it may be desirable to only statically link unwinder and C++ ABI library into static C++ library since for shared C++ library we can rely on dynamic linking and linker scripts. This change enables selectively enabling or disabling statically linking only to shared or static library. Differential Revision: https://reviews.llvm.org/D49502 Modified: libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/src/CMakeLists.txt Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=337668&r1=337667&r2=337668&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Sun Jul 22 21:19:55 2018 @@ -84,6 +84,13 @@ set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CAC option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON) option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON) +cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY + "Statically link the LLVM unwinder to static library" ON + "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF) +cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY + "Statically link the LLVM unwinder to shared library" ON + "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF) + option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF) # The default terminate handler attempts to demangle uncaught exceptions, which # causes extra I/O and demangling code to be pulled in. Modified: libcxxabi/trunk/src/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=337668&r1=337667&r2=337668&view=diff == --- libcxxabi/trunk/src/CMakeLists.txt (original) +++ libcxxabi/trunk/src/CMakeLists.txt Sun Jul 22 21:19:55 2018 @@ -61,19 +61,27 @@ if (LIBCXXABI_USE_LLVM_UNWINDER) # Prefer using the in-tree version of libunwind, either shared or static. If # none are found fall back to using -lunwind. # FIXME: Is it correct to prefer the static version of libunwind? - if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_LIBRARIES unwind_shared) - elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_LIBRARIES unwind_static) + if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_static) else() -list(APPEND LIBCXXABI_LIBRARIES unwind) +list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind) + endif() + if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_shared) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) + # We handle this by directly merging libunwind objects into libc++abi. + else() +list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind) endif() else() add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s) endif() if (MINGW) # MINGW_LIBRARIES is defined in config-ix.cmake - list(APPEND LIBCXXABI_LIBRARIES ${MINGW_LIBRARIES}) + list(APPEND LIBCXXABI_SHARED_LIBRARIES ${MINGW_LIBRARIES}) + list(APPEND LIBCXXABI_STATIC_LIBRARIES ${MINGW_LIBRARIES}) endif() # Setup flags. @@ -130,7 +138,7 @@ if (LIBCXXABI_ENABLE_SHARED) if(COMMAND llvm_setup_rpath) llvm_setup_rpath(cxxabi_shared) endif() - target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_shared ${LIBCXXABI_SHARED_LIBRARIES}) set_target_properties(cxxabi_shared PROPERTIES CXX_EXTENSIONS @@ -155,13 +163,13 @@ endif() # Build the static library. if (LIBCXXABI_ENABLE_STATIC) set(cxxabi_static_sources $) - if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER) + if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) if (TARGET unwind_static OR HAVE_LIBUNWIND) list(APPEND cxxabi_static_sources $) endif() endif() add_library(cxxabi_static STATIC ${cxxabi_static_sources}) - target_link_libraries(cxx
[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rL337668: [CMake] Support statically linking dependencies only to shared or static library (authored by phosek, committed by ). Changed prior to commit: https://reviews.llvm.org/D49502?vs=156416&id=156722#toc Repository: rL LLVM https://reviews.llvm.org/D49502 Files: libcxx/trunk/CMakeLists.txt libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake libcxx/trunk/lib/CMakeLists.txt libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/src/CMakeLists.txt Index: libcxxabi/trunk/CMakeLists.txt === --- libcxxabi/trunk/CMakeLists.txt +++ libcxxabi/trunk/CMakeLists.txt @@ -84,6 +84,13 @@ option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON) option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON) +cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY + "Statically link the LLVM unwinder to static library" ON + "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF) +cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY + "Statically link the LLVM unwinder to shared library" ON + "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF) + option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF) # The default terminate handler attempts to demangle uncaught exceptions, which # causes extra I/O and demangling code to be pulled in. Index: libcxxabi/trunk/src/CMakeLists.txt === --- libcxxabi/trunk/src/CMakeLists.txt +++ libcxxabi/trunk/src/CMakeLists.txt @@ -61,19 +61,27 @@ # Prefer using the in-tree version of libunwind, either shared or static. If # none are found fall back to using -lunwind. # FIXME: Is it correct to prefer the static version of libunwind? - if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_LIBRARIES unwind_shared) - elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND)) -list(APPEND LIBCXXABI_LIBRARIES unwind_static) + if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_shared) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind_static) else() -list(APPEND LIBCXXABI_LIBRARIES unwind) +list(APPEND LIBCXXABI_SHARED_LIBRARIES unwind) + endif() + if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) +list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind_shared) + elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND)) + # We handle this by directly merging libunwind objects into libc++abi. + else() +list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind) endif() else() add_library_flags_if(LIBCXXABI_HAS_GCC_S_LIB gcc_s) endif() if (MINGW) # MINGW_LIBRARIES is defined in config-ix.cmake - list(APPEND LIBCXXABI_LIBRARIES ${MINGW_LIBRARIES}) + list(APPEND LIBCXXABI_SHARED_LIBRARIES ${MINGW_LIBRARIES}) + list(APPEND LIBCXXABI_STATIC_LIBRARIES ${MINGW_LIBRARIES}) endif() # Setup flags. @@ -130,7 +138,7 @@ if(COMMAND llvm_setup_rpath) llvm_setup_rpath(cxxabi_shared) endif() - target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_shared ${LIBCXXABI_SHARED_LIBRARIES}) set_target_properties(cxxabi_shared PROPERTIES CXX_EXTENSIONS @@ -155,13 +163,13 @@ # Build the static library. if (LIBCXXABI_ENABLE_STATIC) set(cxxabi_static_sources $) - if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER) + if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) if (TARGET unwind_static OR HAVE_LIBUNWIND) list(APPEND cxxabi_static_sources $) endif() endif() add_library(cxxabi_static STATIC ${cxxabi_static_sources}) - target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_static ${LIBCXXABI_STATIC_LIBRARIES}) set_target_properties(cxxabi_static PROPERTIES CXX_EXTENSIONS Index: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake === --- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake +++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake @@ -96,10 +96,10 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") if (LIBCXX_CXX_ABI_INTREE) # Link against just-built "cxxabi" target. -if (LIBCXX_ENABLE_STATIC_A
[libcxx] r337668 - [CMake] Support statically linking dependencies only to shared or static library
Author: phosek Date: Sun Jul 22 21:19:55 2018 New Revision: 337668 URL: http://llvm.org/viewvc/llvm-project?rev=337668&view=rev Log: [CMake] Support statically linking dependencies only to shared or static library Currently it's possible to select whether to statically link unwinder or the C++ ABI library, but this option applies to both the shared and static library. However, in some scenarios it may be desirable to only statically link unwinder and C++ ABI library into static C++ library since for shared C++ library we can rely on dynamic linking and linker scripts. This change enables selectively enabling or disabling statically linking only to shared or static library. Differential Revision: https://reviews.llvm.org/D49502 Modified: libcxx/trunk/CMakeLists.txt libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake libcxx/trunk/lib/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=337668&r1=337667&r2=337668&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Sun Jul 22 21:19:55 2018 @@ -155,6 +155,14 @@ endif() # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) +cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY + "Statically link the ABI library to static library" ON + "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF) + +cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY + "Statically link the ABI library to shared library" ON + "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF) + # Generate and install a linker script inplace of libc++.so. The linker script # will link libc++ to the correct ABI library. This option is on by default # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=337668&r1=337667&r2=337668&view=diff == --- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original) +++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Sun Jul 22 21:19:55 2018 @@ -96,10 +96,10 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") if (LIBCXX_CXX_ABI_INTREE) # Link against just-built "cxxabi" target. -if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) -set(CXXABI_LIBNAME cxxabi_static) +if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) + set(CXXABI_LIBNAME cxxabi_static) else() -set(CXXABI_LIBNAME cxxabi_shared) + set(CXXABI_LIBNAME cxxabi_shared) endif() set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE) else() Modified: libcxx/trunk/lib/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=337668&r1=337667&r2=337668&view=diff == --- libcxx/trunk/lib/CMakeLists.txt (original) +++ libcxx/trunk/lib/CMakeLists.txt Sun Jul 22 21:19:55 2018 @@ -44,7 +44,7 @@ if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME ST set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON) endif() -if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) +if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic") add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}") add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive") @@ -259,14 +259,14 @@ if (LIBCXX_ENABLE_STATIC) list(APPEND LIBCXX_TARGETS "cxx_static") # Attempt to merge the libc++.a archive and the ABI library archive into one. - if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) + if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) set(MERGE_ARCHIVES_SEARCH_PATHS "") if (LIBCXX_CXX_ABI_LIBRARY_PATH) set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") endif() if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI)) - set(MERGE_ARCHIVES_ABI_TARGET "$") + set(MERGE_ARCHIVES_ABI_TARGET "$") else() set(MERGE_ARCHIVES_ABI_TARGET "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker
rnkovacs created this revision. rnkovacs added reviewers: NoQ, xazax.hun, george.karpenkov. Herald added subscribers: mikhail.ramalho, a.sidorin, dkrupp, szepet, baloghadamsoftware, whisperity. According to the standard, pointers referring to the elements of a `basic_string` sequence may also be invalidated if they are used as an argument to any standard library function taking a reference to non-const `basic_string` as an argument. This patch makes InnerPointerChecker warn for these cases as well. Repository: rC Clang https://reviews.llvm.org/D49656 Files: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/inner-pointer.cpp Index: test/Analysis/inner-pointer.cpp === --- test/Analysis/inner-pointer.cpp +++ test/Analysis/inner-pointer.cpp @@ -38,6 +38,15 @@ typedef basic_string u16string; typedef basic_string u32string; +template< class T > +void func_ref(T& a, T& b); + +template< class T > +void func_const_ref(const T& a, const T& b); + +template< class T > +void func_value(T a, T b); + } // end namespace std void consume(const char *) {} @@ -277,6 +286,31 @@ // expected-note@-1 {{Use of memory after it is freed}} } +void non_member_func_ref() { + const char *c; + std::string s1, s2; + c = s1.c_str();// expected-note {{Dangling inner pointer obtained here}} + std::func_ref(s1, s2); // expected-note {{Inner pointer invalidated by call to 'func_ref'}} + consume(c);// expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void non_member_func_const_ref() { + const char *c; + std::string s1, s2; + c = s1.c_str(); + std::func_const_ref(s1, s2); + consume(c); // no-warning +} + +void non_member_func_value() { + const char *c; + std::string s1, s2; + c = s1.c_str(); + std::func_value(s1, s2); + consume(c); // no-warning +} + void deref_after_scope_ok(bool cond) { const char *c, *d; std::string s; Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2930,6 +2930,8 @@ OS << MemCallE->getMethodDecl()->getNameAsString(); } else if (const auto *OpCallE = dyn_cast(S)) { OS << OpCallE->getDirectCallee()->getNameAsString(); +} else if (const auto *CallE = dyn_cast(S)) { + OS << CallE->getDirectCallee()->getNameAsString(); } OS << "'"; } Index: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp === --- lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp +++ lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp @@ -45,7 +45,7 @@ namespace { class InnerPointerChecker -: public Checker { +: public Checker { CallDescription AppendFn, AssignFn, ClearFn, CStrFn, DataFn, EraseFn, InsertFn, PopBackFn, PushBackFn, ReplaceFn, ReserveFn, ResizeFn, @@ -91,37 +91,33 @@ ReserveFn("reserve"), ResizeFn("resize"), ShrinkToFitFn("shrink_to_fit"), SwapFn("swap") {} - /// Check whether the function called on the container object is a - /// member function that potentially invalidates pointers referring - /// to the objects's internal buffer. - bool mayInvalidateBuffer(const CallEvent &Call) const; + /// Check whether the called member function potentially invalidates + /// pointers referring to the container object's inner buffer. + bool isInvalidatingMemberFunction(const CallEvent &Call) const; - /// Record the connection between the symbol returned by c_str() and the - /// corresponding string object region in the ProgramState. Mark the symbol - /// released if the string object is destroyed. + /// Mark pointer symbols associated with the given memory region released + /// in the program state. + void markPtrSymbolsReleased(const CallEvent &Call, ProgramStateRef State, + const MemRegion *ObjRegion, + CheckerContext &C) const; + + /// Record the connection between raw pointers referring to a container + /// object's inner buffer and the object's memory region in the program state. + /// Mark pointers potentially invalidated by member functions released. void checkPostCall(const CallEvent &Call, CheckerContext &C) const; - /// Clean up the ProgramState map. + /// Mark pointers potentially invalidated by functions taking the object + /// by non-const reference released. + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; + + /// Clean up the program state map. void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; }; } // end anonymous namespace -// [string.require] -// -// "References, p
[libcxx] r337666 - Fix use of C++14 syntax in C++11 filesystem tests.
Author: ericwf Date: Sun Jul 22 20:41:46 2018 New Revision: 337666 URL: http://llvm.org/viewvc/llvm-project?rev=337666&view=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&r1=337665&r2=337666&view=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
Author: ericwf Date: Sun Jul 22 20:06:57 2018 New Revision: 337665 URL: http://llvm.org/viewvc/llvm-project?rev=337665&view=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&r1=337664&r2=337665&view=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(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&r1=337664&r2=337665&view=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, &m_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
[PATCH] D49643: [HIP] Add -target-cpu option for clang -cc1
yaxunl added a comment. In https://reviews.llvm.org/D49643#1171158, @rjmccall wrote: > The commit message here could be better. You're passing `-target-cpu` when > running the device-mode compiler. Right. Will fix. Thanks. https://reviews.llvm.org/D49643 ___ 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.
Author: ericwf Date: Sun Jul 22 19:00:52 2018 New Revision: 337664 URL: http://llvm.org/viewvc/llvm-project?rev=337664&view=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&r1=337663&r2=337664&view=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_f
[PATCH] D49647: [libcxx] Library support for contracts (C++2a)
mclow.lists added a comment. I get that lib++ will not make these things, but we still need some tests showing that the whole machinery works. Repository: rCXX libc++ https://reviews.llvm.org/D49647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49647: [libcxx] Library support for contracts (C++2a)
mclow.lists added a comment. Thanks for doing this, but it needs tests before it can land. If I were to define `class contract_violation {};` that would pass the tests you've provided. (Heck, if I removed the entire definition of `contract_violation`, it would still pass.) Comment at: include/contract:41 + +class contract_violation { +public: Needs `_LIBCPP_TYPE_VIS` Repository: rCXX libc++ https://reviews.llvm.org/D49647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337663 - Fix the test
Author: brad Date: Sun Jul 22 15:04:28 2018 New Revision: 337663 URL: http://llvm.org/viewvc/llvm-project?rev=337663&view=rev Log: Fix the test Modified: cfe/trunk/test/Driver/openbsd.c Modified: cfe/trunk/test/Driver/openbsd.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=337663&r1=337662&r2=337663&view=diff == --- cfe/trunk/test/Driver/openbsd.c (original) +++ cfe/trunk/test/Driver/openbsd.c Sun Jul 22 15:04:28 2018 @@ -110,4 +110,5 @@ // Check ARM float ABI // RUN: %clang -target arm-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s -// CHECK-ARM-FLOAT-ABI: "-mfloat-abi" "softfp" +// CHECK-ARM-FLOAT-ABI-NOT: "-target-feature" "+soft-float" +// CHECK-ARM-FLOAT-ABI: "-target-feature" "+soft-float-abi" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r337662 - Add GCC 9 to XFAILs list for test
Author: ericwf Date: Sun Jul 22 14:58:46 2018 New Revision: 337662 URL: http://llvm.org/viewvc/llvm-project?rev=337662&view=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&r1=337661&r2=337662&view=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.
Author: ericwf Date: Sun Jul 22 14:56:40 2018 New Revision: 337661 URL: http://llvm.org/viewvc/llvm-project?rev=337661&view=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&r1=337660&r2=337661&view=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
r337660 - OpenBSD/arm has switched to float ABI SoftFP.
Author: brad Date: Sun Jul 22 14:39:54 2018 New Revision: 337660 URL: http://llvm.org/viewvc/llvm-project?rev=337660&view=rev Log: OpenBSD/arm has switched to float ABI SoftFP. Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/test/Driver/openbsd.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=337660&r1=337659&r2=337660&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Sun Jul 22 14:39:54 2018 @@ -232,7 +232,7 @@ arm::FloatABI arm::getARMFloatABI(const break; case llvm::Triple::OpenBSD: - ABI = FloatABI::Soft; + ABI = FloatABI::SoftFP; break; default: Modified: cfe/trunk/test/Driver/openbsd.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=337660&r1=337659&r2=337660&view=diff == --- cfe/trunk/test/Driver/openbsd.c (original) +++ cfe/trunk/test/Driver/openbsd.c Sun Jul 22 14:39:54 2018 @@ -110,4 +110,4 @@ // Check ARM float ABI // RUN: %clang -target arm-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s -// CHECK-ARM-FLOAT-ABI: "-mfloat-abi" "soft" +// CHECK-ARM-FLOAT-ABI: "-mfloat-abi" "softfp" ___ 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.
Author: ericwf Date: Sun Jul 22 14:15:15 2018 New Revision: 337659 URL: http://llvm.org/viewvc/llvm-project?rev=337659&view=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&r1=337658&r2=337659&view=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( &to, 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
Author: ericwf Date: Sun Jul 22 13:50:16 2018 New Revision: 337658 URL: http://llvm.org/viewvc/llvm-project?rev=337658&view=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&view=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&r1=337657&r2=337658&view=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&r1=337657&r2=337658&view=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&r1=337657&r2=337658&view=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 names
[PATCH] D49652: Apply -fdebug-prefix-map in reverse of command line order
alxu added a comment. Oh, I forgot to mention, this is the way that gcc does it. Therefore, I expect that almost everybody either doesn't care about the order, or assumes the gcc behavior. Repository: rC Clang https://reviews.llvm.org/D49652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49652: Apply -fdebug-prefix-map in reverse of command line order
alxu created this revision. Herald added a subscriber: cfe-commits. Before this patch, it is applied in order of increasing OLD path length. This is not a useful behavior. After this patch, it is applied based on the command line order from right to left, stopping on the first match. Repository: rC Clang https://reviews.llvm.org/D49652 Files: include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -604,7 +604,7 @@ Opts.EmbedSource = Args.hasArg(OPT_gembed_source); for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) -Opts.DebugPrefixMap.insert(StringRef(Arg).split('=')); +Opts.DebugPrefixMap.push_back(StringRef(Arg).split('=')); if (const Arg *A = Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists)) Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -80,7 +80,7 @@ /// Cache of previously constructed Types. llvm::DenseMap TypeCache; - llvm::SmallDenseMap DebugPrefixMap; + llvm::SmallVector, 4> DebugPrefixMap; /// Cache that maps VLA types to size expressions for that type, /// represented by instantiated Metadata nodes. Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -65,8 +65,9 @@ : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()), DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs), DBuilder(CGM.getModule()) { - for (const auto &KV : CGM.getCodeGenOpts().DebugPrefixMap) -DebugPrefixMap[KV.first] = KV.second; + for (auto C = CGM.getCodeGenOpts().DebugPrefixMap, +I = C.rbegin(), E = C.rend(); I != E; ++I) +DebugPrefixMap.push_back(std::make_pair((*I).first, (*I).second)); CreateCompileUnit(); } Index: include/clang/Frontend/CodeGenOptions.h === --- include/clang/Frontend/CodeGenOptions.h +++ include/clang/Frontend/CodeGenOptions.h @@ -132,7 +132,7 @@ /// non-empty. std::string DwarfDebugFlags; - std::map DebugPrefixMap; + std::vector> DebugPrefixMap; /// The ABI to use for passing floating point arguments. std::string FloatABI; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -604,7 +604,7 @@ Opts.EmbedSource = Args.hasArg(OPT_gembed_source); for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) -Opts.DebugPrefixMap.insert(StringRef(Arg).split('=')); +Opts.DebugPrefixMap.push_back(StringRef(Arg).split('=')); if (const Arg *A = Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists)) Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -80,7 +80,7 @@ /// Cache of previously constructed Types. llvm::DenseMap TypeCache; - llvm::SmallDenseMap DebugPrefixMap; + llvm::SmallVector, 4> DebugPrefixMap; /// Cache that maps VLA types to size expressions for that type, /// represented by instantiated Metadata nodes. Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -65,8 +65,9 @@ : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()), DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs), DBuilder(CGM.getModule()) { - for (const auto &KV : CGM.getCodeGenOpts().DebugPrefixMap) -DebugPrefixMap[KV.first] = KV.second; + for (auto C = CGM.getCodeGenOpts().DebugPrefixMap, +I = C.rbegin(), E = C.rend(); I != E; ++I) +DebugPrefixMap.push_back(std::make_pair((*I).first, (*I).second)); CreateCompileUnit(); } Index: include/clang/Frontend/CodeGenOptions.h === --- include/clang/Frontend/CodeGenOptions.h +++ include/clang/Frontend/CodeGenOptions.h @@ -132,7 +132,7 @@ /// non-empty. std::string DwarfDebugFlags; - std::map DebugPrefixMap; + std::vector> DebugPrefixMap; /// The ABI to use for passing floating point arguments. std::string FloatABI; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49650: Targets/AMDGPU: Don't set fp32-denormals feature for r600
jvesely created this revision. jvesely added reviewers: arsenm, tstellar. Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, kzhuravl. This feature was removed in r335942 Repository: rC Clang https://reviews.llvm.org/D49650 Files: lib/Basic/Targets/AMDGPU.cpp Index: lib/Basic/Targets/AMDGPU.cpp === --- lib/Basic/Targets/AMDGPU.cpp +++ lib/Basic/Targets/AMDGPU.cpp @@ -205,7 +205,7 @@ if (I == "+fp64-fp16-denormals" || I == "-fp64-fp16-denormals") hasFP64Denormals = true; } - if (!hasFP32Denormals) + if (!hasFP32Denormals && isAMDGCN(getTriple())) TargetOpts.Features.push_back( (Twine(CGOptsGPU.HasFastFMAF && !CGOpts.FlushDenorm ? '+' Index: lib/Basic/Targets/AMDGPU.cpp === --- lib/Basic/Targets/AMDGPU.cpp +++ lib/Basic/Targets/AMDGPU.cpp @@ -205,7 +205,7 @@ if (I == "+fp64-fp16-denormals" || I == "-fp64-fp16-denormals") hasFP64Denormals = true; } - if (!hasFP32Denormals) + if (!hasFP32Denormals && isAMDGCN(getTriple())) TargetOpts.Features.push_back( (Twine(CGOptsGPU.HasFastFMAF && !CGOpts.FlushDenorm ? '+' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49643: [HIP] Add -target-cpu option for clang -cc1
rjmccall added a comment. The commit message here could be better. You're passing `-target-cpu` when running the device-mode compiler. https://reviews.llvm.org/D49643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
lebedev.ri updated this revision to Diff 156705. lebedev.ri marked 3 inline comments as done. lebedev.ri added a comment. Hurray, got the PCH test working! I'm still unsure about marking *all* the immediate implicit casts as part of the group. Repository: rC Clang https://reviews.llvm.org/D49508 Files: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/ASTDumper.cpp lib/Sema/SemaCast.cpp lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterDecl.cpp lib/Serialization/ASTWriterStmt.cpp test/PCH/cxx_exprs.cpp test/Sema/multistep-explicit-cast.c test/SemaCXX/multistep-explicit-cast.cpp test/SemaOpenCL/multistep-explicit-cast.cl Index: test/SemaOpenCL/multistep-explicit-cast.cl === --- /dev/null +++ test/SemaOpenCL/multistep-explicit-cast.cl @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -ast-dump %s | FileCheck %s +// expected-no-diagnostics + +typedef __attribute__((ext_vector_type(2))) char char2; + +void vectorIncrementDecrementOps() { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} vectorIncrementDecrementOps 'void (void)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'char2':'char __attribute__((ext_vector_type(2)))' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'char' part_of_explicit_cast{{$}} + // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1{{$}} + char2 A = (char2)(1); + A++; +} Index: test/SemaCXX/multistep-explicit-cast.cpp === --- /dev/null +++ test/SemaCXX/multistep-explicit-cast.cpp @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -ast-dump %s | FileCheck %s + +// We are checking that implicit casts don't get marked with 'part_of_explicit_cast', +// while in explicit casts, the implicitly-inserted implicit casts are marked with 'part_of_explicit_cast' + +unsigned char implicitcast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return x; +} + +signed char implicitcast_1(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_1 'signed char (unsigned int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return x; +} + +unsigned char implicitcast_2(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_2 'unsigned char (int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return x; +} + +signed char implicitcast_3(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_3 'signed char (int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return x; +} + +//// + +unsigned char cstylecast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned char' part_of_explicit_cast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' part_of_explicit_cast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return (unsigned char)x; +} + +signed char cstylecast_1(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_1 'signed char (unsigned int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'signed char' part_of_explicit_cast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' part_of_explicit_cast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return (signed char)x; +} + +unsigned char cstylecast_2(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_2 'unsigned char (int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned char' part_of_explicit_cast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' part_of_explicit_cast{{$}} + // CHECK-NEXT:
[clang-tools-extra] r337655 - [clangd] Unbreak fuzzer build.
Author: d0k Date: Sun Jul 22 08:55:57 2018 New Revision: 337655 URL: http://llvm.org/viewvc/llvm-project?rev=337655&view=rev Log: [clangd] Unbreak fuzzer build. Modified: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp Modified: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=337655&r1=337654&r2=337655&view=diff == --- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original) +++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp Sun Jul 22 08:55:57 2018 @@ -20,7 +20,8 @@ #include extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { - clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(), nullptr); + clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(), +clang::clangd::Logger::Error, nullptr); clang::clangd::CodeCompleteOptions CCOpts; CCOpts.EnableSnippets = false; clang::clangd::ClangdServer::Options Opts; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49647: [libcxx] Library support for contracts (C++2a)
hamzasood created this revision. hamzasood added reviewers: EricWF, mclow.lists, rsmith. Herald added subscribers: cfe-commits, ldionne, christof. This patch adds the library components needed for contracts in C++2a. The wording says that a contract_violation object is populated in an implementation-defined manner. A private constructor that the compiler can call seems like the most sensible (and obvious) solution. Repository: rCXX libc++ https://reviews.llvm.org/D49647 Files: include/contract include/module.modulemap test/libcxx/double_include.sh.cpp test/libcxx/language.support/support.contract/version.pass.cpp Index: test/libcxx/language.support/support.contract/version.pass.cpp === --- test/libcxx/language.support/support.contract/version.pass.cpp +++ test/libcxx/language.support/support.contract/version.pass.cpp @@ -0,0 +1,20 @@ +//===--===// +// +// 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. +// +//===--===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} Index: test/libcxx/double_include.sh.cpp === --- test/libcxx/double_include.sh.cpp +++ test/libcxx/double_include.sh.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include Index: include/module.modulemap === --- include/module.modulemap +++ include/module.modulemap @@ -255,6 +255,10 @@ header "condition_variable" export * } + module contract { +header "contract" +export * + } module deque { header "deque" export initializer_list Index: include/contract === --- include/contract +++ include/contract @@ -0,0 +1,67 @@ +// -*- C++ -*- +//===-- contract --===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_CONTRACT +#define _LIBCPP_CONTRACT + +/* +contract synopsis + +namespace std { + class contract_violation { + public: +uint_least32_t line_number() const noexcept; +string_view file_name() const noexcept; +string_view function_name() const noexcept; +string_view comment() const noexcept; +string_view assertion_level() const noexcept; + }; +} +*/ + +#include <__config> +#include +#include + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +class contract_violation { +public: + _LIBCPP_INLINE_VISIBILITY uint_least32_t line_number() const noexcept { return __line_number; } + _LIBCPP_INLINE_VISIBILITY string_view file_name() const noexcept { return __file_name; } + _LIBCPP_INLINE_VISIBILITY string_view function_name() const noexcept { return __function_name; } + _LIBCPP_INLINE_VISIBILITY string_view comment() const noexcept { return __comment; } + _LIBCPP_INLINE_VISIBILITY string_view assertion_level() const noexcept { return __assertion_level; } + +private: + _LIBCPP_INLINE_VISIBILITY + constexpr contract_violation(uint_least32_t __line, string_view __file, string_view __fn, + string_view __comment, string_view __lvl) noexcept + : __line_number(__line), __file_name(__file), __function_name(__fn), +__comment(__comment), __assertion_level(__lvl) {} + + uint_least32_t __line_number; + string_view __file_name; + string_view __function_name; + string_view __comment; + string_view __assertion_level; +}; + +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_CONTRACT ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits