[PATCH] D47299: [CodeGenCXX] Emit strip.invariant.group with -fstrict-vtable-pointers
rjmccall added inline comments. Comment at: clang/include/clang/AST/DeclCXX.h:784 +return !hasDefinition() || !isDynamicClass() || hasAnyDependentBases(); + } + Both of these new methods deserve doc comments explaining that they're conservative checks because the class might be incomplete or dependent. I think `NonDynamic` would read better than `NotDynamic`. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1623 + const CXXRecordDecl *SourceClassDecl = + E->getType().getTypePtr()->getPointeeCXXRecordDecl(); + const CXXRecordDecl *DstClassDecl = DestTy->getPointeeCXXRecordDecl(); Unnecessary `getTypePtr()`. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1624 + E->getType().getTypePtr()->getPointeeCXXRecordDecl(); + const CXXRecordDecl *DstClassDecl = DestTy->getPointeeCXXRecordDecl(); + The opposite of `Dst` is `Src`. Alternatively, the opposite of `Source` is `Destination` (or `Result`). Please pick. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1633 + bool DstMayNotBeDynamic = + !DstClassDecl || DstClassDecl->mayBeNotDynamicClass(); + if (SourceMayBeNotDynamic && DstMayBeDynamic) { If you made a couple of tiny helper functions here that you could invoke on either `SourceClassDecl` or `DstClassDecl`, you could avoid some redundant logic and also make the calls self-documenting enough to legibly inline into the `if`-conditions. ...in fact, since you start from a QualType in every case, maybe you should just define the helper as a method there. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1647 + } +} + Incidentally, how do you protect against code like this? A *ptr; reinterpret_cast(ptr) = new B(); ptr->foo(); Presumably there needs to be a launder/strip here, but I guess it would have to be introduced by the middle-end when forwarding the store? The way I've written this is an aliasing violation, but (1) I assume your pass isn't disabled whenever strict-aliasing is disabled and (2) you can do this with a memcpy and still pretty reliably expect that LLVM will be able to eventually forward the store. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1791 + // dynamic information from invariant.group. + if (DstClassDecl && DstClassDecl->mayBeDynamicClass()) +IntToPtr = Builder.CreateLaunderInvariantGroup(IntToPtr); Another place you could definitely just use that helper function on QualType. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1802 + const CXXRecordDecl *ClassDecl = + E->getType().getTypePtr()->getPointeeCXXRecordDecl(); + // Casting to integer requires stripping dynamic information as it does Same. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3305 + if (RD->mayBeDynamicClass()) +RHS = Builder.CreateStripInvariantGroup(RHS); + } Yeah, helper function on QualType, please. :) Repository: rL LLVM https://reviews.llvm.org/D47299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48062: Fix that AlignedAllocation.h doesn't compile because of VersionTuple
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 rC334471: Fix that AlignedAllocation.h doesn't compile because of VersionTuple (authored by teemperor, committed by ). Repository: rC Clang https://reviews.llvm.org/D48062 Files: include/clang/Basic/AlignedAllocation.h Index: include/clang/Basic/AlignedAllocation.h === --- include/clang/Basic/AlignedAllocation.h +++ include/clang/Basic/AlignedAllocation.h @@ -22,18 +22,18 @@ namespace clang { -inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { +inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { switch (OS) { default: break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. -return VersionTuple(10U, 13U); +return llvm::VersionTuple(10U, 13U); case llvm::Triple::IOS: case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. -return VersionTuple(11U); +return llvm::VersionTuple(11U); case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. -return VersionTuple(4U); +return llvm::VersionTuple(4U); } llvm_unreachable("Unexpected OS"); Index: include/clang/Basic/AlignedAllocation.h === --- include/clang/Basic/AlignedAllocation.h +++ include/clang/Basic/AlignedAllocation.h @@ -22,18 +22,18 @@ namespace clang { -inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { +inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { switch (OS) { default: break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. -return VersionTuple(10U, 13U); +return llvm::VersionTuple(10U, 13U); case llvm::Triple::IOS: case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. -return VersionTuple(11U); +return llvm::VersionTuple(11U); case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. -return VersionTuple(4U); +return llvm::VersionTuple(4U); } llvm_unreachable("Unexpected OS"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334471 - Fix that AlignedAllocation.h doesn't compile because of VersionTuple
Author: teemperor Date: Mon Jun 11 20:43:21 2018 New Revision: 334471 URL: http://llvm.org/viewvc/llvm-project?rev=334471&view=rev Log: Fix that AlignedAllocation.h doesn't compile because of VersionTuple Summary: rL334399 put VersionTuple in the llvm namespace, but this header still assumes it's in the clang namespace. This leads to compilation failures with enabled modules when building Clang. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48062 Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=334471&r1=334470&r2=334471&view=diff == --- cfe/trunk/include/clang/Basic/AlignedAllocation.h (original) +++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Mon Jun 11 20:43:21 2018 @@ -22,18 +22,18 @@ namespace clang { -inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { +inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { switch (OS) { default: break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. -return VersionTuple(10U, 13U); +return llvm::VersionTuple(10U, 13U); case llvm::Triple::IOS: case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. -return VersionTuple(11U); +return llvm::VersionTuple(11U); case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. -return VersionTuple(4U); +return llvm::VersionTuple(4U); } llvm_unreachable("Unexpected OS"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r334470 - [CMake] Add a missing target dependency on C++ ABI headers
Author: phosek Date: Mon Jun 11 20:31:03 2018 New Revision: 334470 URL: http://llvm.org/viewvc/llvm-project?rev=334470&view=rev Log: [CMake] Add a missing target dependency on C++ ABI headers This resolves the breakage introduced in r334468 which results in build error when using CMake Makefile generator. Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake libcxx/trunk/lib/CMakeLists.txt Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=334470&r1=334469&r2=334470&view=diff == --- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original) +++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Mon Jun 11 20:31:03 2018 @@ -79,6 +79,7 @@ macro(setup_abi_lib abidefines abilib ab include_directories("${LIBCXX_BINARY_INCLUDE_DIR}") add_custom_target(cxx-abi-headers ALL DEPENDS ${abilib_headers}) + set(LIBCXX_ABI_HEADERS_TARGET cxx-abi-headers) endmacro() Modified: libcxx/trunk/lib/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=334470&r1=334469&r2=334470&view=diff == --- libcxx/trunk/lib/CMakeLists.txt (original) +++ libcxx/trunk/lib/CMakeLists.txt Mon Jun 11 20:31:03 2018 @@ -287,7 +287,7 @@ endif() # Add a meta-target for both libraries. add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS}) -add_dependencies(cxx cxx-headers) +add_dependencies(cxx cxx-headers ${LIBCXX_ABI_HEADERS_TARGET}) if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48062: Fix that AlignedAllocation.h doesn't compile because of VersionTuple
teemperor created this revision. https://reviews.llvm.org/rL334399 put VersionTuple in the llvm namespace, but this header still assumes it's in the clang namespace. This leads to compilation failures with enabled modules when building Clang. Repository: rC Clang https://reviews.llvm.org/D48062 Files: include/clang/Basic/AlignedAllocation.h Index: include/clang/Basic/AlignedAllocation.h === --- include/clang/Basic/AlignedAllocation.h +++ include/clang/Basic/AlignedAllocation.h @@ -22,18 +22,18 @@ namespace clang { -inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { +inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { switch (OS) { default: break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. -return VersionTuple(10U, 13U); +return llvm::VersionTuple(10U, 13U); case llvm::Triple::IOS: case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. -return VersionTuple(11U); +return llvm::VersionTuple(11U); case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. -return VersionTuple(4U); +return llvm::VersionTuple(4U); } llvm_unreachable("Unexpected OS"); Index: include/clang/Basic/AlignedAllocation.h === --- include/clang/Basic/AlignedAllocation.h +++ include/clang/Basic/AlignedAllocation.h @@ -22,18 +22,18 @@ namespace clang { -inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { +inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { switch (OS) { default: break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. -return VersionTuple(10U, 13U); +return llvm::VersionTuple(10U, 13U); case llvm::Triple::IOS: case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. -return VersionTuple(11U); +return llvm::VersionTuple(11U); case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. -return VersionTuple(4U); +return llvm::VersionTuple(4U); } llvm_unreachable("Unexpected OS"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r334468 - Reland "Use custom command and target to install libc++ headers"
Author: phosek Date: Mon Jun 11 20:10:02 2018 New Revision: 334468 URL: http://llvm.org/viewvc/llvm-project?rev=334468&view=rev Log: Reland "Use custom command and target to install libc++ headers" Using file(COPY FILE...) has several downsides. Since the file command is only executed at configuration time, any changes to headers made after the initial CMake execution are ignored. This can lead to subtle errors since the just built Clang will be using stale libc++ headers. Furthermore, since the headers are copied prior to executing the build system, this may hide missing dependencies on libc++ from other LLVM components. This changes replaces the use of file(COPY FILE...) command with a custom command and target which addresses all aforementioned issues and matches the implementation already used by other LLVM components that also install headers like Clang builtin headers. Differential Revision: https://reviews.llvm.org/D44773 Modified: libcxx/trunk/NOTES.TXT libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake libcxx/trunk/include/CMakeLists.txt libcxx/trunk/lib/CMakeLists.txt Modified: libcxx/trunk/NOTES.TXT URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/NOTES.TXT?rev=334468&r1=334467&r2=334468&view=diff == --- libcxx/trunk/NOTES.TXT (original) +++ libcxx/trunk/NOTES.TXT Mon Jun 11 20:10:02 2018 @@ -26,3 +26,4 @@ to libc++. 1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`. 2. Update `test/libcxx/double_include.sh.cpp` to include the new header. 3. Create a submodule in `include/module.modulemap` for the new header. +4. Update the include/CMakeLists.txt file to include the new header. Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=334468&r1=334467&r2=334468&view=diff == --- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original) +++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Mon Jun 11 20:10:02 2018 @@ -47,12 +47,22 @@ macro(setup_abi_lib abidefines abilib ab set(found TRUE) get_filename_component(dstdir ${fpath} PATH) get_filename_component(ifile ${fpath} NAME) -file(COPY "${incpath}/${fpath}" - DESTINATION "${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}" - ) -file(COPY "${incpath}/${fpath}" - DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}" - ) +set(src ${incpath}/${fpath}) + +set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${fpath}) +add_custom_command(OUTPUT ${dst} +DEPENDS ${src} +COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} +COMMENT "Copying C++ ABI header ${fpath}...") +list(APPEND abilib_headers "${dst}") + +set(dst "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}/${fpath}") +add_custom_command(OUTPUT ${dst} +DEPENDS ${src} +COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} +COMMENT "Copying C++ ABI header ${fpath}...") +list(APPEND abilib_headers "${dst}") + if (LIBCXX_INSTALL_HEADERS) install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir} @@ -60,7 +70,6 @@ macro(setup_abi_lib abidefines abilib ab PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) endif() -list(APPEND abilib_headers "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}") endif() endforeach() if (NOT found) @@ -69,6 +78,7 @@ macro(setup_abi_lib abidefines abilib ab endforeach() include_directories("${LIBCXX_BINARY_INCLUDE_DIR}") + add_custom_target(cxx-abi-headers ALL DEPENDS ${abilib_headers}) endmacro() Modified: libcxx/trunk/include/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=334468&r1=334467&r2=334468&view=diff == --- libcxx/trunk/include/CMakeLists.txt (original) +++ libcxx/trunk/include/CMakeLists.txt Mon Jun 11 20:10:02 2018 @@ -1,5 +1,184 @@ -if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS) - set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE) +set(files + __bit_reference + __bsd_locale_defaults.h + __bsd_locale_fallbacks.h + __debug + __functional_03 + __functional_base + __functional_base_03 + __hash_table + __libcpp_version + __locale + __mutex_base + __nullptr + __split_buffer + __sso_allocator + __std_stream + __string + __threading_support + __tree + __tuple + __undef_macros + algorithm + any + array + atomic + bitset + cassert + ccomplex + cctype + cerrno + cfenv + cfloat + chrono + cinttypes + ciso646 + climits + clocale + cmath + codecvt + com
[libcxx] r334467 - Update the to-do list with motions from Rapperswil.
Author: marshall Date: Mon Jun 11 19:45:30 2018 New Revision: 334467 URL: http://llvm.org/viewvc/llvm-project?rev=334467&view=rev Log: Update the to-do list with motions from Rapperswil. Modified: libcxx/trunk/www/cxx2a_status.html Modified: libcxx/trunk/www/cxx2a_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=334467&r1=334466&r2=334467&view=diff == --- libcxx/trunk/www/cxx2a_status.html (original) +++ libcxx/trunk/www/cxx2a_status.html Mon Jun 11 19:45:30 2018 @@ -82,6 +82,32 @@ https://wg21.link/P0905R1";>P0905R1CWGSymmetry for spaceshipJacksonville https://wg21.link/P0966R1";>P0966R1LWGstring::reserve Should Not ShrinkJacksonville + + https://wg21.link/P0019R8";>P0019R8LWGAtomic RefRapperswil + https://wg21.link/P0458R2";>P0458R2LWGChecking for Existence of an Element in Associative ContainersRapperswil + https://wg21.link/P0475R1";>P0475R1LWGLWG 2511: guaranteed copy elision for piecewise constructionRapperswil + https://wg21.link/P0476R2";>P0476R2LWGBit-casting object representationsRapperswil + https://wg21.link/P0528R3";>P0528R3CWGThe Curious Case of Padding Bits, Featuring Atomic Compare-and-ExchangeRapperswil + https://wg21.link/P0542R5";>P0542R5CWGSupport for contract based programming in C++Rapperswil + https://wg21.link/P0556R3";>P0556R3LWGIntegral power-of-2 operationsRapperswil + https://wg21.link/P0619R4";>P0619R4LWGReviewing Deprecated Facilities of C++17 for C++20Rapperswil + https://wg21.link/P0646R1";>P0646R1LWGImproving the Return Value of Erase-Like AlgorithmsRapperswil + https://wg21.link/P0722R3";>P0722R3CWGEfficient sized delete for variable sized classesRapperswil + https://wg21.link/P0758R1";>P0758R1LWGImplicit conversion traits and utility functionsRapperswil + https://wg21.link/P0759R1";>P0759R1LWGfpos RequirementsRapperswil + https://wg21.link/P0769R2";>P0769R2LWGAdd shift toRapperswil + https://wg21.link/P0771R0";>P0771R0LWGstd::function move operations should be noexceptRapperswil + https://wg21.link/P0788R3";>P0788R3LWGStandard Library Specification in a Concepts and Contracts WorldRapperswil + https://wg21.link/P0879R0";>P0879R0LWGConstexpr for swap and swap related functions Also resolves LWG issue 2800.Rapperswil + https://wg21.link/P0887R1";>P0887R1LWGThe identity metafunctionRapperswil + https://wg21.link/P0892R2";>P0892R2CWGexplicit(bool)Rapperswil + https://wg21.link/P0898R3";>P0898R3LWGStandard Library ConceptsRapperswil + https://wg21.link/P0935R0";>P0935R0LWGEradicating unnecessarily explicit default constructors from the standard libraryRapperswil + https://wg21.link/P0941R2";>P0941R2CWGIntegrating feature-test macros into the C++ WDRapperswil + https://wg21.link/P1023R0";>P1023R0LWGconstexpr comparison operators for std::arrayRapperswil + https://wg21.link/P1025R1";>P1025R1CWGUpdate The Reference To The Unicode StandardRapperswil + https://wg21.link/P1120R0";>P1120R0CWGConsistency improvements for <=> and other comparison operatorsRapperswil + @@ -177,10 +203,27 @@ https://wg21.link/LWG3051";>3051Floating point classifications were inadvertently changed in P0175JacksonvilleNothing to do https://wg21.link/LWG3075";>3075basic_string needs deduction guides from basic_string_viewJacksonville + + https://wg21.link/LWG2139";>2139What is a user-defined type?Rapperswil + https://wg21.link/LWG2970";>2970Return type of std::visit misspecifiedRapperswil + https://wg21.link/LWG3058";>3058Parallel adjacent_difference shouldn't require creating temporariesRapperswil + https://wg21.link/LWG3062";>3062Unnecessary decay_t in is_execution_policy_v should be remove_cvref_tRapperswil + https://wg21.link/LWG3067";>3067recursive_directory_iterator::pop must invalidateRapperswilNothing to do + https://wg21.link/LWG3071";>3071[networking.ts] read_until still refers to "input sequence"RapperswilNothing to do + https://wg21.link/LWG3074";>3074Non-member functions for valarray should only deduce from the valarrayRapperswil + https://wg21.link/LWG3076";>3076basic_string CTAD ambiguityRapperswil + https://wg21.link/LWG3079";>3079LWG 2935 forgot to fix the existing_p overloads of create_directoryRapperswil + https://wg21.link/LWG3080";>3080Floating point from_chars pattern specification breaks round-trippingRapperswil + https://wg21.link/LWG3083";>3083What should ios::iword(-1) do?RapperswilNothing to do + https://wg21.link/LWG3094";>3094[time.duration.io]p4 makes surprising claims about encodingRapperswil + https://wg21.link/LWG3100";>3100Unnecessary and confusing "empty span" wordingRapperswilNothing to do +
[PATCH] D47687: [Sema] Missing -Wlogical-op-parentheses warnings in macros (PR18971)
Higuoxing added a comment. In https://reviews.llvm.org/D47687#1128757, @dexonsmith wrote: > > Yes, I think understand the patch; but I think it's the wrong direction. I > think we should just make the existing `-Wlogical-op-parentheses` smart > enough to show actionable warnings in macros (but suppress the ones that are > not actionable, like the internals of `foo(&&, ||, ...)`, rather than adding > `-Wlogical-op-parentheses-in-macros`, which sounds like it would be > permanently off-by-default. In https://reviews.llvm.org/D47687#1128757, @dexonsmith wrote: > In https://reviews.llvm.org/D47687#1127120, @Higuoxing wrote: > > > In https://reviews.llvm.org/D47687#1126607, @dexonsmith wrote: > > > > > In https://reviews.llvm.org/D47687#1126074, @lebedev.ri wrote: > > > > > > > In https://reviews.llvm.org/D47687#1126032, @Higuoxing wrote: > > > > > > > > > In https://reviews.llvm.org/D47687#1125926, @rnk wrote: > > > > > > > > > > > @dexonsmith is there someone from Apple who can comment on > > > > > > rdar://8678458 and the merits of disabling this warning in macros? > > > > > > I strongly suspect the original report was dealing with code like > > > > > > `assert(x || y && "str");`, if so we can go forward with this. > > > > > > > > > > > > @chandlerc I know you've hit this behavior difference vs. GCC > > > > > > before. Any thoughts on the proposed change? > > > > > > > > > > > > > > > > > > > > > > > > > In https://reviews.llvm.org/D47687#1125964, @dexonsmith wrote: > > > > > > > > > > > In https://reviews.llvm.org/D47687#1125926, @rnk wrote: > > > > > > > > > > > > > @dexonsmith is there someone from Apple who can comment on > > > > > > > rdar://8678458 and the merits of disabling this warning in > > > > > > > macros? I strongly suspect the original report was dealing with > > > > > > > code like `assert(x || y && "str");`, if so we can go forward > > > > > > > with this. > > > > > > > > > > > > > > > > > > There were two commits with this radar: r119537 and r119540. The > > > > > > main motivation was a deeply nested macro that when "inlined" > > > > > > included the moral equivalent of `#define DOUBLE_OP(OP1, OP2, X, Y, > > > > > > Z) (X OP1 Y OP2 Z)`. There was terrible note spew when the warning > > > > > > fired in this case, and the use case for the macro made the warning > > > > > > un-actionable. We decided to suppress the warning entirely: > > > > > > > > > > > > > As a general comment, the warning seems to be useless for macros; > > > > > > > I'll follow the example of warn_logical_instead_of_bitwise which > > > > > > > doesn't trigger for macros and I'll make the warning not warn for > > > > > > > macros. > > > > > > > > > > > > > > > Hi, Thank you, > > > > > > > > > > I noticed that `warn_logical_instead_of_bitwise ` will also skip > > > > > parentheses checking in macros... well, this patch seems not so > > > > > necessary... both ok for me ... depends on all of you :-) > > > > > > > > > > > > At worst, we can issue this warning in a new `-Wparentheses-in-macros` > > > > subgroup, which, if apple so insists, could be off-by-default. > > > > That would less worse than just completely silencing it for the entire > > > > world. > > > > > > > > > I’d be fine with strengthening the existing warning as long as there is > > > an actionable fix-it. I suspect if you suppress it when the relevant > > > expression is constructed from multiple macro arguments that will be good > > > enough. > > > > > > Thanks, currently, `[-Wparentheses | -Wlogical-op-parentheses]` will not > > emit warning for parentheses in macros. only if you add > > `[-Wlogical-op-parentheses-in-macros]` it will emit something like `'&&' > > within '||'` warning... > > > > However, `'&' within '|'` checking was disabled in macros as well... I > > don't know if this patch meet the needs... if this patch was ok, then, just > > as @lebedev.ri said, Maybe we could add a `[-Wparentheses-in-macros]` > > subgroup and add these warning into this new group, in the future... > > depends on users :-) any suggestion? > > > Yes, I think understand the patch; but I think it's the wrong direction. I > think we should just make the existing `-Wlogical-op-parentheses` smart > enough to show actionable warnings in macros (but suppress the ones that are > not actionable, like the internals of `foo(&&, ||, ...)`, rather than adding > `-Wlogical-op-parentheses-in-macros`, which sounds like it would be > permanently off-by-default. Thank you `@lebedev.ri` for reviewing my code and change the title and various things! Thank you `@dexonsmith` for helping me on backgrounds of this topic, I do agree with you, because those who did not participate in our discussion might not know this option `[-Wlogical-op-parentheses-in-macros]`, and make a special option for this warning seems a little bit strange ... I will have a try, thanks a lot! https://reviews.llvm.org/D47687 __
RE: r334418 - Enable crash recovery tests on Windows, globs work in the lit internal shell now
Hi Reid, Actually, it seems all four tests you changed are failing on one Windows bot http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12464. Can you please take a look and fix the tests? Douglas Yung > -Original Message- > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf > Of via cfe-commits > Sent: Monday, June 11, 2018 18:37 > To: r...@google.com > Cc: cfe-commits@lists.llvm.org > Subject: RE: r334418 - Enable crash recovery tests on Windows, globs > work in the lit internal shell now > > Hi Reid, > > I don't know if you noticed, but one of the tests you changed with this > commit is failing on the PS4 Windows bot. Can you take a look? > > http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast/builds/17695/ > > FAIL: Clang :: Driver/crash-report-modules.m (7229 of 40862) > TEST 'Clang :: Driver/crash-report-modules.m' > FAILED > Script: > -- > : 'RUN: at line 1'; rm -rf C:\ps4-buildslave2\llvm-clang-lld-x86_64- > scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp > : 'RUN: at line 2'; mkdir -p C:\ps4-buildslave2\llvm-clang-lld- > x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp/i C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp/m C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp > : 'RUN: at line 4'; not env FORCE_CLANG_DIAGNOSTICS_CRASH= > TMPDIR=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp > TEMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp > TMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp > c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\bin\clang.EXE -fsyntax-only C:\ps4-buildslave2\llvm- > clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m -I C:\ps4- > buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.src\tools\clang\test\Driver/Inputs/module -isysroot C:/ps4- > buildslave2/llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast/llvm.obj/tools/clang/test/Driver/Output/crash-report- > modules.m.tmp/i/ -fmodules -fmodules-cache-path=C:\ps4- > buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp/m/ -DFOO=BAR 2>&1 | C:\ps4-buildslave2\llvm-clang-lld- > x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\FileCheck.EXE C:\ps4- > buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m > : 'RUN: at line 8'; C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei- > ps4-windows10pro-fast\llvm.obj\bin\FileCheck.EXE --check- > prefix=CHECKSRC C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.src\tools\clang\test\Driver\crash-report- > modules.m -input-file C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei- > ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash- > report-modules.m.tmp/crash-report-*.m > : 'RUN: at line 9'; C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei- > ps4-windows10pro-fast\llvm.obj\bin\FileCheck.EXE --check-prefix=CHECKSH > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m -input- > file C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp/crash-report-*.sh > -- > Exit Code: 2 > > Command Output (stdout): > -- > $ ":" "RUN: at line 1" > $ "rm" "-rf" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp" > $ ":" "RUN: at line 2" > $ "mkdir" "-p" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp/i" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp/m" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp" > $ ":" "RUN: at line 4" > $ "not" "env" "FORCE_CLANG_DIAGNOSTICS_CRASH=" "TMPDIR=C:\ps4- > buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro- > fast\llvm.obj\tools\clang\test\Driver\Output\crash-report- > modules.m.tmp" "TEMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4- > windows10pro-fast\llvm.obj\tools
[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.
MTC added a comment. In https://reviews.llvm.org/D48027#1128301, @xazax.hun wrote: > Having C++ support would be awesome! > Thanks for working on this! > > While I do agree matching is not trivial with qualified names, this problem > is already solved with AST matchers. > > I wonder if using matchers or reusing the `HasNameMatcher` class would make > this easier. That code path is already well tested and optimized. Thank you for pointing out the direction, xazax.hun! I will looking into the matchers and try to give a better solution. Repository: rC Clang https://reviews.llvm.org/D48027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types
rjmccall added a comment. In https://reviews.llvm.org/D47233#1129110, @smeenai wrote: > Wrapping an Objective-C exception inside a C++ exception means dynamically > constructing a C++ exception object and traversing the class hierarchy of the > thrown Obj-C object to populate the catchable types array of the C++ > exception. Microsoft's C++ runtime will perform the appropriate catch type > comparisons, and this patch makes the compiler emit the right typeinfos into > the exception handling tables for all of that to work. > https://github.com/Microsoft/libobjc2/blob/f2e4c5ac4b3ac17f413a38bbc7ee1242f9efd0f7/msvc/eh_winobjc.cc#L116 > is how WinObjC does this wrapping, for example. I see. The idea of creating the type descriptors and mangled names ad-hoc for the catchable-types array is clever, and it's nice that the ABI is defined in a way that makes that work. (Expensive, but hey, it's the exceptions path.) Alright, now that I understand why this only matters for the catch side, I'll take a look at the patch. Repository: rC Clang https://reviews.llvm.org/D47233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r334418 - Enable crash recovery tests on Windows, globs work in the lit internal shell now
Hi Reid, I don't know if you noticed, but one of the tests you changed with this commit is failing on the PS4 Windows bot. Can you take a look? http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/17695/ FAIL: Clang :: Driver/crash-report-modules.m (7229 of 40862) TEST 'Clang :: Driver/crash-report-modules.m' FAILED Script: -- : 'RUN: at line 1'; rm -rf C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp : 'RUN: at line 2'; mkdir -p C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/i C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/m C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp : 'RUN: at line 4'; not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp TEMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp TMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE -fsyntax-only C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m -I C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver/Inputs/module -isysroot C:/ps4-buildslave2/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/tools/clang/test/Driver/Output/crash-report-modules.m.tmp/i/ -fmodules -fmodules-cache-path=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/m/ -DFOO=BAR 2>&1 | C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\FileCheck.EXE C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m : 'RUN: at line 8'; C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\FileCheck.EXE --check-prefix=CHECKSRC C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m -input-file C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/crash-report-*.m : 'RUN: at line 9'; C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\FileCheck.EXE --check-prefix=CHECKSH C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m -input-file C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/crash-report-*.sh -- Exit Code: 2 Command Output (stdout): -- $ ":" "RUN: at line 1" $ "rm" "-rf" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp" $ ":" "RUN: at line 2" $ "mkdir" "-p" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/i" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp/m" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp" $ ":" "RUN: at line 4" $ "not" "env" "FORCE_CLANG_DIAGNOSTICS_CRASH=" "TMPDIR=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp" "TEMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp" "TMP=C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\crash-report-modules.m.tmp" "c:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\bin\clang.EXE" "-fsyntax-only" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\crash-report-modules.m" "-I" "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver/Inputs/module" "-isysroot" "C:/ps4-buildslave2/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/tools/clang/test/Driver/Output/crash-report-modules.m.tmp/i/" "-fmo
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
ormris added inline comments. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89 +new Callback(LCtx, MRMgr, ITraits)); + Finder.matchAST(ASTCtx); + NoQ wrote: > NoQ wrote: > > george.karpenkov wrote: > > > ormris wrote: > > > > george.karpenkov wrote: > > > > > IMO using the iterator directly (e.g. like it was done in > > > > > https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) > > > > > leads to a much cleaner code and saves you from having to define a > > > > > callback class. > > > > Hmm... I think that's a better approach. Let me see if I can get that > > > > working. > > > @ormris Yeah I'm really not sure why all examples use the callback API by > > > default. > > Also, please match only the local AST, i.e. the body of the function under > > analysis, which can be obtained as `LCtx->getDecl()->getBody()`. There's no > > need to scan the whole translation unit. > Actually not sure, would widening screw the previous stack frames as well? We > should test that, i guess. And even then, it's better to match a few stack > frames in the current stack trace than to match the whole translation unit. I can't seem to get the new syntax to work. The following assert(0) is never triggered. ``` auto Matches = match(varDecl(hasType(referenceType())).bind(MatchRef), *LCtx->getDecl()->getBody(), ASTCtx); for (BoundNodes Match : Matches) { assert(0 && "anything"); const VarDecl *VD = Match.getNodeAs(MatchRef); const VarRegion *VarMem = MRMgr.getVarRegion(VD, LCtx); ITraits.setTrait(VarMem, RegionAndSymbolInvalidationTraits::TK_PreserveContents); } ``` Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47958: [CUDA][HIP] Allow CUDA __global__ functions to have amdgpu kernel attributes
yaxunl updated this revision to Diff 150872. yaxunl marked 2 inline comments as done. yaxunl retitled this revision from "[CUDA][HIP] Allow CUDA `__global__` functions to have amdgpu kernel attributes" to "[CUDA][HIP] Allow CUDA __global__ functions to have amdgpu kernel attributes". yaxunl added a comment. Improve error msg. https://reviews.llvm.org/D47958 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/CodeGenCUDA/amdgpu-kernel-attrs.cu test/SemaCUDA/amdgpu-attrs.cu test/SemaOpenCL/invalid-kernel-attrs.cl Index: test/SemaOpenCL/invalid-kernel-attrs.cl === --- test/SemaOpenCL/invalid-kernel-attrs.cl +++ test/SemaOpenCL/invalid-kernel-attrs.cl @@ -14,11 +14,11 @@ kernel __attribute__((work_group_size_hint(1,2,3))) __attribute__((work_group_size_hint(3,2,1))) void kernel7() {} //expected-warning{{attribute 'work_group_size_hint' is already applied with different parameters}} -__attribute__((reqd_work_group_size(8,16,32))) void kernel8(){} // expected-error {{attribute 'reqd_work_group_size' can only be applied to a kernel}} +__attribute__((reqd_work_group_size(8,16,32))) void kernel8(){} // expected-error {{attribute 'reqd_work_group_size' can only be applied to an OpenCL kernel}} -__attribute__((work_group_size_hint(8,16,32))) void kernel9(){} // expected-error {{attribute 'work_group_size_hint' can only be applied to a kernel}} +__attribute__((work_group_size_hint(8,16,32))) void kernel9(){} // expected-error {{attribute 'work_group_size_hint' can only be applied to an OpenCL kernel}} -__attribute__((vec_type_hint(char))) void kernel10(){} // expected-error {{attribute 'vec_type_hint' can only be applied to a kernel}} +__attribute__((vec_type_hint(char))) void kernel10(){} // expected-error {{attribute 'vec_type_hint' can only be applied to an OpenCL kernel}} constant int foo1 __attribute__((reqd_work_group_size(8,16,32))) = 0; // expected-error {{'reqd_work_group_size' attribute only applies to functions}} @@ -34,6 +34,6 @@ kernel __attribute__((reqd_work_group_size(1,0,2))) void kernel12(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}} kernel __attribute__((reqd_work_group_size(0,1,2))) void kernel13(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}} -__attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to a kernel}} +__attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to an OpenCL kernel}} kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}} kernel __attribute__((intel_reqd_sub_group_size(8))) __attribute__((intel_reqd_sub_group_size(16))) void kernel16() {} //expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied with different parameters}} Index: test/SemaCUDA/amdgpu-attrs.cu === --- test/SemaCUDA/amdgpu-attrs.cu +++ test/SemaCUDA/amdgpu-attrs.cu @@ -1,110 +1,80 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s - #include "Inputs/cuda.h" -// expected-error@+2 {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}} __attribute__((amdgpu_flat_work_group_size(32, 64))) __global__ void flat_work_group_size_32_64() {} -// expected-error@+2 {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}} __attribute__((amdgpu_waves_per_eu(2))) __global__ void waves_per_eu_2() {} -// expected-error@+2 {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}} __attribute__((amdgpu_waves_per_eu(2, 4))) __global__ void waves_per_eu_2_4() {} -// expected-error@+2 {{'amdgpu_num_sgpr' attribute only applies to kernel functions}} __attribute__((amdgpu_num_sgpr(32))) __global__ void num_sgpr_32() {} -// expected-error@+2 {{'amdgpu_num_vgpr' attribute only applies to kernel functions}} __attribute__((amdgpu_num_vgpr(64))) __global__ void num_vgpr_64() {} -// expected-error@+3 {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}} -// fixme-expected-error@+2 {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}} __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2))) __global__ void flat_work_group_size_32_64_waves_per_eu_2() {} -// expected-error@+3 {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}} -// fixme-expected-error@+2 {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}} __attribute__((amdgpu_flat_work_group_size(32, 64), amdgpu_waves_per_eu(2, 4))) __global__ void flat_work_group_size_32_64_waves_per_eu_2_4() {} -// expected-error@+3 {{'amdgpu_flat_work_group_size' attribute only applies t
[PATCH] D47733: [CUDA][HIP] Set kernel calling convention before arrange function
This revision was automatically updated to reflect the committed changes. Closed by commit rL334457: [CUDA][HIP] Set kernel calling convention before arrange function (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D47733?vs=150559&id=150869#toc Repository: rL LLVM https://reviews.llvm.org/D47733 Files: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/CodeGen/TargetInfo.h cfe/trunk/test/CodeGenCUDA/kernel-args.cu Index: cfe/trunk/test/CodeGenCUDA/kernel-args.cu === --- cfe/trunk/test/CodeGenCUDA/kernel-args.cu +++ cfe/trunk/test/CodeGenCUDA/kernel-args.cu @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \ +// RUN: -emit-llvm %s -o - | FileCheck -check-prefix=AMDGCN %s +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda- -fcuda-is-device \ +// RUN: -emit-llvm %s -o - | FileCheck -check-prefix=NVPTX %s +#include "Inputs/cuda.h" + +struct A { + int a[32]; +}; + +// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A %x.coerce) +// NVPTX: define void @_Z6kernel1A(%struct.A* byval align 4 %x) +__global__ void kernel(A x) { +} + +class Kernel { +public: + // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A %x.coerce) + // NVPTX: define void @_ZN6Kernel12memberKernelE1A(%struct.A* byval align 4 %x) + static __global__ void memberKernel(A x){} + template static __global__ void templateMemberKernel(T x) {} +}; + + +template +__global__ void templateKernel(T x) {} + +void launch(void*); + +void test() { + Kernel K; + // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A %x.coerce) + // NVPTX: define void @_Z14templateKernelI1AEvT_(%struct.A* byval align 4 %x) + launch((void*)templateKernel); + + // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A %x.coerce) + // NVPTX: define void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A* byval align 4 %x) + launch((void*)Kernel::templateMemberKernel); +} Index: cfe/trunk/lib/CodeGen/TargetInfo.h === --- cfe/trunk/lib/CodeGen/TargetInfo.h +++ cfe/trunk/lib/CodeGen/TargetInfo.h @@ -302,7 +302,7 @@ /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } - virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} + virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const {} }; } // namespace CodeGen Index: cfe/trunk/lib/CodeGen/CGCall.cpp === --- cfe/trunk/lib/CodeGen/CGCall.cpp +++ cfe/trunk/lib/CodeGen/CGCall.cpp @@ -255,6 +255,16 @@ FTP->getCanonicalTypeUnqualified().getAs(), MD); } +/// Set calling convention for CUDA/HIP kernel. +static void setCUDAKernelCallingConvention(CanQualType &FTy, CodeGenModule &CGM, + const FunctionDecl *FD) { + if (FD->hasAttr()) { +const FunctionType *FT = FTy->getAs(); +CGM.getTargetCodeGenInfo().setCUDAKernelCallingConvention(FT); +FTy = FT->getCanonicalTypeUnqualified(); + } +} + /// Arrange the argument and result information for a declaration or /// definition of the given C++ non-static member function. The /// member function must be an ordinary function, i.e. not a @@ -264,7 +274,9 @@ assert(!isa(MD) && "wrong method for constructors!"); assert(!isa(MD) && "wrong method for destructors!"); - CanQual prototype = GetFormalType(MD); + CanQualType FT = GetFormalType(MD).getAs(); + setCUDAKernelCallingConvention(FT, CGM, MD); + auto prototype = FT.getAs(); if (MD->isInstance()) { // The abstract case is perfectly fine. @@ -424,6 +436,7 @@ CanQualType FTy = FD->getType()->getCanonicalTypeUnqualified(); assert(isa(FTy)); + setCUDAKernelCallingConvention(FTy, CGM, FD); // When declaring a function without a prototype, always use a // non-variadic type. Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -7646,7 +7646,7 @@ llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; - void setCUDAKernelCallingConvention(llvm::Function *F) const override; + void setCUDAKernelCallingConvention(const FunctionType *&FT) const override; }; } @@ -7783,8 +7783,9 @@ } void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( -llvm::Function *F) const { - F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +const FunctionType *&FT) const { + FT = getABIInfo(
r334457 - [CUDA][HIP] Set kernel calling convention before arrange function
Author: yaxunl Date: Mon Jun 11 17:16:33 2018 New Revision: 334457 URL: http://llvm.org/viewvc/llvm-project?rev=334457&view=rev Log: [CUDA][HIP] Set kernel calling convention before arrange function Currently clang set kernel calling convention for CUDA/HIP after arranging function, which causes incorrect kernel function type since it depends on calling convention. This patch moves setting kernel convention before arranging function. Differential Revision: https://reviews.llvm.org/D47733 Added: cfe/trunk/test/CodeGenCUDA/kernel-args.cu Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/CodeGen/TargetInfo.h Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=334457&r1=334456&r2=334457&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jun 11 17:16:33 2018 @@ -255,6 +255,16 @@ CodeGenTypes::arrangeCXXMethodType(const FTP->getCanonicalTypeUnqualified().getAs(), MD); } +/// Set calling convention for CUDA/HIP kernel. +static void setCUDAKernelCallingConvention(CanQualType &FTy, CodeGenModule &CGM, + const FunctionDecl *FD) { + if (FD->hasAttr()) { +const FunctionType *FT = FTy->getAs(); +CGM.getTargetCodeGenInfo().setCUDAKernelCallingConvention(FT); +FTy = FT->getCanonicalTypeUnqualified(); + } +} + /// Arrange the argument and result information for a declaration or /// definition of the given C++ non-static member function. The /// member function must be an ordinary function, i.e. not a @@ -264,7 +274,9 @@ CodeGenTypes::arrangeCXXMethodDeclaratio assert(!isa(MD) && "wrong method for constructors!"); assert(!isa(MD) && "wrong method for destructors!"); - CanQual prototype = GetFormalType(MD); + CanQualType FT = GetFormalType(MD).getAs(); + setCUDAKernelCallingConvention(FT, CGM, MD); + auto prototype = FT.getAs(); if (MD->isInstance()) { // The abstract case is perfectly fine. @@ -424,6 +436,7 @@ CodeGenTypes::arrangeFunctionDeclaration CanQualType FTy = FD->getType()->getCanonicalTypeUnqualified(); assert(isa(FTy)); + setCUDAKernelCallingConvention(FTy, CGM, FD); // When declaring a function without a prototype, always use a // non-variadic type. Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=334457&r1=334456&r2=334457&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 11 17:16:33 2018 @@ -3671,8 +3671,6 @@ void CodeGenModule::EmitGlobalFunctionDe MaybeHandleStaticInExternC(D, Fn); - if (D->hasAttr()) -getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn); maybeSetTrivialComdat(*D, *Fn); Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=334457&r1=334456&r2=334457&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Jun 11 17:16:33 2018 @@ -7646,7 +7646,7 @@ public: llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; - void setCUDAKernelCallingConvention(llvm::Function *F) const override; + void setCUDAKernelCallingConvention(const FunctionType *&FT) const override; }; } @@ -7783,8 +7783,9 @@ bool AMDGPUTargetCodeGenInfo::shouldEmit } void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( -llvm::Function *F) const { - F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +const FunctionType *&FT) const { + FT = getABIInfo().getContext().adjustFunctionType( + FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel)); } //===--===// Modified: cfe/trunk/lib/CodeGen/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.h?rev=334457&r1=334456&r2=334457&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.h (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.h Mon Jun 11 17:16:33 2018 @@ -302,7 +302,7 @@ public: /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } - virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} + virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const {} }; } // namespace
[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types
smeenai added a comment. Wrapping an Objective-C exception inside a C++ exception means dynamically constructing a C++ exception object and traversing the class hierarchy of the thrown Obj-C object to populate the catchable types array of the C++ exception. Microsoft's C++ runtime will perform the appropriate catch type comparisons, and this patch makes the compiler emit the right typeinfos into the exception handling tables for all of that to work. https://github.com/Microsoft/libobjc2/blob/f2e4c5ac4b3ac17f413a38bbc7ee1242f9efd0f7/msvc/eh_winobjc.cc#L116 is how WinObjC does this wrapping, for example. Essentially, with this patch, `@catch (I *)` in Obj-C ends up generating the same exception handling table as `catch (struct I *)` in C++ would. If you're throwing an `I *` (or any derived class), the runtime will generate an exception object which is catchable by this handler (the catchable types array for that exception object will contain the appropriate typeinfo). Successive catch clauses don't need any special handling; they work the same way as they would in C++. The runtime is generating that exception object based on a dynamic traversal of the class hierarchy, so I think Obj-C's dynamic semantics should be respected. Repository: rC Clang https://reviews.llvm.org/D47233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89 +new Callback(LCtx, MRMgr, ITraits)); + Finder.matchAST(ASTCtx); + NoQ wrote: > george.karpenkov wrote: > > ormris wrote: > > > george.karpenkov wrote: > > > > IMO using the iterator directly (e.g. like it was done in > > > > https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) > > > > leads to a much cleaner code and saves you from having to define a > > > > callback class. > > > Hmm... I think that's a better approach. Let me see if I can get that > > > working. > > @ormris Yeah I'm really not sure why all examples use the callback API by > > default. > Also, please match only the local AST, i.e. the body of the function under > analysis, which can be obtained as `LCtx->getDecl()->getBody()`. There's no > need to scan the whole translation unit. Actually not sure, would widening screw the previous stack frames as well? We should test that, i guess. And even then, it's better to match a few stack frames in the current stack trace than to match the whole translation unit. Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
NoQ added a comment. Thanks, this looks very reasonable! I agree that the syntax pointed out by @george.karpenkov is much cleaner. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h:30 ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState, +ASTContext &ASTCtx, const LocationContext *LCtx, You can obtain the `ASTContext` either from `PrevState->getStateManager()` or from `LCtx->getAnalysisDeclContext()`, there's no need to pass it separately. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:46-48 + explicit Callback(const LocationContext *LCtx_, MemRegionManager &MRMgr_, +RegionAndSymbolInvalidationTraits &ITraits_) + : LCtx(LCtx_), MRMgr(MRMgr_), ITraits(ITraits_) {} We usually just write `X(Y y): y(y) {}` and don't bother about name collisions. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89 +new Callback(LCtx, MRMgr, ITraits)); + Finder.matchAST(ASTCtx); + george.karpenkov wrote: > ormris wrote: > > george.karpenkov wrote: > > > IMO using the iterator directly (e.g. like it was done in > > > https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) > > > leads to a much cleaner code and saves you from having to define a > > > callback class. > > Hmm... I think that's a better approach. Let me see if I can get that > > working. > @ormris Yeah I'm really not sure why all examples use the callback API by > default. Also, please match only the local AST, i.e. the body of the function under analysis, which can be obtained as `LCtx->getDecl()->getBody()`. There's no need to scan the whole translation unit. Comment at: test/Analysis/loop-widening-preserve-reference-type.cpp:13 + for (int i = 0; i < 10; ++i) { } + clang_analyzer_eval(&x == &x); // expected-warning{{TRUE}} +} The expression is trivially true, i don't think it's exactly the thing we want to be testing. I'm not sure how to come up with a better test here. One good thing to test, which i'd prefer, would be `&x != 0` - which should be true because stack objects can't have address `0` and the analyzer is supposed to know that, but the symbolic pointer that would have overwritten `x` during over-aggressive widening could as well be null. Other alternatives are to add some sort of `clang_analyzer_getMemorySpace()` and check that the variable is still on the stack (which tests more, but is also more work) or use `clang_analyzer_dump()`/`clang_analyzer_explain()` to verify the exact value (but that'd test too much as it'd also test the dump format, which is redundant). Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48039: - Add "AV" as new default acronym. - Add support for "I" and "A" in lowerCamelCase pattern
This revision was automatically updated to reflect the committed changes. Closed by commit rL334448: - Add "AV" as new default acronym. - Add support for "I" and "A" in… (authored by Wizard, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D48039 Files: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -45,6 +45,7 @@ "AR", "ARGB", "ASCII", +"AV", "BGRA", "CA", "CF", @@ -153,7 +154,7 @@ std::string StartMatcher = UsedInMatcher ? "::" : "^"; std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms); return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" + - AcronymsMatcher + "|([A-Z][a-z0-9]+))*$"; + AcronymsMatcher + "|([A-Z][a-z0-9]+)|A|I)*$"; } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m === --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m @@ -22,6 +22,7 @@ @property(assign, nonatomic) int shouldUseCFPreferences; @property(assign, nonatomic) int enableGLAcceleration; @property(assign, nonatomic) int ID; +@property(assign, nonatomic) int hasADog; @end @interface Foo (Bar) Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -45,6 +45,7 @@ "AR", "ARGB", "ASCII", +"AV", "BGRA", "CA", "CF", @@ -153,7 +154,7 @@ std::string StartMatcher = UsedInMatcher ? "::" : "^"; std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms); return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" + - AcronymsMatcher + "|([A-Z][a-z0-9]+))*$"; + AcronymsMatcher + "|([A-Z][a-z0-9]+)|A|I)*$"; } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m === --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m @@ -22,6 +22,7 @@ @property(assign, nonatomic) int shouldUseCFPreferences; @property(assign, nonatomic) int enableGLAcceleration; @property(assign, nonatomic) int ID; +@property(assign, nonatomic) int hasADog; @end @interface Foo (Bar) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r334448 - - Add "AV" as new default acronym. - Add support for "I" and "A" in lowerCamelCase pattern
Author: wizard Date: Mon Jun 11 15:44:06 2018 New Revision: 334448 URL: http://llvm.org/viewvc/llvm-project?rev=334448&view=rev Log: - Add "AV" as new default acronym. - Add support for "I" and "A" in lowerCamelCase pattern Summary: Now we can support property names like "hasADog" correctly. Reviewers: benhamilton, hokein Reviewed By: benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48039 Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=334448&r1=334447&r2=334448&view=diff == --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Mon Jun 11 15:44:06 2018 @@ -45,6 +45,7 @@ constexpr llvm::StringLiteral DefaultSpe "AR", "ARGB", "ASCII", +"AV", "BGRA", "CA", "CF", @@ -153,7 +154,7 @@ std::string validPropertyNameRegex(llvm: std::string StartMatcher = UsedInMatcher ? "::" : "^"; std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms); return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" + - AcronymsMatcher + "|([A-Z][a-z0-9]+))*$"; + AcronymsMatcher + "|([A-Z][a-z0-9]+)|A|I)*$"; } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=334448&r1=334447&r2=334448&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m (original) +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Mon Jun 11 15:44:06 2018 @@ -22,6 +22,7 @@ @property(assign, nonatomic) int shouldUseCFPreferences; @property(assign, nonatomic) int enableGLAcceleration; @property(assign, nonatomic) int ID; +@property(assign, nonatomic) int hasADog; @end @interface Foo (Bar) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types
rjmccall added a comment. The non-fragile Objective-C path — i.e. interoperation with C++ exceptions instead of using `setjmp`/`longjmp` in an utterly-incompatible style — is absolutely the right direction going forward. How does "wrapping an Objective-C exception inside a C++ exception" work? Do you mean that you'll throw and catch a well-known C++ exception type and then separately test for subclassing in the catch clause? How do you intend to handle successive catch clauses in that case? Note that you cannot just wrap the Objective-C exception inside a separate C++ exception corresponding to the static type of the exception: unlike C++ pointers (even polymorphic ones), exception matching for ObjC pointers is based on the dynamic type of the exception. Repository: rC Clang https://reviews.llvm.org/D47233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334445 - [CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang
Author: phosek Date: Mon Jun 11 15:06:44 2018 New Revision: 334445 URL: http://llvm.org/viewvc/llvm-project?rev=334445&view=rev Log: [CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang We want to build the second stage compiler with libc++ and compiler-rt, also include builtins and runtimes into extra bootstrap components to ensure these get built. Differential Revision: https://reviews.llvm.org/D47356 Modified: cfe/trunk/cmake/caches/Fuchsia.cmake Modified: cfe/trunk/cmake/caches/Fuchsia.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=334445&r1=33&r2=334445&view=diff == --- cfe/trunk/cmake/caches/Fuchsia.cmake (original) +++ cfe/trunk/cmake/caches/Fuchsia.cmake Mon Jun 11 15:06:44 2018 @@ -21,6 +21,9 @@ if(NOT APPLE) set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") endif() +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") + if(APPLE) set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") @@ -51,6 +54,10 @@ endforeach() # Setup the bootstrap build. set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_EXTRA_DEPS + builtins + runtimes + CACHE STRING "") set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47356: [CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang
This revision was automatically updated to reflect the committed changes. Closed by commit rC334445: [CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang (authored by phosek, committed by ). Changed prior to commit: https://reviews.llvm.org/D47356?vs=150841&id=150859#toc Repository: rC Clang https://reviews.llvm.org/D47356 Files: cmake/caches/Fuchsia.cmake Index: cmake/caches/Fuchsia.cmake === --- cmake/caches/Fuchsia.cmake +++ cmake/caches/Fuchsia.cmake @@ -21,6 +21,9 @@ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") endif() +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") + if(APPLE) set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") @@ -51,6 +54,10 @@ # Setup the bootstrap build. set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_EXTRA_DEPS + builtins + runtimes + CACHE STRING "") set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake Index: cmake/caches/Fuchsia.cmake === --- cmake/caches/Fuchsia.cmake +++ cmake/caches/Fuchsia.cmake @@ -21,6 +21,9 @@ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") endif() +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") + if(APPLE) set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") @@ -51,6 +54,10 @@ # Setup the bootstrap build. set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_EXTRA_DEPS + builtins + runtimes + CACHE STRING "") set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
rjmccall added a comment. Thanks, comment change looks good. LGTM. https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48053: Correct behavior of __builtin_*_overflow and constexpr.
efriedma added a reviewer: rsmith. efriedma added inline comments. Comment at: lib/Sema/SemaChecking.cpp:228 + S.getASTContext(), Ty, /*consume*/ false); + Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); + TheCall->setArg(2, Arg.get()); Is it possible for this initialization to fail? If it can't fail, please add an assertion; otherwise, you probably need to "return true". (Not sure off the top of my head how that would happen; maybe it would error out on a `volatile int*`?) Repository: rC Clang https://reviews.llvm.org/D48053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47618: __c11_atomic_load's _Atomic can be const
rsmith added a comment. We need to figure out what should happen in the OpenCL case, but the rest seems fine. Comment at: lib/Sema/SemaChecking.cpp:3360 } -if (AtomTy.isConstQualified() || +if ((Form != Load && Form != LoadCopy && AtomTy.isConstQualified()) || AtomTy.getAddressSpace() == LangAS::opencl_constant) { The `LoadCopy` check is redundant; only the GNU `__atomic_load` builtin has the `LoadCopy` form. But see below, we can avoid this duplicated condition with some refactoring. Comment at: lib/Sema/SemaChecking.cpp:3361 +if ((Form != Load && Form != LoadCopy && AtomTy.isConstQualified()) || AtomTy.getAddressSpace() == LangAS::opencl_constant) { Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_atomic) We also need to figure out what to do about this -- should an atomic load from a constant address space be valid? (It seems a little pointless to use an *atomic* load here, but not obviously wrong.) Comment at: lib/Sema/SemaChecking.cpp:3368-3374 } else if (Form != Load && Form != LoadCopy) { if (ValType.isConstQualified()) { Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_pointer) << Ptr->getType() << Ptr->getSourceRange(); return ExprError(); } } It would be a little nicer to change this `else if` to a plain `if` and conditionalize the diagnostic instead. Can you track down whoever added the address space check to the C11 atomic path and ask them if they really meant for it to not apply to the GNU atomic builtins? Repository: rC Clang https://reviews.llvm.org/D47618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
efriedma added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:10071 + // is _MM_FROUND_CUR_DIRECTION + if (cast(Ops[4])->getZExtValue() != 4) +UsesNonDefaultRounding = true; Given we're ignoring floating-point exceptions, we should also ignore the "rounding mode" operand (__MM_FROUND_NO_EXC only affects exceptions, and the other values are irrelevant because there isn't any actual rounding involved). Comment at: lib/CodeGen/CGBuiltin.cpp:10156 -// We can't handle 8-31 immediates with native IR, use the intrinsic. -// Except for predicates that create constants. +// These two must still use the intrinsic, when some interseting rounding +// mode is specified. *interesting. https://reviews.llvm.org/D45616 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.
vsapsai added a comment. With this change and the mentioned libc++ change the tests with old libc++ dylib are passing (didn't test all possible configurations though). Would like to get more feedback from other reviewers on this matter. https://reviews.llvm.org/D45015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48053: Correct behavior of __builtin_*_overflow and constexpr.
erichkeane created this revision. erichkeane added a reviewer: eli.friedman. Enable these builtins to be called across a lambda boundary, as brought up by Eli here: https://reviews.llvm.org/D48040 Repository: rC Clang https://reviews.llvm.org/D48053 Files: lib/Sema/SemaChecking.cpp test/SemaCXX/builtins-overflow.cpp Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -197,28 +197,36 @@ // First two arguments should be integers. for (unsigned I = 0; I < 2; ++I) { -Expr *Arg = TheCall->getArg(I); -QualType Ty = Arg->getType(); +ExprResult Arg = TheCall->getArg(I); +QualType Ty = Arg.get()->getType(); if (!Ty->isIntegerType()) { - S.Diag(Arg->getLocStart(), diag::err_overflow_builtin_must_be_int) - << Ty << Arg->getSourceRange(); + S.Diag(Arg.get()->getLocStart(), diag::err_overflow_builtin_must_be_int) + << Ty << Arg.get()->getSourceRange(); return true; } +InitializedEntity Entity = InitializedEntity::InitializeParameter( +S.getASTContext(), Ty, /*consume*/ false); +Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); +TheCall->setArg(I, Arg.get()); } // Third argument should be a pointer to a non-const integer. // IRGen correctly handles volatile, restrict, and address spaces, and // the other qualifiers aren't possible. { -Expr *Arg = TheCall->getArg(2); -QualType Ty = Arg->getType(); +ExprResult Arg = TheCall->getArg(2); +QualType Ty = Arg.get()->getType(); const auto *PtrTy = Ty->getAs(); if (!(PtrTy && PtrTy->getPointeeType()->isIntegerType() && !PtrTy->getPointeeType().isConstQualified())) { - S.Diag(Arg->getLocStart(), diag::err_overflow_builtin_must_be_ptr_int) - << Ty << Arg->getSourceRange(); + S.Diag(Arg.get()->getLocStart(), diag::err_overflow_builtin_must_be_ptr_int) + << Ty << Arg.get()->getSourceRange(); return true; } + InitializedEntity Entity = InitializedEntity::InitializeParameter( + S.getASTContext(), Ty, /*consume*/ false); + Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); + TheCall->setArg(2, Arg.get()); } return false; Index: test/SemaCXX/builtins-overflow.cpp === --- test/SemaCXX/builtins-overflow.cpp +++ test/SemaCXX/builtins-overflow.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics + +int a() { + const int x = 3; + static int z; + constexpr int *y = &z; + return []() { return __builtin_sub_overflow((int)x, (int)x, (int *)y); }(); +} +int a2() { + const int x = 3; + static int z; + constexpr int *y = &z; + return []() { return __builtin_sub_overflow(x, x, y); }(); +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -197,28 +197,36 @@ // First two arguments should be integers. for (unsigned I = 0; I < 2; ++I) { -Expr *Arg = TheCall->getArg(I); -QualType Ty = Arg->getType(); +ExprResult Arg = TheCall->getArg(I); +QualType Ty = Arg.get()->getType(); if (!Ty->isIntegerType()) { - S.Diag(Arg->getLocStart(), diag::err_overflow_builtin_must_be_int) - << Ty << Arg->getSourceRange(); + S.Diag(Arg.get()->getLocStart(), diag::err_overflow_builtin_must_be_int) + << Ty << Arg.get()->getSourceRange(); return true; } +InitializedEntity Entity = InitializedEntity::InitializeParameter( +S.getASTContext(), Ty, /*consume*/ false); +Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); +TheCall->setArg(I, Arg.get()); } // Third argument should be a pointer to a non-const integer. // IRGen correctly handles volatile, restrict, and address spaces, and // the other qualifiers aren't possible. { -Expr *Arg = TheCall->getArg(2); -QualType Ty = Arg->getType(); +ExprResult Arg = TheCall->getArg(2); +QualType Ty = Arg.get()->getType(); const auto *PtrTy = Ty->getAs(); if (!(PtrTy && PtrTy->getPointeeType()->isIntegerType() && !PtrTy->getPointeeType().isConstQualified())) { - S.Diag(Arg->getLocStart(), diag::err_overflow_builtin_must_be_ptr_int) - << Ty << Arg->getSourceRange(); + S.Diag(Arg.get()->getLocStart(), diag::err_overflow_builtin_must_be_ptr_int) + << Ty << Arg.get()->getSourceRange(); return true; } + InitializedEntity Entity = InitializedEntity::InitializeParameter( + S.getASTContext(), Ty, /*consume*/ false); + Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); + TheCall->setArg(2, Arg.get()); } return false; Index: test/SemaCXX/builtins-overflow.cpp
[PATCH] D48040: Implement constexpr __builtin_*_overflow
erichkeane added a comment. Alright, done here: https://reviews.llvm.org/D48053 This one'll require some rebasing on that change, but I'm not sure how to do it in SVN. Therefore, I'll just rebase this one when it comes to commit it. -Erich https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size
compnerd accepted this revision. compnerd added a comment. This revision is now accepted and ready to land. This makes much more sense. Thanks @joerg https://reviews.llvm.org/D38680 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47356: [CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang
phosek updated this revision to Diff 150841. Repository: rC Clang https://reviews.llvm.org/D47356 Files: clang/cmake/caches/Fuchsia.cmake Index: clang/cmake/caches/Fuchsia.cmake === --- clang/cmake/caches/Fuchsia.cmake +++ clang/cmake/caches/Fuchsia.cmake @@ -21,6 +21,9 @@ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") endif() +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") + if(APPLE) set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") @@ -51,6 +54,10 @@ # Setup the bootstrap build. set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_EXTRA_DEPS + builtins + runtimes + CACHE STRING "") set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake Index: clang/cmake/caches/Fuchsia.cmake === --- clang/cmake/caches/Fuchsia.cmake +++ clang/cmake/caches/Fuchsia.cmake @@ -21,6 +21,9 @@ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") endif() +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") + if(APPLE) set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") @@ -51,6 +54,10 @@ # Setup the bootstrap build. set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_EXTRA_DEPS + builtins + runtimes + CACHE STRING "") set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47355: [CMake] Allow specifying extra dependencies of bootstrap stage
phosek updated this revision to Diff 150838. phosek marked an inline comment as done. Repository: rC Clang https://reviews.llvm.org/D47355 Files: clang/CMakeLists.txt Index: clang/CMakeLists.txt === --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -583,6 +583,10 @@ endif() endif() + if(CLANG_BOOTSTRAP_EXTRA_DEPS) +add_dependencies(clang-bootstrap-deps ${CLANG_BOOTSTRAP_EXTRA_DEPS}) + endif() + add_custom_target(${NEXT_CLANG_STAGE}-clear DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared ) Index: clang/CMakeLists.txt === --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -583,6 +583,10 @@ endif() endif() + if(CLANG_BOOTSTRAP_EXTRA_DEPS) +add_dependencies(clang-bootstrap-deps ${CLANG_BOOTSTRAP_EXTRA_DEPS}) + endif() + add_custom_target(${NEXT_CLANG_STAGE}-clear DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47355: [CMake] Allow specifying extra dependencies of bootstrap stage
This revision was automatically updated to reflect the committed changes. Closed by commit rL334437: [CMake] Allow specifying extra dependencies of bootstrap stage (authored by phosek, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D47355?vs=150838&id=150839#toc Repository: rL LLVM https://reviews.llvm.org/D47355 Files: cfe/trunk/CMakeLists.txt Index: cfe/trunk/CMakeLists.txt === --- cfe/trunk/CMakeLists.txt +++ cfe/trunk/CMakeLists.txt @@ -583,6 +583,10 @@ endif() endif() + if(CLANG_BOOTSTRAP_EXTRA_DEPS) +add_dependencies(clang-bootstrap-deps ${CLANG_BOOTSTRAP_EXTRA_DEPS}) + endif() + add_custom_target(${NEXT_CLANG_STAGE}-clear DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared ) Index: cfe/trunk/CMakeLists.txt === --- cfe/trunk/CMakeLists.txt +++ cfe/trunk/CMakeLists.txt @@ -583,6 +583,10 @@ endif() endif() + if(CLANG_BOOTSTRAP_EXTRA_DEPS) +add_dependencies(clang-bootstrap-deps ${CLANG_BOOTSTRAP_EXTRA_DEPS}) + endif() + add_custom_target(${NEXT_CLANG_STAGE}-clear DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334437 - [CMake] Allow specifying extra dependencies of bootstrap stage
Author: phosek Date: Mon Jun 11 13:59:31 2018 New Revision: 334437 URL: http://llvm.org/viewvc/llvm-project?rev=334437&view=rev Log: [CMake] Allow specifying extra dependencies of bootstrap stage This allows adding additional bootstrap dependencies to the bootstrap compiler that may be needed by later stages. Differential Revision: https://reviews.llvm.org/D47355 Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=334437&r1=334436&r2=334437&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Mon Jun 11 13:59:31 2018 @@ -583,6 +583,10 @@ if (CLANG_ENABLE_BOOTSTRAP) endif() endif() + if(CLANG_BOOTSTRAP_EXTRA_DEPS) +add_dependencies(clang-bootstrap-deps ${CLANG_BOOTSTRAP_EXTRA_DEPS}) + endif() + add_custom_target(${NEXT_CLANG_STAGE}-clear DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47355: [CMake] Allow specifying extra dependencies of bootstrap stage
beanz accepted this revision. beanz added a comment. This revision is now accepted and ready to land. I prefer `DEPS` to `COMPONENTS` because I've tried to explicitly use the term components to mean targets that have paired build and install targets. Otherwise looks good. Repository: rC Clang https://reviews.llvm.org/D47355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
erichkeane added inline comments. Comment at: lib/Sema/SemaChecking.cpp:210 +Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); +TheCall->setArg(I, Arg.get()); } efriedma wrote: > erichkeane wrote: > > efriedma wrote: > > > Can you split this change into a separate patch? Testcase: > > > > > > ``` > > > int a() { > > > const int x = 3; > > > static int z; > > > constexpr int * y = &z; > > > return []() { return __builtin_sub_overflow(x,x,y); }(); > > > }``` > > Can you clarify what you mean? That above testcase (with added captures) > > seems to work currently. What difference in behavior should I be expecting? > The testcase should type-check as-is, without adding any captures. Reading > the value of a constexpr variable, or a const variable of integer type, isn't > an odr-use. This doesn't work correctly at the moment because the > lvalue-to-rvalue conversions are missing from the AST. Compare to the > following: > > ``` > int a() { > const int x = 3; > static int z; > constexpr int * y = &z; > return []() { return __builtin_sub_overflow((int)x,(int)x,(int*)y); }(); > } > ``` Ah, got it! I 'll split that off into a separate patch with those test cases now. Look for the review soon! https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
efriedma added inline comments. Comment at: lib/Sema/SemaChecking.cpp:210 +Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); +TheCall->setArg(I, Arg.get()); } erichkeane wrote: > efriedma wrote: > > Can you split this change into a separate patch? Testcase: > > > > ``` > > int a() { > > const int x = 3; > > static int z; > > constexpr int * y = &z; > > return []() { return __builtin_sub_overflow(x,x,y); }(); > > }``` > Can you clarify what you mean? That above testcase (with added captures) > seems to work currently. What difference in behavior should I be expecting? The testcase should type-check as-is, without adding any captures. Reading the value of a constexpr variable, or a const variable of integer type, isn't an odr-use. This doesn't work correctly at the moment because the lvalue-to-rvalue conversions are missing from the AST. Compare to the following: ``` int a() { const int x = 3; static int z; constexpr int * y = &z; return []() { return __builtin_sub_overflow((int)x,(int)x,(int*)y); }(); } ``` https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30760: Record command lines in objects built by clang, Clang part
george.burgess.iv closed this revision. george.burgess.iv added a comment. Herald added a subscriber: JDevlieghere. (Committed as noted by echristo; just trying to clean my queue a bit. :) ) https://reviews.llvm.org/D30760 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease
rnk added a comment. In https://reviews.llvm.org/D47672#1128308, @hans wrote: > It sounds like adding proper support for HLE prefixes is a largeish project. > > ctopper, rnk: Do you think it would be worth adding inline asm versions (with > the xacquire/release prefixes) of these intrinsics in the meantime? It would > inhibit optimizations but be better than the current state of not having the > intrinsics at all. Yeah, let's do that. I'm a lot more comfortable ignoring bugs about missed optimizations with fancy intrinsics than bugs that say the intrinsic doesn't do what it says it does. Repository: rC Clang https://reviews.llvm.org/D47672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47671: [analyzer] Implement copy elision.
NoQ added a comment. In https://reviews.llvm.org/D47671#1127486, @xazax.hun wrote: > Just for the record, there is a common example where relying on copy elision > might bite and google do not recommend relying on it for correctness: > https://abseil.io/tips/120 > > The main purpose of sharing is to add some more context to the discussion, I > do not consider this to be an argument, because I can still see that this > practice as opinionated. Ah, NRVO, thanks for pointing it out! We can't do that yet, this patch only enables simple RVO. Also it seems that NRVO isn't mandatory even in C++17. In any case, it's clear that relying on any sort of copy elision should be treated as a bug, but not necessarily a high-priority bug, and i'm not seeing any better way of detecting this bug other than suggesting the user to run a separate analysis with copy elision disabled and see if any of our usual kinds of bugs are found. P.S. It seems that one of my currently-on-review patches has introduced a performance regression, i'm investigating it. Repository: rC Clang https://reviews.llvm.org/D47671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48044: [Power9] Update fp128 as a valid homogenous aggregate base type
lei updated this revision to Diff 150821. https://reviews.llvm.org/D48044 Files: include/clang/AST/Type.h lib/CodeGen/TargetInfo.cpp test/CodeGen/ppc64le-f128Aggregates.c Index: test/CodeGen/ppc64le-f128Aggregates.c === --- /dev/null +++ test/CodeGen/ppc64le-f128Aggregates.c @@ -0,0 +1,124 @@ +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm \ +// RUN: -target-cpu pwr9 -target-feature +float128 -o - %s | FileCheck %s + +// Test homogeneous fp128 aggregate passing and returning. + +struct fp1 { __float128 f[1]; }; +struct fp2 { __float128 f[2]; }; +struct fp3 { __float128 f[3]; }; +struct fp4 { __float128 f[4]; }; +struct fp5 { __float128 f[5]; }; +struct fp6 { __float128 f[6]; }; +struct fp7 { __float128 f[7]; }; +struct fp8 { __float128 f[8]; }; +struct fp9 { __float128 f[9]; }; + +struct fpab { __float128 a; __float128 b; }; +struct fpabc { __float128 a; __float128 b; __float128 c; }; + +struct fp2a2b { __float128 a[2]; __float128 b[2]; }; + +// CHECK: define [1 x fp128] @func_f1(fp128 inreg %x.coerce) +struct fp1 func_f1(struct fp1 x) { return x; } + +// CHECK: define [2 x fp128] @func_f2([2 x fp128] %x.coerce) +struct fp2 func_f2(struct fp2 x) { return x; } + +// CHECK: define [3 x fp128] @func_f3([3 x fp128] %x.coerce) +struct fp3 func_f3(struct fp3 x) { return x; } + +// CHECK: define [4 x fp128] @func_f4([4 x fp128] %x.coerce) +struct fp4 func_f4(struct fp4 x) { return x; } + +// CHECK: define [5 x fp128] @func_f5([5 x fp128] %x.coerce) +struct fp5 func_f5(struct fp5 x) { return x; } + +// CHECK: define [6 x fp128] @func_f6([6 x fp128] %x.coerce) +struct fp6 func_f6(struct fp6 x) { return x; } + +// CHECK: define [7 x fp128] @func_f7([7 x fp128] %x.coerce) +struct fp7 func_f7(struct fp7 x) { return x; } + +// CHECK: define [8 x fp128] @func_f8([8 x fp128] %x.coerce) +struct fp8 func_f8(struct fp8 x) { return x; } + +// CHECK: define void @func_f9(%struct.fp9* noalias sret %agg.result, %struct.fp9* byval align 16 %x) +struct fp9 func_f9(struct fp9 x) { return x; } + +// CHECK: define [2 x fp128] @func_fab([2 x fp128] %x.coerce) +struct fpab func_fab(struct fpab x) { return x; } + +// CHECK: define [3 x fp128] @func_fabc([3 x fp128] %x.coerce) +struct fpabc func_fabc(struct fpabc x) { return x; } + +// CHECK: define [4 x fp128] @func_f2a2b([4 x fp128] %x.coerce) +struct fp2a2b func_f2a2b(struct fp2a2b x) { return x; } + +// CHECK-LABEL: @call_fp1 +// CHECK: %[[TMP:[^ ]+]] = load fp128, fp128* getelementptr inbounds (%struct.fp1, %struct.fp1* @global_f1, i32 0, i32 0, i32 0), align 16 +// CHECK: call [1 x fp128] @func_f1(fp128 inreg %[[TMP]]) +struct fp1 global_f1; +void call_fp1(void) { global_f1 = func_f1(global_f1); } + +// CHECK-LABEL: @call_fp2 +// CHECK: %[[TMP:[^ ]+]] = load [2 x fp128], [2 x fp128]* getelementptr inbounds (%struct.fp2, %struct.fp2* @global_f2, i32 0, i32 0), align 16 +// CHECK: call [2 x fp128] @func_f2([2 x fp128] %[[TMP]]) +struct fp2 global_f2; +void call_fp2(void) { global_f2 = func_f2(global_f2); } + +// CHECK-LABEL: @call_fp3 +// CHECK: %[[TMP:[^ ]+]] = load [3 x fp128], [3 x fp128]* getelementptr inbounds (%struct.fp3, %struct.fp3* @global_f3, i32 0, i32 0), align 16 +// CHECK: call [3 x fp128] @func_f3([3 x fp128] %[[TMP]]) +struct fp3 global_f3; +void call_fp3(void) { global_f3 = func_f3(global_f3); } + +// CHECK-LABEL: @call_fp4 +// CHECK: %[[TMP:[^ ]+]] = load [4 x fp128], [4 x fp128]* getelementptr inbounds (%struct.fp4, %struct.fp4* @global_f4, i32 0, i32 0), align 16 +// CHECK: call [4 x fp128] @func_f4([4 x fp128] %[[TMP]]) +struct fp4 global_f4; +void call_fp4(void) { global_f4 = func_f4(global_f4); } + +// CHECK-LABEL: @call_fp5 +// CHECK: %[[TMP:[^ ]+]] = load [5 x fp128], [5 x fp128]* getelementptr inbounds (%struct.fp5, %struct.fp5* @global_f5, i32 0, i32 0), align 16 +// CHECK: call [5 x fp128] @func_f5([5 x fp128] %[[TMP]]) +struct fp5 global_f5; +void call_fp5(void) { global_f5 = func_f5(global_f5); } + +// CHECK-LABEL: @call_fp6 +// CHECK: %[[TMP:[^ ]+]] = load [6 x fp128], [6 x fp128]* getelementptr inbounds (%struct.fp6, %struct.fp6* @global_f6, i32 0, i32 0), align 16 +// CHECK: call [6 x fp128] @func_f6([6 x fp128] %[[TMP]]) +struct fp6 global_f6; +void call_fp6(void) { global_f6 = func_f6(global_f6); } + +// CHECK-LABEL: @call_fp7 +// CHECK: %[[TMP:[^ ]+]] = load [7 x fp128], [7 x fp128]* getelementptr inbounds (%struct.fp7, %struct.fp7* @global_f7, i32 0, i32 0), align 16 +// CHECK: call [7 x fp128] @func_f7([7 x fp128] %[[TMP]]) +struct fp7 global_f7; +void call_fp7(void) { global_f7 = func_f7(global_f7); } + +// CHECK-LABEL: @call_fp8 +// CHECK: %[[TMP:[^ ]+]] = load [8 x fp128], [8 x fp128]* getelementptr inbounds (%struct.fp8, %struct.fp8* @global_f8, i32 0, i32 0), align 16 +// CHECK: call [8 x fp128] @func_f8([8 x fp128] %[[TMP]]) +struct fp8 global_f8; +void call_fp8(void) { global_f8 = func_f8(global_f8); } + +// CHECK-LABEL: @call_fp9 +// CHECK: %
[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain
gtbercea marked 3 inline comments as done. gtbercea added inline comments. Comment at: include/clang/Driver/Compilation.h:312 + /// \param skipBundler - bool value set once by the driver. + void setSkipOffloadBundler(bool skipBundler); + sfantao wrote: > Why is this a property of the compilation and not of a set of actions > referring to a given target? That would allow one to combine in the same > compilation targets requiring the bundler and targets that wouldn't. This was a way to pass this information to the OpenMP NVPTX device toolchain. Both the Driver OpenMP NVPTX toolchain need to agree on the usage of the new scheme (proposed in this patch) or the old scheme (the one that is in the compiler today). Comment at: lib/Driver/Compilation.cpp:276 +void Compilation::setSkipOffloadBundler(bool skipBundler) { + skipOffloadBundler = skipBundler; +} sfantao wrote: > Given the logic you have below, you are assuming this is not set to false > ever. It would be wise to get an assertion here in case you end up having > toolchains skipping and others don't. If that is just not supported a > diagnostic should be added instead. > > The convention is that local variables use CamelCase. The checks I added in the Driver will set this flag to true if all toolchains Clang offloads to support the skipping of the bundler/unbundler for object files. Currently only NVPTX toolchain can skip the bundler/unbundler for object files so the code path in this patch will be taken only for: -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda Comment at: lib/Driver/Driver.cpp:2943 +} + } + sfantao wrote: > Can you just implement this check in the definition of `Compilation: > canSkipClangOffloadBundler` and get rid of `setSkipOffloadBundler`? All the > requirted information is already in `Compilation` under `C.getInputArgs()`. The driver needs to have the result of this check available. The flag is passed to the step which adds host-device dependencies. If the bundler can be skipped then the unbundling action is not required. I guess this could be implemented in Compilation. Even so I would like it to happen only once like it does here and not every time someone queries the "can I skip the bundler" flag. I wanted this check to happen only once hence why I put in on the driver side. The result of this check needs to be available in Driver.cpp and in Cuda.cpp files (see usage in this patch). Compilation keeps track of the flag because skipping the bundler is an all or nothing flag: you can skip the bundler/unbundler for object files if and only if all toolchains you are offloading to can skip it. Comment at: lib/Driver/Driver.cpp:2962 +// is ld instead but this needs to be replaced. +canDoPartialLinking = LinkerName.endswith("/ld"); + } sfantao wrote: > In the current implementation there is no distinction between what is meant > for Windows/Linux. This check would only work on Linux and the test below > would fail for bots running windows. > > Also, I think it makes more sense to have this check part of the `Toolchain` > instead of doing it in the driver. The `Toolchain` definition knows the names > of the third-party executables, the driver doesn't. Currently this is only meant to work with ld because that we know for sure is a linker which supports partial linking. If other linkers also support it then they can be added here. Not finding ld will lead to the old scheme being used. You are correct the test needs to be fixed. Comment at: lib/Driver/ToolChains/Clang.cpp:5504 + StringRef LinkerName = getToolChain().GetLinkerPath(); + assert(LinkerName.endswith("/ld") && "Partial linking not supported."); + sfantao wrote: > I believe this check should be done when the toolchain is created with all > the required diagnostics. What happens if the linker does not support partial > linking? The linker should always support partial linking at this point, hence the assert. The linker not supporting partial linking is determined at a much earlier step so by this point we should already have that information. In the eventuality that some corner case arises that I may have missed then this assert is triggered. But it would be really unexpected for this assert to be triggered since choosing this action is based on the linker supporting partial linking. Comment at: lib/Driver/ToolChains/Cuda.cpp:536 + } } sfantao wrote: > gtbercea wrote: > > sfantao wrote: > > > What prevents all this from being done in the bundler? If I understand it > > > correctly, if the bundler implements this wrapping all the checks for > > > librariers wouldn't be required and, only two changes would be required > > > in the driver: > > > > > > - generate fatbin instead of cubin. This is straightf
[libcxx] r334431 - Mark the test using to require c++experimental.
Author: vsapsai Date: Mon Jun 11 12:42:27 2018 New Revision: 334431 URL: http://llvm.org/viewvc/llvm-project?rev=334431&view=rev Log: Mark the test using to require c++experimental. When built against the old libc++ version the test was causing linker error Undefined symbols for architecture x86_64: "std::experimental::fundamentals_v1::pmr::new_delete_resource()", referenced from: void test_evil() in construct_piecewise_pair_evil.pass.cpp.o void test_evil() in construct_piecewise_pair_evil.pass.cpp.o void test_evil() in construct_piecewise_pair_evil.pass.cpp.o void test_evil() in construct_piecewise_pair_evil.pass.cpp.o void test_evil() in construct_piecewise_pair_evil.pass.cpp.o void test_evil() in construct_piecewise_pair_evil.pass.cpp.o void test_evil() in construct_piecewise_pair_evil.pass.cpp.o ... Modified: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp Modified: libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp?rev=334431&r1=334430&r2=334431&view=diff == --- libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp Mon Jun 11 12:42:27 2018 @@ -7,6 +7,7 @@ // //===--===// +// REQUIRES: c++experimental // UNSUPPORTED: c++98, c++03 // ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: [Sema] Missing -Wlogical-op-parentheses warnings in macros (PR18971)
dexonsmith added a comment. In https://reviews.llvm.org/D47687#1127120, @Higuoxing wrote: > In https://reviews.llvm.org/D47687#1126607, @dexonsmith wrote: > > > In https://reviews.llvm.org/D47687#1126074, @lebedev.ri wrote: > > > > > In https://reviews.llvm.org/D47687#1126032, @Higuoxing wrote: > > > > > > > In https://reviews.llvm.org/D47687#1125926, @rnk wrote: > > > > > > > > > @dexonsmith is there someone from Apple who can comment on > > > > > rdar://8678458 and the merits of disabling this warning in macros? I > > > > > strongly suspect the original report was dealing with code like > > > > > `assert(x || y && "str");`, if so we can go forward with this. > > > > > > > > > > @chandlerc I know you've hit this behavior difference vs. GCC before. > > > > > Any thoughts on the proposed change? > > > > > > > > > > > > > > > > > > > > In https://reviews.llvm.org/D47687#1125964, @dexonsmith wrote: > > > > > > > > > In https://reviews.llvm.org/D47687#1125926, @rnk wrote: > > > > > > > > > > > @dexonsmith is there someone from Apple who can comment on > > > > > > rdar://8678458 and the merits of disabling this warning in macros? > > > > > > I strongly suspect the original report was dealing with code like > > > > > > `assert(x || y && "str");`, if so we can go forward with this. > > > > > > > > > > > > > > > There were two commits with this radar: r119537 and r119540. The > > > > > main motivation was a deeply nested macro that when "inlined" > > > > > included the moral equivalent of `#define DOUBLE_OP(OP1, OP2, X, Y, > > > > > Z) (X OP1 Y OP2 Z)`. There was terrible note spew when the warning > > > > > fired in this case, and the use case for the macro made the warning > > > > > un-actionable. We decided to suppress the warning entirely: > > > > > > > > > > > As a general comment, the warning seems to be useless for macros; > > > > > > I'll follow the example of warn_logical_instead_of_bitwise which > > > > > > doesn't trigger for macros and I'll make the warning not warn for > > > > > > macros. > > > > > > > > > > > > Hi, Thank you, > > > > > > > > I noticed that `warn_logical_instead_of_bitwise ` will also skip > > > > parentheses checking in macros... well, this patch seems not so > > > > necessary... both ok for me ... depends on all of you :-) > > > > > > > > > At worst, we can issue this warning in a new `-Wparentheses-in-macros` > > > subgroup, which, if apple so insists, could be off-by-default. > > > That would less worse than just completely silencing it for the entire > > > world. > > > > > > I’d be fine with strengthening the existing warning as long as there is an > > actionable fix-it. I suspect if you suppress it when the relevant > > expression is constructed from multiple macro arguments that will be good > > enough. > > > Thanks, currently, `[-Wparentheses | -Wlogical-op-parentheses]` will not emit > warning for parentheses in macros. only if you add > `[-Wlogical-op-parentheses-in-macros]` it will emit something like `'&&' > within '||'` warning... > > However, `'&' within '|'` checking was disabled in macros as well... I don't > know if this patch meet the needs... if this patch was ok, then, just as > @lebedev.ri said, Maybe we could add a `[-Wparentheses-in-macros]` subgroup > and add these warning into this new group, in the future... depends on users > :-) any suggestion? Yes, I think understand the patch; but I think it's the wrong direction. I think we should just make the existing `-Wlogical-op-parentheses` smart enough to show actionable warnings in macros (but suppress the ones that are not actionable, like the internals of `foo(&&, ||, ...)`, rather than adding `-Wlogical-op-parentheses-in-macros`, which sounds like it would be permanently off-by-default. https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34156: [LTO] Enable module summary emission by default for regular LTO
tobiasvk added a comment. In https://reviews.llvm.org/D34156#1125489, @vlad.tsyrklevich wrote: > Hi Tobias, I tracked down the failure self-hosting LLVM with LTO with this > revision to https://bugs.llvm.org/show_bug.cgi?id=37684#c2 and have a fix > under review in https://reviews.llvm.org/D47898. Fantastic! That sounds exactly like the problem I was seeing back then. Thanks for tracking this down! > Are you still interested in landing this? Sure, I'll push an update to the patch. Tobias https://reviews.llvm.org/D34156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
erichkeane added inline comments. Comment at: lib/Sema/SemaChecking.cpp:210 +Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); +TheCall->setArg(I, Arg.get()); } efriedma wrote: > Can you split this change into a separate patch? Testcase: > > ``` > int a() { > const int x = 3; > static int z; > constexpr int * y = &z; > return []() { return __builtin_sub_overflow(x,x,y); }(); > }``` Can you clarify what you mean? That above testcase (with added captures) seems to work currently. What difference in behavior should I be expecting? https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
efriedma added inline comments. Comment at: lib/Sema/SemaChecking.cpp:210 +Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); +TheCall->setArg(I, Arg.get()); } Can you split this change into a separate patch? Testcase: ``` int a() { const int x = 3; static int z; constexpr int * y = &z; return []() { return __builtin_sub_overflow(x,x,y); }(); }``` https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
erichkeane updated this revision to Diff 150808. erichkeane marked an inline comment as done. https://reviews.llvm.org/D48040 Files: lib/AST/ExprConstant.cpp lib/Sema/SemaChecking.cpp test/SemaCXX/builtins-overflow.cpp Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -8155,6 +8155,124 @@ case Builtin::BIomp_is_initial_device: // We can decide statically which value the runtime would return if called. return Success(Info.getLangOpts().OpenMPIsDevice ? 0 : 1, E); + case Builtin::BI__builtin_add_overflow: + case Builtin::BI__builtin_sub_overflow: + case Builtin::BI__builtin_mul_overflow: + case Builtin::BI__builtin_sadd_overflow: + case Builtin::BI__builtin_uadd_overflow: + case Builtin::BI__builtin_uaddl_overflow: + case Builtin::BI__builtin_uaddll_overflow: + case Builtin::BI__builtin_usub_overflow: + case Builtin::BI__builtin_usubl_overflow: + case Builtin::BI__builtin_usubll_overflow: + case Builtin::BI__builtin_umul_overflow: + case Builtin::BI__builtin_umull_overflow: + case Builtin::BI__builtin_umulll_overflow: + case Builtin::BI__builtin_saddl_overflow: + case Builtin::BI__builtin_saddll_overflow: + case Builtin::BI__builtin_ssub_overflow: + case Builtin::BI__builtin_ssubl_overflow: + case Builtin::BI__builtin_ssubll_overflow: + case Builtin::BI__builtin_smul_overflow: + case Builtin::BI__builtin_smull_overflow: + case Builtin::BI__builtin_smulll_overflow: { +LValue ResultLValue; +APSInt LHS, RHS; + +QualType ResultType = E->getArg(2)->getType()->getPointeeType(); +if (!EvaluateInteger(E->getArg(0), LHS, Info) || +!EvaluateInteger(E->getArg(1), RHS, Info) || +!EvaluatePointer(E->getArg(2), ResultLValue, Info)) + return false; + +APSInt Result; +bool DidOverflow = false; + +// If the types don't have to match, enlarge all 3 to the largest of them. +if (BuiltinOp == Builtin::BI__builtin_add_overflow || +BuiltinOp == Builtin::BI__builtin_sub_overflow || +BuiltinOp == Builtin::BI__builtin_mul_overflow) { + bool IsSigned = LHS.isSigned() || RHS.isSigned() || + ResultType->isSignedIntegerOrEnumerationType(); + bool AllSigned = LHS.isSigned() && RHS.isSigned() && + ResultType->isSignedIntegerOrEnumerationType(); + uint64_t LHSSize = LHS.getBitWidth(); + uint64_t RHSSize = RHS.getBitWidth(); + uint64_t ResultSize = Info.Ctx.getTypeSize(ResultType); + uint64_t MaxBits = std::max(std::max(LHSSize, RHSSize), ResultSize); + + // Add an additional bit if the signedness isn't uniformly agreed to. We + // could do this ONLY if there is a signed and an unsigned that both have + // MaxBits, but the code to check that is pretty nasty. The issue will be + // caught in the shrink-to-result later anyway. + if (IsSigned && !AllSigned) +++MaxBits; + + LHS = APSInt(IsSigned ? LHS.sextOrSelf(MaxBits) : LHS.zextOrSelf(MaxBits), + !IsSigned); + RHS = APSInt(IsSigned ? RHS.sextOrSelf(MaxBits) : RHS.zextOrSelf(MaxBits), + !IsSigned); + Result = APSInt(MaxBits, !IsSigned); +} + +// Find largest int. +switch (BuiltinOp) { +default: + llvm_unreachable("Invalid value for BuiltinOp"); +case Builtin::BI__builtin_add_overflow: +case Builtin::BI__builtin_sadd_overflow: +case Builtin::BI__builtin_saddl_overflow: +case Builtin::BI__builtin_saddll_overflow: +case Builtin::BI__builtin_uadd_overflow: +case Builtin::BI__builtin_uaddl_overflow: +case Builtin::BI__builtin_uaddll_overflow: + Result = LHS.isSigned() ? LHS.sadd_ov(RHS, DidOverflow) + : LHS.uadd_ov(RHS, DidOverflow); + break; +case Builtin::BI__builtin_sub_overflow: +case Builtin::BI__builtin_ssub_overflow: +case Builtin::BI__builtin_ssubl_overflow: +case Builtin::BI__builtin_ssubll_overflow: +case Builtin::BI__builtin_usub_overflow: +case Builtin::BI__builtin_usubl_overflow: +case Builtin::BI__builtin_usubll_overflow: + Result = LHS.isSigned() ? LHS.ssub_ov(RHS, DidOverflow) + : LHS.usub_ov(RHS, DidOverflow); + break; +case Builtin::BI__builtin_mul_overflow: +case Builtin::BI__builtin_smul_overflow: +case Builtin::BI__builtin_smull_overflow: +case Builtin::BI__builtin_smulll_overflow: +case Builtin::BI__builtin_umul_overflow: +case Builtin::BI__builtin_umull_overflow: +case Builtin::BI__builtin_umulll_overflow: + Result = LHS.isSigned() ? LHS.smul_ov(RHS, DidOverflow) + : LHS.umul_ov(RHS, DidOverflow); + break; +} + +// In the case where multiple sizes are allowed, truncate and see if +// the values are the same. +if (BuiltinOp == Builtin::BI__builtin_add_overflow || +
[PATCH] D48044: [Power9] Update fp128 as a valid homogenous aggregate base type
lei created this revision. lei added reviewers: hfinkel, kbarton, nemanjai, power-llvm-team. Update clang to treat fp128 as a valid base type for homogeneous aggregate passing and returning. https://reviews.llvm.org/D48044 Files: include/clang/AST/Type.h lib/CodeGen/TargetInfo.cpp test/CodeGen/ppc64le-f128Aggregates.c Index: test/CodeGen/ppc64le-f128Aggregates.c === --- /dev/null +++ test/CodeGen/ppc64le-f128Aggregates.c @@ -0,0 +1,124 @@ +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm \ +// RUN: -target-cpu pwr9 -target-feature +float128 -o - %s | FileCheck %s + +// Test homogeneous fp128 aggregate passing and returning. + +struct fp1 { __float128 f[1]; }; +struct fp2 { __float128 f[2]; }; +struct fp3 { __float128 f[3]; }; +struct fp4 { __float128 f[4]; }; +struct fp5 { __float128 f[5]; }; +struct fp6 { __float128 f[6]; }; +struct fp7 { __float128 f[7]; }; +struct fp8 { __float128 f[8]; }; +struct fp9 { __float128 f[9]; }; + +struct fpab { __float128 a; __float128 b; }; +struct fpabc { __float128 a; __float128 b; __float128 c; }; + +struct fp2a2b { __float128 a[2]; __float128 b[2]; }; + +// CHECK: define [1 x fp128] @func_f1(fp128 inreg %x.coerce) +struct fp1 func_f1(struct fp1 x) { return x; } + +// CHECK: define [2 x fp128] @func_f2([2 x fp128] %x.coerce) +struct fp2 func_f2(struct fp2 x) { return x; } + +// CHECK: define [3 x fp128] @func_f3([3 x fp128] %x.coerce) +struct fp3 func_f3(struct fp3 x) { return x; } + +// CHECK: define [4 x fp128] @func_f4([4 x fp128] %x.coerce) +struct fp4 func_f4(struct fp4 x) { return x; } + +// CHECK: define [5 x fp128] @func_f5([5 x fp128] %x.coerce) +struct fp5 func_f5(struct fp5 x) { return x; } + +// CHECK: define [6 x fp128] @func_f6([6 x fp128] %x.coerce) +struct fp6 func_f6(struct fp6 x) { return x; } + +// CHECK: define [7 x fp128] @func_f7([7 x fp128] %x.coerce) +struct fp7 func_f7(struct fp7 x) { return x; } + +// CHECK: define [8 x fp128] @func_f8([8 x fp128] %x.coerce) +struct fp8 func_f8(struct fp8 x) { return x; } + +// CHECK: define void @func_f9(%struct.fp9* noalias sret %agg.result, %struct.fp9* byval align 16 %x) +struct fp9 func_f9(struct fp9 x) { return x; } + +// CHECK: define [2 x fp128] @func_fab([2 x fp128] %x.coerce) +struct fpab func_fab(struct fpab x) { return x; } + +// CHECK: define [3 x fp128] @func_fabc([3 x fp128] %x.coerce) +struct fpabc func_fabc(struct fpabc x) { return x; } + +// CHECK: define [4 x fp128] @func_f2a2b([4 x fp128] %x.coerce) +struct fp2a2b func_f2a2b(struct fp2a2b x) { return x; } + +// CHECK-LABEL: @call_fp1 +// CHECK: %[[TMP:[^ ]+]] = load fp128, fp128* getelementptr inbounds (%struct.fp1, %struct.fp1* @global_f1, i32 0, i32 0, i32 0), align 16 +// CHECK: call [1 x fp128] @func_f1(fp128 inreg %[[TMP]]) +struct fp1 global_f1; +void call_fp1(void) { global_f1 = func_f1(global_f1); } + +// CHECK-LABEL: @call_fp2 +// CHECK: %[[TMP:[^ ]+]] = load [2 x fp128], [2 x fp128]* getelementptr inbounds (%struct.fp2, %struct.fp2* @global_f2, i32 0, i32 0), align 16 +// CHECK: call [2 x fp128] @func_f2([2 x fp128] %[[TMP]]) +struct fp2 global_f2; +void call_fp2(void) { global_f2 = func_f2(global_f2); } + +// CHECK-LABEL: @call_fp3 +// CHECK: %[[TMP:[^ ]+]] = load [3 x fp128], [3 x fp128]* getelementptr inbounds (%struct.fp3, %struct.fp3* @global_f3, i32 0, i32 0), align 16 +// CHECK: call [3 x fp128] @func_f3([3 x fp128] %[[TMP]]) +struct fp3 global_f3; +void call_fp3(void) { global_f3 = func_f3(global_f3); } + +// CHECK-LABEL: @call_fp4 +// CHECK: %[[TMP:[^ ]+]] = load [4 x fp128], [4 x fp128]* getelementptr inbounds (%struct.fp4, %struct.fp4* @global_f4, i32 0, i32 0), align 16 +// CHECK: call [4 x fp128] @func_f4([4 x fp128] %[[TMP]]) +struct fp4 global_f4; +void call_fp4(void) { global_f4 = func_f4(global_f4); } + +// CHECK-LABEL: @call_fp5 +// CHECK: %[[TMP:[^ ]+]] = load [5 x fp128], [5 x fp128]* getelementptr inbounds (%struct.fp5, %struct.fp5* @global_f5, i32 0, i32 0), align 16 +// CHECK: call [5 x fp128] @func_f5([5 x fp128] %[[TMP]]) +struct fp5 global_f5; +void call_fp5(void) { global_f5 = func_f5(global_f5); } + +// CHECK-LABEL: @call_fp6 +// CHECK: %[[TMP:[^ ]+]] = load [6 x fp128], [6 x fp128]* getelementptr inbounds (%struct.fp6, %struct.fp6* @global_f6, i32 0, i32 0), align 16 +// CHECK: call [6 x fp128] @func_f6([6 x fp128] %[[TMP]]) +struct fp6 global_f6; +void call_fp6(void) { global_f6 = func_f6(global_f6); } + +// CHECK-LABEL: @call_fp7 +// CHECK: %[[TMP:[^ ]+]] = load [7 x fp128], [7 x fp128]* getelementptr inbounds (%struct.fp7, %struct.fp7* @global_f7, i32 0, i32 0), align 16 +// CHECK: call [7 x fp128] @func_f7([7 x fp128] %[[TMP]]) +struct fp7 global_f7; +void call_fp7(void) { global_f7 = func_f7(global_f7); } + +// CHECK-LABEL: @call_fp8 +// CHECK: %[[TMP:[^ ]+]] = load [8 x fp128], [8 x fp128]* getelementptr inbounds (%struct.fp8, %struct.fp8* @global_f8, i32 0, i32 0), align 16 +// CHECK: call [8 x fp128]
[PATCH] D47733: [CUDA][HIP] Set kernel calling convention before arrange function
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Ok. https://reviews.llvm.org/D47733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
rjmccall added inline comments. Comment at: lib/AST/ExprConstant.cpp:8260 + // It won't GROW, since that isn't possible, so use this to allow + // TruncOrSelf. + APSInt Temp = Result.extOrTrunc(Info.Ctx.getTypeSize(ResultType)); The comment should explain *why* growth isn't possible (it's because we extended to the max-width type earlier). I don't think a casual reader is going to understand what you're saying about TruncOrSelf (that APSInt doesn't have such an operation, but that we can safely simulate it with `extOrTrunc` because we'll never do an extension). Repository: rC Clang https://reviews.llvm.org/D48040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46651: [OpenCL] Support new/delete in Sema
rjmccall accepted this revision. rjmccall added a comment. LGTM. Comment at: lib/Sema/SemaExprCXX.cpp:2030 + } +} svenvh wrote: > rjmccall wrote: > > Anastasia wrote: > > > svenvh wrote: > > > > rjmccall wrote: > > > > > I think a better interpretation of this rule would be to just error > > > > > on attempts to use the standard non-placement operator new/delete > > > > > instead of trying to outlaw the operator declarations. For example, > > > > > I don't know why a user-defined non-global operator new would be > > > > > problematic. > > > > Good point, I have raised this with Khronos, so I will hold this off > > > > until we have clarification. > > > The decision by Khronos is to allow all user defined new/delete operators > > > (even global). I have submitted the change to the spec. The next > > > publishing date is however in July. > > Okay. I agree with your decision in this patch to treat this as a defect > > in the spec and thus to go ahead and do the right thing now. > I can postpone committing this until the revised spec has been published, if > that's more desirable? No, if that's the directive I see no reason to wait for formal publication. As precedent, we update C++ rules long before ISO officially blesses the current draft into a standard. https://reviews.llvm.org/D46651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47627: [ASTContext] Make getAddrSpaceQualType replace address spaces.
rjmccall added a comment. In https://reviews.llvm.org/D47627#1127716, @ebevhan wrote: > > Well, the documentation mismatch is worth fixing even if the code isn't. > > But I think at best your use-case calls for weakening the assertion to be > > that any existing address space isn't *different*, yeah. > > Alright, I'll give that a shot. > > > Separately, I'm not sure that's really the right representation for a > > Harvard architecture (which is what I assume you're trying to extend Clang > > to support); I think you should probably just teach the compiler that > > function pointers are different. > > Well, we've already implemented it and it's been running in our downstream > for a while without issues at this point. We just figured it was less work to > use the existing address space support for it than to hack special cases all > over the place for functions and function pointers. I'm going to insist that you try it before you can upstream, I'm afraid. Repository: rC Clang https://reviews.llvm.org/D47627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48040: Implement constexpr __builtin_*_overflow
erichkeane created this revision. erichkeane added reviewers: eli.friedman, rjmccall. As requested here:https://bugs.llvm.org/show_bug.cgi?id=37633 permit the __builtin_*_overflow builtins in constexpr functions. Repository: rC Clang https://reviews.llvm.org/D48040 Files: lib/AST/ExprConstant.cpp lib/Sema/SemaChecking.cpp test/SemaCXX/builtins-overflow.cpp Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -8155,6 +8155,121 @@ case Builtin::BIomp_is_initial_device: // We can decide statically which value the runtime would return if called. return Success(Info.getLangOpts().OpenMPIsDevice ? 0 : 1, E); + case Builtin::BI__builtin_add_overflow: + case Builtin::BI__builtin_sub_overflow: + case Builtin::BI__builtin_mul_overflow: + case Builtin::BI__builtin_sadd_overflow: + case Builtin::BI__builtin_uadd_overflow: + case Builtin::BI__builtin_uaddl_overflow: + case Builtin::BI__builtin_uaddll_overflow: + case Builtin::BI__builtin_usub_overflow: + case Builtin::BI__builtin_usubl_overflow: + case Builtin::BI__builtin_usubll_overflow: + case Builtin::BI__builtin_umul_overflow: + case Builtin::BI__builtin_umull_overflow: + case Builtin::BI__builtin_umulll_overflow: + case Builtin::BI__builtin_saddl_overflow: + case Builtin::BI__builtin_saddll_overflow: + case Builtin::BI__builtin_ssub_overflow: + case Builtin::BI__builtin_ssubl_overflow: + case Builtin::BI__builtin_ssubll_overflow: + case Builtin::BI__builtin_smul_overflow: + case Builtin::BI__builtin_smull_overflow: + case Builtin::BI__builtin_smulll_overflow: { +LValue ResultLValue; +APSInt LHS, RHS; + +QualType ResultType = E->getArg(2)->getType()->getPointeeType(); +if (!EvaluateInteger(E->getArg(0), LHS, Info) || +!EvaluateInteger(E->getArg(1), RHS, Info) || +!EvaluatePointer(E->getArg(2), ResultLValue, Info)) + return false; + +APSInt Result; +bool DidOverflow = false; + +// If the types don't have to match, enlarge all 3 to the largest of them. +if (BuiltinOp == Builtin::BI__builtin_add_overflow || +BuiltinOp == Builtin::BI__builtin_sub_overflow || +BuiltinOp == Builtin::BI__builtin_mul_overflow) { + bool IsSigned = LHS.isSigned() || RHS.isSigned() || + ResultType->isSignedIntegerOrEnumerationType(); + bool AllSigned = LHS.isSigned() && RHS.isSigned() && + ResultType->isSignedIntegerOrEnumerationType(); + uint64_t LHSSize = LHS.getBitWidth(); + uint64_t RHSSize = RHS.getBitWidth(); + uint64_t ResultSize = Info.Ctx.getTypeSize(ResultType); + uint64_t MaxBits = std::max(std::max(LHSSize, RHSSize), ResultSize); + + // Add an additional bit if the signedness isn't uniformly agreed to. We + // could do this ONLY if there is a signed and an unsigned that both have + // MaxBits, but the code to check that is pretty nasty. The issue will be + // caught in the shrink-to-result later anyway. + if (IsSigned && !AllSigned) +++MaxBits; + + LHS = APSInt(IsSigned ? LHS.sextOrSelf(MaxBits) : LHS.zextOrSelf(MaxBits), + !IsSigned); + RHS = APSInt(IsSigned ? RHS.sextOrSelf(MaxBits) : RHS.zextOrSelf(MaxBits), + !IsSigned); + Result = APSInt(MaxBits, !IsSigned); +} + +// Find largest int. +switch (BuiltinOp) { +default: + llvm_unreachable("Invalid value for BuiltinOp"); +case Builtin::BI__builtin_add_overflow: +case Builtin::BI__builtin_sadd_overflow: +case Builtin::BI__builtin_saddl_overflow: +case Builtin::BI__builtin_saddll_overflow: +case Builtin::BI__builtin_uadd_overflow: +case Builtin::BI__builtin_uaddl_overflow: +case Builtin::BI__builtin_uaddll_overflow: + Result = LHS.isSigned() ? LHS.sadd_ov(RHS, DidOverflow) + : LHS.uadd_ov(RHS, DidOverflow); + break; +case Builtin::BI__builtin_sub_overflow: +case Builtin::BI__builtin_ssub_overflow: +case Builtin::BI__builtin_ssubl_overflow: +case Builtin::BI__builtin_ssubll_overflow: +case Builtin::BI__builtin_usub_overflow: +case Builtin::BI__builtin_usubl_overflow: +case Builtin::BI__builtin_usubll_overflow: + Result = LHS.isSigned() ? LHS.ssub_ov(RHS, DidOverflow) + : LHS.usub_ov(RHS, DidOverflow); + break; +case Builtin::BI__builtin_mul_overflow: +case Builtin::BI__builtin_smul_overflow: +case Builtin::BI__builtin_smull_overflow: +case Builtin::BI__builtin_smulll_overflow: +case Builtin::BI__builtin_umul_overflow: +case Builtin::BI__builtin_umull_overflow: +case Builtin::BI__builtin_umulll_overflow: + Result = LHS.isSigned() ? LHS.smul_ov(RHS, DidOverflow) + : LHS.umul_ov(RHS, DidOverflow); + break; +} + +// In the case where m
[PATCH] D48039: - Add "AV" as new default acronym. - Add support for "I" and "A" in lowerCamelCase pattern
Wizard created this revision. Herald added a subscriber: cfe-commits. Wizard edited the summary of this revision. Wizard added reviewers: benhamilton, hokein. Now we can support property names like "hasADog" correctly. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48039 Files: clang-tidy/objc/PropertyDeclarationCheck.cpp test/clang-tidy/objc-property-declaration.m Index: test/clang-tidy/objc-property-declaration.m === --- test/clang-tidy/objc-property-declaration.m +++ test/clang-tidy/objc-property-declaration.m @@ -22,6 +22,7 @@ @property(assign, nonatomic) int shouldUseCFPreferences; @property(assign, nonatomic) int enableGLAcceleration; @property(assign, nonatomic) int ID; +@property(assign, nonatomic) int hasADog; @end @interface Foo (Bar) Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -45,6 +45,7 @@ "AR", "ARGB", "ASCII", +"AV", "BGRA", "CA", "CF", @@ -153,7 +154,7 @@ std::string StartMatcher = UsedInMatcher ? "::" : "^"; std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms); return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" + - AcronymsMatcher + "|([A-Z][a-z0-9]+))*$"; + AcronymsMatcher + "|([A-Z][a-z0-9]+)|A|I)*$"; } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { Index: test/clang-tidy/objc-property-declaration.m === --- test/clang-tidy/objc-property-declaration.m +++ test/clang-tidy/objc-property-declaration.m @@ -22,6 +22,7 @@ @property(assign, nonatomic) int shouldUseCFPreferences; @property(assign, nonatomic) int enableGLAcceleration; @property(assign, nonatomic) int ID; +@property(assign, nonatomic) int hasADog; @end @interface Foo (Bar) Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -45,6 +45,7 @@ "AR", "ARGB", "ASCII", +"AV", "BGRA", "CA", "CF", @@ -153,7 +154,7 @@ std::string StartMatcher = UsedInMatcher ? "::" : "^"; std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms); return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" + - AcronymsMatcher + "|([A-Z][a-z0-9]+))*$"; + AcronymsMatcher + "|([A-Z][a-z0-9]+)|A|I)*$"; } bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47586: Update NRVO logic to support early return (Attempt 2)
tzik added a comment. rsmith: ping. Any chance you could review this? Repository: rC Clang https://reviews.llvm.org/D47586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48037: [CUDA] Add tests to ensure that std::min/max can be called from __host__ __device__ functions.
jlebar created this revision. jlebar added a reviewer: rsmith. Herald added subscribers: llvm-commits, sanjoy. Tests for https://reviews.llvm.org/D48036 / PR37753. Repository: rT test-suite https://reviews.llvm.org/D48037 Files: External/CUDA/algorithm.cu Index: External/CUDA/algorithm.cu === --- External/CUDA/algorithm.cu +++ External/CUDA/algorithm.cu @@ -17,10 +17,16 @@ __device__ void min() { assert(std::min(0, 1) == 0); } +__host__ __device__ void min_hd() { + assert(std::min(0, 1) == 0); +} __device__ void max() { assert(std::max(0, 1) == 1); } +__host__ __device__ void max_hd() { + assert(std::max(0, 1) == 1); +} // Clang has device-side shims implementing std::min and std::max for scalars // starting in C++11, but doesn't implement minimax or std::min/max on @@ -39,10 +45,27 @@ #endif } +// Same tests as cpp14_tests, but from a host-device context. +__host__ __device__ void cpp14_tests_hd() { +#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014 + assert(std::greater()(1, 0)); + assert(std::min({5, 1, 10}) == 1); + assert(std::max({5, 1, 10}, std::less()) == 10); + + assert(std::minmax(1, 0).first == 0); + assert(std::minmax(1, 0).second == 1); + assert(std::minmax({0, 10, -10, 100}, std::less()).first == -10); + assert(std::minmax({0, 10, -10, 100}, std::less()).second == 100); +#endif +} + __global__ void kernel() { min(); + min_hd(); max(); + max_hd(); cpp14_tests(); + cpp14_tests_hd(); } int main() { @@ -52,6 +75,11 @@ printf("CUDA error %d\n", (int)err); return 1; } + + min_hd(); + max_hd(); + cpp14_tests_hd(); + printf("Success!\n"); return 0; } Index: External/CUDA/algorithm.cu === --- External/CUDA/algorithm.cu +++ External/CUDA/algorithm.cu @@ -17,10 +17,16 @@ __device__ void min() { assert(std::min(0, 1) == 0); } +__host__ __device__ void min_hd() { + assert(std::min(0, 1) == 0); +} __device__ void max() { assert(std::max(0, 1) == 1); } +__host__ __device__ void max_hd() { + assert(std::max(0, 1) == 1); +} // Clang has device-side shims implementing std::min and std::max for scalars // starting in C++11, but doesn't implement minimax or std::min/max on @@ -39,10 +45,27 @@ #endif } +// Same tests as cpp14_tests, but from a host-device context. +__host__ __device__ void cpp14_tests_hd() { +#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014 + assert(std::greater()(1, 0)); + assert(std::min({5, 1, 10}) == 1); + assert(std::max({5, 1, 10}, std::less()) == 10); + + assert(std::minmax(1, 0).first == 0); + assert(std::minmax(1, 0).second == 1); + assert(std::minmax({0, 10, -10, 100}, std::less()).first == -10); + assert(std::minmax({0, 10, -10, 100}, std::less()).second == 100); +#endif +} + __global__ void kernel() { min(); + min_hd(); max(); + max_hd(); cpp14_tests(); + cpp14_tests_hd(); } int main() { @@ -52,6 +75,11 @@ printf("CUDA error %d\n", (int)err); return 1; } + + min_hd(); + max_hd(); + cpp14_tests_hd(); + printf("Success!\n"); return 0; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48036: [CUDA] Make min/max shims host+device.
jlebar created this revision. jlebar added a reviewer: rsmith. Herald added a subscriber: sanjoy. Fixes PR37753: min/max can't be called from __host__ __device__ functions in C++14 mode. Testcase in a separate test-suite commit. https://reviews.llvm.org/D48036 Files: clang/lib/Headers/cuda_wrappers/algorithm Index: clang/lib/Headers/cuda_wrappers/algorithm === --- clang/lib/Headers/cuda_wrappers/algorithm +++ clang/lib/Headers/cuda_wrappers/algorithm @@ -69,28 +69,28 @@ template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & max(const __T &__a, const __T &__b, __Cmp __cmp) { return __cmp(__a, __b) ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & max(const __T &__a, const __T &__b) { return __a < __b ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & min(const __T &__a, const __T &__b, __Cmp __cmp) { return __cmp(__b, __a) ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & min(const __T &__a, const __T &__b) { return __a < __b ? __a : __b; } Index: clang/lib/Headers/cuda_wrappers/algorithm === --- clang/lib/Headers/cuda_wrappers/algorithm +++ clang/lib/Headers/cuda_wrappers/algorithm @@ -69,28 +69,28 @@ template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & max(const __T &__a, const __T &__b, __Cmp __cmp) { return __cmp(__a, __b) ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & max(const __T &__a, const __T &__b) { return __a < __b ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & min(const __T &__a, const __T &__b, __Cmp __cmp) { return __cmp(__b, __a) ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __device__ const __T & +inline __host__ __device__ const __T & min(const __T &__a, const __T &__b) { return __a < __b ? __a : __b; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46651: [OpenCL] Support new/delete in Sema
svenvh added inline comments. Comment at: lib/Sema/SemaExprCXX.cpp:2030 + } +} rjmccall wrote: > Anastasia wrote: > > svenvh wrote: > > > rjmccall wrote: > > > > I think a better interpretation of this rule would be to just error on > > > > attempts to use the standard non-placement operator new/delete instead > > > > of trying to outlaw the operator declarations. For example, I don't > > > > know why a user-defined non-global operator new would be problematic. > > > Good point, I have raised this with Khronos, so I will hold this off > > > until we have clarification. > > The decision by Khronos is to allow all user defined new/delete operators > > (even global). I have submitted the change to the spec. The next publishing > > date is however in July. > Okay. I agree with your decision in this patch to treat this as a defect in > the spec and thus to go ahead and do the right thing now. I can postpone committing this until the revised spec has been published, if that's more desirable? https://reviews.llvm.org/D46651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
george.karpenkov added inline comments. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89 +new Callback(LCtx, MRMgr, ITraits)); + Finder.matchAST(ASTCtx); + ormris wrote: > george.karpenkov wrote: > > IMO using the iterator directly (e.g. like it was done in > > https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) > > leads to a much cleaner code and saves you from having to define a > > callback class. > Hmm... I think that's a better approach. Let me see if I can get that working. @ormris Yeah I'm really not sure why all examples use the callback API by default. Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46651: [OpenCL] Support new/delete in Sema
svenvh updated this revision to Diff 150788. svenvh added a comment. Dropped 2 redundant uses of `getTypePtr()`; minor formatting changes. https://reviews.llvm.org/D46651 Files: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaType.cpp test/SemaOpenCLCXX/newdelete.cl Index: test/SemaOpenCLCXX/newdelete.cl === --- /dev/null +++ test/SemaOpenCLCXX/newdelete.cl @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only + +class A { + public: + A() : x(21) {} + int x; +}; + +typedef __SIZE_TYPE__ size_t; + +class B { + public: + B() : bx(42) {} + void *operator new(size_t); + void operator delete(void *ptr); + int bx; +}; + +// There are no global user-defined new operators at this point. Test that clang +// rejects these gracefully. +void test_default_new_delete(void *buffer, A **pa) { + A *a = new A; // expected-error {{'default new' is not supported in OpenCL C++}} + delete a; // expected-error {{'default delete' is not supported in OpenCL C++}} + *pa = new (buffer) A; // expected-error {{'default new' is not supported in OpenCL C++}} +} + +// expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}} +void *operator new(size_t _s, void *ptr) noexcept { + return ptr; +} + +// expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}} +void *operator new[](size_t _s, void *ptr) noexcept { + return ptr; +} + +void test_new_delete(void *buffer, A **a, B **b) { + *a = new A; // expected-error {{no matching function for call to 'operator new'}} + delete a; // expected-error {{'default delete' is not supported in OpenCL C++}} + + *a = new A[20]; // expected-error {{no matching function for call to 'operator new[]'}} + delete[] *a;// expected-error {{'default delete' is not supported in OpenCL C++}} + + // User-defined placement new is supported. + *a = new (buffer) A; + + // User-defined placement new[] is supported. + *a = new (buffer) A[30]; + + // User-defined new is supported. + *b = new B; + + // User-defined delete is supported. + delete *b; +} Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -7137,8 +7137,9 @@ // The default address space name for arguments to a function in a // program, or local variables of a function is __private. All function // arguments shall be in the __private address space. - if (State.getSema().getLangOpts().OpenCLVersion <= 120) { - ImpAddr = LangAS::opencl_private; + if (State.getSema().getLangOpts().OpenCLVersion <= 120 && + !State.getSema().getLangOpts().OpenCLCPlusPlus) { +ImpAddr = LangAS::opencl_private; } else { // If address space is not set, OpenCL 2.0 defines non private default // address spaces for some cases: Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -2146,7 +2146,8 @@ else if (AllocType->isVariablyModifiedType()) return Diag(Loc, diag::err_variably_modified_new_type) << AllocType; - else if (AllocType.getAddressSpace() != LangAS::Default) + else if (AllocType.getAddressSpace() != LangAS::Default && + !getLangOpts().OpenCLCPlusPlus) return Diag(Loc, diag::err_address_space_qualified_new) << AllocType.getUnqualifiedType() << AllocType.getQualifiers().getAddressSpaceAttributePrintValue(); @@ -2362,6 +2363,11 @@ LookupQualifiedName(R, Context.getTranslationUnitDecl()); } +if (getLangOpts().OpenCLCPlusPlus && R.empty()) { + Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new"; + return true; +} + assert(!R.empty() && "implicitly declared allocation functions not found"); assert(!R.isAmbiguous() && "global allocation functions are ambiguous"); @@ -2597,6 +2603,11 @@ if (GlobalNewDeleteDeclared) return; + // OpenCL C++ 1.0 s2.9: the implicitly declared new and delete operators + // are not supported. + if (getLangOpts().OpenCLCPlusPlus) +return; + // C++ [basic.std.dynamic]p2: // [...] The following allocation and deallocation functions (18.4) are // implicitly declared in global scope in each translation unit of a @@ -3230,7 +3241,8 @@ QualType Pointee = Type->getAs()->getPointeeType(); QualType PointeeElem = Context.getBaseElementType(Pointee); -if (Pointee.getAddressSpace() != LangAS::Default) +if (Pointee.getAddressSpace() != LangAS::Default && +!getLangOpts().OpenCLCPlusPlus) return Diag(Ex.get()->getLocStart(), diag::err_address_space_qualified_delete) << Pointee.getUnqualifiedType() @@ -3305,6 +3317,11 @@ } if (!OperatorDelete) { +
[PATCH] D47950: [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"
malaperle added a comment. In https://reviews.llvm.org/D47950#1128487, @sammccall wrote: > In https://reviews.llvm.org/D47950#1128370, @malaperle wrote: > > > Very nice! I tried "std" and got much less (unimportant) results. I see > > something a bit weird with "getStandardResourceDir" but it might be VSCode. > > Here, I guess it's the "d" in Dir that matches but what's odd is that VS > > Code will highlight the first "d", i.e. in "standard". But it doesn't look > > like there is any way to control this in the LSP, is there? > > > That's right. VSCode applies its fuzzymatch again client-side to determine > which characters to highlight, and it chooses the wrong (IMO) "d" here. We > wouldn't match [std] against "getStandardResourceZir". > (Worse, they use the same algorithm to rerank our results if client-side > filtering applies...) Thanks for the confirmation. In that case, I think the approach of this patch is quite good! Although it would be better is someone familiar with code completion could review the details :) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D47950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
ormris added inline comments. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89 +new Callback(LCtx, MRMgr, ITraits)); + Finder.matchAST(ASTCtx); + george.karpenkov wrote: > IMO using the iterator directly (e.g. like it was done in > https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) > leads to a much cleaner code and saves you from having to define a callback > class. Hmm... I think that's a better approach. Let me see if I can get that working. Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334422 - [X86] Fix operand order in the shuffle created for blend builtins.
Author: ctopper Date: Mon Jun 11 10:06:01 2018 New Revision: 334422 URL: http://llvm.org/viewvc/llvm-project?rev=334422&view=rev Log: [X86] Fix operand order in the shuffle created for blend builtins. This was broken when the builtin was added in r334249. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334422&r1=334421&r2=334422&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun 11 10:06:01 2018 @@ -9430,7 +9430,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx for (unsigned i = 0; i != NumElts; ++i) Indices[i] = ((Imm >> (i % 8)) & 0x1) ? NumElts + i : i; -return Builder.CreateShuffleVector(Ops[1], Ops[0], +return Builder.CreateShuffleVector(Ops[0], Ops[1], makeArrayRef(Indices, NumElts), "blend"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47964: Modified protobuf and converter to add new signature, remove conditionals.
This revision was automatically updated to reflect the committed changes. Closed by commit rL334421: [clang-fuzzer] Modified protobuf and converter to add new signature, remove… (authored by morehouse, committed by ). Repository: rL LLVM https://reviews.llvm.org/D47964 Files: cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp Index: cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto === --- cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto +++ cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto @@ -11,7 +11,7 @@ /// This file describes a subset of C++ as a protobuf. It is used to /// more easily find interesting inputs for fuzzing Clang. This subset /// differs from the one defined in cxx_proto.proto by eliminating while -/// loops and Lvalues. The goal is that the C++ code generated will be +/// loops and conditionals. The goal is that the C++ code generated will be /// more likely to stress the LLVM loop vectorizer. /// //===--===// @@ -22,6 +22,16 @@ required int32 val = 1; } +message VarRef { + // Add an enum for each array in function signature + enum Arr { +ARR_A = 0; +ARR_B = 1; +ARR_C = 2; + }; + required Arr arr = 1; +} + message BinaryOp { enum Op { PLUS = 0; @@ -48,10 +58,12 @@ oneof rvalue_oneof { Const cons = 1; BinaryOp binop = 2; +VarRef varref = 3; } } message AssignmentStatement { + required VarRef varref = 1; required Rvalue rvalue = 2; } @@ -62,10 +74,7 @@ } message Statement { - oneof stmt_oneof { -AssignmentStatement assignment = 1; -IfElse ifelse = 2; - } + required AssignmentStatement assignment = 1; } message StatementSeq { Index: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp === --- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp +++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp @@ -36,11 +36,23 @@ std::ostream &operator<<(std::ostream &os, const Const &x) { return os << "(" << x.val() << ")"; } +std::ostream &operator<<(std::ostream &os, const VarRef &x) { + switch (x.arr()) { +case VarRef::ARR_A: + return os << "a[i]"; +case VarRef::ARR_B: + return os << "b[i]"; +case VarRef::ARR_C: + return os << "c[i]"; + } +} std::ostream &operator<<(std::ostream &os, const Rvalue &x) { if (x.has_cons()) return os << x.cons(); if (x.has_binop()) return os << x.binop(); + if (x.has_varref()) +return os << x.varref(); return os << "1"; } std::ostream &operator<<(std::ostream &os, const BinaryOp &x) { @@ -92,27 +104,23 @@ return os << x.right() << ")"; } std::ostream &operator<<(std::ostream &os, const AssignmentStatement &x) { - return os << "a[i]=" << x.rvalue(); + return os << x.varref() << "=" << x.rvalue() << ";\n"; } std::ostream &operator<<(std::ostream &os, const IfElse &x) { return os << "if (" << x.cond() << "){\n" << x.if_body() << "} else { \n" << x.else_body() << "}\n"; } std::ostream &operator<<(std::ostream &os, const Statement &x) { - if (x.has_assignment()) -return os << x.assignment() << ";\n"; - if (x.has_ifelse()) -return os << x.ifelse(); - return os << "(void)0;\n"; + return os << x.assignment(); } std::ostream &operator<<(std::ostream &os, const StatementSeq &x) { for (auto &st : x.statements()) os << st; return os; } std::ostream &operator<<(std::ostream &os, const LoopFunction &x) { - return os << "void foo(int *a, size_t s) {\n" + return os << "void foo(int *a, int *b, int *__restrict__ c, size_t s) {\n" << "for (int i=0; i___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334421 - [clang-fuzzer] Modified protobuf and converter to add new signature, remove conditionals.
Author: morehouse Date: Mon Jun 11 10:05:45 2018 New Revision: 334421 URL: http://llvm.org/viewvc/llvm-project?rev=334421&view=rev Log: [clang-fuzzer] Modified protobuf and converter to add new signature, remove conditionals. Changed the function signature and removed conditionals from loop body. Patch By: emmettneyman Differential Revision: https://reviews.llvm.org/D47964 Modified: cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp Modified: cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto?rev=334421&r1=334420&r2=334421&view=diff == --- cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto (original) +++ cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto Mon Jun 11 10:05:45 2018 @@ -11,7 +11,7 @@ /// This file describes a subset of C++ as a protobuf. It is used to /// more easily find interesting inputs for fuzzing Clang. This subset /// differs from the one defined in cxx_proto.proto by eliminating while -/// loops and Lvalues. The goal is that the C++ code generated will be +/// loops and conditionals. The goal is that the C++ code generated will be /// more likely to stress the LLVM loop vectorizer. /// //===--===// @@ -22,6 +22,16 @@ message Const { required int32 val = 1; } +message VarRef { + // Add an enum for each array in function signature + enum Arr { +ARR_A = 0; +ARR_B = 1; +ARR_C = 2; + }; + required Arr arr = 1; +} + message BinaryOp { enum Op { PLUS = 0; @@ -48,10 +58,12 @@ message Rvalue { oneof rvalue_oneof { Const cons = 1; BinaryOp binop = 2; +VarRef varref = 3; } } message AssignmentStatement { + required VarRef varref = 1; required Rvalue rvalue = 2; } @@ -62,10 +74,7 @@ message IfElse { } message Statement { - oneof stmt_oneof { -AssignmentStatement assignment = 1; -IfElse ifelse = 2; - } + required AssignmentStatement assignment = 1; } message StatementSeq { Modified: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp?rev=334421&r1=334420&r2=334421&view=diff == --- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp (original) +++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp Mon Jun 11 10:05:45 2018 @@ -36,11 +36,23 @@ std::ostream &operator<<(std::ostream &o std::ostream &operator<<(std::ostream &os, const Const &x) { return os << "(" << x.val() << ")"; } +std::ostream &operator<<(std::ostream &os, const VarRef &x) { + switch (x.arr()) { +case VarRef::ARR_A: + return os << "a[i]"; +case VarRef::ARR_B: + return os << "b[i]"; +case VarRef::ARR_C: + return os << "c[i]"; + } +} std::ostream &operator<<(std::ostream &os, const Rvalue &x) { if (x.has_cons()) return os << x.cons(); if (x.has_binop()) return os << x.binop(); + if (x.has_varref()) +return os << x.varref(); return os << "1"; } std::ostream &operator<<(std::ostream &os, const BinaryOp &x) { @@ -92,7 +104,7 @@ std::ostream &operator<<(std::ostream &o return os << x.right() << ")"; } std::ostream &operator<<(std::ostream &os, const AssignmentStatement &x) { - return os << "a[i]=" << x.rvalue(); + return os << x.varref() << "=" << x.rvalue() << ";\n"; } std::ostream &operator<<(std::ostream &os, const IfElse &x) { return os << "if (" << x.cond() << "){\n" @@ -100,11 +112,7 @@ std::ostream &operator<<(std::ostream &o << x.else_body() << "}\n"; } std::ostream &operator<<(std::ostream &os, const Statement &x) { - if (x.has_assignment()) -return os << x.assignment() << ";\n"; - if (x.has_ifelse()) -return os << x.ifelse(); - return os << "(void)0;\n"; + return os << x.assignment(); } std::ostream &operator<<(std::ostream &os, const StatementSeq &x) { for (auto &st : x.statements()) @@ -112,7 +120,7 @@ std::ostream &operator<<(std::ostream &o return os; } std::ostream &operator<<(std::ostream &os, const LoopFunction &x) { - return os << "void foo(int *a, size_t s) {\n" + return os << "void foo(int *a, int *b, int *__restrict__ c, size_t s) {\n" << "for (int i=0; ihttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47950: [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"
sammccall added a comment. In https://reviews.llvm.org/D47950#1128370, @malaperle wrote: > Very nice! I tried "std" and got much less (unimportant) results. I see > something a bit weird with "getStandardResourceDir" but it might be VSCode. > Here, I guess it's the "d" in Dir that matches but what's odd is that VS Code > will highlight the first "d", i.e. in "standard". But it doesn't look like > there is any way to control this in the LSP, is there? That's right. VSCode applies its fuzzymatch again client-side to determine which characters to highlight, and it chooses the wrong (IMO) "d" here. We wouldn't match [std] against "getStandardResourceZir". (Worse, they use the same algorithm to rerank our results if client-side filtering applies...) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D47950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48034: [clang-format] Discourage breaks in submessage entries
krasimir added a comment. In https://reviews.llvm.org/D48034#1128475, @sammccall wrote: > All else equal, I'd expect this to be a hard rule, at least in google-style. > > "foo\n { a: b }" --> "foo {\n a: b\n}" only makes the first line longer, by > 2 chars. So if 78 < indent + len("foo") <= 80 we're breaking the line limit, > but that seems vanishingly rare. > > If the penalty is sufficient to stop it happening almost always, maybe it > works out the same. If we make this a hard rule, there's a better way: update `canBreak` to return `false`. Repository: rC Clang https://reviews.llvm.org/D48034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48034: [clang-format] Discourage breaks in submessage entries
sammccall added a comment. All else equal, I'd expect this to be a hard rule, at least in google-style. "foo\n { a: b }" --> "foo {\n a: b\n}" only makes the first line longer, by 2 chars. So if 78 < indent + len("foo") <= 80 we're breaking the line limit, but that seems vanishingly rare. If the penalty is sufficient to stop it happening almost always, maybe it works out the same. Repository: rC Clang https://reviews.llvm.org/D48034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47964: Modified protobuf and converter to add new signature, remove conditionals.
emmettneyman updated this revision to Diff 150783. emmettneyman added a comment. - removed include statement meant for testing Repository: rC Clang https://reviews.llvm.org/D47964 Files: tools/clang-fuzzer/cxx_loop_proto.proto tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp === --- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp +++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp @@ -36,11 +36,23 @@ std::ostream &operator<<(std::ostream &os, const Const &x) { return os << "(" << x.val() << ")"; } +std::ostream &operator<<(std::ostream &os, const VarRef &x) { + switch (x.arr()) { +case VarRef::ARR_A: + return os << "a[i]"; +case VarRef::ARR_B: + return os << "b[i]"; +case VarRef::ARR_C: + return os << "c[i]"; + } +} std::ostream &operator<<(std::ostream &os, const Rvalue &x) { if (x.has_cons()) return os << x.cons(); if (x.has_binop()) return os << x.binop(); + if (x.has_varref()) +return os << x.varref(); return os << "1"; } std::ostream &operator<<(std::ostream &os, const BinaryOp &x) { @@ -92,27 +104,23 @@ return os << x.right() << ")"; } std::ostream &operator<<(std::ostream &os, const AssignmentStatement &x) { - return os << "a[i]=" << x.rvalue(); + return os << x.varref() << "=" << x.rvalue() << ";\n"; } std::ostream &operator<<(std::ostream &os, const IfElse &x) { return os << "if (" << x.cond() << "){\n" << x.if_body() << "} else { \n" << x.else_body() << "}\n"; } std::ostream &operator<<(std::ostream &os, const Statement &x) { - if (x.has_assignment()) -return os << x.assignment() << ";\n"; - if (x.has_ifelse()) -return os << x.ifelse(); - return os << "(void)0;\n"; + return os << x.assignment(); } std::ostream &operator<<(std::ostream &os, const StatementSeq &x) { for (auto &st : x.statements()) os << st; return os; } std::ostream &operator<<(std::ostream &os, const LoopFunction &x) { - return os << "void foo(int *a, size_t s) {\n" + return os << "void foo(int *a, int *b, int *__restrict__ c, size_t s) {\n" << "for (int i=0; i___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47964: Modified protobuf and converter to add new signature, remove conditionals.
emmettneyman added a comment. @kcc suggested removing conditionals for now and adding them back later. include statement was for testing; I'll remove it and resubmit. Repository: rC Clang https://reviews.llvm.org/D47964 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47341: [Sema] Fix infinite typo correction loop.
vsapsai added a comment. Ping. https://reviews.llvm.org/D47341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334418 - Enable crash recovery tests on Windows, globs work in the lit internal shell now
Author: rnk Date: Mon Jun 11 09:50:07 2018 New Revision: 334418 URL: http://llvm.org/viewvc/llvm-project?rev=334418&view=rev Log: Enable crash recovery tests on Windows, globs work in the lit internal shell now Modified: cfe/trunk/test/Driver/crash-report-header.h cfe/trunk/test/Driver/crash-report-modules.m cfe/trunk/test/Driver/crash-report-spaces.c cfe/trunk/test/Driver/crash-report.c Modified: cfe/trunk/test/Driver/crash-report-header.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-header.h?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report-header.h (original) +++ cfe/trunk/test/Driver/crash-report-header.h Mon Jun 11 09:50:07 2018 @@ -5,9 +5,6 @@ // RUN: cat %t/crash-report-header-*.sh | FileCheck --check-prefix=CHECKSH "%s" // REQUIRES: crash-recovery -// because of the glob (*.h, *.sh) -// REQUIRES: shell - #pragma clang __debug parser_crash // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}.h Modified: cfe/trunk/test/Driver/crash-report-modules.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-modules.m?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report-modules.m (original) +++ cfe/trunk/test/Driver/crash-report-modules.m Mon Jun 11 09:50:07 2018 @@ -9,12 +9,6 @@ // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-report-*.sh // REQUIRES: crash-recovery -// because of the glob (*.m, *.sh) -// REQUIRES: shell - -// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it? -// XFAIL: mingw32 - @import simple; const int x = MODULE_MACRO; @@ -34,4 +28,4 @@ const int x = MODULE_MACRO; // CHECKSH: "-D" "FOO=BAR" // CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-report-modules-{{[^ ]*}}.m" -// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ ]*}}.cache/vfs/vfs.yaml" +// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ ]*}}.cache{{(/|)}}vfs{{(/|)}}vfs.yaml" Modified: cfe/trunk/test/Driver/crash-report-spaces.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-spaces.c?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report-spaces.c (original) +++ cfe/trunk/test/Driver/crash-report-spaces.c Mon Jun 11 09:50:07 2018 @@ -6,9 +6,6 @@ // RUN: cat "%t/crash report spaces"-*.sh | FileCheck --check-prefix=CHECKSH "%s" // REQUIRES: crash-recovery -// because of the glob (*.c, *.sh) -// REQUIRES: shell - #pragma clang __debug parser_crash // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}.c Modified: cfe/trunk/test/Driver/crash-report.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report.c?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report.c (original) +++ cfe/trunk/test/Driver/crash-report.c Mon Jun 11 09:50:07 2018 @@ -13,9 +13,6 @@ // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s // REQUIRES: crash-recovery -// because of the glob (*.c, *.sh) -// REQUIRES: shell - #pragma clang __debug parser_crash // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.c ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48034: [clang-format] Discourage breaks in submessage entries
krasimir created this revision. Herald added a subscriber: cfe-commits. Currently clang-format allows this for text protos: submessage: { key: 'aa' } when it is under the column limit and when putting it all on one line exceeds the column limit. This is not a very intuitive formatting, so I'd prefer having submessage: { key: 'aa' } instead, even if it takes one line more. This is just a rough sketch of an approach to achieve this: add a penalty for breaking before the `{`. Want to discuss the validity of this approach. Repository: rC Clang https://reviews.llvm.org/D48034 Files: lib/Format/ContinuationIndenter.cpp unittests/Format/FormatTestTextProto.cpp Index: unittests/Format/FormatTestTextProto.cpp === --- unittests/Format/FormatTestTextProto.cpp +++ unittests/Format/FormatTestTextProto.cpp @@ -670,5 +670,11 @@ "}"); } +TEST_F(FormatTestTextProto, TODO) { + verifyFormat("submessage: {\n" + " key: 'a'\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -22,6 +22,9 @@ #include "llvm/Support/Debug.h" #define DEBUG_TYPE "format-indenter" +#define DBG(A) \ + llvm::dbgs() << __func__ << ":" << __LINE__ << ":" << #A << " = " << A \ + << "\n"; namespace clang { namespace format { @@ -717,6 +720,7 @@ bool DryRun) { FormatToken &Current = *State.NextToken; const FormatToken &Previous = *State.NextToken->Previous; + DBG(Current.TokenText); // Extra penalty that needs to be added because of the way certain line // breaks are chosen. @@ -743,6 +747,13 @@ State.Stack.back().BreakBeforeParameter)) Penalty += Style.PenaltyBreakFirstLessLess; + // Breaking before the "{" in a text proto submessage is not desirable. + if (Style.Language == FormatStyle::LK_TextProto) { +if (Current.is(tok::l_brace)) { + Penalty += Style.PenaltyExcessCharacter; +} + } + State.Column = getNewLineColumn(State); // Indent nested blocks relative to this column, unless in a very specific Index: unittests/Format/FormatTestTextProto.cpp === --- unittests/Format/FormatTestTextProto.cpp +++ unittests/Format/FormatTestTextProto.cpp @@ -670,5 +670,11 @@ "}"); } +TEST_F(FormatTestTextProto, TODO) { + verifyFormat("submessage: {\n" + " key: 'a'\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -22,6 +22,9 @@ #include "llvm/Support/Debug.h" #define DEBUG_TYPE "format-indenter" +#define DBG(A) \ + llvm::dbgs() << __func__ << ":" << __LINE__ << ":" << #A << " = " << A \ + << "\n"; namespace clang { namespace format { @@ -717,6 +720,7 @@ bool DryRun) { FormatToken &Current = *State.NextToken; const FormatToken &Previous = *State.NextToken->Previous; + DBG(Current.TokenText); // Extra penalty that needs to be added because of the way certain line // breaks are chosen. @@ -743,6 +747,13 @@ State.Stack.back().BreakBeforeParameter)) Penalty += Style.PenaltyBreakFirstLessLess; + // Breaking before the "{" in a text proto submessage is not desirable. + if (Style.Language == FormatStyle::LK_TextProto) { +if (Current.is(tok::l_brace)) { + Penalty += Style.PenaltyExcessCharacter; +} + } + State.Column = getNewLineColumn(State); // Indent nested blocks relative to this column, unless in a very specific ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334417 - [MS] Use mangled names and comdats for string merging with ASan
Author: rnk Date: Mon Jun 11 09:49:43 2018 New Revision: 334417 URL: http://llvm.org/viewvc/llvm-project?rev=334417&view=rev Log: [MS] Use mangled names and comdats for string merging with ASan This should reduce the binary size penalty of ASan on Windows. After r334313, ASan will add red zones to globals in comdats, so we will still find OOB accesses to string literals. Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=334417&r1=334416&r2=334417&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 11 09:49:43 2018 @@ -4114,15 +4114,13 @@ CodeGenModule::GetAddrOfConstantStringFr StringRef GlobalVariableName; llvm::GlobalValue::LinkageTypes LT; - // Mangle the string literal if the ABI allows for it. However, we cannot - // do this if we are compiling with ASan or -fwritable-strings because they - // rely on strings having normal linkage. - if (!LangOpts.WritableStrings && - !LangOpts.Sanitize.has(SanitizerKind::Address) && - getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) { + // Mangle the string literal if that's how the ABI merges duplicate strings. + // Don't do it if they are writable, since we don't want writes in one TU to + // affect strings in another. + if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) && + !LangOpts.WritableStrings) { llvm::raw_svector_ostream Out(MangledNameBuffer); getCXXABI().getMangleContext().mangleStringLiteral(S, Out); - LT = llvm::GlobalValue::LinkOnceODRLinkage; GlobalVariableName = MangledNameBuffer; } else { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
george.karpenkov added inline comments. Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89 +new Callback(LCtx, MRMgr, ITraits)); + Finder.matchAST(ASTCtx); + IMO using the iterator directly (e.g. like it was done in https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) leads to a much cleaner code and saves you from having to define a callback class. Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47964: Modified protobuf and converter to add new signature, remove conditionals.
morehouse added inline comments. Comment at: tools/clang-fuzzer/cxx_loop_proto.proto:67 -AssignmentStatement assignment = 1; -IfElse ifelse = 2; - } Do you really want to get rid of if-else? Comment at: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp:123 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) { - return os << "void foo(int *a, size_t s) {\n" + return os << "#include \"foo.h\"\n" // This line is just for testing +<< "void foo(int *a, int *b, int *__restrict__ c, size_t s) {\n" What's the purpose of this include? Repository: rC Clang https://reviews.llvm.org/D47964 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334416 - [X86] Properly account for the immediate being multiplied by 8 in the immediate range checking for BI__builtin_ia32_psrldqi128 and friends.
Author: ctopper Date: Mon Jun 11 09:34:10 2018 New Revision: 334416 URL: http://llvm.org/viewvc/llvm-project?rev=334416&view=rev Log: [X86] Properly account for the immediate being multiplied by 8 in the immediate range checking for BI__builtin_ia32_psrldqi128 and friends. The limit was set to 1023 which only up to 127*8. It needs to be 2047 to allow 255*8. Modified: cfe/trunk/lib/Sema/SemaChecking.cpp Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=334416&r1=334415&r2=334416&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jun 11 09:34:10 2018 @@ -2911,7 +2911,7 @@ bool Sema::CheckX86BuiltinFunctionCall(u case X86::BI__builtin_ia32_psrldqi128: case X86::BI__builtin_ia32_psrldqi256: case X86::BI__builtin_ia32_psrldqi512: -i = 1; l = 0; u = 1023; +i = 1; l = 0; u = 2047; break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334352 - [analyzer] Clean up the program state map of DanglingInternalBufferChecker.
Author: rkovacs Date: Sat Jun 9 14:08:27 2018 New Revision: 334352 URL: http://llvm.org/viewvc/llvm-project?rev=334352&view=rev Log: [analyzer] Clean up the program state map of DanglingInternalBufferChecker. Symbols are cleaned up from the program state map when they go out of scope. Memory regions are cleaned up when the corresponding object is destroyed, and additionally in 'checkDeadSymbols' in case destructor modeling was incomplete. Differential Revision: https://reviews.llvm.org/D47416 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp?rev=334352&r1=334351&r2=334352&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp Sat Jun 9 14:08:27 2018 @@ -26,7 +26,8 @@ using namespace ento; namespace { -class DanglingInternalBufferChecker : public Checker { +class DanglingInternalBufferChecker : public Checker { CallDescription CStrFn; public: @@ -36,6 +37,9 @@ public: /// corresponding string object region in the ProgramState. Mark the symbol /// released if the string object is destroyed. void checkPostCall(const CallEvent &Call, CheckerContext &C) const; + + /// Clean up the ProgramState map. + void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; }; } // end anonymous namespace @@ -76,12 +80,29 @@ void DanglingInternalBufferChecker::chec // FIXME: What if Origin is null? const Expr *Origin = Call.getOriginExpr(); State = allocation_state::markReleased(State, *StrBufferPtr, Origin); + State = State->remove(TypedR); C.addTransition(State); return; } } } +void DanglingInternalBufferChecker::checkDeadSymbols(SymbolReaper &SymReaper, + CheckerContext &C) const { + ProgramStateRef State = C.getState(); + RawPtrMapTy RPM = State->get(); + for (const auto Entry : RPM) { +if (!SymReaper.isLive(Entry.second)) + State = State->remove(Entry.first); +if (!SymReaper.isLiveRegion(Entry.first)) { + // Due to incomplete destructor support, some dead regions might still + // remain in the program state map. Clean them up. + State = State->remove(Entry.first); +} + } + C.addTransition(State); +} + void ento::registerDanglingInternalBufferChecker(CheckerManager &Mgr) { registerNewDeleteChecker(Mgr); Mgr.registerChecker(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45706: [CFG] [analyzer] Add construction contexts for loop condition variables.
alexfh added a comment. Herald added a subscriber: mikhail.ramalho. This commit seems to have introduced https://bugs.llvm.org/show_bug.cgi?id=37769. Could you take a look? Repository: rL LLVM https://reviews.llvm.org/D45706 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
ormris marked 2 inline comments as done. ormris added a comment. Thanks for the review @MTC! I'll wait for @NoQ's feedback. Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48030: clang-format: [JS] strict prop init annotation.
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 rL334415: clang-format: [JS] strict prop init annotation. (authored by mprobst, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D48030 Files: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -2981,7 +2981,7 @@ // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1540,6 +1540,15 @@ "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -2981,7 +2981,7 @@ // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1540,6 +1540,15 @@ "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334415 - clang-format: [JS] strict prop init annotation.
Author: mprobst Date: Mon Jun 11 09:20:13 2018 New Revision: 334415 URL: http://llvm.org/viewvc/llvm-project?rev=334415&view=rev Log: clang-format: [JS] strict prop init annotation. Summary: TypeScript uses the `!` token for strict property initialization assertions, as in: class X { strictPropAsserted!: string; } Previously, clang-format would wrap between the `!` and the `:` for overly long lines. This patch fixes that by generally preventing the wrap in that location. Reviewers: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48030 Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=334415&r1=334414&r2=334415&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jun 11 09:20:13 2018 @@ -2981,7 +2981,7 @@ bool TokenAnnotator::mustBreakBefore(con // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ bool TokenAnnotator::canBreakBefore(cons return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=334415&r1=334414&r2=334415&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jun 11 09:20:13 2018 @@ -1540,6 +1540,15 @@ TEST_F(FormatTestJS, ClassDeclarations) "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48021: [Driver] Add aliases for -Qn/-Qy
This revision was automatically updated to reflect the committed changes. Closed by commit rC334414: [Driver] Add aliases for -Qn/-Qy (authored by miyuki, committed by ). Changed prior to commit: https://reviews.llvm.org/D48021?vs=150732&id=150772#toc Repository: rC Clang https://reviews.llvm.org/D48021 Files: include/clang/Driver/Options.td test/CodeGen/no-ident-version.c Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -404,6 +404,8 @@ HelpText<"Emit metadata containing compiler name and version">; def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, HelpText<"Do not emit metadata containing compiler name and version">; +def : Flag<["-"], "fident">, Group, Alias, Flags<[CC1Option]>; +def : Flag<["-"], "fno-ident">, Group, Alias, Flags<[CC1Option]>; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; @@ -2840,7 +2842,6 @@ defm gcse_las: BooleanFFlag<"gcse-las">, Group; defm gcse_sm: BooleanFFlag<"gcse-sm">, Group; defm gnu : BooleanFFlag<"gnu">, Group; -defm ident : BooleanFFlag<"ident">, Group; defm implicit_templates : BooleanFFlag<"implicit-templates">, Group; defm implement_inlines : BooleanFFlag<"implement-inlines">, Group; defm merge_constants : BooleanFFlag<"merge-constants">, Group; Index: test/CodeGen/no-ident-version.c === --- test/CodeGen/no-ident-version.c +++ test/CodeGen/no-ident-version.c @@ -2,8 +2,12 @@ // RUN: | FileCheck --check-prefix=CHECK-NONE %s // RUN: %clang_cc1 -Qn -emit-llvm -debug-info-kind=limited -o - %s \ // RUN: | FileCheck --check-prefix=CHECK-QN %s +// RUN: %clang_cc1 -fno-ident -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QN %s // RUN: %clang_cc1 -Qy -emit-llvm -debug-info-kind=limited -o - %s \ // RUN: | FileCheck --check-prefix=CHECK-QY %s +// RUN: %clang_cc1 -fident -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QY %s // CHECK-NONE: @main // CHECK-NONE: llvm.ident Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -404,6 +404,8 @@ HelpText<"Emit metadata containing compiler name and version">; def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, HelpText<"Do not emit metadata containing compiler name and version">; +def : Flag<["-"], "fident">, Group, Alias, Flags<[CC1Option]>; +def : Flag<["-"], "fno-ident">, Group, Alias, Flags<[CC1Option]>; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; @@ -2840,7 +2842,6 @@ defm gcse_las: BooleanFFlag<"gcse-las">, Group; defm gcse_sm: BooleanFFlag<"gcse-sm">, Group; defm gnu : BooleanFFlag<"gnu">, Group; -defm ident : BooleanFFlag<"ident">, Group; defm implicit_templates : BooleanFFlag<"implicit-templates">, Group; defm implement_inlines : BooleanFFlag<"implement-inlines">, Group; defm merge_constants : BooleanFFlag<"merge-constants">, Group; Index: test/CodeGen/no-ident-version.c === --- test/CodeGen/no-ident-version.c +++ test/CodeGen/no-ident-version.c @@ -2,8 +2,12 @@ // RUN: | FileCheck --check-prefix=CHECK-NONE %s // RUN: %clang_cc1 -Qn -emit-llvm -debug-info-kind=limited -o - %s \ // RUN: | FileCheck --check-prefix=CHECK-QN %s +// RUN: %clang_cc1 -fno-ident -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QN %s // RUN: %clang_cc1 -Qy -emit-llvm -debug-info-kind=limited -o - %s \ // RUN: | FileCheck --check-prefix=CHECK-QY %s +// RUN: %clang_cc1 -fident -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QY %s // CHECK-NONE: @main // CHECK-NONE: llvm.ident ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334414 - [Driver] Add aliases for -Qn/-Qy
Author: miyuki Date: Mon Jun 11 09:10:06 2018 New Revision: 334414 URL: http://llvm.org/viewvc/llvm-project?rev=334414&view=rev Log: [Driver] Add aliases for -Qn/-Qy This patch adds aliases for -Qn (-fno-ident) and -Qy (-fident) which look less cryptic than -Qn/-Qy. The aliases are compatible with GCC. Differential Revision: https://reviews.llvm.org/D48021 Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/test/CodeGen/no-ident-version.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=334414&r1=334413&r2=334414&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Jun 11 09:10:06 2018 @@ -404,6 +404,8 @@ def Qy : Flag<["-"], "Qy">, Flags<[CC1Op HelpText<"Emit metadata containing compiler name and version">; def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, HelpText<"Do not emit metadata containing compiler name and version">; +def : Flag<["-"], "fident">, Group, Alias, Flags<[CC1Option]>; +def : Flag<["-"], "fno-ident">, Group, Alias, Flags<[CC1Option]>; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; @@ -2840,7 +2842,6 @@ defm gcse_after_reload: BooleanFFlag<"gc defm gcse_las: BooleanFFlag<"gcse-las">, Group; defm gcse_sm: BooleanFFlag<"gcse-sm">, Group; defm gnu : BooleanFFlag<"gnu">, Group; -defm ident : BooleanFFlag<"ident">, Group; defm implicit_templates : BooleanFFlag<"implicit-templates">, Group; defm implement_inlines : BooleanFFlag<"implement-inlines">, Group; defm merge_constants : BooleanFFlag<"merge-constants">, Group; Modified: cfe/trunk/test/CodeGen/no-ident-version.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/no-ident-version.c?rev=334414&r1=334413&r2=334414&view=diff == --- cfe/trunk/test/CodeGen/no-ident-version.c (original) +++ cfe/trunk/test/CodeGen/no-ident-version.c Mon Jun 11 09:10:06 2018 @@ -2,8 +2,12 @@ // RUN: | FileCheck --check-prefix=CHECK-NONE %s // RUN: %clang_cc1 -Qn -emit-llvm -debug-info-kind=limited -o - %s \ // RUN: | FileCheck --check-prefix=CHECK-QN %s +// RUN: %clang_cc1 -fno-ident -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QN %s // RUN: %clang_cc1 -Qy -emit-llvm -debug-info-kind=limited -o - %s \ // RUN: | FileCheck --check-prefix=CHECK-QY %s +// RUN: %clang_cc1 -fident -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QY %s // CHECK-NONE: @main // CHECK-NONE: llvm.ident ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47950: [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"
malaperle added a comment. Very nice! I tried "std" and got much less (unimportant) results. I see something a bit weird with "getStandardResourceDir" but it might be VSCode. Here, I guess it's the "d" in Dir that matches but what's odd is that VS Code will highlight the first "d", i.e. in "standard". But it doesn't look like there is any way to control this in the LSP, is there? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D47950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48030: clang-format: [JS] strict prop init annotation.
mprobst updated this revision to Diff 150770. mprobst added a comment. fix typo in test Repository: rC Clang https://reviews.llvm.org/D48030 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1540,6 +1540,15 @@ "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2981,7 +2981,7 @@ // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1540,6 +1540,15 @@ "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2981,7 +2981,7 @@ // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48030: clang-format: [JS] strict prop init annotation.
mprobst created this revision. mprobst added a reviewer: krasimir. TypeScript uses the `!` token for strict property initialization assertions, as in: class X { strictPropAsserted!: string; } Previously, clang-format would wrap between the `!` and the `:` for overly long lines. This patch fixes that by generally preventing the wrap in that location. Repository: rC Clang https://reviews.llvm.org/D48030 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1540,6 +1540,15 @@ "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2981,7 +2981,7 @@ // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1540,6 +1540,15 @@ "}"); } +TEST_F(FormatTestJS, StrictPropInitWrap) { + const FormatStyle &Style = getGoogleJSStyleWithColumns(22); + verifyFormat("class X {\n" + " strictPropInitField!:\n" + " string;\n" + "}", + Style); +} + TEST_F(FormatTestJS, InterfaceDeclarations) { verifyFormat("interface I {\n" " x: string;\n" Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2981,7 +2981,7 @@ // We deal with this case later by detecting an entry // following a closing paren of this submessage. } - + // If this is an entry immediately following a submessage, it will be // preceded by a closing paren of that submessage, like in: // left---. .---right @@ -3027,6 +3027,9 @@ return false; if (Left.is(TT_JsTypeColon)) return true; +// Don't wrap between ":" and "!" of a strict prop init ("field!: type;"). +if (Left.is(tok::exclaim) && Right.is(tok::colon)) + return false; if (Right.is(Keywords.kw_is)) return false; if (Left.is(Keywords.kw_in)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
GBuella added a comment. Ping @efriedma https://reviews.llvm.org/D45616 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
GBuella updated this revision to Diff 150767. GBuella added a comment. I altered the code, to ignore the the signaling behaviour, as suggested. Also, it handles more vector cmp builtins now. https://reviews.llvm.org/D45616 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx-builtins.c test/CodeGen/avx-cmp-builtins.c test/CodeGen/avx2-builtins.c test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c Index: test/CodeGen/avx512vl-builtins.c === --- test/CodeGen/avx512vl-builtins.c +++ test/CodeGen/avx512vl-builtins.c @@ -1073,53 +1073,168 @@ __mmask8 test_mm256_cmp_ps_mask(__m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_cmp_ps_mask - // CHECK: call <8 x i1> @llvm.x86.avx512.mask.cmp.ps.256 + // CHECK: fcmp oeq <8 x float> %{{.*}}, %{{.*}} return (__mmask8)_mm256_cmp_ps_mask(__A, __B, 0); } +__mmask8 test_mm256_cmp_ps_mask_true_uq(__m256 __A, __m256 __B) { + // CHECK-LABEL: @test_mm256_cmp_ps_mask_true_uq + // CHECK-NOT: call + // CHECK: ret i8 -1 + return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_TRUE_UQ); +} + +__mmask8 test_mm256_cmp_ps_mask_true_us(__m256 __A, __m256 __B) { + // CHECK-LABEL: @test_mm256_cmp_ps_mask_true_us + // CHECK-NOT: call + // CHECK: ret i8 -1 + return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_TRUE_US); +} + +__mmask8 test_mm256_cmp_ps_mask_false_oq(__m256 __A, __m256 __B) { + // CHECK-LABEL: @test_mm256_cmp_ps_mask_false_oq + // CHECK-NOT: call + // CHECK: ret i8 0 + return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_FALSE_OQ); +} + +__mmask8 test_mm256_cmp_ps_mask_false_os(__m256 __A, __m256 __B) { + // CHECK-LABEL: @test_mm256_cmp_ps_mask_false_os + // CHECK-NOT: call + // CHECK: ret i8 0 + return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_FALSE_OS); +} + __mmask8 test_mm256_mask_cmp_ps_mask(__mmask8 m, __m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask - // CHECK: [[CMP:%.*]] = call <8 x i1> @llvm.x86.avx512.mask.cmp.ps.256 - // CHECK: and <8 x i1> [[CMP]], {{.*}} + // CHECK: fcmp oeq <8 x float> %{{.*}}, %{{.*}} + // CHECK: and <8 x i1> %{{.*}}, %{{.*}} return _mm256_mask_cmp_ps_mask(m, __A, __B, 0); } __mmask8 test_mm_cmp_ps_mask(__m128 __A, __m128 __B) { // CHECK-LABEL: @test_mm_cmp_ps_mask - // CHECK: call <4 x i1> @llvm.x86.avx512.mask.cmp.ps.128 + // CHECK: fcmp oeq <4 x float> %{{.*}}, %{{.*}} return (__mmask8)_mm_cmp_ps_mask(__A, __B, 0); } +__mmask8 test_mm_cmp_ps_mask_true_uq(__m128 __A, __m128 __B) { + // CHECK-LABEL: @test_mm_cmp_ps_mask_true_uq + // CHECK-NOT: call + // CHECK: ret i8 -1 + return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_TRUE_UQ); +} + +__mmask8 test_mm_cmp_ps_mask_true_us(__m128 __A, __m128 __B) { + // CHECK-LABEL: @test_mm_cmp_ps_mask_true_us + // CHECK-NOT: call + // CHECK: ret i8 -1 + return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_TRUE_US); +} + +__mmask8 test_mm_cmp_ps_mask_false_oq(__m128 __A, __m128 __B) { + // CHECK-LABEL: @test_mm_cmp_ps_mask_false_oq + // CHECK-NOT: call + // CHECK: ret i8 0 + return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_FALSE_OQ); +} + +__mmask8 test_mm_cmp_ps_mask_false_os(__m128 __A, __m128 __B) { + // CHECK-LABEL: @test_mm_cmp_ps_mask_false_os + // CHECK-NOT: call + // CHECK: ret i8 0 + return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_FALSE_OS); +} + __mmask8 test_mm_mask_cmp_ps_mask(__mmask8 m, __m128 __A, __m128 __B) { // CHECK-LABEL: @test_mm_mask_cmp_ps_mask - // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.x86.avx512.mask.cmp.ps.128 - // CHECK: and <4 x i1> [[CMP]], {{.*}} + // CHECK: fcmp oeq <4 x float> %{{.*}}, %{{.*}} + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: and <4 x i1> %{{.*}}, %{{.*}} return _mm_mask_cmp_ps_mask(m, __A, __B, 0); } __mmask8 test_mm256_cmp_pd_mask(__m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_cmp_pd_mask - // CHECK: call <4 x i1> @llvm.x86.avx512.mask.cmp.pd.256 + // CHECK: fcmp oeq <4 x double> %{{.*}}, %{{.*}} return (__mmask8)_mm256_cmp_pd_mask(__A, __B, 0); } +__mmask8 test_mm256_cmp_pd_mask_true_uq(__m256d __A, __m256d __B) { + // CHECK-LABEL: @test_mm256_cmp_pd_mask_true_uq + // CHECK-NOT: call + // CHECK: ret i8 -1 + return (__mmask8)_mm256_cmp_pd_mask(__A, __B, _CMP_TRUE_UQ); +} + +__mmask8 test_mm256_cmp_pd_mask_true_us(__m256d __A, __m256d __B) { + // CHECK-LABEL: @test_mm256_cmp_pd_mask_true_us + // CHECK-NOT: call + // CHECK: ret i8 -1 + return (__mmask8)_mm256_cmp_pd_mask(__A, __B, _CMP_TRUE_US); +} + +__mmask8 test_mm256_cmp_pd_mask_false_oq(__m256d __A, __m256d __B) { + // CHECK-LABEL: @test_mm256_cmp_pd_mask_false_oq + // CHECK-NOT: call + // CHECK: ret i8 0 + return (__mmask8)_mm256_cmp_pd_mask(__A, __B, _CMP_FALSE_OQ); +} + +__mmask8 test_mm256_cmp_pd_mask_false_os(__m256d __A, __m256d __B) { + // CHECK-LABEL: @test_mm256_cmp_pd_mask_false_os + // CHECK-NOT: call + // CHECK: ret i8 0 + return (__
[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease
hans added a comment. It sounds like adding proper support for HLE prefixes is a largeish project. ctopper, rnk: Do you think it would be worth adding inline asm versions (with the xacquire/release prefixes) of these intrinsics in the meantime? It would inhibit optimizations but be better than the current state of not having the intrinsics at all. Repository: rC Clang https://reviews.llvm.org/D47672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets
erik.pilkington added a comment. Ping! https://reviews.llvm.org/D46845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.
xazax.hun added a comment. Having C++ support would be awesome! Thanks for working on this! While I do agree matching is not trivial with qualified names, this problem is already solved with AST matchers. I wonder if using matchers or reusing the `HasNameMatcher` class would make this easier. That code path is already well tested and optimized. Repository: rC Clang https://reviews.llvm.org/D48027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.
MTC updated this revision to Diff 150758. MTC added a comment. Remove useless header files for testing. Repository: rC Clang https://reviews.llvm.org/D48027 Files: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h lib/StaticAnalyzer/Core/CallEvent.cpp Index: lib/StaticAnalyzer/Core/CallEvent.cpp === --- lib/StaticAnalyzer/Core/CallEvent.cpp +++ lib/StaticAnalyzer/Core/CallEvent.cpp @@ -256,11 +256,18 @@ return false; if (!CD.IsLookupDone) { CD.IsLookupDone = true; -CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName); +CD.II = &getState()->getStateManager().getContext().Idents.get( +CD.getFunctionName()); } const IdentifierInfo *II = getCalleeIdentifier(); if (!II || II != CD.II) return false; + + const auto *ND = dyn_cast_or_null(getDecl()); + if (!ND) +return false; + if (!CD.matchQualifiedName(ND->getQualifiedNameAsString())) +return false; return (CD.RequiredArgs == CallDescription::NoArgRequirement || CD.RequiredArgs == getNumArgs()); } Index: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -79,6 +79,8 @@ mutable IdentifierInfo *II = nullptr; mutable bool IsLookupDone = false; + // Represent the function name or method name, like "c_str" or + // "std::string::c_str". StringRef FuncName; unsigned RequiredArgs; @@ -96,7 +98,25 @@ : FuncName(FuncName), RequiredArgs(RequiredArgs) {} /// Get the name of the function that this object matches. - StringRef getFunctionName() const { return FuncName; } + StringRef getFunctionName() const { +auto QualifierNamePair = FuncName.rsplit("::"); +return QualifierNamePair.second.empty() ? QualifierNamePair.first +: QualifierNamePair.second; + } + + bool matchQualifiedName(llvm::StringRef QualifiedName) const { +llvm::SmallVector Names; +// Split the function name with the separator "::". +FuncName.split(Names, "::"); + +// FIXME: Since there is no perfect way to get the qualified name without +// template argument, we can only use a fuzzy matching approach. +for (auto item : Names) + if (QualifiedName.find(item) == StringRef::npos) +return false; + +return true; + } }; template Index: lib/StaticAnalyzer/Core/CallEvent.cpp === --- lib/StaticAnalyzer/Core/CallEvent.cpp +++ lib/StaticAnalyzer/Core/CallEvent.cpp @@ -256,11 +256,18 @@ return false; if (!CD.IsLookupDone) { CD.IsLookupDone = true; -CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName); +CD.II = &getState()->getStateManager().getContext().Idents.get( +CD.getFunctionName()); } const IdentifierInfo *II = getCalleeIdentifier(); if (!II || II != CD.II) return false; + + const auto *ND = dyn_cast_or_null(getDecl()); + if (!ND) +return false; + if (!CD.matchQualifiedName(ND->getQualifiedNameAsString())) +return false; return (CD.RequiredArgs == CallDescription::NoArgRequirement || CD.RequiredArgs == getNumArgs()); } Index: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -79,6 +79,8 @@ mutable IdentifierInfo *II = nullptr; mutable bool IsLookupDone = false; + // Represent the function name or method name, like "c_str" or + // "std::string::c_str". StringRef FuncName; unsigned RequiredArgs; @@ -96,7 +98,25 @@ : FuncName(FuncName), RequiredArgs(RequiredArgs) {} /// Get the name of the function that this object matches. - StringRef getFunctionName() const { return FuncName; } + StringRef getFunctionName() const { +auto QualifierNamePair = FuncName.rsplit("::"); +return QualifierNamePair.second.empty() ? QualifierNamePair.first +: QualifierNamePair.second; + } + + bool matchQualifiedName(llvm::StringRef QualifiedName) const { +llvm::SmallVector Names; +// Split the function name with the separator "::". +FuncName.split(Names, "::"); + +// FIXME: Since there is no perfect way to get the qualified name without +// template argument, we can only use a fuzzy matching approach. +for (auto item : Names) + if (QualifiedName.find(item) == StringRef::npos) +return false; + +return true; + } }; template ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-b
[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.
MTC added a comment. The implementation is not complicated, the difficulty is that there is no good way to get the qualified name without template arguments. For 'std::basic_string::c_str()', its qualified name may be `std::__1::basic_string, std::__1::allocator >::c_str`, it is almost impossible for users to provide such a name. So one possible implementation is to use `std`, `basic_string` and `c_str` to match in the `std::__1::basic_string, std::__1::allocator >::c_str` sequentially. Repository: rC Clang https://reviews.llvm.org/D48027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43015: clang-format: Introduce BreakInheritanceList option
This revision was automatically updated to reflect the committed changes. Closed by commit rC334408: clang-format: Introduce BreakInheritanceList option (authored by Typz, committed by ). Changed prior to commit: https://reviews.llvm.org/D43015?vs=150755&id=150756#toc Repository: rC Clang https://reviews.llvm.org/D43015 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -893,16 +893,35 @@ /// \endcode std::string CommentPragmas; - /// If ``true``, in the class inheritance expression clang-format will - /// break before ``:`` and ``,`` if there is multiple inheritance. - /// \code - ///true: false: - ///class MyClass vs. class MyClass : public X, public Y { - ///: public X }; - ///, public Y { - ///}; - /// \endcode - bool BreakBeforeInheritanceComma; + /// Different ways to break inheritance list. + enum BreakInheritanceListStyle { +/// Break inheritance list before the colon and after the commas. +/// \code +/// class Foo +/// : Base1, +/// Base2 +/// {}; +/// \endcode +BILS_BeforeColon, +/// Break inheritance list before the colon and commas, and align +/// the commas with the colon. +/// \code +/// Constructor() +/// : initializer1() +/// , initializer2() +/// \endcode +BILS_BeforeComma, +/// Break inheritance list after the colon and commas. +/// \code +/// Constructor() : +/// initializer1(), +/// initializer2() +/// \endcode +BILS_AfterColon + }; + + /// The inheritance list style to use. + BreakInheritanceListStyle BreakInheritanceList; /// If ``true``, consecutive namespace declarations will be on the same /// line. If ``false``, each namespace is declared on a new line. @@ -946,7 +965,7 @@ bool ConstructorInitializerAllOnOneLineOrOnePerLine; /// The number of characters to use for indentation of constructor - /// initializer lists. + /// initializer lists as well as inheritance lists. unsigned ConstructorInitializerIndentWidth; /// Indent width for line continuations. @@ -1673,7 +1692,7 @@ BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations && BreakStringLiterals == R.BreakStringLiterals && ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas && - BreakBeforeInheritanceComma == R.BreakBeforeInheritanceComma && + BreakInheritanceList == R.BreakInheritanceList && ConstructorInitializerAllOnOneLineOrOnePerLine == R.ConstructorInitializerAllOnOneLineOrOnePerLine && ConstructorInitializerIndentWidth == Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -149,6 +149,16 @@ }; template <> +struct ScalarEnumerationTraits { + static void + enumeration(IO &IO, FormatStyle::BreakInheritanceListStyle &Value) { +IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon); +IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma); +IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon); + } +}; + +template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, FormatStyle::PPDirectiveIndentStyle &Value) { IO.enumCase(Value, "None", FormatStyle::PPDIS_None); @@ -350,8 +360,19 @@ IO.mapOptional("BreakBeforeBinaryOperators", Style.BreakBeforeBinaryOperators); IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces); + +bool BreakBeforeInheritanceComma = false; IO.mapOptional("BreakBeforeInheritanceComma", - Style.BreakBeforeInheritanceComma); + BreakBeforeInheritanceComma); +IO.mapOptional("BreakInheritanceList", + Style.BreakInheritanceList); +// If BreakBeforeInheritanceComma was specified but +// BreakInheritance was not, initialize the latter from the +// former for backwards compatibility. +if (BreakBeforeInheritanceComma && +Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon) + Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma; + IO.mapOptional("BreakBeforeTernaryOperators", Style.BreakBeforeTernaryOperators); @@ -624,7 +645,7 @@ false, false, true, true, true}; LLVMStyle.BreakAfterJavaFieldAnnotations = false; LLVMStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon; - LLVMStyle.BreakBeforeInheritanceComm
r334408 - clang-format: Introduce BreakInheritanceList option
Author: typz Date: Mon Jun 11 07:41:26 2018 New Revision: 334408 URL: http://llvm.org/viewvc/llvm-project?rev=334408&view=rev Log: clang-format: Introduce BreakInheritanceList option Summary: This option replaces the BreakBeforeInheritanceComma option with an enum, thus introducing a mode where the colon stays on the same line as constructor declaration: // When it fits on line: class A : public B, public C { ... }; // When it does not fit: class A : public B, public C { ... }; This matches the behavior of the `BreakConstructorInitializers` option, introduced in https://reviews.llvm.org/D32479. Reviewers: djasper, klimek Reviewed By: djasper Subscribers: mzeren-vmw, cfe-commits Differential Revision: https://reviews.llvm.org/D43015 Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/Format.cpp cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=334408&r1=334407&r2=334408&view=diff == --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original) +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Jun 11 07:41:26 2018 @@ -994,18 +994,6 @@ the configuration (without a prefix: ``A -**BreakBeforeInheritanceComma** (``bool``) - If ``true``, in the class inheritance expression clang-format will - break before ``:`` and ``,`` if there is multiple inheritance. - - .. code-block:: c++ - - true: false: - class MyClass vs. class MyClass : public X, public Y { - : public X }; - , public Y { - }; - **BreakBeforeTernaryOperators** (``bool``) If ``true``, ternary operators will be placed after line breaks. @@ -1056,6 +1044,42 @@ the configuration (without a prefix: ``A +**BreakInheritanceList** (``BreakInheritanceListStyle``) + The inheritance list style to use. + + Possible values: + + * ``BILS_BeforeColon`` (in configuration: ``BeforeColon``) +Break inheritance list before the colon and after the commas. + +.. code-block:: c++ + +class Foo +: Base1, + Base2 +{}; + + * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``) +Break inheritance list before the colon and commas, and align +the commas with the colon. + +.. code-block:: c++ + +Constructor() +: initializer1() +, initializer2() + + * ``BILS_AfterColon`` (in configuration: ``AfterColon``) +Break inheritance list after the colon and commas. + +.. code-block:: c++ + +Constructor() : +initializer1(), +initializer2() + + + **BreakStringLiterals** (``bool``) Allow breaking string literals when formatting. @@ -1122,7 +1146,7 @@ the configuration (without a prefix: ``A **ConstructorInitializerIndentWidth** (``unsigned``) The number of characters to use for indentation of constructor - initializer lists. + initializer lists as well as inheritance lists. **ContinuationIndentWidth** (``unsigned``) Indent width for line continuations. Modified: cfe/trunk/include/clang/Format/Format.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=334408&r1=334407&r2=334408&view=diff == --- cfe/trunk/include/clang/Format/Format.h (original) +++ cfe/trunk/include/clang/Format/Format.h Mon Jun 11 07:41:26 2018 @@ -893,16 +893,35 @@ struct FormatStyle { /// \endcode std::string CommentPragmas; - /// If ``true``, in the class inheritance expression clang-format will - /// break before ``:`` and ``,`` if there is multiple inheritance. - /// \code - ///true: false: - ///class MyClass vs. class MyClass : public X, public Y { - ///: public X }; - ///, public Y { - ///}; - /// \endcode - bool BreakBeforeInheritanceComma; + /// Different ways to break inheritance list. + enum BreakInheritanceListStyle { +/// Break inheritance list before the colon and after the commas. +/// \code +/// class Foo +/// : Base1, +/// Base2 +/// {}; +/// \endcode +BILS_BeforeColon, +/// Break inheritance list before the colon and commas, and align +/// the commas with the colon. +/// \code +/// Constructor() +/// : initializer1() +/// , initializer2() +/// \endcode +BILS_BeforeComma, +/// Break inheritance list after the colon and commas. +/// \code +/// Constructor() : +/// initializer1(), +/// initializer2() +/// \end
[PATCH] D43015: clang-format: Introduce BreakInheritanceList option
Typz updated this revision to Diff 150755. Typz added a comment. rebase Repository: rC Clang https://reviews.llvm.org/D43015 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1316,15 +1316,40 @@ verifyFormat("class ::A::B {};"); } -TEST_F(FormatTest, BreakBeforeInheritanceComma) { - FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); - StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; - - verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); +TEST_F(FormatTest, BreakInheritanceStyle) { + FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle(); + StyleWithInheritanceBreakBeforeComma.BreakInheritanceList = + FormatStyle::BILS_BeforeComma; + verifyFormat("class MyClass : public X {};", + StyleWithInheritanceBreakBeforeComma); verifyFormat("class MyClass\n" ": public X\n" ", public Y {};", - StyleWithInheritanceBreak); + StyleWithInheritanceBreakBeforeComma); + verifyFormat("class AA\n" + ": public BB\n" + ", public CC {};", + StyleWithInheritanceBreakBeforeComma); + verifyFormat("struct a\n" + ": public aaa< // break\n" + " > {};", + StyleWithInheritanceBreakBeforeComma); + + FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle(); + StyleWithInheritanceBreakAfterColon.BreakInheritanceList = + FormatStyle::BILS_AfterColon; + verifyFormat("class MyClass : public X {};", + StyleWithInheritanceBreakAfterColon); + verifyFormat("class MyClass : public X, public Y {};", + StyleWithInheritanceBreakAfterColon); + verifyFormat("class AA :\n" + "public BB,\n" + "public CC {};", + StyleWithInheritanceBreakAfterColon); + verifyFormat("struct a :\n" + "public aaa< // break\n" + "> {};", + StyleWithInheritanceBreakAfterColon); } TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { @@ -3726,6 +3751,23 @@ " aa,\n" " bb {}", Style); + + // `ConstructorInitializerIndentWidth` actually applies to InheritanceList as well + Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon; + verifyFormat("class SomeClass\n" + " : public aa,\n" + "public bb {};", + Style); + Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma; + verifyFormat("class SomeClass\n" + " : public aa\n" + " , public bb {};", + Style); + Style.BreakInheritanceList = FormatStyle::BILS_AfterColon; + verifyFormat("class SomeClass :\n" + " public aa,\n" + " public bb {};", + Style); } #ifndef EXPENSIVE_CHECKS @@ -9164,7 +9206,7 @@ " (2) {}", CtorInitializerStyle); - FormatStyle InheritanceStyle = getLLVMStyle(); + FormatStyle InheritanceStyle = getLLVMStyleWithColumns(30); InheritanceStyle.SpaceBeforeInheritanceColon = false; verifyFormat("class Foo: public Bar {};", InheritanceStyle); verifyFormat("Foo::Foo() : foo(1) {}", InheritanceStyle); @@ -9180,6 +9222,29 @@ "default:\n" "}", InheritanceStyle); + InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_AfterColon; + verifyFormat("class Foo:\n" + "public aa,\n" + "public bb {\n" + "}", + InheritanceStyle); + InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_BeforeComma; + verifyFormat("class Foo\n" + ": public aa\n" + ", public bb {\n" + "}", + InheritanceStyle); +