From 1b6fff624e24727940c1fe59431e74ef11eda230 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 23 Feb 2017 19:02:12 +0000 Subject: [PATCH] Vendor import of clang release_40 branch r295910: https://llvm.org/svn/llvm-project/cfe/branches/release_40@295910 --- CMakeLists.txt | 6 +++++- docs/ReleaseNotes.rst | 24 +++++++++++++++++------- lib/Driver/Tools.cpp | 4 ++++ test/Driver/openbsd.c | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c56707e7fb5..ff1ff210b56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) - list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH) + list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH) if(NOT MSVC_IDE) set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} @@ -57,6 +57,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") + # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. + # CMake assumes slashes as PATH. + file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH) + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 08d7a7583f5..8363ae457da 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -241,17 +241,27 @@ show the description of the defects. Static Analyzer --------------- -... +With the option --show-description, scan-build's list of defects will also +show the description of the defects. -Core Analysis Improvements -========================== +The analyzer now provides better support of code that uses gtest. -- ... +Several new checks were added: -New Issues Found -================ +- The analyzer warns when virtual calls are made from constructors or + destructors. This check is off by default but can be enabled by passing the + following command to scan-build: -enable-checker optin.cplusplus.VirtualCall. +- The analyzer checks for synthesized copy properties of mutable types in + Objective C, such as NSMutableArray. Calling the setter for these properties + will store an immutable copy of the value. +- The analyzer checks for calls to dispatch_once() that use an Objective-C + instance variable as the predicate. Using an instance variable as a predicate + may result in the passed-in block being executed multiple times or not at all. + These calls should be rewritten either to use a lock or to store the predicate + in a global or static variable. +- The analyzer checks for unintended comparisons of NSNumber, CFNumberRef, and + other Cocoa number objects to scalar values. -- ... Python Binding Changes ---------------------- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index b4a83347def..3c3d453ff7d 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -8937,6 +8937,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_pg)) CmdArgs.push_back( Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o"))); + else if (Args.hasArg(options::OPT_static) && + !Args.hasArg(options::OPT_nopie)) + CmdArgs.push_back( + Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o"))); else CmdArgs.push_back( Args.MakeArgString(getToolChain().GetFilePath("crt0.o"))); diff --git a/test/Driver/openbsd.c b/test/Driver/openbsd.c index 95b9e6ad4f3..587c31ded0a 100644 --- a/test/Driver/openbsd.c +++ b/test/Driver/openbsd.c @@ -67,3 +67,26 @@ // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC" // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL" // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC" + +// Check linking against correct startup code when (not) using PIE +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-PIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-PIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-STATIC-PIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-STATIC-PIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -nopie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-NOPIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie -nopie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-NOPIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -nopie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-NOPIE %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie -static -nopie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-NOPIE %s +// CHECK-PIE: "{{.*}}crt0.o" +// CHECK-PIE-NOT: "-nopie" +// CHECK-STATIC-PIE: "{{.*}}rcrt0.o" +// CHECK-STATIC-PIE-NOT: "-nopie" +// CHECK-NOPIE: "-nopie" "{{.*}}crt0.o"