Richard Trieu [Thu, 24 Sep 2015 01:21:01 +0000 (01:21 +0000)]
Improve the printing of ranges when macros are involved.
Trace the ranges through the macro backtrace better. This allows better
range highlighting through all levels of the macro bracktrace. Also some
improvements to backtrace printer for omitting different backtraces.
[analyzer] Discard malloc-overflow bug-report when a known size is malloc'ed.
This patch ignores malloc-overflow bug in two cases:
Case1:
x = a/b; where n < b
malloc (x*n); Then x*n will not overflow.
Case2:
x = a; // when 'a' is a known value.
malloc (x*n);
Also replaced isa with dyn_cast.
Reject multiplication by zero cases in MallocOverflowSecurityChecker
Currently MallocOverflowSecurityChecker does not catch cases like:
malloc(n * 0 * sizeof(int));
This patch rejects such cases.
Two test cases added. malloc-overflow2.c has an example inspired from a code
in linux kernel where the current checker flags a warning while it should not.
Chris Bieneman [Wed, 23 Sep 2015 22:52:35 +0000 (22:52 +0000)]
[darwin] [builtins] Stop generating cc_kext_ios5 and move iOS architectures out of cc_kext into cc_kext_ios
Summary:
This corresponds to a patch to compiler-rt (D13112).
Xcode 7 doesn't support targeting iOS5 and earlier. Instead of just dropping cc_kext_ios5, I've repurposed it to cc_kext_ios, and I'm pulling the iOS architectures out of cc_kext. Putting OS X and iOS slices inside the same archive was just odd.
John McCall [Wed, 23 Sep 2015 22:14:21 +0000 (22:14 +0000)]
Forbid qualifiers on ObjC generic parameters and arguments, but
silently ignore them on arguments when they're provided indirectly
(.e.g behind a template argument or typedef).
This is mostly just good language design --- specifying that a
generic argument is __weak doesn't actually do anything --- but
it also prevents assertions when trying to apply a different
ownership qualifier.
Richard Smith [Wed, 23 Sep 2015 22:07:44 +0000 (22:07 +0000)]
Remove warning on over-wide bit-field of boolean type; there's no risk that
someone thought all the bits would be value bits in this case.
Also fix the wording of the warning -- it claimed that the width of 'bool' is
8, which is not correct; the width is 1 bit, whereas the size is 8 bits in our
implementation.
Added new option --cuda-path=<path> which allows
overriding default search paths.
If it's not specified we look for CUDA installation in
/usr/include/cuda and /usr/include/cuda-7.0.
[analyzer] Improve localizability checks for iOS / OS X.
Various improvements to the localization checker:
* Adjusted copy to be consistent with diagnostic text in other Apple
API checkers.
* Added in ~150 UIKit / AppKit methods that require localized strings in
UnlocalizedStringsChecker.
* UnlocalizedStringChecker now checks for UI methods up the class hierarchy and
UI methods that conform for a certain Objective-C protocol.
* Added in alpha version of PluralMisuseChecker and some regression tests. False
positives are still not ideal.
(This is the second attempt, with the memory issues on Linux resolved.)
Richard Smith [Wed, 23 Sep 2015 21:41:42 +0000 (21:41 +0000)]
PR14858: Initial support for proper sizeof... handling within alias templates.
This doesn't quite get alias template equivalence right yet, but handles the
egregious cases where we would silently give the wrong answers.
Richard Smith [Wed, 23 Sep 2015 21:30:47 +0000 (21:30 +0000)]
Remove wrong implication that value-dependent implies instantiation-dependent,
and fix the only code that was depending on this so that it sets all the
relevant flags appropriately.
Added new option --cuda-path=<path> which allows
overriding default search paths.
If it's not specified we look for CUDA installation in
/usr/include/cuda and /usr/include/cuda-7.0.
David Majnemer [Wed, 23 Sep 2015 16:04:47 +0000 (16:04 +0000)]
[Lex] A source-file new-line in a raw string literal results in a new-line
Our string literal parser copied any source-file new-line characters
into the execution string-literal. This is incorrect if the source-file
new-line character was a \r\n sequence because new-line characters are
merely \n.
Benjamin Kramer [Wed, 23 Sep 2015 16:03:53 +0000 (16:03 +0000)]
[Sema] Don't create an invalid source range for overlong initializer lists.
We took both source locations from the end of the initializer list what
the code below doesn't expect. This can lead to a crash when rendering
the diagnostic (PR24816). Assert that we have more than one element in
a scalar initializer with too many elements.
John Brawn [Wed, 23 Sep 2015 13:55:40 +0000 (13:55 +0000)]
Add -fplugin=name.so option to the driver
This translates to -load name.so in the cc1 command. We can't name the driver
option -load, as that means "link against oad", so instead we follow GCC's lead
and name the option -fplugin.
To implement this nicely, add a function that merges two sets of
replacements that are meant to be done in sequence. This functionality
will also be useful for other applications, e.g. formatting the result
of clang-tidy fixes.
[analyzer] Improve localizability checks for iOS / OS X.
Various improvements to the localization checker:
* Adjusted copy to be consistent with diagnostic text in other Apple
API checkers.
* Added in ~150 UIKit / AppKit methods that require localized strings in
UnlocalizedStringsChecker.
* UnlocalizedStringChecker now checks for UI methods up the class hierarchy and
UI methods that conform for a certain Objective-C protocol.
* Added in alpha version of PluralMisuseChecker and some regression tests. False
positives are still not ideal.
Adrian Prantl [Tue, 22 Sep 2015 23:26:43 +0000 (23:26 +0000)]
Module Debugging: Use the clang module signature as the module's dwo_id
when building a module. Clang already records the module signature when
building a skeleton CU to reference a clang module.
Matching the id in the skeleton with the one in the module allows a DWARF
consumer to verify that they found the correct version of the module
without them needing to know about the clang module format.
[analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).
Currently realloc(ptr, 0) is treated as free() which seems to be not correct. C
standard (N1570) establishes equivalent behavior for malloc(0) and realloc(ptr,
0): "7.22.3 Memory management functions calloc, malloc, realloc: If the size of
the space requested is zero, the behavior is implementation-defined: either a
null pointer is returned, or the behavior is as if the size were some nonzero
value, except that the returned pointer shall not be used to access an object."
The patch equalizes the processing of malloc(0) and realloc(ptr,0). The patch
also enables unix.Malloc checker to detect references to zero-allocated memory
returned by realloc(ptr,0) ("Use of zero-allocated memory" warning).
Analyzer: Teach analyzer how to handle TypeTraitExpr
Summary:
`TypeTraitExpr`s are not supported by the ExprEngine today. Analyzer
creates a sink, and aborts the block. Therefore, certain bugs that
involve type traits intrinsics cannot be detected (see PR24710).
This patch creates boolean `SVal`s for `TypeTraitExpr`s, which are
evaluated by the compiler.
[CUDA] Allow parsing of host and device code simultaneously.
* adds -aux-triple option to specify target triple
* propagates aux target info to AST context and Preprocessor
* pulls in target specific preprocessor macros.
* pulls in target-specific builtins from aux target.
* sets appropriate host or device attribute on builtins.
[CUDA] Fixes minor cuda-related issues in the driver
* Only the last of the --cuda-host-only/--cuda-device-only options has effect.
* CudaHostAction always wraps host-side compilation now.
* Fixed printing of empty action lists.
[CUDA] Allow function overloads in CUDA based on host/device attributes.
The patch makes it possible to parse CUDA files that contain host/device
functions with identical signatures, but different attributes without
having to physically split source into host-only and device-only parts.
This change is needed in order to parse CUDA header files that have
a lot of name clashes with standard include files.
Gory details are in design doc here: https://goo.gl/EXnymm
Feel free to leave comments there or in this review thread.
This feature is controlled with CC1 option -fcuda-target-overloads
and is disabled by default.
[CUDA] Add implicit __attribute__((used)) to all __global__ functions.
This makes sure that we emit kernels that were instantiated from the
host code and which would never be explicitly referenced by anything
else on device side.
[tooling] Provide the compile commands of the JSON database in the order that they were provided in the JSON file.
This is useful for debugging of issues and reduction of test cases.
For example, an issue may show up due to the order that some commands were processed.
It is convenient to be able to remove commands from the file and still preserve the order
that they are returned, instead of getting a completely different order when removing a few commands.
ms Intrin.h: Fix __movsw's and __stosw's inline asm.
Before, clang's internal assembler would reject the inline asm in clang's
Intrin.h. To make sure this doesn't happen for other Intrin.h functions using
__asm__ blocks, add 32-bit and 64-bit codegen tests for Intrin.h.
Sadly, these tests discovered that __readcr3 and __writecr3 have bad
implementations in 64-bit builds. This will have to be fixed in a follow-up.
We prefer setting these in our .clang-format file as the macros change over
time. (Also, the code was setting MacroBlockBegin twice and didn't set
MacroBlockEnd, so it wasn't doing what it tried to do anyways.)
Alexander Musman [Mon, 21 Sep 2015 14:41:00 +0000 (14:41 +0000)]
Fix assertion in inline assembler IR gen
Several inputs may not refer to one output constraint in inline assembler
insertions, clang was failing on assertion on such test case.
[ARM] Handle +t2dsp feature as an ArchExtKind in ARMTargetParser.def
Currently, the availability of DSP instructions (ACLE 6.4.7) is handled in
a hand-rolled tricky condition block in lib/Basic/Targets.cpp, with a FIXME:
attached.
http://reviews.llvm.org/D12937 moved the handling of +t2dsp over to
ARMTargetParser.def in LLVM, to be in line with other architecture extensions.
This is the corresponding patch to clang, to clear the FIXME: and update
the tests.
This changes getARMFloatABI to use the ToolChain and Args instead of Driver,
Args, Triple. Although this pushes the Triple calculation/parsing into the
function itself, it enables the use of the function for a future change. The
reason to sink the triple calculation here is to avoid threading the Triple
through multiple layers in a future change.
Rather than using re-calculating the effective triple, thread the already
calculated value down into AddARMTargetArgs. This avoids both recreating the
triple, as well as re-parsing the triple as it was already done in the previous
frame.
Simon Pilgrim [Sat, 19 Sep 2015 15:12:38 +0000 (15:12 +0000)]
[X86][SSE] Replace 128-bit SSE41 PMOVSX intrinsics with native IR
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).
[Modules] More descriptive diagnostics for misplaced import directive
If an import directive was put into wrong context, the error message was obscure,
complaining on misbalanced braces. To get more descriptive messages, annotation
tokens related to modules are processed where they must not be seen.
Use an enumeration for the Floating Point ABIs supported on MIPS. This is
replicating the ARM change to avoid string based tracking of the floating point
ABI. NFC.
Richard Trieu [Fri, 18 Sep 2015 23:18:39 +0000 (23:18 +0000)]
Split off the binary literal warning into a subgroup of C++14 warnings
Binary literals predate C++14, but they are listed as a C++14 extension since
this was the first time they were standardized in the language. Move the
warning into a subgroup so it can be selectively disabled when checking for
other C++14 features.
Adrian Prantl [Fri, 18 Sep 2015 23:01:45 +0000 (23:01 +0000)]
CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
We don't want a skeleton CU when generating debug info for the module
itself.
Summary:
Name `Out` refers to the parameter. It is moved into the member `Out`
in ctor-init. Dereferencing null pointer will crash clang, if user
passes '-analyzer-viz-egraph-ubigraph' argument.
Chris Bieneman [Fri, 18 Sep 2015 21:15:54 +0000 (21:15 +0000)]
[CMake] Refactoring and cleaning up clang symlink generation.
Generation of clang symlinks now uses add_clang_symlink macro which uses add_llvm_symlink. Also the list of symlinks to generate is configurable via CLANG_LINKS_TO_CREATE.
This re-lands r248015, with fixes for clang symlinks to always be generated as part of the clang and install-clang targets.
Adrian Prantl [Fri, 18 Sep 2015 21:06:14 +0000 (21:06 +0000)]
Debug Info: Use the full module name as a key when caching DIModules.
The signature may not have been computed at the time the module reference
is generated (e.g.: in the future while emitting debug info for a clang
module). Using the full module name is safe because each clang module may
only have a single definition.
LLVM r217812 made it so that clang-cl implicitly creates bigobj files when
needed, independent of this flag. It looks like cl has this flag to produce obj
flags compatible with MSVS 2003's linker by default, something we don't care
about. Since clang-cl always has /bigobj behavior, don't warn that the flag is
unused, just ignore it silently.
Chris Bieneman [Fri, 18 Sep 2015 18:09:15 +0000 (18:09 +0000)]
[CMake] Refactoring and cleaning up clang symlink generation.
Generation of clang symlinks now uses add_clang_symlink macro which uses add_llvm_symlink. Also the list of symlinks to generate is configurable via CLANG_LINKS_TO_CREATE.