[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files
nkakuev added a comment. In https://reviews.llvm.org/D26418#590168, @alexfh wrote: > What's the biggest complexity with -header-filter? Lack of way to specify > ? Will it help to make -header-filter a > GlobList? See my previous comment. Header filter isn't to help when a (false positive) warning, caused by a third-party header, results in diagnostics for your source file. https://reviews.llvm.org/D26418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files
nkakuev added a comment. In https://reviews.llvm.org/D26418#590170, @alexfh wrote: > I also don't understand the use case for turning off only some checks for > third-party headers. Either you care about third-party stuff or not, why only > switch off certain checks? The use case is ignoring false positives that originate from third-party headers. Because even if you don't care about third-party stuff, you can't suppress all diagnostics from it. Here's an example: // header.h void TriggerWarning(const int& In, int& Out) { if (In > 123) Out = 123; } // source.cpp #include "header.h" void MaybeInitialize(int &Out) { int In; TriggerWarning(In, Out); } The warning is caused by a third-party code, but header filter won't help you to suppress it since it now relates to your sources. But let's say this warning is a false-positive. What can you do to suppress it? You can turn off a faulty check, but you need to turn it off for //your// code. With '-suppress-checks-filter' you can turn it off for third-party headers only, without sabotaging your own sources. https://reviews.llvm.org/D26418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26306: [AVX-512] Make VBMI instruction set enabling imply that the BWI instruction set is also enabled.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286340: [AVX-512] Make VBMI instruction set enabling imply that the BWI instruction set… (authored by ctopper). Changed prior to commit: https://reviews.llvm.org/D26306?vs=76961&id=77310#toc Repository: rL LLVM https://reviews.llvm.org/D26306 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/x86_target_features.c Index: cfe/trunk/test/Preprocessor/x86_target_features.c === --- cfe/trunk/test/Preprocessor/x86_target_features.c +++ cfe/trunk/test/Preprocessor/x86_target_features.c @@ -196,6 +196,7 @@ // RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vbmi -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512VBMI %s // AVX512VBMI: #define __AVX2__ 1 +// AVX512VBMI: #define __AVX512BW__ 1 // AVX512VBMI: #define __AVX512F__ 1 // AVX512VBMI: #define __AVX512VBMI__ 1 // AVX512VBMI: #define __AVX__ 1 @@ -208,6 +209,11 @@ // AVX512VBMI: #define __SSE__ 1 // AVX512VBMI: #define __SSSE3__ 1 +// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vbmi -mno-avx512bw -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512VBMINOAVX512BW %s + +// AVX512VBMINOAVX512BW-NOT: #define __AVX512BW__ 1 +// AVX512VBMINOAVX512BW-NOT: #define __AVX512VBMI__ 1 + // RUN: %clang -target i386-unknown-unknown -march=atom -msse4.2 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSE42POPCNT %s // SSE42POPCNT: #define __POPCNT__ 1 Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -3351,6 +3351,12 @@ Name == "avx512vbmi" || Name == "avx512ifma") { if (Enabled) setSSELevel(Features, AVX512F, Enabled); +// Enable BWI instruction if VBMI is being enabled. +if (Name == "avx512vbmi" && Enabled) + Features["avx512bw"] = true; +// Also disable VBMI if BWI is being disabled. +if (Name == "avx512bw" && !Enabled) + Features["avx512vbmi"] = false; } else if (Name == "fma") { if (Enabled) setSSELevel(Features, AVX, Enabled); Index: cfe/trunk/test/Preprocessor/x86_target_features.c === --- cfe/trunk/test/Preprocessor/x86_target_features.c +++ cfe/trunk/test/Preprocessor/x86_target_features.c @@ -196,6 +196,7 @@ // RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vbmi -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512VBMI %s // AVX512VBMI: #define __AVX2__ 1 +// AVX512VBMI: #define __AVX512BW__ 1 // AVX512VBMI: #define __AVX512F__ 1 // AVX512VBMI: #define __AVX512VBMI__ 1 // AVX512VBMI: #define __AVX__ 1 @@ -208,6 +209,11 @@ // AVX512VBMI: #define __SSE__ 1 // AVX512VBMI: #define __SSSE3__ 1 +// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vbmi -mno-avx512bw -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512VBMINOAVX512BW %s + +// AVX512VBMINOAVX512BW-NOT: #define __AVX512BW__ 1 +// AVX512VBMINOAVX512BW-NOT: #define __AVX512VBMI__ 1 + // RUN: %clang -target i386-unknown-unknown -march=atom -msse4.2 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSE42POPCNT %s // SSE42POPCNT: #define __POPCNT__ 1 Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -3351,6 +3351,12 @@ Name == "avx512vbmi" || Name == "avx512ifma") { if (Enabled) setSSELevel(Features, AVX512F, Enabled); +// Enable BWI instruction if VBMI is being enabled. +if (Name == "avx512vbmi" && Enabled) + Features["avx512bw"] = true; +// Also disable VBMI if BWI is being disabled. +if (Name == "avx512bw" && !Enabled) + Features["avx512vbmi"] = false; } else if (Name == "fma") { if (Enabled) setSSELevel(Features, AVX, Enabled); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286340 - [AVX-512] Make VBMI instruction set enabling imply that the BWI instruction set is also enabled.
Author: ctopper Date: Tue Nov 8 22:51:03 2016 New Revision: 286340 URL: http://llvm.org/viewvc/llvm-project?rev=286340&view=rev Log: [AVX-512] Make VBMI instruction set enabling imply that the BWI instruction set is also enabled. Summary: This is needed to make the v64i8 and v32i16 types legal for the 512-bit VBMI instructions. Fixes PR30912. Reviewers: delena, zvi Subscribers: RKSimon, cfe-commits Differential Revision: https://reviews.llvm.org/D26306 Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/x86_target_features.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286340&r1=286339&r2=286340&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov 8 22:51:03 2016 @@ -3351,6 +3351,12 @@ void X86TargetInfo::setFeatureEnabledImp Name == "avx512vbmi" || Name == "avx512ifma") { if (Enabled) setSSELevel(Features, AVX512F, Enabled); +// Enable BWI instruction if VBMI is being enabled. +if (Name == "avx512vbmi" && Enabled) + Features["avx512bw"] = true; +// Also disable VBMI if BWI is being disabled. +if (Name == "avx512bw" && !Enabled) + Features["avx512vbmi"] = false; } else if (Name == "fma") { if (Enabled) setSSELevel(Features, AVX, Enabled); Modified: cfe/trunk/test/Preprocessor/x86_target_features.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/x86_target_features.c?rev=286340&r1=286339&r2=286340&view=diff == --- cfe/trunk/test/Preprocessor/x86_target_features.c (original) +++ cfe/trunk/test/Preprocessor/x86_target_features.c Tue Nov 8 22:51:03 2016 @@ -196,6 +196,7 @@ // RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vbmi -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512VBMI %s // AVX512VBMI: #define __AVX2__ 1 +// AVX512VBMI: #define __AVX512BW__ 1 // AVX512VBMI: #define __AVX512F__ 1 // AVX512VBMI: #define __AVX512VBMI__ 1 // AVX512VBMI: #define __AVX__ 1 @@ -208,6 +209,11 @@ // AVX512VBMI: #define __SSE__ 1 // AVX512VBMI: #define __SSSE3__ 1 +// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vbmi -mno-avx512bw -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512VBMINOAVX512BW %s + +// AVX512VBMINOAVX512BW-NOT: #define __AVX512BW__ 1 +// AVX512VBMINOAVX512BW-NOT: #define __AVX512VBMI__ 1 + // RUN: %clang -target i386-unknown-unknown -march=atom -msse4.2 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSE42POPCNT %s // SSE42POPCNT: #define __POPCNT__ 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS
ikudrin added a comment. Done: https://reviews.llvm.org/rL286337. https://reviews.llvm.org/D26150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r286337 - [libc++abi] Remove the test for checking using of fallback malloc in case of dynamic memory exhaustion.
Author: ikudrin Date: Tue Nov 8 22:14:31 2016 New Revision: 286337 URL: http://llvm.org/viewvc/llvm-project?rev=286337&view=rev Log: [libc++abi] Remove the test for checking using of fallback malloc in case of dynamic memory exhaustion. This test is too fragile and doesn't add significant value. See https://reviews.llvm.org/D26150 for some details. Removed: libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp Removed: libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp?rev=286336&view=auto == --- libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp (original) +++ libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp (removed) @@ -1,40 +0,0 @@ -//===--- test_exception_storage_nodynmem.cpp --===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// - -// UNSUPPORTED: libcxxabi-no-exceptions - -// cxa_exception_storage does not use dynamic memory in the single thread mode. -// UNSUPPORTED: libcpp-has-no-threads - -// Our overwritten calloc() is not compatible with these sanitizers. -// UNSUPPORTED: msan, tsan - -#include -#include - -static bool OverwrittenCallocCalled = false; - -// Override calloc to simulate exhaustion of dynamic memory -void *calloc(size_t, size_t) { -OverwrittenCallocCalled = true; -return 0; -} - -int main(int argc, char *argv[]) { -// Run the test a couple of times -// to ensure that fallback memory doesn't leak. -for (int I = 0; I < 1000; ++I) -try { -throw 42; -} catch (...) { -} - -assert(OverwrittenCallocCalled); -return 0; -} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286336 - Doxygen comments for avxintrin.h.
Author: kromanova Date: Tue Nov 8 21:58:30 2016 New Revision: 286336 URL: http://llvm.org/viewvc/llvm-project?rev=286336&view=rev Log: Doxygen comments for avxintrin.h. Added doxygen comments to avxintrin.h's intrinsics. As of now, around 75% of the intrinsics in this file are documented here. The patches for the other 25% will be se nt out later. Removed extra spaces in emmitrin.h. Note: The doxygen comments are automatically generated based on Sony's intrinsics document. I got an OK from Eric Christopher to commit doxygen comments without prior code review upstream. Modified: cfe/trunk/lib/Headers/avxintrin.h cfe/trunk/lib/Headers/emmintrin.h Modified: cfe/trunk/lib/Headers/avxintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=286336&r1=286335&r2=286336&view=diff == --- cfe/trunk/lib/Headers/avxintrin.h (original) +++ cfe/trunk/lib/Headers/avxintrin.h Tue Nov 8 21:58:30 2016 @@ -2533,12 +2533,65 @@ _mm256_undefined_si256(void) return (__m256i)__builtin_ia32_undef256(); } +/// \brief Constructs a 256-bit floating-point vector of [4 x double] +///initialized with the specified double-precision floating-point values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VUNPCKLPD+VINSERTF128 instruction. +/// +/// \param __a +///A double-precision floating-point value used to initialize bits [255:192] +///of the result. +/// \param __b +///A double-precision floating-point value used to initialize bits [191:128] +///of the result. +/// \param __c +///A double-precision floating-point value used to initialize bits [127:64] +///of the result. +/// \param __d +///A double-precision floating-point value used to initialize bits [63:0] +///of the result. +/// \returns An initialized 256-bit floating-point vector of [4 x double]. static __inline __m256d __DEFAULT_FN_ATTRS _mm256_set_pd(double __a, double __b, double __c, double __d) { return (__m256d){ __d, __c, __b, __a }; } +/// \brief Constructs a 256-bit floating-point vector of [8 x float] initialized +///with the specified single-precision floating-point values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +///instruction. +/// +/// \param __a +///A single-precision floating-point value used to initialize bits [255:224] +///of the result. +/// \param __b +///A single-precision floating-point value used to initialize bits [223:192] +///of the result. +/// \param __c +///A single-precision floating-point value used to initialize bits [191:160] +///of the result. +/// \param __d +///A single-precision floating-point value used to initialize bits [159:128] +///of the result. +/// \param __e +///A single-precision floating-point value used to initialize bits [127:96] +///of the result. +/// \param __f +///A single-precision floating-point value used to initialize bits [95:64] +///of the result. +/// \param __g +///A single-precision floating-point value used to initialize bits [63:32] +///of the result. +/// \param __h +///A single-precision floating-point value used to initialize bits [31:0] +///of the result. +/// \returns An initialized 256-bit floating-point vector of [8 x float]. static __inline __m256 __DEFAULT_FN_ATTRS _mm256_set_ps(float __a, float __b, float __c, float __d, float __e, float __f, float __g, float __h) @@ -2546,6 +2599,31 @@ _mm256_set_ps(float __a, float __b, floa return (__m256){ __h, __g, __f, __e, __d, __c, __b, __a }; } +/// \brief Constructs a 256-bit integer vector initialized with the specified +///32-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +///instruction. +/// +/// \param __i0 +///A 32-bit integral value used to initialize bits [255:224] of the result. +/// \param __i1 +///A 32-bit integral value used to initialize bits [223:192] of the result. +/// \param __i2 +///A 32-bit integral value used to initialize bits [191:160] of the result. +/// \param __i3 +///A 32-bit integral value used to initialize bits [159:128] of the result. +/// \param __i4 +///A 32-bit integral value used to initialize bits [127:96] of the result. +/// \param __i5 +///A 32-bit integral value used to initialize bits [95:64] of the result. +/// \param __i6 +///A 32-bit integral value used to initialize bits [63:32] of the result. +/// \param __i7 +///A 32-bit integral value used to initialize bits [31:0] of the result. +/// \returns An initialized 256-bit integer vector. static __inline __m256i __DEFAULT_FN_ATTRS _mm256_set_epi32(int __i0, int __i1, int __i2, int __i3, int __i4, int __i5, int __i6, int __i7) @@ -2553,6 +2631,47 @@ _mm256_set_epi32(int
[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS
EricWF added a comment. Go ahead and remove it. Ill try and fix it later next week when I get time. https://reviews.llvm.org/D26150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r286334 - Revert "[CMake] Check runtimes subdir when looking for libcxx and libuwind"
Author: phosek Date: Tue Nov 8 21:38:21 2016 New Revision: 286334 URL: http://llvm.org/viewvc/llvm-project?rev=286334&view=rev Log: Revert "[CMake] Check runtimes subdir when looking for libcxx and libuwind" This reverts commit eecb79506d88b268fb0d00cce178213b4aa17933. Modified: libcxxabi/trunk/CMakeLists.txt Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286334&r1=286333&r2=286334&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Tue Nov 8 21:38:21 2016 @@ -140,10 +140,7 @@ endif() if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR) set(LIBCXXABI_LIBCXX_SRC_DIR ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}) else() - set(LIBCXXABI_LIBCXX_SRC_DIR -"${LLVM_MAIN_SRC_DIR}/projects/libcxx" -"${LLVM_MAIN_SRC_DIR}/runtimes/libcxx" -) + set(LIBCXXABI_LIBCXX_SRC_DIR ${LLVM_MAIN_SRC_DIR}/projects/libcxx) endif() find_path( @@ -383,7 +380,6 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_ ${LIBCXXABI_LIBUNWIND_PATH}/include ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES} ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include - ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include NO_DEFAULT_PATH ) @@ -393,7 +389,6 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_ PATHS ${LIBCXXABI_LIBUNWIND_PATH}/src/ ${LIBCXXABI_LIBUNWIND_INCLUDES}/../src/ ${LLVM_MAIN_SRC_DIR}/projects/libunwind/src/ - ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/src/ NO_DEFAULT_PATH ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r286333 - [CMake] Check runtimes subdir when looking for libcxxabi
Author: phosek Date: Tue Nov 8 21:22:28 2016 New Revision: 286333 URL: http://llvm.org/viewvc/llvm-project?rev=286333&view=rev Log: [CMake] Check runtimes subdir when looking for libcxxabi The runtimes subdir is the new location for runtimes, we should include it when looking for libcxxabi headers. Differential Revision: https://reviews.llvm.org/D26363 Modified: libcxx/trunk/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=286333&r1=286332&r2=286333&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Tue Nov 8 21:22:28 2016 @@ -101,10 +101,17 @@ set_property(CACHE LIBCXX_CXX_ABI PROPER # Setup the default options if LIBCXX_CXX_ABI is not specified. if (NOT LIBCXX_CXX_ABI) + find_path( +LIBCXX_LIBCXXABI_INCLUDES_INTERNAL +cxxabi.h +PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include + ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include +NO_DEFAULT_PATH + ) if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND - IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") + IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") -set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include") +set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_INTREE 1) else() set(LIBCXX_CXX_ABI_LIBNAME "none") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r286332 - [CMake] Check runtimes subdir when looking for libcxx and libuwind
Author: phosek Date: Tue Nov 8 21:22:19 2016 New Revision: 286332 URL: http://llvm.org/viewvc/llvm-project?rev=286332&view=rev Log: [CMake] Check runtimes subdir when looking for libcxx and libuwind The runtimes subdir is the new location for runtimes, we should include it when looking for libcxx and libunwind headers. Differential Revision: https://reviews.llvm.org/D26362 Modified: libcxxabi/trunk/CMakeLists.txt Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286332&r1=286331&r2=286332&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Tue Nov 8 21:22:19 2016 @@ -140,7 +140,10 @@ endif() if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR) set(LIBCXXABI_LIBCXX_SRC_DIR ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}) else() - set(LIBCXXABI_LIBCXX_SRC_DIR ${LLVM_MAIN_SRC_DIR}/projects/libcxx) + set(LIBCXXABI_LIBCXX_SRC_DIR +"${LLVM_MAIN_SRC_DIR}/projects/libcxx" +"${LLVM_MAIN_SRC_DIR}/runtimes/libcxx" +) endif() find_path( @@ -380,6 +383,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_ ${LIBCXXABI_LIBUNWIND_PATH}/include ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES} ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include + ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include NO_DEFAULT_PATH ) @@ -389,6 +393,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_ PATHS ${LIBCXXABI_LIBUNWIND_PATH}/src/ ${LIBCXXABI_LIBUNWIND_INCLUDES}/../src/ ${LLVM_MAIN_SRC_DIR}/projects/libunwind/src/ + ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/src/ NO_DEFAULT_PATH ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS
ikudrin added a comment. The test is too implementation-specific, and trying to override a function like `calloc` makes it fragile. Unfortunately, I didn't find a better way to test the library's behavior in case of memory exhaustion, but now I believe that this test doesn't add any significant value. I'm going to remove it if no one objects. https://reviews.llvm.org/D26150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286331 - [index] Fix issue with protocol name locations in conformance list of an ObjC class when they come from a typedef.
Author: akirtzidis Date: Tue Nov 8 20:47:07 2016 New Revision: 286331 URL: http://llvm.org/viewvc/llvm-project?rev=286331&view=rev Log: [index] Fix issue with protocol name locations in conformance list of an ObjC class when they come from a typedef. The ObjC class protocol list assumes there is an associated location for each protocol but no location is provided when the protocol list comes from a typedef, and we end up with a buffer overflow when trying to get locations for the protocol names. Fixes crash of rdar://28980278. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseObjc.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/test/Index/Core/index-source.m Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=286331&r1=286330&r2=286331&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Nov 8 20:47:07 2016 @@ -7470,6 +7470,7 @@ public: SourceRange SuperTypeArgsRange); void ActOnTypedefedProtocols(SmallVectorImpl &ProtocolRefs, + SmallVectorImpl &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc); Modified: cfe/trunk/lib/Parse/ParseObjc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=286331&r1=286330&r2=286331&view=diff == --- cfe/trunk/lib/Parse/ParseObjc.cpp (original) +++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Nov 8 20:47:07 2016 @@ -369,7 +369,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclar } if (Tok.isNot(tok::less)) -Actions.ActOnTypedefedProtocols(protocols, superClassId, superClassLoc); +Actions.ActOnTypedefedProtocols(protocols, protocolLocs, +superClassId, superClassLoc); Decl *ClsType = Actions.ActOnStartClassInterface(getCurScope(), AtLoc, nameId, nameLoc, Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=286331&r1=286330&r2=286331&view=diff == --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Nov 8 20:47:07 2016 @@ -1028,6 +1028,7 @@ ActOnStartClassInterface(Scope *S, Sourc /// typedef'ed use for a qualified super class and adds them to the list /// of the protocols. void Sema::ActOnTypedefedProtocols(SmallVectorImpl &ProtocolRefs, + SmallVectorImpl &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc) { if (!SuperName) @@ -1040,8 +1041,14 @@ void Sema::ActOnTypedefedProtocols(Small if (const TypedefNameDecl *TDecl = dyn_cast_or_null(IDecl)) { QualType T = TDecl->getUnderlyingType(); if (T->isObjCObjectType()) - if (const ObjCObjectType *OPT = T->getAs()) + if (const ObjCObjectType *OPT = T->getAs()) { ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end()); +// FIXME: Consider whether this should be an invalid loc since the loc +// is not actually pointing to a protocol name reference but to the +// typedef reference. Note that the base class name loc is also pointing +// at the typedef. +ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc); + } } } Modified: cfe/trunk/test/Index/Core/index-source.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=286331&r1=286330&r2=286331&view=diff == --- cfe/trunk/test/Index/Core/index-source.m (original) +++ cfe/trunk/test/Index/Core/index-source.m Tue Nov 8 20:47:07 2016 @@ -129,3 +129,23 @@ extern int setjmp(jmp_buf); // CHECK: [[@LINE+1]]:12 | extension/ObjC | | | | Decl | rel: 0 @interface NonExistent() @end + +@interface MyGenCls : Base +@end + +@protocol MyEnumerating +@end + +// CHECK: [[@LINE+4]]:41 | type-alias/C | MyEnumerator | c:index-source.m@T@MyEnumerator | | Def | rel: 0 +// CHECK: [[@LINE+3]]:26 | protocol/ObjC | MyEnumerating | c:objc(pl)MyEnumerating | | Ref | rel: 0 +// CHECK: [[@LINE+2]]:9 | class/ObjC | MyGenCls | c:objc(cs)MyGenCls | _OBJC_CLASS_$_MyGenCls | Ref | rel: 0 +// CHECK: [[@LINE+1]]:18 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref | rel: 0 +typedef MyGenCls MyEnumerator; + +// CHECK: [[@LINE+5]]:12 | class/ObjC | PermanentEnumerator | c:objc(cs)PermanentEnumerator | _OBJC_CLASS_$_PermanentEnumerator | Decl | rel: 0 +// CHECK: [[@LINE+4]]:34 | class/ObjC | MyGenCls | c:objc(cs)MyGenCls | _OBJC_
[PATCH] D26109: Warn when 'assume_nonnull' infers nullability within an array.
jordan_rose added a dependency: D26108: Add -Wnullability-completeness-on-arrays.. jordan_rose added a comment. Depends on https://reviews.llvm.org/D26108 too, for the tests to apply cleanly. Repository: rL LLVM https://reviews.llvm.org/D26109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26227: Don't require nullability on 'va_list'.
jordan_rose added a dependency: D26108: Add -Wnullability-completeness-on-arrays.. jordan_rose added a comment. Depends on https://reviews.llvm.org/D26108 too (for the tests to apply cleanly). Repository: rL LLVM https://reviews.llvm.org/D26227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26108: Add -Wnullability-completeness-on-arrays.
jordan_rose added a comment. It works fine for me, though note the "depends on https://reviews.llvm.org/D25850";. The other patches in the series do seem to have been thrown off by https://reviews.llvm.org/D26226 landing first, though, so I'll update those. Repository: rL LLVM https://reviews.llvm.org/D26108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
dschuff added a comment. Yeah, I don't mean for this to be the final word; mostly this just matches asm.js. I do agree with you that the unixy stuff goes with the emscripten environment rather than wasm per se. I had thought we might define emscripten as an "OS" (i.e. the third or maybe even 4th part of the triple) in LLVM, because currently it affects not just defines but also things like emscripten exception handling (which we currently use a backend flag for). https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.
dtarditi created this revision. dtarditi added a subscriber: cfe-commits. This changes pointers to cached tokens for default arguments in C++ from raw pointers to unique_ptrs. There was a fixme in the code where the cached tokens are created about using a smart pointer. The change is straightforward, though I did have to track down and fix a memory corruption caused by the change. memcpy was being used to copy parameter information. This duplicated the unique_ptr, which led to the cached token buffer being deleted prematurely. https://reviews.llvm.org/D26435 Files: include/clang/Parse/Parser.h include/clang/Sema/DeclSpec.h lib/Parse/ParseCXXInlineMethods.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/DeclSpec.cpp lib/Sema/SemaDeclCXX.cpp Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -395,17 +395,15 @@ ++argIdx) { ParmVarDecl *Param = cast(chunk.Fun.Params[argIdx].Param); if (Param->hasUnparsedDefaultArg()) { - CachedTokens *Toks = chunk.Fun.Params[argIdx].DefaultArgTokens; + std::unique_ptr Toks = std::move(chunk.Fun.Params[argIdx].DefaultArgTokens); SourceRange SR; if (Toks->size() > 1) SR = SourceRange((*Toks)[1].getLocation(), Toks->back().getLocation()); else SR = UnparsedDefaultArgLocs[Param]; Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc) << SR; - delete Toks; - chunk.Fun.Params[argIdx].DefaultArgTokens = nullptr; } else if (Param->getDefaultArg()) { Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc) << Param->getDefaultArg()->getSourceRange(); Index: lib/Sema/DeclSpec.cpp === --- lib/Sema/DeclSpec.cpp +++ lib/Sema/DeclSpec.cpp @@ -229,7 +229,8 @@ I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams]; I.Fun.DeleteParams = true; } -memcpy(I.Fun.Params, Params, sizeof(Params[0]) * NumParams); +for (unsigned i = 0; i < NumParams; i++) + I.Fun.Params[i] = std::move(Params[i]); } // Check what exception specification information we should actually store. Index: lib/Parse/ParseDeclCXX.cpp === --- lib/Parse/ParseDeclCXX.cpp +++ lib/Parse/ParseDeclCXX.cpp @@ -2039,7 +2039,7 @@ LateMethod->DefaultArgs.reserve(FTI.NumParams); for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument( -FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens)); +FTI.Params[ParamIdx].Param, std::move(FTI.Params[ParamIdx].DefaultArgTokens))); } } Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -6021,7 +6021,7 @@ // DefArgToks is used when the parsing of default arguments needs // to be delayed. -CachedTokens *DefArgToks = nullptr; +std::unique_ptr DefArgToks; // If no parameter was specified, verify that *something* was specified, // otherwise we have a missing type and identifier. @@ -6057,13 +6057,11 @@ // If we're inside a class definition, cache the tokens // corresponding to the default argument. We'll actually parse // them when we see the end of the class definition. - // FIXME: Can we use a smart pointer for Toks? - DefArgToks = new CachedTokens; + DefArgToks.reset(new CachedTokens); SourceLocation ArgStartLoc = NextToken().getLocation(); if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) { -delete DefArgToks; -DefArgToks = nullptr; +DefArgToks.release(); Actions.ActOnParamDefaultArgumentError(Param, EqualLoc); } else { Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc, @@ -6099,7 +6097,7 @@ ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII, ParmDeclarator.getIdentifierLoc(), - Param, DefArgToks)); + Param, std::move(DefArgToks))); } if (TryConsumeToken(tok::ellipsis, EllipsisLoc)) { Index: lib/Parse/ParseCXXInlineMethods.cpp === --- lib/Parse/ParseCXXInlineMethods.cpp +++ lib/Parse/ParseCXXInlineMethods.cpp @@ -319,7 +319,8 @@ // Introduce the parameter into scope. bool HasUnparsed = Param->hasUnparsedDefaultArg(); Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param); -if (CachedT
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
jgravelle-google added a comment. I think you're right, it's the Emscripten embedding that's unixy, therefore Emscripten should be responsible for telling clang to be unixy. To play devil's advocate, it might be advantageous for all compile-to-wasm code to assume a common environment, and unix is a reasonable thing to arbitrarily standardize on. But it's probably more advantageous to not decide that at this level. Double-alternatively it might make sense to have a `wasm32-unknown-emscripten` triple, and let that determine whether we're unixy or not in clang. https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286324 - clang-cl: Pass /Zc:threadSafeInit through to MSVC with /fallback (PR30948)
Author: hans Date: Tue Nov 8 18:56:42 2016 New Revision: 286324 URL: http://llvm.org/viewvc/llvm-project?rev=286324&view=rev Log: clang-cl: Pass /Zc:threadSafeInit through to MSVC with /fallback (PR30948) Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/cl-fallback.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=286324&r1=286323&r2=286324&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Tue Nov 8 18:56:42 2016 @@ -10978,6 +10978,14 @@ std::unique_ptr visualstudio::C options::OPT__SLASH_MT, options::OPT__SLASH_MTd)) A->render(Args, CmdArgs); + // Use MSVC's default threadsafe statics behaviour unless there was a flag. + if (Arg *A = Args.getLastArg(options::OPT_fthreadsafe_statics, + options::OPT_fno_threadsafe_statics)) { +CmdArgs.push_back(A->getOption().getID() == options::OPT_fthreadsafe_statics + ? "/Zc:threadSafeInit" + : "/Zc:threadSafeInit-"); + } + // Pass through all unknown arguments so that the fallback command can see // them too. Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN); Modified: cfe/trunk/test/Driver/cl-fallback.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-fallback.c?rev=286324&r1=286323&r2=286324&view=diff == --- cfe/trunk/test/Driver/cl-fallback.c (original) +++ cfe/trunk/test/Driver/cl-fallback.c Tue Nov 8 18:56:42 2016 @@ -46,6 +46,12 @@ // GS: cl.exe // GS: "/GS-" +// RUN: %clang_cl /fallback /Zc:threadSafeInit -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafe %s +// ThreadSafe: /Zc:threadSafeInit + +// RUN: %clang_cl /fallback /Zc:threadSafeInit- -### -- %s 2>&1 | FileCheck -check-prefix=NonThreadSafe %s +// NonThreadSafe: /Zc:threadSafeInit- + // RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s // O0: cl.exe // O0: "/Od" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26423: [clang-move] Support template class.
hokein updated this revision to Diff 77292. hokein marked 3 inline comments as done. hokein added a comment. Add comments. https://reviews.llvm.org/D26423 Files: clang-move/ClangMove.cpp test/clang-move/Inputs/template_class_test.cpp test/clang-move/Inputs/template_class_test.h test/clang-move/move-template-class.cpp Index: test/clang-move/move-template-class.cpp === --- /dev/null +++ test/clang-move/move-template-class.cpp @@ -0,0 +1,86 @@ +// RUN: mkdir -p %T/move-template-class +// RUN: cp %S/Inputs/template_class_test* %T/move-template-class +// RUN: cd %T/move-template-class +// RUN: clang-move -names="A,B" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp -- +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE1 %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s +// +// RUN: cp %S/Inputs/template_class_test* %T/move-template-class +// RUN: clang-move -names="A" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp -- +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-H-CASE2 %s +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP-CASE2 %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE2 %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE2 %s +// +// +// CHECK-OLD-TEST-EMPTY: {{^}}{{$}} +// +// CHECK-NEW-TEST-H-CASE1: #ifndef TEMPLATE_CLASS_TEST_H // comment 1 +// CHECK-NEW-TEST-H-CASE1: #define TEMPLATE_CLASS_TEST_H +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: class A { +// CHECK-NEW-TEST-H-CASE1: public: +// CHECK-NEW-TEST-H-CASE1: void f(); +// CHECK-NEW-TEST-H-CASE1: void g(); +// CHECK-NEW-TEST-H-CASE1: template void h(); +// CHECK-NEW-TEST-H-CASE1: template void k(); +// CHECK-NEW-TEST-H-CASE1: static int b; +// CHECK-NEW-TEST-H-CASE1: static int c; +// CHECK-NEW-TEST-H-CASE1: }; +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: void A::f() {} +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: void A::h() {} +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: int A::b = 2; +// CHECK-NEW-TEST-H-CASE1: class B { +// CHECK-NEW-TEST-H-CASE1: public: +// CHECK-NEW-TEST-H-CASE1: void f(); +// CHECK-NEW-TEST-H-CASE1: }; +// CHECK-NEW-TEST-H-CASE1: #endif // TEMPLATE_CLASS_TEST_H +// +// CHECK-NEW-TEST-CPP-CASE1: #include "{{.*}}new_template_class_test.h" +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: void A::g() {} +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: void A::k() {} +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: int A::c = 2; +// CHECK-NEW-TEST-CPP-CASE1: void B::f() {} +// +// CHECK-OLD-TEST-H-CASE2: #ifndef TEMPLATE_CLASS_TEST_H // comment 1 +// CHECK-OLD-TEST-H-CASE2: #define TEMPLATE_CLASS_TEST_H +// CHECK-OLD-TEST-H-CASE2: class B { +// CHECK-OLD-TEST-H-CASE2: public: +// CHECK-OLD-TEST-H-CASE2: void f(); +// CHECK-OLD-TEST-H-CASE2: }; +// CHECK-OLD-TEST-H-CASE2: #endif // TEMPLATE_CLASS_TEST_H +// +// CHECK-OLD-TEST-CPP-CASE2: #include "template_class_test.h" +// CHECK-OLD-TEST-CPP-CASE2: void B::f() {} +// +// CHECK-NEW-TEST-H-CASE2: #ifndef {{.*}}NEW_TEMPLATE_CLASS_TEST_H +// CHECK-NEW-TEST-H-CASE2: #define {{.*}}NEW_TEMPLATE_CLASS_TEST_H +// CHECK-NEW-TEST-H-CASE2: template +// CHECK-NEW-TEST-H-CASE2: class A { +// CHECK-NEW-TEST-H-CASE2: public: +// CHECK-NEW-TEST-H-CASE2: void f(); +// CHECK-NEW-TEST-H-CASE2: void g(); +// CHECK-NEW-TEST-H-CASE2: template void h(); +// CHECK-NEW-TEST-H-CASE2: template void k(); +// CHECK-NEW-TEST-H-CASE2: static int b; +// CHECK-NEW-TEST-H-CASE2: static int c; +// CHECK-NEW-TEST-H-CASE2: }; +// CHECK-NEW-TEST-H-CASE2: template void A::f() {} +// CHECK-NEW-TEST-H-CASE2: template template void A::h() {} +// CHECK-NEW-TEST-H-CASE2: template int A
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
sunfish added a comment. The other main way we could provide __unix et al would be to add them to tools/shared.py in Emscripten (see the comment "wasm target does not automatically define emscripten stuff"). It's not clear to me whether that's better than adding the macros to clang itself or not. Currently Unixy-like functionality is provided by Emscripten facilities, and one could think of (hypothetical future) non-Emscripten clang as targeting more of the bare metal of WebAssembly which isn't inherently Unixy. Thoughts? However, I'm also open to just adding it to clang for now and re-evaluating later, which we can do since we don't yet have a stable ABI. https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286322 - Emit debug info for global constants whose address is taken exactly once.
Author: adrian Date: Tue Nov 8 18:42:03 2016 New Revision: 286322 URL: http://llvm.org/viewvc/llvm-project?rev=286322&view=rev Log: Emit debug info for global constants whose address is taken exactly once. Add a check to the DeclCache before emitting debug info for a GlobalVariable a second time and just attach the previsously created one to it. Added: cfe/trunk/test/CodeGen/debug-info-global-constant.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=286322&r1=286321&r2=286322&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Nov 8 18:42:03 2016 @@ -3675,6 +3675,13 @@ void CGDebugInfo::EmitGlobalVariable(llv assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (D->hasAttr()) return; + + // If we already created a DIGlobalVariable for this declaration, just attach + // it to the llvm::GlobalVariable. + auto Cached = DeclCache.find(D->getCanonicalDecl()); + if (Cached != DeclCache.end()) +return Var->addDebugInfo(cast(Cached->second)); + // Create global variable debug descriptor. llvm::DIFile *Unit = nullptr; llvm::DIScope *DContext = nullptr; Added: cfe/trunk/test/CodeGen/debug-info-global-constant.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-global-constant.c?rev=286322&view=auto == --- cfe/trunk/test/CodeGen/debug-info-global-constant.c (added) +++ cfe/trunk/test/CodeGen/debug-info-global-constant.c Tue Nov 8 18:42:03 2016 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone \ +// RUN: -triple %itanium_abi_triple %s -o - | FileCheck %s + +// Debug info for a global constant whose address is taken should be emitted +// exactly once. + +// CHECK: @i = internal constant i32 1, align 4, !dbg ![[I:[0-9]+]] +// CHECK: ![[I]] = distinct !DIGlobalVariable(name: "i", +// CHECK-SAME:expr: ![[EXPR:[0-9]+]] +// CHECK: !DICompileUnit({{.*}}globals: ![[GLOBALS:[0-9]+]]) +// CHECK: ![[GLOBALS]] = !{![[I]]} +// CHECK: ![[EXPR]] = !DIExpression(DW_OP_constu, 1, DW_OP_stack_value) +static const int i = 1; + +void g(const int *, int); +void f() { + g(&i, i); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26071: [CodeCompletion] Show block invocation result for block property setters
manmanren accepted this revision. manmanren added a comment. This revision is now accepted and ready to land. LGTM. Manman Repository: rL LLVM https://reviews.llvm.org/D26071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
jgravelle-google added a comment. For the emscripten testsuite, specifically test_zlib relies on `#ifdef __unix__` to `#include `, which it needs. The rest of the unistd tests don't actually care. So we could make that test pass by explicitly adding a define for __unix__ for it, but I figure it would be better to have things as similar as possible between wasm and asmjs. https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files
alexfh added a comment. I also don't understand the use case for turning off only some checks for third-party headers. Either you care about third-party stuff or not, why only switch off certain checks? https://reviews.llvm.org/D26418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files
alexfh added a comment. What's the biggest complexity with -header-filter? Lack of way to specify ? Will it help to make -header-filter a GlobList? https://reviews.llvm.org/D26418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
sunfish added a comment. When adding new predefined macros, please also add the new macros to test/Preprocessor/init.c (and remove negative tests that no longer apply). Also though, I'd also like to understand this a little more. Even with emulation, there will be limits to how Unixy a Web environment could be (though a non-Web environment could potentially do more). Which tests start passing with this? https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
dschuff accepted this revision. dschuff added a comment. This revision is now accepted and ready to land. Also it matches asm.js @sunfish is planning on unifying the triples, and this will be part of that (and there may be more defines that we want to add and/or subtract), but for now it makes more of the emscripten test suite pass, so LGTM https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26423: [clang-move] Support template class.
ioeric added a comment. Nice! First round of comments. Comment at: clang-move/ClangMove.cpp:414 RemovedDecls.push_back(MovedDecls.back()); + if (const auto *FTD = CMD->getDescribedFunctionTemplate()) { +UnremovedDeclsInOldHeader.erase(FTD); Some comments here would be appreciated. Also nit: no braces. Comment at: clang-move/ClangMove.cpp:427 Result.Nodes.getNodeAs("moved_class")) { -MovedDecls.emplace_back(class_decl, &Result.Context->getSourceManager()); +if (const auto * TC = CD->getDescribedClassTemplate()) { + MovedDecls.emplace_back(TC, &Result.Context->getSourceManager()); Same as above. Comments and braces. Comment at: test/clang-move/move-template-class.cpp:20 +// +// CHECK-NEW-TEST-H-CASE1: #ifndef TEMPLATE_CLASS_TEST_H // comment 1 +// CHECK-NEW-TEST-H-CASE1: #define TEMPLATE_CLASS_TEST_H Not directly related, but we might want to start thinking about appropriate code formatting like spaces between decls. Code jamming together is not pretty... https://reviews.llvm.org/D26423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
jgravelle-google created this revision. jgravelle-google added reviewers: dschuff, sunfish. jgravelle-google added a subscriber: cfe-commits. Herald added a subscriber: jfb. Unix is a convenient common denominator for embeddings to implement syscalls for. This makes it explicit that wasm is unix-y https://reviews.llvm.org/D26431 Files: lib/Basic/Targets.cpp Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -856,6 +856,8 @@ // Follow g++ convention and predefine _GNU_SOURCE for C++. if (Opts.CPlusPlus) Builder.defineMacro("_GNU_SOURCE"); + +DefineStd(Builder, "unix", Opts); } // As an optimization, group static init code together in a section. Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -856,6 +856,8 @@ // Follow g++ convention and predefine _GNU_SOURCE for C++. if (Opts.CPlusPlus) Builder.defineMacro("_GNU_SOURCE"); + +DefineStd(Builder, "unix", Opts); } // As an optimization, group static init code together in a section. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286313 - [CUDA] Use only the GVALinkage on function definitions.
Author: jlebar Date: Tue Nov 8 17:45:51 2016 New Revision: 286313 URL: http://llvm.org/viewvc/llvm-project?rev=286313&view=rev Log: [CUDA] Use only the GVALinkage on function definitions. Summary: Previously we'd look at the GVALinkage of whatever FunctionDecl you happened to be calling. This is not right. In the absence of the gnu_inline attribute, to be handled separately, the function definition determines the function's linkage. So we need to wait until we get a def before we can know whether something is known-emitted. Reviewers: tra Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D26268 Added: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=286313&r1=286312&r2=286313&view=diff == --- cfe/trunk/lib/Sema/SemaCUDA.cpp (original) +++ cfe/trunk/lib/Sema/SemaCUDA.cpp Tue Nov 8 17:45:51 2016 @@ -577,8 +577,22 @@ static bool IsKnownEmitted(Sema &S, Func (T == Sema::CFT_Device || T == Sema::CFT_Global)) return false; - // Externally-visible and similar functions are always emitted. - if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD))) + // Check whether this function is externally visible -- if so, it's + // known-emitted. + // + // We have to check the GVA linkage of the function's *definition* -- if we + // only have a declaration, we don't know whether or not the function will be + // emitted, because (say) the definition could include "inline". + FunctionDecl *Def = FD->getDefinition(); + + // We may currently be parsing the body of FD, in which case + // FD->getDefinition() will be null, but we still want to treat FD as though + // it's a definition. + if (!Def && FD->willHaveBody()) +Def = FD; + + if (Def && + !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def))) return true; // Otherwise, the function is known-emitted if it's in our set of Added: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu?rev=286313&view=auto == --- cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu (added) +++ cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu Tue Nov 8 17:45:51 2016 @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +#include "Inputs/cuda.h" + +#ifndef __CUDA_ARCH__ +// expected-no-diagnostics +#endif + +// When compiling for device, foo()'s call to host_fn() is an error, because +// foo() is known-emitted. +// +// The trickiness here comes from the fact that the FunctionDecl bar() sees +// foo() does not have the "inline" keyword, so we might incorrectly think that +// foo() is a priori known-emitted. This would prevent us from marking foo() +// as known-emitted when we see the call from bar() to foo(), which would +// prevent us from emitting an error for foo()'s call to host_fn() when we +// eventually see it. + +void host_fn() {} +#ifdef __CUDA_ARCH__ + // expected-note@-2 {{declared here}} +#endif + +__host__ __device__ void foo(); +__device__ void bar() { + foo(); +#ifdef __CUDA_ARCH__ + // expected-note@-2 {{called by 'bar'}} +#endif +} +inline __host__ __device__ void foo() { + host_fn(); +#ifdef __CUDA_ARCH__ + // expected-error@-2 {{reference to __host__ function}} +#endif +} + +// This is similar to the above, except there's no error here. This code used +// to trip an assertion due to us noticing, when emitting the definition of +// boom(), that T::operator S() was (incorrectly) considered a priori +// known-emitted. +struct S {}; +struct T { + __device__ operator S() const; +}; +__device__ inline T::operator S() const { return S(); } + +__device__ T t; +__device__ void boom() { + S s = t; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.
This revision was automatically updated to reflect the committed changes. jlebar marked 2 inline comments as done. Closed by commit rL286313: [CUDA] Use only the GVALinkage on function definitions. (authored by jlebar). Changed prior to commit: https://reviews.llvm.org/D26268?vs=76808&id=77280#toc Repository: rL LLVM https://reviews.llvm.org/D26268 Files: cfe/trunk/lib/Sema/SemaCUDA.cpp cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu Index: cfe/trunk/lib/Sema/SemaCUDA.cpp === --- cfe/trunk/lib/Sema/SemaCUDA.cpp +++ cfe/trunk/lib/Sema/SemaCUDA.cpp @@ -577,8 +577,22 @@ (T == Sema::CFT_Device || T == Sema::CFT_Global)) return false; - // Externally-visible and similar functions are always emitted. - if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD))) + // Check whether this function is externally visible -- if so, it's + // known-emitted. + // + // We have to check the GVA linkage of the function's *definition* -- if we + // only have a declaration, we don't know whether or not the function will be + // emitted, because (say) the definition could include "inline". + FunctionDecl *Def = FD->getDefinition(); + + // We may currently be parsing the body of FD, in which case + // FD->getDefinition() will be null, but we still want to treat FD as though + // it's a definition. + if (!Def && FD->willHaveBody()) +Def = FD; + + if (Def && + !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def))) return true; // Otherwise, the function is known-emitted if it's in our set of Index: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu === --- cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu +++ cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +#include "Inputs/cuda.h" + +#ifndef __CUDA_ARCH__ +// expected-no-diagnostics +#endif + +// When compiling for device, foo()'s call to host_fn() is an error, because +// foo() is known-emitted. +// +// The trickiness here comes from the fact that the FunctionDecl bar() sees +// foo() does not have the "inline" keyword, so we might incorrectly think that +// foo() is a priori known-emitted. This would prevent us from marking foo() +// as known-emitted when we see the call from bar() to foo(), which would +// prevent us from emitting an error for foo()'s call to host_fn() when we +// eventually see it. + +void host_fn() {} +#ifdef __CUDA_ARCH__ + // expected-note@-2 {{declared here}} +#endif + +__host__ __device__ void foo(); +__device__ void bar() { + foo(); +#ifdef __CUDA_ARCH__ + // expected-note@-2 {{called by 'bar'}} +#endif +} +inline __host__ __device__ void foo() { + host_fn(); +#ifdef __CUDA_ARCH__ + // expected-error@-2 {{reference to __host__ function}} +#endif +} + +// This is similar to the above, except there's no error here. This code used +// to trip an assertion due to us noticing, when emitting the definition of +// boom(), that T::operator S() was (incorrectly) considered a priori +// known-emitted. +struct S {}; +struct T { + __device__ operator S() const; +}; +__device__ inline T::operator S() const { return S(); } + +__device__ T t; +__device__ void boom() { + S s = t; +} Index: cfe/trunk/lib/Sema/SemaCUDA.cpp === --- cfe/trunk/lib/Sema/SemaCUDA.cpp +++ cfe/trunk/lib/Sema/SemaCUDA.cpp @@ -577,8 +577,22 @@ (T == Sema::CFT_Device || T == Sema::CFT_Global)) return false; - // Externally-visible and similar functions are always emitted. - if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD))) + // Check whether this function is externally visible -- if so, it's + // known-emitted. + // + // We have to check the GVA linkage of the function's *definition* -- if we + // only have a declaration, we don't know whether or not the function will be + // emitted, because (say) the definition could include "inline". + FunctionDecl *Def = FD->getDefinition(); + + // We may currently be parsing the body of FD, in which case + // FD->getDefinition() will be null, but we still want to treat FD as though + // it's a definition. + if (!Def && FD->willHaveBody()) +Def = FD; + + if (Def && + !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def))) return true; // Otherwise, the function is known-emitted if it's in our set of Index: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu === --- cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu +++ cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -
[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.
jlebar marked 2 inline comments as done. jlebar added a comment. Thank you for the review! Submitting... Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:13-14 +// +// The trickiness here comes from the fact that the FunctionDecl bar() sees for +// foo() does not have the "inline" keyword, so we might incorrectly think that +// foo() is a priori known-emitted. This would prevent us from marking foo() tra wrote: > "bar() sees for foo()" does not sound right. Did you mean "bar() sees *that* > foo()"? Yes, this is a mistake, thanks! Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:15 +// foo() does not have the "inline" keyword, so we might incorrectly think that +// foo() is a priori known-emitted. This would prevent us from marking foo() +// as known-emitted, which would prevent us from emitting an error for foo()'s tra wrote: > Extra whitespace. We seem to be pretty evenly-split wrt one or two spaces here in llvm, agreed irl it's nbd. https://reviews.llvm.org/D26268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel
khazem updated this revision to Diff 77277. khazem added a comment. If a double-lock or double-release is detected, path notes are now emitted on the _first_ lock or release event. Also updated the tests to check for these notes. https://reviews.llvm.org/D26340 Files: include/clang/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp test/Analysis/spinlock_correct.c test/Analysis/spinlock_double_lock.c test/Analysis/spinlock_double_release.c Index: test/Analysis/spinlock_double_release.c === --- /dev/null +++ test/Analysis/spinlock_double_release.c @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -analyze -analyzer-output=text -analyzer-checker=magenta.SpinLock -verify %s + +typedef unsigned int lock_t; + +typedef struct S { + int a; + lock_t l; +} S_t; + +static S_t st; + +void spin_lock(lock_t *lock); +void spin_unlock(lock_t *lock); +int bar(); + +void bar1(lock_t *y) { + spin_unlock(y); // expected-note {{First unlocked here}} +} + +void bar2(lock_t *x) { + spin_unlock(x); // expected-warning{{Execution path found where spinlock is unlocked twice in a row}} + // expected-note@-1 0+ {{Execution path found where spinlock is unlocked twice in a row}} +} + +int foo() { + int a = bar(); + if (a > 0) { // expected-note {{Assuming 'a' is > 0}} \ +// expected-note {{Taking true branch}} +spin_lock(&st.l); +bar1(&st.l); // expected-note {{Calling 'bar1'}} \ +expected-note {{Returning from 'bar1'}} + } + + lock_t *c = &st.l; + bar2(c); // expected-note {{Calling 'bar2'}} + return 0; +} + Index: test/Analysis/spinlock_double_lock.c === --- /dev/null +++ test/Analysis/spinlock_double_lock.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -analyzer-output=text -verify %s + +typedef unsigned int lock_t; + +static lock_t l; + +void spin_lock(lock_t *lock); +void spin_unlock(lock_t *lock); +int bar(); + +int foo() { + int a = bar(); + if (a > 0) // expected-note{{Assuming 'a' is > 0}} \ +expected-note{{Taking true branch}} + +spin_lock(&l); // expected-note{{First locked here}} + if (a > 10) // expected-note{{Assuming 'a' is > 10}} \ + expected-note{{Taking true branch}} + +spin_lock(&l); // expected-warning{{Execution path found where spinlock is locked twice in a row}} +// expected-note@-1 0+ {{Execution path found where spinlock is locked twice in a row}} + + + return 0; +} + Index: test/Analysis/spinlock_correct.c === --- /dev/null +++ test/Analysis/spinlock_correct.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s +// expected-no-diagnostics + +typedef unsigned int lock_t; + +static lock_t l; + +void spin_lock(lock_t *lock); +void spin_unlock(lock_t *lock); +int bar(); + +int foo() { + int a = bar(); + if (a > 0) { +spin_lock(&l); + } + + if (a < -10) { +spin_lock(&l); + } + + if (a > 0) +spin_unlock(&l); + + if (a < -10) +spin_unlock(&l); + + return 0; +} + Index: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp === --- /dev/null +++ lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp @@ -0,0 +1,262 @@ +//== SpinLockChecker.cpp - SpinLock checker -*- C++ -*--==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This defines SpinLockChecker, a check for the Magenta kernel. It +// checks that there are no execution paths where spinlocks are locked +// twice in a row, or unlocked twice in a row. +// +//===--===// + +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "llvm/ADT/SmallString.h" + +using namespace clang; +using namespace ento; + +namespace { + +struct LockInfo { + + enum Kind { Locked, Released } K; + + LockInfo(Kind kind) : K(kind) {} + + bool operator==(const LockInfo &LI) const { return K == LI.K; } + + void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(K); } + + bool isLocked() const { return K == Locked; } + + bool isReleased() const { return K == Released; } + + static LockInfo getLocked() { return LockInfo(Locked); } + + static LockInfo getReleased() { return LockInfo(Released); } + +}; + +// When we detect a doub
[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.
tra accepted this revision. tra added a comment. This revision is now accepted and ready to land. LGTM. Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:13-14 +// +// The trickiness here comes from the fact that the FunctionDecl bar() sees for +// foo() does not have the "inline" keyword, so we might incorrectly think that +// foo() is a priori known-emitted. This would prevent us from marking foo() "bar() sees for foo()" does not sound right. Did you mean "bar() sees *that* foo()"? Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:15 +// foo() does not have the "inline" keyword, so we might incorrectly think that +// foo() is a priori known-emitted. This would prevent us from marking foo() +// as known-emitted, which would prevent us from emitting an error for foo()'s Extra whitespace. https://reviews.llvm.org/D26268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel
khazem updated this revision to Diff 77275. khazem added a comment. The strings for Spin{Unl,L}ockFuncName and LockErrorCategory are now initialized when constructing a SpinLockChecker object rather than being static globals, in order to avoid adverse effects on startup time. Also, the Spin*FuncName variables are now of type CallDescription. This is to enable pointer rather than string comparisons of the function name. https://reviews.llvm.org/D26340 Files: include/clang/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp test/Analysis/spinlock_correct.c test/Analysis/spinlock_double_lock.c test/Analysis/spinlock_double_release.c Index: test/Analysis/spinlock_double_release.c === --- /dev/null +++ test/Analysis/spinlock_double_release.c @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s + +typedef unsigned int lock_t; + +typedef struct S { + int a; + lock_t l; +} S_t; + +static S_t st; + +void spin_lock(lock_t *lock); +void spin_unlock(lock_t *lock); +int bar(); + +void bar1(lock_t *y) { + spin_unlock(y); +} + +void bar2(lock_t *x) { + spin_unlock(x); // expected-warning{{Execution path found where spinlock is unlocked twice in a row}} +} + +int foo() { + int a = bar(); + if (a > 0) { +spin_lock(&st.l); +bar1(&st.l); + } + + lock_t *c = &st.l; + bar2(c); + return 0; +} + Index: test/Analysis/spinlock_double_lock.c === --- /dev/null +++ test/Analysis/spinlock_double_lock.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s + +typedef unsigned int lock_t; + +static lock_t l; + +void spin_lock(lock_t *lock); +void spin_unlock(lock_t *lock); +int bar(); + +int foo() { + int a = bar(); + if (a > 0) +spin_lock(&l); + if (a > 10) +spin_lock(&l); // expected-warning{{Execution path found where spinlock is locked twice in a row}} + + return 0; +} + Index: test/Analysis/spinlock_correct.c === --- /dev/null +++ test/Analysis/spinlock_correct.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s +// expected-no-diagnostics + +typedef unsigned int lock_t; + +static lock_t l; + +void spin_lock(lock_t *lock); +void spin_unlock(lock_t *lock); +int bar(); + +int foo() { + int a = bar(); + if (a > 0) { +spin_lock(&l); + } + + if (a < -10) { +spin_lock(&l); + } + + if (a > 0) +spin_unlock(&l); + + if (a < -10) +spin_unlock(&l); + + return 0; +} + Index: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp === --- /dev/null +++ lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp @@ -0,0 +1,187 @@ +//== SpinLockChecker.cpp - SpinLock checker -*- C++ -*--==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This defines SpinLockChecker, a check for the Magenta kernel. It +// checks that there are no execution paths where spinlocks are locked +// twice in a row, or unlocked twice in a row. +// +//===--===// + +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "llvm/ADT/SmallString.h" + +using namespace clang; +using namespace ento; + +namespace { + +struct LockInfo { + + enum Kind { Locked, Released } K; + + LockInfo(Kind kind) : K(kind) {} + + bool operator==(const LockInfo &LI) const { return K == LI.K; } + + void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(K); } + + bool isLocked() const { return K == Locked; } + + bool isReleased() const { return K == Released; } + + static LockInfo getLocked() { return LockInfo(Locked); } + + static LockInfo getReleased() { return LockInfo(Released); } + +}; + +} + +/// We keep track of the locks in a map. SpinLockMap maps the +/// memory region of a spinlock to its status (locked, released). +/// The reason that we keep track of spinlocks as memory region is +/// that the lock/unlock functions take lock arguments as pointers. +REGISTER_MAP_WITH_PROGRAMSTATE(SpinLockMap, const MemRegion *, LockInfo) + +namespace { + +class SpinLockChecker : public Checker { + + /// When facing a spin_unlock function call, check the record of the + /// corresponding lock in SpinLockMap and make sure that there are no + /// problems su
[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel
khazem added a comment. Good to meet you too, thanks for the useful comments and pointers to helpful examples! I'm going to update the diff twice: the first one to address your first two comments, and the second one to address your last two. https://reviews.llvm.org/D26340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.
hfinkel added a comment. In https://reviews.llvm.org/D25403#590049, @jlebar wrote: > Use TEST_STD_VER macro. This is fine with me; @EricWF , @mclow.lists ? https://reviews.llvm.org/D25403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r286308 - [CMake] Get libunwind building under LLVM/runtimes
Author: phosek Date: Tue Nov 8 17:02:49 2016 New Revision: 286308 URL: http://llvm.org/viewvc/llvm-project?rev=286308&view=rev Log: [CMake] Get libunwind building under LLVM/runtimes The new LLVM runtimes directory requires the same conventions to be followed across the runtime projects. These changes make libunwind build under the runtimes subdirectory. This patch contains the following changes: * Rename LLVM_CONFIG to LLVM_CONFIG_PATH * Check if compiler supports C++11 (required by libunwind) Differential Revision: https://reviews.llvm.org/D26360 Modified: libunwind/trunk/CMakeLists.txt libunwind/trunk/cmake/config-ix.cmake Modified: libunwind/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=286308&r1=286307&r2=286308&view=diff == --- libunwind/trunk/CMakeLists.txt (original) +++ libunwind/trunk/CMakeLists.txt Tue Nov 8 17:02:49 2016 @@ -13,15 +13,17 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR # Rely on llvm-config. set(CONFIG_OUTPUT) - find_program(LLVM_CONFIG "llvm-config") + if(NOT LLVM_CONFIG_PATH) +find_program(LLVM_CONFIG_PATH "llvm-config") + endif() if (DEFINED LLVM_PATH) set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree") set(LLVM_MAIN_SRC_DIR ${LLVM_PATH}) set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules") - elseif (LLVM_CONFIG) -message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") -set(CONFIG_COMMAND ${LLVM_CONFIG} "--includedir" "--prefix" "--src-root") + elseif(LLVM_CONFIG_PATH) +message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}") +set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} "--includedir" "--prefix" "--src-root") execute_process(COMMAND ${CONFIG_COMMAND} RESULT_VARIABLE HAD_ERROR OUTPUT_VARIABLE CONFIG_OUTPUT) Modified: libunwind/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=286308&r1=286307&r2=286308&view=diff == --- libunwind/trunk/cmake/config-ix.cmake (original) +++ libunwind/trunk/cmake/config-ix.cmake Tue Nov 8 17:02:49 2016 @@ -38,6 +38,11 @@ check_cxx_compiler_flag(/EHsc check_cxx_compiler_flag(/EHs- LIBUNWIND_HAS_NO_EHS_FLAG) check_cxx_compiler_flag(/EHa- LIBUNWIND_HAS_NO_EHA_FLAG) check_cxx_compiler_flag(/GR- LIBUNWIND_HAS_NO_GR_FLAG) +check_cxx_compiler_flag(-std=c++11LIBUNWIND_HAS_STD_CXX11) + +if(LIBUNWIND_HAS_STD_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +endif() check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB) check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.
jlebar added a comment. Friendly ping https://reviews.llvm.org/D26268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26415: [XRay] Support AArch64 in Clang
dberris added inline comments. Comment at: lib/Driver/Tools.cpp:4903-4906 if (Triple.getOS() == llvm::Triple::Linux && (Triple.getArch() == llvm::Triple::arm || - Triple.getArch() == llvm::Triple::x86_64)) { + Triple.getArch() == llvm::Triple::x86_64 || + Triple.getArch() == llvm::Triple::aarch64)) { I'm wondering whether it's worth turning this into a `switch` statement now that we have more than two supported architectures? https://reviews.llvm.org/D26415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286307: [change-namespace] shorten namespace qualifier based on UsingDecl and… (authored by ioeric). Changed prior to commit: https://reviews.llvm.org/D25771?vs=77270&id=77272#toc Repository: rL LLVM https://reviews.llvm.org/D25771 Files: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp clang-tools-extra/trunk/change-namespace/ChangeNamespace.h clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h === --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h @@ -67,8 +67,8 @@ void replaceQualifiedSymbolInDeclContext( const ast_matchers::MatchFinder::MatchResult &Result, - const Decl *DeclContext, SourceLocation Start, SourceLocation End, - llvm::StringRef DeclName); + const DeclContext *DeclContext, SourceLocation Start, SourceLocation End, + const NamedDecl *FromDecl); void fixTypeLoc(const ast_matchers::MatchFinder::MatchResult &Result, SourceLocation Start, SourceLocation End, TypeLoc Type); @@ -139,6 +139,12 @@ // will be done after removing the code from the old namespace and before // inserting it to the new namespace. std::map> InsertFwdDecls; + // Records all using declarations, which can be used to shorten namespace + // specifiers. + llvm::SmallPtrSet UsingDecls; + // Records all using namespace declarations, which can be used to shorten + // namespace specifiers. + llvm::SmallPtrSet UsingNamespaceDecls; }; } // namespace change_namespace Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp === --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp @@ -189,10 +189,8 @@ llvm::StringRef NsName) { DeclName = DeclName.ltrim(':'); NsName = NsName.ltrim(':'); - // If `DeclName` is a global variable, we prepend "::" to it if it is not in - // the global namespace. if (DeclName.find(':') == llvm::StringRef::npos) -return NsName.empty() ? DeclName.str() : ("::" + DeclName).str(); +return DeclName; while (!DeclName.consume_front((NsName + "::").str())) { const auto Pos = NsName.find_last_of(':'); @@ -219,6 +217,26 @@ return Code; } +// Returns true if \p D is a nested DeclContext in \p Context +bool isNestedDeclContext(const DeclContext *D, const DeclContext *Context) { + while (D) { +if (D == Context) + return true; +D = D->getParent(); + } + return false; +} + +// Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx. +bool isDeclVisibleAtLocation(const SourceManager &SM, const Decl *D, + const DeclContext *DeclCtx, SourceLocation Loc) { + SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation()); + Loc = SM.getSpellingLoc(Loc); + return SM.isBeforeInTranslationUnit(DeclLoc, Loc) && + (SM.getFileID(DeclLoc) == SM.getFileID(Loc) && + isNestedDeclContext(DeclCtx, D->getDeclContext())); +} + } // anonymous namespace ChangeNamespaceTool::ChangeNamespaceTool( @@ -244,17 +262,40 @@ } void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { - // Match old namespace blocks. std::string FullOldNs = "::" + OldNamespace; + // Prefix is the outer-most namespace in DiffOldNamespace. For example, if the + // OldNamespace is "a::b::c" and DiffOldNamespace is "b::c", then Prefix will + // be "a::b". Declarations in this namespace will not be visible in the new + // namespace. If DiffOldNamespace is empty, Prefix will be a invalid name "-". + llvm::SmallVector DiffOldNsSplitted; + llvm::StringRef(DiffOldNamespace).split(DiffOldNsSplitted, "::"); + std::string Prefix = "-"; + if (!DiffOldNsSplitted.empty()) +Prefix = (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) + + DiffOldNsSplitted.front()) + .str(); + auto IsInMovedNs = + allOf(hasAncestor(namespaceDecl(hasName(FullOldNs)).bind("ns_decl")), +isExpansionInFileMatching(FilePattern)); + auto IsVisibleInNewNs = anyOf( + IsInMovedNs, unless(hasAncestor(namespaceDecl(hasName(Prefix); + // Match using declarations. + Finder->addMatcher( + usingDecl(isExpansionInFileMatching(FilePattern), IsVisibleInNewNs) + .bind("using"), + this); + // Match using namespace declarations. + Finder->addMatcher(usingDirectiveDecl(isExpansionInFileMatching(FilePattern), +IsVisibleInNewNs) + .bind("using_namespace"), + this); + + // Match old namespace bl
[clang-tools-extra] r286307 - [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
Author: ioeric Date: Tue Nov 8 16:44:17 2016 New Revision: 286307 URL: http://llvm.org/viewvc/llvm-project?rev=286307&view=rev Log: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl. Summary: when replacing symbol references in moved namespaces, trying to make the replace name as short as possible by considering UsingDecl (i.e. UsingShadow) and UsingDirectiveDecl (i.e. using namespace decl). Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25771 Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp clang-tools-extra/trunk/change-namespace/ChangeNamespace.h clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=286307&r1=286306&r2=286307&view=diff == --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original) +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Tue Nov 8 16:44:17 2016 @@ -189,10 +189,8 @@ std::string getShortestQualifiedNameInNa llvm::StringRef NsName) { DeclName = DeclName.ltrim(':'); NsName = NsName.ltrim(':'); - // If `DeclName` is a global variable, we prepend "::" to it if it is not in - // the global namespace. if (DeclName.find(':') == llvm::StringRef::npos) -return NsName.empty() ? DeclName.str() : ("::" + DeclName).str(); +return DeclName; while (!DeclName.consume_front((NsName + "::").str())) { const auto Pos = NsName.find_last_of(':'); @@ -219,6 +217,26 @@ std::string wrapCodeInNamespace(StringRe return Code; } +// Returns true if \p D is a nested DeclContext in \p Context +bool isNestedDeclContext(const DeclContext *D, const DeclContext *Context) { + while (D) { +if (D == Context) + return true; +D = D->getParent(); + } + return false; +} + +// Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx. +bool isDeclVisibleAtLocation(const SourceManager &SM, const Decl *D, + const DeclContext *DeclCtx, SourceLocation Loc) { + SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation()); + Loc = SM.getSpellingLoc(Loc); + return SM.isBeforeInTranslationUnit(DeclLoc, Loc) && + (SM.getFileID(DeclLoc) == SM.getFileID(Loc) && + isNestedDeclContext(DeclCtx, D->getDeclContext())); +} + } // anonymous namespace ChangeNamespaceTool::ChangeNamespaceTool( @@ -244,17 +262,40 @@ ChangeNamespaceTool::ChangeNamespaceTool } void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { - // Match old namespace blocks. std::string FullOldNs = "::" + OldNamespace; + // Prefix is the outer-most namespace in DiffOldNamespace. For example, if the + // OldNamespace is "a::b::c" and DiffOldNamespace is "b::c", then Prefix will + // be "a::b". Declarations in this namespace will not be visible in the new + // namespace. If DiffOldNamespace is empty, Prefix will be a invalid name "-". + llvm::SmallVector DiffOldNsSplitted; + llvm::StringRef(DiffOldNamespace).split(DiffOldNsSplitted, "::"); + std::string Prefix = "-"; + if (!DiffOldNsSplitted.empty()) +Prefix = (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) + + DiffOldNsSplitted.front()) + .str(); + auto IsInMovedNs = + allOf(hasAncestor(namespaceDecl(hasName(FullOldNs)).bind("ns_decl")), +isExpansionInFileMatching(FilePattern)); + auto IsVisibleInNewNs = anyOf( + IsInMovedNs, unless(hasAncestor(namespaceDecl(hasName(Prefix); + // Match using declarations. + Finder->addMatcher( + usingDecl(isExpansionInFileMatching(FilePattern), IsVisibleInNewNs) + .bind("using"), + this); + // Match using namespace declarations. + Finder->addMatcher(usingDirectiveDecl(isExpansionInFileMatching(FilePattern), +IsVisibleInNewNs) + .bind("using_namespace"), + this); + + // Match old namespace blocks. Finder->addMatcher( namespaceDecl(hasName(FullOldNs), isExpansionInFileMatching(FilePattern)) .bind("old_ns"), this); - auto IsInMovedNs = - allOf(hasAncestor(namespaceDecl(hasName(FullOldNs)).bind("ns_decl")), -isExpansionInFileMatching(FilePattern)); - // Match forward-declarations in the old namespace. Finder->addMatcher( cxxRecordDecl(unless(anyOf(isImplicit(), isDefinition())), IsInMovedNs) @@ -288,9 +329,9 @@ void ChangeNamespaceTool::registerMatche // Types in `UsingShadowDecl` is not matched by `typeLoc` above, so we need to // special case it. - Finder->addMatcher( - usingDecl(IsInMovedNs, hasAnyUsingShadowDec
[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.
jlebar updated this revision to Diff 77271. jlebar added a comment. Use TEST_STD_VER macro. https://reviews.llvm.org/D25403 Files: libcxx/include/cmath libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp Index: libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp === --- /dev/null +++ libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp @@ -0,0 +1,35 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take +// floating-point values are evaluatable from constexpr contexts. +// +// These functions need to be constexpr in order to be called from CUDA, see +// https://reviews.llvm.org/D25403. They don't actually need to be +// constexpr-evaluatable, but that's what we check here, since we can't check +// true constexpr-ness. + +#include + +#include "test_macros.h" + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +#if TEST_STD_VER >= 11 +constexpr bool a = std::__libcpp_isnan(0.); +constexpr bool b = std::__libcpp_isinf(0.0); +constexpr bool c = std::__libcpp_isfinite(0.0); +#endif + +int main() +{ + return 0; +} Index: libcxx/include/cmath === --- libcxx/include/cmath +++ libcxx/include/cmath @@ -560,7 +560,7 @@ template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isnan) @@ -572,15 +572,15 @@ template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT { return isnan(__lcpp_x); } template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isinf) @@ -592,15 +592,15 @@ template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT { return isinf(__lcpp_x); } template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isfinite) @@ -612,7 +612,7 @@ template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT { return isfinite(__lcpp_x); Index: libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp === --- /dev/null +++ libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp @@ -0,0 +1,35 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take +// floating-point values are evaluatable from constexpr contexts. +// +// These functions need to be constexpr in order to be called from CUDA, see +// https://reviews.llvm.org/D25403. They don't actually need to be +// constexpr-evaluatable, but that's what we check here, since we can't check +// true constexpr-ness. + +#include + +#include "test_macros.h" + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +#if TEST_STD_VER >= 11 +constexpr bool a = std::__libcpp_isnan(0.); +constexpr bool b = std::__libcpp_isinf(0.0); +constexpr bool c = std::__libcpp_isfinite(0.0); +#endif + +int main() +{ + return 0; +} Index: libcxx/include/cmath === --- libcxx/include/cmath +++ libcxx/include/cmath @@ -560,7 +560,7 @@ template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isnan) @@ -572,15 +572,15 @@ template _LIBCPP_ALWAYS_INLINE -typename enable_if::value, bool>::type +_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT { return isnan(__lcpp_x); } template _LIBCPP_ALWAYS_INLINE
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
ioeric updated this revision to Diff 77270. ioeric marked an inline comment as done. ioeric added a comment. - Addressed comment. https://reviews.llvm.org/D25771 Files: change-namespace/ChangeNamespace.cpp change-namespace/ChangeNamespace.h unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -313,8 +313,8 @@ "}\n" "namespace nb {\n" "using nc::SAME;\n" - "using YO = nc::SAME;\n" - "typedef nc::SAME IDENTICAL;\n" + "using YO = nd::SAME;\n" + "typedef nd::SAME IDENTICAL;\n" "void f(nd::SAME Same) {}\n" "} // namespace nb\n" "} // namespace na\n"; @@ -333,93 +333,14 @@ "namespace x {\n" "namespace y {\n" "using ::na::nc::SAME;\n" - "using YO = na::nc::SAME;\n" - "typedef na::nc::SAME IDENTICAL;\n" + "using YO = na::nd::SAME;\n" + "typedef na::nd::SAME IDENTICAL;\n" "void f(na::nd::SAME Same) {}\n" "} // namespace y\n" "} // namespace x\n"; EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } -TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "namespace na {\n" - "namespace nb {\n" - "void f() {\n" - " using glob::Glob;\n" - " Glob g;\n" - "}\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is UsingShadowDecl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() {\n" - " using ::glob::Glob;\n" - " glob::Glob g;\n" - "}\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - -TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using glob::Glob;\n" - "namespace na {\n" - "namespace nb {\n" - "void f() { Glob g; }\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is UsingShadowDecl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using glob::Glob;\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() { glob::Glob g; }\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - -TEST_F(ChangeNamespaceTest, UsingNamespace) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using namespace glob;\n" - "namespace na {\n" - "namespace nb {\n" - "void f() { Glob g; }\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is "using namespace" decl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using namespace glob;\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() { glob::Glob g; }\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - TEST_F(ChangeNamespaceTest, TypeInNestedNameSpecifier) { std::string Code = "namespace na {\n" @@ -625,6 +546,359 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnC
[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286306: [analyzer] Provide Contains() on ImmutableMap program state partial trait. (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D26373?vs=77109&id=77269#toc Repository: rL LLVM https://reviews.llvm.org/D26373 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286306 - [analyzer] Provide Contains() on ImmutableMap program state partial trait.
Author: ddcc Date: Tue Nov 8 16:39:14 2016 New Revision: 286306 URL: http://llvm.org/viewvc/llvm-project?rev=286306&view=rev Log: [analyzer] Provide Contains() on ImmutableMap program state partial trait. Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26373 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h?rev=286306&r1=286305&r2=286306&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Tue Nov 8 16:39:14 2016 @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ namespace ento { return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ namespace ento { } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ namespace ento { return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. LGTM with one nit. Comment at: change-namespace/ChangeNamespace.cpp:275 + (DiffOldNsSplitted.empty() ? "-" : DiffOldNsSplitted.front())) + .str(); + auto IsInMovedNs = ioeric wrote: > hokein wrote: > > Using an invalid name `-` is not an elegant solution to me. Is it possible > > to avoid it? > > Maybe we can explicitly specify `IsVisibleInNewNs` using the code like: > > > > ``` > > Optional> IsVisibleInNewNs = > > IsInMovedNs; > > if (!DiffOldNsSplitted.empty() ) { > > std::string Prefix = ... > > IsVisibleInNewNs = anyOf(*IsVisibleInNewNs, > > unless(hasAncestor(namespaceDecl(hasName(Prefix)); > > } > > ``` > As per offline discussion, this seems to be impossible. OK, then add a comment explicitly specifying that `"-"` is used as an invalid name. I think the code can be simplified as: ``` std::string Prefix = "-"; if (!DiffOldNsSplitted.empty()) { Prefix = (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) + DiffOldNsSplitted.front()).str(); } ``` https://reviews.llvm.org/D25771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26196: Add support for non-zero null pointers
rjmccall added a comment. In https://reviews.llvm.org/D26196#589493, @yaxunl wrote: > Fixed list initialization of large struct which are mostly initialized by 0 > through memset. > Added tests for casting literal 0 and non-literal integer to pointer. > > There are many more places need to be changed. I am wondering if it makes > sense to split this feature into multiple pieces, e.g. for C and OpenCL, C++, > Objective-C, OpenMP, incrementally. It's fine to split it up. Note that at least some of the Objective-C code doesn't need to be updated, because Objective-C object pointers can't be in an alternate address space. Comment at: lib/CodeGen/CGExprConstant.cpp:1645 if (const RecordType *RT = T->getAs()) { -const CXXRecordDecl *RD = cast(RT->getDecl()); +const RecordDecl *RD = cast(RT->getDecl()); return ::EmitNullConstant(*this, RD, /*complete object*/ true); The cast<> here is now unnecessary. Comment at: lib/CodeGen/CodeGenModule.h:1159 + /// Does null pointer have zero value. + bool isNullPtrZero(llvm::PointerType *T, QualType QT); + This can just take QT; it's not optimized by taking T as well, and in some cases you wouldn't otherwise need to compute that. Comment at: lib/CodeGen/TargetInfo.cpp:7040 + auto AS = PT->getAddressSpace(); + return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0; +} This check is definitely not correct; this function needs to return true when AS == 0, right? Also, you should really just be checking QT.getAddressSpace(). https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.
dcoughlin added a comment. In https://reviews.llvm.org/D26373#589614, @ddcc wrote: > Even though there isn't a performance difference, I think it is semantically > clearer since it is explicit that the value is unneeded. Makes sense to me! https://reviews.llvm.org/D26373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26423: [clang-move] Support template class.
hokein created this revision. hokein added a reviewer: ioeric. hokein added a subscriber: cfe-commits. https://reviews.llvm.org/D26423 Files: clang-move/ClangMove.cpp test/clang-move/Inputs/template_class_test.cpp test/clang-move/Inputs/template_class_test.h test/clang-move/move-template-class.cpp Index: test/clang-move/move-template-class.cpp === --- /dev/null +++ test/clang-move/move-template-class.cpp @@ -0,0 +1,86 @@ +// RUN: mkdir -p %T/move-template-class +// RUN: cp %S/Inputs/template_class_test* %T/move-template-class +// RUN: cd %T/move-template-class +// RUN: clang-move -names="A,B" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp -- +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE1 %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s +// +// RUN: cp %S/Inputs/template_class_test* %T/move-template-class +// RUN: clang-move -names="A" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp -- +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-H-CASE2 %s +// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP-CASE2 %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE2 %s +// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE2 %s +// +// +// CHECK-OLD-TEST-EMPTY: {{^}}{{$}} +// +// CHECK-NEW-TEST-H-CASE1: #ifndef TEMPLATE_CLASS_TEST_H // comment 1 +// CHECK-NEW-TEST-H-CASE1: #define TEMPLATE_CLASS_TEST_H +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: class A { +// CHECK-NEW-TEST-H-CASE1: public: +// CHECK-NEW-TEST-H-CASE1: void f(); +// CHECK-NEW-TEST-H-CASE1: void g(); +// CHECK-NEW-TEST-H-CASE1: template void h(); +// CHECK-NEW-TEST-H-CASE1: template void k(); +// CHECK-NEW-TEST-H-CASE1: static int b; +// CHECK-NEW-TEST-H-CASE1: static int c; +// CHECK-NEW-TEST-H-CASE1: }; +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: void A::f() {} +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: void A::h() {} +// CHECK-NEW-TEST-H-CASE1: template +// CHECK-NEW-TEST-H-CASE1: int A::b = 2; +// CHECK-NEW-TEST-H-CASE1: class B { +// CHECK-NEW-TEST-H-CASE1: public: +// CHECK-NEW-TEST-H-CASE1: void f(); +// CHECK-NEW-TEST-H-CASE1: }; +// CHECK-NEW-TEST-H-CASE1: #endif // TEMPLATE_CLASS_TEST_H +// +// CHECK-NEW-TEST-CPP-CASE1: #include "{{.*}}new_template_class_test.h" +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: void A::g() {} +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: void A::k() {} +// CHECK-NEW-TEST-CPP-CASE1: template +// CHECK-NEW-TEST-CPP-CASE1: int A::c = 2; +// CHECK-NEW-TEST-CPP-CASE1: void B::f() {} +// +// CHECK-OLD-TEST-H-CASE2: #ifndef TEMPLATE_CLASS_TEST_H // comment 1 +// CHECK-OLD-TEST-H-CASE2: #define TEMPLATE_CLASS_TEST_H +// CHECK-OLD-TEST-H-CASE2: class B { +// CHECK-OLD-TEST-H-CASE2: public: +// CHECK-OLD-TEST-H-CASE2: void f(); +// CHECK-OLD-TEST-H-CASE2: }; +// CHECK-OLD-TEST-H-CASE2: #endif // TEMPLATE_CLASS_TEST_H +// +// CHECK-OLD-TEST-CPP-CASE2: #include "template_class_test.h" +// CHECK-OLD-TEST-CPP-CASE2: void B::f() {} +// +// CHECK-NEW-TEST-H-CASE2: #ifndef {{.*}}NEW_TEMPLATE_CLASS_TEST_H +// CHECK-NEW-TEST-H-CASE2: #define {{.*}}NEW_TEMPLATE_CLASS_TEST_H +// CHECK-NEW-TEST-H-CASE2: template +// CHECK-NEW-TEST-H-CASE2: class A { +// CHECK-NEW-TEST-H-CASE2: public: +// CHECK-NEW-TEST-H-CASE2: void f(); +// CHECK-NEW-TEST-H-CASE2: void g(); +// CHECK-NEW-TEST-H-CASE2: template void h(); +// CHECK-NEW-TEST-H-CASE2: template void k(); +// CHECK-NEW-TEST-H-CASE2: static int b; +// CHECK-NEW-TEST-H-CASE2: static int c; +// CHECK-NEW-TEST-H-CASE2: }; +// CHECK-NEW-TEST-H-CASE2: template void A::f() {} +// CHECK-NEW-TEST-H-CASE2: template template void A::h() {} +// CHECK-NEW-TEST-H-CASE2: template int A::b = 2; +// CHECK-NEW
[PATCH] D26196: Add support for non-zero null pointers
rjmccall added inline comments. Comment at: lib/CodeGen/CGExprConstant.cpp:1340 + return C; +return getNullPtr(PT, DestType); } yaxunl wrote: > efriedma wrote: > > yaxunl wrote: > > > yaxunl wrote: > > > > rjmccall wrote: > > > > > efriedma wrote: > > > > > > Consider code like the following: > > > > > > > > > > > > int x = 0; > > > > > > auto y1 = (__specialaddrspace int*)0; > > > > > > auto y2 = (__specialaddrspace int*)((void)0, 0); > > > > > > auto y3 = (__specialaddrspace int*)x; > > > > > > > > > > > > How do you expect these three cases to behave? (The first case > > > > > > involves a C null pointer constant, the second and third cases are > > > > > > different ways of writing a general int->ptr conversion.) > > > > > Yeah, I think you probably need to fix APValue to be unambiguous > > > > > about whether the value is a formal null pointer (CK_NullToPointer) > > > > > or just a cast of an integer (CK_IntegralToPointer). It looks like > > > > > PointerExprEvaluator will generate the exact same value for both. > > > > It seems the current implementation generates the correct IR. > > > > > > > > I tried the following sample and I saw correct IR generated. > > > > > > > > > > > > ``` > > > > private int* test_cast_0_to_ptr(void) { > > > > return (private int*)0; > > > > } > > > > > > > > private int* test_cast_int_to_ptr1(void) { > > > > return (private int*)((void)0, 0); > > > > } > > > > > > > > private int* test_cast_int_to_ptr2(void) { > > > > int x = 0; > > > > return (private int*)x; > > > > } > > > > > > > > ``` > > > > > > > > The dumped AST is > > > > > > > > > > > > ``` > > > > |-FunctionDecl 0x95fdc88 line:3:14 > > > > test_cast_0_to_ptr 'int *(void)' > > > > | `-CompoundStmt 0x95fdde8 > > > > | `-ReturnStmt 0x95fddd0 > > > > | `-CStyleCastExpr 0x95fdda8 'int *' > > > > > > > > | `-IntegerLiteral 0x95fdd70 'int' 0 > > > > |-FunctionDecl 0x95fdea0 line:13:14 > > > > test_cast_int_to_ptr1 'int *(void)' > > > > | `-CompoundStmt 0x95fe098 > > > > | `-ReturnStmt 0x95fe080 > > > > | `-CStyleCastExpr 0x95fe058 'int *' > > > > > > > > | `-ParenExpr 0x95fe038 'int' > > > > | `-BinaryOperator 0x95fe010 'int' ',' > > > > | |-CStyleCastExpr 0x95fdf78 'void' > > > > | | `-IntegerLiteral 0x95fdf48 'int' 0 > > > > | `-IntegerLiteral 0x95fdfa0 'int' 0 > > > > `-FunctionDecl 0x95fe150 line:19:14 > > > > test_cast_int_to_ptr2 'int *(void)' > > > > `-CompoundStmt 0x9620130 > > > > |-DeclStmt 0x9620080 > > > > | `-VarDecl 0x95fe210 col:7 used x 'int' cinit > > > > | `-IntegerLiteral 0x9620060 'int' 0 > > > > `-ReturnStmt 0x9620118 > > > > `-CStyleCastExpr 0x96200f0 'int *' > > > > > > > > ``` > > > > > > > > Since only CK_NullToPointer is translated to null pointer through > > > > getNullPtr, CK_IntegralToPointer will result in either zero-valued > > > > pointer or inttoptr, the generated IR is correct. > > > Basically in the second and third case the destination type is not > > > pointer, so they do not need to be emitted as null pointer. If a literal > > > 0 is casted to a pointer type, then it should be emitted as a null > > > pointer. > > What happens in the following case? > > > > static private int* x = (private int*)((void)0, 0); > You are right. This needs to be fixed. Another straightforward test case would be reinterpret_cast(0), or (private void*) (1-1) in C++11. https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
ioeric marked an inline comment as done. ioeric added inline comments. Comment at: change-namespace/ChangeNamespace.cpp:275 + (DiffOldNsSplitted.empty() ? "-" : DiffOldNsSplitted.front())) + .str(); + auto IsInMovedNs = hokein wrote: > Using an invalid name `-` is not an elegant solution to me. Is it possible to > avoid it? > Maybe we can explicitly specify `IsVisibleInNewNs` using the code like: > > ``` > Optional> IsVisibleInNewNs = > IsInMovedNs; > if (!DiffOldNsSplitted.empty() ) { > std::string Prefix = ... > IsVisibleInNewNs = anyOf(*IsVisibleInNewNs, > unless(hasAncestor(namespaceDecl(hasName(Prefix)); > } > ``` As per offline discussion, this seems to be impossible. https://reviews.llvm.org/D25771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.
hfinkel added inline comments. Comment at: libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp:24 + +#if __cplusplus >= 201103L +constexpr bool a = std::__libcpp_isnan(0.); I think the preferred form here is: #if TEST_STD_VER >= 11 https://reviews.llvm.org/D25403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."
Yes, some bots don't build all the targets. I think the test should go into Preprocessor/init.c. On Tue, Nov 8, 2016 at 2:07 PM, Stephen Hines wrote: > srhines added a comment. > > Reverted because this broke builds: > > clang-hexagon-elf > llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast > clang-ppc64be-linux-multistage > llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast > > It isn't clear from the logs why these builds failed, since I did a general > build, but perhaps there is something that is stripping out Android-specific > targets there. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D26422 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."
srhines added a comment. Reverted because this broke builds: clang-hexagon-elf llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast clang-ppc64be-linux-multistage llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast It isn't clear from the logs why these builds failed, since I did a general build, but perhaps there is something that is stripping out Android-specific targets there. Repository: rL LLVM https://reviews.llvm.org/D26422 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."
This revision was automatically updated to reflect the committed changes. Closed by commit rL286298: Revert "Define __ANDROID_API__ for all Android builds." (authored by srhines). Changed prior to commit: https://reviews.llvm.org/D26422?vs=77254&id=77256#toc Repository: rL LLVM https://reviews.llvm.org/D26422 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Driver/android-targets.cpp Index: cfe/trunk/test/Driver/android-targets.cpp === --- cfe/trunk/test/Driver/android-targets.cpp +++ cfe/trunk/test/Driver/android-targets.cpp @@ -1,83 +0,0 @@ -// Test API-related defines for various Android targets. -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 - -// CHECK: __ANDROID__defined -// LEVEL19: __ANDROID__defined -// LEVEL20: __ANDROID__defined -#ifdef __ANDROID__ -void __ANDROID__defined(void) {} -#endif - -// CHECK-NOT: __ANDROID_API__defined -// LEVEL19: __ANDROID_API__defined -// LEVEL20: __ANDROID_API__defined -#ifdef __ANDROID_API__ -void __ANDROID_API__defined(void) {} -int android_api = __ANDROID_API__; -#endif - -// CHECK-NOT: __ANDROID_API__20 -// LEVEL19-NOT: __ANDROID_API__20 -// LEVEL20: __ANDROID_API__20 -#if __ANDROID_API__ >= 20 -void __ANDROID_API__20(void) {} -#endif Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -465,8 +465,6 @@ Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); - if (Maj) -Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286298 - Revert "Define __ANDROID_API__ for all Android builds."
Author: srhines Date: Tue Nov 8 15:54:49 2016 New Revision: 286298 URL: http://llvm.org/viewvc/llvm-project?rev=286298&view=rev Log: Revert "Define __ANDROID_API__ for all Android builds." Summary: This reverts commit a8804ddd9fe71304b28e5b834d134fe93e568ee0. Subscribers: cfe-commits, pirama, eugenis, tberghammer, danalbert Differential Revision: https://reviews.llvm.org/D26422 Removed: cfe/trunk/test/Driver/android-targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286298&r1=286297&r2=286298&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov 8 15:54:49 2016 @@ -465,8 +465,6 @@ protected: Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); - if (Maj) -Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); Removed: cfe/trunk/test/Driver/android-targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-targets.cpp?rev=286297&view=auto == --- cfe/trunk/test/Driver/android-targets.cpp (original) +++ cfe/trunk/test/Driver/android-targets.cpp (removed) @@ -1,83 +0,0 @@ -// Test API-related defines for various Android targets. -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 - -// CHECK: __ANDROID__defined -// LEVEL19: __ANDROID__defined -// LEVEL20: __ANDROID__defined -#ifdef __ANDROID__ -void __ANDROID__defined(void) {} -#endif - -// CHECK-NOT: __ANDROID_API__defined -// LEVEL19: __ANDROID_API__defined -// LEVEL20: __ANDROID_API__defined -#ifdef __ANDROID_API__ -void __ANDROID_API__defined(void) {} -int android_api = __ANDROID_API__; -#endif - -// CHECK-NOT: __ANDROID_API__20 -// LEVEL19-NOT: __ANDROID_API__20 -// LEVEL20: __ANDROID_API__20 -#if __ANDROID_API__ >= 20 -void __ANDROID_API__20(void) {} -#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."
srhines created this revision. srhines added subscribers: danalbert, eugenis, pirama, cfe-commits. Herald added a subscriber: tberghammer. This reverts commit a8804ddd9fe71304b28e5b834d134fe93e568ee0. https://reviews.llvm.org/D26422 Files: lib/Basic/Targets.cpp test/Driver/android-targets.cpp Index: test/Driver/android-targets.cpp === --- test/Driver/android-targets.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Test API-related defines for various Android targets. -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target arm-linux-androideabi20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target aarch64-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target i686-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target x86_64-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mipsel-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 -// -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android \ -// RUN: | FileCheck %s -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android19 \ -// RUN: | FileCheck %s -check-prefix=LEVEL19 -// RUN: %clang %s -emit-llvm -S -c -o - \ -// RUN: -target mips64el-linux-android20 \ -// RUN: | FileCheck %s -check-prefix=LEVEL20 - -// CHECK: __ANDROID__defined -// LEVEL19: __ANDROID__defined -// LEVEL20: __ANDROID__defined -#ifdef __ANDROID__ -void __ANDROID__defined(void) {} -#endif - -// CHECK-NOT: __ANDROID_API__defined -// LEVEL19: __ANDROID_API__defined -// LEVEL20: __ANDROID_API__defined -#ifdef __ANDROID_API__ -void __ANDROID_API__defined(void) {} -int android_api = __ANDROID_API__; -#endif - -// CHECK-NOT: __ANDROID_API__20 -// LEVEL19-NOT: __ANDROID_API__20 -// LEVEL20: __ANDROID_API__20 -#if __ANDROID_API__ >= 20 -void __ANDROID_API__20(void) {} -#endif Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -465,8 +465,6 @@ Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); - if (Maj) -Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26196: Add support for non-zero null pointers
yaxunl marked an inline comment as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGExprConstant.cpp:1340 + return C; +return getNullPtr(PT, DestType); } efriedma wrote: > yaxunl wrote: > > yaxunl wrote: > > > rjmccall wrote: > > > > efriedma wrote: > > > > > Consider code like the following: > > > > > > > > > > int x = 0; > > > > > auto y1 = (__specialaddrspace int*)0; > > > > > auto y2 = (__specialaddrspace int*)((void)0, 0); > > > > > auto y3 = (__specialaddrspace int*)x; > > > > > > > > > > How do you expect these three cases to behave? (The first case > > > > > involves a C null pointer constant, the second and third cases are > > > > > different ways of writing a general int->ptr conversion.) > > > > Yeah, I think you probably need to fix APValue to be unambiguous about > > > > whether the value is a formal null pointer (CK_NullToPointer) or just a > > > > cast of an integer (CK_IntegralToPointer). It looks like > > > > PointerExprEvaluator will generate the exact same value for both. > > > It seems the current implementation generates the correct IR. > > > > > > I tried the following sample and I saw correct IR generated. > > > > > > > > > ``` > > > private int* test_cast_0_to_ptr(void) { > > > return (private int*)0; > > > } > > > > > > private int* test_cast_int_to_ptr1(void) { > > > return (private int*)((void)0, 0); > > > } > > > > > > private int* test_cast_int_to_ptr2(void) { > > > int x = 0; > > > return (private int*)x; > > > } > > > > > > ``` > > > > > > The dumped AST is > > > > > > > > > ``` > > > |-FunctionDecl 0x95fdc88 line:3:14 > > > test_cast_0_to_ptr 'int *(void)' > > > | `-CompoundStmt 0x95fdde8 > > > | `-ReturnStmt 0x95fddd0 > > > | `-CStyleCastExpr 0x95fdda8 'int *' > > > | `-IntegerLiteral 0x95fdd70 'int' 0 > > > |-FunctionDecl 0x95fdea0 line:13:14 > > > test_cast_int_to_ptr1 'int *(void)' > > > | `-CompoundStmt 0x95fe098 > > > | `-ReturnStmt 0x95fe080 > > > | `-CStyleCastExpr 0x95fe058 'int *' > > > > > > | `-ParenExpr 0x95fe038 'int' > > > | `-BinaryOperator 0x95fe010 'int' ',' > > > | |-CStyleCastExpr 0x95fdf78 'void' > > > | | `-IntegerLiteral 0x95fdf48 'int' 0 > > > | `-IntegerLiteral 0x95fdfa0 'int' 0 > > > `-FunctionDecl 0x95fe150 line:19:14 > > > test_cast_int_to_ptr2 'int *(void)' > > > `-CompoundStmt 0x9620130 > > > |-DeclStmt 0x9620080 > > > | `-VarDecl 0x95fe210 col:7 used x 'int' cinit > > > | `-IntegerLiteral 0x9620060 'int' 0 > > > `-ReturnStmt 0x9620118 > > > `-CStyleCastExpr 0x96200f0 'int *' > > > > > > ``` > > > > > > Since only CK_NullToPointer is translated to null pointer through > > > getNullPtr, CK_IntegralToPointer will result in either zero-valued > > > pointer or inttoptr, the generated IR is correct. > > Basically in the second and third case the destination type is not pointer, > > so they do not need to be emitted as null pointer. If a literal 0 is casted > > to a pointer type, then it should be emitted as a null pointer. > What happens in the following case? > > static private int* x = (private int*)((void)0, 0); You are right. This needs to be fixed. https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files
Eugene.Zelenko added a comment. I think will be good idea to mention this in documentation and release notes. https://reviews.llvm.org/D26418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
srhines added a comment. Ugh, phabricator dropped my updated commit message, so that is completely wrong now. Oh well. I guess I will just use repo/gerrit for staging things in the future (and get consensus there) before asking for any upstream reviews. Repository: rL LLVM https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286295: Define __ANDROID_API__ for all Android builds. (authored by srhines). Changed prior to commit: https://reviews.llvm.org/D26385?vs=77236&id=77250#toc Repository: rL LLVM https://reviews.llvm.org/D26385 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Driver/android-targets.cpp Index: cfe/trunk/test/Driver/android-targets.cpp === --- cfe/trunk/test/Driver/android-targets.cpp +++ cfe/trunk/test/Driver/android-targets.cpp @@ -0,0 +1,83 @@ +// Test API-related defines for various Android targets. +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 + +// CHECK: __ANDROID__defined +// LEVEL19: __ANDROID__defined +// LEVEL20: __ANDROID__defined +#ifdef __ANDROID__ +void __ANDROID__defined(void) {} +#endif + +// CHECK-NOT: __ANDROID_API__defined +// LEVEL19: __ANDROID_API__defined +// LEVEL20: __ANDROID_API__defined +#ifdef __ANDROID_API__ +void __ANDROID_API__defined(void) {} +int android_api = __ANDROID_API__; +#endif + +// CHECK-NOT: __ANDROID_API__20 +// LEVEL19-NOT: __ANDROID_API__20 +// LEVEL20: __ANDROID_API__20 +#if __ANDROID_API__ >= 20 +void __ANDROID_API__20(void) {} +#endif Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -465,6 +465,8 @@ Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); + if (Maj) +Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286295 - Define __ANDROID_API__ for all Android builds.
Author: srhines Date: Tue Nov 8 15:23:26 2016 New Revision: 286295 URL: http://llvm.org/viewvc/llvm-project?rev=286295&view=rev Log: Define __ANDROID_API__ for all Android builds. Summary: Bug: https://llvm.org/bugs/show_bug.cgi?id=30940 This macro (along with __ANDROID__) should always be defined for Android targets. We set it to the major (only) version of the Android API being compiled for. The Android version is able to be set as an integer suffix for any valid Android target. Reviewers: danalbert, eugenis Subscribers: cfe-commits, pirama, eugenis, tberghammer, danalbert Differential Revision: https://reviews.llvm.org/D26385 Added: cfe/trunk/test/Driver/android-targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286295&r1=286294&r2=286295&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov 8 15:23:26 2016 @@ -465,6 +465,8 @@ protected: Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); + if (Maj) +Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); Added: cfe/trunk/test/Driver/android-targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-targets.cpp?rev=286295&view=auto == --- cfe/trunk/test/Driver/android-targets.cpp (added) +++ cfe/trunk/test/Driver/android-targets.cpp Tue Nov 8 15:23:26 2016 @@ -0,0 +1,83 @@ +// Test API-related defines for various Android targets. +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 + +// CHECK: __ANDROID__defined +// LEVEL19: __ANDROID__defined +// LEVEL20: __ANDROID__defined +#ifdef __ANDROID__ +void __ANDROID__defined(void) {} +#endif + +// CHECK-NOT: __ANDROID_API__defined +// LEVEL19: __ANDROID_API__defined +// LEVEL20: __ANDROID_API__defined +#ifdef __ANDROID_API__ +void __ANDROID_API__defined(void) {} +int android_api = __ANDROID_API__; +#endif + +// CHECK-NOT: __ANDROID_API__20 +// LEVEL19-NOT: __ANDROID_API__20 +// LEVEL20: __ANDROID_API__20 +#if __ANDROID_API__ >= 20 +void __ANDROID_API__20(void) {} +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26196: Add support for non-zero null pointers
efriedma added inline comments. Comment at: lib/CodeGen/CGExprConstant.cpp:1340 + return C; +return getNullPtr(PT, DestType); } yaxunl wrote: > yaxunl wrote: > > rjmccall wrote: > > > efriedma wrote: > > > > Consider code like the following: > > > > > > > > int x = 0; > > > > auto y1 = (__specialaddrspace int*)0; > > > > auto y2 = (__specialaddrspace int*)((void)0, 0); > > > > auto y3 = (__specialaddrspace int*)x; > > > > > > > > How do you expect these three cases to behave? (The first case > > > > involves a C null pointer constant, the second and third cases are > > > > different ways of writing a general int->ptr conversion.) > > > Yeah, I think you probably need to fix APValue to be unambiguous about > > > whether the value is a formal null pointer (CK_NullToPointer) or just a > > > cast of an integer (CK_IntegralToPointer). It looks like > > > PointerExprEvaluator will generate the exact same value for both. > > It seems the current implementation generates the correct IR. > > > > I tried the following sample and I saw correct IR generated. > > > > > > ``` > > private int* test_cast_0_to_ptr(void) { > > return (private int*)0; > > } > > > > private int* test_cast_int_to_ptr1(void) { > > return (private int*)((void)0, 0); > > } > > > > private int* test_cast_int_to_ptr2(void) { > > int x = 0; > > return (private int*)x; > > } > > > > ``` > > > > The dumped AST is > > > > > > ``` > > |-FunctionDecl 0x95fdc88 line:3:14 > > test_cast_0_to_ptr 'int *(void)' > > | `-CompoundStmt 0x95fdde8 > > | `-ReturnStmt 0x95fddd0 > > | `-CStyleCastExpr 0x95fdda8 'int *' > > | `-IntegerLiteral 0x95fdd70 'int' 0 > > |-FunctionDecl 0x95fdea0 line:13:14 > > test_cast_int_to_ptr1 'int *(void)' > > | `-CompoundStmt 0x95fe098 > > | `-ReturnStmt 0x95fe080 > > | `-CStyleCastExpr 0x95fe058 'int *' > > > > | `-ParenExpr 0x95fe038 'int' > > | `-BinaryOperator 0x95fe010 'int' ',' > > | |-CStyleCastExpr 0x95fdf78 'void' > > | | `-IntegerLiteral 0x95fdf48 'int' 0 > > | `-IntegerLiteral 0x95fdfa0 'int' 0 > > `-FunctionDecl 0x95fe150 line:19:14 > > test_cast_int_to_ptr2 'int *(void)' > > `-CompoundStmt 0x9620130 > > |-DeclStmt 0x9620080 > > | `-VarDecl 0x95fe210 col:7 used x 'int' cinit > > | `-IntegerLiteral 0x9620060 'int' 0 > > `-ReturnStmt 0x9620118 > > `-CStyleCastExpr 0x96200f0 'int *' > > > > ``` > > > > Since only CK_NullToPointer is translated to null pointer through > > getNullPtr, CK_IntegralToPointer will result in either zero-valued pointer > > or inttoptr, the generated IR is correct. > Basically in the second and third case the destination type is not pointer, > so they do not need to be emitted as null pointer. If a literal 0 is casted > to a pointer type, then it should be emitted as a null pointer. What happens in the following case? static private int* x = (private int*)((void)0, 0); https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26418: Add '-suppress-checks-filter' option to suppress diagnostics from certain files
nkakuev created this revision. nkakuev added reviewers: malcolm.parsons, alexfh. nkakuev added a subscriber: cfe-commits. Currently clang-tidy doesn't provide a practical way to suppress diagnostics from headers you don't have control over. If using a function defined in such header causes a false positive, there is no easy way to deal with this issue. Since you //cannot// modify a header, you //cannot// add NOLINT (or any other source annotations) to it. And adding NOLINT to each invocation of such function is either impossible or hugely impractical if invocations are ubiquitous. Using the '-header-filter' doesn't help to address this issue as well. Unless your own headers are strategically named, it is virtually impossible to craft a regex that will filter out only the third-party ones. The '-line-filter' can be used to suppress such warnings, but it's not very convenient. Instead of excluding a line that produces a warning you have to include all other lines. Plus, it provides no way to suppress only certain warnings from a file. The option I propose solves aforementioned problems. It allows a user to specify a set of regular expressions to suppress diagnostics from files whose names match these expressions. Additionally, a set of checks can be specified to suppress only certain diagnostics. The option can be used in the following way: `clang-tidy -suppress-checks-filter='[{"name":"falty_header.h"},{"name":"third-party/","checks":"google-explicit-constructor"}]' source.cpp -- -c` https://reviews.llvm.org/D26418 Files: clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/ClangTidyOptions.cpp clang-tidy/ClangTidyOptions.h clang-tidy/tool/ClangTidyMain.cpp test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h test/clang-tidy/suppress-checks-filter.cpp Index: test/clang-tidy/suppress-checks-filter.cpp === --- test/clang-tidy/suppress-checks-filter.cpp +++ test/clang-tidy/suppress-checks-filter.cpp @@ -0,0 +1,17 @@ +// RUN: clang-tidy -checks='-*,google-explicit-constructor,google-readability-casting' -header-filter='header*' -suppress-checks-filter='[{"name":"header1.h"},{"name":"header2.h","checks":"google-explicit-constructor"},{"name":"2/"}]' %s -- -I %S/Inputs/suppress-checks-filter 2>&1 | FileCheck %s + +#include "1/header1.h" +// CHECK-NOT: header1.h:{{.*}} warning + +#include "1/header2.h" +// CHECK-NOT: 1/header2.h:{{.*}} warning: single-argument constructors {{.*}} +// CHECK: 1/header2.h:{{.*}} warning: redundant cast to the same type {{.*}} + +#include "2/header3.h" +// CHECK-NOT: 2/header3.h:{{.*}} warning: single-argument constructors + +#include "2/header4.h" +// CHECK-NOT: 2/header4.h:{{.*}} warning: single-argument constructors + +// CHECK: Suppressed 4 warnings (4 with suppressed checks filters) + Index: test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h === --- test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h +++ test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h @@ -0,0 +1,2 @@ +class A4 { A4(int); }; + Index: test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h === --- test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h +++ test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h @@ -0,0 +1,2 @@ +class A3 { A3(int); }; + Index: test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h === --- test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h +++ test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h @@ -0,0 +1,6 @@ +class A2 { A2(int); }; + +class B2 { + B2(int &In, int &Out) { Out = (int)In; } +}; + Index: test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h === --- test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h +++ test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h @@ -0,0 +1,2 @@ +class A1 { A1(int); }; + Index: clang-tidy/tool/ClangTidyMain.cpp === --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -105,6 +105,20 @@ cl::init(""), cl::cat(ClangTidyCategory)); +static cl::opt +SuppressWarningsFromHeaders("suppress-checks-filter", cl::desc(R"( +Suppress diagnostics from files whose names match +provided regular expression. If a list of checks +is specified, only diagnostics produces by these +checks will be suppressed. The format of +the argument is a JSON array of objec
[PATCH] D26196: Add support for non-zero null pointers
yaxunl marked 3 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGExprConstant.cpp:1340 + return C; +return getNullPtr(PT, DestType); } yaxunl wrote: > rjmccall wrote: > > efriedma wrote: > > > Consider code like the following: > > > > > > int x = 0; > > > auto y1 = (__specialaddrspace int*)0; > > > auto y2 = (__specialaddrspace int*)((void)0, 0); > > > auto y3 = (__specialaddrspace int*)x; > > > > > > How do you expect these three cases to behave? (The first case involves > > > a C null pointer constant, the second and third cases are different ways > > > of writing a general int->ptr conversion.) > > Yeah, I think you probably need to fix APValue to be unambiguous about > > whether the value is a formal null pointer (CK_NullToPointer) or just a > > cast of an integer (CK_IntegralToPointer). It looks like > > PointerExprEvaluator will generate the exact same value for both. > It seems the current implementation generates the correct IR. > > I tried the following sample and I saw correct IR generated. > > > ``` > private int* test_cast_0_to_ptr(void) { > return (private int*)0; > } > > private int* test_cast_int_to_ptr1(void) { > return (private int*)((void)0, 0); > } > > private int* test_cast_int_to_ptr2(void) { > int x = 0; > return (private int*)x; > } > > ``` > > The dumped AST is > > > ``` > |-FunctionDecl 0x95fdc88 line:3:14 test_cast_0_to_ptr > 'int *(void)' > | `-CompoundStmt 0x95fdde8 > | `-ReturnStmt 0x95fddd0 > | `-CStyleCastExpr 0x95fdda8 'int *' > | `-IntegerLiteral 0x95fdd70 'int' 0 > |-FunctionDecl 0x95fdea0 line:13:14 > test_cast_int_to_ptr1 'int *(void)' > | `-CompoundStmt 0x95fe098 > | `-ReturnStmt 0x95fe080 > | `-CStyleCastExpr 0x95fe058 'int *' > | `-ParenExpr 0x95fe038 'int' > | `-BinaryOperator 0x95fe010 'int' ',' > | |-CStyleCastExpr 0x95fdf78 'void' > | | `-IntegerLiteral 0x95fdf48 'int' 0 > | `-IntegerLiteral 0x95fdfa0 'int' 0 > `-FunctionDecl 0x95fe150 line:19:14 > test_cast_int_to_ptr2 'int *(void)' > `-CompoundStmt 0x9620130 > |-DeclStmt 0x9620080 > | `-VarDecl 0x95fe210 col:7 used x 'int' cinit > | `-IntegerLiteral 0x9620060 'int' 0 > `-ReturnStmt 0x9620118 > `-CStyleCastExpr 0x96200f0 'int *' > ``` > > Since only CK_NullToPointer is translated to null pointer through getNullPtr, > CK_IntegralToPointer will result in either zero-valued pointer or inttoptr, > the generated IR is correct. Basically in the second and third case the destination type is not pointer, so they do not need to be emitted as null pointer. If a literal 0 is casted to a pointer type, then it should be emitted as a null pointer. https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284272 - Implement no_sanitize_address for global vars
On Tue, Nov 8, 2016 at 3:52 PM, Kostya Serebryany via cfe-commits wrote: > > > On Tue, Nov 8, 2016 at 11:27 AM, Douglas Katzman wrote: >> >> oh, sorry for missing this email. >> I'll say "no" - I was hoping you'd audit it! > > > We do indeed have this practice for post-commit audit, but only for the > authors or active maintainers of the piece of code in question. > I afraid I do not fully understand the consequences of this patch -- they > may be non-trivial. > Please initiate a code review (even though the code is already committed). I concur; please add me as a reviewer. ~Aaron > > --kcc > >> >> >> jyknight looked at it and gave me the suggestion to fail the attribute >> parsing if, in the non-deprecated syntax, _any_ of the no_sanitize modifiers >> are inapplicable to global vars. >> >> On Tue, Oct 25, 2016 at 7:19 PM, Kostya Serebryany wrote: >>> >>> ping >>> >>> On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryany >>> wrote: Did you code-review this? (sorry if I missed it) On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits wrote: > > Author: dougk > Date: Fri Oct 14 14:55:09 2016 > New Revision: 284272 > > URL: http://llvm.org/viewvc/llvm-project?rev=284272&view=rev > Log: > Implement no_sanitize_address for global vars > > Modified: > cfe/trunk/include/clang/Basic/Attr.td > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/include/clang/Sema/AttributeList.h > cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > cfe/trunk/test/CodeGen/asan-globals.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp > > Modified: cfe/trunk/include/clang/Basic/Attr.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=284272&r1=284271&r2=284272&view=diff > > == > --- cfe/trunk/include/clang/Basic/Attr.td (original) > +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 > @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl > def NoSanitize : InheritableAttr { >let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >let Args = [VariadicStringArgument<"Sanitizers">]; > - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; > + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], > ErrorDiag, > +"ExpectedFunctionMethodOrGlobalVar">; >let Documentation = [NoSanitizeDocs]; >let AdditionalMembers = [{ > SanitizerMask getMask() const { > @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr > GCC<"no_sanitize_address">, > GCC<"no_sanitize_thread">, > GNU<"no_sanitize_memory">]; > - let Subjects = SubjectList<[Function], ErrorDiag>; > + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, > +"ExpectedFunctionGlobalVarMethodOrProperty">; >let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, > NoSanitizeMemoryDocs]; >let ASTNode = 0; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284272&r1=284271&r2=284272&view=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 > 14:55:09 2016 > @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >"|functions, methods and blocks" >"|functions, methods, and classes" >"|functions, methods, and parameters" > + "|functions, methods, and global variables" >"|classes" >"|enums" >"|variables" > > Modified: cfe/trunk/include/clang/Sema/AttributeList.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=284272&r1=284271&r2=284272&view=diff > > == > --- cfe/trunk/include/clang/Sema/AttributeList.h (original) > +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 > 2016 > @@ -891,6 +891,7 @@ enum AttributeDeclKind { >ExpectedFunctionMethodOrBlock, >ExpectedFunctionMethodOrClass, >ExpectedFunctionMethodOrParameter, > + ExpectedFunctionMethodOrGlobalVar, >ExpectedClass, >ExpectedEnum, >ExpectedVariable, > > Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > URL: > http://llvm.org/viewv
Re: r284272 - Implement no_sanitize_address for global vars
On Tue, Nov 8, 2016 at 11:27 AM, Douglas Katzman wrote: > oh, sorry for missing this email. > I'll say "no" - I was hoping you'd audit it! > We do indeed have this practice for post-commit audit, but only for the authors or active maintainers of the piece of code in question. I afraid I do not fully understand the consequences of this patch -- they may be non-trivial. Please initiate a code review (even though the code is already committed). --kcc > > jyknight looked at it and gave me the suggestion to fail the attribute > parsing if, in the non-deprecated syntax, _any_ of the no_sanitize > modifiers are inapplicable to global vars. > > On Tue, Oct 25, 2016 at 7:19 PM, Kostya Serebryany wrote: > >> ping >> >> On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryany >> wrote: >> >>> Did you code-review this? >>> (sorry if I missed it) >>> >>> On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: dougk Date: Fri Oct 14 14:55:09 2016 New Revision: 284272 URL: http://llvm.org/viewvc/llvm-project?rev=284272&view=rev Log: Implement no_sanitize_address for global vars Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/AttributeList.h cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/CodeGen/asan-globals.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ Basic/Attr.td?rev=284272&r1=284271&r2=284272&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl def NoSanitize : InheritableAttr { let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; let Args = [VariadicStringArgument<"Sanitizers">]; - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag, +"ExpectedFunctionMethodOrGlobalVar">; let Documentation = [NoSanitizeDocs]; let AdditionalMembers = [{ SanitizerMask getMask() const { @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr GCC<"no_sanitize_address">, GCC<"no_sanitize_thread">, GNU<"no_sanitize_memory">]; - let Subjects = SubjectList<[Function], ErrorDiag>; + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, +"ExpectedFunctionGlobalVarMethodOrProperty">; let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, NoSanitizeMemoryDocs]; let ASTNode = 0; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ Basic/DiagnosticSemaKinds.td?rev=284272&r1=284271&r2=284272&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 14:55:09 2016 @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War "|functions, methods and blocks" "|functions, methods, and classes" "|functions, methods, and parameters" + "|functions, methods, and global variables" "|classes" "|enums" "|variables" Modified: cfe/trunk/include/clang/Sema/AttributeList.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ Sema/AttributeList.h?rev=284272&r1=284271&r2=284272&view=diff == --- cfe/trunk/include/clang/Sema/AttributeList.h (original) +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016 @@ -891,6 +891,7 @@ enum AttributeDeclKind { ExpectedFunctionMethodOrBlock, ExpectedFunctionMethodOrClass, ExpectedFunctionMethodOrParameter, + ExpectedFunctionMethodOrGlobalVar, ExpectedClass, ExpectedEnum, ExpectedVariable, Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Sa nitizerMetadata.cpp?rev=284272&r1=284271&r2=284272&view=diff == --- cfe/trunk/lib/CodeGe
[PATCH] D26196: Add support for non-zero null pointers
yaxunl updated this revision to Diff 77238. yaxunl marked 2 inline comments as done. yaxunl added a comment. Added isNullPtrZero to TargetCodeGenInfo. https://reviews.llvm.org/D26196 Files: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/TargetInfo.cpp lib/CodeGen/TargetInfo.h test/CodeGenOpenCL/amdgpu-nullptr.cl Index: test/CodeGenOpenCL/amdgpu-nullptr.cl === --- /dev/null +++ test/CodeGenOpenCL/amdgpu-nullptr.cl @@ -0,0 +1,414 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s + +// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common +// to suppress common linkage for tentative definition. + +// Test 0 as initializer. + +// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +private char *private_p = 0; + +// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 +local char *local_p = 0; + +// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4 +global char *global_p = 0; + +// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4 +constant char *constant_p = 0; + +// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4 +generic char *generic_p = 0; + +// Test NULL as initializer. + +// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +private char *private_p_NULL = NULL; + +// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 +local char *local_p_NULL = NULL; + +// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4 +global char *global_p_NULL = NULL; + +// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4 +constant char *constant_p_NULL = NULL; + +// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4 +generic char *generic_p_NULL = NULL; + +// Test default initialization of pointers. + +// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +private char *p1; + +// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 +local char *p2; + +// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4 +constant char *p3; + +// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4 +global char *p4; + +// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4 +generic char *p5; + +// Test default initialization of sturcture. +typedef struct { + private char *p1; + local char *p2; + constant char *p3; + global char *p4; + generic char *p5; +} StructTy1; + +// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4 +StructTy1 S1; + +typedef struct { + constant char *p3; + global char *p4; + generic char *p5; +} StructTy2; + +// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 4 +StructTy2 S2; + +// Test default initialization of array. +// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }], align 4 +StructTy1 A1[2]; + +// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 4 +StructTy2 A2[2]; + +// Test comparison with 0. + +// CHECK-LABEL: cmp_private +// CHECK: icmp eq i8* %p, addrspacecast (i8 addrspace(4)* null to i8*) +void cmp_private(private char* p) { + if (p != 0) +*p = 0; +} + +// CHECK-LABEL: cmp_local +// CHECK: icmp eq i8 addrspace(3)* %p, addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*) +void cmp_local(local char* p) { + if (p != 0) +*p = 0; +} + +// CHECK-LABEL: cmp_global +// CHECK: icmp eq i8 addr
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
eugenis accepted this revision. eugenis added a reviewer: eugenis. eugenis added a comment. LGTM https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24431: CodeGen: Start using inrange annotations on vtable getelementptr.
pcc added a comment. Ping https://reviews.llvm.org/D24431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
danalbert accepted this revision. danalbert added a reviewer: danalbert. danalbert added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
srhines updated this revision to Diff 77236. srhines added a comment. Switched to conditionally defining __ANDROID_API__ instead. https://reviews.llvm.org/D26385 Files: lib/Basic/Targets.cpp test/Driver/android-targets.cpp Index: test/Driver/android-targets.cpp === --- /dev/null +++ test/Driver/android-targets.cpp @@ -0,0 +1,83 @@ +// Test API-related defines for various Android targets. +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target arm-linux-androideabi20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target aarch64-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target i686-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target x86_64-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mipsel-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 +// +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android \ +// RUN: | FileCheck %s +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android19 \ +// RUN: | FileCheck %s -check-prefix=LEVEL19 +// RUN: %clang %s -emit-llvm -S -c -o - \ +// RUN: -target mips64el-linux-android20 \ +// RUN: | FileCheck %s -check-prefix=LEVEL20 + +// CHECK: __ANDROID__defined +// LEVEL19: __ANDROID__defined +// LEVEL20: __ANDROID__defined +#ifdef __ANDROID__ +void __ANDROID__defined(void) {} +#endif + +// CHECK-NOT: __ANDROID_API__defined +// LEVEL19: __ANDROID_API__defined +// LEVEL20: __ANDROID_API__defined +#ifdef __ANDROID_API__ +void __ANDROID_API__defined(void) {} +int android_api = __ANDROID_API__; +#endif + +// CHECK-NOT: __ANDROID_API__20 +// LEVEL19-NOT: __ANDROID_API__20 +// LEVEL20: __ANDROID_API__20 +#if __ANDROID_API__ >= 20 +void __ANDROID_API__20(void) {} +#endif Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -465,6 +465,8 @@ Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); + if (Maj) +Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
hokein added a comment. One more comment, otherwise looks good. Comment at: change-namespace/ChangeNamespace.cpp:275 + (DiffOldNsSplitted.empty() ? "-" : DiffOldNsSplitted.front())) + .str(); + auto IsInMovedNs = Using an invalid name `-` is not an elegant solution to me. Is it possible to avoid it? Maybe we can explicitly specify `IsVisibleInNewNs` using the code like: ``` Optional> IsVisibleInNewNs = IsInMovedNs; if (!DiffOldNsSplitted.empty() ) { std::string Prefix = ... IsVisibleInNewNs = anyOf(*IsVisibleInNewNs, unless(hasAncestor(namespaceDecl(hasName(Prefix)); } ``` https://reviews.llvm.org/D25771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26236: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286281: [clang-move] Move all code from old.h/cc directly when moving all class… (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D26236?vs=77223&id=77233#toc Repository: rL LLVM https://reviews.llvm.org/D26236 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-move/ClangMove.h clang-tools-extra/trunk/test/clang-move/Inputs/test.h clang-tools-extra/trunk/test/clang-move/move-class.cpp clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp === --- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp +++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp @@ -173,24 +173,25 @@ "} // namespace a\n"; std::map -runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec) { +runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec, + const char *const Header = TestHeader, + const char *const CC = TestCC) { clang::RewriterTestContext Context; std::map FileToFileID; std::vector> FileToSourceText = { - {TestHeaderName, TestHeader}, {TestCCName, TestCC}}; + {TestHeaderName, Header}, {TestCCName, CC}}; auto CreateFiles = [&FileToSourceText, &Context, &FileToFileID]( llvm::StringRef Name, llvm::StringRef Code) { if (!Name.empty()) { - FileToSourceText.emplace_back(Name, Code); FileToFileID[Name] = Context.createInMemoryFile(Name, Code); } }; CreateFiles(Spec.NewCC, ""); CreateFiles(Spec.NewHeader, ""); - CreateFiles(Spec.OldHeader, TestHeader); - CreateFiles(Spec.OldCC, TestCC); + CreateFiles(Spec.OldHeader, Header); + CreateFiles(Spec.OldCC, CC); std::map FileToReplacements; llvm::SmallString<128> InitialDirectory; @@ -201,7 +202,7 @@ Spec, FileToReplacements, InitialDirectory.str(), "LLVM"); tooling::runToolOnCodeWithArgs( - Factory->create(), TestCC, {"-std=c++11", "-fparse-all-comments"}, + Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"}, TestCCName, "clang-move", std::make_shared(), FileToSourceText); formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm"); @@ -263,6 +264,79 @@ EXPECT_EQ(0u, Results.size()); } +TEST(ClangMove, MoveAll) { + std::vector TestHeaders = { +"class A {\npublic:\n int f();\n};", +// forward declaration. +"class B;\nclass A {\npublic:\n int f();\n};", +// template forward declaration. +"template class B;\nclass A {\npublic:\n int f();\n};", +"namespace a {}\nclass A {\npublic:\n int f();\n};", +"namespace a {}\nusing namespace a;\nclass A {\npublic:\n int f();\n};", + }; + const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }"; + move::ClangMoveTool::MoveDefinitionSpec Spec; + Spec.Names.push_back("A"); + Spec.OldHeader = "foo.h"; + Spec.OldCC = "foo.cc"; + Spec.NewHeader = "new_foo.h"; + Spec.NewCC = "new_foo.cc"; + for (const auto& Header : TestHeaders) { +auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code); +EXPECT_EQ(Header, Results[Spec.NewHeader]); +EXPECT_EQ("", Results[Spec.OldHeader]); +EXPECT_EQ("", Results[Spec.OldCC]); + } +} + +TEST(ClangMove, MoveAllMultipleClasses) { + move::ClangMoveTool::MoveDefinitionSpec Spec; + std::vector TestHeaders = { +"class C;\nclass A {\npublic:\n int f();\n};\nclass B {};", +"class C;\nclass B;\nclass A {\npublic:\n int f();\n};\nclass B {};", + }; + const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }"; + Spec.Names = {std::string("A"), std::string("B")}; + Spec.OldHeader = "foo.h"; + Spec.OldCC = "foo.cc"; + Spec.NewHeader = "new_foo.h"; + Spec.NewCC = "new_foo.cc"; + for (const auto& Header : TestHeaders) { +auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code); +EXPECT_EQ(Header, Results[Spec.NewHeader]); +EXPECT_EQ("", Results[Spec.OldHeader]); +EXPECT_EQ("", Results[Spec.OldCC]); + } +} + +TEST(ClangMove, DontMoveAll) { + const char ExpectedHeader[] = "#ifndef NEW_FOO_H\n" +"#define NEW_FOO_H\n" +"class A {\npublic:\n int f();\n};\n" +"#endif // NEW_FOO_H\n"; + const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }"; + std::vector TestHeaders = { +"typedef int Int;\nclass A {\npublic:\n int f();\n};", +"using Int=int;\nclass A {\npublic:\n int f();\n};", +"class B {};\nclass A {\npublic:\n int f();\n};", +"void f() {};\nclass A {\npublic:\n int f();\n};", +"enum Color { RED };\nclass A {\npublic:\n int f();\n};", + }; + move::ClangMoveTool::MoveDefinitionSpec Spec; + Spec.Names.push_back("
[PATCH] D26415: [XRay] Support AArch64 in Clang
rSerge created this revision. rSerge added reviewers: dberris, rengolin. rSerge added subscribers: iid_iunknown, cfe-commits. Herald added a subscriber: aemerson. This patch adds XRay support in Clang for AArch64 target. https://reviews.llvm.org/D26415 Files: lib/Driver/Tools.cpp test/Driver/XRay/xray-instrument-cpu.c test/Driver/XRay/xray-instrument-os.c Index: test/Driver/XRay/xray-instrument-os.c === --- test/Driver/XRay/xray-instrument-os.c +++ test/Driver/XRay/xray-instrument-os.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s // XFAIL: -linux- -// REQUIRES-ANY: amd64, x86_64, x86_64h, arm +// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64 typedef int a; Index: test/Driver/XRay/xray-instrument-cpu.c === --- test/Driver/XRay/xray-instrument-cpu.c +++ test/Driver/XRay/xray-instrument-cpu.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s -// XFAIL: amd64-, x86_64-, x86_64h-, arm +// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64 // REQUIRES: linux typedef int a; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4902,7 +4902,8 @@ const char *const XRayInstrumentOption = "-fxray-instrument"; if (Triple.getOS() == llvm::Triple::Linux && (Triple.getArch() == llvm::Triple::arm || - Triple.getArch() == llvm::Triple::x86_64)) { + Triple.getArch() == llvm::Triple::x86_64 || + Triple.getArch() == llvm::Triple::aarch64)) { // Supported. } else { D.Diag(diag::err_drv_clang_unsupported) Index: test/Driver/XRay/xray-instrument-os.c === --- test/Driver/XRay/xray-instrument-os.c +++ test/Driver/XRay/xray-instrument-os.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s // XFAIL: -linux- -// REQUIRES-ANY: amd64, x86_64, x86_64h, arm +// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64 typedef int a; Index: test/Driver/XRay/xray-instrument-cpu.c === --- test/Driver/XRay/xray-instrument-cpu.c +++ test/Driver/XRay/xray-instrument-cpu.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s -// XFAIL: amd64-, x86_64-, x86_64h-, arm +// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64 // REQUIRES: linux typedef int a; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4902,7 +4902,8 @@ const char *const XRayInstrumentOption = "-fxray-instrument"; if (Triple.getOS() == llvm::Triple::Linux && (Triple.getArch() == llvm::Triple::arm || - Triple.getArch() == llvm::Triple::x86_64)) { + Triple.getArch() == llvm::Triple::x86_64 || + Triple.getArch() == llvm::Triple::aarch64)) { // Supported. } else { D.Diag(diag::err_drv_clang_unsupported) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
srhines added a comment. In https://reviews.llvm.org/D26385#589589, @eugenis wrote: > This is a good change, but I don't think it is the right fix for PR30940. > Instead of handling this in the NDK, we should change *::getIRStackGuard to > fallback to __stack_chk_guard when targeting an old version. Right, this is only addressing part of the problem related to that issue. I can probably put together a follow up to address the rest of the bug, although I am not all that familiar with __stack_chk_guard, so testing might be a problem. https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26410: [CodeGen] Don't emit the same global block multiple times.
george.burgess.iv created this revision. george.burgess.iv added a reviewer: rjmccall. george.burgess.iv added a subscriber: cfe-commits. https://reviews.llvm.org/D14274 makes our constexpr evaluator more aggressive with some variables marked `const`. This changes how we behave on code like the following: void foo() { void (^const block_A)(void) = ^{ return; }; get_kernel_work_group_size(block_A); get_kernel_work_group_size(block_A); } The constexpr evaluator will now give us `^{ return; }` three times (one for each use of `block_A`) instead of once (in `block_A`'s assignment). CodeGen emits a block every time it gets handed a `BlockExpr`, so we end up emitting the code for `^{ return; }` three times in total. We can fix this by tracking which global `BlockExpr`s we've already generated code for. This seems to not happen for local `BlockExpr`s, since the constexpr fails for `BlockExpr`s with captures (see `PointerExprEvaluator::VisitBlockExpr` in lib/AST/ExprConstant.cpp). That said, I'm happy to add this uniquing code for `BlockExpr`s with captures if anyone wants me to. https://reviews.llvm.org/D26410 Files: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.h test/CodeGenCXX/block-in-ctor-dtor.cpp test/CodeGenOpenCL/cl20-device-side-enqueue.cl Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl === --- test/CodeGenOpenCL/cl20-device-side-enqueue.cl +++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl @@ -2,6 +2,8 @@ typedef void (^bl_t)(local void *); +// N.B. The check here only exists to set BL_GLOBAL +// CHECK: @block_G = {{.*}}bitcast ([[BL_GLOBAL:[^@]+@__block_literal_global(\.[0-9]+)?]] const bl_t block_G = (bl_t) ^ (local void *a) {}; kernel void device_side_enqueue(global int *a, global int *b, int i) { @@ -84,27 +86,23 @@ }, c); + // The full type of these expressions are long (and repeated elsewhere), so we + // capture it as part of the regex for convenience and clarity. + // CHECK: store void ()* bitcast ([[BL_A:[^@]+@__block_literal_global.[0-9]+]] to void ()*), void ()** %block_A void (^const block_A)(void) = ^{ return; }; + // CHECK: store void (i8 addrspace(2)*)* bitcast ([[BL_B:[^@]+@__block_literal_global.[0-9]+]] to void (i8 addrspace(2)*)*), void (i8 addrspace(2)*)** %block_B void (^const block_B)(local void *) = ^(local void *a) { return; }; - // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A - // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8* - // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]]) + // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* bitcast ([[BL_A]] to i8*)) unsigned size = get_kernel_work_group_size(block_A); - // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)** %block_B - // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8* - // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]]) + // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* bitcast ([[BL_B]] to i8*)) size = get_kernel_work_group_size(block_B); - // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A - // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8* - // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]]) + // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* bitcast ([[BL_A]] to i8*)) size = get_kernel_preferred_work_group_size_multiple(block_A); - // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)* addrspace(1)* @block_G - // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8* - // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]]) + // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* bitcast ([[BL_GLOBAL]] to i8*)) size = get_kernel_preferred_work_group_size_multiple(block_G); } Index: test/CodeGenCXX/block-in-ctor-dtor.cpp === --- test/CodeGenCXX/block-in-ctor-dtor.cpp +++ test/CodeGenCXX/block-in-ctor-dtor.cpp @@ -42,7 +42,5 @@ // CHECK-LABEL: define internal void @___ZN4ZoneD2Ev_block_invoke_ // CHECK-LABEL: define internal void @___ZN1XC2Ev_block_invoke // CHECK-LABEL: define internal void @___ZN1XC2Ev_block_invoke_ -// CHECK-LABEL: define internal void @___ZN1XC1Ev_block_invoke -// CHECK-LABEL: define internal void @___ZN1XC1Ev_block_invoke_ // CHECK-LABEL: define internal void @___ZN1XD2Ev_block_invoke // CHECK-LABEL: define internal void @___ZN1XD2Ev_block_invoke_ Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -457,6 +457,10 @@ bool isTriviallyRecursive(const FunctionDecl *F); bool
[PATCH] D22296: CodeGen: New vtable group representation: struct of vtable arrays.
pcc added a comment. Ping https://reviews.llvm.org/D22296 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic
kastiglione updated this revision to Diff 77232. kastiglione added a comment. Added test https://reviews.llvm.org/D26406 Files: include/clang/Basic/DiagnosticSemaKinds.td test/Misc/warning-flags.c test/SemaObjC/check-dup-objc-decls-1.m Index: test/SemaObjC/check-dup-objc-decls-1.m === --- test/SemaObjC/check-dup-objc-decls-1.m +++ test/SemaObjC/check-dup-objc-decls-1.m @@ -35,6 +35,12 @@ @protocol PP @end // expected-note {{previous definition is here}} @protocol PP @end // expected-warning {{duplicate protocol definition of 'PP'}} +@protocol DP @end +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wduplicate-protocol" +@protocol DP @end +#pragma clang diagnostic pop + @interface A(Cat) @end // expected-note {{previous definition is here}} @interface A(Cat) @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}} Index: test/Misc/warning-flags.c === --- test/Misc/warning-flags.c +++ test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (83): +CHECK: Warnings without flags (82): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,7 +58,6 @@ CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include CHECK-NEXT: warn_dup_category_def -CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow CHECK-NEXT: warn_expected_qualified_after_typename CHECK-NEXT: warn_extraneous_char_constant Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -739,7 +739,8 @@ "trying to recursively use %0 as superclass of %1">; def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">; def warn_undef_interface : Warning<"cannot find interface declaration for %0">; -def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">; +def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">, + InGroup>; def err_protocol_has_circular_dependency : Error< "protocol has circular dependency">; def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">; Index: test/SemaObjC/check-dup-objc-decls-1.m === --- test/SemaObjC/check-dup-objc-decls-1.m +++ test/SemaObjC/check-dup-objc-decls-1.m @@ -35,6 +35,12 @@ @protocol PP @end // expected-note {{previous definition is here}} @protocol PP @end // expected-warning {{duplicate protocol definition of 'PP'}} +@protocol DP @end +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wduplicate-protocol" +@protocol DP @end +#pragma clang diagnostic pop + @interface A(Cat) @end // expected-note {{previous definition is here}} @interface A(Cat) @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}} Index: test/Misc/warning-flags.c === --- test/Misc/warning-flags.c +++ test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (83): +CHECK: Warnings without flags (82): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,7 +58,6 @@ CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include CHECK-NEXT: warn_dup_category_def -CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow CHECK-NEXT: warn_expected_qualified_after_typename CHECK-NEXT: warn_extraneous_char_constant Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -739,7 +739,8 @@ "trying to recursively use %0 as superclass of %1">; def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">; def warn_undef_interface : Warning<"cannot find interface declaration for %0">; -def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">; +def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">, + InGroup>; def err_protocol_has_circular_dependency : Error< "protocol has circular dependency">; def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">; ___ cfe-commits mai
[clang-tools-extra] r286281 - [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.
Author: hokein Date: Tue Nov 8 13:55:13 2016 New Revision: 286281 URL: http://llvm.org/viewvc/llvm-project?rev=286281&view=rev Log: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h. Summary: When moving all code to new.h/cc, these code also will be formatted based on the given code style. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26236 Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-move/ClangMove.h clang-tools-extra/trunk/test/clang-move/Inputs/test.h clang-tools-extra/trunk/test/clang-move/move-class.cpp clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=286281&r1=286280&r2=286281&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Nov 8 13:55:13 2016 @@ -122,13 +122,13 @@ public: void InclusionDirective(clang::SourceLocation HashLoc, const clang::Token & /*IncludeTok*/, StringRef FileName, bool IsAngled, - clang::CharSourceRange /*FilenameRange*/, + clang::CharSourceRange FilenameRange, const clang::FileEntry * /*File*/, StringRef SearchPath, StringRef /*RelativePath*/, const clang::Module * /*Imported*/) override { if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) MoveTool->addIncludes(FileName, IsAngled, SearchPath, -FileEntry->getName(), SM); +FileEntry->getName(), FilenameRange, SM); } private: @@ -321,20 +321,42 @@ void ClangMoveTool::registerMatchers(ast return; } - auto InOldHeader = isExpansionInFile( - MakeAbsolutePath(OriginalRunningDirectory, Spec.OldHeader)); - auto InOldCC = - isExpansionInFile(MakeAbsolutePath(OriginalRunningDirectory, Spec.OldCC)); + auto InOldHeader = isExpansionInFile(makeAbsolutePath(Spec.OldHeader)); + auto InOldCC = isExpansionInFile(makeAbsolutePath(Spec.OldCC)); auto InOldFiles = anyOf(InOldHeader, InOldCC); auto InMovedClass = hasOutermostEnclosingClass(cxxRecordDecl(*InMovedClassNames)); + auto ForwardDecls = + cxxRecordDecl(unless(anyOf(isImplicit(), isDefinition(; + + // + // Matchers for old header + // + // Match all top-level named declarations (e.g. function, variable, enum) in + // old header, exclude forward class declarations and namespace declarations. + // + // The old header which contains only one declaration being moved and forward + // declarations is considered to be moved totally. + auto AllDeclsInHeader = namedDecl( + unless(ForwardDecls), unless(namespaceDecl()), + unless(usingDirectiveDecl()), // using namespace decl. + unless(classTemplateDecl(has(ForwardDecls))), // template forward decl. + InOldHeader, + hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(); + Finder->addMatcher(AllDeclsInHeader.bind("decls_in_header"), this); + // Match forward declarations in old header. + Finder->addMatcher(namedDecl(ForwardDecls, InOldHeader).bind("fwd_decl"), + this); + + // + // Matchers for old files, including old.h/old.cc + // // Match moved class declarations. auto MovedClass = cxxRecordDecl( InOldFiles, *InMovedClassNames, isDefinition(), hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(; Finder->addMatcher(MovedClass.bind("moved_class"), this); - // Match moved class methods (static methods included) which are defined // outside moved class declaration. Finder->addMatcher( @@ -343,6 +365,9 @@ void ClangMoveTool::registerMatchers(ast .bind("class_method"), this); + // + // Matchers for old cc + // // Match static member variable definition of the moved class. Finder->addMatcher( varDecl(InMovedClass, InOldCC, isDefinition(), isStaticDataMember()) @@ -374,16 +399,13 @@ void ClangMoveTool::registerMatchers(ast varDecl(IsOldCCStaticDefinition))) .bind("static_decls"),
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
ioeric updated this revision to Diff 77228. ioeric marked 2 inline comments as done. ioeric added a comment. - Addressed comments. https://reviews.llvm.org/D25771 Files: change-namespace/ChangeNamespace.cpp change-namespace/ChangeNamespace.h unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -313,8 +313,8 @@ "}\n" "namespace nb {\n" "using nc::SAME;\n" - "using YO = nc::SAME;\n" - "typedef nc::SAME IDENTICAL;\n" + "using YO = nd::SAME;\n" + "typedef nd::SAME IDENTICAL;\n" "void f(nd::SAME Same) {}\n" "} // namespace nb\n" "} // namespace na\n"; @@ -333,93 +333,14 @@ "namespace x {\n" "namespace y {\n" "using ::na::nc::SAME;\n" - "using YO = na::nc::SAME;\n" - "typedef na::nc::SAME IDENTICAL;\n" + "using YO = na::nd::SAME;\n" + "typedef na::nd::SAME IDENTICAL;\n" "void f(na::nd::SAME Same) {}\n" "} // namespace y\n" "} // namespace x\n"; EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } -TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "namespace na {\n" - "namespace nb {\n" - "void f() {\n" - " using glob::Glob;\n" - " Glob g;\n" - "}\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is UsingShadowDecl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() {\n" - " using ::glob::Glob;\n" - " glob::Glob g;\n" - "}\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - -TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using glob::Glob;\n" - "namespace na {\n" - "namespace nb {\n" - "void f() { Glob g; }\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is UsingShadowDecl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using glob::Glob;\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() { glob::Glob g; }\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - -TEST_F(ChangeNamespaceTest, UsingNamespace) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using namespace glob;\n" - "namespace na {\n" - "namespace nb {\n" - "void f() { Glob g; }\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is "using namespace" decl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using namespace glob;\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() { glob::Glob g; }\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - TEST_F(ChangeNamespaceTest, TypeInNestedNameSpecifier) { std::string Code = "namespace na {\n" @@ -625,6 +546,359 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOn
Re: r286243 - [clang-format] Remove (SourceManager, FileID) variants
Fixed in r286279. On Tue, Nov 8, 2016 at 10:45 AM, Galina Kistanova wrote: > Hello Daniel, > > This commit broke at least one of our builders: > http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/234 > > Please have a look at this? > > Thanks > > Galina > > On Tue, Nov 8, 2016 at 8:11 AM, Daniel Jasper via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: djasper >> Date: Tue Nov 8 10:11:33 2016 >> New Revision: 286243 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=286243&view=rev >> Log: >> [clang-format] Remove (SourceManager, FileID) variants >> >> In Format, remove the reformat() and clean() functions taking a >> SourceManager >> and a FileID. Keep the versions taking StringRef Code. >> >> - there was duplicated functionality >> - the FileID versions were harder to use >> - the clean() version is dead code anyways >> >> Patch by Krasimir Georgiev. Thank you. >> >> Modified: >> cfe/trunk/include/clang/Format/Format.h >> cfe/trunk/lib/Format/Format.cpp >> cfe/trunk/lib/Index/CommentToXML.cpp >> >> Modified: cfe/trunk/include/clang/Format/Format.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Format/Format.h?rev=286243&r1=286242&r2=286243&view=diff >> >> == >> --- cfe/trunk/include/clang/Format/Format.h (original) >> +++ cfe/trunk/include/clang/Format/Format.h Tue Nov 8 10:11:33 2016 >> @@ -794,7 +794,7 @@ llvm::Expected >> cleanupAroundReplacements(StringRef Code, const tooling::Replacements >> &Replaces, >>const FormatStyle &Style); >> >> -/// \brief Reformats the given \p Ranges in the file \p ID. >> +/// \brief Reformats the given \p Ranges in \p Code. >> /// >> /// Each range is extended on either end to its next bigger logic unit, >> i.e. >> /// everything that might influence its formatting or might be >> influenced by its >> @@ -806,31 +806,15 @@ cleanupAroundReplacements(StringRef Code >> /// If ``IncompleteFormat`` is non-null, its value will be set to true >> if any >> /// of the affected ranges were not formatted due to a non-recoverable >> syntax >> /// error. >> -tooling::Replacements reformat(const FormatStyle &Style, >> - SourceManager &SourceMgr, FileID ID, >> - ArrayRef Ranges, >> - bool *IncompleteFormat = nullptr); >> - >> -/// \brief Reformats the given \p Ranges in \p Code. >> -/// >> -/// Otherwise identical to the reformat() function using a file ID. >> tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, >> ArrayRef Ranges, >> StringRef FileName = "", >> bool *IncompleteFormat = nullptr); >> >> -/// \brief Clean up any erroneous/redundant code in the given \p Ranges >> in the >> -/// file \p ID. >> -/// >> -/// Returns the ``Replacements`` that clean up all \p Ranges in the file >> \p ID. >> -tooling::Replacements cleanup(const FormatStyle &Style, >> - SourceManager &SourceMgr, FileID ID, >> - ArrayRef Ranges); >> - >> /// \brief Clean up any erroneous/redundant code in the given \p Ranges >> in \p >> /// Code. >> /// >> -/// Otherwise identical to the cleanup() function using a file ID. >> +/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code. >> tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code, >>ArrayRef Ranges, >>StringRef FileName = ""); >> >> Modified: cfe/trunk/lib/Format/Format.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/For >> mat.cpp?rev=286243&r1=286242&r2=286243&view=diff >> >> == >> --- cfe/trunk/lib/Format/Format.cpp (original) >> +++ cfe/trunk/lib/Format/Format.cpp Tue Nov 8 10:11:33 2016 >> @@ -1719,18 +1719,6 @@ cleanupAroundReplacements(StringRef Code >>return processReplacements(Cleanup, Code, NewReplaces, Style); >> } >> >> -tooling::Replacements reformat(const FormatStyle &Style, SourceManager >> &SM, >> - FileID ID, ArrayRef >> Ranges, >> - bool *IncompleteFormat) { >> - FormatStyle Expanded = expandPresets(Style); >> - if (Expanded.DisableFormat) >> -return tooling::Replacements(); >> - >> - Environment Env(SM, ID, Ranges); >> - Formatter Format(Env, Expanded, IncompleteFormat); >> - return Format.process(); >> -} >> - >> tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, >> ArrayRef Ranges, >> StringRef FileName, bool >> *IncompleteFormat) { >> @@ -1760,13 +1748,6 @@ tooling::Replacements reformat(const For >>return Format.process(); >> } >
[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.
alexfh added a comment. > and generally frowned upon in many codebases (e.g. LLVM) Should it still be a part of google/? The old check was enforcing a part of the Google C++ style guide, but the new one seems to be somewhat broader. Am I mistaken? https://reviews.llvm.org/D23130 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286279 - Remove FormatContext from libClang as it is now unused.
Author: djasper Date: Tue Nov 8 13:47:19 2016 New Revision: 286279 URL: http://llvm.org/viewvc/llvm-project?rev=286279&view=rev Log: Remove FormatContext from libClang as it is now unused. Modified: cfe/trunk/include/clang/Index/CommentToXML.h cfe/trunk/lib/Index/CommentToXML.cpp Modified: cfe/trunk/include/clang/Index/CommentToXML.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=286279&r1=286278&r2=286279&view=diff == --- cfe/trunk/include/clang/Index/CommentToXML.h (original) +++ cfe/trunk/include/clang/Index/CommentToXML.h Tue Nov 8 13:47:19 2016 @@ -22,12 +22,7 @@ class HTMLTagComment; } namespace index { -class SimpleFormatContext; - class CommentToXMLConverter { - std::unique_ptr FormatContext; - unsigned FormatInMemoryUniqueId; - public: CommentToXMLConverter(); ~CommentToXMLConverter(); Modified: cfe/trunk/lib/Index/CommentToXML.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=286279&r1=286278&r2=286279&view=diff == --- cfe/trunk/lib/Index/CommentToXML.cpp (original) +++ cfe/trunk/lib/Index/CommentToXML.cpp Tue Nov 8 13:47:19 2016 @@ -8,7 +8,6 @@ //===--===// #include "clang/Index/CommentToXML.h" -#include "SimpleFormatContext.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" #include "clang/AST/Comment.h" @@ -531,12 +530,8 @@ public: CommentASTToXMLConverter(const FullComment *FC, SmallVectorImpl &Str, const CommandTraits &Traits, - const SourceManager &SM, - SimpleFormatContext &SFC, - unsigned FUID) : - FC(FC), Result(Str), Traits(Traits), SM(SM), - FormatRewriterContext(SFC), - FormatInMemoryUniqueId(FUID) { } + const SourceManager &SM) : + FC(FC), Result(Str), Traits(Traits), SM(SM) { } // Inline content. void visitTextComment(const TextComment *C); @@ -574,8 +569,6 @@ private: const CommandTraits &Traits; const SourceManager &SM; - SimpleFormatContext &FormatRewriterContext; - unsigned FormatInMemoryUniqueId; }; void getSourceTextOfDeclaration(const DeclInfo *ThisDecl, @@ -596,18 +589,13 @@ void CommentASTToXMLConverter::formatTex StringRef StringDecl(Declaration.c_str(), Declaration.size()); // Formatter specific code. - // Form a unique in memory buffer name. - SmallString<128> Filename; - Filename += "xmldecl"; - Filename += llvm::utostr(FormatInMemoryUniqueId); - Filename += ".xd"; unsigned Offset = 0; unsigned Length = Declaration.size(); bool IncompleteFormat = false; tooling::Replacements Replaces = reformat(format::getLLVMStyle(), StringDecl, - tooling::Range(Offset, Length), Filename, &IncompleteFormat); + tooling::Range(Offset, Length), "xmldecl.xd", &IncompleteFormat); auto FormattedStringDecl = applyAllReplacements(StringDecl, Replaces); if (static_cast(FormattedStringDecl)) { Declaration = *FormattedStringDecl; @@ -1127,7 +1115,7 @@ void CommentASTToXMLConverter::appendToR Result << "]]>"; } -CommentToXMLConverter::CommentToXMLConverter() : FormatInMemoryUniqueId(0) {} +CommentToXMLConverter::CommentToXMLConverter() {} CommentToXMLConverter::~CommentToXMLConverter() {} void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC, @@ -1149,14 +1137,7 @@ void CommentToXMLConverter::convertHTMLT void CommentToXMLConverter::convertCommentToXML(const FullComment *FC, SmallVectorImpl &XML, const ASTContext &Context) { - if (!FormatContext || (FormatInMemoryUniqueId % 1000) == 0) { -// Create a new format context, or re-create it after some number of -// iterations, so the buffers don't grow too large. -FormatContext.reset(new SimpleFormatContext(Context.getLangOpts())); - } - CommentASTToXMLConverter Converter(FC, XML, Context.getCommentCommandTraits(), - Context.getSourceManager(), *FormatContext, - FormatInMemoryUniqueId++); + Context.getSourceManager()); Converter.visit(FC); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
danalbert added a comment. > It is defines with a value of 0. This allows you to actually do something > better, IMO. Can we stick with undefined? That's historically how things have been, and I'm sure there's code out there depending on that (I had actually written a test that would depend on this a few weeks ago). If we do want to do this, we're going to have to redo the legacy headers as they current define this unconditionally (`-Wmacro-redefined`). I suppose we probably don't have to worry about people using a new clang with an old NDK, so we could just change that, but I don't really see an argument for setting it to zero. https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r285946 - Using release to free memory is at best confusing -- one would expect
Ah, I see - your follow up in 285950 mentions that this unique_ptr was always null, so none of it really mattered/did anything. On Tue, Nov 8, 2016 at 11:42 AM David Blaikie wrote: > On Thu, Nov 3, 2016 at 10:52 AM Chandler Carruth via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > > Author: chandlerc > Date: Thu Nov 3 12:42:32 2016 > New Revision: 285946 > > URL: http://llvm.org/viewvc/llvm-project?rev=285946&view=rev > Log: > Using release to free memory is at best confusing -- one would expect > that its result is in fact used. Instead, use reset. > > > Perhaps I'm missing something/perhaps you could provide some more > context/detail: release() wouldn't've free'd memory, it would've leaked it, > right? (seems more than just confusing, but actually wrong - so I'm > confused by your description) > > > > This was pointed out by PVS-Studio. > > Modified: > cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp > > Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285946&r1=285945&r2=285946&view=diff > > == > --- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original) > +++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov 3 > 12:42:32 2016 > @@ -43,7 +43,7 @@ VerifyDiagnosticConsumer::~VerifyDiagnos >assert(!CurrentPreprocessor && "CurrentPreprocessor should be > invalid!"); >SrcManager = nullptr; >CheckDiagnostics(); > - Diags.takeClient().release(); > + Diags.takeClient().reset(); > } > > #ifndef NDEBUG > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.
ddcc added a comment. Even though there isn't a performance difference, I think it is semantically clearer since it is explicit that the value is unneeded. The interface of ProgramState provides a `contains()` function that calls into `Contains()` of the underlying partial traits as part of its implementation. That function is present for `ImmutableSet` and `ImmutableList`, so it is inconsistent that `ImmutableMap` doesn't have it. I've been working on a Z3 constraint backend that uses this, though the implementation has been trickier than I expected. https://reviews.llvm.org/D26373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r285946 - Using release to free memory is at best confusing -- one would expect
On Thu, Nov 3, 2016 at 10:52 AM Chandler Carruth via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: chandlerc > Date: Thu Nov 3 12:42:32 2016 > New Revision: 285946 > > URL: http://llvm.org/viewvc/llvm-project?rev=285946&view=rev > Log: > Using release to free memory is at best confusing -- one would expect > that its result is in fact used. Instead, use reset. > Perhaps I'm missing something/perhaps you could provide some more context/detail: release() wouldn't've free'd memory, it would've leaked it, right? (seems more than just confusing, but actually wrong - so I'm confused by your description) > > This was pointed out by PVS-Studio. > > Modified: > cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp > > Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285946&r1=285945&r2=285946&view=diff > > == > --- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original) > +++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov 3 > 12:42:32 2016 > @@ -43,7 +43,7 @@ VerifyDiagnosticConsumer::~VerifyDiagnos >assert(!CurrentPreprocessor && "CurrentPreprocessor should be > invalid!"); >SrcManager = nullptr; >CheckDiagnostics(); > - Diags.takeClient().release(); > + Diags.takeClient().reset(); > } > > #ifndef NDEBUG > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14274: Add alloc_size attribute to clang
george.burgess.iv updated this revision to Diff 77222. george.burgess.iv added a comment. Rebased and made the `__builtin_object_size` code a tiny bit cleaner. The blocks bugfix I mentioned will be up as a separate review in a few minutes. :) https://reviews.llvm.org/D14274 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/AST/ExprConstant.cpp lib/CodeGen/CGCall.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/alloc-size.c test/CodeGenCXX/alloc-size.cpp test/CodeGenCXX/global-init.cpp test/Sema/alloc-size.c test/SemaCXX/constant-expression-cxx11.cpp Index: test/SemaCXX/constant-expression-cxx11.cpp === --- test/SemaCXX/constant-expression-cxx11.cpp +++ test/SemaCXX/constant-expression-cxx11.cpp @@ -1156,7 +1156,7 @@ constexpr int m2b = const_cast(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}} struct T { int n; }; -const T t = { 42 }; // expected-note {{declared here}} +const T t = { 42 }; constexpr int f(volatile int &&r) { return r; // expected-note {{read of volatile-qualified type 'volatile int'}} @@ -1168,7 +1168,7 @@ int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}} int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}} int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}} - int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}} + int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}} }; } Index: test/Sema/alloc-size.c === --- /dev/null +++ test/Sema/alloc-size.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 %s -verify + +void *fail1(int a) __attribute__((alloc_size)); //expected-error{{'alloc_size' attribute takes at least 1 argument}} +void *fail2(int a) __attribute__((alloc_size())); //expected-error{{'alloc_size' attribute takes at least 1 argument}} + +void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}} +void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}} + +void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}} +void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}} + +void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}} +void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}} + +int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}} + +int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to non-K&R-style functions}} + +void *fail11(void *a) __attribute__((alloc_size(1))); //expected-error{{'alloc_size' attribute argument may only refer to a function parameter of integer type}} + +void *fail12(int a) __attribute__((alloc_size("abc"))); //expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}} +void *fail12(int a) __attribute__((alloc_size(1, "abc"))); //expected-error{{'alloc_size' attribute requires parameter 2 to be an integer constant}} +void *fail13(int a) __attribute__((alloc_size(1U<<31))); //expected-error{{integer constant expression evaluates to value 2147483648 that cannot be represented in a 32-bit signed integer type}} Index: test/CodeGenCXX/global-init.cpp === --- test/CodeGenCXX/global-init.cpp +++ test/CodeGenCXX/global-init.cpp @@ -18,9 +18,6 @@ // CHECK: @__dso_handle = external global i8 // CHECK: @c = global %struct.C zeroinitializer, align 8 -// It's okay if we ever implement the IR-generation optimization to remove this. -// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8], [7 x i8]* - // PR6205: The casts should not require global initializers // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C" // CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* getelementptr inbounds (%"struct.PR5974::C", %"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0) Index: test/CodeGenCXX/alloc-size.cpp === --- /dev/null +++ test/CodeGenCXX/alloc-size.cpp @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -O0 %s -o - 2>&1 -std=c++11 | FileCheck %s + +namespace templates { +void *my_malloc(int
Re: r284272 - Implement no_sanitize_address for global vars
On Fri, Oct 14, 2016 at 3:55 PM, Douglas Katzman via cfe-commits wrote: > Author: dougk > Date: Fri Oct 14 14:55:09 2016 > New Revision: 284272 > > URL: http://llvm.org/viewvc/llvm-project?rev=284272&view=rev > Log: > Implement no_sanitize_address for global vars > > Modified: > cfe/trunk/include/clang/Basic/Attr.td > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/include/clang/Sema/AttributeList.h > cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > cfe/trunk/test/CodeGen/asan-globals.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp > > Modified: cfe/trunk/include/clang/Basic/Attr.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=284272&r1=284271&r2=284272&view=diff > == > --- cfe/trunk/include/clang/Basic/Attr.td (original) > +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 > @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl > def NoSanitize : InheritableAttr { >let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >let Args = [VariadicStringArgument<"Sanitizers">]; > - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; > + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag, > +"ExpectedFunctionMethodOrGlobalVar">; The down-side to this change is that now every no_sanitize attribute now appertains to a global variable, as far as its subjects go, but really only the address sanitizer applies to global variables. I'm not certain there's much to be done for it, but this divergence is unfortunate. For instance, this means that misuse of no_sanitizer for thread may tell the user the attribute appertains to global variables, and when they fix the misuse on a global variable, they're told "just kidding, this doesn't apply to global variables." >let Documentation = [NoSanitizeDocs]; >let AdditionalMembers = [{ > SanitizerMask getMask() const { > @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr > GCC<"no_sanitize_address">, > GCC<"no_sanitize_thread">, > GNU<"no_sanitize_memory">]; > - let Subjects = SubjectList<[Function], ErrorDiag>; > + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, > +"ExpectedFunctionGlobalVarMethodOrProperty">; This new diagnostic looks incorrect to me -- the subject list does not list methods or properties, for instance. >let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, > NoSanitizeMemoryDocs]; >let ASTNode = 0; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284272&r1=284271&r2=284272&view=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 14:55:09 > 2016 > @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >"|functions, methods and blocks" >"|functions, methods, and classes" >"|functions, methods, and parameters" > + "|functions, methods, and global variables" >"|classes" >"|enums" >"|variables" > > Modified: cfe/trunk/include/clang/Sema/AttributeList.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=284272&r1=284271&r2=284272&view=diff > == > --- cfe/trunk/include/clang/Sema/AttributeList.h (original) > +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016 > @@ -891,6 +891,7 @@ enum AttributeDeclKind { >ExpectedFunctionMethodOrBlock, >ExpectedFunctionMethodOrClass, >ExpectedFunctionMethodOrParameter, > + ExpectedFunctionMethodOrGlobalVar, >ExpectedClass, >ExpectedEnum, >ExpectedVariable, > > Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp?rev=284272&r1=284271&r2=284272&view=diff > == > --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) > +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 > @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS >std::string QualName; >llvm::raw_string_ostream OS(QualName); >D.printQualifiedName(OS); > - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit); > + > + bool IsBlacklisted = false; > + for (auto Attr : D.specific_attrs()) This should be const auto * and probably not use Attr (since that's a type name). > +
[PATCH] D26236: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.
hokein updated this revision to Diff 77223. hokein marked 2 inline comments as done. hokein added a comment. Update test to check old header. https://reviews.llvm.org/D26236 Files: clang-move/ClangMove.cpp clang-move/ClangMove.h test/clang-move/Inputs/test.h test/clang-move/move-class.cpp unittests/clang-move/ClangMoveTests.cpp Index: unittests/clang-move/ClangMoveTests.cpp === --- unittests/clang-move/ClangMoveTests.cpp +++ unittests/clang-move/ClangMoveTests.cpp @@ -173,24 +173,25 @@ "} // namespace a\n"; std::map -runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec) { +runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec, + const char *const Header = TestHeader, + const char *const CC = TestCC) { clang::RewriterTestContext Context; std::map FileToFileID; std::vector> FileToSourceText = { - {TestHeaderName, TestHeader}, {TestCCName, TestCC}}; + {TestHeaderName, Header}, {TestCCName, CC}}; auto CreateFiles = [&FileToSourceText, &Context, &FileToFileID]( llvm::StringRef Name, llvm::StringRef Code) { if (!Name.empty()) { - FileToSourceText.emplace_back(Name, Code); FileToFileID[Name] = Context.createInMemoryFile(Name, Code); } }; CreateFiles(Spec.NewCC, ""); CreateFiles(Spec.NewHeader, ""); - CreateFiles(Spec.OldHeader, TestHeader); - CreateFiles(Spec.OldCC, TestCC); + CreateFiles(Spec.OldHeader, Header); + CreateFiles(Spec.OldCC, CC); std::map FileToReplacements; llvm::SmallString<128> InitialDirectory; @@ -201,7 +202,7 @@ Spec, FileToReplacements, InitialDirectory.str(), "LLVM"); tooling::runToolOnCodeWithArgs( - Factory->create(), TestCC, {"-std=c++11", "-fparse-all-comments"}, + Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"}, TestCCName, "clang-move", std::make_shared(), FileToSourceText); formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm"); @@ -263,6 +264,79 @@ EXPECT_EQ(0u, Results.size()); } +TEST(ClangMove, MoveAll) { + std::vector TestHeaders = { +"class A {\npublic:\n int f();\n};", +// forward declaration. +"class B;\nclass A {\npublic:\n int f();\n};", +// template forward declaration. +"template class B;\nclass A {\npublic:\n int f();\n};", +"namespace a {}\nclass A {\npublic:\n int f();\n};", +"namespace a {}\nusing namespace a;\nclass A {\npublic:\n int f();\n};", + }; + const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }"; + move::ClangMoveTool::MoveDefinitionSpec Spec; + Spec.Names.push_back("A"); + Spec.OldHeader = "foo.h"; + Spec.OldCC = "foo.cc"; + Spec.NewHeader = "new_foo.h"; + Spec.NewCC = "new_foo.cc"; + for (const auto& Header : TestHeaders) { +auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code); +EXPECT_EQ(Header, Results[Spec.NewHeader]); +EXPECT_EQ("", Results[Spec.OldHeader]); +EXPECT_EQ("", Results[Spec.OldCC]); + } +} + +TEST(ClangMove, MoveAllMultipleClasses) { + move::ClangMoveTool::MoveDefinitionSpec Spec; + std::vector TestHeaders = { +"class C;\nclass A {\npublic:\n int f();\n};\nclass B {};", +"class C;\nclass B;\nclass A {\npublic:\n int f();\n};\nclass B {};", + }; + const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }"; + Spec.Names = {std::string("A"), std::string("B")}; + Spec.OldHeader = "foo.h"; + Spec.OldCC = "foo.cc"; + Spec.NewHeader = "new_foo.h"; + Spec.NewCC = "new_foo.cc"; + for (const auto& Header : TestHeaders) { +auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code); +EXPECT_EQ(Header, Results[Spec.NewHeader]); +EXPECT_EQ("", Results[Spec.OldHeader]); +EXPECT_EQ("", Results[Spec.OldCC]); + } +} + +TEST(ClangMove, DontMoveAll) { + const char ExpectedHeader[] = "#ifndef NEW_FOO_H\n" +"#define NEW_FOO_H\n" +"class A {\npublic:\n int f();\n};\n" +"#endif // NEW_FOO_H\n"; + const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }"; + std::vector TestHeaders = { +"typedef int Int;\nclass A {\npublic:\n int f();\n};", +"using Int=int;\nclass A {\npublic:\n int f();\n};", +"class B {};\nclass A {\npublic:\n int f();\n};", +"void f() {};\nclass A {\npublic:\n int f();\n};", +"enum Color { RED };\nclass A {\npublic:\n int f();\n};", + }; + move::ClangMoveTool::MoveDefinitionSpec Spec; + Spec.Names.push_back("A"); + Spec.OldHeader = "foo.h"; + Spec.OldCC = "foo.cc"; + Spec.NewHeader = "new_foo.h"; + Spec.NewCC = "new_foo.cc"; + for (const auto& Header : TestHeaders) { +auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code); +EXPECT_EQ(ExpectedHeader, Results[Spec.NewHeader]); +// The expected old header should not contain class A
[PATCH] D26196: Add support for non-zero null pointers
yaxunl added inline comments. Comment at: lib/CodeGen/CodeGenTypes.cpp:743 +auto NullPtr = CGM.getNullPtr(LLPT, T); +return isa(NullPtr); + } tony-tye wrote: > Is this correct if the target does not represent a NULL pointer as the > address with value 0? Or should this be asking the target if this null > pointer is represented by an address value of 0? Currently this is correct even if the target does not represent a null pointer as address with value 0. The purpose of this line is to check if NullPtr has zero value at compile time. In LLVM checking whether a pointer having zero value at compile time is by checking if it is ConstantPointerNull. However, if in the future LLVM no longer assumes ConstantPointerNull having zero value, then this will become incorrect. To be future proof, I think I'd better add a member function isPtrZero to TargetCodeGenInfo and use it to check if a pointer has zero value. https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
eugenis added a comment. This is a good change, but I don't think it is the right fix for PR30940. Instead of handling this in the NDK, we should change *::getIRStackGuard to fallback to __stack_chk_guard when targeting an old version. https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284272 - Implement no_sanitize_address for global vars
oh, sorry for missing this email. I'll say "no" - I was hoping you'd audit it! jyknight looked at it and gave me the suggestion to fail the attribute parsing if, in the non-deprecated syntax, _any_ of the no_sanitize modifiers are inapplicable to global vars. On Tue, Oct 25, 2016 at 7:19 PM, Kostya Serebryany wrote: > ping > > On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryany wrote: > >> Did you code-review this? >> (sorry if I missed it) >> >> On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: dougk >>> Date: Fri Oct 14 14:55:09 2016 >>> New Revision: 284272 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=284272&view=rev >>> Log: >>> Implement no_sanitize_address for global vars >>> >>> Modified: >>> cfe/trunk/include/clang/Basic/Attr.td >>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> cfe/trunk/include/clang/Sema/AttributeList.h >>> cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp >>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp >>> cfe/trunk/test/CodeGen/asan-globals.cpp >>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp >>> cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp >>> >>> Modified: cfe/trunk/include/clang/Basic/Attr.td >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Basic/Attr.td?rev=284272&r1=284271&r2=284272&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/Attr.td (original) >>> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 >>> @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl >>> def NoSanitize : InheritableAttr { >>>let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >>>let Args = [VariadicStringArgument<"Sanitizers">]; >>> - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; >>> + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], >>> ErrorDiag, >>> +"ExpectedFunctionMethodOrGlobalVar">; >>>let Documentation = [NoSanitizeDocs]; >>>let AdditionalMembers = [{ >>> SanitizerMask getMask() const { >>> @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr >>> GCC<"no_sanitize_address">, >>> GCC<"no_sanitize_thread">, >>> GNU<"no_sanitize_memory">]; >>> - let Subjects = SubjectList<[Function], ErrorDiag>; >>> + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, >>> +"ExpectedFunctionGlobalVarMethodOrProperty">; >>>let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, >>> NoSanitizeMemoryDocs]; >>>let ASTNode = 0; >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Basic/DiagnosticSemaKinds.td?rev=284272&r1=284271&r2=284272&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 >>> 14:55:09 2016 >>> @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >>>"|functions, methods and blocks" >>>"|functions, methods, and classes" >>>"|functions, methods, and parameters" >>> + "|functions, methods, and global variables" >>>"|classes" >>>"|enums" >>>"|variables" >>> >>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Sema/AttributeList.h?rev=284272&r1=284271&r2=284272&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original) >>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 >>> 2016 >>> @@ -891,6 +891,7 @@ enum AttributeDeclKind { >>>ExpectedFunctionMethodOrBlock, >>>ExpectedFunctionMethodOrClass, >>>ExpectedFunctionMethodOrParameter, >>> + ExpectedFunctionMethodOrGlobalVar, >>>ExpectedClass, >>>ExpectedEnum, >>>ExpectedVariable, >>> >>> Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Sa >>> nitizerMetadata.cpp?rev=284272&r1=284271&r2=284272&view=diff >>> >>> == >>> --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) >>> +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 >>> @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS >>>std::string QualName; >>>llvm::raw_string_ostream OS(QualName); >>>D.printQualifiedName(OS); >>> - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), >>> IsDynInit); >>> + >>> + bool IsBlacklisted = false; >>> + for (auto Attr : D.specific_attrs()) >>> +if (Attr->getMask() & Sani
[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.
aaron.ballman added inline comments. Comment at: clang-tidy/google/GlobalNamesCheck.cpp:77 +} +diag( +D->getLocStart(), Is this formatting that clang-format generates? Comment at: test/clang-tidy/google-global-names.cpp:13-14 +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'i' declared in the global namespace +extern int ii = 0; +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'ii' declared in the global namespace + aaron.ballman wrote: > bkramer wrote: > > aaron.ballman wrote: > > > This strikes me as being intentional enough to warrant not diagnosing > > > because of the `extern` keyword. > > The only case I see where this pattern is valuable is interfacing with C > > code. Not sure yet if we want to allow that or enforce extern "C" instead. > > Ideas? > > > > an extern global in the global namespace still feels like something we > > should warn on :| > Yet externs in the global namespace do happen for valid reasons (such as not > breaking ABIs by putting the extern definition into a namespace or changing > the language linkage) -- I'm trying to think of ways we can allow the user to > silence this diagnostic in those cases. I feel like in cases where the user > writes "extern", they're explicitly specifying their intent and that doesn't > seem like a case to warn them about, in some regards. It would give us two > ways to silence the diagnostic (well, three, but two are morally close > enough): > > 1) Put it into a namespace > 2) Slap `extern` on it if it is global for C++ compatibility (such as ABIs) > 3) Slap `extern "C"` on it if it global for C compatibility > > I suppose we could require `extern "C++"` instead of `extern`, but I don't > think that's a particularly common use of the language linkage specifier? I still think that a user explicitly writing 'extern' is expecting external linkage and all that goes along with it. Comment at: test/clang-tidy/google-global-names.cpp:18 +extern "C" void g(); +extern "C" void h() {} + Can you also add a test: ``` extern "C++" void h2() {} ``` I believe this will diagnose, but whether it should diagnose or not, I'm less certain of. https://reviews.llvm.org/D23130 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26385: Define __ANDROID_API__ for all Android builds.
srhines added a comment. In https://reviews.llvm.org/D26385#589534, @danalbert wrote: > > This macro (along with ANDROID) should always be defined for Android > > targets. > > What if only `arm-linux-androideabi` (without a version) is specified? We > should be falling back to the old behavior (don't defined `__ANDROID_API__`) > when that happens since that's what every build system out there is going to > be relying on. It is defines with a value of 0. This allows you to actually do something better, IMO. You can now handle old or new NDKs by seeing if this is defined to a special level, or 0 for no level, or not defined at all (old toolchain, build rules, etc.). Does that make sense? https://reviews.llvm.org/D26385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
hokein added inline comments. Comment at: change-namespace/ChangeNamespace.cpp:233 + const DeclContext *DeclCtx, SourceLocation Loc) { + return SM.isBeforeInTranslationUnit(SM.getSpellingLoc(D->getLocation()), + SM.getSpellingLoc(Loc)) && I will create two variables for `SM.getSpellingLoc(D->getLocation())` and `SM.getSpellingLoc(Loc)` to avoid redundant function call. Comment at: change-namespace/ChangeNamespace.cpp:569 +StringRef FromDeclNameRef = FromDeclName; +if (FromDeclNameRef.consume_front(UsingNamespace->getNominatedNamespace() + ->getQualifiedNameAsString())) { Shouldn't we check whether the using namespace decl is visible here? https://reviews.llvm.org/D25771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits