Commit Graph

24270 Commits

Author SHA1 Message Date
Mikhail R. Gadelha eac500f0c3 Move the SMT API to LLVM
Moved everything SMT-related to LLVM and updated the cmake scripts.

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

llvm-svn: 353373
2019-02-07 03:19:45 +00:00
Mikhail R. Gadelha 5f16ad9a1b Moved the whole SMT API to a single file. NFC.
There is no advantage in having them in separate files, I doubt some will ever use them separately.

This also makes it easier to move the API to LLVM.

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

llvm-svn: 353372
2019-02-07 03:18:21 +00:00
Mikhail R. Gadelha c1f8cad191 Got rid of the `Z3ConstraintManager` class
Now, instead of passing the reference to a shared_ptr, we pass the shared_ptr instead.

I've also removed the check if Z3 is present in CreateZ3ConstraintManager as this function already calls CreateZ3Solver that performs the exactly same check.

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

llvm-svn: 353371
2019-02-07 03:18:10 +00:00
Mikhail R. Gadelha c9cd507263 Generalised the SMT state constraints
This patch moves the ConstraintSMT definition to the SMTConstraintManager header to make it easier to move the Z3 backend around.

We achieve this by not using shared_ptr  anymore, as llvm::ImmutableSet doesn't seem to like it.

The solver specific exprs and sorts are cached in the Z3Solver object now and we move pointers to those objects around.

As a nice side-effect, SMTConstraintManager doesn't have to be a template anymore. Yay!

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

llvm-svn: 353370
2019-02-07 03:17:36 +00:00
Artem Dergachev 161e4753b9 [analyzer] Canonicalize declarations within variable regions.
Memory region that correspond to a variable is identified by the variable's
declaration and, in case of local variables, the stack frame it belongs to.

The declaration needs to be canonical, otherwise we'd have two different
memory regions that correspond to the same variable.

Fix such bug for global variables with forward declarations and assert
that no other problems of this kind happen.

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

llvm-svn: 353353
2019-02-07 00:30:20 +00:00
Artem Dergachev b7e33f6404 Revert "[analyzer] Remove the "postponed" hack, deal with derived symbols..."
This reverts commit r341722.

The "postponed" mechanism turns out to be necessary in order to handle
situations when a symbolic region is only kept alive by implicit bindings
in the Store. Otherwise the region is never scanned by the Store's worklist
and the binding gets dropped despite being live, as demonstrated
by the newly added tests.

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

llvm-svn: 353350
2019-02-06 23:56:43 +00:00
Heejin Ahn bab8597916 [WebAssembly] Add atomics target option
Reviewers: tlively

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, jfb, cfe-commits

Tags: #clang

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

llvm-svn: 353260
2019-02-06 01:41:26 +00:00
Artem Belevich 4071763bb8 Basic CUDA-10 support.
Differential Revision: https://reviews.llvm.org/D57771

llvm-svn: 353232
2019-02-05 22:38:58 +00:00
Volodymyr Sapsai 421380a108 [Preprocessor] Add a note with framework location for "file not found" error.
When a framework with the same name is available at multiple framework
search paths, we use the first matching location. If a framework at this
location doesn't have all the headers, it can be confusing for
developers because they see only an error `'Foo/Foo.h' file not found`,
can find the complete framework with required header, and don't know the
incomplete framework was used instead.

Add a note explaining a framework without required header was found.
Also mention framework directory path to make it easier to find the
incomplete framework.

rdar://problem/39246514

Reviewers: arphaman, erik.pilkington, jkorous

Reviewed By: jkorous

Subscribers: jkorous, dexonsmith, cfe-commits

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

llvm-svn: 353231
2019-02-05 22:34:55 +00:00
Joe Daniels f7393d2a3e [OBJC] Add attribute to mark Objective C class as non-lazy
A non-lazy class will be initialized eagerly when the Objective-C runtime is
loaded. This is required for certain system classes which have instances allocated in
non-standard ways, such as the classes for blocks and constant strings.
Adding this attribute is essentially equivalent to providing a trivial
+load method but avoids the (fairly small) load-time overheads associated
with defining and calling such a method.

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

llvm-svn: 353116
2019-02-04 23:32:55 +00:00
Kadir Cetinkaya 9e012e8b33 [clang] Add getCommentHandler to PreambleCallbacks
Summary:
Enables users to add comment handlers to preprocessor when building
preambles.

Reviewers: ilya-biryukov, ioeric

Subscribers: cfe-commits

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

llvm-svn: 353030
2019-02-04 09:42:33 +00:00
Sergi Mateo Bellido 31df1adbe9 [OpenMP] Adding support to the mutexinoutset dep-type
Summary: this commit adds support to a new dependence type introduced in OpenMP
5.0. The LLVM OpenMP RTL already supports this feature, so we  only need to
modify CLANG to take advantage of them.


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

llvm-svn: 353018
2019-02-04 07:33:19 +00:00
Bruno Ricci e64aee87a0 [AST] Update the comments of the various Expr::Ignore* + Related cleanups
The description of what the various Expr::Ignore* do has drifted from the
actual implementation.

Inspection reveals that IgnoreParenImpCasts() is not equivalent to doing
IgnoreParens() + IgnoreImpCasts() until reaching a fixed point, but
IgnoreParenCasts() is equivalent to doing IgnoreParens() + IgnoreCasts()
until reaching a fixed point. There is also a fair amount of duplication
in the various Expr::Ignore* functions which increase the chance of further
future inconsistencies. In preparation for the next patch which will factor
out the implementation of the various Expr::Ignore*, do the following cleanups:

Remove Stmt::IgnoreImplicit, in favor of Expr::IgnoreImplicit. IgnoreImplicit
is the only function among all of the Expr::Ignore* which is available in Stmt.
There are only a few users of Stmt::IgnoreImplicit. They can just use instead
Expr::IgnoreImplicit like they have to do for the other Ignore*.

Move Expr::IgnoreImpCasts() from Expr.h to Expr.cpp. This made no difference
in the run-time with my usual benchmark (-fsyntax-only on all of Boost).

While we are at it, make IgnoreParenNoopCasts take a const reference to the
ASTContext for const correctness.

Update the comments to match what the Expr::Ignore* are actually doing.
I am not sure that listing exactly what each Expr::Ignore* do is optimal,
but it certainly looks better than the current state which is in my opinion
between misleading and just plain wrong.

The whole patch is NFC (if you count removing Stmt::IgnoreImplicit as NFC).

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

Reviewed By: aaron.ballman

llvm-svn: 353006
2019-02-03 19:50:56 +00:00
Stephen Kelly c49330152e [AST] Extract ASTNodeTraverser class from ASTDumper
Summary:
This new traverser class allows clients to re-use the traversal logic
which was previously part of ASTDumper.  This means that alternative
visit logic may be implemented, such as

* Dump to alternative data formats such as JSON
* Implement AST Matcher parent/child visitation matching AST dumps

Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

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

llvm-svn: 352989
2019-02-03 14:06:54 +00:00
Philip Pfaffe e3f105c651 [NewPM] Add support for new-PM plugins to clang
Summary:
This adds support for new-PM plugin loading to clang. The option
`-fpass-plugin=` may be used to specify a dynamic shared object file
that adheres to the PassPlugin API.

Tested: created simple plugin that registers an EP callback; with optimization level > 0, the pass is run as expected.

Committed on behalf of Marco Elver

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

llvm-svn: 352972
2019-02-02 23:19:32 +00:00
Akira Hatanaka a50489754a [Sema][ObjC] Allow declaring ObjC pointer members with non-trivial
ownership qualifications in C++ unions under ARC.

An ObjC pointer member with non-trivial ownership qualifications causes
all of the defaulted special functions of the enclosing union to be
defined as deleted, except when the member has an in-class initializer,
the default constructor isn't defined as deleted.

rdar://problem/34213306

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

llvm-svn: 352949
2019-02-02 02:23:40 +00:00
James Y Knight 916db651c8 Remove redundant FunctionDecl argument from a couple functions.
This argument was added in r254554 in order to support the
pass_object_size attribute. However, in r296076, the attribute's
presence is now also represented in FunctionProtoType's
ExtParameterInfo, and thus it's unnecessary to pass along a separate
FunctionDecl.

The functions modified are:
 RequiredArgs::forPrototype{,Plus}, and
 CodeGenTypes::ConvertFunctionType.

After this, it's also (again) unnecessary to have a separate
ConvertFunctionType function ConvertType, so convert callers back to
the latter, leaving the former as an internal helper function.

llvm-svn: 352946
2019-02-02 01:48:23 +00:00
Dan Gohman cae8459ad2 [WebAssembly] Add an import_field function attribute
This is similar to import_module, but sets the import field name
instead.

By default, the import field name is the same as the C/asm/.o symbol
name. However, there are situations where it's useful to have it be
different. For example, suppose I have a wasm API with a module named
"pwsix" and a field named "read". There's no risk of namespace
collisions with user code at the wasm level because the generic name
"read" is qualified by the module name "pwsix". However in the C/asm/.o
namespaces, the module name is not used, so if I have a global function
named "read", it is intruding on the user's namespace.

With the import_field module, I can declare my function (in libc) to be
"__read", and then set the wasm import module to be "pwsix" and the wasm
import field to be "read". So at the C/asm/.o levels, my symbol is
outside the user namespace.

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

llvm-svn: 352930
2019-02-01 22:25:23 +00:00
Eric Fiselier 1147f71fed Improve diagnostic to tell you a type is incomplete.
I recently ran into this code:
```
\#include <iostream>
void foo(const std::string &s, const std::string& = "");
\#include <string>
void test() { foo(""); }
```

The diagnostic produced said it can't bind char[1] to std::string
const&. It didn't mention std::string is incomplete. The user had to
infer that.

This patch causes the diagnostic to now say "incomplete type".

llvm-svn: 352927
2019-02-01 22:06:02 +00:00
Richard Smith 259e1bdfdd Factor out duplication between ExprIterator and ConstExprIterator.
This also exposes a more general iterator cast mechanism suitable for
use in http://reviews.llvm.org/D56571.

llvm-svn: 352925
2019-02-01 21:58:17 +00:00
Eric Fiselier de9ffab1ca Don't use ASTContext in DeclOpenMP.h because it's still incomplete.
llvm-svn: 352919
2019-02-01 21:19:20 +00:00
Michael Kruse 251e1488e1 [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.
This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive, is a new
feature in OpenMP 5.0. It is introduced to extend existing map clauses
for the purpose of simplifying the copy of complex data structures
between host and device (i.e., deep copy). An example is shown below:

    struct S {  int len;  int *d; };
    #pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory region that d points to is also mapped using this mapper.

Contributed-by: Lingda Li <lildmh@gmail.com>

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

llvm-svn: 352906
2019-02-01 20:25:04 +00:00
Serge Guelton 5ef88bdb68 Fix isInSystemMacro to handle pasted macros
Token pasted by the preprocessor (through ##) have a Spelling pointing to scratch buffer.
As a result they are not recognized at system macro, even though the pasting happened in
a system macro. Fix that by looking into the parent macro if the original lookup finds a
scratch buffer.

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

This effectively fixes https://bugs.llvm.org/show_bug.cgi?id=35268,

llvm-svn: 352838
2019-02-01 06:11:44 +00:00
Nico Weber 0abcafd8a4 Make clang/test/Index/pch-from-libclang.c pass in more places
- fixes the test on macOS with LLVM_ENABLE_PIC=OFF
- together with D57343, gets the test to pass on Windows
- makes it run everywhere (it seems to just pass on Linux)

The main change is to pull out the resource directory computation into a
function shared by all 3 places that do it. In CIndexer.cpp, this now works no
matter if libclang is in lib/ or bin/ or statically linked to a binary in bin/.


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

llvm-svn: 352803
2019-01-31 22:15:32 +00:00
Artem Belevich c62214da3d [CUDA] add support for the new kernel launch API in CUDA-9.2+.
Instead of calling CUDA runtime to arrange function arguments,
the new API constructs arguments in a local array and the kernels
are launched with __cudaLaunchKernel().

The old API has been deprecated and is expected to go away
in the next CUDA release.

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

llvm-svn: 352799
2019-01-31 21:34:03 +00:00
Artem Belevich 8fa28a0db0 [CUDA] Propagate detected version of CUDA to cc1
..and use it to control that parts of CUDA compilation
that depend on the specific version of CUDA SDK.

This patch has a placeholder for a 'new launch API' support
which is in a separate patch. The list will be further
extended in the upcoming patch to support CUDA-10.1.

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

llvm-svn: 352798
2019-01-31 21:32:24 +00:00
Thomas Lively 88058d4e1e [WebAssembly] Add bulk memory target feature
Summary: Also clean up some preexisting target feature code.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb

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

llvm-svn: 352793
2019-01-31 21:02:19 +00:00
Ilya Biryukov 4f9543b4d6 [CodeComplete] Propagate preferred types through parser in more cases
Preferred types are used by code completion for ranking. This commit
considerably increases the number of points in code where those types
are propagated.

In order to avoid complicating signatures of Parser's methods, a
preferred type is kept as a member variable in the parser and updated
during parsing.

Differential revision: https://reviews.llvm.org/D56723

llvm-svn: 352788
2019-01-31 20:20:32 +00:00
Kristof Umann 01c4939658 [analyzer] Make NullReturnedFromNonnullChecker depend on NullabilityBase
Accidentally left this dependency out after D54438.

llvm-svn: 352693
2019-01-30 23:48:37 +00:00
Erik Pilkington 28a892b972 Don't define __has_feature(objc_fixed_enum) in non-objc mode
This is only a formal language feature in ObjC, otherwise its just an
extension. Making this change was also an ABI break.

llvm-svn: 352672
2019-01-30 21:14:08 +00:00
Erik Pilkington 9c3b588db9 Add a new builtin: __builtin_dynamic_object_size
This builtin has the same UI as __builtin_object_size, but has the
potential to be evaluated dynamically. It is meant to be used as a
drop-in replacement for libraries that use __builtin_object_size when
a dynamic checking mode is enabled. For instance,
__builtin_object_size fails to provide any extra checking in the
following function:

  void f(size_t alloc) {
    char* p = malloc(alloc);
    strcpy(p, "foobar"); // expands to __builtin___strcpy_chk(p, "foobar", __builtin_object_size(p, 0))
  }

This is an overflow if alloc < 7, but because LLVM can't fold the
object size intrinsic statically, it folds __builtin_object_size to
-1. With __builtin_dynamic_object_size, alloc is passed through to
__builtin___strcpy_chk.

rdar://32212419

Differential revision: https://reviews.llvm.org/D56760

llvm-svn: 352665
2019-01-30 20:34:53 +00:00
Stephen Kelly b6318c923e [ASTDump] Move Decl node dumping to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

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

llvm-svn: 352655
2019-01-30 19:32:48 +00:00
Yaxun Liu 95f2ca541f [HIP] Fix size_t for MSVC environment
In 64 bit MSVC environment size_t is defined as unsigned long long.
In single source language like HIP, data layout should be consistent
in device and host compilation, therefore copy data layout controlling
fields from Aux target for AMDGPU target.

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

llvm-svn: 352620
2019-01-30 12:26:54 +00:00
George Karpenkov 77eae6d4c4 [analyzer] [RetainCountChecker] Bugfix for tracking top-level parameters of Objective-C methods
Differential Revision: https://reviews.llvm.org/D57433

llvm-svn: 352588
2019-01-30 02:11:04 +00:00
Stephen Kelly aecce85da6 NFC: Move GenericSelectionExpr dump to NodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 352558
2019-01-29 22:58:28 +00:00
Stephen Kelly fbf40f4500 NFC: Implement GenericSelectionExpr::Association dump with Visitor
Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 352552
2019-01-29 22:22:55 +00:00
Aaron Puchert ffa1d6ad17 Thread safety analysis: Improve diagnostics for double locking
Summary:
We use the existing diag::note_locked_here to tell the user where we saw
the first locking.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 352549
2019-01-29 22:11:42 +00:00
Matt Arsenault 58fc8082a8 OpenCL: Use length modifier for warning on vector printf arguments
Re-enable format string warnings on printf.

The warnings are still incomplete. Apparently it is undefined to use a
vector specifier without a length modifier, which is not currently
warned on. Additionally, type warnings appear to not be working with
the hh modifier, and aren't warning on all of the special restrictions
from c99 printf.

llvm-svn: 352540
2019-01-29 20:49:54 +00:00
George Karpenkov d37ff4e888 [analyzer] [RetainCountChecker] Track input parameters to the top-level function
Track them for ISL/OS objects by default, and for NS/CF under a flag.

rdar://47536377

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

llvm-svn: 352534
2019-01-29 19:29:59 +00:00
George Karpenkov b0fc58b57c [analyzer] [RetainSummaryManager] [NFC] Split one function into two, as it's really doing two things
Differential Revision: https://reviews.llvm.org/D57201

llvm-svn: 352533
2019-01-29 19:29:45 +00:00
George Karpenkov 2e46667853 [analyzer] [ARCMT] [NFC] Unify entry point into RetainSummaryManager
Just use one single entry point, since we have AnyCall utility now.

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

llvm-svn: 352532
2019-01-29 19:29:33 +00:00
George Karpenkov 38bc347ff5 Extend AnyCall to handle callable declarations without the call expressions
That weakens inner invariants, but allows the class to be more generic,
allowing usage in situations where the call expression is not known (or
should not matter).

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

llvm-svn: 352531
2019-01-29 19:29:19 +00:00
Sterling Augustine 5be3dbdb08 Rollback unwindlib patch.
llvm-svn: 352524
2019-01-29 18:27:51 +00:00
Bruno Ricci 1ec7fd35ce Re-commit "[AST] Introduce GenericSelectionExpr::Association"
This time with a fix to make gcc 4.8 happy.

llvm-svn: 352486
2019-01-29 12:57:11 +00:00
Sam Parker 015f97db8b [AArch64] Update int64_t ACLE builtin arguments
Re-applying r351740 with fixes (changing LL to W).

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

llvm-svn: 352463
2019-01-29 09:04:03 +00:00
Matt Arsenault b72888647b AMDGPU: Add ds append/consume builtins
llvm-svn: 352443
2019-01-28 23:59:18 +00:00
Sterling Augustine 31e2acc3b5 Correct help text for --unwindlib options.
llvm-svn: 352405
2019-01-28 18:56:44 +00:00
Sterling Augustine 9490fcc191 Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib=
Summary:
"clang++ hello.cc --rtlib=compiler-rt"

now works without specifying additional unwind or exception
handling libraries.

Reviewers: rsmith

Subscribers: srhines, dberris, aheejin, llvm-commits

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

llvm-svn: 352404
2019-01-28 18:56:43 +00:00
Bruno Ricci 586d949b9c Revert "[AST] Introduce GenericSelectionExpr::Association"
This breaks GCC 4.8.4. Reported by email by Hans Wennborg.

llvm-svn: 352403
2019-01-28 18:40:26 +00:00
Scott Linder bef2663751 Add -fapply-global-visibility-to-externs for -cc1
Introduce an option to request global visibility settings be applied to
declarations without a definition or an explicit visibility, rather than
the existing behavior of giving these default visibility. When the
visibility of all or most extern definitions are known this allows for
the same optimisations -fvisibility permits without updating source code
to annotate all declarations.

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

llvm-svn: 352391
2019-01-28 17:12:19 +00:00