Commit Graph

73305 Commits

Author SHA1 Message Date
Craig Topper 294016b826 Fix a couple places that immediately called operator-> on the result of dyn_cast.
It looks like it safe to just use cast for both cases.

llvm-svn: 331578
2018-05-05 01:58:26 +00:00
Eli Friedman b6e64e734d Add warning flag -Wordered-compare-function-pointers.
The C standard doesn't allow comparisons like "f1 < f2" (where f1 and f2
are function pointers), but we allow them as an extension.  Add a
warning flag to control this warning.

Differential Revision: https://reviews.llvm.org/D46155

llvm-svn: 331570
2018-05-05 00:09:51 +00:00
Artem Dergachev e0fb481cc5 [analyzer] Remove untested code in evalLoad.
No functional change intended.

llvm-svn: 331565
2018-05-04 23:01:10 +00:00
Artem Dergachev 394588a1a6 [analyzer] Invalidate union regions properly. Don't hesitate to load later.
We weren't invalidating our unions correctly. The previous behavior in
invalidateRegionsWorker::VisitCluster() was to direct-bind an UnknownVal
to the union (at offset 0).

For that reason we were never actually loading default bindings from our unions,
because there never was any default binding to load, and the value
that is presumed when there's no default binding to load
is usually completely incorrect (eg. UndefinedVal for stack unions).

The new behavior is to default-bind a conjured symbol (of irrelevant type)
to the union that's being invalidated, similarly to what we do for structures
and classes. Then it becomes safe to load the value properly.

Differential Revision: https://reviews.llvm.org/D45241

llvm-svn: 331563
2018-05-04 22:19:32 +00:00
Artem Dergachev e603e076f5 [analyzer] pr36458: Fix retrieved value cast for symbolic void pointers.
C allows us to write any bytes into any memory region. When loading weird bytes
from memory regions of known types, the analyzer is required to make sure that
the loaded value makes sense by casting it to an appropriate type.

Fix such cast for loading values that represent void pointers from non-void
pointer type places.

Differential Revision: https://reviews.llvm.org/D46415

llvm-svn: 331562
2018-05-04 22:11:12 +00:00
Artem Dergachev 806486c781 [analyzer] pr18953: Split C++ zero-initialization from default initialization.
The bindDefault() API of the ProgramState allows setting a default value
for reads from memory regions that were not preceded by writes.

It was used for implementing C++ zeroing constructors (i.e. default constructors
that boil down to setting all fields of the object to 0).

Because differences between zeroing consturctors and other forms of default
initialization have been piling up (in particular, zeroing constructors can be
called multiple times over the same object, probably even at the same offset,
requiring a careful and potentially slow cleanup of previous bindings in the
RegionStore), we split the API in two: bindDefaultInitial() for modeling
initial values and bindDefaultZero() for modeling zeroing constructors.

This fixes a few assertion failures from which the investigation originated.

The imperfect protection from both inability of the RegionStore to support
binding extents and lack of information in ASTRecordLayout has been loosened
because it's, well, imperfect, and it is unclear if it fixing more than it
was breaking.

Differential Revision: https://reviews.llvm.org/D46368

llvm-svn: 331561
2018-05-04 21:56:51 +00:00
Craig Topper 2cd09d017a [X86] Correct the attributes on the incssp and rdssp builtins to only have 'nothrow'
llvm-svn: 331560
2018-05-04 21:56:43 +00:00
Craig Topper 934f86a848 [X86] Fix some inconsistent formatting in the first line of our intrinsics headers.
Some were too long and some were too short.

llvm-svn: 331559
2018-05-04 21:45:25 +00:00
Artem Dergachev 2fd6aa7d56 [analyzer] pr37209: Fix casts of glvalues to references.
Many glvalue expressions aren't of their respective reference type -
they are simply glvalues of their value type.

This was causing problems when we were trying to obtain type of the original
expression while evaluating certain glvalue bit-casts.

Fixed by artificially forging a reference type to provide to the casting
procedure.

Differential Revision: https://reviews.llvm.org/D46224

llvm-svn: 331558
2018-05-04 21:39:25 +00:00
Artem Dergachev a2e053638b [analyzer] Treat more const variables and fields as known contants.
When loading from a variable or a field that is declared as constant,
the analyzer will try to inspect its initializer and constant-fold it.
Upon success, the analyzer would skip normal load and return the respective
constant.

The new behavior also applies to fields/elements of brace-initialized structures
and arrays.

Patch by Rafael Stahl!

Differential Revision: https://reviews.llvm.org/D45774

llvm-svn: 331556
2018-05-04 20:52:39 +00:00
Sterling Augustine 5891064692 Allow modifying the PrintingPolicy for fully qualified names.
Author: mikhail.ramalho@gmail.com
llvm-svn: 331552
2018-05-04 20:12:39 +00:00
Eric Liu bf4c41c7e1 [clang-format] Refactor #include insertion/deletion functionality into a class.
Summary:
The class will be moved into libToolingCore as followup.

The new behaviors in this patch:
- New #include is inserted in the right position in a #include block to
preserver sorted #includes. This is best effort - only works when the
block is already sorted.
- When inserting multiple #includes to the end of a file which doesn't
end with a "\n" character, a "\n" will be prepended to each #include.
This is a special and rare case that was previously handled. This is now
relaxed to avoid complexity as it's rare in practice.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, cfe-commits, djasper

Differential Revision: https://reviews.llvm.org/D46180

llvm-svn: 331544
2018-05-04 17:55:13 +00:00
Erich Keane 8668503c8f [NFC]Convert Class to use member initialization instead of inline.
llvm-svn: 331536
2018-05-04 16:19:53 +00:00
Erich Keane 425f48d480 [clang-cl] Print /showIncludes to stderr, if used in combination with /E, /EP or /P
This replicates 'cl.exe' behavior and allows for both preprocessor output and
dependency information to be extraced with a single compiler invocation.

This is especially useful for compiler caching with tools like Mozilla's sccache.

See: https://github.com/mozilla/sccache/issues/246

Patch By: fxb

Differential Revision: https://reviews.llvm.org/D46394

llvm-svn: 331533
2018-05-04 15:58:31 +00:00
Alexander Kornienko a61d4c959a Remove explicit cfg-temporary-dtors=true
Summary:
Remove explicit -analyzer-config cfg-temporary-dtors=true in analyzer tests,
since this option defaults to true since r326461.

Reviewers: NoQ

Reviewed By: NoQ

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D46393

llvm-svn: 331520
2018-05-04 14:13:14 +00:00
Brian Gesiak ea9144e818 [Coroutines] Catch exceptions in await_resume
Summary:
http://wg21.link/P0664r2 section "Evolution/Core Issues 24" describes a
proposed change to Coroutines TS that would have any exceptions thrown
after the initial suspend point of a coroutine be caught by the handler
specified by the promise type's 'unhandled_exception' member function.
This commit provides a sample implementation of the specified behavior.

Test Plan: `check-clang`

Reviewers: GorNishanov, EricWF

Reviewed By: GorNishanov

Subscribers: cfe-commits, lewissbaker, eric_niebler

Differential Revision: https://reviews.llvm.org/D45860

llvm-svn: 331519
2018-05-04 14:02:37 +00:00
Martin Storsjo 665c7a4479 [Driver] Don't warn about unused inputs in config files
This avoids warnings about unused linker parameters, just like
other flags are ignored if they're from config files.

Differential Revision: https://reviews.llvm.org/D46286

llvm-svn: 331504
2018-05-04 06:05:58 +00:00
Artem Dergachev 4cc0d4e823 [analyzer] NFC: Remove unused parameteer of StoreManager::CastRetrievedVal().
llvm-svn: 331496
2018-05-04 00:53:41 +00:00
Craig Topper ce716347af [X86] Make __builtin_ia32_directstore_u32 and __builtin_ia32_movdir64b 'nothrow'
These builtins snuck in while I was in the middle of adding nothrow to the other builtins in my local clone and I guess I missed them.

llvm-svn: 331483
2018-05-03 21:01:35 +00:00
Craig Topper 274506dab8 [CodeGenFunction] Use the StringRef::split function that takes a char separator instead of StringRef separator. NFC
The char separator version should be a little better optimized.

llvm-svn: 331482
2018-05-03 21:01:33 +00:00
Joel E. Denny 96fde08f3b [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG
Reviewed by: ABataev

Differential Revision: https://reviews.llvm.org/D46370

llvm-svn: 331469
2018-05-03 17:22:04 +00:00
Joel E. Denny d110fe4a7e Revert r331466: [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG"
Sorry, forgot to add commit log attributes.

llvm-svn: 331468
2018-05-03 17:22:01 +00:00
Joel E. Denny 3c14663740 [OPENMP] Fix test typos: CHECK-DAG-N -> CHECK-N-DAG
llvm-svn: 331466
2018-05-03 17:15:44 +00:00
Aaron Ballman b9a457af35 Allow writing calling convention attributes on function types.
Calling convention attributes notionally appertain to the function type -- they modify the mangling of the function, change the behavior of assignment operations, etc. This commit allows the calling convention attributes to be written in the type position as well as the declaration position.

llvm-svn: 331459
2018-05-03 15:33:50 +00:00
Piotr Padlewski 5dde809404 Rename invariant.group.barrier to launder.invariant.group
Summary:
This is one of the initial commit of "RFC: Devirtualization v2" proposal:
https://docs.google.com/document/d/16GVtCpzK8sIHNc2qZz6RN8amICNBtvjWUod2SujZVEo/edit?usp=sharing

Reviewers: rsmith, amharc, kuhar, sanjoy

Subscribers: arsenm, nhaehnle, javed.absar, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D45111

llvm-svn: 331448
2018-05-03 11:03:01 +00:00
Fangrui Song 369a38ba0f Enable -fsanitize=function on FreeBSD.
llvm-svn: 331440
2018-05-03 06:37:47 +00:00
Karl-Johan Karlsson f4cf59ef99 Fix -Wunused-variable warning in Clang.cpp
llvm-svn: 331438
2018-05-03 05:53:29 +00:00
Richard Smith eaf11ad709 Track the result of evaluating a computed noexcept specification on the
FunctionProtoType.

We previously re-evaluated the expression each time we wanted to know whether
the type is noexcept or not. We now evaluate the expression exactly once.

This is not quite "no functional change": it fixes a crasher bug during AST
deserialization where we would try to evaluate the noexcept specification in a
situation where we have not deserialized sufficient portions of the AST to
permit such evaluation.

llvm-svn: 331428
2018-05-03 03:58:32 +00:00
Petr Hosek edb6ff8c06 [CMake][Cache] Stop pretending that Fuchsia is UNIX
This changes some aspects of the build that are not relevant or useful
for Fuchsia like setting the RPATH/RUNPATH.

Differential Revision: https://reviews.llvm.org/D46361

llvm-svn: 331425
2018-05-03 01:44:03 +00:00
Lei Liu 413f3c5595 [Sema] Do not match function type with const T in template argument deduction
From http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584,
function type should not match cv-qualified type in template argument
deduction. This also matches what GCC and EDG do in template argument
deduction.

Differential Revision: https://reviews.llvm.org/D45755

llvm-svn: 331424
2018-05-03 01:43:23 +00:00
Alex Lorenz f4d4cfbefa [ObjC] Supress the 'implementing unavailable method' warning when
the method declaration is unavailable for an app extension platform

Rationale:
Classes are often shared between an app extension code and
non-app extension code. There's no way to remove the implementation
using preprocessor when building the app extension, so we should not warn here.

rdar://38150617

llvm-svn: 331421
2018-05-03 01:12:06 +00:00
Chandler Carruth 9325c38fdb [gcov] Make the CLang side coverage test work with the new
instrumentation codegeneration strategy of using a data structure and
a loop. Required some finesse to get the critical things being tested to
surface in a nice way for FileCheck but I think this preserves the
original intent of the test.

llvm-svn: 331411
2018-05-02 22:57:20 +00:00
Alex Lorenz 613725507c [ObjC] The absence of ownership qualifiers on an ambiguous property leads
to synthesis of a valid property even when the selected protocol property
has ownership qualifiers

rdar://39024725

llvm-svn: 331409
2018-05-02 22:40:19 +00:00
Artem Dergachev 1aaf402530 [analyzer] Revert r331096 "CStringChecker: Add support for BSD strlcpy()...".
The return values of the newly supported functions were not handled correctly:
strlcpy()/strlcat() return string sizes rather than pointers.

Differential Revision: https://reviews.llvm.org/D45177

llvm-svn: 331401
2018-05-02 20:33:17 +00:00
Craig Topper b374bca7eb [X86] Mark all x86 specific builtins as nothrow.
I believe all of the x86 builtins should be considered nothrow.

I've left the incssp builtins alone because I think its current attributes are wrong and I'm following up with the contributor for that.

I plan to start adding const as well, but that requires more careful auditing.

Differential Revision: https://reviews.llvm.org/D46328

llvm-svn: 331399
2018-05-02 20:18:57 +00:00
Alexey Bataev fac26cf4ca [OPENMP] Add support for reductions on simd directives in target
regions.

Added codegen for `simd reduction()` constructs in target directives.

llvm-svn: 331393
2018-05-02 20:03:27 +00:00
Volodymyr Sapsai 2d77119f72 Revert "Emit an error when mixing <stdatomic.h> and <atomic>"
It reverts r331378 as it caused test failures

    ThreadSanitizer-x86_64 :: Darwin/gcd-groups-destructor.mm
    ThreadSanitizer-x86_64 :: Darwin/libcxx-shared-ptr-stress.mm
    ThreadSanitizer-x86_64 :: Darwin/xpc-race.mm

Only clang part of the change is reverted, libc++ part remains as is because it
emits error less aggressively.

llvm-svn: 331392
2018-05-02 19:52:07 +00:00
Dan Albert 4d64306a92 [Driver] Infer Android sysroot location.
Summary:
Android toolchains include their headers and libraries in a
self-contained directory within the toolchain.

Reviewers: srhines

Reviewed By: srhines

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45291

llvm-svn: 331390
2018-05-02 19:38:37 +00:00
Dan Albert f6f114936a [Driver] Obey computed sysroot when finding libc++ headers.
Summary:
A handful of targets will try some default paths if --sysroot is not provided.
If that is the case, it should be used for the libc++ header paths.

Reviewers: srhines, EricWF

Reviewed By: srhines

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45292

llvm-svn: 331389
2018-05-02 19:31:01 +00:00
Alexey Bataev 354df2eeab [OPENMP] Analyze the type of the mapped entity instead of its base.
If the mapped entity is a data member, we erroneously checked the type
of its base rather than the type of the mapped entity itself.

llvm-svn: 331385
2018-05-02 18:44:10 +00:00
Volodymyr Sapsai c0a278aada Emit an error when mixing <stdatomic.h> and <atomic>
Atomics in C and C++ are incompatible at the moment and mixing the
headers can result in confusing error messages.

Emit an error explicitly telling about the incompatibility. Introduce
the macro `__ALLOW_STDC_ATOMICS_IN_CXX__` that allows to choose in C++
between C atomics and C++ atomics.

rdar://problem/27435938

Reviewers: rsmith, EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: jkorous-apple, christof, bumblebritches57, JonChesterfield, smeenai, cfe-commits

Differential Revision: https://reviews.llvm.org/D45470

llvm-svn: 331378
2018-05-02 17:50:43 +00:00
Alexey Bataev dcc815d015 [OPENMP] Do not emit warning for implicitly declared target functions.
Since upcoming OpenMP 5.0 functions can be mapped implicitly as declare
target and we should not emit warnings for such functions.

llvm-svn: 331377
2018-05-02 17:39:00 +00:00
Alexey Bataev 1ab3457319 [OPENMP] Enable c++ exceptions outside of the target constructs iff they are
enabled for the host.

If the compilation for the host enables C++ exceptions, but they are not
supported by the device, we still need to allow the code with the
exception handling constructs outside of the target regions.

llvm-svn: 331372
2018-05-02 16:52:07 +00:00
Jessica Paquette 8e71ee3c07 Add -foutline option to enable the MachineOutliner in AArch64
Since we've been working on productizing the MachineOutliner in AArch64, it
makes sense to provide a more user-friendly way to enable it.

This allows users of AArch64 to enable the outliner using -foutline instead
of -mllvm -enable-machine-outliner. Other, less mature implementations (e.g,
x86-64) can still enable the pass using the -mllvm option.

Also add a test to make sure it works.

llvm-svn: 331370
2018-05-02 16:42:51 +00:00
Alexey Bataev 6d94410914 [OPENMP] Support C++ member functions in the device constructs.
Added correct emission of the C++ member functions for the device
function when they are used in the device constructs.

llvm-svn: 331365
2018-05-02 15:45:28 +00:00
Malcolm Parsons 099e4b2a92 [analyzer] Fix filename in cross-file HTML report
Summary:
The filename is currently taken from the start of the path, while the
line and column are taken from the end of the path.
This didn't matter until cross-file path reporting was added.

Reviewers: george.karpenkov, dcoughlin, vlad.tsyrklevich

Reviewed By: george.karpenkov, vlad.tsyrklevich

Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D45611

llvm-svn: 331361
2018-05-02 14:26:12 +00:00
Alexey Bataev 18fa2323b6 [OPENMP] Emit names of the globals depending on target.
Some symbols are not allowed to be used as names on some targets. Patch
ries to unify the emission of the names of LLVM globals so they could be
used on different targets.

llvm-svn: 331358
2018-05-02 14:20:50 +00:00
Henry Wong e14e591c93 [analyzer] Add `TaintBugVisitor` to the ArrayBoundV2, DivideZero and VLASize.
Summary: Add `TaintBugVisitor` to the ArrayBoundV2, DivideZero, VLASize to be able to indicate where the taint information originated from.

Reviewers: NoQ, george.karpenkov, xazax.hun, a.sidorin

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, cfe-commits, MTC

Differential Revision: https://reviews.llvm.org/D46007

llvm-svn: 331345
2018-05-02 12:11:22 +00:00
Peter Szecsi ef97252a2c [ASTImporter] Fix isa cast assert
Do early return if we can't import the found decl for a member expr.
This follows the pre-existing scheme, e.g with E->getMemberDecl().
E->getFoundDecl().getDecl() can be null when a member expression does
not involve lookup. It may involve a lookup in case of a using directive
which refers to a member function in a base class template.

We faced this assert during the CTU analysis of google::protobuf v3.5.2.
We tried hard to synthesize a minimal test example both by hand and by
executing creduce on multiple files. Unfortunately, we were unable to reduce
to such a minimal example, yet. Nevertheless, this fix solved the problem in
protobuf.

To reproduce the error one must execute the analyzer with
-Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true -Xclang -analyzer-config -Xclang ctu-dir=/path/to/ctu_dir

Patch by Gabor Marton!

Differential Revision: https://reviews.llvm.org/D46019

llvm-svn: 331344
2018-05-02 11:52:54 +00:00
Bruno Cardoso Lopes 22d97065d3 [Modules] Allow @import to reach submodules in private module maps
A @import targeting a top level module from a private module map file
(@import Foo_Private), would fail if there's any submodule declaration
around (module Foo.SomeSub) in the same private module map.

This happens because compileModuleImpl, when building Foo_Private, will
start with the private module map and will not parse the public one,
which leads to unsuccessful parsing of Foo.SomeSub, since top level Foo
was never parsed.

Declaring other submodules in the private module map is not common and
should usually be avoided, but it shouldn't fail to build. Canonicalize
compileModuleImpl to always look at the public module first, so that all
necessary information is available when parsing the private one.

rdar://problem/39822328

llvm-svn: 331322
2018-05-02 02:25:03 +00:00