[PATCH] D12832: [Driver] Added support for Windows 10 SDK
ikudrin created this revision. ikudrin added reviewers: ruiu, rnk. ikudrin added a subscriber: cfe-commits. With Windows 10 SDK, Include and Lib directories now contain an additional subfolder with the name that corresponds to the full version of the SDK, for example: - C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\um - C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64 http://reviews.llvm.org/D12832 Files: cfe/trunk/lib/Driver/MSVCToolChain.cpp cfe/trunk/lib/Driver/ToolChains.h Index: cfe/trunk/lib/Driver/ToolChains.h === --- cfe/trunk/lib/Driver/ToolChains.h +++ cfe/trunk/lib/Driver/ToolChains.h @@ -838,7 +838,9 @@ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool getWindowsSDKDir(std::string &path, int &major, int &minor) const; + bool getWindowsSDKDir(std::string &path, int &major, +std::string &windowsSDKIncludeVersion, +std::string &windowsSDKLibVersion) const; bool getWindowsSDKLibraryPath(std::string &path) const; /// \brief Check if Universal CRT should be used if available bool useUniversalCRT(std::string &visualStudioDir) const; @@ -856,7 +858,9 @@ void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const std::string &folder, - const char *subfolder) const; + const Twine &subfolder1, + const Twine &subfolder2 = "", + const Twine &subfolder3 = "") const; Tool *buildLinker() const override; Tool *buildAssembler() const override; Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp === --- cfe/trunk/lib/Driver/MSVCToolChain.cpp +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp @@ -220,27 +220,80 @@ } } +// Find the most recent version of Universal CRT or Windows 10 SDK. +// vcvarsqueryregistry.bat from Visual Studio 2015 sorts entries in the include +// directory by name and uses the last one of the list. +// So we compare entry names lexicographically to find the greatest one. +static bool getWindows10SDKVersion(const std::string &SDKPath, + std::string &SDKVersion) { + SDKVersion.clear(); + + std::error_code EC; + llvm::SmallString<128> IncludePath(SDKPath); + llvm::sys::path::append(IncludePath, "Include"); + for (llvm::sys::fs::directory_iterator DirIt(IncludePath, EC), DirEnd; + DirIt != DirEnd && !EC; DirIt.increment(EC)) { +if (!llvm::sys::fs::is_directory(DirIt->path())) + continue; +const StringRef CandidateName = llvm::sys::path::filename(DirIt->path()); +if (CandidateName > SDKVersion) + SDKVersion = CandidateName; + } + + return !SDKVersion.empty(); +} + /// \brief Get Windows SDK installation directory. -bool MSVCToolChain::getWindowsSDKDir(std::string &path, int &major, - int &minor) const { - std::string sdkVersion; +bool MSVCToolChain::getWindowsSDKDir(std::string &Path, int &Major, + std::string &WindowsSDKIncludeVersion, + std::string &WindowsSDKLibVersion) const { + std::string RegistrySDKVersion; // Try the Windows registry. - bool hasSDKDir = getSystemRegistryString( - "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION", - "InstallationFolder", path, &sdkVersion); - if (!sdkVersion.empty()) -std::sscanf(sdkVersion.c_str(), "v%d.%d", &major, &minor); - return hasSDKDir && !path.empty(); + if (!getSystemRegistryString( + "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION", + "InstallationFolder", Path, &RegistrySDKVersion)) +return false; + if (Path.empty() || RegistrySDKVersion.empty()) +return false; + + WindowsSDKIncludeVersion.clear(); + WindowsSDKLibVersion.clear(); + Major = 0; + std::sscanf(RegistrySDKVersion.c_str(), "v%d.", &Major); + if (Major > 7 && Major < 10) { +// Windows SDK 8.x installs libraries in a folder whose names depend on the +// version of the OS you're targeting. By default choose the newest, which +// usually corresponds to the version of the OS you've installed the SDK on. +const char *Tests[] = {"winv6.3", "win8", "win7"}; +for (const char *Test : Tests) { + llvm::SmallString<128> TestPath(Path); + llvm::sys::path::append(TestPath, "Lib", Test); + if (llvm::sys::fs::exists(TestPath.c_str())) { +WindowsSDKLibVersion = Test; +break; + } +} +if (WindowsSDKLibVersion.empty()) + return false; + } + else { +if (!getWindows10SDKVersion(Path, WindowsSDKIncludeVersion)) + return false
Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.
Late to the party, but I wanted to ask: is there a way to indicate to the checker that we really *did* mean sizeof()? I think I've stumbled over code in our code base that uses sizeof(container) to report memory usage statistics and it seems valid, so it'd be nice if this checker could be silenced on a case-by-case basis. Thanks, - Kim On Sat, Sep 12, 2015 at 12:09 AM, Alexander Kornienko via cfe-commits wrote: > Indeed. But this has been fixed before I could get to it. > > > On Thu, Sep 10, 2015 at 10:47 PM, Aaron Ballman via cfe-commits > wrote: >> >> aaron.ballman added a comment. >> >> This appears to have broken one of the bots: >> >> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/15065 >> >> >> http://reviews.llvm.org/D12759 >> >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.
I've also found a bunch of similar cases in our codebase, and I'm trying to figure out whether the pattern can be narrowed down to just dangerous cases. If we don't find a way to do so, we'll probably have to resort to "// NOLINT" to shut clang-tidy up. On 13 Sep 2015 10:52, "Kim Gräsman" wrote: > Late to the party, but I wanted to ask: is there a way to indicate to > the checker that we really *did* mean sizeof()? > > I think I've stumbled over code in our code base that uses > sizeof(container) to report memory usage statistics and it seems > valid, so it'd be nice if this checker could be silenced on a > case-by-case basis. > > Thanks, > - Kim > > On Sat, Sep 12, 2015 at 12:09 AM, Alexander Kornienko via cfe-commits > wrote: > > Indeed. But this has been fixed before I could get to it. > > > > > > On Thu, Sep 10, 2015 at 10:47 PM, Aaron Ballman via cfe-commits > > wrote: > >> > >> aaron.ballman added a comment. > >> > >> This appears to have broken one of the bots: > >> > >> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/15065 > >> > >> > >> http://reviews.llvm.org/D12759 > >> > >> > >> > >> ___ > >> cfe-commits mailing list > >> cfe-commits@lists.llvm.org > >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > > > > > ___ > > cfe-commits mailing list > > cfe-commits@lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12835: [X86][SSE] Replace 128-bit SSE41 PMOVSX intrinsics with native IR
RKSimon created this revision. RKSimon added reviewers: ab, qcolombet, craig.topper, spatel. RKSimon added a subscriber: cfe-commits. RKSimon set the repository for this revision to rL LLVM. 128-bit vector integer sign extensions correctly lower to the pmovsx instructions even for debug builds. This patch removes the builtins and reimplements the _mm_cvtepi*_epi* intrinsics using __builtin_shufflevector (to extract the bottom most subvector) and __builtin_convertvector (to actually perform the sign extension). After this I'll add a patch for the removal/upgrade of the pmovsx intrinsics on the llvm side. Note: AVX2 256-bit vector integer sign extensions currently don't lower correctly in debug builds if they need the __builtin_shufflevector stage (although I could add the ones that don't need this straightaway). Repository: rL LLVM http://reviews.llvm.org/D12835 Files: include/clang/Basic/BuiltinsX86.def lib/Headers/smmintrin.h test/CodeGen/builtins-x86.c test/CodeGen/sse41-builtins.c Index: test/CodeGen/sse41-builtins.c === --- test/CodeGen/sse41-builtins.c +++ test/CodeGen/sse41-builtins.c @@ -86,42 +86,42 @@ __m128i test_mm_cvtepi8_epi16(__m128i a) { // CHECK-LABEL: test_mm_cvtepi8_epi16 - // CHECK: call <8 x i16> @llvm.x86.sse41.pmovsxbw(<16 x i8> {{.*}}) + // CHECK: sext <8 x i8> {{.*}} to <8 x i16> // CHECK-ASM: pmovsxbw %xmm{{.*}}, %xmm{{.*}} return _mm_cvtepi8_epi16(a); } __m128i test_mm_cvtepi8_epi32(__m128i a) { // CHECK-LABEL: test_mm_cvtepi8_epi32 - // CHECK: call <4 x i32> @llvm.x86.sse41.pmovsxbd(<16 x i8> {{.*}}) + // CHECK: sext <4 x i8> {{.*}} to <4 x i32> // CHECK-ASM: pmovsxbd %xmm{{.*}}, %xmm{{.*}} return _mm_cvtepi8_epi32(a); } __m128i test_mm_cvtepi8_epi64(__m128i a) { // CHECK-LABEL: test_mm_cvtepi8_epi64 - // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxbq(<16 x i8> {{.*}}) + // CHECK: sext <2 x i8> {{.*}} to <2 x i64> // CHECK-ASM: pmovsxbq %xmm{{.*}}, %xmm{{.*}} return _mm_cvtepi8_epi64(a); } __m128i test_mm_cvtepi16_epi32(__m128i a) { // CHECK-LABEL: test_mm_cvtepi16_epi32 - // CHECK: call <4 x i32> @llvm.x86.sse41.pmovsxwd(<8 x i16> {{.*}}) + // CHECK: sext <4 x i16> {{.*}} to <4 x i32> // CHECK-ASM: pmovsxwd %xmm{{.*}}, %xmm{{.*}} return _mm_cvtepi16_epi32(a); } __m128i test_mm_cvtepi16_epi64(__m128i a) { // CHECK-LABEL: test_mm_cvtepi16_epi64 - // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxwq(<8 x i16> {{.*}}) + // CHECK: sext <2 x i16> {{.*}} to <2 x i64> // CHECK-ASM: pmovsxwq %xmm{{.*}}, %xmm{{.*}} return _mm_cvtepi16_epi64(a); } __m128i test_mm_cvtepi32_epi64(__m128i a) { // CHECK-LABEL: test_mm_cvtepi32_epi64 - // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxdq(<4 x i32> {{.*}}) + // CHECK: sext <2 x i32> {{.*}} to <2 x i64> // CHECK-ASM: pmovsxdq %xmm{{.*}}, %xmm{{.*}} return _mm_cvtepi32_epi64(a); } Index: test/CodeGen/builtins-x86.c === --- test/CodeGen/builtins-x86.c +++ test/CodeGen/builtins-x86.c @@ -372,12 +372,6 @@ tmp_V4i = __builtin_ia32_pminsd128(tmp_V4i, tmp_V4i); tmp_V4i = __builtin_ia32_pminud128(tmp_V4i, tmp_V4i); tmp_V8s = __builtin_ia32_pminuw128(tmp_V8s, tmp_V8s); - tmp_V4i = __builtin_ia32_pmovsxbd128(tmp_V16c); - tmp_V2LLi = __builtin_ia32_pmovsxbq128(tmp_V16c); - tmp_V8s = __builtin_ia32_pmovsxbw128(tmp_V16c); - tmp_V2LLi = __builtin_ia32_pmovsxdq128(tmp_V4i); - tmp_V4i = __builtin_ia32_pmovsxwd128(tmp_V8s); - tmp_V2LLi = __builtin_ia32_pmovsxwq128(tmp_V8s); tmp_V4i = __builtin_ia32_pmovzxbd128(tmp_V16c); tmp_V2LLi = __builtin_ia32_pmovzxbq128(tmp_V16c); tmp_V8s = __builtin_ia32_pmovzxbw128(tmp_V16c); Index: lib/Headers/smmintrin.h === --- lib/Headers/smmintrin.h +++ lib/Headers/smmintrin.h @@ -286,37 +286,37 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi8_epi16(__m128i __V) { - return (__m128i) __builtin_ia32_pmovsxbw128((__v16qi) __V); + return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qi)__V, (__v16qi)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi); } static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi8_epi32(__m128i __V) { - return (__m128i) __builtin_ia32_pmovsxbd128((__v16qi) __V); + return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qi)__V, (__v16qi)__V, 0, 1, 2, 3), __v4si); } static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi8_epi64(__m128i __V) { - return (__m128i) __builtin_ia32_pmovsxbq128((__v16qi) __V); + return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qi)__V, (__v16qi)__V, 0, 1), __v2di); } static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi16_epi32(__m128i __V) { - return (__m128i) __builtin_ia32_pmovsxwd128((__v8hi) __V); + return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)_
Re: [PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line
beltex added a comment. Thanks! My first patch! :) http://reviews.llvm.org/D12684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer
Alexander_Droste updated this revision to Diff 34647. Alexander_Droste marked 2 inline comments as done. Alexander_Droste added a comment. - fixed integration test file: tools/clang/test/Analysis/MPIChecker.c - mocked types, constants, functions from mpi.h - mocked types from stdint.h - dropped -I/usr/... from first line http://reviews.llvm.org/D12761 Files: tools/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt tools/clang/lib/StaticAnalyzer/Checkers/Checkers.td tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerAST.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerAST.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerPathSensitive.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerPathSensitive.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/TranslationUnitVisitor.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/TranslationUnitVisitor.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/TypeVisitor.h tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Utility.cpp tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Utility.h tools/clang/test/Analysis/MPIChecker.c tools/clang/unittests/StaticAnalyzer/CMakeLists.txt tools/clang/unittests/StaticAnalyzer/MPI-Checker/CMakeLists.txt tools/clang/unittests/StaticAnalyzer/MPI-Checker/ContainerTest.cpp tools/clang/unittests/StaticAnalyzer/MPI-Checker/UtilityTest.cpp Index: tools/clang/unittests/StaticAnalyzer/MPI-Checker/UtilityTest.cpp === --- tools/clang/unittests/StaticAnalyzer/MPI-Checker/UtilityTest.cpp +++ tools/clang/unittests/StaticAnalyzer/MPI-Checker/UtilityTest.cpp @@ -0,0 +1,12 @@ +#include "gtest/gtest.h" +#include "Utility.h" + +TEST(Utility, split) { + auto s = util::split("aaa:bbb", ':'); + EXPECT_EQ(s[0], "aaa"); + EXPECT_EQ(s[1], "bbb"); + + auto s2 = util::split("aaa,bbb", ','); + EXPECT_EQ(s2[0], "aaa"); + EXPECT_EQ(s2[1], "bbb"); +} Index: tools/clang/unittests/StaticAnalyzer/MPI-Checker/ContainerTest.cpp === --- tools/clang/unittests/StaticAnalyzer/MPI-Checker/ContainerTest.cpp +++ tools/clang/unittests/StaticAnalyzer/MPI-Checker/ContainerTest.cpp @@ -0,0 +1,10 @@ +#include "gtest/gtest.h" +#include +#include "Container.h" + +TEST(Container, contains) { + std::vector v{0, 1, 2, 3, 4, 5, 6, 8, 9}; + EXPECT_TRUE(cont::contains(v, 0)); + EXPECT_TRUE(cont::contains(v, 3)); + EXPECT_TRUE(cont::contains(v, 9)); +} Index: tools/clang/unittests/StaticAnalyzer/MPI-Checker/CMakeLists.txt === --- tools/clang/unittests/StaticAnalyzer/MPI-Checker/CMakeLists.txt +++ tools/clang/unittests/StaticAnalyzer/MPI-Checker/CMakeLists.txt @@ -0,0 +1,18 @@ +set(LLVM_LINK_COMPONENTS Support) + +include_directories( +../../../lib/StaticAnalyzer/Checkers/MPI-Checker +) + +add_clang_unittest(MPI-Checker +UtilityTest.cpp +ContainerTest.cpp +) + +target_link_libraries(MPI-Checker + clangAST + clangBasic + clangLex + clangParse + clangSema + clangStaticAnalyzerCheckers) Index: tools/clang/unittests/StaticAnalyzer/CMakeLists.txt === --- tools/clang/unittests/StaticAnalyzer/CMakeLists.txt +++ tools/clang/unittests/StaticAnalyzer/CMakeLists.txt @@ -6,8 +6,10 @@ AnalyzerOptionsTest.cpp ) +add_subdirectory(MPI-Checker) + target_link_libraries(StaticAnalysisTests clangBasic clangAnalysis - clangStaticAnalyzerCore + clangStaticAnalyzerCore ) Index: tools/clang/test/Analysis/MPIChecker.c === --- tools/clang/test/Analysis/MPIChecker.c +++ tools/clang/test/Analysis/MPIChecker.c @@ -0,0 +1,507 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=mpi.MPI-Checker -verify %s + + +// MPI-Checker makes no assumptions about details of an MPI implementation. +// Typedefs and constants are compared as strings. + +#define NULL ((void *)0) + +// mock types +typedef int MPI_Datatype; +typedef int MPI_Comm; +typedef int MPI_Request; +typedef int MPI_Status; +typedef int MPI_Op; + +typedef int int8_t; +typedef int uint8_t; +typedef int uint16_t; +typedef int int64_t; + +// mock constants +#define MPI_COMM_WORLD 0 +#define MPI_CHAR 0 +#define MPI_BYTE 0 +#define MPI_INT 0 +#define MPI_LONG 0 +#define MPI_LONG_DOUBLE 0 +#define MPI_UN
Re: [PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line
This revision was automatically updated to reflect the committed changes. Closed by commit rL247530: [docs] NFC: Fix line formatting in INSTALL.txt (authored by vedantk). Changed prior to commit: http://reviews.llvm.org/D12684?vs=34178&id=34650#toc Repository: rL LLVM http://reviews.llvm.org/D12684 Files: cfe/trunk/INSTALL.txt Index: cfe/trunk/INSTALL.txt === --- cfe/trunk/INSTALL.txt +++ cfe/trunk/INSTALL.txt @@ -44,6 +44,6 @@ compiler and header files into the prefix directory selected when LLVM was configured. -The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like command line -interface. See the man page for clang (installed into $prefix/share/man/man1) -for more information. +The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like +command line interface. See the man page for clang (installed into +$prefix/share/man/man1) for more information. Index: cfe/trunk/INSTALL.txt === --- cfe/trunk/INSTALL.txt +++ cfe/trunk/INSTALL.txt @@ -44,6 +44,6 @@ compiler and header files into the prefix directory selected when LLVM was configured. -The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like command line -interface. See the man page for clang (installed into $prefix/share/man/man1) -for more information. +The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like +command line interface. See the man page for clang (installed into +$prefix/share/man/man1) for more information. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r247530 - [docs] NFC: Fix line formatting in INSTALL.txt
Author: vedantk Date: Sun Sep 13 15:17:18 2015 New Revision: 247530 URL: http://llvm.org/viewvc/llvm-project?rev=247530&view=rev Log: [docs] NFC: Fix line formatting in INSTALL.txt Patch by beltex! Differential Revision: http://reviews.llvm.org/D12684 Modified: cfe/trunk/INSTALL.txt Modified: cfe/trunk/INSTALL.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/INSTALL.txt?rev=247530&r1=247529&r2=247530&view=diff == --- cfe/trunk/INSTALL.txt (original) +++ cfe/trunk/INSTALL.txt Sun Sep 13 15:17:18 2015 @@ -44,6 +44,6 @@ From inside the Clang build directory, r compiler and header files into the prefix directory selected when LLVM was configured. -The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like command line -interface. See the man page for clang (installed into $prefix/share/man/man1) -for more information. +The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like +command line interface. See the man page for clang (installed into +$prefix/share/man/man1) for more information. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12549: Remove unused variable
gribozavr accepted this revision. gribozavr added a comment. This revision is now accepted and ready to land. LGTM. http://reviews.llvm.org/D12549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12381: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.
xazax.hun marked 3 inline comments as done. Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:121 @@ -54,3 +120,3 @@ I != E; ++I) { if (!SR.isLiveRegion(I->first)) { State = State->remove(I->first); zaks.anna wrote: > It's odd that we are using this API.. Are we keeping track of non-symbolic > regions? If not, can't we just check if Region->getSymbol() is dead? > (Same in the nullability checker.) The DynamicTypeMap might contain non-symbolic regions. (The tests fails when I cast the regions stored in the map to symbolic regions.) This observation is good however for the nullability checker. Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:275 @@ +274,3 @@ +/// +/// Precondition: the cast is between ObjCObjectPointers. +ExplodedNode *DynamicTypePropagation::dynamicTypePropagationOnCasts( zaks.anna wrote: > I do not see where you are checking the precondition. The check is in line 507. It is checked anyways for the generics checker and I did not want to add redundant checks to this function. http://reviews.llvm.org/D12381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r247532 - [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.
Author: xazax Date: Sun Sep 13 18:02:24 2015 New Revision: 247532 URL: http://llvm.org/viewvc/llvm-project?rev=247532&view=rev Log: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker. Differential Revision: http://reviews.llvm.org/D12381 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp cfe/trunk/test/Analysis/generics.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=247532&r1=247531&r2=247532&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Sun Sep 13 18:02:24 2015 @@ -53,7 +53,6 @@ add_clang_library(clangStaticAnalyzerChe ObjCAtSyncChecker.cpp ObjCContainersASTChecker.cpp ObjCContainersChecker.cpp - ObjCGenericsChecker.cpp ObjCMissingSuperCallChecker.cpp ObjCSelfInitChecker.cpp ObjCUnusedIVarsChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=247532&r1=247531&r2=247532&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Sun Sep 13 18:02:24 2015 @@ -479,7 +479,7 @@ def DirectIvarAssignmentForAnnotatedFunc def ObjCGenericsChecker : Checker<"ObjCGenerics">, HelpText<"Check for type errors when using Objective-C generics">, - DescFile<"ObjCGenericsChecker.cpp">; + DescFile<"DynamicTypePropagation.cpp">; def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">, HelpText<"Warns about uses of non-localized NSStrings passed to UI methods expecting localized NSStrings">, Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp?rev=247532&r1=247531&r2=247532&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp Sun Sep 13 18:02:24 2015 @@ -7,11 +7,23 @@ // //===--===// // +// This file contains two checkers. One helps the static analyzer core to track +// types, the other does type inference on Obj-C generics and report type +// errors. +// +// Dynamic Type Propagation: // This checker defines the rules for dynamic type gathering and propagation. // +// Generics Checker for Objective-C: +// This checker tries to find type errors that the compiler is not able to catch +// due to the implicit conversions that were introduced for backward +// compatibility. +// //===--===// #include "ClangSACheckers.h" +#include "clang/AST/ParentMap.h" +#include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/Builtins.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" @@ -24,25 +36,83 @@ using namespace clang; using namespace ento; +// ProgramState trait - The type inflation is tracked by DynamicTypeMap. This is +// an auxiliary map that tracks more information about generic types, because in +// some cases the most derived type is not the most informative one about the +// type parameters. This types that are stored for each symbol in this map must +// be specialized. +REGISTER_MAP_WITH_PROGRAMSTATE(TypeParamMap, SymbolRef, + const ObjCObjectPointerType *) + namespace { class DynamicTypePropagation: public Checker< check::PreCall, check::PostCall, check::DeadSymbols, -check::PostStmt, -check::PostStmt > { +check::PostStmt, +check::PostStmt, +check::PreObjCMessage, +check::PostObjCMessage > { const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr *MsgE, CheckerContext &C) const; /// \brief Return a better dynamic type if one can be derived from the cast. const ObjCObjectPointerType *getBetterObjCType(const Expr *CastE, CheckerContext &C) const; + + ExplodedNode *dynamicTypePropagationOnCasts(const CastExpr *CE, + ProgramStateRef &State, +
r247533 - [Static Analyzer] Remove a redundant file.
Author: xazax Date: Sun Sep 13 18:03:11 2015 New Revision: 247533 URL: http://llvm.org/viewvc/llvm-project?rev=247533&view=rev Log: [Static Analyzer] Remove a redundant file. Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp?rev=247532&view=auto == --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp (removed) @@ -1,623 +0,0 @@ -//=== ObjCGenericsChecker.cpp - Path sensitive checker for Generics *- C++ -*=// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// -// -// This checker tries to find type errors that the compiler is not able to catch -// due to the implicit conversions that were introduced for backward -// compatibility. -// -//===--===// - -#include "ClangSACheckers.h" -#include "clang/AST/ParentMap.h" -#include "clang/AST/RecursiveASTVisitor.h" -#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" -#include "clang/StaticAnalyzer/Core/Checker.h" -#include "clang/StaticAnalyzer/Core/CheckerManager.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" - -using namespace clang; -using namespace ento; - -// ProgramState trait - a map from symbol to its specialized type. -REGISTER_MAP_WITH_PROGRAMSTATE(TypeParamMap, SymbolRef, - const ObjCObjectPointerType *) - -namespace { -class ObjCGenericsChecker -: public Checker> { -public: - void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const; - void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const; - void checkPostStmt(const CastExpr *CE, CheckerContext &C) const; - void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const; - -private: - mutable std::unique_ptr ObjCGenericsBugType; - void initBugType() const { -if (!ObjCGenericsBugType) - ObjCGenericsBugType.reset( - new BugType(this, "Generics", categories::CoreFoundationObjectiveC)); - } - - class GenericsBugVisitor : public BugReporterVisitorImpl { - public: -GenericsBugVisitor(SymbolRef S) : Sym(S) {} - -void Profile(llvm::FoldingSetNodeID &ID) const override { - static int X = 0; - ID.AddPointer(&X); - ID.AddPointer(Sym); -} - -PathDiagnosticPiece *VisitNode(const ExplodedNode *N, - const ExplodedNode *PrevN, - BugReporterContext &BRC, - BugReport &BR) override; - - private: -// The tracked symbol. -SymbolRef Sym; - }; - - void reportGenericsBug(const ObjCObjectPointerType *From, - const ObjCObjectPointerType *To, ExplodedNode *N, - SymbolRef Sym, CheckerContext &C, - const Stmt *ReportedNode = nullptr) const; - - void checkReturnType(const ObjCMessageExpr *MessageExpr, - const ObjCObjectPointerType *TrackedType, SymbolRef Sym, - const ObjCMethodDecl *Method, - ArrayRef TypeArgs, bool SubscriptOrProperty, - CheckerContext &C) const; -}; -} // end anonymous namespace - -void ObjCGenericsChecker::reportGenericsBug(const ObjCObjectPointerType *From, -const ObjCObjectPointerType *To, -ExplodedNode *N, SymbolRef Sym, -CheckerContext &C, -const Stmt *ReportedNode) const { - initBugType(); - SmallString<192> Buf; - llvm::raw_svector_ostream OS(Buf); - OS << "Conversion from value of type '"; - QualType::print(From, Qualifiers(), OS, C.getLangOpts(), llvm::Twine()); - OS << "' to incompatible type '"; - QualType::print(To, Qualifiers(), OS, C.getLangOpts(), llvm::Twine()); - OS << "'"; - std::unique_ptr R( - new BugReport(*ObjCGenericsBugType, OS.str(), N)); - R->markInteresting(Sym); - R->addVisitor(llvm::make_unique(Sym)); - if (ReportedNode) -R->addRange(ReportedNode->getSourceRange()); - C.emitReport(std::move(R)); -} - -PathDiagnosticPiece *ObjCGenericsChecker::GenericsBugVisitor::VisitNode( -const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, -BugReport &BR) { - ProgramSt
Re: [PATCH] D12381: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.
This revision was automatically updated to reflect the committed changes. Closed by commit rL247532: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type… (authored by xazax). Changed prior to commit: http://reviews.llvm.org/D12381?vs=34606&id=34651#toc Repository: rL LLVM http://reviews.llvm.org/D12381 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp cfe/trunk/test/Analysis/generics.m Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt === --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -53,7 +53,6 @@ ObjCAtSyncChecker.cpp ObjCContainersASTChecker.cpp ObjCContainersChecker.cpp - ObjCGenericsChecker.cpp ObjCMissingSuperCallChecker.cpp ObjCSelfInitChecker.cpp ObjCUnusedIVarsChecker.cpp Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -7,11 +7,23 @@ // //===--===// // +// This file contains two checkers. One helps the static analyzer core to track +// types, the other does type inference on Obj-C generics and report type +// errors. +// +// Dynamic Type Propagation: // This checker defines the rules for dynamic type gathering and propagation. // +// Generics Checker for Objective-C: +// This checker tries to find type errors that the compiler is not able to catch +// due to the implicit conversions that were introduced for backward +// compatibility. +// //===--===// #include "ClangSACheckers.h" +#include "clang/AST/ParentMap.h" +#include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/Builtins.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" @@ -24,25 +36,83 @@ using namespace clang; using namespace ento; +// ProgramState trait - The type inflation is tracked by DynamicTypeMap. This is +// an auxiliary map that tracks more information about generic types, because in +// some cases the most derived type is not the most informative one about the +// type parameters. This types that are stored for each symbol in this map must +// be specialized. +REGISTER_MAP_WITH_PROGRAMSTATE(TypeParamMap, SymbolRef, + const ObjCObjectPointerType *) + namespace { class DynamicTypePropagation: public Checker< check::PreCall, check::PostCall, check::DeadSymbols, -check::PostStmt, -check::PostStmt > { +check::PostStmt, +check::PostStmt, +check::PreObjCMessage, +check::PostObjCMessage > { const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr *MsgE, CheckerContext &C) const; /// \brief Return a better dynamic type if one can be derived from the cast. const ObjCObjectPointerType *getBetterObjCType(const Expr *CastE, CheckerContext &C) const; + + ExplodedNode *dynamicTypePropagationOnCasts(const CastExpr *CE, + ProgramStateRef &State, + CheckerContext &C) const; + + mutable std::unique_ptr ObjCGenericsBugType; + void initBugType() const { +if (!ObjCGenericsBugType) + ObjCGenericsBugType.reset( + new BugType(this, "Generics", categories::CoreFoundationObjectiveC)); + } + + class GenericsBugVisitor : public BugReporterVisitorImpl { + public: +GenericsBugVisitor(SymbolRef S) : Sym(S) {} + +void Profile(llvm::FoldingSetNodeID &ID) const override { + static int X = 0; + ID.AddPointer(&X); + ID.AddPointer(Sym); +} + +PathDiagnosticPiece *VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) override; + + private: +// The tracked symbol. +SymbolRef Sym; + }; + + void reportGenericsBug(const ObjCObjectPointerType *From, + const ObjCObjectPointerType *To, ExplodedNode *N, + SymbolRef Sym, CheckerContext &C, + const Stmt *ReportedNode = nullptr) const; + + void checkReturnType(const ObjCMessageExpr *MessageExpr, + const ObjCObjectPointerType *TrackedType, Sy
Re: [PATCH] D12549: Remove unused variable
hintonda added a comment. I don't have commit access, so could you commit it for me? thanks... don http://reviews.llvm.org/D12549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12549: Remove unused variable
gribozavr closed this revision. gribozavr added a comment. Current trunk does not contain this line, no need to apply the patch. http://reviews.llvm.org/D12549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12549: Remove unused variable
hintonda added a comment. Looks like Manuel cleaned it up along with another change on the 8th, r247018. thanks again... http://reviews.llvm.org/D12549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits